@ys-knife-crud/taro 0.0.4 → 0.0.5

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/dist/index.js CHANGED
@@ -1,22 +1,22 @@
1
- import { defineComponent as Y, ref as p, computed as P, watch as O, getCurrentInstance as G, onMounted as U, openBlock as u, createElementBlock as r, normalizeStyle as z, createElementVNode as d, Fragment as j, renderList as q, normalizeClass as T, createCommentVNode as w, renderSlot as S, toDisplayString as F, nextTick as H, inject as W, onBeforeUnmount as X, useSlots as Z, shallowRef as ee, provide as te, withDirectives as le, vShow as ne, createVNode as L, withCtx as D } from "vue";
2
- import { createSelectorQuery as ae } from "@tarojs/taro";
3
- import { emptyFilter as se, FilterInfo as ie } from "@ys-knife-crud/core";
4
- import './index.css';const oe = ["lower-threshold"], ue = { class: "yk-infinite-list__content" }, re = ["onTap"], ce = {
1
+ import { defineComponent as Y, ref as w, computed as B, watch as X, getCurrentInstance as ae, onMounted as G, openBlock as d, createElementBlock as v, normalizeStyle as z, createElementVNode as s, Fragment as L, renderList as H, normalizeClass as T, createCommentVNode as b, renderSlot as V, toDisplayString as C, nextTick as ie, inject as re, onBeforeUnmount as se, useSlots as ue, shallowRef as oe, provide as ce, withDirectives as fe, vShow as de, createBlock as K, withCtx as q, unref as F, withModifiers as W, createVNode as J } from "vue";
2
+ import { createSelectorQuery as ye } from "@tarojs/taro";
3
+ import { emptyFilter as me, FilterInfo as ve, filter as A, con as M, Operator as Q } from "@ys-knife-crud/core";
4
+ import './index.css';const he = ["lower-threshold"], ge = { class: "yk-infinite-list__content" }, pe = ["onTap"], ke = {
5
5
  key: 0,
6
6
  class: "yk-infinite-list__checkbox-icon"
7
- }, de = { class: "yk-infinite-list__item-body" }, fe = { class: "yk-infinite-list__item-json" }, ye = {
7
+ }, _e = { class: "yk-infinite-list__item-body" }, xe = { class: "yk-infinite-list__item-json" }, Se = {
8
8
  key: 0,
9
9
  class: "yk-infinite-list__status"
10
- }, me = {
10
+ }, we = {
11
11
  key: 1,
12
12
  class: "yk-infinite-list__status"
13
- }, he = { class: "yk-infinite-list__status-text" }, ve = {
13
+ }, be = { class: "yk-infinite-list__status-text" }, Ce = {
14
14
  key: 2,
15
15
  class: "yk-infinite-list__loading-more"
16
- }, ge = {
16
+ }, $e = {
17
17
  key: 3,
18
18
  class: "yk-infinite-list__no-more"
19
- }, we = /* @__PURE__ */ Y({
19
+ }, Fe = /* @__PURE__ */ Y({
20
20
  name: "YsInfiniteList",
21
21
  __name: "infinite-list",
22
22
  props: {
@@ -47,172 +47,172 @@ import './index.css';const oe = ["lower-threshold"], ue = { class: "yk-infinite-
47
47
  showCheckbox: { type: Boolean, default: !1 }
48
48
  },
49
49
  emits: ["data-loaded", "error", "selection-change"],
50
- setup(e, { expose: x, emit: y }) {
51
- const l = e, c = y, m = p([]), v = p(!1), h = p(!1), i = p(!0), n = p(null), f = p(0), b = P(() => m.value.length), g = p(/* @__PURE__ */ new Map()), I = P(() => [...g.value.values()]);
52
- function _(t) {
53
- return g.value.has(String(t[l.rowKey]));
50
+ setup(e, { expose: a, emit: n }) {
51
+ const t = e, c = n, f = w([]), i = w(!1), l = w(!1), r = w(!0), u = w(null), h = w(0), x = B(() => f.value.length), m = w(/* @__PURE__ */ new Map()), $ = B(() => [...m.value.values()]);
52
+ function S(g) {
53
+ return m.value.has(String(g[t.rowKey]));
54
54
  }
55
- function R(t, s) {
56
- const a = String(t[l.rowKey]), C = new Map(g.value), $ = C.has(a), V = s ?? !$;
57
- V && !$ ? C.set(a, t) : !V && $ && C.delete(a), g.value = C;
55
+ function I(g, k) {
56
+ const p = String(g[t.rowKey]), R = new Map(m.value), E = R.has(p), N = k ?? !E;
57
+ N && !E ? R.set(p, g) : !N && E && R.delete(p), m.value = R;
58
58
  }
59
59
  function o() {
60
- g.value = /* @__PURE__ */ new Map();
60
+ m.value = /* @__PURE__ */ new Map();
61
61
  }
62
- function k() {
63
- const t = new Map(g.value);
64
- for (const s of m.value) t.set(String(s[l.rowKey]), s);
65
- g.value = t;
62
+ function y() {
63
+ const g = new Map(m.value);
64
+ for (const k of f.value) g.set(String(k[t.rowKey]), k);
65
+ m.value = g;
66
66
  }
67
- function B() {
68
- const t = new Map(g.value);
69
- for (const s of m.value) {
70
- const a = String(s[l.rowKey]);
71
- t.has(a) ? t.delete(a) : t.set(a, s);
67
+ function _() {
68
+ const g = new Map(m.value);
69
+ for (const k of f.value) {
70
+ const p = String(k[t.rowKey]);
71
+ g.has(p) ? g.delete(p) : g.set(p, k);
72
72
  }
73
- g.value = t;
73
+ m.value = g;
74
74
  }
75
- O(I, (t) => c("selection-change", [...t]));
76
- async function E(t) {
77
- if (t) {
78
- if (h.value || v.value || !i.value) return;
79
- h.value = !0;
75
+ X($, (g) => c("selection-change", [...g]));
76
+ async function P(g) {
77
+ if (g) {
78
+ if (l.value || i.value || !r.value) return;
79
+ l.value = !0;
80
80
  } else {
81
- if (v.value) return;
82
- v.value = !0, n.value = null;
81
+ if (i.value) return;
82
+ i.value = !0, u.value = null;
83
83
  }
84
84
  try {
85
- const s = t ? b.value : 0, a = await l.dataFun({ limit: l.pageSize, offset: s });
86
- t ? m.value.push(...a.items) : m.value = a.items, i.value = a.hasNext ?? !1, a.totalCount != null && (f.value = a.totalCount), c("data-loaded", a, t);
87
- } catch (s) {
88
- n.value = s, c("error", s);
85
+ const k = g ? x.value : 0, p = await t.dataFun({ limit: t.pageSize, offset: k });
86
+ g ? f.value.push(...p.items) : f.value = p.items, r.value = p.hasNext ?? !1, p.totalCount != null && (h.value = p.totalCount), c("data-loaded", p, g);
87
+ } catch (k) {
88
+ u.value = k, c("error", k);
89
89
  } finally {
90
- t ? h.value = !1 : v.value = !1, n.value || Q();
90
+ g ? l.value = !1 : i.value = !1, u.value || ne();
91
91
  }
92
92
  }
93
- function K() {
94
- E(!0);
93
+ function j() {
94
+ P(!0);
95
95
  }
96
- function N() {
97
- i.value = !0, E(!1);
96
+ function D() {
97
+ r.value = !0, P(!1);
98
98
  }
99
- function J() {
100
- i.value && !v.value && !h.value && K();
99
+ function le() {
100
+ r.value && !i.value && !l.value && j();
101
101
  }
102
- const M = G();
103
- async function Q() {
104
- if (!i.value || v.value || h.value) return;
105
- await H();
106
- const t = M == null ? void 0 : M.proxy;
107
- t && await new Promise((s) => {
108
- ae().in(t).select(".yk-infinite-list").boundingClientRect().select(".yk-infinite-list__content").boundingClientRect().exec((a) => {
109
- const C = a ?? [], $ = C[0], V = C[1];
110
- $ && V && V.height <= $.height + 1 && K(), s();
102
+ const U = ae();
103
+ async function ne() {
104
+ if (!r.value || i.value || l.value) return;
105
+ await ie();
106
+ const g = U == null ? void 0 : U.proxy;
107
+ g && await new Promise((k) => {
108
+ ye().in(g).select(".yk-infinite-list").boundingClientRect().select(".yk-infinite-list__content").boundingClientRect().exec((p) => {
109
+ const R = p ?? [], E = R[0], N = R[1];
110
+ E && N && N.height <= E.height + 1 && j(), k();
111
111
  });
112
112
  });
113
113
  }
114
- return U(() => {
115
- l.immediate && E(!1);
116
- }), O(() => l.dataFun, () => N()), x({
114
+ return G(() => {
115
+ t.immediate && P(!1);
116
+ }), X(() => t.dataFun, () => D()), a({
117
117
  /** 当前已加载的全部数据 */
118
- items: m,
118
+ items: f,
119
119
  /** 首屏加载态 */
120
- loading: v,
120
+ loading: i,
121
121
  /** 追加加载态 */
122
- loadingMore: h,
122
+ loadingMore: l,
123
123
  /** 是否还有下一页 */
124
- hasMore: i,
124
+ hasMore: r,
125
125
  /** 重置并从第一页重新加载 */
126
- reload: N,
126
+ reload: D,
127
127
  /** 刷新:重置为第一页重新加载(与 YsTable 的 refresh 同名同义) */
128
- refresh: N,
128
+ refresh: D,
129
129
  /** 手动触发加载下一页(一般由触底自动触发) */
130
- loadNextPage: K,
130
+ loadNextPage: j,
131
131
  /** rows 别名:当前已加载的全部数据(与 YsTable 的 rows 同名) */
132
- rows: m,
132
+ rows: f,
133
133
  /** 跨页累计选中的行(showCheckbox 开启时有意义) */
134
- selectedRows: I,
134
+ selectedRows: $,
135
135
  /** 某行当前是否选中 */
136
- isRowSelected: _,
136
+ isRowSelected: S,
137
137
  /** 切换某行选中态(selected 缺省时取反) */
138
- toggleRowSelection: R,
138
+ toggleRowSelection: I,
139
139
  /** 清空全部选中 */
140
140
  clearSelection: o,
141
141
  /** 选中当前已加载的全部行 */
142
- selectAllOnPage: k,
142
+ selectAllOnPage: y,
143
143
  /** 反选当前已加载的行 */
144
- invertSelectionOnPage: B
145
- }), (t, s) => (u(), r("scroll-view", {
144
+ invertSelectionOnPage: _
145
+ }), (g, k) => (d(), v("scroll-view", {
146
146
  class: "yk-infinite-list",
147
147
  style: z({ height: e.height }),
148
148
  "scroll-y": "",
149
149
  "lower-threshold": e.threshold,
150
- onScrolltolower: J
150
+ onScrolltolower: le
151
151
  }, [
152
- d("view", ue, [
153
- (u(!0), r(j, null, q(m.value, (a, C) => (u(), r("view", {
154
- key: String(a[e.rowKey]),
155
- class: T(["yk-infinite-list__item", { "is-selected": e.showCheckbox && _(a) }])
152
+ s("view", ge, [
153
+ (d(!0), v(L, null, H(f.value, (p, R) => (d(), v("view", {
154
+ key: String(p[e.rowKey]),
155
+ class: T(["yk-infinite-list__item", { "is-selected": e.showCheckbox && S(p) }])
156
156
  }, [
157
- e.showCheckbox ? (u(), r("view", {
157
+ e.showCheckbox ? (d(), v("view", {
158
158
  key: 0,
159
- class: T(["yk-infinite-list__item-checkbox", { "is-checked": _(a) }]),
160
- onTap: ($) => R(a)
159
+ class: T(["yk-infinite-list__item-checkbox", { "is-checked": S(p) }]),
160
+ onTap: (E) => I(p)
161
161
  }, [
162
- _(a) ? (u(), r("text", ce, "✓")) : w("", !0)
163
- ], 42, re)) : w("", !0),
164
- d("view", de, [
165
- S(t.$slots, "default", {
166
- row: a,
167
- index: C
162
+ S(p) ? (d(), v("text", ke, "✓")) : b("", !0)
163
+ ], 42, pe)) : b("", !0),
164
+ s("view", _e, [
165
+ V(g.$slots, "default", {
166
+ row: p,
167
+ index: R
168
168
  }, () => [
169
- d("text", fe, F(JSON.stringify(a)), 1)
169
+ s("text", xe, C(JSON.stringify(p)), 1)
170
170
  ])
171
171
  ])
172
172
  ], 2))), 128)),
173
- !v.value && m.value.length === 0 && !n.value ? (u(), r("view", ye, [
174
- S(t.$slots, "empty", {}, () => [
175
- s[0] || (s[0] = d("text", { class: "yk-infinite-list__status-text" }, "暂无数据", -1))
173
+ !i.value && f.value.length === 0 && !u.value ? (d(), v("view", Se, [
174
+ V(g.$slots, "empty", {}, () => [
175
+ k[0] || (k[0] = s("text", { class: "yk-infinite-list__status-text" }, "暂无数据", -1))
176
176
  ])
177
- ])) : n.value ? (u(), r("view", me, [
178
- S(t.$slots, "error", { error: n.value }, () => [
179
- d("text", he, "加载失败:" + F(String(n.value)), 1),
180
- d("button", {
177
+ ])) : u.value ? (d(), v("view", we, [
178
+ V(g.$slots, "error", { error: u.value }, () => [
179
+ s("text", be, "加载失败:" + C(String(u.value)), 1),
180
+ s("button", {
181
181
  class: "yk-infinite-list__retry",
182
182
  size: "mini",
183
- onTap: N
183
+ onTap: D
184
184
  }, "重试", 32)
185
185
  ])
186
- ])) : w("", !0),
187
- h.value ? (u(), r("view", ve, [
188
- S(t.$slots, "loading", {}, () => [
189
- s[1] || (s[1] = d("view", { class: "yk-infinite-list__spinner" }, null, -1)),
190
- s[2] || (s[2] = d("text", null, "加载中...", -1))
186
+ ])) : b("", !0),
187
+ l.value ? (d(), v("view", Ce, [
188
+ V(g.$slots, "loading", {}, () => [
189
+ k[1] || (k[1] = s("view", { class: "yk-infinite-list__spinner" }, null, -1)),
190
+ k[2] || (k[2] = s("text", null, "加载中...", -1))
191
191
  ])
192
- ])) : w("", !0),
193
- !i.value && m.value.length > 0 && !v.value ? (u(), r("view", ge, [
194
- S(t.$slots, "no-more", {}, () => [
195
- s[3] || (s[3] = d("text", null, "— 没有更多了 —", -1))
192
+ ])) : b("", !0),
193
+ !r.value && f.value.length > 0 && !i.value ? (d(), v("view", $e, [
194
+ V(g.$slots, "no-more", {}, () => [
195
+ k[3] || (k[3] = s("text", null, "— 没有更多了 —", -1))
196
196
  ])
197
- ])) : w("", !0)
197
+ ])) : b("", !0)
198
198
  ])
199
- ], 44, oe));
199
+ ], 44, he));
200
200
  }
201
- }), A = Symbol("YsFilterPanel");
202
- function Ee(e) {
203
- const x = W(A, null);
204
- if (!x) return;
205
- let y = null;
206
- U(() => {
207
- y = x(e);
208
- }), X(() => {
209
- y == null || y(), y = null;
201
+ }), te = Symbol("YsFilterPanel");
202
+ function Be(e) {
203
+ const a = re(te, null);
204
+ if (!a) return;
205
+ let n = null;
206
+ G(() => {
207
+ n = a(e);
208
+ }), se(() => {
209
+ n == null || n(), n = null;
210
210
  });
211
211
  }
212
- const ke = { class: "yk-filter-panel__bar" }, xe = { class: "yk-filter-panel__trigger-text" }, pe = { class: "yk-filter-panel__arrow" }, Se = { class: "yk-filter-panel__field" }, Ce = ["value", "placeholder"], be = { class: "yk-filter-panel__actions" }, _e = {
212
+ const Ie = { class: "yk-filter-panel__bar" }, Ve = { class: "yk-filter-panel__trigger-text" }, Te = { class: "yk-filter-panel__arrow" }, Pe = { class: "yk-filter-panel__field" }, Re = ["value", "placeholder"], Ye = { class: "yk-filter-panel__actions" }, Ee = {
213
213
  key: 0,
214
214
  class: "yk-filter-panel__conditions"
215
- }, Be = /* @__PURE__ */ Y({
215
+ }, qe = /* @__PURE__ */ Y({
216
216
  name: "YsFilterPanel",
217
217
  __name: "filter-panel",
218
218
  props: {
@@ -256,99 +256,521 @@ const ke = { class: "yk-filter-panel__bar" }, xe = { class: "yk-filter-panel__tr
256
256
  customStyle: { type: String, default: "" }
257
257
  },
258
258
  emits: ["update:modelValue", "search", "reset", "expand-change"],
259
- setup(e, { expose: x, emit: y }) {
260
- const l = e, c = y, m = Z(), v = P(() => !!m.default), h = p(l.defaultExpanded), i = ee([]);
261
- function n(o) {
262
- return i.value = [...i.value, o], () => {
263
- i.value = i.value.filter((k) => k !== o);
259
+ setup(e, { expose: a, emit: n }) {
260
+ const t = e, c = n, f = ue(), i = B(() => !!f.default), l = w(t.defaultExpanded), r = oe([]);
261
+ function u(o) {
262
+ return r.value = [...r.value, o], () => {
263
+ r.value = r.value.filter((y) => y !== o);
264
264
  };
265
265
  }
266
- te(A, n);
267
- const f = P(() => {
268
- var B;
269
- const o = ((B = l.modelValue) == null ? void 0 : B.trim()) ?? "";
270
- return !o || !l.textFilterBuilder ? null : l.textFilterBuilder(o) ?? null;
271
- }), b = P(() => {
266
+ ce(te, u);
267
+ const h = B(() => {
268
+ var _;
269
+ const o = ((_ = t.modelValue) == null ? void 0 : _.trim()) ?? "";
270
+ return !o || !t.textFilterBuilder ? null : t.textFilterBuilder(o) ?? null;
271
+ }), x = B(() => {
272
272
  const o = [];
273
- f.value && o.push(f.value);
274
- for (const k of i.value) {
275
- const B = k.filter;
276
- B && o.push(B);
273
+ h.value && o.push(h.value);
274
+ for (const y of r.value) {
275
+ const _ = y.filter;
276
+ _ && o.push(_);
277
277
  }
278
- return o.length === 0 ? se() : o.length === 1 ? o[0] : ie.createAnd(...o);
278
+ return o.length === 0 ? me() : o.length === 1 ? o[0] : ve.createAnd(...o);
279
279
  });
280
- function g() {
281
- h.value = !h.value, c("expand-change", h.value);
280
+ function m() {
281
+ l.value = !l.value, c("expand-change", l.value);
282
282
  }
283
- function I(o) {
284
- const k = o.detail;
285
- c("update:modelValue", (k == null ? void 0 : k.value) ?? "");
283
+ function $(o) {
284
+ const y = o.detail;
285
+ c("update:modelValue", (y == null ? void 0 : y.value) ?? "");
286
286
  }
287
- function _() {
288
- c("search", b.value);
287
+ function S() {
288
+ c("search", x.value);
289
289
  }
290
- function R() {
290
+ function I() {
291
291
  c("update:modelValue", "");
292
- for (const o of i.value) o.reset();
292
+ for (const o of r.value) o.reset();
293
293
  c("reset");
294
294
  }
295
- return x({
295
+ return a({
296
296
  /** 条件区是否展开 */
297
- expanded: h,
297
+ expanded: l,
298
298
  /** 当前聚合后的查询条件 */
299
- filter: b,
299
+ filter: x,
300
300
  /** 切换条件区展开/折叠 */
301
- toggle: g,
301
+ toggle: m,
302
302
  /** 重置(清空文本 + 重置已注册子项 + 派发 reset) */
303
- reset: R
304
- }), (o, k) => (u(), r("view", {
303
+ reset: I
304
+ }), (o, y) => (d(), v("view", {
305
305
  class: T(["yk-filter-panel", e.customClass]),
306
306
  style: z(e.customStyle)
307
307
  }, [
308
- d("view", ke, [
309
- v.value ? (u(), r("view", {
308
+ s("view", Ie, [
309
+ i.value ? (d(), v("view", {
310
310
  key: 0,
311
311
  class: "yk-filter-panel__trigger",
312
- onTap: g
312
+ onTap: m
313
313
  }, [
314
- d("text", xe, F(e.filterText), 1),
315
- d("text", pe, F(h.value ? "▲" : "▼"), 1)
316
- ], 32)) : w("", !0),
317
- d("view", Se, [
318
- d("input", {
314
+ s("text", Ve, C(e.filterText), 1),
315
+ s("text", Te, C(l.value ? "▲" : "▼"), 1)
316
+ ], 32)) : b("", !0),
317
+ s("view", Pe, [
318
+ s("input", {
319
319
  class: "yk-filter-panel__input",
320
320
  value: e.modelValue,
321
321
  placeholder: e.placeholder,
322
322
  "placeholder-class": "yk-filter-panel__placeholder",
323
- onInput: I,
324
- onConfirm: _
325
- }, null, 40, Ce)
323
+ onInput: $,
324
+ onConfirm: S
325
+ }, null, 40, Re)
326
326
  ]),
327
- d("view", be, [
328
- e.showSearch ? (u(), r("view", {
327
+ s("view", Ye, [
328
+ e.showSearch ? (d(), v("view", {
329
329
  key: 0,
330
330
  class: "yk-filter-panel__btn yk-filter-panel__btn--primary",
331
- onTap: _
331
+ onTap: S
332
332
  }, [
333
- d("text", null, F(e.searchButtonText), 1)
334
- ], 32)) : w("", !0),
335
- e.showReset ? (u(), r("view", {
333
+ s("text", null, C(e.searchButtonText), 1)
334
+ ], 32)) : b("", !0),
335
+ e.showReset ? (d(), v("view", {
336
336
  key: 1,
337
337
  class: "yk-filter-panel__btn yk-filter-panel__btn--default",
338
- onTap: R
338
+ onTap: I
339
339
  }, [
340
- d("text", null, F(e.resetButtonText), 1)
341
- ], 32)) : w("", !0)
340
+ s("text", null, C(e.resetButtonText), 1)
341
+ ], 32)) : b("", !0)
342
342
  ])
343
343
  ]),
344
- v.value ? le((u(), r("view", _e, [
345
- S(o.$slots, "default")
344
+ i.value ? fe((d(), v("view", Ee, [
345
+ V(o.$slots, "default")
346
346
  ], 512)), [
347
- [ne, h.value]
348
- ]) : w("", !0)
347
+ [de, l.value]
348
+ ]) : b("", !0)
349
349
  ], 6));
350
350
  }
351
- }), $e = ["onTap"], Fe = { class: "yk-command-bar__btn-text" }, Te = /* @__PURE__ */ Y({
351
+ }), Ae = { class: "yk-filter-item" }, Me = {
352
+ key: 0,
353
+ class: "yk-filter-item__label"
354
+ }, Ne = { class: "yk-filter-item__control" }, O = /* @__PURE__ */ Y({
355
+ name: "YsFilterItemLayout",
356
+ __name: "filter-item-layout",
357
+ props: {
358
+ /** 控件上方的标签文本;空串时不渲染 */
359
+ label: { type: String, default: "" },
360
+ /** FilterItem 的 API 对象,由 layout 注册到最近的 YsFilterPanel */
361
+ api: { type: Object, required: !0 }
362
+ },
363
+ setup(e) {
364
+ return Be(e.api), (n, t) => (d(), v("view", Ae, [
365
+ e.label ? (d(), v("text", Me, C(e.label), 1)) : b("", !0),
366
+ s("view", Ne, [
367
+ V(n.$slots, "default")
368
+ ])
369
+ ]));
370
+ }
371
+ });
372
+ function De(e) {
373
+ const a = w(
374
+ typeof e.defaultValue == "string" ? e.defaultValue : ""
375
+ );
376
+ function n(f) {
377
+ return f == null || f.trim() === "";
378
+ }
379
+ const t = B(() => n(a.value) ? null : A(e.propertyPath, e.op, M(a.value)));
380
+ function c() {
381
+ a.value = typeof e.defaultValue == "string" ? e.defaultValue : "";
382
+ }
383
+ return { value: a, filter: t, reset: c };
384
+ }
385
+ function Le(e) {
386
+ const a = w(
387
+ typeof e.defaultValue == "string" ? e.defaultValue : ""
388
+ );
389
+ function n(f) {
390
+ return f == null || f.trim() === "";
391
+ }
392
+ const t = B(() => n(a.value) ? null : A(e.propertyPath, e.op, M(a.value)));
393
+ function c() {
394
+ a.value = typeof e.defaultValue == "string" ? e.defaultValue : "";
395
+ }
396
+ return { value: a, filter: t, reset: c };
397
+ }
398
+ function ze(e) {
399
+ function a(l) {
400
+ return l && l.length === 2 && typeof l[0] == "string" && typeof l[1] == "string" ? [l[0], l[1]] : null;
401
+ }
402
+ const n = a(e.defaultValue), t = w(n);
403
+ function c(l) {
404
+ return l == null || l.length !== 2 || !l[0] || !l[1];
405
+ }
406
+ const f = B(() => {
407
+ if (c(t.value)) return null;
408
+ const [l, r] = t.value;
409
+ return A(e.propertyPath, Q.Between, M([l, r]));
410
+ });
411
+ function i() {
412
+ t.value = n;
413
+ }
414
+ return { value: t, filter: f, reset: i };
415
+ }
416
+ function Z(e) {
417
+ return typeof e == "string" || typeof e == "number" ? e : null;
418
+ }
419
+ function ee(e) {
420
+ return Array.isArray(e) ? e.filter(
421
+ (a) => typeof a == "string" || typeof a == "number"
422
+ ) : [];
423
+ }
424
+ function Ke(e) {
425
+ const a = e.multiple === !0, n = w(
426
+ a ? ee(e.defaultValue) : Z(e.defaultValue)
427
+ );
428
+ function t() {
429
+ const i = n.value;
430
+ return a ? !Array.isArray(i) || i.length === 0 : i == null || typeof i == "string" && i.trim() === "";
431
+ }
432
+ const c = B(() => {
433
+ if (t()) return null;
434
+ if (a) {
435
+ const l = n.value;
436
+ if (l.length === 1) {
437
+ const r = l[0];
438
+ return r == null ? null : A(e.propertyPath, Q.Equals, M(r));
439
+ }
440
+ return A(
441
+ e.propertyPath,
442
+ Q.In,
443
+ M(l)
444
+ );
445
+ }
446
+ const i = n.value;
447
+ return i == null ? null : A(e.propertyPath, e.op, M(i));
448
+ });
449
+ function f() {
450
+ n.value = a ? ee(e.defaultValue) : Z(e.defaultValue);
451
+ }
452
+ return { value: n, filter: c, reset: f };
453
+ }
454
+ const Oe = { class: "yk-filter-item__field" }, je = ["value", "placeholder"], yt = /* @__PURE__ */ Y({
455
+ name: "YsTextFilterItem",
456
+ __name: "text-filter-item",
457
+ props: {
458
+ /** 控件上方的标签 */
459
+ label: { type: String, default: "" },
460
+ /** 运算符(字符串 enum 跨包用 String as PropType<Operator>) */
461
+ op: { type: String, required: !0 },
462
+ /** 实体属性路径(FilterInfo.left),如 "name" / "user.name" */
463
+ propertyPath: { type: String, required: !0 },
464
+ /** 初始值;缺省为空字符串 */
465
+ defaultValue: {
466
+ type: String,
467
+ default: void 0
468
+ },
469
+ /** 占位文本 */
470
+ placeholder: { type: String, default: "请输入" }
471
+ },
472
+ setup(e, { expose: a }) {
473
+ const n = e, { value: t, filter: c, reset: f } = De(n);
474
+ function i(r) {
475
+ const u = r.detail;
476
+ t.value = (u == null ? void 0 : u.value) ?? "";
477
+ }
478
+ const l = {
479
+ get filter() {
480
+ return c.value;
481
+ },
482
+ reset: f
483
+ };
484
+ return a(l), (r, u) => (d(), K(O, {
485
+ label: e.label,
486
+ api: l
487
+ }, {
488
+ default: q(() => [
489
+ s("view", Oe, [
490
+ s("input", {
491
+ class: "yk-filter-item__input",
492
+ value: F(t),
493
+ placeholder: e.placeholder,
494
+ "placeholder-class": "yk-filter-item__placeholder",
495
+ onInput: i
496
+ }, null, 40, je)
497
+ ])
498
+ ]),
499
+ _: 1
500
+ }, 8, ["label"]));
501
+ }
502
+ }), Ue = ["value", "start", "end"], Je = { class: "yk-filter-item__picker" }, mt = /* @__PURE__ */ Y({
503
+ name: "YsDateFilterItem",
504
+ __name: "date-filter-item",
505
+ props: {
506
+ /** 控件上方的标签 */
507
+ label: { type: String, default: "" },
508
+ /** 运算符(字符串 enum 跨包用 String as PropType<Operator>) */
509
+ op: { type: String, required: !0 },
510
+ /** 实体属性路径(FilterInfo.left),如 "birthDate" / "user.createdAt" */
511
+ propertyPath: { type: String, required: !0 },
512
+ /** 初始值;YYYY-MM-DD 格式字符串 */
513
+ defaultValue: {
514
+ type: String,
515
+ default: void 0
516
+ },
517
+ /** 占位文本 */
518
+ placeholder: { type: String, default: "选择日期" },
519
+ /** 可选范围下限(YYYY-MM-DD),空串表示不限制 */
520
+ start: { type: String, default: "" },
521
+ /** 可选范围上限(YYYY-MM-DD),空串表示不限制 */
522
+ end: { type: String, default: "" }
523
+ },
524
+ setup(e, { expose: a }) {
525
+ const n = e, { value: t, filter: c, reset: f } = Le(n);
526
+ function i(u) {
527
+ const h = u.detail;
528
+ t.value = (h == null ? void 0 : h.value) ?? "";
529
+ }
530
+ function l() {
531
+ t.value = "";
532
+ }
533
+ const r = {
534
+ get filter() {
535
+ return c.value;
536
+ },
537
+ reset: f
538
+ };
539
+ return a(r), (u, h) => (d(), K(O, {
540
+ label: e.label,
541
+ api: r
542
+ }, {
543
+ default: q(() => [
544
+ s("picker", {
545
+ class: "yk-filter-item__picker-trigger",
546
+ mode: "date",
547
+ value: F(t),
548
+ start: e.start,
549
+ end: e.end,
550
+ onChange: i
551
+ }, [
552
+ s("view", Je, [
553
+ s("text", {
554
+ class: T(["yk-filter-item__picker-text", { "yk-filter-item__picker-text--placeholder": !F(t) }])
555
+ }, C(F(t) || e.placeholder), 3)
556
+ ])
557
+ ], 40, Ue),
558
+ F(t) ? (d(), v("view", {
559
+ key: 0,
560
+ class: "yk-filter-item__clear",
561
+ onTap: W(l, ["stop"])
562
+ }, [...h[0] || (h[0] = [
563
+ s("text", null, "✕", -1)
564
+ ])], 32)) : b("", !0)
565
+ ]),
566
+ _: 1
567
+ }, 8, ["label"]));
568
+ }
569
+ }), Qe = ["value", "start", "end"], Ge = { class: "yk-filter-item__picker" }, He = ["value", "start", "end"], We = { class: "yk-filter-item__picker" }, vt = /* @__PURE__ */ Y({
570
+ name: "YsDateRangeFilterItem",
571
+ __name: "date-range-filter-item",
572
+ props: {
573
+ /** 控件上方的标签 */
574
+ label: { type: String, default: "" },
575
+ /** 实体属性路径(FilterInfo.left),如 "createdAt" / "user.registeredAt" */
576
+ propertyPath: { type: String, required: !0 },
577
+ /** 初始值;[start, end] 字符串数组 */
578
+ defaultValue: {
579
+ type: Array,
580
+ default: void 0
581
+ },
582
+ /** 起始日期占位文本 */
583
+ startPlaceholder: { type: String, default: "开始日期" },
584
+ /** 结束日期占位文本 */
585
+ endPlaceholder: { type: String, default: "结束日期" },
586
+ /** 可选范围下限(YYYY-MM-DD),空串表示不限制 */
587
+ start: { type: String, default: "" },
588
+ /** 可选范围上限(YYYY-MM-DD),空串表示不限制 */
589
+ end: { type: String, default: "" }
590
+ },
591
+ setup(e, { expose: a }) {
592
+ const n = e, { value: t, filter: c, reset: f } = ze(n);
593
+ function i(x, m) {
594
+ const $ = t.value ?? ["", ""], S = [$[0], $[1]];
595
+ S[x] = m, t.value = !S[0] && !S[1] ? null : S;
596
+ }
597
+ function l(x) {
598
+ const m = x.detail;
599
+ i(0, (m == null ? void 0 : m.value) ?? "");
600
+ }
601
+ function r(x) {
602
+ const m = x.detail;
603
+ i(1, (m == null ? void 0 : m.value) ?? "");
604
+ }
605
+ function u() {
606
+ t.value = null;
607
+ }
608
+ const h = {
609
+ get filter() {
610
+ return c.value;
611
+ },
612
+ reset: f
613
+ };
614
+ return a(h), (x, m) => (d(), K(O, {
615
+ label: e.label,
616
+ api: h
617
+ }, {
618
+ default: q(() => {
619
+ var $, S, I, o, y, _;
620
+ return [
621
+ s("picker", {
622
+ class: "yk-filter-item__picker-trigger",
623
+ mode: "date",
624
+ value: (($ = F(t)) == null ? void 0 : $[0]) ?? "",
625
+ start: e.start,
626
+ end: e.end,
627
+ onChange: l
628
+ }, [
629
+ s("view", Ge, [
630
+ s("text", {
631
+ class: T(["yk-filter-item__picker-text", { "yk-filter-item__picker-text--placeholder": !((S = F(t)) != null && S[0]) }])
632
+ }, C(((I = F(t)) == null ? void 0 : I[0]) || e.startPlaceholder), 3)
633
+ ])
634
+ ], 40, Qe),
635
+ m[1] || (m[1] = s("text", { class: "yk-filter-item__sep" }, "至", -1)),
636
+ s("picker", {
637
+ class: "yk-filter-item__picker-trigger",
638
+ mode: "date",
639
+ value: ((o = F(t)) == null ? void 0 : o[1]) ?? "",
640
+ start: e.start,
641
+ end: e.end,
642
+ onChange: r
643
+ }, [
644
+ s("view", We, [
645
+ s("text", {
646
+ class: T(["yk-filter-item__picker-text", { "yk-filter-item__picker-text--placeholder": !((y = F(t)) != null && y[1]) }])
647
+ }, C(((_ = F(t)) == null ? void 0 : _[1]) || e.endPlaceholder), 3)
648
+ ])
649
+ ], 40, He),
650
+ F(t) ? (d(), v("view", {
651
+ key: 0,
652
+ class: "yk-filter-item__clear",
653
+ onTap: W(u, ["stop"])
654
+ }, [...m[0] || (m[0] = [
655
+ s("text", null, "✕", -1)
656
+ ])], 32)) : b("", !0)
657
+ ];
658
+ }),
659
+ _: 1
660
+ }, 8, ["label"]));
661
+ }
662
+ }), Xe = {
663
+ key: 0,
664
+ class: "yk-filter-item__chips"
665
+ }, Ze = {
666
+ key: 0,
667
+ class: "yk-filter-item__chips-empty"
668
+ }, et = ["onTap"], tt = ["range", "value"], lt = { class: "yk-filter-item__picker" }, ht = /* @__PURE__ */ Y({
669
+ name: "YsEnumFilterItem",
670
+ __name: "enum-filter-item",
671
+ props: {
672
+ /** 控件上方的标签 */
673
+ label: { type: String, default: "" },
674
+ /** 运算符;仅单选模式使用(多选模式按 1 项→Equals、2+ 项→In 自动派生) */
675
+ op: { type: String, required: !0 },
676
+ /** 实体属性路径(FilterInfo.left),如 "status" / "user.roleId" */
677
+ propertyPath: { type: String, required: !0 },
678
+ /** 初始值;单选为 string | number | null,多选为 (string | number)[] */
679
+ defaultValue: {
680
+ type: [String, Number, Array],
681
+ default: void 0
682
+ },
683
+ /** 占位文本 */
684
+ placeholder: { type: String, default: "请选择" },
685
+ /** 选项数据源,返回 { label, value } 数组 */
686
+ optionsSource: { type: Function, required: !0 },
687
+ /** 是否多选;多选时用标签式选项渲染 */
688
+ multiple: { type: Boolean, default: !1 },
689
+ /** 单选模式是否显示清除按钮 */
690
+ clearable: { type: Boolean, default: !0 }
691
+ },
692
+ setup(e, { expose: a }) {
693
+ const n = e, { value: t, filter: c, reset: f } = Ke(n), i = w([]), l = w(!1);
694
+ G(async () => {
695
+ l.value = !0;
696
+ try {
697
+ i.value = await n.optionsSource();
698
+ } finally {
699
+ l.value = !1;
700
+ }
701
+ });
702
+ const r = B(() => {
703
+ const o = Array.isArray(t.value) ? null : t.value;
704
+ return o == null ? -1 : i.value.findIndex((y) => String(y.value) === String(o));
705
+ }), u = B(() => {
706
+ var y;
707
+ const o = r.value;
708
+ return o >= 0 ? ((y = i.value[o]) == null ? void 0 : y.label) ?? "" : "";
709
+ });
710
+ function h(o) {
711
+ const y = o.detail, _ = Number((y == null ? void 0 : y.value) ?? -1), P = i.value[_];
712
+ P && (t.value = P.value);
713
+ }
714
+ function x() {
715
+ t.value = null;
716
+ }
717
+ const m = B(
718
+ () => Array.isArray(t.value) ? t.value : []
719
+ );
720
+ function $(o) {
721
+ return m.value.some((y) => String(y) === String(o.value));
722
+ }
723
+ function S(o) {
724
+ const y = [...m.value], _ = y.findIndex((P) => String(P) === String(o.value));
725
+ _ >= 0 ? y.splice(_, 1) : y.push(o.value), t.value = y;
726
+ }
727
+ const I = {
728
+ get filter() {
729
+ return c.value;
730
+ },
731
+ reset: f
732
+ };
733
+ return a(I), (o, y) => (d(), K(O, {
734
+ label: e.label,
735
+ api: I
736
+ }, {
737
+ default: q(() => [
738
+ e.multiple ? (d(), v("view", Xe, [
739
+ l.value ? (d(), v("text", Ze, "加载中…")) : (d(!0), v(L, { key: 1 }, H(i.value, (_) => (d(), v("view", {
740
+ key: String(_.value),
741
+ class: T(["yk-filter-item__chip", { "yk-filter-item__chip--active": $(_) }]),
742
+ onTap: (P) => S(_)
743
+ }, [
744
+ s("text", null, C(_.label), 1)
745
+ ], 42, et))), 128))
746
+ ])) : (d(), v(L, { key: 1 }, [
747
+ s("picker", {
748
+ class: "yk-filter-item__picker-trigger",
749
+ mode: "selector",
750
+ range: i.value,
751
+ "range-key": "label",
752
+ value: r.value < 0 ? 0 : r.value,
753
+ onChange: h
754
+ }, [
755
+ s("view", lt, [
756
+ s("text", {
757
+ class: T(["yk-filter-item__picker-text", { "yk-filter-item__picker-text--placeholder": !u.value }])
758
+ }, C(l.value ? "加载中…" : u.value || e.placeholder), 3)
759
+ ])
760
+ ], 40, tt),
761
+ e.clearable && u.value ? (d(), v("view", {
762
+ key: 0,
763
+ class: "yk-filter-item__clear",
764
+ onTap: W(x, ["stop"])
765
+ }, [...y[0] || (y[0] = [
766
+ s("text", null, "✕", -1)
767
+ ])], 32)) : b("", !0)
768
+ ], 64))
769
+ ]),
770
+ _: 1
771
+ }, 8, ["label"]));
772
+ }
773
+ }), nt = ["onTap"], at = { class: "yk-command-bar__btn-text" }, it = /* @__PURE__ */ Y({
352
774
  name: "YsCommandBar",
353
775
  __name: "command-bar",
354
776
  props: {
@@ -363,37 +785,37 @@ const ke = { class: "yk-filter-panel__bar" }, xe = { class: "yk-filter-panel__tr
363
785
  customStyle: { type: String, default: "" }
364
786
  },
365
787
  setup(e) {
366
- async function x(y) {
788
+ async function a(n) {
367
789
  try {
368
- await y.execute(void 0);
369
- } catch (l) {
370
- console.error("[YsCommandBar] action failed:", y.name, l);
790
+ await n.execute(void 0);
791
+ } catch (t) {
792
+ console.error("[YsCommandBar] action failed:", n.name, t);
371
793
  }
372
794
  }
373
- return (y, l) => (u(), r("view", {
795
+ return (n, t) => (d(), v("view", {
374
796
  class: T(["yk-command-bar", e.customClass]),
375
797
  style: z(e.customStyle)
376
798
  }, [
377
- e.actions.length > 0 ? (u(!0), r(j, { key: 0 }, q(e.actions, (c) => (u(), r("view", {
799
+ e.actions.length > 0 ? (d(!0), v(L, { key: 0 }, H(e.actions, (c) => (d(), v("view", {
378
800
  key: c.name,
379
801
  class: T(["yk-command-bar__btn", [
380
802
  c.type ? `yk-command-bar__btn--${c.type}` : "yk-command-bar__btn--default",
381
803
  { "yk-command-bar__btn--plain": c.plain }
382
804
  ]]),
383
- onTap: (m) => x(c)
805
+ onTap: (f) => a(c)
384
806
  }, [
385
- d("text", Fe, F(c.desc), 1)
386
- ], 42, $e))), 128)) : w("", !0),
387
- S(y.$slots, "default")
807
+ s("text", at, C(c.desc), 1)
808
+ ], 42, nt))), 128)) : b("", !0),
809
+ V(n.$slots, "default")
388
810
  ], 6));
389
811
  }
390
- }), Re = { class: "yk-infinite-page" }, Ve = {
812
+ }), rt = { class: "yk-infinite-page" }, st = {
391
813
  key: 0,
392
814
  class: "yk-infinite-page__filter"
393
- }, Pe = { class: "yk-infinite-page__list" }, Ie = {
815
+ }, ut = { class: "yk-infinite-page__list" }, ot = {
394
816
  key: 1,
395
817
  class: "yk-infinite-page__cmd"
396
- }, Ke = /* @__PURE__ */ Y({
818
+ }, gt = /* @__PURE__ */ Y({
397
819
  name: "YsInfinitePage",
398
820
  __name: "infinite-page",
399
821
  props: {
@@ -434,29 +856,29 @@ const ke = { class: "yk-filter-panel__bar" }, xe = { class: "yk-filter-panel__tr
434
856
  listCustomStyle: { type: String, default: "" }
435
857
  },
436
858
  emits: ["update:modelValue", "search", "reset", "expand-change", "data-loaded", "selection-change", "error"],
437
- setup(e, { expose: x, emit: y }) {
438
- const l = y, c = p(null), m = p(null);
439
- x({
859
+ setup(e, { expose: a, emit: n }) {
860
+ const t = n, c = w(null), f = w(null);
861
+ a({
440
862
  /** YsInfiniteList 实例(空壳子 CommandBar 没有 list 引用,业务侧通过这个 ref 调 reload / clearSelection 等) */
441
863
  get list() {
442
864
  return c.value;
443
865
  },
444
866
  /** YsFilterPanel 实例 */
445
867
  get filterPanel() {
446
- return m.value;
868
+ return f.value;
447
869
  }
448
870
  });
449
- function v(i) {
450
- l("update:modelValue", i);
871
+ function i(r) {
872
+ t("update:modelValue", r);
451
873
  }
452
- function h(i, n) {
453
- l("data-loaded", i, n);
874
+ function l(r, u) {
875
+ t("data-loaded", r, u);
454
876
  }
455
- return (i, n) => (u(), r("view", Re, [
456
- e.showFilter ? (u(), r("view", Ve, [
457
- L(Be, {
877
+ return (r, u) => (d(), v("view", rt, [
878
+ e.showFilter ? (d(), v("view", st, [
879
+ J(qe, {
458
880
  ref_key: "filterRef",
459
- ref: m,
881
+ ref: f,
460
882
  "model-value": e.modelValue,
461
883
  placeholder: e.placeholder,
462
884
  "filter-text": e.filterText,
@@ -468,19 +890,19 @@ const ke = { class: "yk-filter-panel__bar" }, xe = { class: "yk-filter-panel__tr
468
890
  "text-filter-builder": e.textFilterBuilder,
469
891
  "custom-class": e.filterCustomClass,
470
892
  "custom-style": e.filterCustomStyle,
471
- "onUpdate:modelValue": v,
472
- onSearch: n[0] || (n[0] = (f) => l("search", f)),
473
- onReset: n[1] || (n[1] = (f) => l("reset")),
474
- onExpandChange: n[2] || (n[2] = (f) => l("expand-change", f))
893
+ "onUpdate:modelValue": i,
894
+ onSearch: u[0] || (u[0] = (h) => t("search", h)),
895
+ onReset: u[1] || (u[1] = (h) => t("reset")),
896
+ onExpandChange: u[2] || (u[2] = (h) => t("expand-change", h))
475
897
  }, {
476
- default: D(() => [
477
- S(i.$slots, "filter-default")
898
+ default: q(() => [
899
+ V(r.$slots, "filter-default")
478
900
  ]),
479
901
  _: 3
480
902
  }, 8, ["model-value", "placeholder", "filter-text", "search-button-text", "reset-button-text", "default-expanded", "show-search", "show-reset", "text-filter-builder", "custom-class", "custom-style"])
481
- ])) : w("", !0),
482
- d("view", Pe, [
483
- L(we, {
903
+ ])) : b("", !0),
904
+ s("view", ut, [
905
+ J(Fe, {
484
906
  ref_key: "listRef",
485
907
  ref: c,
486
908
  "data-fun": e.dataFun,
@@ -492,40 +914,45 @@ const ke = { class: "yk-filter-panel__bar" }, xe = { class: "yk-filter-panel__tr
492
914
  height: "100%",
493
915
  class: T(e.listCustomClass),
494
916
  style: z(e.listCustomStyle),
495
- onDataLoaded: n[3] || (n[3] = (f, b) => h(f, b)),
496
- onSelectionChange: n[4] || (n[4] = (f) => l("selection-change", f)),
497
- onError: n[5] || (n[5] = (f) => l("error", f))
917
+ onDataLoaded: u[3] || (u[3] = (h, x) => l(h, x)),
918
+ onSelectionChange: u[4] || (u[4] = (h) => t("selection-change", h)),
919
+ onError: u[5] || (u[5] = (h) => t("error", h))
498
920
  }, {
499
- default: D(({ row: f, index: b }) => [
500
- S(i.$slots, "list-default", {
501
- row: f,
502
- index: b
921
+ default: q(({ row: h, index: x }) => [
922
+ V(r.$slots, "list-default", {
923
+ row: h,
924
+ index: x
503
925
  })
504
926
  ]),
505
927
  _: 3
506
928
  }, 8, ["data-fun", "page-size", "threshold", "row-key", "immediate", "show-checkbox", "class", "style"])
507
929
  ]),
508
- e.showCommandBar ? (u(), r("view", Ie, [
509
- L(Te, {
930
+ e.showCommandBar ? (d(), v("view", ot, [
931
+ J(it, {
510
932
  actions: e.actions,
511
933
  "custom-class": e.cmdCustomClass,
512
934
  "custom-style": e.cmdCustomStyle
513
935
  }, {
514
- default: D(() => [
515
- S(i.$slots, "cmd-default")
936
+ default: q(() => [
937
+ V(r.$slots, "cmd-default")
516
938
  ]),
517
939
  _: 3
518
940
  }, 8, ["actions", "custom-class", "custom-style"])
519
- ])) : w("", !0)
941
+ ])) : b("", !0)
520
942
  ]));
521
943
  }
522
944
  });
523
945
  export {
524
- A as FilterPanelKey,
525
- Te as YsCommandBar,
526
- Be as YsFilterPanel,
527
- we as YsInfiniteList,
528
- Ke as YsInfinitePage,
529
- Ee as useFilterPanelItem
946
+ te as FilterPanelKey,
947
+ it as YsCommandBar,
948
+ mt as YsDateFilterItem,
949
+ vt as YsDateRangeFilterItem,
950
+ ht as YsEnumFilterItem,
951
+ O as YsFilterItemLayout,
952
+ qe as YsFilterPanel,
953
+ Fe as YsInfiniteList,
954
+ gt as YsInfinitePage,
955
+ yt as YsTextFilterItem,
956
+ Be as useFilterPanelItem
530
957
  };
531
958
  //# sourceMappingURL=index.js.map