不是元素的模块
DuoyunUI 除了提供许多自定义元素、具有某些特定功能的基类之外, 还包含一些常用模块,它们有些被用在 DuoyunUI 的自定义元素中,有些则是独立提供的。
Color
色彩空间转换;亮度、对比度计算。
| Name | Description |
|---|---|
rgbToRgbColor |
|
rgbToHslColor |
|
rgbToHexColor |
|
randomColor |
|
parseHexColor |
|
luminance |
Note: ignore alpha |
contrast |
Note: ignore alpha |
rgbToHsl |
Note: ignore alpha |
hslToRgb |
|
rgbToHsv |
|
hsvToRgb |
|
hslToHsv |
|
hsvToHsl |
Encode
hash, base64 等编码/解码。
| Name | Description |
|---|---|
b64ToUtf8 |
|
base64ToArrayBuffer |
|
utf8ToB64 |
Converted string to Base64, isSafe indicates URL safe |
arrayBufferToBase64 |
|
hash |
Must be async |
fnv1a |
Simple hash, output int |
HotKeys
轻量版的 hotkeys。
| Name | Description |
|---|---|
normalizeKey |
|
getDisplayKey |
Get the platform button |
setKeys |
Custom key map |
matchHotKey |
Detect whether the current keyboard event matches the specified button |
unlock |
Release the lock state of the continuous button, see hotkeys |
hotkeys |
Must have non-control character; Not case sensitive; Support a-b, press a, hotkeys be locked, wait next keydown event, allow call unlock |
Image
压缩图片;生成 SVG 图片。
| Name | Description |
|---|---|
createCanvas |
|
createDataURLFromSVG |
|
createSVGFromText |
Create SVG according to the text |
createBitmapFromSvg |
|
createDataURLFromBlob |
|
compressionImage |
Compression HTMLImageElement/File to DataURL/File |
Number
格式化数字、范围调整。
| Name | Description |
|---|---|
splitInt |
Use a comma to separate numbers |
formatNumber |
Format number, generator object Need to be combined as a strings on after |
formatBandwidth |
|
formatTraffic |
|
formatDecimal |
|
formatCurrency |
|
formatPercentage |
|
formatToPrecision |
|
clamp |
Similar CSS clamp |
middle |
|
adjustRange |
Calculate the friendly range based on the maximum and minimum value, e.g: [0, 100], [0,500] |
pseudoRandom |
Generate a pseudo -random function |
normalizeNumber |
Random large integer normalization, output 0-1 |
Time
轻量版的日期时间处理库。
| Name | Description |
|---|---|
parseDate |
Parse Date/number to object |
parseNarrowTimeRange |
|
parseNarrowRelativeTime |
|
Time |
Provide some convenient operation methods for Date/Time |
parseDuration |
Parse timestamp to Duration object |
parseDurationToParts |
|
formatDuration |
Timer
一些定时器函数。
| Name | Description |
|---|---|
forever |
Until the callback function resolve |
polling |
Polling calls until cancel |
sleep |
|
nextFrame |
|
throttle |
|
debounce |
|
invoke |
Invoke the function by condition |
once |
Only invoke first |
omitOnce |
Ignore the first invoke |
Utils
一些常用的函数。
| Name | Description |
|---|---|
convertToMap |
Similar lodash.keyBy |
getCascaderDeep |
Get Cascader/Tree max deep |
getCascaderBubbleWeakMap |
Get the value from the bottom layer, compare the new value of the upper layer to choose a new value, bubbling to the top layer |
proxyObject |
Simple proxy object, use prop name as a fallback when reading prop |
readProp |
Deep read prop |
OrderlyPromisePool |
Only let the last add Promise take effect, don’t care about the order of Resolve |
comparer |
Serialize comparer |
getStringFromTemplate |
Serialized TemplateResult return text content |
splitString |
Segmentation search word |
isIncludesString |
Search |
createCacheStore |
Create auto cache(localStorage) Store |
isRemoteIcon |
|
DyPromise |
Pass additional fields not support async function |
其他
animations:使用 Web Animations API 运行简单动画cache:提供简单的缓存方案,比如 LRU 缓存icons:内置图标,另见 locale:切换、修改语言,另见 styles:一些可全局共享的样式theme:内置主题,另见 types:方便 Typescript 类型推导的帮助函数
