@ithinkdt/ui 4.0.0-402 → 4.0.0-403

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/auto-imports.js CHANGED
@@ -13,7 +13,10 @@ export const UIComponents = [
13
13
  {
14
14
  type: 'component',
15
15
  resolve(name) {
16
- return ['DataTable', 'DataForm', 'DataFormActions', 'DataCustom', 'DataFilter', 'DataSelection', 'DataPagination'].includes(name)
16
+ return [
17
+ 'DataTable', 'DataForm', 'DataFormActions', 'DataCustom', 'DataFilter', 'DataSelection', 'DataPagination',
18
+ 'NCheckboxes', 'NRadios', 'NStateButton',
19
+ ].includes(name)
17
20
  ? { name, from: '@ithinkdt/ui/components' }
18
21
  : undefined
19
22
  },
@@ -1732,5 +1732,45 @@ const DtDeptRender = /* @__PURE__ */ defineComponent({
1732
1732
  });
1733
1733
  }, { immediate: !0 }), () => renderUsers(v.value, e);
1734
1734
  }
1735
+ }), StateButtonProps = {
1736
+ disabled: {
1737
+ type: Boolean,
1738
+ default: void 0
1739
+ },
1740
+ succeeded: {
1741
+ type: [Boolean, Object],
1742
+ default: void 0
1743
+ },
1744
+ successText: {
1745
+ type: [
1746
+ String,
1747
+ Number,
1748
+ Object
1749
+ ],
1750
+ default: void 0
1751
+ },
1752
+ failureText: {
1753
+ type: [
1754
+ String,
1755
+ Number,
1756
+ Object
1757
+ ],
1758
+ default: void 0
1759
+ }
1760
+ }, NStateButton = /* @__PURE__ */ defineComponent({
1761
+ name: "StateButton",
1762
+ props: StateButtonProps,
1763
+ setup(e, { slots: v }) {
1764
+ return () => {
1765
+ let { disabled: y, succeeded: b, successText: x, failureText: S } = e;
1766
+ return createVNode(NButton, {
1767
+ type: b ? "success" : b === !1 ? "error" : void 0,
1768
+ disabled: typeof b == "boolean" ? !0 : y
1769
+ }, {
1770
+ default: () => (b ? v.success ? v.success() : x : b === !1 ? v.failure ? v.failure() : S : v.default?.()) ?? v.default(),
1771
+ icon: () => b ? v.successIcon ? v.successIcon() : createVNode(NIcon, null, { default: () => [createVNode(ICheck, null, null)] }) : b === !1 ? v.failureIcon ? v.failureIcon() : createVNode(NIcon, null, { default: () => [createVNode(IClose, null, null)] }) : v.icon?.()
1772
+ });
1773
+ };
1774
+ }
1735
1775
  });
1736
- export { DataActions as _, NRadios as a, DataSelection as c, useLocaleEdit as d, DataFilter as f, DataCustom as g, dataFormActionsProps as h, renderUsers as i, DataPagination as l, DataFormActions as m, DtUserDept as n, DataTable as o, DataForm as p, DtUserRender as r, useDataTableDrag as s, DtDeptRender as t, DataLocaleInput as u, NCheckboxes as v };
1776
+ export { dataFormActionsProps as _, DtUserRender as a, NCheckboxes as b, DataTable as c, DataPagination as d, DataLocaleInput as f, DataFormActions as g, DataForm as h, DtUserDept as i, useDataTableDrag as l, DataFilter as m, StateButtonProps as n, renderUsers as o, useLocaleEdit as p, DtDeptRender as r, NRadios as s, NStateButton as t, DataSelection as u, DataCustom as v, DataActions as y };
@@ -1,5 +1,5 @@
1
1
  import "./use-i18n-Dx7V4KrY.js";
2
2
  import "./directives-qqYcWl1I.js";
3
3
  import "./use-style-DcT-1dj4.js";
4
- import { _ as DataActions, a as NRadios, c as DataSelection, d as useLocaleEdit, f as DataFilter, g as DataCustom, h as dataFormActionsProps, i as renderUsers, l as DataPagination, m as DataFormActions, n as DtUserDept, o as DataTable, p as DataForm, r as DtUserRender, s as useDataTableDrag, t as DtDeptRender, u as DataLocaleInput, v as NCheckboxes } from "./components-B_qzc9ro.js";
5
- export { DataActions, DataCustom, DataFilter, DataForm, DataFormActions, DataLocaleInput, DataPagination, DataSelection, DataTable, DtDeptRender, DtUserDept, DtUserRender, NCheckboxes, NRadios, dataFormActionsProps, renderUsers, useDataTableDrag, useLocaleEdit };
4
+ import { _ as dataFormActionsProps, a as DtUserRender, b as NCheckboxes, c as DataTable, d as DataPagination, f as DataLocaleInput, g as DataFormActions, h as DataForm, i as DtUserDept, l as useDataTableDrag, m as DataFilter, n as StateButtonProps, o as renderUsers, p as useLocaleEdit, r as DtDeptRender, s as NRadios, t as NStateButton, u as DataSelection, v as DataCustom, y as DataActions } from "./components-CYEw_C_U.js";
5
+ export { DataActions, DataCustom, DataFilter, DataForm, DataFormActions, DataLocaleInput, DataPagination, DataSelection, DataTable, DtDeptRender, DtUserDept, DtUserRender, NCheckboxes, NRadios, NStateButton, StateButtonProps, dataFormActionsProps, renderUsers, useDataTableDrag, useLocaleEdit };
package/dist/page.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { n as useI18n } from "./use-i18n-Dx7V4KrY.js";
2
2
  import "./directives-qqYcWl1I.js";
3
3
  import "./use-style-DcT-1dj4.js";
4
- import { a as NRadios, n as DtUserDept, p as DataForm, r as DtUserRender, t as DtDeptRender, v as NCheckboxes } from "./components-B_qzc9ro.js";
4
+ import { a as DtUserRender, b as NCheckboxes, h as DataForm, i as DtUserDept, r as DtDeptRender, s as NRadios } from "./components-CYEw_C_U.js";
5
5
  import { computed, createVNode, defineComponent, h, isVNode, mergeProps, ref, shallowRef, unref } from "vue";
6
6
  import { until } from "@vueuse/core";
7
7
  import { NButton, NCheckbox, NColorPicker, NDatePicker, NDrawer, NDrawerContent, NFlex, NInput, NInputNumber, NModal, NScrollbar, NSelect, NText, NUpload, useMessage } from "ithinkdt-ui";
@@ -156,42 +156,42 @@ function createPageFormHelper({ getUserGroups: n, getUsersByGroup: u, getDeptsBy
156
156
  },
157
157
  checkboxes: () => {
158
158
  let n, c;
159
- return ({ props: l }, { modelValue: u, required: d, readonly: f, ...m }) => {
160
- let { dictType: g, options: v, ...y } = mapProps(l);
161
- if (v ? c = v : n !== g && (n = g, !c && n && (c = useDict(n))), f) {
159
+ return ({ props: u }, { modelValue: d, required: f, readonly: p, ...m }) => {
160
+ let { dictType: g, options: v, ...y } = mapProps(u);
161
+ if (v ? c = v : n !== g && (n = g, !c && n && (c = useDict(n))), p) {
162
162
  let n;
163
163
  return createVNode(NText, {
164
164
  depth: 2,
165
165
  style: "line-height: 2.4"
166
- }, _isSlot(n = (u?.map((n) => c?.find((c) => c[y.valueField || "value"] === n)) ?? []).map((n, c, l) => {
167
- let d = n ? n[y.labelField ?? "label"] ?? "" : u[c] ?? "";
168
- return createVNode("span", { key: n ? n[y.valueField ?? "value"] : u[c] ?? "" }, [d, c < l.length - 1 ? ", " : ""]);
166
+ }, _isSlot(n = (d?.map((n) => c?.find((c) => c[y.valueField || "value"] === n)) ?? []).map((n, c, l) => {
167
+ let u = n ? n[y.labelField ?? "label"] ?? "" : d[c] ?? "";
168
+ return createVNode("span", { key: n ? n[y.valueField ?? "value"] : d[c] ?? "" }, [u, c < l.length - 1 ? ", " : ""]);
169
169
  })) ? n : { default: () => [n] });
170
170
  }
171
171
  return h(NCheckboxes, {
172
172
  ...y,
173
173
  ...m,
174
174
  options: c,
175
- modelValue: u
175
+ modelValue: d
176
176
  });
177
177
  };
178
178
  },
179
179
  radios: () => {
180
- let n, l;
181
- return ({ props: u }, { modelValue: d, required: f, readonly: p, ...m }) => {
182
- let { dictType: g, options: v, ...y } = mapProps(u);
183
- if (v ? l = v : n !== g && (n = g, !l && n && (l = useDict(n))), p) {
184
- let n = l?.find((n) => n[y.valueField ?? "value"] === d);
180
+ let n, c;
181
+ return ({ props: l }, { modelValue: u, required: d, readonly: f, ...m }) => {
182
+ let { dictType: g, options: v, ...y } = mapProps(l);
183
+ if (v ? c = v : n !== g && (n = g, !c && n && (c = useDict(n))), f) {
184
+ let n = c?.find((n) => n[y.valueField ?? "value"] === u);
185
185
  return createVNode(NText, {
186
186
  depth: 2,
187
187
  style: "line-height: 1.25"
188
- }, { default: () => [n ? n[y.labelField ?? "label"] ?? "" : d ?? ""] });
188
+ }, { default: () => [n ? n[y.labelField ?? "label"] ?? "" : u ?? ""] });
189
189
  }
190
190
  return h(NRadios, {
191
191
  ...y,
192
192
  ...m,
193
- options: l,
194
- modelValue: d
193
+ options: c,
194
+ modelValue: u
195
195
  });
196
196
  };
197
197
  },
@@ -287,11 +287,11 @@ function createPageFormHelper({ getUserGroups: n, getUsersByGroup: u, getDeptsBy
287
287
  };
288
288
  },
289
289
  user: () => {
290
- let c, p, v;
290
+ let l, p, v;
291
291
  return ({ slots: y, props: b }, { modelValue: S, "onUpdate:modelValue": C, required: w, readonly: T, ...E }) => {
292
292
  let D = mapProps(b);
293
- return c || (c = shallowRef([]), p = shallowRef([]), v = shallowRef([]), g().then((n) => {
294
- c.value = n;
293
+ return l || (l = shallowRef([]), p = shallowRef([]), v = shallowRef([]), g().then((n) => {
294
+ l.value = n;
295
295
  }), n().then((n) => {
296
296
  p.value = n;
297
297
  }), f().then((n) => {
@@ -302,7 +302,7 @@ function createPageFormHelper({ getUserGroups: n, getUsersByGroup: u, getDeptsBy
302
302
  getUsersByUsername: g
303
303
  }, null) : h(DtUserDept, {
304
304
  type: "user",
305
- users: c.value,
305
+ users: l.value,
306
306
  depts: v.value,
307
307
  groups: p.value,
308
308
  getUsersByDept: m,
@@ -316,7 +316,7 @@ function createPageFormHelper({ getUserGroups: n, getUsersByGroup: u, getDeptsBy
316
316
  }
317
317
  };
318
318
  }
319
- function createPageTableHelper({ getDeptsByCode: n, getUsersByUsername: c, getFileInfos: l, previewFileUrl: u }) {
319
+ function createPageTableHelper({ getDeptsByCode: n, getUsersByUsername: l, getFileInfos: u, previewFileUrl: d }) {
320
320
  let p = (n) => () => (c, l, u, d) => {
321
321
  if (c != null) return format(c, d.formatter ?? n);
322
322
  }, m = (n = {}) => createVNode("svg", mergeProps({
@@ -376,12 +376,12 @@ function createPageTableHelper({ getDeptsByCode: n, getUsersByUsername: c, getFi
376
376
  disabled: !0,
377
377
  size: "small"
378
378
  }, null),
379
- image: () => (n, c, l, d) => {
379
+ image: () => (n, c, l, u) => {
380
380
  let f;
381
381
  return n ? createVNode(NFlex, {
382
382
  gap: "8",
383
383
  wrap: !0
384
- }, _isSlot(f = (Array.isArray(n) ? n : d?.multiple ? n.split(",") : [n]).map((n) => u(n)).map((n) => createVNode("img", {
384
+ }, _isSlot(f = (Array.isArray(n) ? n : u?.multiple ? n.split(",") : [n]).map((n) => d(n)).map((n) => createVNode("img", {
385
385
  key: n,
386
386
  src: n,
387
387
  style: "max-height: 32px; max-width: 100px; object-fit: contain"
@@ -389,14 +389,14 @@ function createPageTableHelper({ getDeptsByCode: n, getUsersByUsername: c, getFi
389
389
  },
390
390
  file: () => {
391
391
  let n = nanoid();
392
- return (c, u, d, f) => {
392
+ return (c, l, d, f) => {
393
393
  let p;
394
- return c ? (u.__file_urls ??= {}, u.__file_urls[n] || l(Array.isArray(c) ? c : f?.multiple ? c.split(",") : [c]).then((c) => {
395
- u.__file_urls[n] = c;
394
+ return c ? (l.__file_urls ??= {}, l.__file_urls[n] || u(Array.isArray(c) ? c : f?.multiple ? c.split(",") : [c]).then((c) => {
395
+ l.__file_urls[n] = c;
396
396
  }), createVNode(NFlex, {
397
397
  gap: "8",
398
398
  wrap: !0
399
- }, _isSlot(p = (u.__file_urls[n] || []).map((n) => createVNode("a", {
399
+ }, _isSlot(p = (l.__file_urls[n] || []).map((n) => createVNode("a", {
400
400
  key: n.id,
401
401
  href: n.url,
402
402
  target: "_blank",
@@ -412,11 +412,11 @@ function createPageTableHelper({ getDeptsByCode: n, getUsersByUsername: c, getFi
412
412
  getDeptsByCode: n
413
413
  }, null);
414
414
  },
415
- user: () => (n, l, u, f) => {
415
+ user: () => (n, u, d, f) => {
416
416
  if (n) return createVNode(DtUserRender, {
417
417
  value: n,
418
418
  multiple: f?.multiple,
419
- getUsersByUsername: c
419
+ getUsersByUsername: l
420
420
  }, null);
421
421
  }
422
422
  };
@@ -1,4 +1,6 @@
1
1
  import {
2
+ ButtonProps,
3
+ ButtonSlots,
2
4
  CheckboxGroupProps, DataTableInst as NDataTableInst, DataTableProps as NDataTableProps, FlexProps,
3
5
  FormItemGiProps as NFormItemGiProps, FormProps as NFormProps, GridItemProps as NGridItemProps, GridProps as NGridProps,
4
6
  PopoverProps,
@@ -51,9 +53,32 @@ declare module '@ithinkdt/page' {
51
53
  interface FormItemRenderExtraParams {
52
54
  size?: 'small' | 'medium' | 'large' | undefined
53
55
  }
56
+ }
57
+
58
+ export type NStateButtonProps = ButtonProps & {
59
+ succeeded?: boolean | null | undefined
60
+ successText?: string | undefined
61
+ failureText?: string | undefined
62
+ }
54
63
 
64
+ export type NStateButtonEmits = {
65
+ (e: 'click', evt: MouseEvent): void
55
66
  }
56
67
 
68
+ export type NStateButtonSlots = ButtonSlots & {
69
+ success?: () => VNodeChild
70
+ failure?: () => VNodeChild
71
+ successIcon?: () => VNodeChild
72
+ failureIcon?: () => VNodeChild
73
+ }
74
+
75
+ export declare function NStateButton(
76
+ props: NStateButtonProps & PublicProps,
77
+ ctx?: Pick<GenericCtx<NStateButtonProps, NStateButtonEmits, NStateButtonSlots>, 'attrs' | 'emit' | 'slots'>,
78
+ expose?: (exposed?: GenericExposed) => void,
79
+ setup?: GenericCtx<NStateButtonProps, NStateButtonEmits, NStateButtonSlots>,
80
+ ): GenericReturn<NStateButtonProps, NStateButtonEmits, NStateButtonSlots>
81
+
57
82
  export type DataFormActionsProps = Pick<FlexProps, 'align' | 'justify' | 'vertical' | 'reverse'> & {
58
83
  size?: 'small' | 'medium' | 'large' | undefined
59
84
  gap?: number | string | undefined
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ithinkdt/ui",
3
- "version": "4.0.0-402",
3
+ "version": "4.0.0-403",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "description": "iThinkDT UI",