@ithinkdt/ui 4.0.0-36 → 4.0.0-38

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ithinkdt/ui",
3
- "version": "4.0.0-36",
3
+ "version": "4.0.0-38",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "description": "iThinkDT UI",
@@ -88,7 +88,7 @@
88
88
  "vite": "npm:rolldown-vite@^7.1.19",
89
89
  "vue": "^3.5.22",
90
90
  "vue-router": "^4.6.3",
91
- "@ithinkdt/page": "^4.0.0-33"
91
+ "@ithinkdt/page": "^4.0.0-34"
92
92
  },
93
93
  "scripts": {
94
94
  "release": "pnpm publish --no-git-checks"
@@ -44,7 +44,7 @@ function _map(columns, width) {
44
44
  }
45
45
 
46
46
  if (col.children?.length) {
47
- column.children = _map(col.children, width.value)
47
+ column.children = _map(col.children, width)
48
48
  } else {
49
49
  if (col.hidden !== true) {
50
50
  column.width ??= 100
package/src/page.jsx CHANGED
@@ -4,6 +4,7 @@ import {
4
4
  NButton, NCheckbox, NColorPicker, NDatePicker, NDrawer, NDrawerContent, NFlex, NInput,
5
5
  NInputNumber, NModal, NScrollbar, NSelect, NText, NUpload, useMessage,
6
6
  } from 'ithinkdt-ui'
7
+ import { useFormItem } from 'ithinkdt-ui/es/_mixins'
7
8
  import { computed, defineComponent, h, mergeProps, ref, shallowRef, unref } from 'vue'
8
9
 
9
10
  import { useDict, useDictMap } from '@ithinkdt/common/dict'
@@ -19,6 +20,7 @@ const SimpleUpload = /* @__PURE__ */ defineComponent({
19
20
  name: 'SimpleUpload',
20
21
  props: {
21
22
  type: { type: String, default: 'file' }, // file | image
23
+ size: { type: String, default: 'medium' },
22
24
  multiple: { type: Boolean, default: false },
23
25
  max: { type: Number, default: undefined },
24
26
  accept: { type: String, default: undefined },
@@ -32,6 +34,8 @@ const SimpleUpload = /* @__PURE__ */ defineComponent({
32
34
  const { t } = useI18n()
33
35
  SimpleUpload.t = t
34
36
 
37
+ const formItem = useFormItem(props)
38
+
35
39
  const message = useMessage()
36
40
  const customRequest = computed(() => props.customRequest || (
37
41
  ({ file, onProgress, onFinish, onError }) => {
@@ -52,6 +56,11 @@ const SimpleUpload = /* @__PURE__ */ defineComponent({
52
56
  return until(inst).toBeTruthy().then(inst => inst.submit())
53
57
  },
54
58
  })
59
+
60
+ const onUpdate = (fileList) => {
61
+ props.onUpdateFileList?.(fileList)
62
+ nextTick(() => formItem.nTriggerFormChange())
63
+ }
55
64
  return () => {
56
65
  const { type, onUpdateFileList, ...props0 } = props
57
66
  return (
@@ -61,10 +70,16 @@ const SimpleUpload = /* @__PURE__ */ defineComponent({
61
70
  customRequest={customRequest.value}
62
71
  listType={type === 'image' ? 'image-card' : 'text'}
63
72
  accept={props0.accept ?? type === 'image' ? 'image/*' : undefined}
64
- onUpdate:fileList={onUpdateFileList}
73
+ onUpdate:fileList={onUpdate}
65
74
  >
66
75
  {{
67
- default: () => <NButton disabled={props.disabled}>{t('common.page.form.selectFileText')}</NButton>,
76
+ default: () => (
77
+ <NButton disabled={formItem.mergedDisabledRef.value} size={formItem.mergedSizeRef.value}>
78
+ {
79
+ t('common.page.form.selectFileText')
80
+ }
81
+ </NButton>
82
+ ),
68
83
  ...slots,
69
84
  }}
70
85
  </NUpload>
@@ -125,12 +140,12 @@ export function createPageFormHelper({
125
140
  }
126
141
  if (readonly) {
127
142
  if (props.multiple) {
128
- const items = modelValue ? options0?.filter(item => modelValue.includes(item[props.valueField || 'value'])) : []
143
+ const items = modelValue?.map(it => options0?.find(it2 => it2[props.valueField || 'value'] === it)) ?? []
129
144
  return (
130
145
  <NText depth={2} style="line-height: 1.25">
131
146
  {
132
147
  items.map((it, i, arr) => {
133
- const vn = props.renderLabel ? props.renderLabel(it) ?? '' : it[props.labelField || 'label'] ?? ''
148
+ const vn = it ? (props.renderLabel ? props.renderLabel(it) ?? '' : it[props.labelField || 'label'] ?? '') : (modelValue[i] ?? '')
134
149
  return (
135
150
  <span key={it[props.valueField || 'value']}>
136
151
  {vn}
@@ -143,7 +158,7 @@ export function createPageFormHelper({
143
158
  )
144
159
  } else {
145
160
  const it = options0?.find(item => item[props.valueField || 'value'] === modelValue)
146
- return <NText depth={2} style="line-height: 1.25">{it ? props.renderLabel ? props.renderLabel(it) ?? '' : it[props.labelField || 'label'] ?? '' : ''}</NText>
161
+ return <NText depth={2} style="line-height: 1.25">{it ? (props.renderLabel ? props.renderLabel(it) ?? '' : it[props.labelField || 'label'] ?? '') : (modelValue ?? '')}</NText>
147
162
  }
148
163
  }
149
164
 
@@ -200,12 +215,12 @@ export function createPageFormHelper({
200
215
  }
201
216
  }
202
217
  if (readonly) {
203
- const items = options0?.filter(item => modelValue.includes(item[props.valueField ?? 'value']))
218
+ const items = modelValue?.map(it => options0?.find(it2 => it2[props.valueField || 'value'] === it)) ?? []
204
219
  return (
205
220
  <NText depth={2} style="line-height: 2.4">
206
221
  {
207
222
  items.map((it, i, arr) => {
208
- const vn = it[props.labelField ?? 'label'] ?? ''
223
+ const vn = it ? (it[props.labelField ?? 'label'] ?? '') : (modelValue[i] ?? '')
209
224
  return (
210
225
  <span key={it[props.valueField ?? 'value']}>
211
226
  {vn}
@@ -248,7 +263,7 @@ export function createPageFormHelper({
248
263
 
249
264
  if (readonly) {
250
265
  const it = options0?.find(item => item[props.valueField ?? 'value'] === modelValue)
251
- return <NText depth={2} style="line-height: 1.25">{it?.[props.labelField ?? 'label'] ?? ''}</NText>
266
+ return <NText depth={2} style="line-height: 1.25">{it ? (it[props.labelField ?? 'label'] ?? '') : (modelValue ?? '')}</NText>
252
267
  }
253
268
 
254
269
  return h(