@ithinkdt/ui 4.0.0-9 → 4.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.
package/locale.d.ts ADDED
@@ -0,0 +1,79 @@
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
+ fileSizeExceeded: string
68
+ }
69
+ }
70
+ filter: {
71
+ submitText: string
72
+ expand: string
73
+ collapse: string
74
+ }
75
+ }
76
+ }
77
+
78
+ declare const locale: UILocale
79
+ export default locale
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ithinkdt/ui",
3
- "version": "4.0.0-9",
3
+ "version": "4.0.0",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "description": "iThinkDT UI",
@@ -10,34 +10,35 @@
10
10
  "ui"
11
11
  ],
12
12
  "files": [
13
- "src",
13
+ "dist",
14
+ "esm",
14
15
  "auto-imports.*",
15
- "shims.*",
16
- "unocss.*"
16
+ "locale.*",
17
+ "unocss*"
17
18
  ],
18
- "main": "./src/index.js",
19
- "module": "./src/index.js",
20
- "types": "./src/index.d.ts",
19
+ "main": "./esm/index.js",
20
+ "module": "./esm/index.js",
21
+ "types": "./esm/index.d.ts",
21
22
  "exports": {
22
23
  ".": {
23
- "types": "./src/index.d.ts",
24
- "default": "./src/index.js"
24
+ "types": "./esm/index.d.ts",
25
+ "default": "./esm/index.js"
25
26
  },
26
27
  "./directives": {
27
- "types": "./src/directives.d.ts",
28
- "default": "./src/directives/index.js"
28
+ "types": "./esm/directives.d.ts",
29
+ "default": "./esm/directives.js"
29
30
  },
30
31
  "./components": {
31
- "types": "./src/components.d.ts",
32
- "default": "./src/components/index.js"
32
+ "types": "./esm/components.d.ts",
33
+ "default": "./esm/components.js"
33
34
  },
34
35
  "./use-style": {
35
- "types": "./src/use-style.d.ts",
36
- "default": "./src/use-style.js"
36
+ "types": "./esm/use-style.d.ts",
37
+ "default": "./esm/use-style.js"
37
38
  },
38
39
  "./page": {
39
- "types": "./src/page.d.ts",
40
- "default": "./src/page.jsx"
40
+ "types": "./esm/page.d.ts",
41
+ "default": "./esm/page.js"
41
42
  },
42
43
  "./package.json": {
43
44
  "default": "./package.json"
@@ -47,8 +48,8 @@
47
48
  "default": "./auto-imports.js"
48
49
  },
49
50
  "./unocss": {
50
- "types": "./unocss.d.ts",
51
- "default": "./unocss.js"
51
+ "types": "./unocss-preset.d.ts",
52
+ "default": "./unocss-preset.js"
52
53
  }
53
54
  },
54
55
  "publishConfig": {
@@ -57,13 +58,13 @@
57
58
  },
58
59
  "sideEffects": false,
59
60
  "dependencies": {
60
- "@vueuse/core": "^13.9.0",
61
+ "@vueuse/core": "^14.2.0",
61
62
  "date-fns": "^4.1.0",
62
63
  "vueuc": "^0.4.65",
63
64
  "sortablejs": "^1.15.6",
64
- "@types/sortablejs": "^1.15.8",
65
+ "@types/sortablejs": "^1.15.9",
65
66
  "nanoid": "^5.1.6",
66
- "@ithinkdt/common": "^4.0.0-9"
67
+ "@ithinkdt/common": "^4.0.0"
67
68
  },
68
69
  "peerDependencies": {
69
70
  "@ithinkdt/page": ">=4.0",
@@ -81,19 +82,18 @@
81
82
  }
82
83
  },
83
84
  "devDependencies": {
84
- "@vitejs/plugin-vue-jsx": "^5.1.1",
85
- "ithinkdt-ui": "^1.7.3",
85
+ "@vitejs/plugin-vue-jsx": "^5.1.4",
86
+ "ithinkdt-ui": "^1.8.3",
86
87
  "typescript": "~5.9.3",
87
- "unocss": ">=66.5.2",
88
- "vite": "npm:rolldown-vite@^7.1.16",
89
- "vue": "^3.5.22",
90
- "vue-router": "^4.5.1",
91
- "@ithinkdt/page": "^4.0.0-9"
88
+ "unocss": ">=66.6.0",
89
+ "vite": "^8.0.0-beta.11",
90
+ "vue": "^3.5.27",
91
+ "vue-router": "^5.0.2",
92
+ "@ithinkdt/page": "^4.0.0"
92
93
  },
93
94
  "scripts": {
94
- "build": " vite build && cp -r ./_src/*.d.ts ./src",
95
- "prerelease": "cp -r ./src ./_src && pnpm run build",
96
- "release": "pnpm publish --no-git-checks",
97
- "postrelease": "rm -rf ./src && cp -r ./_src ./src && rm -rf ./_src"
95
+ "dev": "vite build --watch",
96
+ "build": "vite build",
97
+ "release": "pnpm run build && pnpm publish --no-git-checks"
98
98
  }
99
99
  }
@@ -0,0 +1,5 @@
1
+ import { Preset, PresetWind4Theme } from 'unocss'
2
+
3
+ declare const ithinkdt: (options?: { namespace?: string | undefined }) => Preset<PresetWind4Theme>[]
4
+
5
+ export default ithinkdt
@@ -0,0 +1,163 @@
1
+ import { presetWind4, transformerDirectives, transformerVariantGroup } from 'unocss'
2
+
3
+ const ithinkdt = (options = {}) => {
4
+ const { namespace: ns } = options
5
+
6
+ let wind4, postprocess
7
+ if (ns) {
8
+ wind4 = () => {
9
+ const plugin = presetWind4({
10
+ variablePrefix: `${ns}-`,
11
+ preflights: {
12
+ reset: false,
13
+ property: {
14
+ selector: `.${ns} :where(*, ::before, ::after)`,
15
+ },
16
+ },
17
+ })
18
+
19
+ return {
20
+ ...plugin,
21
+ preflights: plugin.preflights?.map((preflight) => {
22
+ if (preflight.layer === 'theme') {
23
+ return {
24
+ ...preflight,
25
+ async getCSS(ctx) {
26
+ let result = await preflight.getCSS?.(ctx)
27
+ if (result) {
28
+ result = result.replace(':root, :host', `.${ns}`)
29
+ }
30
+ return result
31
+ },
32
+ }
33
+ } else if (preflight.layer === 'properties') {
34
+ return {
35
+ ...preflight,
36
+ async getCSS(ctx) {
37
+ let result = await preflight.getCSS?.(ctx)
38
+ if (result) {
39
+ result = result
40
+ .replaceAll('--un-', `--${ns}-`)
41
+ }
42
+ return result
43
+ },
44
+ }
45
+ }
46
+ return preflight
47
+ }),
48
+ }
49
+ }
50
+ postprocess = [
51
+ (p) => {
52
+ if (p.selector.includes('--un-')) {
53
+ p.selector = p.selector.replaceAll('--un-', `--${ns}-`)
54
+ } else if (p.selector.endsWith(String.raw`.\-`)) {
55
+ if (p.selector.startsWith('.dark ')) {
56
+ p.selector = `.dark & ${p.selector.slice(6)}`
57
+ }
58
+ } else {
59
+ p.selector = p.selector.startsWith('.dark ') ? `.dark .${ns} ${p.selector.slice(6)}` : `.${ns} ${p.selector}`
60
+ }
61
+ },
62
+ ]
63
+ } else { wind4 = presetWind4 }
64
+
65
+ const alphas = [50, 100, 200, 300, 400, 500, 600, 700, 800, 900, 950]
66
+ const ithinkdt = {
67
+ name: 'preset-ithinkdt',
68
+ options,
69
+ theme: {
70
+ colors: {
71
+ ...Object.fromEntries(
72
+ ['primary', 'success', 'warning', 'danger'].map(name => [
73
+ name,
74
+ {
75
+ DEFAULT: `var(--color-${name})`,
76
+ ...Object.fromEntries(alphas.map(alpha => [`${alpha}`, `color-mix(in oklab, var(--color-${name}) ${alpha / 10}%, #fff ${(1000 - alpha) / 10}%)`])),
77
+ ...Object.fromEntries(
78
+ ['hover', 'active'].flatMap(level => [
79
+ [level, `var(--color-${name}-${level})`],
80
+ ...alphas.map(alpha => [`${level}-${alpha}`, `color-mix(in oklab, var(--color-${name}-${level}) ${alpha / 10}%, #fff ${(1000 - alpha) / 10}%)`]),
81
+ ]),
82
+ ),
83
+ },
84
+ ]),
85
+ ),
86
+ text: {
87
+ DEFAULT: `var(--color-text)`,
88
+ ...Object.fromEntries(alphas.map(alpha => [`${alpha}`, `color-mix(in oklab, var(--color-text) ${alpha / 10}%, #fff ${(1000 - alpha) / 10}%)`])),
89
+ },
90
+ base: { DEFAULT: `var(--color-base)` },
91
+ },
92
+ radius: Object.fromEntries(
93
+ ['xs', 'sm', 'md', 'lg'].map(size => [size, `var(--rounded-${size})`]),
94
+ ),
95
+ },
96
+ variants: [
97
+ // stuck:
98
+ (matcher) => {
99
+ const array = ['top', 'right', 'bottom', 'left']
100
+ const index = array.findIndex(it => matcher.startsWith(`stuck-${it}:`))
101
+ if (index === -1)
102
+ return matcher
103
+ return {
104
+ matcher: matcher.slice(7 + array[index].length),
105
+ handle: (input, next) => next({
106
+ ...input,
107
+ parent: `${input.parent ? `${input.parent} $$ ` : ''} @container scroll-state(stuck: ${array[index]})`,
108
+ }),
109
+ }
110
+ },
111
+ ],
112
+ rules: [
113
+ ['scroll-state', { 'container-type': 'scroll-state' }],
114
+ [
115
+ /^bg-img-(.*)$/,
116
+ ([_, r]) => {
117
+ return {
118
+ 'background-image': r[0] === '[' && r.at(-1) === ']' ? r.slice(1, -1) : r,
119
+ }
120
+ },
121
+ ],
122
+ [
123
+ /^mask-(.*)$/,
124
+ ([_, r]) => {
125
+ const mask = `var(--un-icon) no-repeat`
126
+ return {
127
+ '--un-icon': r[0] === '[' && r.at(-1) === ']' ? r.slice(1, -1) : r,
128
+ mask,
129
+ 'mask-size': '100% 100%',
130
+ }
131
+ },
132
+ ],
133
+ ],
134
+ shortcuts: [
135
+ [
136
+ /^card-(.*)$/,
137
+ ([_, size]) => {
138
+ const i = ['none', 'sm', 'md', 'lg'].indexOf(size)
139
+ if (i === -1) return
140
+ const p = [0, 2, 4, 5][i]
141
+ return `rounded-${size} px-${p + 1} py-${p} bg-white dark:bg-dark ease-in-out transition-shadow
142
+ 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)]`
143
+ },
144
+ { autocomplete: ['card-none', 'card-sm', 'card-md', 'card-lg'] },
145
+ ],
146
+ {
147
+ 'ell': 'truncate',
148
+ 'ell-2': 'line-clamp-2 whitespace-normal',
149
+ 'ell-3': 'line-clamp-3 whitespace-normal',
150
+ 'flex-center': 'flex justify-center items-center',
151
+ 'card': `card-md`,
152
+ },
153
+ ],
154
+ transformers: [transformerDirectives(), transformerVariantGroup()],
155
+ postprocess: postprocess,
156
+ }
157
+ return [
158
+ wind4(),
159
+ ithinkdt,
160
+ ]
161
+ }
162
+
163
+ export default ithinkdt
package/src/page.d.ts DELETED
@@ -1,153 +0,0 @@
1
- import {
2
- CheckboxProps, DatePickerProps, DatePickerSlots,
3
- DrawerContentProps, DrawerProps,
4
- InputNumberProps, InputNumberSlots, InputProps, InputSlots,
5
- ModalOptions,
6
- SelectGroupOption, SelectOption, SelectProps, SelectSlots,
7
- UploadFileInfo,
8
- } from 'ithinkdt-ui'
9
- import { MaybeRef, VNode, VNodeProps } from 'vue'
10
-
11
- import { DictItem, DictTypeKey } from '@ithinkdt/common/dict'
12
- import { PageOptions } from '@ithinkdt/page'
13
-
14
- import { CheckboxesProps, RadiosProps, UserDeptProps, UserGroupOption } from './components'
15
-
16
- type DeepMaybeRef<T extends {}> = {
17
- [Key in (keyof T)]: MaybeRef<T[Key]>
18
- }
19
-
20
- declare module '@ithinkdt/page' {
21
- interface FormComponentPresets {
22
- input: {
23
- props?: DeepMaybeRef<Omit<InputProps, 'value' | 'onUpdate:value' | 'disabled'>> & VNodeProps
24
- slots?: InputSlots
25
- }
26
- number: {
27
- props?: DeepMaybeRef<Omit<InputNumberProps, 'value' | 'onUpdate:value' | 'disabled'>> & VNodeProps
28
- slots?: InputNumberSlots
29
- }
30
- select: {
31
- props?: DeepMaybeRef<Omit<SelectProps, 'options' | 'value' | 'onUpdate:value' | 'disabled'> & VNodeProps
32
- & {
33
- dictType?: DictTypeKey | undefined
34
- options?: DictItem[] | (SelectOption | SelectGroupOption)[] | undefined
35
- }>
36
- slots?: SelectSlots
37
- }
38
-
39
- checkbox: {
40
- props?: DeepMaybeRef<Omit<CheckboxProps, 'checked' | 'onUpdate:checked' | 'disabled'>> & VNodeProps
41
- slots?: {
42
- default?: (() => VNode[]) | undefined
43
- checked?: (() => VNode[]) | undefined
44
- unchecked?: (() => VNode[]) | undefined
45
- }
46
- }
47
-
48
- checkboxes: {
49
- props?: DeepMaybeRef<Omit<CheckboxesProps, 'disabled'> & VNodeProps
50
- & {
51
- dictType?: DictTypeKey | undefined
52
- options?: DictItem[] | undefined
53
- }>
54
- slots?: { }
55
- }
56
-
57
- radios: {
58
- props?: DeepMaybeRef<Omit<RadiosProps, 'disabled'> & VNodeProps
59
- & {
60
- dictType?: DictTypeKey | undefined
61
- options?: DictItem[] | undefined
62
- }>
63
- slots?: { }
64
- }
65
-
66
- datepicker: {
67
- props?: DeepMaybeRef<Omit<DatePickerProps, 'value' | 'onUpdate:value' | 'disabled'>> & VNodeProps
68
- slots?: DatePickerSlots
69
- }
70
-
71
- file: {
72
- props?: DeepMaybeRef<{
73
- type?: 'file' | 'image' | undefined
74
- multiple?: boolean | undefined
75
- max?: number | undefined
76
- accept?: string | undefined
77
- maxSize?: number | undefined
78
- } & VNodeProps>
79
- slots?: {
80
- default?: (() => VNode[]) | undefined
81
- }
82
- }
83
-
84
- user: {
85
- props?: DeepMaybeRef<Omit<UserDeptProps<boolean>, 'modelValue' | 'onUpdate:modelValue' | 'disabled'
86
- | 'users' | 'groups' | 'depts' | 'getUsersByGroup' | 'getUsersByDept'>> & VNodeProps
87
- slots?: {}
88
- }
89
- }
90
-
91
- interface TableTypePresets {
92
- number: {
93
- /** 保留 n 位小数(保留 0) */
94
- fixed?: number | undefined
95
- /** 保留 n 位小数(不保留 0) */
96
- round?: number | undefined
97
- /** 保留 n 位数(不保留 0) */
98
- precision?: number | undefined
99
- /** 使用数字分隔符 */
100
- separator?: boolean | undefined
101
- /** 是否为百分数 */
102
- percent?: boolean | undefined
103
- }
104
-
105
- date: {
106
- formatter?: 'yyyy-MM-dd' | 'yyyy/MM/dd' | string & {} | undefined
107
- }
108
-
109
- datetime: {
110
- formatter?: 'yyyy-MM-dd HH:mm' | 'yyyy-MM-dd HH:mm:ss' | string & {} | undefined
111
- }
112
-
113
- dict: {
114
- dictType?: DictTypeKey | undefined
115
- options?: DictItem[] | (SelectOption | SelectGroupOption)[] | undefined
116
- multiple?: boolean | undefined
117
- labelField?: string | undefined
118
- valueField?: string | undefined
119
- statusMap?: Record<string, 'primary' | 'success' | 'warning' | 'danger' | string & {} | undefined> | undefined
120
- }
121
- email: {}
122
- url: {}
123
- color: {}
124
- file: { multiple?: boolean | undefined }
125
- image: { multiple?: boolean | undefined }
126
- user: { multiple?: boolean | undefined }
127
- dept: { multiple?: boolean | undefined }
128
- }
129
-
130
- type ModalOptionsKey = 'type' | keyof import('@ithinkdt/page').ModalOptions
131
- interface ModalDrawerOptions extends DeepMaybeRef<Omit<DrawerContentProps, ModalOptionsKey>>, DeepMaybeRef<Omit<DrawerProps, ModalOptionsKey>> { }
132
-
133
- interface ModalDialogOptions extends DeepMaybeRef<Omit<ModalOptions, ModalOptionsKey>> {}
134
- }
135
-
136
- export declare function createPageFormHelper(options?: {
137
- getUserGroups?: (() => Promise<UserGroupOption[]>) | undefined
138
- getUsersByGroup?: ((code: string) => Promise<{ username: string, nickname: string }[]>) | undefined
139
- getUsersByDept?: ((code: string) => Promise<{ username: string, nickname: string }[]>) | undefined
140
- getUsersByUsername?: ((usernames: string[]) => Promise<{ username: string, nickname: string }[]>) | undefined
141
- getDeptsByCode?: (codes: string[]) => Promise<{ code: string, name: string }[]>
142
- uploadFile?: (file: File, options?: {
143
- onProgress?: ((percent: number) => void) | undefined
144
- }) => Promise<string>
145
- }): PageOptions['getFormItemRenderer']
146
- export declare function createPageTableHelper(options?: {
147
- getUsersByUsername?: (usernames: string[]) => Promise<{ username: string, nickname: string }[]>
148
- getDeptsByCode?: (codes: string[]) => Promise<{ code: string, name: string }[]>
149
- getFileInfos?: (fileIds: string[]) => Promise<UploadFileInfo[]>
150
- previewFileUrl?: (fileId: string) => string
151
- }): PageOptions['getCellRenderer']
152
- export declare function createFormHelper(options?: { }): PageOptions['getFormRenderer']
153
- export declare function createModalHelper(options?: { }): PageOptions['getModalRenderer']
package/unocss.d.ts DELETED
@@ -1,5 +0,0 @@
1
- import { PresetFactory, PresetUnoTheme } from 'unocss'
2
-
3
- declare const ithinkdt: PresetFactory<PresetUnoTheme, {}>
4
-
5
- export default ithinkdt
package/unocss.js DELETED
@@ -1,95 +0,0 @@
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
- 'page': 'flex flex-col p-5 gap-4',
89
- 'card': `card-medium`,
90
- },
91
- ],
92
- }
93
- }
94
-
95
- export default ithinkdt
File without changes
File without changes