@otwb/ui 2.0.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.
@@ -0,0 +1,42 @@
1
+ import { Directive, VNode, VNodeChild } from 'vue'
2
+
3
+ export declare const SpinDirectiveProvider: (props: { dark?: boolean }) => VNode
4
+
5
+ /**
6
+ * directive 加载效果
7
+ *
8
+ * 支持 dom dataset 参数 'data-spin-tip'
9
+ *
10
+ * 将在容器最后 append 元素,如果容器的 position 是 static,将修改为 relative。如出现样式问题请注意排查
11
+ *
12
+ * 支持的修饰符
13
+ * - 'light' | 'dark' | 'auto' 暗色|亮色|自动模式
14
+ */
15
+ export declare const vSpin: Directive<HTMLElement, void | undefined | string | boolean | number, 'light' | 'dark'>
16
+
17
+ export declare const TooltipDirectiveProvider: (props: { delay?: number }) => VNode
18
+
19
+ /**
20
+ * directive 弹出提示
21
+ *
22
+ * 支持的修饰符
23
+ * - 'auto' 当内容溢出来容器时自动展示,否则隐藏
24
+ * - 'left-end'、'left'、'left-start'、'top-start'、'top'、'top-end'、'right-start'、'right'、'right-end'、'bottom-end'、'bottom'、'bottom-start' 弹出内容的位置
25
+ */
26
+ export declare const vTooltip: Directive<
27
+ HTMLElement,
28
+ VNodeChild,
29
+ | 'auto'
30
+ | 'left-end'
31
+ | 'left'
32
+ | 'left-start'
33
+ | 'top-start'
34
+ | 'top'
35
+ | 'top-end'
36
+ | 'right-start'
37
+ | 'right'
38
+ | 'right-end'
39
+ | 'bottom-end'
40
+ | 'bottom'
41
+ | 'bottom-start'
42
+ >
@@ -0,0 +1 @@
1
+ export * from '../dist/directives.js'
package/esm/index.d.ts ADDED
@@ -0,0 +1,19 @@
1
+ import { VNode } from 'vue'
2
+
3
+ import { I18nComposable, ParseMessage } from '@otwb/common/i18n'
4
+
5
+ import { UILocale } from '../locale.js'
6
+
7
+ import '../shims.js'
8
+
9
+ export * from './directives.js'
10
+ export * from './design.js'
11
+
12
+ export { UILocale }
13
+
14
+ /** Props for {@link UIProvider} */
15
+ export interface UIProviderProps {
16
+ i18n?: I18nComposable<ParseMessage<UILocale, 'common'>>
17
+ }
18
+
19
+ export declare const UIProvider: (props: UIProviderProps) => VNode
package/esm/index.js ADDED
@@ -0,0 +1 @@
1
+ export * from '../dist/index.js'
package/esm/page.d.ts ADDED
@@ -0,0 +1,170 @@
1
+ import {
2
+ CheckboxProps,
3
+ DatePickerProps, DatePickerSlots,
4
+ DrawerContentProps, DrawerProps,
5
+ InputNumberProps, InputNumberSlots, InputProps, InputSlots,
6
+ ModalOptions,
7
+ SelectGroupOption, SelectOption, SelectProps, SelectSlots,
8
+ UploadFileInfo, UploadProps,
9
+ } from 'ithinkdt-ui'
10
+ import { MaybeRef, VNode } from 'vue'
11
+
12
+ import { PublicProps } from '@otwb/common'
13
+ import { DictItem, DictTypeKey } from '@otwb/common/dict'
14
+ import { PageOptions } from '@otwb/page'
15
+
16
+ import { CheckboxesProps, RadiosProps, UserDeptProps, UserGroupOption } from './components'
17
+
18
+ type ShallowMaybeRef<T extends {}> = {
19
+ [Key in (keyof T)]: MaybeRef<T[Key]>
20
+ }
21
+
22
+ declare module '@otwb/page' {
23
+ interface FormComponentPresets {
24
+ input: {
25
+ inputProps?: ShallowMaybeRef<Omit<InputProps, 'value' | 'onUpdate:value' | 'disabled'>> & PublicProps
26
+ inputSlots?: InputSlots
27
+ }
28
+ number: {
29
+ numberProps?: ShallowMaybeRef<Omit<InputNumberProps, 'value' | 'onUpdate:value' | 'disabled'>> & PublicProps
30
+ numberSlots?: InputNumberSlots
31
+ }
32
+ select: {
33
+ selectProps?: ShallowMaybeRef<Omit<SelectProps, 'options' | 'value' | 'onUpdate:value' | 'disabled'> & PublicProps
34
+ & {
35
+ dictType?: DictTypeKey | undefined
36
+ options?: DictItem[] | (SelectOption | SelectGroupOption)[] | undefined
37
+ }>
38
+ selectSlots?: SelectSlots
39
+ }
40
+
41
+ checkbox: {
42
+ checkboxProps?: ShallowMaybeRef<Omit<CheckboxProps, 'checked' | 'onUpdate:checked' | 'disabled'>> & PublicProps
43
+ checkboxSlots?: {
44
+ default?: (() => VNode[]) | undefined
45
+ checked?: (() => VNode[]) | undefined
46
+ unchecked?: (() => VNode[]) | undefined
47
+ }
48
+ }
49
+
50
+ checkboxes: {
51
+ checkboxesProps?: ShallowMaybeRef<Omit<CheckboxesProps, 'disabled'> & PublicProps
52
+ & {
53
+ dictType?: DictTypeKey | undefined
54
+ options?: DictItem[] | undefined
55
+ }>
56
+ checkboxesSlots?: { }
57
+ }
58
+
59
+ radios: {
60
+ radiosProps?: ShallowMaybeRef<Omit<RadiosProps, 'disabled'> & PublicProps
61
+ & {
62
+ dictType?: DictTypeKey | undefined
63
+ options?: DictItem[] | undefined
64
+ }>
65
+ radiosSlots?: { }
66
+ }
67
+
68
+ datepicker: {
69
+ datepickerProps?: ShallowMaybeRef<Omit<DatePickerProps, 'value' | 'onUpdate:value' | 'disabled'>> & PublicProps
70
+ datepickerSlots?: DatePickerSlots
71
+ }
72
+
73
+ file: {
74
+ fileProps?: ShallowMaybeRef<{
75
+ type?: 'file' | 'image' | undefined
76
+ multiple?: boolean | undefined
77
+ max?: number | undefined
78
+ accept?: string | undefined
79
+ maxSize?: number | undefined
80
+ onBeforeUpload?: UploadProps['onBeforeUpload']
81
+ } & PublicProps>
82
+ fileSlots?: {
83
+ default?: (() => VNode[]) | undefined
84
+ }
85
+ }
86
+ upload: {
87
+ uploadProps?: ShallowMaybeRef<{
88
+ type?: 'file' | 'image' | undefined
89
+ multiple?: boolean | undefined
90
+ max?: number | undefined
91
+ accept?: string | undefined
92
+ maxSize?: number | undefined
93
+ onBeforeUpload?: UploadProps['onBeforeUpload']
94
+ } & PublicProps>
95
+ uploadSlots?: {
96
+ default?: (() => VNode[]) | undefined
97
+ }
98
+ }
99
+
100
+ user: {
101
+ userProps?: ShallowMaybeRef<Omit<UserDeptProps<boolean>, 'modelValue' | 'onUpdate:modelValue' | 'disabled'
102
+ | 'users' | 'groups' | 'depts' | 'getUsersByGroup' | 'getUsersByDept'>> & PublicProps
103
+ userSlots?: {}
104
+ }
105
+ }
106
+
107
+ interface TableTypePresets {
108
+ number: {
109
+ /** 保留 n 位小数(保留 0) */
110
+ fixed?: number | undefined
111
+ /** 保留 n 位小数(不保留 0) */
112
+ round?: number | undefined
113
+ /** 保留 n 位数(不保留 0) */
114
+ precision?: number | undefined
115
+ /** 使用数字分隔符 */
116
+ separator?: boolean | undefined
117
+ /** 是否为百分数 */
118
+ percent?: boolean | undefined
119
+ }
120
+
121
+ date: {
122
+ formatter?: 'yyyy-MM-dd' | 'yyyy/MM/dd' | string & {} | undefined
123
+ }
124
+
125
+ datetime: {
126
+ formatter?: 'yyyy-MM-dd HH:mm' | 'yyyy-MM-dd HH:mm:ss' | string & {} | undefined
127
+ }
128
+
129
+ dict: {
130
+ dictType?: DictTypeKey | undefined
131
+ options?: DictItem[] | (SelectOption | SelectGroupOption)[] | undefined
132
+ multiple?: boolean | undefined
133
+ labelField?: string | undefined
134
+ valueField?: string | undefined
135
+ statusMap?: Record<string, 'primary' | 'success' | 'warning' | 'danger' | string & {} | undefined> | undefined
136
+ }
137
+ email: {}
138
+ url: {}
139
+ color: {}
140
+ file: { multiple?: boolean | undefined }
141
+ image: { multiple?: boolean | undefined }
142
+ user: { multiple?: boolean | undefined }
143
+ dept: { multiple?: boolean | undefined }
144
+ }
145
+
146
+ type ModalOptionsKey = 'type' | keyof import('@otwb/page').ModalOptions
147
+ interface ModalDrawerOptions extends ShallowMaybeRef<Omit<DrawerContentProps, ModalOptionsKey>>, ShallowMaybeRef<Omit<DrawerProps, ModalOptionsKey>> { }
148
+
149
+ interface ModalDialogOptions extends ShallowMaybeRef<Omit<ModalOptions, ModalOptionsKey>> {}
150
+ }
151
+
152
+ export declare function createPageFormHelper(options?: {
153
+ getUserGroups?: (() => Promise<UserGroupOption[]>) | undefined
154
+ getUsersByGroup?: ((code: string) => Promise<{ username: string, nickname: string }[]>) | undefined
155
+ getUsersByDept?: ((code: string) => Promise<{ username: string, nickname: string }[]>) | undefined
156
+ getUsersByUsername?: ((usernames: string[]) => Promise<{ username: string, nickname: string }[]>) | undefined
157
+ getDeptsByCode?: (codes: string[]) => Promise<{ code: string, name: string }[]>
158
+ uploadFile?: (file: File, options?: {
159
+ onProgress?: ((percent: number) => void) | undefined
160
+ }) => Promise<string>
161
+ getFileInfos?: (files: string[]) => Promise<UploadFileInfo[]>
162
+ }): PageOptions['getFormItemRenderer']
163
+ export declare function createPageTableHelper(options?: {
164
+ getUsersByUsername?: (usernames: string[]) => Promise<{ username: string, nickname: string }[]>
165
+ getDeptsByCode?: (codes: string[]) => Promise<{ code: string, name: string }[]>
166
+ getFileInfos?: (fileIds: string[]) => Promise<UploadFileInfo[]>
167
+ previewFileUrl?: (fileId: string) => string
168
+ }): PageOptions['getCellRenderer']
169
+ export declare function createFormHelper(options?: { }): PageOptions['getFormRenderer']
170
+ export declare function createModalHelper(options?: { }): PageOptions['getModalRenderer']
package/esm/page.js ADDED
@@ -0,0 +1 @@
1
+ export * from '../dist/page.js'
@@ -0,0 +1,10 @@
1
+ import _useStyle from 'ithinkdt-ui/es/_mixins/use-style'
2
+ import { Ref } from 'vue'
3
+
4
+ export { c, cB, cE, cM } from 'ithinkdt-ui/es/_utils/cssr/index'
5
+
6
+ export declare function useClsPrefix(): Ref<string>
7
+
8
+ declare function useStyle(...params: Parameters<typeof _useStyle>): Ref<string>
9
+
10
+ export default useStyle
@@ -0,0 +1 @@
1
+ export { c, cB, cE, cM, default, useClsPrefix } from '../dist/use-style.js'
package/locale.d.ts ADDED
@@ -0,0 +1,78 @@
1
+ export interface UILocale {
2
+ all: string
3
+ back: string
4
+ layout: {
5
+ sider: {
6
+ collapse: string
7
+ expand: string
8
+ }
9
+ screen: {
10
+ full: string
11
+ exitfull: string
12
+ }
13
+ mode: {
14
+ auto: string
15
+ light: string
16
+ dark: string
17
+ }
18
+ tabs: {
19
+ exitFullTab: string
20
+ fullTab: string
21
+ reloadTab: string
22
+ openTabBlank: string
23
+ closeAllTabs: string
24
+ closeLeftTabs: string
25
+ closeRightTabs: string
26
+ closeOtherTabs: string
27
+ }
28
+ }
29
+ account: {
30
+ logout: string
31
+ changePwd: string
32
+ changeTenant: string
33
+ }
34
+ notification: {
35
+ tip: (params: { count?: number | null }) => string
36
+ title: string
37
+ all: string
38
+ unread: (params: { count: string }) => string
39
+ markPageRead: string
40
+ markRead: string
41
+ markDelete: string
42
+ time: string
43
+ }
44
+ timeago: (params: { time: string | number | Date }) => string
45
+ page: {
46
+ selection: {
47
+ countText: (params: { count: number }) => string
48
+ back: string
49
+ view: string
50
+ clear: string
51
+ }
52
+ pagination: {
53
+ prefix: (params: { total: number }) => string
54
+ suffix: string
55
+ }
56
+ custom: {
57
+ tooltip: string
58
+ reset: string
59
+ }
60
+ form: {
61
+ submitText: string
62
+ resetText: string
63
+ cancelText: string
64
+ selectFileText: string
65
+ validate: {
66
+ fileErrorMessage: string
67
+ }
68
+ }
69
+ filter: {
70
+ submitText: string
71
+ expand: string
72
+ collapse: string
73
+ }
74
+ }
75
+ }
76
+
77
+ declare const locale: UILocale
78
+ export default locale
package/package.json ADDED
@@ -0,0 +1,99 @@
1
+ {
2
+ "name": "@otwb/ui",
3
+ "version": "2.0.0",
4
+ "type": "module",
5
+ "license": "MIT",
6
+ "description": "otwb UI",
7
+ "keywords": [
8
+ "otwb",
9
+ "vue",
10
+ "ui"
11
+ ],
12
+ "files": [
13
+ "dist",
14
+ "esm",
15
+ "auto-imports.*",
16
+ "locale.*",
17
+ "unocss*"
18
+ ],
19
+ "main": "./esm/index.js",
20
+ "module": "./esm/index.js",
21
+ "types": "./esm/index.d.ts",
22
+ "exports": {
23
+ ".": {
24
+ "types": "./esm/index.d.ts",
25
+ "default": "./esm/index.js"
26
+ },
27
+ "./directives": {
28
+ "types": "./esm/directives.d.ts",
29
+ "default": "./esm/directives.js"
30
+ },
31
+ "./components": {
32
+ "types": "./esm/components.d.ts",
33
+ "default": "./esm/components.js"
34
+ },
35
+ "./use-style": {
36
+ "types": "./esm/use-style.d.ts",
37
+ "default": "./esm/use-style.js"
38
+ },
39
+ "./page": {
40
+ "types": "./esm/page.d.ts",
41
+ "default": "./esm/page.js"
42
+ },
43
+ "./package.json": {
44
+ "default": "./package.json"
45
+ },
46
+ "./auto-imports": {
47
+ "types": "./auto-imports.d.ts",
48
+ "default": "./auto-imports.js"
49
+ },
50
+ "./unocss": {
51
+ "types": "./unocss-preset.d.ts",
52
+ "default": "./unocss-preset.js"
53
+ }
54
+ },
55
+ "publishConfig": {
56
+ "registry": "https://registry.npmjs.org/",
57
+ "access": "public"
58
+ },
59
+ "sideEffects": false,
60
+ "dependencies": {
61
+ "@vueuse/core": "^14.0.0",
62
+ "date-fns": "^4.1.0",
63
+ "vueuc": "^0.4.65",
64
+ "sortablejs": "^1.15.6",
65
+ "@types/sortablejs": "^1.15.9",
66
+ "nanoid": "^5.1.6",
67
+ "@otwb/common": "^2.0.0"
68
+ },
69
+ "peerDependencies": {
70
+ "@otwb/page": ">=4.0",
71
+ "vue": ">=3.5",
72
+ "vue-router": ">=4.5",
73
+ "ithinkdt-ui": ">=1.5",
74
+ "unocss": ">=66"
75
+ },
76
+ "peerDependenciesMeta": {
77
+ "@otwb/page": {
78
+ "optional": true
79
+ },
80
+ "unocss": {
81
+ "optional": true
82
+ }
83
+ },
84
+ "devDependencies": {
85
+ "@vitejs/plugin-vue-jsx": "^5.1.1",
86
+ "ithinkdt-ui": "^1.8.0",
87
+ "typescript": "~5.9.3",
88
+ "unocss": ">=66.5.4",
89
+ "vite": "npm:rolldown-vite@^7.1.20",
90
+ "vue": "^3.5.22",
91
+ "vue-router": "^4.6.3",
92
+ "@otwb/page": "^5.0.0-10"
93
+ },
94
+ "scripts": {
95
+ "dev": "vite build --watch",
96
+ "build": "vite build",
97
+ "release": "pnpm run build && pnpm publish --no-git-checks"
98
+ }
99
+ }
@@ -0,0 +1,5 @@
1
+ import { PresetFactory, PresetUnoTheme } from 'unocss'
2
+
3
+ declare const ithinkdt: PresetFactory<PresetUnoTheme, {}>
4
+
5
+ export default ithinkdt
@@ -0,0 +1,94 @@
1
+ const ithinkdt = () => {
2
+ return {
3
+ name: 'preset-ithinkdt',
4
+ theme: {
5
+ colors: {
6
+ ...Object.fromEntries(
7
+ ['primary', 'success', 'warning', 'danger'].map(name => [
8
+ name,
9
+ {
10
+ DEFAULT: `rgb(var(--color-${name}-rgb) / <alpha-value>)`,
11
+ ...Object.fromEntries(
12
+ ['hover', 'active'].map(level => [
13
+ level,
14
+ `rgb(var(--color-${name}-${level}-rgb) / <alpha-value>)`,
15
+ ]),
16
+ ),
17
+ },
18
+ ]),
19
+ ),
20
+ text: {
21
+ DEFAULT: `rgb(var(--color-text-rgb))`,
22
+ },
23
+ base: {
24
+ DEFAULT: `rgb(var(--color-base-rgb))`,
25
+ },
26
+ },
27
+ borderRadius: Object.fromEntries(
28
+ ['tiny', 'small', 'medium', 'large'].map(size => [size, `var(--rounded-${size})`]),
29
+ ),
30
+ },
31
+ variants: [
32
+ // stuck:
33
+ (matcher) => {
34
+ const array = ['top', 'right', 'bottom', 'left']
35
+ const index = array.findIndex(it => matcher.startsWith(`stuck-${it}:`))
36
+ if (index === -1)
37
+ return matcher
38
+ return {
39
+ matcher: matcher.slice(7 + array[index].length),
40
+ handle: (input, next) => next({
41
+ ...input,
42
+ parent: `${input.parent ? `${input.parent} $$ ` : ''} @container scroll-state(stuck: ${array[index]})`,
43
+ }),
44
+ }
45
+ },
46
+ ],
47
+ rules: [
48
+ ['scroll-state', { 'container-type': 'scroll-state' }],
49
+ [
50
+ /^bg-img-(.*)$/,
51
+ ([_, r]) => {
52
+ return {
53
+ 'background-image': r[0] === '[' && r.at(-1) === ']' ? r.slice(1, -1) : r,
54
+ }
55
+ },
56
+ ],
57
+ [
58
+ /^mask-(.*)$/,
59
+ ([_, r]) => {
60
+ const mask = `var(--un-icon) no-repeat`
61
+ return {
62
+ '--un-icon': r[0] === '[' && r.at(-1) === ']' ? r.slice(1, -1) : r,
63
+ mask,
64
+ 'mask-size': '100% 100%',
65
+ }
66
+ },
67
+ ],
68
+ ],
69
+ shortcuts: [
70
+ [
71
+ /^card-(.*)$/,
72
+ ([_, size]) => {
73
+ const i = ['none', 'small', 'medium', 'large'].indexOf(size)
74
+ if (i === -1) return
75
+ const p = [0, 2, 4, 5][i]
76
+ return `rounded-${size} px-${p + 1} py-${p} bg-white dark:bg-dark ease-in-out transition-shadow
77
+ hover:shadow-[0_1px_2px_0_rgba(0_0_0_/_0.03),0_1px_6px_-1px_rgba(0_0_0_/_0.02),0_2px_4px_0_rgba(0_0_0_/_0.02)]`
78
+ },
79
+ { autocomplete: ['card-none', 'card-small', 'card-medium', 'card-large'] },
80
+ ],
81
+ {
82
+ 'ell': 'truncate',
83
+ 'ell-2': 'line-clamp-2',
84
+ 'ell-3': 'line-clamp-3',
85
+ 'flex-x-center': 'flex items-center',
86
+ 'flex-y-center': 'flex justify-center',
87
+ 'flex-center': 'flex justify-center items-center',
88
+ 'card': `card-medium`,
89
+ },
90
+ ],
91
+ }
92
+ }
93
+
94
+ export default ithinkdt