@aplus-frontend/ui 0.2.6 → 0.2.7

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.
@@ -71,10 +71,11 @@ export type ApiFieldRadioExpose = {
71
71
  focus: () => void;
72
72
  blur: () => void;
73
73
  };
74
+ export type ApFieldSwitchConfirmConfig = Pick<PopconfirmProps, 'title' | 'okText' | 'cancelText' | 'description' | 'showCancel' | 'icon' | 'okType' | 'onCancel' | 'okButtonProps' | 'cancelButtonProps'>;
74
75
  export type ApFieldSwitchProps = BasicApFieldProps<Omit<SwitchProps, 'onClick'>> & {
75
76
  emptyText?: string;
76
77
  onAction?: (checked: string | boolean | number, e?: Event) => boolean | Promise<boolean>;
77
- confirm?: Pick<PopconfirmProps, 'title' | 'okText' | 'cancelText' | 'description' | 'showCancel' | 'icon' | 'okType' | 'onCancel'>;
78
+ confirm?: ApFieldSwitchConfirmConfig | ((checked: string | number | boolean) => ApFieldSwitchConfirmConfig);
78
79
  };
79
80
  export type ApFieldTextAreaProps = BasicApFieldProps<Omit<TextAreaProps, 'autosize'>> & {
80
81
  emptyText?: string;
@@ -1,10 +1,10 @@
1
- import { defineComponent as F, useSlots as U, ref as z, unref as o, computed as D, createVNode as u, Fragment as s, openBlock as h, createBlock as k, resolveDynamicComponent as T, createElementBlock as E, mergeProps as p, createSlots as g, renderList as V, withCtx as C, renderSlot as v, normalizeProps as B, guardReactiveProps as w } from "vue";
2
- import { Switch as A, Popconfirm as K } from "@aplus-frontend/antdv";
1
+ import { defineComponent as z, useSlots as D, ref as T, unref as o, computed as g, createVNode as s, Fragment as f, openBlock as h, createBlock as k, resolveDynamicComponent as E, createElementBlock as K, mergeProps as p, createSlots as V, renderList as v, withCtx as C, renderSlot as B, normalizeProps as w, guardReactiveProps as A } from "vue";
2
+ import { Switch as P, Popconfirm as L } from "@aplus-frontend/antdv";
3
3
  import "../../hooks/index.mjs";
4
- import { isNil as L, omit as P } from "lodash-unified";
5
- import { isDef as f } from "@fruits-chain/utils";
6
- import { useControllableValue as M } from "../../hooks/useControllableValue.mjs";
7
- const J = /* @__PURE__ */ F({
4
+ import { isNil as M, isFunction as R, omit as S } from "lodash-unified";
5
+ import { isDef as l } from "@fruits-chain/utils";
6
+ import { useControllableValue as j } from "../../hooks/useControllableValue.mjs";
7
+ const O = /* @__PURE__ */ z({
8
8
  name: "ApFieldSwitch",
9
9
  __name: "index",
10
10
  props: {
@@ -49,76 +49,76 @@ const J = /* @__PURE__ */ F({
49
49
  confirm: {}
50
50
  },
51
51
  emits: ["update:checked"],
52
- setup(S, {
52
+ setup(_, {
53
53
  emit: b
54
54
  }) {
55
- const c = U(), n = S, N = b, {
56
- value: l,
57
- updateValue: a
58
- } = M(n, N, {
55
+ const c = D(), e = _, F = b, {
56
+ value: r,
57
+ updateValue: d
58
+ } = j(e, F, {
59
59
  valuePropName: "checked"
60
- }), i = z(!1);
61
- async function y(e, r) {
62
- if (!f(n.confirm)) {
63
- if (!f(n.onAction)) {
64
- a(e);
60
+ }), a = T(!1);
61
+ async function y(n, u) {
62
+ if (!l(e.confirm)) {
63
+ if (!l(e.onAction)) {
64
+ d(n);
65
65
  return;
66
66
  }
67
- i.value = !0;
67
+ a.value = !0;
68
68
  try {
69
- await n.onAction(e, r) && a(e);
69
+ await e.onAction(n, u) && d(n);
70
70
  } finally {
71
- i.value = !1;
71
+ a.value = !1;
72
72
  }
73
73
  }
74
74
  }
75
- async function _() {
76
- const e = o(l) === n.checkedValue ? n.unCheckedValue : n.checkedValue;
77
- if (!f(n.onAction)) {
78
- a(e);
75
+ async function N() {
76
+ const n = o(r) === e.checkedValue ? e.unCheckedValue : e.checkedValue;
77
+ if (!l(e.onAction)) {
78
+ d(n);
79
79
  return;
80
80
  }
81
- await n.onAction(e) && a(e);
81
+ await e.onAction(n) && d(n);
82
82
  }
83
- const $ = D(() => {
84
- var d, t;
85
- const e = o(l);
86
- return L(e) ? u(s, null, [n.emptyText]) : e === n.checkedValue ? u(s, null, [n.checkedChildren || ((d = c.checkedChildren) == null ? void 0 : d.call(c)) || `${n.checkedValue}`]) : u(s, null, [n.unCheckedChildren || ((t = c.unCheckedChildren) == null ? void 0 : t.call(c)) || `${n.unCheckedValue}`]);
87
- });
88
- return (e, r) => e.mode === "read" ? (h(), k(T($.value), {
83
+ const $ = g(() => {
84
+ var i, t;
85
+ const n = o(r);
86
+ return M(n) ? s(f, null, [e.emptyText]) : n === e.checkedValue ? s(f, null, [e.checkedChildren || ((i = c.checkedChildren) == null ? void 0 : i.call(c)) || `${e.checkedValue}`]) : s(f, null, [e.unCheckedChildren || ((t = c.unCheckedChildren) == null ? void 0 : t.call(c)) || `${e.unCheckedValue}`]);
87
+ }), U = g(() => l(e.confirm) ? R(e.confirm) ? e.confirm(o(r)) : e.confirm : {});
88
+ return (n, u) => n.mode === "read" ? (h(), k(E($.value), {
89
89
  key: 0
90
- })) : (h(), E(s, {
90
+ })) : (h(), K(f, {
91
91
  key: 1
92
- }, [!o(f)(e.confirm) || e.disabled ? (h(), k(o(A), p({
92
+ }, [!o(l)(n.confirm) || n.disabled ? (h(), k(o(P), p({
93
93
  key: 0
94
- }, o(P)(n, "onUpdate:checked"), {
95
- checked: o(l),
94
+ }, o(S)(e, "onUpdate:checked"), {
95
+ checked: o(r),
96
96
  onClick: y,
97
- loading: e.loading ?? i.value
98
- }), g({
97
+ loading: n.loading ?? a.value
98
+ }), V({
99
99
  _: 2
100
- }, [V(c, (d, t) => ({
100
+ }, [v(c, (i, t) => ({
101
101
  name: t,
102
- fn: C((m) => [v(e.$slots, t, B(w(m || {})))])
103
- }))]), 1040, ["checked", "loading"])) : (h(), k(o(K), p({
102
+ fn: C((m) => [B(n.$slots, t, w(A(m || {})))])
103
+ }))]), 1040, ["checked", "loading"])) : (h(), k(o(L), p({
104
104
  key: 1
105
- }, e.confirm || {}, {
106
- onConfirm: _
105
+ }, U.value, {
106
+ onConfirm: N
107
107
  }), {
108
- default: C(() => [u(o(A), p(o(P)(n, "onUpdate:checked"), {
109
- checked: o(l),
108
+ default: C(() => [s(o(P), p(o(S)(e, "onUpdate:checked"), {
109
+ checked: o(r),
110
110
  onClick: y,
111
- loading: e.loading ?? i.value
112
- }), g({
111
+ loading: n.loading ?? a.value
112
+ }), V({
113
113
  _: 2
114
- }, [V(c, (d, t) => ({
114
+ }, [v(c, (i, t) => ({
115
115
  name: t,
116
- fn: C((m) => [v(e.$slots, t, B(w(m || {})))])
116
+ fn: C((m) => [B(n.$slots, t, w(A(m || {})))])
117
117
  }))]), 1040, ["checked", "loading"])]),
118
118
  _: 3
119
119
  }, 16))], 64));
120
120
  }
121
121
  });
122
122
  export {
123
- J as default
123
+ O as default
124
124
  };