@vyr/design 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 (83) hide show
  1. package/package.json +16 -0
  2. package/src/components/Button.vue +64 -0
  3. package/src/components/Card.vue +203 -0
  4. package/src/components/Cascader.vue +171 -0
  5. package/src/components/Checked.vue +124 -0
  6. package/src/components/CheckedGroup.vue +51 -0
  7. package/src/components/Col.vue +52 -0
  8. package/src/components/ColorPicker.vue +331 -0
  9. package/src/components/Confirm.vue +86 -0
  10. package/src/components/Dialog.vue +220 -0
  11. package/src/components/Divider.vue +40 -0
  12. package/src/components/Draggable.vue +50 -0
  13. package/src/components/Dropdown.vue +175 -0
  14. package/src/components/DynamicDialog.vue +113 -0
  15. package/src/components/DynamicLayouter.vue +235 -0
  16. package/src/components/Form.vue +88 -0
  17. package/src/components/Input.vue +254 -0
  18. package/src/components/InputNumber.vue +96 -0
  19. package/src/components/Label.vue +116 -0
  20. package/src/components/Loading.vue +196 -0
  21. package/src/components/Mask.vue +47 -0
  22. package/src/components/Notify.vue +130 -0
  23. package/src/components/Option.vue +159 -0
  24. package/src/components/Options.vue +202 -0
  25. package/src/components/Popover.vue +271 -0
  26. package/src/components/Provider.vue +12 -0
  27. package/src/components/RightMenu.vue +127 -0
  28. package/src/components/Row.vue +50 -0
  29. package/src/components/Scroll.vue +99 -0
  30. package/src/components/Select.vue +223 -0
  31. package/src/components/Slot.vue +23 -0
  32. package/src/components/SubTree.vue +262 -0
  33. package/src/components/Tree.vue +129 -0
  34. package/src/components/common/DraggableController.ts +113 -0
  35. package/src/components/common/ResizeListener.ts +49 -0
  36. package/src/components/composables/useDefaultProps.ts +179 -0
  37. package/src/components/composables/useDraggable.ts +65 -0
  38. package/src/components/composables/useGetter.ts +15 -0
  39. package/src/components/composables/useMarginStyle.ts +45 -0
  40. package/src/components/composables/usePopover.ts +33 -0
  41. package/src/components/composables/useProvider.ts +186 -0
  42. package/src/components/composables/useScroll.ts +46 -0
  43. package/src/components/composables/useSearch.ts +97 -0
  44. package/src/components/composables/useTimer.ts +5 -0
  45. package/src/components/index.ts +1 -0
  46. package/src/components/singleton/confirm.ts +25 -0
  47. package/src/components/singleton/dialog.ts +25 -0
  48. package/src/components/singleton/index.ts +5 -0
  49. package/src/components/singleton/loading.ts +36 -0
  50. package/src/components/singleton/notify.ts +36 -0
  51. package/src/components/types/index.ts +82 -0
  52. package/src/components/utils/Cascader.ts +52 -0
  53. package/src/components/utils/Confirm.ts +41 -0
  54. package/src/components/utils/Dialog.ts +38 -0
  55. package/src/components/utils/DynamicDialog.ts +41 -0
  56. package/src/components/utils/DynamicLayouter.ts +5 -0
  57. package/src/components/utils/FloatLayer.ts +40 -0
  58. package/src/components/utils/InputNumber.ts +3 -0
  59. package/src/components/utils/Notify.ts +25 -0
  60. package/src/components/utils/Popover.ts +58 -0
  61. package/src/components/utils/RightMenu.ts +21 -0
  62. package/src/components/utils/Scroll.ts +4 -0
  63. package/src/components/utils/Slot.ts +73 -0
  64. package/src/components/utils/index.ts +12 -0
  65. package/src/font/demo.css +539 -0
  66. package/src/font/demo_index.html +1292 -0
  67. package/src/font/iconfont.css +207 -0
  68. package/src/font/iconfont.js +1 -0
  69. package/src/font/iconfont.json +345 -0
  70. package/src/font/iconfont.ttf +0 -0
  71. package/src/font/iconfont.woff +0 -0
  72. package/src/font/iconfont.woff2 +0 -0
  73. package/src/index.ts +68 -0
  74. package/src/locale/Language.ts +10 -0
  75. package/src/locale/LanguageProvider.ts +38 -0
  76. package/src/locale/index.ts +2 -0
  77. package/src/theme/global.less +91 -0
  78. package/src/theme/index.ts +155 -0
  79. package/src/tool/ArrayUtils.ts +38 -0
  80. package/src/tool/Color.ts +7 -0
  81. package/src/tool/Draggable.ts +36 -0
  82. package/src/tool/Listener.ts +59 -0
  83. package/src/tool/index.ts +4 -0
@@ -0,0 +1,155 @@
1
+ import '../font/iconfont.css'
2
+ import '../theme/global.less'
3
+ import { reactive } from "vue"
4
+
5
+ interface ThemeConfig {
6
+ whiteColor: string
7
+ blackColor: string
8
+ blueColor: string
9
+ greenColor: string
10
+ yellowColor: string
11
+ redColor: string
12
+
13
+ successColor: string
14
+ warningColor: string
15
+ dangerColor: string
16
+
17
+ topicColor: string
18
+ activeTopicColor: string
19
+ fontColor: string
20
+ titleColor: string
21
+ borderColor: string
22
+ helperColor: string
23
+ disabledColor: string
24
+ draggableColor: string
25
+ flashingDraggableColor: string
26
+
27
+ fontSize: { unit: string, value: number }
28
+ titleSize: { unit: string, value: number }
29
+ borderSize: { unit: string, value: number }
30
+ radiusSize: { unit: string, value: number }
31
+
32
+ zIndex: number
33
+
34
+ animationTime: { unit: string, value: number }
35
+
36
+ scrollBarColor: string
37
+
38
+ inputHeight: { unit: string, value: number }
39
+ inputRadius: { unit: string, value: number }
40
+ inputLRPadding: { unit: string, value: number }
41
+ inputFontSize: { unit: string, value: number }
42
+ inputIconSize: { unit: string, value: number }
43
+ inputBorderSize: { unit: string, value: number }
44
+ inputFontColor: string
45
+ inputBorderColor: string
46
+ inputPlaceholderColor: string
47
+ inputBackgroundColor: string
48
+
49
+ optionMargin: { unit: string, value: number }
50
+ optionArrowSize: { unit: string, value: number }
51
+ optionBackgroundColor: string
52
+ optionHoverBackgroundColor: string
53
+ optionExpandBackgroundColor: string
54
+ optionDisabledBackgroundColor: string
55
+
56
+ optionsScrollMargin: { unit: string, value: number }
57
+ optionsBorderColor: string
58
+ optionsBackgroundColor: string
59
+
60
+ dialogHeaderBackgroundColor: string
61
+
62
+ popoverBackgroundColor: string
63
+
64
+ notifyZIndex: number
65
+ }
66
+
67
+ const transform = (source: string, split: RegExp, replace: RegExp) => {
68
+ const clips = source.split(split)
69
+ const codes: string[] = []
70
+ for (const clip of clips) codes.push(clip.replace(replace, '$1-').toLowerCase())
71
+ return '--vyr-' + codes.join('-')
72
+ }
73
+
74
+ class Theme {
75
+ static config: ThemeConfig = reactive({
76
+ whiteColor: 'rgba(255, 255, 255, 1)',
77
+ blackColor: 'rgba(0, 0, 0, 1)',
78
+ blueColor: 'rgba(27, 143, 223, 1)',
79
+ greenColor: 'rgba(106, 210, 54, 1)',
80
+ yellowColor: 'rgba(230, 162, 60, 1)',
81
+ redColor: 'rgba(245, 108, 108, 1)',
82
+
83
+ successColor: 'rgba(106, 210, 54, 1)',
84
+ warningColor: 'rgba(230, 162, 60, 1)',
85
+ dangerColor: 'rgba(245, 108, 108, 1)',
86
+
87
+ topicColor: 'rgba(30, 30, 30, 1)',
88
+ activeTopicColor: 'rgba(27, 143, 223, 0.8)',
89
+ fontColor: 'rgba(255, 255, 255, 1)',
90
+ titleColor: 'rgba(255, 255, 255, 1)',
91
+ borderColor: 'rgba(46, 46, 46, 1)',
92
+ helperColor: 'rgba(113, 113, 113, 1)',
93
+ disabledColor: 'rgba(175, 175, 175, 1)',
94
+ draggableColor: 'rgba(27, 143, 223, 0.3)',
95
+ flashingDraggableColor: 'rgba(27, 143, 223, 0.8)',
96
+
97
+ fontSize: { unit: 'px', value: 12 },
98
+ titleSize: { unit: 'px', value: 14 },
99
+ borderSize: { unit: 'px', value: 1 },
100
+ radiusSize: { unit: 'px', value: 2 },
101
+
102
+ zIndex: 999,
103
+
104
+ animationTime: { unit: 'ms', value: 500 },
105
+
106
+ scrollBarColor: 'rgba(46, 46, 46, 1)',
107
+
108
+ inputFontSize: { unit: 'px', value: 12 },
109
+ inputHeight: { unit: 'px', value: 30 },
110
+ inputRadius: { unit: 'px', value: 2 },
111
+ inputLRPadding: { unit: 'px', value: 10 },
112
+ inputIconSize: { unit: 'px', value: 20 },
113
+ inputBorderSize: { unit: 'px', value: 1 },
114
+ inputFontColor: 'rgba(255, 255, 255, 1)',
115
+ inputBorderColor: 'rgba(77, 77, 77, 1)',
116
+ inputPlaceholderColor: 'rgba(113, 113, 113, 1)',
117
+ inputBackgroundColor: 'rgba(42, 42, 42, 1)',
118
+
119
+ optionMargin: { unit: 'px', value: 2 },
120
+ optionArrowSize: { unit: 'px', value: 18 },
121
+ optionBackgroundColor: 'rgba(30, 30, 30, 1)',
122
+ optionHoverBackgroundColor: 'rgba(55, 55, 61, 1)',
123
+ optionExpandBackgroundColor: 'rgba(55, 55, 61, 1)',
124
+ optionDisabledBackgroundColor: 'rgba(77, 77, 77, 1)',
125
+
126
+ optionsScrollMargin: { unit: 'px', value: 6 },
127
+ optionsBorderColor: 'rgba(77, 77, 77, 1)',
128
+ optionsBackgroundColor: 'rgba(30, 30, 30, 1)',
129
+
130
+ dialogHeaderBackgroundColor: 'rgba(30, 30, 30, 0.9)',
131
+
132
+ popoverBackgroundColor: 'rgba(30, 30, 30, 1)',
133
+
134
+ notifyZIndex: 2000,
135
+ })
136
+
137
+ static update(config: Partial<ThemeConfig>) {
138
+ const keys = Object.keys(config) as Array<keyof ThemeConfig>
139
+ const style = document.documentElement.style
140
+
141
+ const splitReg = /(?=[A-Z])/
142
+ const replaceReg = /(.)(?=[A-Z])/g
143
+ for (const key of keys) {
144
+ const attribute = config[key] as any
145
+ const value = typeof attribute === 'object' ? attribute.value + attribute.unit : attribute
146
+ const cssVar = transform(key, splitReg, replaceReg)
147
+ style.setProperty(cssVar, value)
148
+ }
149
+ Object.assign(this.config, config)
150
+ }
151
+ }
152
+
153
+ Theme.update(Theme.config)
154
+
155
+ export { ThemeConfig, Theme }
@@ -0,0 +1,38 @@
1
+ class ArrayUtils {
2
+
3
+ static insert<T extends any = any>(arr: T[], item: T) {
4
+ const i = arr.indexOf(item)
5
+ if (i === -1) arr.push(item)
6
+ }
7
+
8
+ static remove<T extends any = any>(arr: T[], item: T) {
9
+ const i = arr.indexOf(item)
10
+ if (i > -1) arr.splice(i, 1)
11
+ }
12
+
13
+ static auto<T extends any = any>(arr: T[], item: T) {
14
+ const i = arr.indexOf(item)
15
+ i === -1 ? arr.push(item) : arr.splice(i, 1)
16
+ }
17
+
18
+ static insertByKey<T extends any = any>(arr: T[], key: keyof T, item: T) {
19
+ const count = arr.length;
20
+ for (let i = 0; i < count; i++) {
21
+ if (arr[i][key] === item[key]) return
22
+ }
23
+ arr.push(item)
24
+ }
25
+
26
+ static removeByKey<T extends any = any, K extends keyof T = keyof T>(arr: T[], key: keyof T, value: T[K]) {
27
+ const count = arr.length;
28
+ for (let i = 0; i < count; i++) {
29
+ const item = arr[i]
30
+ if (item[key] === value) {
31
+ arr.splice(i, 1)
32
+ return
33
+ }
34
+ }
35
+ }
36
+ }
37
+
38
+ export { ArrayUtils }
@@ -0,0 +1,7 @@
1
+ import * as tinycolor from "tinycolor2"
2
+
3
+ const Color = tinycolor.default
4
+
5
+ export{
6
+ Color
7
+ }
@@ -0,0 +1,36 @@
1
+ type DraggableEndType = 'insert' | 'insertBefore' | 'insertAfter'
2
+ interface AdditionalData { [k: string]: any }
3
+ interface DraggableData<T extends AdditionalData = AdditionalData> { id: string, data: T }
4
+
5
+ interface Draggable<D extends AdditionalData = AdditionalData, T extends AdditionalData = D> {
6
+ id: string
7
+
8
+ /**对拖拽的类型进行限制 */
9
+ limit(dragData: DraggableData<D>, targetData: DraggableData<D>, type: DraggableEndType): DraggableEndType
10
+
11
+ updateTargetOfKey<T extends AdditionalData = AdditionalData>(key: string, value: any, target: any): void
12
+
13
+ /**拖拽组的启动器,当托拽功能准备启动拖拽组时会调用该方法。
14
+ *
15
+ * @param dragData 准备拖动的对象
16
+ * @returns 返回值决定了该对象是否可被拖动
17
+ */
18
+ starter(dragData: D): boolean
19
+
20
+ /**拖拽组的验证器,当托拽对象进入目标对象`(该托拽组内的任意一个对象)`时会调用该方法。
21
+ *
22
+ * @param targetData 进入的目标对象
23
+ * @returns 返回值决定了托拽对象能否被放置在目标对象
24
+ */
25
+ validator(dragData: DraggableData<D>, targetData: DraggableData<T>): boolean
26
+
27
+ /**成功完成托拽时该方法将被执行 */
28
+ finished(dragData: DraggableData<D>, targetData: DraggableData<T>, type: DraggableEndType): void
29
+ }
30
+
31
+ export {
32
+ DraggableEndType,
33
+ AdditionalData,
34
+ DraggableData,
35
+ Draggable
36
+ }
@@ -0,0 +1,59 @@
1
+ type DeafultCallback = (...args: any[]) => any
2
+ type CallbackCollection<T extends {} = {}> = { [k: string]: DeafultCallback } & T
3
+
4
+ interface listenOptions {
5
+ once?: boolean
6
+ insertIndex?: number
7
+ }
8
+
9
+ class Listener<T extends {} = {}> {
10
+ private registrys: any = {}
11
+
12
+ listen<K extends keyof T>(type: K, callback: T[K], options?: listenOptions): () => void
13
+ listen(type: string, callback: DeafultCallback, options?: listenOptions): () => void
14
+ listen<K extends keyof T>(type: K | string, callback?: T[K], options: listenOptions = {}) {
15
+
16
+ let register = this.registrys[type]
17
+ if (register === undefined) {
18
+ register = []
19
+ this.registrys[type] = register
20
+ }
21
+ const insertIndex = options.insertIndex === undefined ? register.length : options.insertIndex
22
+
23
+ const row = register.find((r: any) => r.callback === callback)
24
+ if (!row) register.splice(insertIndex, 0, { once: options.once ?? false, callback })
25
+ const unlisten = () => this.unlisten(type as any, callback)
26
+ return unlisten
27
+ }
28
+
29
+ unlisten<K extends keyof T>(type: K, callback: T[K]): void
30
+ unlisten(type: string, callback: DeafultCallback): void
31
+ unlisten<K extends keyof T>(type: K, callback: T[K]) {
32
+ let registry = this.registrys[type]
33
+ if (registry === undefined) return
34
+
35
+ for (let i = 0; i < registry.length; i++) {
36
+ if (registry[i].callback !== callback) continue
37
+
38
+ registry.splice(i, 1)
39
+ if (registry.length === 0) delete this.registrys[type]
40
+ return
41
+ }
42
+ }
43
+
44
+ trigger<K extends keyof T>(type: K, ...args: Parameters<CallbackCollection<T>[K]>): void
45
+ trigger(type: string, ...args: any[]): void
46
+ trigger<K extends keyof T>(type: K, ...args: Parameters<CallbackCollection<T>[K]>) {
47
+ let registry = this.registrys[type]
48
+ if (registry === undefined) return //console.warn(`无法触发该事件 ${type as string}`)
49
+
50
+ if (registry.length === 0) return
51
+
52
+ registry = [...this.registrys[type]]
53
+ for (let i = 0; i < registry.length; i++) {
54
+ registry[i].callback(...args as any)
55
+ if (registry[i].once === true) this.unlisten(type, registry[i].callback)
56
+ }
57
+ }
58
+ }
59
+ export { Listener }
@@ -0,0 +1,4 @@
1
+ export * from './ArrayUtils'
2
+ export * from './Color'
3
+ export * from './Listener'
4
+ export * from './Draggable'