@wot-ui/ui 2.0.7 → 2.1.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 (50) hide show
  1. package/README.md +11 -11
  2. package/attributes.json +1 -1
  3. package/changelog.md +26 -0
  4. package/common/AbortablePromise.ts +28 -0
  5. package/common/canvasHelper.ts +49 -0
  6. package/common/clickoutside.ts +25 -0
  7. package/common/event.ts +8 -0
  8. package/common/formatDate.ts +68 -0
  9. package/common/interceptor.ts +43 -0
  10. package/common/props.ts +53 -0
  11. package/common/util.ts +836 -0
  12. package/components/wd-avatar/wd-avatar.vue +1 -1
  13. package/components/wd-button/types.ts +11 -8
  14. package/components/wd-button/wd-button.vue +26 -4
  15. package/components/wd-calendar-view/monthPanel/month-panel.vue +1 -0
  16. package/components/wd-calendar-view/yearPanel/year-panel.vue +1 -0
  17. package/components/wd-cell/index.scss +12 -1
  18. package/components/wd-config-provider/global-config.ts +50 -0
  19. package/components/wd-config-provider/theme-vars.ts +2073 -0
  20. package/components/wd-config-provider/types.ts +20 -2071
  21. package/components/wd-config-provider/wd-config-provider.vue +15 -4
  22. package/components/wd-dialog/wd-dialog.vue +1 -0
  23. package/components/wd-drop-menu/wd-drop-menu.vue +1 -0
  24. package/components/wd-grid/wd-grid.vue +0 -2
  25. package/components/wd-icon/wd-icon.vue +2 -2
  26. package/components/wd-img/wd-img.vue +1 -0
  27. package/components/wd-index-anchor/index.scss +5 -5
  28. package/components/wd-index-bar/index.scss +14 -14
  29. package/components/wd-keyboard/key/index.vue +2 -0
  30. package/components/wd-notify/wd-notify.vue +1 -0
  31. package/components/wd-picker-view/useSelection.ts +3 -1
  32. package/components/wd-root-portal/wd-root-portal.vue +1 -1
  33. package/components/wd-select-picker/wd-select-picker.vue +1 -0
  34. package/components/wd-signature/wd-signature.vue +1 -0
  35. package/components/wd-slider/index.scss +45 -45
  36. package/components/wd-slider/wd-slider.vue +19 -3
  37. package/components/wd-switch/wd-switch.vue +2 -0
  38. package/components/wd-tabs/wd-tabs.vue +1 -0
  39. package/components/wd-tag/index.scss +8 -7
  40. package/components/wd-tag/types.ts +10 -7
  41. package/components/wd-tag/wd-tag.vue +23 -6
  42. package/components/wd-toast/wd-toast.vue +4 -0
  43. package/composables/index.ts +2 -0
  44. package/composables/useConfigProvider.ts +27 -12
  45. package/composables/useGlobalConfig.ts +9 -0
  46. package/index.ts +1 -1
  47. package/package.json +1 -1
  48. package/styles/variable.scss +381 -381
  49. package/tags.json +1 -1
  50. package/web-types.json +1 -1
package/changelog.md CHANGED
@@ -1,6 +1,32 @@
1
1
  # 更新日志
2
2
 
3
3
 
4
+ ## [2.1.0](https://github.com/wot-ui/wot-ui/compare/v2.0.8...v2.1.0) (2026-06-10)
5
+
6
+
7
+ ### ✨ Features | 新功能
8
+
9
+ * ✨ config-provider 新增全局配置能力并接入 button 与 tag ([#62](https://github.com/wot-ui/wot-ui/issues/62)) ([f451ba8](https://github.com/wot-ui/wot-ui/commit/f451ba8e22d4672ace475d807451347b6668e153)), closes [#13](https://github.com/wot-ui/wot-ui/issues/13)
10
+
11
+
12
+ ### 🐛 Bug Fixes | Bug 修复
13
+
14
+ * 🐛 兼容性修复与类型补全 ([#43](https://github.com/wot-ui/wot-ui/issues/43)) ([953d164](https://github.com/wot-ui/wot-ui/commit/953d164642f2a2179c89dce3a64496fc5412e750))
15
+ * 🐛 将 FAB 组件示例中的错误按钮类型更改为危险按钮 ([#65](https://github.com/wot-ui/wot-ui/issues/65)) ([ed16d5f](https://github.com/wot-ui/wot-ui/commit/ed16d5f9457c2e603f4447b52bc8751b30112269)), closes [#5](https://github.com/wot-ui/wot-ui/issues/5)
16
+ * 🐛 修复 Cell 组件的 title 和 label 纯数字和英文场景不换行的问题 ([#64](https://github.com/wot-ui/wot-ui/issues/64)) ([b9d748f](https://github.com/wot-ui/wot-ui/commit/b9d748f29e9d88cdaebd8818b8565b52b5b959a6)), closes [#47](https://github.com/wot-ui/wot-ui/issues/47)
17
+ * 🐛 修复 size 属性在 image 和 cssIcon 模式下的无效问题 ([#45](https://github.com/wot-ui/wot-ui/issues/45)) ([ddcc89e](https://github.com/wot-ui/wot-ui/commit/ddcc89e5d232320b2214d4f5db4febd64c899b2e))
18
+ * 🐛 修复 toast 不支持自定义 icon 颜色 ([#54](https://github.com/wot-ui/wot-ui/issues/54)) ([3718cf4](https://github.com/wot-ui/wot-ui/commit/3718cf42140fbeefc4551e8f0540b599a0007d4e))
19
+ * 🐛 修复 useVideoPreview 没有被导出的问题 ([#52](https://github.com/wot-ui/wot-ui/issues/52)) ([3617c07](https://github.com/wot-ui/wot-ui/commit/3617c078f55a4c13463308e429ed57c785d10580))
20
+ * 🐛 修复不传 type 时 size 样式被默认类型覆盖的问题 ([#44](https://github.com/wot-ui/wot-ui/issues/44)) ([f811e7f](https://github.com/wot-ui/wot-ui/commit/f811e7f6c9e0aa33f968e73030e115d41ef0e511))
21
+
22
+
23
+ ### ✏️ Documentation | 文档
24
+
25
+ * ✏️ 补全 form-item 文档 value-align 属性 ([#67](https://github.com/wot-ui/wot-ui/issues/67)) ([a7cf766](https://github.com/wot-ui/wot-ui/commit/a7cf7666b5cba5e0d347b15f4b8d5e6db3af5b0a))
26
+ * ✏️ 更新所有文档中的链接,替换为新的域名 ([b6d2e4f](https://github.com/wot-ui/wot-ui/commit/b6d2e4f1799f2576fff9e7f4705a8c8efb292e4b))
27
+
28
+ ### [2.0.8](https://github.com/wot-ui/wot-ui/compare/v2.0.7...v2.0.8) (2026-05-12)
29
+
4
30
  ### [2.0.7](https://github.com/wot-ui/wot-ui/compare/v2.0.6...v2.0.7) (2026-05-12)
5
31
 
6
32
  ### [2.0.6](https://github.com/wot-ui/wot-ui/compare/v2.0.5...v2.0.6) (2026-05-12)
@@ -0,0 +1,28 @@
1
+ export class AbortablePromise<T> {
2
+ promise: Promise<T>
3
+ private _reject: ((res?: any) => void) | null = null
4
+
5
+ constructor(executor: (resolve: (value: T | PromiseLike<T>) => void, reject: (reason?: any) => void) => void) {
6
+ this.promise = new Promise<T>((resolve, reject) => {
7
+ executor(resolve, reject)
8
+ this._reject = reject // 保存reject方法的引用,以便在abort时调用
9
+ })
10
+ }
11
+ // 提供abort方法来中止Promise
12
+ abort(error?: any) {
13
+ if (this._reject) {
14
+ this._reject(error) // 调用reject方法来中止Promise
15
+ }
16
+ }
17
+
18
+ then<TResult1 = T, TResult2 = never>(
19
+ onfulfilled?: ((value: T) => TResult1 | PromiseLike<TResult1>) | undefined | null,
20
+ onrejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | undefined | null
21
+ ): Promise<TResult1 | TResult2> {
22
+ return this.promise.then(onfulfilled, onrejected)
23
+ }
24
+
25
+ catch<TResult = never>(onrejected?: ((reason: any) => TResult | PromiseLike<TResult>) | undefined | null): Promise<T | TResult> {
26
+ return this.promise.catch(onrejected)
27
+ }
28
+ }
@@ -0,0 +1,49 @@
1
+ /**
2
+ * 适配 canvas 2d 上下文
3
+ * @param ctx canvas 2d 上下文
4
+ * @returns
5
+ */
6
+ export function canvas2dAdapter(ctx: CanvasRenderingContext2D): UniApp.CanvasContext {
7
+ return Object.assign(ctx, {
8
+ setFillStyle(color: string | CanvasGradient) {
9
+ ctx.fillStyle = color
10
+ },
11
+ setStrokeStyle(color: string | CanvasGradient | CanvasPattern) {
12
+ ctx.strokeStyle = color
13
+ },
14
+ setLineWidth(lineWidth: number) {
15
+ ctx.lineWidth = lineWidth
16
+ },
17
+ setLineCap(lineCap: 'butt' | 'round' | 'square') {
18
+ ctx.lineCap = lineCap
19
+ },
20
+
21
+ setFontSize(font: string) {
22
+ ctx.font = font
23
+ },
24
+ setGlobalAlpha(alpha: number) {
25
+ ctx.globalAlpha = alpha
26
+ },
27
+ setLineJoin(lineJoin: 'bevel' | 'round' | 'miter') {
28
+ ctx.lineJoin = lineJoin
29
+ },
30
+ setTextAlign(align: 'left' | 'center' | 'right') {
31
+ ctx.textAlign = align
32
+ },
33
+ setMiterLimit(miterLimit: number) {
34
+ ctx.miterLimit = miterLimit
35
+ },
36
+ setShadow(offsetX: number, offsetY: number, blur: number, color: string) {
37
+ ctx.shadowOffsetX = offsetX
38
+ ctx.shadowOffsetY = offsetY
39
+ ctx.shadowBlur = blur
40
+ ctx.shadowColor = color
41
+ },
42
+ setTextBaseline(textBaseline: 'top' | 'bottom' | 'middle') {
43
+ ctx.textBaseline = textBaseline
44
+ },
45
+ createCircularGradient() {},
46
+ draw() {},
47
+ addColorStop() {}
48
+ }) as unknown as UniApp.CanvasContext
49
+ }
@@ -0,0 +1,25 @@
1
+ let queue: any[] = []
2
+
3
+ export function pushToQueue(comp: any) {
4
+ queue.push(comp)
5
+ }
6
+
7
+ export function removeFromQueue(comp: any) {
8
+ queue = queue.filter((item) => {
9
+ return item.$.uid !== comp.$.uid
10
+ })
11
+ }
12
+
13
+ export function closeOther(comp: any) {
14
+ queue.forEach((item) => {
15
+ if (item.$.uid !== comp.$.uid) {
16
+ item.$.exposed.close()
17
+ }
18
+ })
19
+ }
20
+
21
+ export function closeOutside() {
22
+ queue.forEach((item) => {
23
+ item.$.exposed.close()
24
+ })
25
+ }
@@ -0,0 +1,8 @@
1
+ export const UPDATE_MODEL_EVENT = 'update:modelValue'
2
+ export const CHANGE_EVENT = 'change'
3
+ export const INPUT_EVENT = 'input'
4
+ export const CLICK_EVENT = 'click'
5
+ export const CLOSE_EVENT = 'close'
6
+ export const OPEN_EVENT = 'open'
7
+ export const CONFIRM_EVENT = 'confirm'
8
+ export const CANCEL_EVENT = 'cancel'
@@ -0,0 +1,68 @@
1
+ /**
2
+ * 轻量级日期格式化工具,用于替代 dayjs
3
+ */
4
+
5
+ /**
6
+ * 日期格式化函数,替代 dayjs.format()
7
+ * @description 将日期格式化为指定格式的字符串
8
+ * @param date 日期(时间戳或 Date 对象)
9
+ * @param format 格式模板,如 'YYYY-MM-DD HH:mm:ss'
10
+ * @returns 格式化后的字符串
11
+ *
12
+ * @example
13
+ * formatDate(Date.now(), 'YYYY-MM-DD') // '2026-02-02'
14
+ * formatDate(1706860800000, 'YYYY年MM月DD日') // '2026年02月02日'
15
+ * formatDate(new Date(), 'HH:mm:ss') // '14:30:00'
16
+ *
17
+ * 支持的 tokens:
18
+ * - YYYY: 4位年份
19
+ * - YY: 2位年份
20
+ * - MM: 2位月份(补零)
21
+ * - M: 月份
22
+ * - DD: 2位日期(补零)
23
+ * - D: 日期
24
+ * - HH: 2位小时(补零,24小时制)
25
+ * - H: 小时(24小时制)
26
+ * - mm: 2位分钟(补零)
27
+ * - m: 分钟
28
+ * - ss: 2位秒数(补零)
29
+ * - s: 秒数
30
+ */
31
+ export function formatDate(date: number | Date, format: string): string {
32
+ const d = date instanceof Date ? date : new Date(date)
33
+
34
+ // 检查日期是否有效
35
+ if (isNaN(d.getTime())) {
36
+ return 'Invalid Date'
37
+ }
38
+
39
+ const year = d.getFullYear()
40
+ const month = d.getMonth() + 1
41
+ const day = d.getDate()
42
+ const hours = d.getHours()
43
+ const minutes = d.getMinutes()
44
+ const seconds = d.getSeconds()
45
+
46
+ // 定义 token 到值的映射(按长度降序排列以确保正确匹配)
47
+ const tokens: Record<string, string> = {
48
+ YYYY: String(year),
49
+ YY: String(year).slice(-2),
50
+ MM: String(month).padStart(2, '0'),
51
+ M: String(month),
52
+ DD: String(day).padStart(2, '0'),
53
+ D: String(day),
54
+ HH: String(hours).padStart(2, '0'),
55
+ H: String(hours),
56
+ mm: String(minutes).padStart(2, '0'),
57
+ m: String(minutes),
58
+ ss: String(seconds).padStart(2, '0'),
59
+ s: String(seconds)
60
+ }
61
+
62
+ // 按 token 长度降序排列,确保先匹配长 token(如 YYYY 优先于 YY)
63
+ const pattern = Object.keys(tokens)
64
+ .sort((a, b) => b.length - a.length)
65
+ .join('|')
66
+
67
+ return format.replace(new RegExp(pattern, 'g'), (match) => tokens[match] || match)
68
+ }
@@ -0,0 +1,43 @@
1
+ import { isPromise } from './util'
2
+
3
+ function noop() {}
4
+
5
+ export type Interceptor = (...args: any[]) => Promise<boolean> | boolean | undefined | void
6
+
7
+ export function callInterceptor(
8
+ interceptor: Interceptor | undefined,
9
+ {
10
+ args = [],
11
+ done,
12
+ canceled,
13
+ error
14
+ }: {
15
+ args?: unknown[]
16
+ done: () => void
17
+ canceled?: () => void
18
+ error?: () => void
19
+ }
20
+ ) {
21
+ if (interceptor) {
22
+ // eslint-disable-next-line prefer-spread
23
+ const returnVal = interceptor.apply(null, args)
24
+
25
+ if (isPromise(returnVal)) {
26
+ returnVal
27
+ .then((value) => {
28
+ if (value) {
29
+ done()
30
+ } else if (canceled) {
31
+ canceled()
32
+ }
33
+ })
34
+ .catch(error || noop)
35
+ } else if (returnVal) {
36
+ done()
37
+ } else if (canceled) {
38
+ canceled()
39
+ }
40
+ } else {
41
+ done()
42
+ }
43
+ }
@@ -0,0 +1,53 @@
1
+ import type { PropType } from 'vue'
2
+
3
+ export type Numeric = number | string
4
+
5
+ export const unknownProp = null as unknown as PropType<unknown>
6
+
7
+ export const numericProp = [Number, String]
8
+
9
+ export const truthProp = {
10
+ type: Boolean,
11
+ default: true as const
12
+ }
13
+
14
+ export const makeRequiredProp = <T>(type: T) => ({
15
+ type,
16
+ required: true as const
17
+ })
18
+
19
+ export const makeArrayProp = <T>() => ({
20
+ type: Array as PropType<T[]>,
21
+ default: () => []
22
+ })
23
+
24
+ export const makeBooleanProp = <T>(defaultVal: T) => ({
25
+ type: Boolean,
26
+ default: defaultVal
27
+ })
28
+
29
+ export const makeNumberProp = <T>(defaultVal: T) => ({
30
+ type: Number,
31
+ default: defaultVal
32
+ })
33
+
34
+ export const makeNumericProp = <T>(defaultVal: T) => ({
35
+ type: numericProp,
36
+ default: defaultVal
37
+ })
38
+
39
+ export const makeStringProp = <T>(defaultVal: T) => ({
40
+ type: String as unknown as PropType<T>,
41
+ default: defaultVal
42
+ })
43
+
44
+ export const baseProps = {
45
+ /**
46
+ * 自定义根节点样式
47
+ */
48
+ customStyle: makeStringProp(''),
49
+ /**
50
+ * 自定义根节点样式类
51
+ */
52
+ customClass: makeStringProp('')
53
+ }