duoyun-ui 2.2.2 → 2.2.8
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.
- package/elements/badge.d.ts +2 -16
- package/elements/badge.d.ts.map +1 -1
- package/elements/badge.js +4 -158
- package/elements/badge.js.map +1 -1
- package/elements/banner.d.ts +2 -17
- package/elements/banner.d.ts.map +1 -1
- package/elements/banner.js +4 -127
- package/elements/banner.js.map +1 -1
- package/elements/base/chart.d.ts +2 -2
- package/elements/base/resize.d.ts +1 -22
- package/elements/base/resize.d.ts.map +1 -1
- package/elements/base/resize.js +1 -95
- package/elements/base/resize.js.map +1 -1
- package/elements/base/scroll.d.ts +1 -8
- package/elements/base/scroll.d.ts.map +1 -1
- package/elements/base/scroll.js +1 -158
- package/elements/base/scroll.js.map +1 -1
- package/elements/base/visible.d.ts +1 -18
- package/elements/base/visible.d.ts.map +1 -1
- package/elements/base/visible.js +1 -112
- package/elements/base/visible.js.map +1 -1
- package/elements/button.d.ts +2 -24
- package/elements/button.d.ts.map +1 -1
- package/elements/button.js +7 -287
- package/elements/button.js.map +1 -1
- package/elements/checkbox.d.ts +3 -21
- package/elements/checkbox.d.ts.map +1 -1
- package/elements/checkbox.js +6 -180
- package/elements/checkbox.js.map +1 -1
- package/elements/code-block.d.ts +2 -7
- package/elements/code-block.d.ts.map +1 -1
- package/elements/code-block.js +4 -432
- package/elements/code-block.js.map +1 -1
- package/elements/collapse.d.ts +3 -29
- package/elements/collapse.d.ts.map +1 -1
- package/elements/collapse.js +6 -197
- package/elements/collapse.js.map +1 -1
- package/elements/compartment.d.ts +2 -5
- package/elements/compartment.d.ts.map +1 -1
- package/elements/compartment.js +4 -23
- package/elements/compartment.js.map +1 -1
- package/elements/contextmenu.d.ts +5 -42
- package/elements/contextmenu.d.ts.map +1 -1
- package/elements/contextmenu.js +8 -285
- package/elements/contextmenu.js.map +1 -1
- package/elements/countdown.d.ts +2 -12
- package/elements/countdown.d.ts.map +1 -1
- package/elements/countdown.js +4 -94
- package/elements/countdown.js.map +1 -1
- package/elements/divider.d.ts +2 -8
- package/elements/divider.d.ts.map +1 -1
- package/elements/divider.js +4 -129
- package/elements/divider.js.map +1 -1
- package/elements/empty.d.ts +2 -8
- package/elements/empty.d.ts.map +1 -1
- package/elements/empty.js +4 -59
- package/elements/empty.js.map +1 -1
- package/elements/grouped-picker.d.ts +29 -0
- package/elements/grouped-picker.d.ts.map +1 -0
- package/elements/grouped-picker.js +199 -0
- package/elements/grouped-picker.js.map +1 -0
- package/elements/input.d.ts +4 -36
- package/elements/input.d.ts.map +1 -1
- package/elements/input.js +6 -489
- package/elements/input.js.map +1 -1
- package/elements/letters.d.ts +4 -0
- package/elements/letters.d.ts.map +1 -0
- package/elements/letters.js +56 -0
- package/elements/letters.js.map +1 -0
- package/elements/link.d.ts +3 -5
- package/elements/link.d.ts.map +1 -1
- package/elements/link.js +6 -38
- package/elements/link.js.map +1 -1
- package/elements/list.d.ts +5 -58
- package/elements/list.d.ts.map +1 -1
- package/elements/list.js +19 -664
- package/elements/list.js.map +1 -1
- package/elements/modal.d.ts +5 -63
- package/elements/modal.d.ts.map +1 -1
- package/elements/modal.js +13 -411
- package/elements/modal.js.map +1 -1
- package/elements/options.d.ts +4 -32
- package/elements/options.d.ts.map +1 -1
- package/elements/options.js +5 -254
- package/elements/options.js.map +1 -1
- package/elements/page-loadbar.js +1 -1
- package/elements/paragraph.d.ts +2 -2
- package/elements/paragraph.d.ts.map +1 -1
- package/elements/paragraph.js +4 -45
- package/elements/paragraph.js.map +1 -1
- package/elements/placeholder.d.ts +2 -14
- package/elements/placeholder.d.ts.map +1 -1
- package/elements/placeholder.js +4 -114
- package/elements/placeholder.js.map +1 -1
- package/elements/radio.d.ts +5 -24
- package/elements/radio.d.ts.map +1 -1
- package/elements/radio.js +7 -165
- package/elements/radio.js.map +1 -1
- package/elements/rate.d.ts +2 -12
- package/elements/rate.d.ts.map +1 -1
- package/elements/rate.js +4 -142
- package/elements/rate.js.map +1 -1
- package/elements/rolling-number.d.ts +4 -0
- package/elements/rolling-number.d.ts.map +1 -0
- package/elements/rolling-number.js +56 -0
- package/elements/rolling-number.js.map +1 -0
- package/elements/scroll-box.d.ts +2 -2
- package/elements/scroll-box.d.ts.map +1 -1
- package/elements/scroll-box.js +4 -5
- package/elements/scroll-box.js.map +1 -1
- package/elements/segmented.d.ts +3 -20
- package/elements/segmented.d.ts.map +1 -1
- package/elements/segmented.js +4 -191
- package/elements/segmented.js.map +1 -1
- package/elements/slider.d.ts +2 -20
- package/elements/slider.d.ts.map +1 -1
- package/elements/slider.js +4 -261
- package/elements/slider.js.map +1 -1
- package/elements/sort-box.d.ts +1 -2
- package/elements/sort-box.d.ts.map +1 -1
- package/elements/sort-box.js +4 -15
- package/elements/sort-box.js.map +1 -1
- package/elements/space.d.ts +2 -4
- package/elements/space.d.ts.map +1 -1
- package/elements/space.js +4 -37
- package/elements/space.js.map +1 -1
- package/elements/switch.d.ts +2 -11
- package/elements/switch.d.ts.map +1 -1
- package/elements/switch.js +5 -134
- package/elements/switch.js.map +1 -1
- package/elements/tag.d.ts +3 -16
- package/elements/tag.d.ts.map +1 -1
- package/elements/tag.js +4 -133
- package/elements/tag.js.map +1 -1
- package/elements/timeline.d.ts.map +1 -1
- package/elements/timeline.js +0 -1
- package/elements/timeline.js.map +1 -1
- package/elements/toast.js +1 -1
- package/elements/wait.js +1 -1
- package/helper/error.js +2 -39
- package/helper/error.js.map +1 -1
- package/helper/webapp.d.ts +4 -5
- package/helper/webapp.d.ts.map +1 -1
- package/helper/webapp.js +5 -11
- package/helper/webapp.js.map +1 -1
- package/lib/animations.d.ts +1 -10
- package/lib/animations.d.ts.map +1 -1
- package/lib/animations.js +1 -29
- package/lib/animations.js.map +1 -1
- package/lib/cache.d.ts +1 -18
- package/lib/cache.d.ts.map +1 -1
- package/lib/cache.js +1 -62
- package/lib/cache.js.map +1 -1
- package/lib/color.d.ts +1 -37
- package/lib/color.d.ts.map +1 -1
- package/lib/color.js +1 -98
- package/lib/color.js.map +1 -1
- package/lib/decorators.d.ts +2 -0
- package/lib/decorators.d.ts.map +1 -0
- package/lib/decorators.js +2 -0
- package/lib/decorators.js.map +1 -0
- package/lib/easing.d.ts +2 -0
- package/lib/easing.d.ts.map +1 -0
- package/lib/easing.js +2 -0
- package/lib/easing.js.map +1 -0
- package/lib/element.d.ts +1 -18
- package/lib/element.d.ts.map +1 -1
- package/lib/element.js +1 -131
- package/lib/element.js.map +1 -1
- package/lib/encode.d.ts +1 -10
- package/lib/encode.d.ts.map +1 -1
- package/lib/encode.js +1 -48
- package/lib/encode.js.map +1 -1
- package/lib/hotkeys.d.ts +1 -43
- package/lib/hotkeys.d.ts.map +1 -1
- package/lib/hotkeys.js +1 -247
- package/lib/hotkeys.js.map +1 -1
- package/lib/icons.d.ts +1 -114
- package/lib/icons.d.ts.map +1 -1
- package/lib/icons.js +1 -90
- package/lib/icons.js.map +1 -1
- package/lib/image.d.ts +1 -39
- package/lib/image.d.ts.map +1 -1
- package/lib/image.js +1 -140
- package/lib/image.js.map +1 -1
- package/lib/locale.d.ts +1 -87
- package/lib/locale.d.ts.map +1 -1
- package/lib/locale.js +1 -8
- package/lib/locale.js.map +1 -1
- package/lib/map.d.ts +1 -8
- package/lib/map.d.ts.map +1 -1
- package/lib/map.js +1 -31
- package/lib/map.js.map +1 -1
- package/lib/number.d.ts +1 -94
- package/lib/number.d.ts.map +1 -1
- package/lib/number.js +1 -169
- package/lib/number.js.map +1 -1
- package/lib/patterns.d.ts +1 -9
- package/lib/patterns.d.ts.map +1 -1
- package/lib/patterns.js +1 -11
- package/lib/patterns.js.map +1 -1
- package/lib/styles.d.ts +1 -4
- package/lib/styles.d.ts.map +1 -1
- package/lib/styles.js +1 -28
- package/lib/styles.js.map +1 -1
- package/lib/theme.d.ts +1 -85
- package/lib/theme.d.ts.map +1 -1
- package/lib/theme.js +6 -70
- package/lib/theme.js.map +1 -1
- package/lib/time.d.ts +1 -81
- package/lib/time.d.ts.map +1 -1
- package/lib/time.js +1 -255
- package/lib/time.js.map +1 -1
- package/lib/timer.d.ts +1 -25
- package/lib/timer.d.ts.map +1 -1
- package/lib/timer.js +1 -106
- package/lib/timer.js.map +1 -1
- package/lib/types.d.ts +1 -13
- package/lib/types.d.ts.map +1 -1
- package/lib/types.js +1 -16
- package/lib/types.js.map +1 -1
- package/lib/utils.d.ts +1 -79
- package/lib/utils.d.ts.map +1 -1
- package/lib/utils.js +1 -240
- package/lib/utils.js.map +1 -1
- package/locales/en.d.ts +1 -37
- package/locales/en.d.ts.map +1 -1
- package/locales/en.js +1 -36
- package/locales/en.js.map +1 -1
- package/locales/zh.d.ts +1 -3
- package/locales/zh.d.ts.map +1 -1
- package/locales/zh.js +1 -37
- package/locales/zh.js.map +1 -1
- package/package.json +4 -6
- package/patterns/console.d.ts +1 -1
- package/patterns/form.d.ts +5 -3
- package/patterns/form.d.ts.map +1 -1
- package/patterns/form.js +18 -5
- package/patterns/form.js.map +1 -1
- package/react/DyBadge.d.ts +1 -9
- package/react/DyBadge.js +1 -1
- package/react/DyBanner.d.ts +1 -6
- package/react/DyBanner.js +1 -1
- package/react/DyButton.d.ts +1 -15
- package/react/DyButton.js +1 -1
- package/react/DyCheckbox.d.ts +1 -7
- package/react/DyCheckbox.js +1 -1
- package/react/DyCheckboxGroup.d.ts +1 -7
- package/react/DyCheckboxGroup.js +1 -1
- package/react/DyCoachMark.d.ts +0 -5
- package/react/DyCoachMark.js +1 -1
- package/react/DyCodeBlock.d.ts +1 -5
- package/react/DyCodeBlock.js +1 -1
- package/react/DyCollapse.d.ts +1 -5
- package/react/DyCollapse.js +1 -1
- package/react/DyCollapsePanel.d.ts +1 -6
- package/react/DyCollapsePanel.js +1 -1
- package/react/DyCompartment.d.ts +1 -3
- package/react/DyCompartment.js +1 -1
- package/react/DyCountdown.d.ts +1 -5
- package/react/DyCountdown.js +1 -1
- package/react/DyDivider.d.ts +1 -6
- package/react/DyDivider.js +1 -1
- package/react/DyDrawer.d.ts +1 -21
- package/react/DyDrawer.js +1 -1
- package/react/DyEmpty.d.ts +1 -5
- package/react/DyEmpty.js +1 -1
- package/react/DyGroupedPicker.d.ts +27 -0
- package/react/DyGroupedPicker.js +22 -0
- package/react/DyInput.d.ts +1 -22
- package/react/DyInput.js +1 -1
- package/react/DyLegend.d.ts +0 -4
- package/react/DyLegend.js +1 -1
- package/react/DyLetters.d.ts +15 -0
- package/react/{DyListOutside.js → DyLetters.js} +4 -4
- package/react/DyList.d.ts +0 -13
- package/react/DyList.js +1 -1
- package/react/DyOptions.d.ts +1 -5
- package/react/DyOptions.js +1 -1
- package/react/DyPatForm.d.ts +1 -0
- package/react/DyPlaceholder.d.ts +1 -10
- package/react/DyPlaceholder.js +1 -1
- package/react/DyRadio.d.ts +1 -6
- package/react/DyRadio.js +1 -1
- package/react/DyRadioGroup.d.ts +1 -7
- package/react/DyRadioGroup.js +1 -1
- package/react/DyRate.d.ts +1 -7
- package/react/DyRate.js +1 -1
- package/react/DyRollingNumber.d.ts +15 -0
- package/react/{DyListItem.js → DyRollingNumber.js} +5 -5
- package/react/DySegmented.d.ts +1 -8
- package/react/DySegmented.js +1 -1
- package/react/DySlider.d.ts +1 -12
- package/react/DySlider.js +1 -1
- package/react/DySortItem.d.ts +1 -3
- package/react/DySortItem.js +1 -1
- package/react/DySpace.d.ts +1 -4
- package/react/DySpace.js +1 -1
- package/react/DySwitch.d.ts +1 -7
- package/react/DySwitch.js +1 -1
- package/react/DyTag.d.ts +1 -9
- package/react/DyTag.js +1 -1
- package/svelte/badge.d.ts +0 -8
- package/svelte/banner.d.ts +0 -5
- package/svelte/button.d.ts +0 -14
- package/svelte/checkbox.d.ts +0 -6
- package/svelte/coach-mark.d.ts +0 -5
- package/svelte/code-block.d.ts +0 -4
- package/svelte/collapse.d.ts +0 -4
- package/svelte/compartment.d.ts +0 -2
- package/svelte/countdown.d.ts +0 -4
- package/svelte/divider.d.ts +0 -5
- package/svelte/drawer.d.ts +0 -20
- package/svelte/empty.d.ts +0 -4
- package/svelte/grouped-picker.d.ts +19 -0
- package/svelte/grouped-picker.js +2 -0
- package/svelte/legend.d.ts +0 -4
- package/svelte/letters.d.ts +9 -0
- package/svelte/letters.js +2 -0
- package/svelte/list.d.ts +4 -11
- package/svelte/options.d.ts +0 -4
- package/svelte/pat-form.d.ts +1 -0
- package/svelte/placeholder.d.ts +0 -9
- package/svelte/radio.d.ts +0 -6
- package/svelte/rate.d.ts +0 -6
- package/svelte/rolling-number.d.ts +9 -0
- package/svelte/rolling-number.js +2 -0
- package/svelte/segmented.d.ts +0 -7
- package/svelte/slider.d.ts +0 -11
- package/svelte/space.d.ts +0 -3
- package/svelte/switch.d.ts +0 -6
- package/svelte/tag.d.ts +0 -8
- package/vue/DyBadge.vue +2 -8
- package/vue/DyBanner.vue +4 -6
- package/vue/DyButton.vue +2 -14
- package/vue/DyCheckbox.vue +4 -7
- package/vue/DyCheckboxGroup.vue +4 -7
- package/vue/DyCoachMark.vue +4 -8
- package/vue/DyCodeBlock.vue +2 -4
- package/vue/DyCollapse.vue +2 -4
- package/vue/DyCollapsePanel.vue +4 -6
- package/vue/DyCompartment.vue +2 -2
- package/vue/DyCountdown.vue +4 -5
- package/vue/DyDivider.vue +2 -5
- package/vue/DyDrawer.vue +4 -21
- package/vue/DyEmpty.vue +2 -4
- package/vue/DyGroupedPicker.vue +53 -0
- package/vue/DyInput.vue +4 -22
- package/vue/DyLegend.vue +2 -6
- package/vue/{DyListOutside.vue → DyLetters.vue} +8 -8
- package/vue/DyList.vue +4 -16
- package/vue/DyOptions.vue +2 -4
- package/vue/DyPatForm.vue +2 -2
- package/vue/DyPlaceholder.vue +2 -9
- package/vue/DyRadio.vue +4 -6
- package/vue/DyRadioGroup.vue +4 -7
- package/vue/DyRate.vue +4 -7
- package/vue/DyRollingNumber.vue +42 -0
- package/vue/DySegmented.vue +4 -8
- package/vue/DySlider.vue +4 -12
- package/vue/DySortItem.vue +2 -2
- package/vue/DySpace.vue +2 -3
- package/vue/DySwitch.vue +4 -7
- package/vue/DyTag.vue +4 -9
- package/elements/flow.d.ts +0 -52
- package/elements/flow.d.ts.map +0 -1
- package/elements/flow.js +0 -703
- package/elements/flow.js.map +0 -1
- package/elements/map.d.ts +0 -48
- package/elements/map.d.ts.map +0 -1
- package/elements/map.js +0 -396
- package/elements/map.js.map +0 -1
- package/react/DyFlow.d.ts +0 -24
- package/react/DyFlow.js +0 -18
- package/react/DyFlowCanvas.d.ts +0 -29
- package/react/DyFlowCanvas.js +0 -18
- package/react/DyListItem.d.ts +0 -24
- package/react/DyListOutside.d.ts +0 -15
- package/react/DyMap.d.ts +0 -32
- package/react/DyMap.js +0 -18
- package/svelte/flow.d.ts +0 -18
- package/svelte/flow.js +0 -2
- package/svelte/map.d.ts +0 -26
- package/svelte/map.js +0 -2
- package/vue/DyFlow.vue +0 -49
- package/vue/DyFlowCanvas.vue +0 -53
- package/vue/DyListItem.vue +0 -48
- package/vue/DyMap.vue +0 -56
package/lib/image.js
CHANGED
|
@@ -1,141 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
import { hslToRgb, luminance, parseHexColor, rgbToHexColor } from './color';
|
|
3
|
-
import { fnv1a } from './encode';
|
|
4
|
-
import { normalizeNumber, pseudoRandom } from './number';
|
|
5
|
-
export function createCanvas(width, height) {
|
|
6
|
-
const canvas = document.createElement('canvas');
|
|
7
|
-
if (width) {
|
|
8
|
-
canvas.width = width;
|
|
9
|
-
canvas.height = height || width;
|
|
10
|
-
}
|
|
11
|
-
return canvas;
|
|
12
|
-
}
|
|
13
|
-
export function createDataURLFromSVG(rawStr) {
|
|
14
|
-
return `data:image/svg+xml;base64,${btoa(rawStr)}`;
|
|
15
|
-
}
|
|
16
|
-
// if `bg` is't `HexColor`, text fill color error
|
|
17
|
-
/**Create SVG according to the text */
|
|
18
|
-
export function createSVGFromText(text, options = {}) {
|
|
19
|
-
const genRandom = pseudoRandom(fnv1a(text));
|
|
20
|
-
const random = () => normalizeNumber(genRandom());
|
|
21
|
-
const hslRange = [
|
|
22
|
-
[0, 1],
|
|
23
|
-
[0.2, 0.7],
|
|
24
|
-
[0.3, 0.6],
|
|
25
|
-
];
|
|
26
|
-
const rgb = options.color
|
|
27
|
-
? parseHexColor(options.color)
|
|
28
|
-
: options.colors
|
|
29
|
-
? parseHexColor(options.colors[Math.floor(random() * options.colors.length)])
|
|
30
|
-
: hslToRgb(Array.from({ length: 3 }, (_, i) => {
|
|
31
|
-
const total = Math.floor(random() * 256) / 255;
|
|
32
|
-
return hslRange[i][0] + total * (hslRange[i][1] - hslRange[i][0]);
|
|
33
|
-
}));
|
|
34
|
-
const bg = rgbToHexColor(rgb);
|
|
35
|
-
const color = luminance(rgb) < 0.2 ? '#fff4' : '#0004';
|
|
36
|
-
const getTranslate = () => options.translate ?? [random() / 5, random() / 5];
|
|
37
|
-
const getRotate = () => options.rotate ?? (random() - 0.5) * 45;
|
|
38
|
-
const strings = [...text].slice(0, options?.showLen || 1).map((char) => `<text
|
|
39
|
-
x="50%"
|
|
40
|
-
y="50%"
|
|
41
|
-
dominant-baseline="central"
|
|
42
|
-
text-anchor="middle"
|
|
43
|
-
transform-origin="center"
|
|
44
|
-
transform="translate(${getTranslate().join()}) rotate(${getRotate()})"
|
|
45
|
-
>${char}</text>`);
|
|
46
|
-
return raw `
|
|
47
|
-
<svg
|
|
48
|
-
xmlns="http://www.w3.org/2000/svg"
|
|
49
|
-
width="300"
|
|
50
|
-
height="300"
|
|
51
|
-
viewBox="0 0 1 1"
|
|
52
|
-
style="background: ${bg}; fill: ${color}; font: 1px sans-serif">
|
|
53
|
-
${strings.join('')}
|
|
54
|
-
</svg>
|
|
55
|
-
`;
|
|
56
|
-
}
|
|
57
|
-
export async function createBitmapFromSvg(svg, { width = 512, height = 512, type, quality } = {}) {
|
|
58
|
-
const img = new Image();
|
|
59
|
-
const canvas = createCanvas(width, height);
|
|
60
|
-
const ctx = canvas.getContext('2d');
|
|
61
|
-
if (!ctx)
|
|
62
|
-
throw new Error('ctx is null');
|
|
63
|
-
img.src = createDataURLFromSVG(svg);
|
|
64
|
-
await new Promise((res) => {
|
|
65
|
-
img.onload = () => {
|
|
66
|
-
ctx.drawImage(img, 0, 0, width, height);
|
|
67
|
-
res(null);
|
|
68
|
-
};
|
|
69
|
-
});
|
|
70
|
-
return new Promise((res) => {
|
|
71
|
-
canvas.toBlob((b) => {
|
|
72
|
-
if (!b)
|
|
73
|
-
throw new Error();
|
|
74
|
-
res(new File([b], '', { type: b.type }));
|
|
75
|
-
}, type, quality);
|
|
76
|
-
});
|
|
77
|
-
}
|
|
78
|
-
export function createDataURLFromBlob(blob) {
|
|
79
|
-
const reader = new FileReader();
|
|
80
|
-
return new Promise((res) => {
|
|
81
|
-
reader.addEventListener('load', () => {
|
|
82
|
-
res(reader.result);
|
|
83
|
-
}, false);
|
|
84
|
-
reader.readAsDataURL(blob);
|
|
85
|
-
});
|
|
86
|
-
}
|
|
87
|
-
export async function compressionImage(origin, limit, { aspectRatio, type } = {}) {
|
|
88
|
-
const originIsFile = origin instanceof Blob;
|
|
89
|
-
const outputDataURL = type === 'url';
|
|
90
|
-
const canvas = createCanvas();
|
|
91
|
-
let img = new Image();
|
|
92
|
-
let file = new File([], '');
|
|
93
|
-
const loadImg = async () => {
|
|
94
|
-
await new Promise((res, rej) => {
|
|
95
|
-
img.onload = res;
|
|
96
|
-
img.onerror = rej;
|
|
97
|
-
});
|
|
98
|
-
};
|
|
99
|
-
if (originIsFile) {
|
|
100
|
-
img.crossOrigin = 'anonymous';
|
|
101
|
-
img.src = await createDataURLFromBlob(origin);
|
|
102
|
-
await loadImg();
|
|
103
|
-
file = origin;
|
|
104
|
-
}
|
|
105
|
-
else {
|
|
106
|
-
img = origin;
|
|
107
|
-
if (!img.complete)
|
|
108
|
-
await loadImg();
|
|
109
|
-
if (limit.fileSize) {
|
|
110
|
-
const res = await fetch(origin.currentSrc);
|
|
111
|
-
const blob = await res.blob();
|
|
112
|
-
const contentType = res.headers.get('content-type');
|
|
113
|
-
file = new File([blob], 'temp', { type: contentType?.startsWith('image/') ? contentType : origin.type || '' });
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
const rate = Math.min(limit.fileSize ? Math.sqrt(limit.fileSize / file.size) : 1, limit.dimension ? limit.dimension.width / img.naturalWidth : 1, limit.dimension ? limit.dimension.height / img.naturalHeight : 1);
|
|
117
|
-
if (rate >= 1) {
|
|
118
|
-
return Promise.resolve(outputDataURL ? img.currentSrc : file);
|
|
119
|
-
}
|
|
120
|
-
const naturalAspectRatio = img.naturalWidth / img.naturalHeight;
|
|
121
|
-
aspectRatio = aspectRatio || naturalAspectRatio;
|
|
122
|
-
const widthRatio = aspectRatio > naturalAspectRatio ? 1 : aspectRatio / naturalAspectRatio;
|
|
123
|
-
const heightRatio = aspectRatio > naturalAspectRatio ? naturalAspectRatio / aspectRatio : 1;
|
|
124
|
-
const width = img.naturalWidth * rate;
|
|
125
|
-
const height = img.naturalHeight * rate;
|
|
126
|
-
canvas.width = width * widthRatio;
|
|
127
|
-
canvas.height = height * heightRatio;
|
|
128
|
-
const ctx = canvas.getContext('2d');
|
|
129
|
-
if (!ctx)
|
|
130
|
-
throw new Error('ctx is null');
|
|
131
|
-
ctx.imageSmoothingQuality = 'high';
|
|
132
|
-
ctx.drawImage(img, (canvas.width - width) / 2, (canvas.height - height) / 2, width, height);
|
|
133
|
-
if (outputDataURL)
|
|
134
|
-
return Promise.resolve(canvas.toDataURL());
|
|
135
|
-
return new Promise((res, rej) => canvas.toBlob((blob) => {
|
|
136
|
-
if (!blob)
|
|
137
|
-
return rej();
|
|
138
|
-
res(new File([blob], 'compressed', { type: blob.type }));
|
|
139
|
-
}));
|
|
140
|
-
}
|
|
1
|
+
export * from '@mantou/tap-ui/lib/image';
|
|
141
2
|
//# sourceMappingURL=image.js.map
|
package/lib/image.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"image.js","sourceRoot":"","sources":["../src/lib/image.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"image.js","sourceRoot":"","sources":["../src/lib/image.ts"],"names":[],"mappings":"AAAA,cAAc,0BAA0B,CAAC"}
|
package/lib/locale.d.ts
CHANGED
|
@@ -1,88 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
export declare const locale: ((value?: Partial<{
|
|
3
|
-
localeCode: string;
|
|
4
|
-
year: string;
|
|
5
|
-
month: string;
|
|
6
|
-
week: string;
|
|
7
|
-
day: string;
|
|
8
|
-
hour: string;
|
|
9
|
-
minute: string;
|
|
10
|
-
second: string;
|
|
11
|
-
millisecond: string;
|
|
12
|
-
thousand: string;
|
|
13
|
-
million: string;
|
|
14
|
-
billion: string;
|
|
15
|
-
trillion: string;
|
|
16
|
-
copySuccess: string;
|
|
17
|
-
copyFail: string;
|
|
18
|
-
add: string;
|
|
19
|
-
remove: string;
|
|
20
|
-
search: string;
|
|
21
|
-
filter: string;
|
|
22
|
-
loading: string;
|
|
23
|
-
ok: string;
|
|
24
|
-
cancel: string;
|
|
25
|
-
prevPage: string;
|
|
26
|
-
nextPage: string;
|
|
27
|
-
perPage: string;
|
|
28
|
-
noData: string;
|
|
29
|
-
more: string;
|
|
30
|
-
less: string;
|
|
31
|
-
nextTour: string;
|
|
32
|
-
skipTour: string;
|
|
33
|
-
finishTour: string;
|
|
34
|
-
currentOfTotal: string;
|
|
35
|
-
requiredMeg: string;
|
|
36
|
-
patternMsg: string;
|
|
37
|
-
}> | undefined) => void) & Omit<{
|
|
38
|
-
name: never;
|
|
39
|
-
apply: never;
|
|
40
|
-
call: never;
|
|
41
|
-
bind: never;
|
|
42
|
-
toString: never;
|
|
43
|
-
prototype: never;
|
|
44
|
-
length: never;
|
|
45
|
-
arguments: never;
|
|
46
|
-
caller: never;
|
|
47
|
-
[Symbol.hasInstance]: never;
|
|
48
|
-
[Symbol.metadata]: never;
|
|
49
|
-
}, "search" | "filter" | "cancel" | "remove" | "loading" | "more" | "add" | "localeCode" | "year" | "month" | "week" | "day" | "hour" | "minute" | "second" | "millisecond" | "thousand" | "million" | "billion" | "trillion" | "copySuccess" | "copyFail" | "ok" | "prevPage" | "nextPage" | "perPage" | "noData" | "less" | "nextTour" | "skipTour" | "finishTour" | "currentOfTotal" | "requiredMeg" | "patternMsg"> & {
|
|
50
|
-
localeCode: string;
|
|
51
|
-
year: string;
|
|
52
|
-
month: string;
|
|
53
|
-
week: string;
|
|
54
|
-
day: string;
|
|
55
|
-
hour: string;
|
|
56
|
-
minute: string;
|
|
57
|
-
second: string;
|
|
58
|
-
millisecond: string;
|
|
59
|
-
thousand: string;
|
|
60
|
-
million: string;
|
|
61
|
-
billion: string;
|
|
62
|
-
trillion: string;
|
|
63
|
-
copySuccess: string;
|
|
64
|
-
copyFail: string;
|
|
65
|
-
add: string;
|
|
66
|
-
remove: string;
|
|
67
|
-
search: string;
|
|
68
|
-
filter: string;
|
|
69
|
-
loading: string;
|
|
70
|
-
ok: string;
|
|
71
|
-
cancel: string;
|
|
72
|
-
prevPage: string;
|
|
73
|
-
nextPage: string;
|
|
74
|
-
perPage: string;
|
|
75
|
-
noData: string;
|
|
76
|
-
more: string;
|
|
77
|
-
less: string;
|
|
78
|
-
nextTour: string;
|
|
79
|
-
skipTour: string;
|
|
80
|
-
finishTour: string;
|
|
81
|
-
currentOfTotal: string;
|
|
82
|
-
requiredMeg: string;
|
|
83
|
-
patternMsg: string;
|
|
84
|
-
};
|
|
85
|
-
export declare const loadLocale: (l: Promise<{
|
|
86
|
-
default: Partial<typeof en>;
|
|
87
|
-
}>) => void;
|
|
1
|
+
export * from '@mantou/tap-ui/lib/locale';
|
|
88
2
|
//# sourceMappingURL=locale.d.ts.map
|
package/lib/locale.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"locale.d.ts","sourceRoot":"","sources":["../src/lib/locale.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"locale.d.ts","sourceRoot":"","sources":["../src/lib/locale.ts"],"names":[],"mappings":"AAAA,cAAc,2BAA2B,CAAC"}
|
package/lib/locale.js
CHANGED
|
@@ -1,9 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
import en from '../locales/en';
|
|
3
|
-
import { OrderlyPromisePool } from './utils';
|
|
4
|
-
export const locale = createStore({ ...en });
|
|
5
|
-
const op = new OrderlyPromisePool();
|
|
6
|
-
export const loadLocale = (l) => {
|
|
7
|
-
op.add(l, (ll) => locale(ll.default));
|
|
8
|
-
};
|
|
1
|
+
export * from '@mantou/tap-ui/lib/locale';
|
|
9
2
|
//# sourceMappingURL=locale.js.map
|
package/lib/locale.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"locale.js","sourceRoot":"","sources":["../src/lib/locale.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"locale.js","sourceRoot":"","sources":["../src/lib/locale.ts"],"names":[],"mappings":"AAAA,cAAc,2BAA2B,CAAC"}
|
package/lib/map.d.ts
CHANGED
|
@@ -1,9 +1,2 @@
|
|
|
1
|
-
export
|
|
2
|
-
#private;
|
|
3
|
-
set(key: string, val: T): void;
|
|
4
|
-
get(key: string): T | undefined;
|
|
5
|
-
findKey(val: T): string | undefined;
|
|
6
|
-
delete(key: string): void;
|
|
7
|
-
[Symbol.iterator](): Generator<readonly [string, T], void, unknown>;
|
|
8
|
-
}
|
|
1
|
+
export * from '@mantou/tap-ui/lib/map';
|
|
9
2
|
//# sourceMappingURL=map.d.ts.map
|
package/lib/map.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"map.d.ts","sourceRoot":"","sources":["../src/lib/map.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"map.d.ts","sourceRoot":"","sources":["../src/lib/map.ts"],"names":[],"mappings":"AAAA,cAAc,wBAAwB,CAAC"}
|
package/lib/map.js
CHANGED
|
@@ -1,32 +1,2 @@
|
|
|
1
|
-
export
|
|
2
|
-
#map = new Map();
|
|
3
|
-
#weakMap = new WeakMap();
|
|
4
|
-
#registry = new FinalizationRegistry((key) => this.#map.delete(key));
|
|
5
|
-
set(key, val) {
|
|
6
|
-
this.delete(key);
|
|
7
|
-
this.#map.set(key, new WeakRef(val));
|
|
8
|
-
this.#weakMap.set(val, key);
|
|
9
|
-
this.#registry.register(val, key, val);
|
|
10
|
-
}
|
|
11
|
-
get(key) {
|
|
12
|
-
return this.#map.get(key)?.deref();
|
|
13
|
-
}
|
|
14
|
-
findKey(val) {
|
|
15
|
-
return this.#weakMap.get(val);
|
|
16
|
-
}
|
|
17
|
-
delete(key) {
|
|
18
|
-
const val = this.get(key);
|
|
19
|
-
if (val) {
|
|
20
|
-
this.#map.delete(key);
|
|
21
|
-
this.#weakMap.delete(val);
|
|
22
|
-
this.#registry.unregister(val);
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
*[Symbol.iterator]() {
|
|
26
|
-
const entries = this.#map.entries();
|
|
27
|
-
for (const [tag, ref] of entries) {
|
|
28
|
-
yield [tag, ref.deref()];
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
}
|
|
1
|
+
export * from '@mantou/tap-ui/lib/map';
|
|
32
2
|
//# sourceMappingURL=map.js.map
|
package/lib/map.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"map.js","sourceRoot":"","sources":["../src/lib/map.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"map.js","sourceRoot":"","sources":["../src/lib/map.ts"],"names":[],"mappings":"AAAA,cAAc,wBAAwB,CAAC"}
|
package/lib/number.d.ts
CHANGED
|
@@ -1,95 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
export declare function splitInt(int: string | number, comma?: number): string | number;
|
|
3
|
-
interface FormatNumberOptions {
|
|
4
|
-
dotAfterCount?: number;
|
|
5
|
-
unitSize?: number | number[];
|
|
6
|
-
units?: string[];
|
|
7
|
-
comma?: number;
|
|
8
|
-
autoOmitFraction?: boolean;
|
|
9
|
-
level?: number;
|
|
10
|
-
}
|
|
11
|
-
/**
|
|
12
|
-
* Format number, generator object
|
|
13
|
-
* Need to be combined as a strings on after
|
|
14
|
-
*/
|
|
15
|
-
export declare function formatNumber(value: number | undefined | null, option: FormatNumberOptions): {
|
|
16
|
-
number: string;
|
|
17
|
-
unit: string;
|
|
18
|
-
int?: undefined;
|
|
19
|
-
fract?: undefined;
|
|
20
|
-
} | {
|
|
21
|
-
int: number;
|
|
22
|
-
fract: number;
|
|
23
|
-
number: string;
|
|
24
|
-
unit: string;
|
|
25
|
-
};
|
|
26
|
-
export declare function formatBandwidth(value: number, needDetail?: boolean): {
|
|
27
|
-
number: string;
|
|
28
|
-
unit: string;
|
|
29
|
-
int?: undefined;
|
|
30
|
-
fract?: undefined;
|
|
31
|
-
} | {
|
|
32
|
-
int: number;
|
|
33
|
-
fract: number;
|
|
34
|
-
number: string;
|
|
35
|
-
unit: string;
|
|
36
|
-
};
|
|
37
|
-
export declare function formatTraffic(value: number, isDetail?: boolean): {
|
|
38
|
-
number: string;
|
|
39
|
-
unit: string;
|
|
40
|
-
int?: undefined;
|
|
41
|
-
fract?: undefined;
|
|
42
|
-
} | {
|
|
43
|
-
int: number;
|
|
44
|
-
fract: number;
|
|
45
|
-
number: string;
|
|
46
|
-
unit: string;
|
|
47
|
-
};
|
|
48
|
-
export declare function formatDecimal(value: number, isDetail?: boolean): {
|
|
49
|
-
number: string;
|
|
50
|
-
unit: string;
|
|
51
|
-
int?: undefined;
|
|
52
|
-
fract?: undefined;
|
|
53
|
-
} | {
|
|
54
|
-
int: number;
|
|
55
|
-
fract: number;
|
|
56
|
-
number: string;
|
|
57
|
-
unit: string;
|
|
58
|
-
};
|
|
59
|
-
export declare function formatCurrency(value: number, isDetail?: boolean): {
|
|
60
|
-
number: string;
|
|
61
|
-
unit: string;
|
|
62
|
-
int?: undefined;
|
|
63
|
-
fract?: undefined;
|
|
64
|
-
} | {
|
|
65
|
-
int: number;
|
|
66
|
-
fract: number;
|
|
67
|
-
number: string;
|
|
68
|
-
unit: string;
|
|
69
|
-
};
|
|
70
|
-
export declare function formatPercentage(value: number, isDetail?: boolean): {
|
|
71
|
-
number: string;
|
|
72
|
-
unit: string;
|
|
73
|
-
int?: undefined;
|
|
74
|
-
fract?: undefined;
|
|
75
|
-
} | {
|
|
76
|
-
int: number;
|
|
77
|
-
fract: number;
|
|
78
|
-
number: string;
|
|
79
|
-
unit: string;
|
|
80
|
-
};
|
|
81
|
-
export declare function formatToPrecision(value: number, count?: number): number;
|
|
82
|
-
/**Similar CSS clamp */
|
|
83
|
-
export declare function clamp(min: number, value: number, max: number): number;
|
|
84
|
-
export declare function middle(x: number, y: number): number;
|
|
85
|
-
/**
|
|
86
|
-
* Calculate the friendly range based on the maximum and minimum value,
|
|
87
|
-
* e.g: [0, 100], [0,500]
|
|
88
|
-
*/
|
|
89
|
-
export declare function adjustRange([min, max]: number[], stepCount: number, units?: number[]): number[];
|
|
90
|
-
/**Generate a pseudo -random function */
|
|
91
|
-
export declare function pseudoRandom(seed: number): () => number;
|
|
92
|
-
/**Random large integer normalization, output 0-1 */
|
|
93
|
-
export declare function normalizeNumber(n: number): number;
|
|
94
|
-
export {};
|
|
1
|
+
export * from '@mantou/tap-ui/lib/number';
|
|
95
2
|
//# sourceMappingURL=number.d.ts.map
|
package/lib/number.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"number.d.ts","sourceRoot":"","sources":["../src/lib/number.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"number.d.ts","sourceRoot":"","sources":["../src/lib/number.ts"],"names":[],"mappings":"AAAA,cAAc,2BAA2B,CAAC"}
|
package/lib/number.js
CHANGED
|
@@ -1,170 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
import { locale } from '../lib/locale';
|
|
3
|
-
/**Use a comma to separate numbers */
|
|
4
|
-
export function splitInt(int, comma = 3) {
|
|
5
|
-
if (comma === 0)
|
|
6
|
-
return int;
|
|
7
|
-
return String(int).replace(new RegExp(`(\\d)(?=(\\d{${comma}})+$)`, 'g'), '$1,');
|
|
8
|
-
}
|
|
9
|
-
/**
|
|
10
|
-
* Format number, generator object
|
|
11
|
-
* Need to be combined as a strings on after
|
|
12
|
-
*/
|
|
13
|
-
export function formatNumber(value, option) {
|
|
14
|
-
if (value !== 0 && !value)
|
|
15
|
-
return { number: '-', unit: '' };
|
|
16
|
-
const { dotAfterCount = 2, unitSize = 10, units = [''], comma = 3, autoOmitFraction = true, level } = option;
|
|
17
|
-
let l = 0;
|
|
18
|
-
let n = value;
|
|
19
|
-
while (true) {
|
|
20
|
-
const u = Array.isArray(unitSize) ? unitSize[l] : unitSize;
|
|
21
|
-
const haveArg = u && l < units.length - 1;
|
|
22
|
-
const needNextLevel = u > 1 ? n >= u : n < 1;
|
|
23
|
-
if (haveArg && (level === undefined ? needNextLevel : l < level)) {
|
|
24
|
-
l++;
|
|
25
|
-
n /= u;
|
|
26
|
-
}
|
|
27
|
-
else {
|
|
28
|
-
break;
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
const oint = Math.trunc(n);
|
|
32
|
-
const fract = n - oint;
|
|
33
|
-
const onlyInt = autoOmitFraction && l === 0 && Math.trunc(value) === value;
|
|
34
|
-
const fractPart = fract.toFixed(dotAfterCount);
|
|
35
|
-
const fractPartStr = fractPart.slice(2);
|
|
36
|
-
const int = fractPart.startsWith('1') ? oint + 1 : oint;
|
|
37
|
-
return {
|
|
38
|
-
// 整数
|
|
39
|
-
int,
|
|
40
|
-
// 小数
|
|
41
|
-
fract,
|
|
42
|
-
// 格式化后的整个数字
|
|
43
|
-
number: `${splitInt(int, comma)}${onlyInt || dotAfterCount === 0 ? '' : `.${fractPartStr}`}`,
|
|
44
|
-
// 单位
|
|
45
|
-
unit: units[l],
|
|
46
|
-
};
|
|
47
|
-
}
|
|
48
|
-
export function formatBandwidth(value, needDetail = false) {
|
|
49
|
-
return formatNumber(value, {
|
|
50
|
-
unitSize: 1000,
|
|
51
|
-
units: ['bps', 'Kbps', 'Mbps', 'Gbps', 'Tbps', 'Pbps', 'Ebps', 'Zbps', 'Ybps'],
|
|
52
|
-
level: needDetail ? 2 : undefined,
|
|
53
|
-
});
|
|
54
|
-
}
|
|
55
|
-
export function formatTraffic(value, isDetail = false) {
|
|
56
|
-
return formatNumber(value, {
|
|
57
|
-
unitSize: 1024,
|
|
58
|
-
units: ['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'],
|
|
59
|
-
level: isDetail ? 3 : undefined,
|
|
60
|
-
});
|
|
61
|
-
}
|
|
62
|
-
export function formatDecimal(value, isDetail = false) {
|
|
63
|
-
return formatNumber(value, {
|
|
64
|
-
unitSize: 1000,
|
|
65
|
-
units: ['', locale.thousand, locale.million, locale.trillion],
|
|
66
|
-
level: isDetail ? 0 : undefined,
|
|
67
|
-
});
|
|
68
|
-
}
|
|
69
|
-
export function formatCurrency(value, isDetail = false) {
|
|
70
|
-
return formatNumber(value, {
|
|
71
|
-
level: 0,
|
|
72
|
-
dotAfterCount: isDetail ? 2 : 0,
|
|
73
|
-
});
|
|
74
|
-
}
|
|
75
|
-
export function formatPercentage(value, isDetail = false) {
|
|
76
|
-
return formatNumber(value, {
|
|
77
|
-
unitSize: 1 / 100,
|
|
78
|
-
units: ['', '%'],
|
|
79
|
-
level: 1,
|
|
80
|
-
dotAfterCount: isDetail ? 5 : undefined,
|
|
81
|
-
});
|
|
82
|
-
}
|
|
83
|
-
export function formatToPrecision(value, count = 2) {
|
|
84
|
-
const i = 10 ** count;
|
|
85
|
-
return Math.round(value * i) / i;
|
|
86
|
-
}
|
|
87
|
-
/**Similar CSS clamp */
|
|
88
|
-
export function clamp(min, value, max) {
|
|
89
|
-
return Math.max(min, Math.min(value, max));
|
|
90
|
-
}
|
|
91
|
-
export function middle(x, y) {
|
|
92
|
-
return Math.floor((x + y) / 2);
|
|
93
|
-
}
|
|
94
|
-
/**
|
|
95
|
-
* Calculate the friendly range based on the maximum and minimum value,
|
|
96
|
-
* e.g: [0, 100], [0,500]
|
|
97
|
-
*/
|
|
98
|
-
export function adjustRange([min, max], stepCount, units) {
|
|
99
|
-
const getRatio = (d) => {
|
|
100
|
-
if (d > 10)
|
|
101
|
-
return 1;
|
|
102
|
-
if (d > 0.1)
|
|
103
|
-
return 10;
|
|
104
|
-
if (d > 0.01)
|
|
105
|
-
return 100;
|
|
106
|
-
if (d > 0.001)
|
|
107
|
-
return 1000;
|
|
108
|
-
return 10000;
|
|
109
|
-
};
|
|
110
|
-
const scale = getRatio(max - min);
|
|
111
|
-
const scaleMin = min * scale;
|
|
112
|
-
const scaleMax = max * scale + (max === min ? 10 : 0);
|
|
113
|
-
const scaleRange = scaleMax - scaleMin;
|
|
114
|
-
const getTotal = (unit) => {
|
|
115
|
-
const currentStepCount = Math.ceil(scaleRange / unit);
|
|
116
|
-
const multiple = Math.ceil(currentStepCount / stepCount);
|
|
117
|
-
return stepCount * multiple * unit;
|
|
118
|
-
};
|
|
119
|
-
const getBase = (i) => {
|
|
120
|
-
if (units) {
|
|
121
|
-
return units[i] || units[units.length - 1];
|
|
122
|
-
}
|
|
123
|
-
if (i === 0)
|
|
124
|
-
return 1;
|
|
125
|
-
if (scaleRange > 10)
|
|
126
|
-
return 10;
|
|
127
|
-
if (scaleRange > 1 && scaleRange > 10 / stepCount)
|
|
128
|
-
return 1;
|
|
129
|
-
return 0.1;
|
|
130
|
-
};
|
|
131
|
-
const getUnit = (unit) => {
|
|
132
|
-
let pp = unit;
|
|
133
|
-
let p = unit;
|
|
134
|
-
let u = unit;
|
|
135
|
-
for (let i = 0;; i++) {
|
|
136
|
-
if (i > 100) {
|
|
137
|
-
break;
|
|
138
|
-
}
|
|
139
|
-
const nextUnit = u * getBase(i);
|
|
140
|
-
const total = getTotal(nextUnit);
|
|
141
|
-
const diff = total - scaleRange;
|
|
142
|
-
if (diff > total / stepCount) {
|
|
143
|
-
break;
|
|
144
|
-
}
|
|
145
|
-
pp = p;
|
|
146
|
-
p = u;
|
|
147
|
-
u = nextUnit;
|
|
148
|
-
}
|
|
149
|
-
return [u, p, pp];
|
|
150
|
-
};
|
|
151
|
-
const [unit, _, prevUnit] = getUnit(1);
|
|
152
|
-
const adjustedMin = Math.floor(scaleMin / prevUnit) * prevUnit;
|
|
153
|
-
const adjustedMax = adjustedMin + getTotal(unit);
|
|
154
|
-
return [adjustedMin / scale, adjustedMax / scale];
|
|
155
|
-
}
|
|
156
|
-
/**Generate a pseudo -random function */
|
|
157
|
-
export function pseudoRandom(seed) {
|
|
158
|
-
const MULTIPLIER = 48271;
|
|
159
|
-
const MODULUS = 2147483647;
|
|
160
|
-
let current = seed;
|
|
161
|
-
return () => {
|
|
162
|
-
current = (current * MULTIPLIER) % MODULUS;
|
|
163
|
-
return current;
|
|
164
|
-
};
|
|
165
|
-
}
|
|
166
|
-
/**Random large integer normalization, output 0-1 */
|
|
167
|
-
export function normalizeNumber(n) {
|
|
168
|
-
return parseFloat(`0.${[...Math.abs(n).toString()].reverse().join('')}`);
|
|
169
|
-
}
|
|
1
|
+
export * from '@mantou/tap-ui/lib/number';
|
|
170
2
|
//# sourceMappingURL=number.js.map
|
package/lib/number.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"number.js","sourceRoot":"","sources":["../src/lib/number.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"number.js","sourceRoot":"","sources":["../src/lib/number.ts"],"names":[],"mappings":"AAAA,cAAc,2BAA2B,CAAC"}
|
package/lib/patterns.d.ts
CHANGED
|
@@ -1,10 +1,2 @@
|
|
|
1
|
-
export
|
|
2
|
-
export declare const EMAIL: RegExp;
|
|
3
|
-
export declare const CJK: RegExp;
|
|
4
|
-
export declare const ASCII: RegExp;
|
|
5
|
-
export declare const USERNAME: RegExp;
|
|
6
|
-
export declare const PASSWORD: RegExp;
|
|
7
|
-
export declare const NUMBER: RegExp;
|
|
8
|
-
export declare const IPv4: RegExp;
|
|
9
|
-
export declare const HEX_COLOR: RegExp;
|
|
1
|
+
export * from '@mantou/tap-ui/lib/patterns';
|
|
10
2
|
//# sourceMappingURL=patterns.d.ts.map
|
package/lib/patterns.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"patterns.d.ts","sourceRoot":"","sources":["../src/lib/patterns.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"patterns.d.ts","sourceRoot":"","sources":["../src/lib/patterns.ts"],"names":[],"mappings":"AAAA,cAAc,6BAA6B,CAAC"}
|
package/lib/patterns.js
CHANGED
|
@@ -1,12 +1,2 @@
|
|
|
1
|
-
export
|
|
2
|
-
export const EMAIL =
|
|
3
|
-
// biome-ignore lint/suspicious/noControlCharactersInRegex: none
|
|
4
|
-
/^(?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*|"(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])*")@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?|\[(?:(?:(2(5[0-5]|[0-4][0-9])|1[0-9][0-9]|[1-9]?[0-9]))\.){3}(?:(2(5[0-5]|[0-4][0-9])|1[0-9][0-9]|[1-9]?[0-9])|[a-z0-9-]*[a-z0-9]:(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21-\x5a\x53-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])+)\])$/;
|
|
5
|
-
export const CJK = /^(\p{sc=Han}|\p{sc=Katakana}|\p{sc=Hiragana}|\p{sc=Hang})+$/u;
|
|
6
|
-
export const ASCII = /^[ -~]+$/;
|
|
7
|
-
export const USERNAME = /^[a-z0-9_-]{4,}$/i;
|
|
8
|
-
export const PASSWORD = /^.*(?=.{6,})(?=.*[A-Z])(?=.*[a-z])(?=.*[!@#$%^&*? ])(?=.*\d).*$/;
|
|
9
|
-
export const NUMBER = /^-?\d*\.?\d*$/;
|
|
10
|
-
export const IPv4 = /^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?).){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/;
|
|
11
|
-
export const HEX_COLOR = /^#([0-9a-f]{3}){1,2}$/i;
|
|
1
|
+
export * from '@mantou/tap-ui/lib/patterns';
|
|
12
2
|
//# sourceMappingURL=patterns.js.map
|
package/lib/patterns.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"patterns.js","sourceRoot":"","sources":["../src/lib/patterns.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"patterns.js","sourceRoot":"","sources":["../src/lib/patterns.ts"],"names":[],"mappings":"AAAA,cAAc,6BAA6B,CAAC"}
|
package/lib/styles.d.ts
CHANGED
|
@@ -1,5 +1,2 @@
|
|
|
1
|
-
export
|
|
2
|
-
export declare const blockContainer: import("@mantou/gem/lib/reactive").Sheet<Record<string, string>>;
|
|
3
|
-
export declare const flexContainer: import("@mantou/gem/lib/reactive").Sheet<Record<string, string>>;
|
|
4
|
-
export declare const contentsContainer: import("@mantou/gem/lib/reactive").Sheet<Record<string, string>>;
|
|
1
|
+
export * from '@mantou/tap-ui/lib/styles';
|
|
5
2
|
//# sourceMappingURL=styles.d.ts.map
|