@aplus-frontend/ui 0.1.1 → 0.1.3

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.
Files changed (41) hide show
  1. package/es/index.mjs +42 -41
  2. package/es/src/ap-action/item/index.vue2.mjs +13 -13
  3. package/es/src/business/ap-input-radio/ApInputRadio.vue.d.ts +37 -0
  4. package/es/src/business/ap-input-radio/ApInputRadio.vue.mjs +4 -0
  5. package/es/src/business/ap-input-radio/ApInputRadio.vue2.mjs +59 -0
  6. package/es/src/business/ap-input-radio/index.d.ts +3 -0
  7. package/es/src/business/ap-input-radio/interface.d.ts +14 -0
  8. package/es/src/business/ap-input-radio/style.css +7 -0
  9. package/es/src/business/ap-select-layout/index.css +1 -0
  10. package/es/src/business/index.d.ts +152 -1
  11. package/es/src/business/index.mjs +15 -12
  12. package/es/src/editable-table/hooks/use-get-columns.mjs +46 -64
  13. package/es/src/editable-table/interface.d.ts +2 -3
  14. package/es/src/editable-table/utils.d.ts +1 -0
  15. package/es/src/editable-table/utils.mjs +75 -35
  16. package/es/src/index.mjs +188 -187
  17. package/es/src/locale/lang/en.mjs +22 -22
  18. package/es/src/locale/lang/zh-cn.mjs +22 -22
  19. package/es/src/theme/ap-input-radio/ap-input-radio.css +7 -0
  20. package/es/src/theme/ap-select-layout/ap-select-layout.css +1 -0
  21. package/lib/index.js +1 -1
  22. package/lib/src/ap-action/item/index.vue2.js +1 -1
  23. package/lib/src/business/ap-input-radio/ApInputRadio.vue.d.ts +37 -0
  24. package/lib/src/business/ap-input-radio/ApInputRadio.vue.js +1 -0
  25. package/lib/src/business/ap-input-radio/ApInputRadio.vue2.js +1 -0
  26. package/lib/src/business/ap-input-radio/index.d.ts +3 -0
  27. package/lib/src/business/ap-input-radio/interface.d.ts +14 -0
  28. package/lib/src/business/ap-input-radio/style.css +7 -0
  29. package/lib/src/business/ap-select-layout/index.css +1 -0
  30. package/lib/src/business/index.d.ts +152 -1
  31. package/lib/src/business/index.js +1 -1
  32. package/lib/src/editable-table/hooks/use-get-columns.js +1 -1
  33. package/lib/src/editable-table/interface.d.ts +2 -3
  34. package/lib/src/editable-table/utils.d.ts +1 -0
  35. package/lib/src/editable-table/utils.js +1 -1
  36. package/lib/src/index.js +1 -1
  37. package/lib/src/locale/lang/en.js +1 -1
  38. package/lib/src/locale/lang/zh-cn.js +1 -1
  39. package/lib/src/theme/ap-input-radio/ap-input-radio.css +7 -0
  40. package/lib/src/theme/ap-select-layout/ap-select-layout.css +1 -0
  41. package/package.json +2 -2
@@ -1,81 +1,63 @@
1
- import { computed as y, createVNode as s, mergeProps as x } from "vue";
2
- import { omit as C, isFunction as h, isBoolean as R } from "lodash-unified";
3
- import { getEditableComponent as F, mergeClass as T, getRawDisplayValue as I } from "../utils.mjs";
4
- import { updateFormProps as N, getFieldProps as V, getPlaceholder as w, getTableRenderProps as L } from "../../ap-table/utils.mjs";
1
+ import { computed as f } from "vue";
2
+ import { omit as g, isFunction as F } from "lodash-unified";
3
+ import { mergeClass as b, getFinalNode as x } from "../utils.mjs";
4
+ import { updateFormProps as R, getFieldProps as h, getPlaceholder as C, getTableRenderProps as I } from "../../ap-table/utils.mjs";
5
5
  import "../../config-provider/index.mjs";
6
- import { apTableRenderItemMap as M, noRenderAsFormItemValueList as A } from "../../ap-table/constants.mjs";
7
- import { Typography as B } from "ant-design-vue";
8
- import { useLocale as D } from "../../config-provider/hooks/use-locale.mjs";
9
- const v = (t) => {
6
+ import { useLocale as y } from "../../config-provider/hooks/use-locale.mjs";
7
+ const $ = (o) => {
10
8
  const {
11
- t: u
12
- } = D(), f = y(() => {
13
- let l = t.columns;
14
- return l ? (l = l.map((e) => ({
15
- ...C(e, ["ellipsis"]),
9
+ t: i
10
+ } = y();
11
+ return f(() => {
12
+ let d = o.columns;
13
+ return d ? (d = d.map((e) => ({
14
+ ...g(e, ["ellipsis"]),
16
15
  customRender({
17
- value: n,
18
- ...a
16
+ value: t,
17
+ ...l
19
18
  }) {
20
- const i = h(e.editable) ? e.editable(a.text, a.record, a.index) : !!e.editable;
21
- let r;
22
- if (i) {
23
- const d = F(e.valueType), o = N(e, V(e.fieldProps, {
24
- value: n,
25
- ...a
26
- })), c = {};
27
- t.onFieldChange && (c[`onUpdate:${o.valuePropName || "value"}`] = (b) => {
28
- var p;
29
- return (p = t.onFieldChange) == null ? void 0 : p.call(t, a.index, e.dataIndex, b);
30
- });
31
- const g = {
32
- name: [t.name, a.index, e.dataIndex],
33
- ...o || {},
19
+ const a = F(e.editable) ? e.editable(l.text, l.record, l.index) : !!e.editable;
20
+ if (!e.valueType && !e.customRender && !e.customRenderFormItem)
21
+ return console.warn("can not render table cell because no `valueType` / `customRender` / `customRenderFormItem`"), null;
22
+ let c;
23
+ if (a) {
24
+ const n = R(e, h(e.fieldProps, {
25
+ value: t,
26
+ ...l
27
+ })), u = {};
28
+ o.onFieldChange && (u[`onUpdate:${n.valuePropName || "value"}`] = (s) => {
29
+ var m;
30
+ return (m = o.onFieldChange) == null ? void 0 : m.call(o, l.index, e.dataIndex, s);
31
+ }), c = {
32
+ name: [o.name, l.index, e.dataIndex],
33
+ ...n || {},
34
34
  // 格式化placeholder
35
- placeholder: w(u, e.valueType, o == null ? void 0 : o.placeholder),
35
+ placeholder: C(i, e.valueType, n == null ? void 0 : n.placeholder),
36
36
  field: {
37
37
  style: "width: 100%",
38
- ...(o == null ? void 0 : o.field) || {},
39
- ...c,
40
- class: T("is-editable", o.class)
38
+ ...(n == null ? void 0 : n.field) || {},
39
+ ...u,
40
+ class: b("is-editable", n.class)
41
41
  }
42
42
  };
43
- r = s(d, g, null);
44
- } else {
45
- const d = M[e.valueType], o = L(e, {
46
- value: n,
47
- ...a
48
- });
49
- r = m(e, n, s(d, x(o, {
50
- mode: "read"
51
- }), null));
52
- }
43
+ } else
44
+ c = {
45
+ field: I(e, {
46
+ value: t,
47
+ ...l
48
+ })
49
+ };
50
+ const r = x(e, a, c, t);
53
51
  return e.customRender ? e.customRender({
54
- value: n,
55
- ...a,
56
- editable: i,
52
+ value: t,
53
+ ...l,
54
+ editable: a,
57
55
  originalNode: r
58
56
  }) : r;
59
57
  }
60
- })), l) : [];
58
+ })), d) : [];
61
59
  });
62
- function m(l, e, n) {
63
- return A.includes(l.valueType) ? n : l.copyable || l.ellipsis ? s(B.Paragraph, {
64
- copyable: l.copyable ? {
65
- text: e,
66
- tooltip: !1
67
- } : !1,
68
- ellipsis: l.ellipsis ? R(l.ellipsis) ? {
69
- tooltip: e
70
- } : {
71
- ...l.ellipsis,
72
- tooltip: e
73
- } : !1,
74
- content: l.ellipsis ? I(l, e) : n
75
- }, null) : n;
76
- }
77
- return f;
78
60
  };
79
61
  export {
80
- v as default
62
+ $ as default
81
63
  };
@@ -29,10 +29,9 @@ export type EditableColumnType<RecordType = any, ValueType extends ApTableValueT
29
29
  */
30
30
  valueEnum?: ValueEnum;
31
31
  /**
32
- * 自定义表单
33
- * @deprecated 未实现,请使用`customRender`
32
+ * 自定义表单,适用于内置`valueType`不满足的情况下使用
34
33
  */
35
- customRenderFormItem?: (config: EditableColumnType<RecordType, ValueType>) => any;
34
+ customRenderFormItem?: (config: EditableColumnType<RecordType, ValueType>, fieldProps: Record<string, any>, editable: boolean) => any;
36
35
  /**
37
36
  * 指定值类型(将会用于普通列和可编辑表格的渲染)
38
37
  */
@@ -27,3 +27,4 @@ export declare function mergeClass(current: string, classNames?: string | string
27
27
  * @param options
28
28
  */
29
29
  export declare function scrollToRowIndex(index: number, container?: HTMLElement, options?: StandardBehaviorOptions): void;
30
+ export declare function getFinalNode(column: EditableColumnType, editable: boolean, innerProps: Record<string, any>, value: any): any;
@@ -1,50 +1,90 @@
1
- import { isFunction as i, isArray as n } from "lodash-unified";
2
- import { apTableFormItemMap as s } from "../ap-table/constants.mjs";
3
- import { isDef as f } from "../utils/index.mjs";
4
- import { getValueStr as l } from "../ap-field/number/helper.mjs";
5
- import d from "scroll-into-view-if-needed";
6
- function m(r) {
7
- const e = s[r];
8
- return e || console.warn(
9
- `${r} can not render because of no default renderer, use customRender instead.`
10
- ), e;
11
- }
12
- function b(r) {
13
- if (!r.fieldProps)
1
+ import { isVNode as f, createVNode as s, mergeProps as d } from "vue";
2
+ import { isFunction as n, isArray as p, isBoolean as a, omit as u } from "lodash-unified";
3
+ import { apTableFormItemMap as c, noRenderAsFormItemValueList as y, apTableRenderItemMap as m } from "../ap-table/constants.mjs";
4
+ import { isDef as b } from "../utils/index.mjs";
5
+ import { getValueStr as g } from "../ap-field/number/helper.mjs";
6
+ import T from "scroll-into-view-if-needed";
7
+ import { Typography as C } from "ant-design-vue";
8
+ import "../ap-form/index.mjs";
9
+ import I from "../ap-form/ap-form-item.vue.mjs";
10
+ function P(e) {
11
+ return typeof e == "function" || Object.prototype.toString.call(e) === "[object Object]" && !f(e);
12
+ }
13
+ function R(e) {
14
+ return c[e];
15
+ }
16
+ function _(e) {
17
+ if (!e.fieldProps)
14
18
  return !1;
15
- const e = i(r.fieldProps) ? r.fieldProps({}) : r.fieldProps;
16
- return f(e.required) ? e.required : (n(e.rules) ? e.rules : e.rules ? [e.rules] : []).some((t) => t.required);
17
- }
18
- function g(r, e) {
19
- if (r.valueType === "text" || r.valueType === "textArea")
20
- return e || "--";
21
- if (r.valueType === "number") {
22
- const o = r.fieldProps ? i(r.fieldProps) ? r.fieldProps({}) : r.fieldProps : {};
23
- return l(e, o) || "--";
19
+ const r = n(e.fieldProps) ? e.fieldProps({}) : e.fieldProps;
20
+ return b(r.required) ? r.required : (p(r.rules) ? r.rules : r.rules ? [r.rules] : []).some((t) => t.required);
21
+ }
22
+ function F(e, r) {
23
+ if (e.valueType === "text" || e.valueType === "textArea")
24
+ return r || "--";
25
+ if (e.valueType === "number") {
26
+ const o = e.fieldProps ? n(e.fieldProps) ? e.fieldProps({}) : e.fieldProps : {};
27
+ return g(r, o) || "--";
24
28
  }
25
- return e;
29
+ return r;
26
30
  }
27
- function w(r, e) {
28
- const o = [r];
29
- if (e) {
30
- const t = n(e) ? e : [e];
31
+ function D(e, r) {
32
+ const o = [e];
33
+ if (r) {
34
+ const t = p(r) ? r : [r];
31
35
  o.unshift(...t);
32
36
  }
33
37
  return o.join(" ");
34
38
  }
35
- function y(r, e = document.body, o = {}) {
36
- const t = e.querySelectorAll("tr.ant-table-row")[r];
37
- console.log(t), t && d(t, {
39
+ function N(e, r = document.body, o = {}) {
40
+ const t = r.querySelectorAll("tr.ant-table-row")[e];
41
+ console.log(t), t && T(t, {
38
42
  scrollMode: "if-needed",
39
43
  block: "nearest",
40
44
  behavior: "smooth",
41
45
  ...o
42
46
  });
43
47
  }
48
+ function V(e, r, o) {
49
+ return y.includes(e.valueType) ? o : e.copyable || e.ellipsis ? s(C.Paragraph, {
50
+ copyable: e.copyable ? {
51
+ text: r,
52
+ tooltip: !1
53
+ } : !1,
54
+ ellipsis: e.ellipsis ? a(e.ellipsis) ? {
55
+ tooltip: r
56
+ } : {
57
+ ...e.ellipsis,
58
+ tooltip: r
59
+ } : !1,
60
+ content: e.ellipsis ? F(e, r) : o
61
+ }, null) : o;
62
+ }
63
+ function O(e, r, o, t) {
64
+ let l;
65
+ if (e.valueType)
66
+ if (r) {
67
+ const i = R(e.valueType);
68
+ l = s(i, o, null);
69
+ } else {
70
+ const i = m[e.valueType];
71
+ l = V(e, t, s(i, d(o.field, {
72
+ mode: "read"
73
+ }), null));
74
+ }
75
+ if (e.customRenderFormItem) {
76
+ const i = e.customRenderFormItem(e, o.field, r);
77
+ l = s(I, u(o, ["field"]), P(i) ? i : {
78
+ default: () => [i]
79
+ });
80
+ }
81
+ return l;
82
+ }
44
83
  export {
45
- b as getColumnIsRequired,
46
- m as getEditableComponent,
47
- g as getRawDisplayValue,
48
- w as mergeClass,
49
- y as scrollToRowIndex
84
+ _ as getColumnIsRequired,
85
+ R as getEditableComponent,
86
+ O as getFinalNode,
87
+ F as getRawDisplayValue,
88
+ D as mergeClass,
89
+ N as scrollToRowIndex
50
90
  };