@appmax_npm/ds-prime 1.0.0-alpha.176 → 1.0.0-alpha.177
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/amdatefilter/index.js +89 -92
- package/package.json +1 -1
package/amdatefilter/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { defineComponent as
|
|
1
|
+
import { defineComponent as E, useAttrs as H, openBlock as b, createElementBlock as w, normalizeClass as V, unref as d, createBlock as T, createCommentVNode as $, withCtx as I, createTextVNode as te, toDisplayString as ae, mergeModels as j, useModel as le, ref as k, Fragment as Y, createVNode as B, toRefs as oe, computed as S, watch as L, nextTick as re, renderList as se } from "vue";
|
|
2
2
|
import { _ as ne } from "../AmText.vue_vue_type_script_setup_true_lang-ZUjjXA8M.js";
|
|
3
3
|
import { _ as ie } from "../AmIcon.vue_vue_type_script_setup_true_lang-DWxib5iw.js";
|
|
4
4
|
import { cva as G } from "class-variance-authority";
|
|
@@ -44,7 +44,7 @@ const me = G(
|
|
|
44
44
|
}
|
|
45
45
|
}
|
|
46
46
|
}
|
|
47
|
-
), pe = (e, a) => q(me(e), a),
|
|
47
|
+
), pe = (e, a) => q(me(e), a), be = (e, a) => q(fe(e), a), ve = ["disabled", "data-test"], ge = /* @__PURE__ */ E({
|
|
48
48
|
inheritAttrs: !1,
|
|
49
49
|
__name: "AmDateFilterButton",
|
|
50
50
|
props: {
|
|
@@ -59,31 +59,31 @@ const me = G(
|
|
|
59
59
|
emits: ["click"],
|
|
60
60
|
setup(e) {
|
|
61
61
|
const a = H();
|
|
62
|
-
return (t, n) => (
|
|
62
|
+
return (t, n) => (b(), w("button", {
|
|
63
63
|
type: "button",
|
|
64
|
-
class: V([d(
|
|
64
|
+
class: V([d(be)({ selected: t.selected, disabled: t.disabled, isCustom: t.isCustom }, d(a).class), { "am-date-filter-button--custom": t.isCustom }]),
|
|
65
65
|
disabled: t.disabled,
|
|
66
66
|
"data-test": t.dataTest,
|
|
67
67
|
onClick: n[0] || (n[0] = (u) => t.$emit("click", u))
|
|
68
68
|
}, [
|
|
69
|
-
t.icon ? (
|
|
69
|
+
t.icon ? (b(), T(ie, {
|
|
70
70
|
key: 0,
|
|
71
71
|
icon: t.icon,
|
|
72
72
|
size: "sm"
|
|
73
|
-
}, null, 8, ["icon"])) :
|
|
74
|
-
t.label ? (
|
|
73
|
+
}, null, 8, ["icon"])) : $("", !0),
|
|
74
|
+
t.label ? (b(), T(ne, {
|
|
75
75
|
key: 1,
|
|
76
76
|
as: "span",
|
|
77
77
|
class: V(t.hideLabel ? "am-date-filter-label--responsive" : "")
|
|
78
78
|
}, {
|
|
79
|
-
default:
|
|
79
|
+
default: I(() => [
|
|
80
80
|
te(ae(t.label), 1)
|
|
81
81
|
]),
|
|
82
82
|
_: 1
|
|
83
|
-
}, 8, ["class"])) :
|
|
84
|
-
], 10,
|
|
83
|
+
}, 8, ["class"])) : $("", !0)
|
|
84
|
+
], 10, ve));
|
|
85
85
|
}
|
|
86
|
-
}), J = /* @__PURE__ */ de(
|
|
86
|
+
}), J = /* @__PURE__ */ de(ge, [["__scopeId", "data-v-e2a79444"]]), De = /* @__PURE__ */ E({
|
|
87
87
|
__name: "AmDateFilterPicker",
|
|
88
88
|
props: /* @__PURE__ */ j({
|
|
89
89
|
selected: { type: Boolean, default: !1 },
|
|
@@ -96,12 +96,12 @@ const me = G(
|
|
|
96
96
|
}),
|
|
97
97
|
emits: /* @__PURE__ */ j(["click"], ["update:date"]),
|
|
98
98
|
setup(e, { expose: a, emit: t }) {
|
|
99
|
-
const n =
|
|
99
|
+
const n = le(e, "date"), u = t, c = k(), p = (s) => {
|
|
100
100
|
var i;
|
|
101
101
|
(i = c.value) == null || i.toggle(s), u("click", s);
|
|
102
102
|
};
|
|
103
|
-
return a({ popover: c }), (s, i) => (
|
|
104
|
-
|
|
103
|
+
return a({ popover: c }), (s, i) => (b(), w(Y, null, [
|
|
104
|
+
B(J, {
|
|
105
105
|
selected: s.selected,
|
|
106
106
|
disabled: s.disabled,
|
|
107
107
|
"is-custom": "",
|
|
@@ -111,14 +111,14 @@ const me = G(
|
|
|
111
111
|
"hide-label": "",
|
|
112
112
|
onClick: p
|
|
113
113
|
}, null, 8, ["selected", "disabled"]),
|
|
114
|
-
|
|
114
|
+
B(d(ue), {
|
|
115
115
|
"data-test": "amdatefilter-popover",
|
|
116
116
|
ref_key: "popover",
|
|
117
117
|
ref: c,
|
|
118
118
|
"pt:content": "!p-0"
|
|
119
119
|
}, {
|
|
120
|
-
default:
|
|
121
|
-
|
|
120
|
+
default: I(() => [
|
|
121
|
+
B(d(ce), {
|
|
122
122
|
"data-test": "amdatefilter-datepicker",
|
|
123
123
|
modelValue: n.value,
|
|
124
124
|
"onUpdate:modelValue": i[0] || (i[0] = (m) => n.value = m),
|
|
@@ -137,31 +137,28 @@ const me = G(
|
|
|
137
137
|
}, 512)
|
|
138
138
|
], 64));
|
|
139
139
|
}
|
|
140
|
-
}),
|
|
140
|
+
}), v = "America/Sao_Paulo", y = (e = v) => {
|
|
141
141
|
const a = /* @__PURE__ */ new Date(), t = new Date(a.toLocaleString("en-US", { timeZone: e }));
|
|
142
142
|
return new Date(t.getFullYear(), t.getMonth(), t.getDate());
|
|
143
|
-
},
|
|
144
|
-
const t =
|
|
143
|
+
}, C = (e, a = v) => {
|
|
144
|
+
const t = y(a);
|
|
145
145
|
return t.setDate(t.getDate() + e), t;
|
|
146
|
-
},
|
|
147
|
-
const a = e.getFullYear(), t = String(e.getMonth() + 1).padStart(2, "0"), n = String(e.getDate()).padStart(2, "0");
|
|
148
|
-
return `${a}-${t}-${n}`;
|
|
149
|
-
}, S = (e) => {
|
|
146
|
+
}, R = (e, a = v) => e.toLocaleDateString("en-CA", { timeZone: a }), x = (e) => {
|
|
150
147
|
const a = e.split("T")[0], [t, n, u] = a.split("-").map(Number);
|
|
151
148
|
return new Date(t, n - 1, u);
|
|
152
|
-
},
|
|
149
|
+
}, z = (e, a) => e.getFullYear() === a.getFullYear() && e.getMonth() === a.getMonth() && e.getDate() === a.getDate(), ye = (e, a = v) => {
|
|
153
150
|
if (!Array.isArray(e) || e.length !== 2)
|
|
154
151
|
throw new Error("Range de datas inválido");
|
|
155
|
-
const [
|
|
156
|
-
if (!
|
|
152
|
+
const [t, n] = e;
|
|
153
|
+
if (!t || !n)
|
|
157
154
|
throw new Error("Datas não podem ser nulas");
|
|
158
|
-
return [
|
|
159
|
-
}, he = (e =
|
|
160
|
-
Hoje: () => [
|
|
161
|
-
Ontem: () => [
|
|
162
|
-
"7D": () => [
|
|
163
|
-
"14D": () => [
|
|
164
|
-
"30D": () => [
|
|
155
|
+
return [R(t, a), R(n, a)];
|
|
156
|
+
}, he = (e = v) => ({
|
|
157
|
+
Hoje: () => [y(e), y(e)],
|
|
158
|
+
Ontem: () => [C(-1, e), C(-1, e)],
|
|
159
|
+
"7D": () => [C(-6, e), y(e)],
|
|
160
|
+
"14D": () => [C(-13, e), y(e)],
|
|
161
|
+
"30D": () => [C(-29, e), y(e)],
|
|
165
162
|
Customizar: () => null
|
|
166
163
|
}), Ce = {
|
|
167
164
|
0: "Hoje",
|
|
@@ -169,14 +166,14 @@ const me = G(
|
|
|
169
166
|
7: "7D",
|
|
170
167
|
14: "14D",
|
|
171
168
|
30: "30D"
|
|
172
|
-
}, U = (e) => {
|
|
169
|
+
}, U = (e, a = v) => {
|
|
173
170
|
if (!(!e || e.length === 0))
|
|
174
|
-
return e.map((
|
|
171
|
+
return e.map((t) => t instanceof Date ? R(t, a) : String(t));
|
|
175
172
|
}, ke = (e, a, t) => {
|
|
176
173
|
if (!e || e.length !== 2)
|
|
177
174
|
return "Customizar";
|
|
178
175
|
try {
|
|
179
|
-
const [n, u] = e, c =
|
|
176
|
+
const [n, u] = e, c = x(n), p = x(u);
|
|
180
177
|
if (isNaN(c.getTime()) || isNaN(p.getTime()))
|
|
181
178
|
return "Customizar";
|
|
182
179
|
for (const s of a) {
|
|
@@ -185,15 +182,15 @@ const me = G(
|
|
|
185
182
|
if (!i) continue;
|
|
186
183
|
const m = i();
|
|
187
184
|
if (!m || !Array.isArray(m) || m.length !== 2) continue;
|
|
188
|
-
const [
|
|
189
|
-
if (
|
|
185
|
+
const [g, A] = m;
|
|
186
|
+
if (z(c, g) && z(p, A))
|
|
190
187
|
return s;
|
|
191
188
|
}
|
|
192
189
|
return "Customizar";
|
|
193
190
|
} catch {
|
|
194
191
|
return "Customizar";
|
|
195
192
|
}
|
|
196
|
-
},
|
|
193
|
+
}, F = "Customizar", Se = /* @__PURE__ */ E({
|
|
197
194
|
inheritAttrs: !1,
|
|
198
195
|
__name: "AmDateFilter",
|
|
199
196
|
props: {
|
|
@@ -204,7 +201,7 @@ const me = G(
|
|
|
204
201
|
dateRangeConfigs: { default: () => ({}) },
|
|
205
202
|
disabled: { type: Boolean },
|
|
206
203
|
card: { type: Boolean },
|
|
207
|
-
timeZone: { default:
|
|
204
|
+
timeZone: { default: v }
|
|
208
205
|
},
|
|
209
206
|
emits: ["update:modelValue"],
|
|
210
207
|
setup(e, { emit: a }) {
|
|
@@ -216,92 +213,92 @@ const me = G(
|
|
|
216
213
|
dateRangeConfigs: s,
|
|
217
214
|
disabled: i,
|
|
218
215
|
card: m,
|
|
219
|
-
timeZone:
|
|
220
|
-
} =
|
|
221
|
-
() =>
|
|
222
|
-
label:
|
|
223
|
-
value:
|
|
224
|
-
selected:
|
|
216
|
+
timeZone: g
|
|
217
|
+
} = oe(t), A = a, h = k(F), N = k(), f = k(null), _ = k(!1), K = H(), O = S(() => !s.value || Object.keys(s.value).length === 0 ? ["Hoje", "Ontem", "7D", "14D", "30D"] : Object.keys(s.value)), Q = S(
|
|
218
|
+
() => O.value.map((l) => ({
|
|
219
|
+
label: l,
|
|
220
|
+
value: l,
|
|
221
|
+
selected: h.value === l
|
|
225
222
|
}))
|
|
226
|
-
),
|
|
227
|
-
...he(
|
|
223
|
+
), P = S(() => ({
|
|
224
|
+
...he(g.value),
|
|
228
225
|
...s.value
|
|
229
|
-
})),
|
|
230
|
-
|
|
231
|
-
const r =
|
|
226
|
+
})), M = (l) => {
|
|
227
|
+
h.value = l;
|
|
228
|
+
const r = P.value[l];
|
|
232
229
|
if (r) {
|
|
233
|
-
const
|
|
234
|
-
|
|
230
|
+
const o = r();
|
|
231
|
+
o && (_.value = !0, f.value = o);
|
|
235
232
|
}
|
|
236
|
-
}, W = (
|
|
237
|
-
if (
|
|
238
|
-
const r = U(
|
|
233
|
+
}, W = (l) => {
|
|
234
|
+
if (_.value) return;
|
|
235
|
+
const r = U(l, g.value), o = ke(
|
|
239
236
|
r,
|
|
240
|
-
|
|
241
|
-
|
|
237
|
+
O.value,
|
|
238
|
+
P.value
|
|
242
239
|
);
|
|
243
|
-
if (
|
|
240
|
+
if (h.value !== o && (h.value = o), r && r.length === 2)
|
|
244
241
|
try {
|
|
245
|
-
const
|
|
246
|
-
|
|
247
|
-
|
|
242
|
+
const D = [
|
|
243
|
+
x(r[0]),
|
|
244
|
+
x(r[1])
|
|
248
245
|
];
|
|
249
|
-
(!f.value || !
|
|
250
|
-
} catch (
|
|
251
|
-
console.warn("Erro ao sincronizar datas do modelValue:",
|
|
246
|
+
(!f.value || !z(f.value[0], D[0]) || !z(f.value[1], D[1])) && (f.value = D);
|
|
247
|
+
} catch (D) {
|
|
248
|
+
console.warn("Erro ao sincronizar datas do modelValue:", D);
|
|
252
249
|
}
|
|
253
250
|
}, X = () => {
|
|
254
|
-
|
|
255
|
-
}, Z = (
|
|
256
|
-
|
|
257
|
-
}, ee = (
|
|
258
|
-
const r = U(p.value);
|
|
251
|
+
M(F);
|
|
252
|
+
}, Z = (l) => {
|
|
253
|
+
M(l);
|
|
254
|
+
}, ee = (l) => {
|
|
255
|
+
const r = U(p.value, g.value);
|
|
259
256
|
if (r && r.length === 2) return;
|
|
260
|
-
const
|
|
261
|
-
|
|
257
|
+
const o = l !== void 0 ? Ce[l] : F;
|
|
258
|
+
o && M(o);
|
|
262
259
|
};
|
|
263
|
-
return
|
|
260
|
+
return L(p, (l) => W(l), {
|
|
264
261
|
immediate: !0,
|
|
265
262
|
deep: !0
|
|
266
|
-
}),
|
|
263
|
+
}), L(
|
|
267
264
|
f,
|
|
268
|
-
async (
|
|
269
|
-
var r,
|
|
270
|
-
if ((
|
|
265
|
+
async (l) => {
|
|
266
|
+
var r, o;
|
|
267
|
+
if ((l == null ? void 0 : l.length) === 2 && l[0] && l[1])
|
|
271
268
|
try {
|
|
272
|
-
(
|
|
269
|
+
(o = (r = N.value) == null ? void 0 : r.popover) == null || o.hide(), A("update:modelValue", ye(l, g.value)), await re(), _.value = !1;
|
|
273
270
|
} catch {
|
|
274
|
-
|
|
271
|
+
_.value = !1;
|
|
275
272
|
}
|
|
276
273
|
},
|
|
277
274
|
{ deep: !0 }
|
|
278
|
-
),
|
|
275
|
+
), L(n, (l) => ee(l), { immediate: !0 }), (l, r) => (b(), w("div", {
|
|
279
276
|
role: "group",
|
|
280
277
|
"aria-label": "Filtro de período",
|
|
281
278
|
class: V(d(pe)({ card: d(m), disabled: d(i) }, d(K).class))
|
|
282
279
|
}, [
|
|
283
|
-
|
|
280
|
+
B(De, {
|
|
284
281
|
ref_key: "pickerRef",
|
|
285
|
-
ref:
|
|
282
|
+
ref: N,
|
|
286
283
|
date: f.value,
|
|
287
|
-
"onUpdate:date": r[0] || (r[0] = (
|
|
288
|
-
selected:
|
|
284
|
+
"onUpdate:date": r[0] || (r[0] = (o) => f.value = o),
|
|
285
|
+
selected: h.value === F,
|
|
289
286
|
disabled: d(i),
|
|
290
287
|
"min-date": d(u) || void 0,
|
|
291
288
|
"max-date": d(c) || void 0,
|
|
292
289
|
onClick: X
|
|
293
290
|
}, null, 8, ["date", "selected", "disabled", "min-date", "max-date"]),
|
|
294
|
-
(
|
|
295
|
-
key:
|
|
296
|
-
selected:
|
|
291
|
+
(b(!0), w(Y, null, se(Q.value, (o) => (b(), T(J, {
|
|
292
|
+
key: o.value,
|
|
293
|
+
selected: o.selected,
|
|
297
294
|
disabled: d(i),
|
|
298
|
-
"data-test": `amdatefilter-toolbar-${
|
|
299
|
-
label:
|
|
300
|
-
onClick: (
|
|
295
|
+
"data-test": `amdatefilter-toolbar-${o.value.toLowerCase()}`,
|
|
296
|
+
label: o.label,
|
|
297
|
+
onClick: (D) => Z(o.value)
|
|
301
298
|
}, null, 8, ["selected", "disabled", "data-test", "label", "onClick"]))), 128))
|
|
302
299
|
], 2));
|
|
303
300
|
}
|
|
304
301
|
});
|
|
305
302
|
export {
|
|
306
|
-
|
|
303
|
+
Se as default
|
|
307
304
|
};
|