@ithinkdt/ui 4.0.0-40 → 4.0.0-400

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.
@@ -1,5 +1,5 @@
1
1
  import {
2
- CheckboxGroupProps, DataTableInst as NDataTableInst, DataTableProps as NDataTableProps,
2
+ CheckboxGroupProps, DataTableInst as NDataTableInst, DataTableProps as NDataTableProps, FlexProps,
3
3
  FormItemGiProps as NFormItemGiProps, FormProps as NFormProps, GridItemProps as NGridItemProps, GridProps as NGridProps,
4
4
  PopoverProps,
5
5
  RadioGroupProps, TransferProps,
@@ -16,6 +16,12 @@ declare module '@ithinkdt/page' {
16
16
 
17
17
  interface FormRenderExtraOptions {
18
18
  showColon?: MaybeRef<boolean | undefined>
19
+ labelWidth?: MaybeRef<string | number | undefined>
20
+ labelAlign?: MaybeRef<'left' | 'right' | 'center' | undefined>
21
+ labelPlacement?: MaybeRef<'left' | 'top' | undefined>
22
+ showRequireMark?: MaybeRef<boolean | undefined>
23
+ requireMarkPlacement?: MaybeRef<'left' | 'right' | 'right-hanging' | undefined>
24
+ showFeedback?: MaybeRef<boolean | undefined>
19
25
  }
20
26
 
21
27
  type FormItemOptionKeys = 'size' | 'showLabel' | 'labelWidth' | 'labelStyle' | 'labelAlign' | 'labelPlacement' | 'labelProps'
@@ -48,16 +54,9 @@ declare module '@ithinkdt/page' {
48
54
 
49
55
  }
50
56
 
51
- export type DataFormProps<Data extends {}> = Omit<NFormProps, 'model' | 'rules' | 'onSubmit' | 'validateMessages'> & {
52
- items: FormItem<Data>[]
53
- model: Data
54
- readonly?: boolean | undefined
55
- grid?: boolean | NGridProps | undefined
56
- validation?: { [k in keyof Data]?: ValidationResults } | undefined
57
- showColon?: boolean | undefined
58
- loading?: boolean | undefined
59
- showAction?: boolean | NGridItemProps & AllowedComponentProps | undefined
60
- actionAlign?: 'start' | 'center' | 'end'
57
+ export type DataFormActionsProps = Pick<FlexProps, 'align' | 'justify' | 'vertical' | 'reverse'> & {
58
+ size?: 'small' | 'medium' | 'large' | undefined
59
+ gap?: number | string | undefined
61
60
  submitText?: VNodeChild | undefined
62
61
  resetText?: VNodeChild | undefined
63
62
  cancelText?: VNodeChild | undefined
@@ -65,21 +64,61 @@ export type DataFormProps<Data extends {}> = Omit<NFormProps, 'model' | 'rules'
65
64
  showResetBtn?: boolean | undefined
66
65
  showCancelBtn?: boolean | undefined
67
66
  submitDisabled?: boolean | undefined
67
+ submitLoading?: boolean | undefined
68
68
  succeeded?: boolean | undefined
69
69
  successText?: VNodeChild | undefined
70
-
71
- tooltipPlacement?: 'bottom' | 'icon' | undefined
72
- onSubmit?: MaybeArray<(model: Data) => void> | undefined
70
+ failureText?: VNodeChild | undefined
71
+ onSubmit?: MaybeArray<() => void> | undefined
73
72
  onRest?: MaybeArray<() => void> | undefined
73
+ onCancel?: MaybeArray<() => void> | undefined
74
+ nativeButtonType?: boolean | undefined
75
+ }
76
+
77
+ export type DataFormActionsEmits = {
78
+ (e: 'submit'): void
79
+ (e: 'reset'): void
80
+ (e: 'cancel'): void
81
+ }
82
+
83
+ export type DataFormActionsSlots = {
84
+ prefix?: () => VNodeChild
85
+ suffix?: () => VNodeChild
74
86
  }
75
87
 
88
+ export declare function DataFormActions(
89
+ props: DataFormActionsProps & PublicProps,
90
+ ctx?: Pick<GenericCtx<DataFormActionsProps, DataFormActionsEmits, DataFormActionsSlots>, 'attrs' | 'emit' | 'slots'>,
91
+ expose?: (exposed?: GenericExposed) => void,
92
+ setup?: GenericCtx<DataFormActionsProps, DataFormActionsEmits, DataFormActionsSlots>,
93
+ ): GenericReturn<DataFormActionsProps, DataFormActionsEmits, DataFormActionsSlots>
94
+
95
+ export type DataFormProps<Data extends {}> = Omit<NFormProps, 'model' | 'rules' | 'onSubmit' | 'validateMessages'>
96
+ & Omit<DataFormActionsProps, 'onSubmit' | 'size' | 'gap' | 'justify' | 'direction' | 'submitloading'> & {
97
+ items: FormItem<Data>[]
98
+ model: Data
99
+ readonly?: boolean | undefined
100
+ grid?: boolean | NGridProps | undefined
101
+ validation?: { [k in keyof Data]?: ValidationResults } | undefined
102
+ showColon?: boolean | undefined
103
+ tooltipPlacement?: 'bottom' | 'icon' | undefined
104
+ loading?: boolean | undefined
105
+ showAction?: boolean | NGridItemProps & AllowedComponentProps | undefined
106
+ actionJustify?: DataFormActionsProps['justify']
107
+ actionAlign?: DataFormActionsProps['align']
108
+ actionGap?: DataFormActionsProps['gap']
109
+ onSubmit?: MaybeArray<(model: Data) => void> | undefined
110
+ }
111
+
76
112
  export type DataFormEmits<Data extends {}> = {
77
113
  (e: 'submit', model: Data): void
78
114
  (e: 'reset'): void
115
+ (e: 'cancel'): void
79
116
  }
80
117
 
81
118
  export type DataFormSlots<_Data extends {}> = {
82
119
  action?: (params: { cols: number, spans: number, overflow: boolean }) => VNodeChild
120
+ actionPrefix?: () => VNodeChild
121
+ actionSuffix?: () => VNodeChild
83
122
  }
84
123
 
85
124
  export type DataFormInst = {
@@ -367,6 +406,7 @@ export interface UserGroupOption {
367
406
  name: string
368
407
  }
369
408
  export interface DeptOption {
409
+ id?: string | undefined
370
410
  code: string
371
411
  name: string
372
412
  children?: DeptOption[]
@@ -382,7 +422,8 @@ interface UserDeptProps<Multiple extends boolean> {
382
422
  'filterable'?: boolean | undefined
383
423
  'disabled'?: boolean | undefined
384
424
  'size'?: TransferProps['size'] | undefined
385
- 'users'?: { username: string, nickname: string }[] | undefined
425
+ 'valueField'?: 'id' | 'username' | 'code' | undefined
426
+ 'users'?: { id?: string | undefined, username: string, nickname: string }[] | undefined
386
427
  'groups'?: UserGroupOption[] | undefined
387
428
  'depts'?: DeptOption[] | undefined
388
429
  'getUsersByGroup'?: ((code: string) => Promise<{ username: string, nickname: string }[]>) | undefined
package/esm/page.d.ts CHANGED
@@ -98,9 +98,9 @@ declare module '@ithinkdt/page' {
98
98
  }
99
99
 
100
100
  user: {
101
- uploadProps?: ShallowMaybeRef<Omit<UserDeptProps<boolean>, 'modelValue' | 'onUpdate:modelValue' | 'disabled'
101
+ userProps?: ShallowMaybeRef<Omit<UserDeptProps<boolean>, 'modelValue' | 'onUpdate:modelValue' | 'disabled'
102
102
  | 'users' | 'groups' | 'depts' | 'getUsersByGroup' | 'getUsersByDept'>> & PublicProps
103
- uploadSlots?: {}
103
+ userSlots?: {}
104
104
  }
105
105
  }
106
106
 
package/esm/use-style.js CHANGED
@@ -1 +1 @@
1
- export * from '../dist/use-style.js'
1
+ export { c, cB, cE, cM, default, useClsPrefix } from '../dist/use-style.js'
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ithinkdt/ui",
3
- "version": "4.0.0-40",
3
+ "version": "4.0.0-400",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "description": "iThinkDT UI",
@@ -14,7 +14,7 @@
14
14
  "esm",
15
15
  "auto-imports.*",
16
16
  "locale.*",
17
- "unocss.*"
17
+ "unocss*"
18
18
  ],
19
19
  "main": "./esm/index.js",
20
20
  "module": "./esm/index.js",
@@ -48,8 +48,8 @@
48
48
  "default": "./auto-imports.js"
49
49
  },
50
50
  "./unocss": {
51
- "types": "./unocss.d.ts",
52
- "default": "./unocss.js"
51
+ "types": "./unocss-preset.d.ts",
52
+ "default": "./unocss-preset.js"
53
53
  }
54
54
  },
55
55
  "publishConfig": {
@@ -62,9 +62,9 @@
62
62
  "date-fns": "^4.1.0",
63
63
  "vueuc": "^0.4.65",
64
64
  "sortablejs": "^1.15.6",
65
- "@types/sortablejs": "^1.15.8",
65
+ "@types/sortablejs": "^1.15.9",
66
66
  "nanoid": "^5.1.6",
67
- "@ithinkdt/common": "^4.0.0-40"
67
+ "@ithinkdt/common": "^4.0.0-400"
68
68
  },
69
69
  "peerDependencies": {
70
70
  "@ithinkdt/page": ">=4.0",
@@ -83,13 +83,13 @@
83
83
  },
84
84
  "devDependencies": {
85
85
  "@vitejs/plugin-vue-jsx": "^5.1.1",
86
- "ithinkdt-ui": "^1.8.0",
86
+ "ithinkdt-ui": "^1.8.1",
87
87
  "typescript": "~5.9.3",
88
- "unocss": ">=66.5.4",
89
- "vite": "npm:rolldown-vite@^7.1.19",
90
- "vue": "^3.5.22",
88
+ "unocss": ">=66.5.6",
89
+ "vite": "npm:rolldown-vite@^7.2.5",
90
+ "vue": "^3.5.24",
91
91
  "vue-router": "^4.6.3",
92
- "@ithinkdt/page": "^4.0.0-40"
92
+ "@ithinkdt/page": "^4.0.0-400"
93
93
  },
94
94
  "scripts": {
95
95
  "dev": "vite build --watch",
@@ -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',
149
+ 'ell-3': 'line-clamp-3',
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/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,94 +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
- 'card': `card-medium`,
89
- },
90
- ],
91
- }
92
- }
93
-
94
- export default ithinkdt