@appmax_npm/ds-prime 1.0.0-alpha.174 → 1.0.0-alpha.175
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 +101 -99
- package/package.json +1 -1
package/amdatefilter/index.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { defineComponent as V, useAttrs as
|
|
2
|
-
import { _ as
|
|
3
|
-
import { _ as
|
|
4
|
-
import { cva as
|
|
5
|
-
import { twMerge as
|
|
6
|
-
import { _ as
|
|
1
|
+
import { defineComponent as V, useAttrs as $, openBlock as b, createElementBlock as _, normalizeClass as S, unref as i, createBlock as z, createCommentVNode as L, withCtx as j, createTextVNode as X, toDisplayString as Z, mergeModels as E, useModel as ee, ref as h, Fragment as I, createVNode as T, toRefs as te, computed as B, watch as x, nextTick as ae, renderList as oe } from "vue";
|
|
2
|
+
import { _ as le } from "../AmText.vue_vue_type_script_setup_true_lang-ZUjjXA8M.js";
|
|
3
|
+
import { _ as re } from "../AmIcon.vue_vue_type_script_setup_true_lang-DWxib5iw.js";
|
|
4
|
+
import { cva as P } from "class-variance-authority";
|
|
5
|
+
import { twMerge as H } from "tailwind-merge";
|
|
6
|
+
import { _ as ne } from "../_plugin-vue_export-helper-CHgC5LLL.js";
|
|
7
7
|
import se from "primevue/popover";
|
|
8
|
-
import
|
|
9
|
-
const
|
|
8
|
+
import ie from "primevue/datepicker";
|
|
9
|
+
const de = P(
|
|
10
10
|
"flex w-full h-[39px] bg-white divide-x divide-surface-300 [container-type:inline-size] border border-surface-300",
|
|
11
11
|
{
|
|
12
12
|
variants: {
|
|
@@ -20,7 +20,7 @@ const ie = I(
|
|
|
20
20
|
}
|
|
21
21
|
}
|
|
22
22
|
}
|
|
23
|
-
),
|
|
23
|
+
), ue = P(
|
|
24
24
|
[
|
|
25
25
|
"flex-1 flex items-center justify-center gap-1.5 px-0.5",
|
|
26
26
|
"cursor-pointer bg-transparent border-solid [border-width:0]",
|
|
@@ -44,7 +44,7 @@ const ie = I(
|
|
|
44
44
|
}
|
|
45
45
|
}
|
|
46
46
|
}
|
|
47
|
-
),
|
|
47
|
+
), ce = (e, t) => H(de(e), t), me = (e, t) => H(ue(e), t), fe = ["disabled", "data-test"], pe = /* @__PURE__ */ V({
|
|
48
48
|
inheritAttrs: !1,
|
|
49
49
|
__name: "AmDateFilterButton",
|
|
50
50
|
props: {
|
|
@@ -58,32 +58,32 @@ const ie = I(
|
|
|
58
58
|
},
|
|
59
59
|
emits: ["click"],
|
|
60
60
|
setup(e) {
|
|
61
|
-
const t =
|
|
62
|
-
return (o, d) => (
|
|
61
|
+
const t = $();
|
|
62
|
+
return (o, d) => (b(), _("button", {
|
|
63
63
|
type: "button",
|
|
64
|
-
class: S([i(
|
|
64
|
+
class: S([i(me)({ selected: o.selected, disabled: o.disabled, isCustom: o.isCustom }, i(t).class), { "am-date-filter-button--custom": o.isCustom }]),
|
|
65
65
|
disabled: o.disabled,
|
|
66
66
|
"data-test": o.dataTest,
|
|
67
67
|
onClick: d[0] || (d[0] = (f) => o.$emit("click", f))
|
|
68
68
|
}, [
|
|
69
|
-
o.icon ? (
|
|
69
|
+
o.icon ? (b(), z(re, {
|
|
70
70
|
key: 0,
|
|
71
71
|
icon: o.icon,
|
|
72
72
|
size: "sm"
|
|
73
73
|
}, null, 8, ["icon"])) : L("", !0),
|
|
74
|
-
o.label ? (
|
|
74
|
+
o.label ? (b(), z(le, {
|
|
75
75
|
key: 1,
|
|
76
76
|
as: "span",
|
|
77
77
|
class: S(o.hideLabel ? "am-date-filter-label--responsive" : "")
|
|
78
78
|
}, {
|
|
79
|
-
default:
|
|
80
|
-
|
|
79
|
+
default: j(() => [
|
|
80
|
+
X(Z(o.label), 1)
|
|
81
81
|
]),
|
|
82
82
|
_: 1
|
|
83
83
|
}, 8, ["class"])) : L("", !0)
|
|
84
|
-
], 10,
|
|
84
|
+
], 10, fe));
|
|
85
85
|
}
|
|
86
|
-
}),
|
|
86
|
+
}), Y = /* @__PURE__ */ ne(pe, [["__scopeId", "data-v-e2a79444"]]), ge = /* @__PURE__ */ V({
|
|
87
87
|
__name: "AmDateFilterPicker",
|
|
88
88
|
props: /* @__PURE__ */ E({
|
|
89
89
|
selected: { type: Boolean, default: !1 },
|
|
@@ -96,20 +96,20 @@ const ie = I(
|
|
|
96
96
|
}),
|
|
97
97
|
emits: /* @__PURE__ */ E(["click"], ["update:date"]),
|
|
98
98
|
setup(e, { expose: t, emit: o }) {
|
|
99
|
-
const d =
|
|
100
|
-
var
|
|
101
|
-
(
|
|
99
|
+
const d = ee(e, "date"), f = o, u = h(), p = (n) => {
|
|
100
|
+
var s;
|
|
101
|
+
(s = u.value) == null || s.toggle(n), f("click", n);
|
|
102
102
|
};
|
|
103
|
-
return t({ popover: u }), (
|
|
104
|
-
T(
|
|
105
|
-
selected:
|
|
106
|
-
disabled:
|
|
103
|
+
return t({ popover: u }), (n, s) => (b(), _(I, null, [
|
|
104
|
+
T(Y, {
|
|
105
|
+
selected: n.selected,
|
|
106
|
+
disabled: n.disabled,
|
|
107
107
|
"is-custom": "",
|
|
108
108
|
"data-test": "amdatefilter-toolbar-custom",
|
|
109
109
|
icon: "calendar_today",
|
|
110
110
|
label: "Customizar",
|
|
111
111
|
"hide-label": "",
|
|
112
|
-
onClick:
|
|
112
|
+
onClick: p
|
|
113
113
|
}, null, 8, ["selected", "disabled"]),
|
|
114
114
|
T(i(se), {
|
|
115
115
|
"data-test": "amdatefilter-popover",
|
|
@@ -117,16 +117,16 @@ const ie = I(
|
|
|
117
117
|
ref: u,
|
|
118
118
|
"pt:content": "!p-0"
|
|
119
119
|
}, {
|
|
120
|
-
default:
|
|
121
|
-
T(i(
|
|
120
|
+
default: j(() => [
|
|
121
|
+
T(i(ie), {
|
|
122
122
|
"data-test": "amdatefilter-datepicker",
|
|
123
123
|
modelValue: d.value,
|
|
124
|
-
"onUpdate:modelValue":
|
|
124
|
+
"onUpdate:modelValue": s[0] || (s[0] = (c) => d.value = c),
|
|
125
125
|
selectionMode: "range",
|
|
126
126
|
inline: "",
|
|
127
127
|
dateFormat: "yyyy-mm-dd",
|
|
128
|
-
minDate:
|
|
129
|
-
maxDate:
|
|
128
|
+
minDate: n.minDate,
|
|
129
|
+
maxDate: n.maxDate,
|
|
130
130
|
"pt:dayCell": "!p-0",
|
|
131
131
|
"pt:tableHeaderCell": "!p-0",
|
|
132
132
|
"pt:panel": "!p-0 !border-none",
|
|
@@ -137,25 +137,25 @@ const ie = I(
|
|
|
137
137
|
}, 512)
|
|
138
138
|
], 64));
|
|
139
139
|
}
|
|
140
|
-
}),
|
|
140
|
+
}), D = () => {
|
|
141
141
|
const e = /* @__PURE__ */ new Date();
|
|
142
142
|
return new Date(Date.UTC(e.getFullYear(), e.getMonth(), e.getDate()));
|
|
143
143
|
}, C = (e) => {
|
|
144
|
-
const t =
|
|
144
|
+
const t = D(), o = new Date(t);
|
|
145
145
|
return o.setUTCDate(t.getUTCDate() + e), o;
|
|
146
|
-
},
|
|
146
|
+
}, M = (e) => new Date(Date.UTC(e.getUTCFullYear(), e.getUTCMonth(), e.getUTCDate())), w = (e, t) => e.getUTCFullYear() === t.getUTCFullYear() && e.getUTCMonth() === t.getUTCMonth() && e.getUTCDate() === t.getUTCDate(), be = (e) => {
|
|
147
147
|
if (!Array.isArray(e) || e.length !== 2)
|
|
148
148
|
throw new Error("Range de datas inválido");
|
|
149
149
|
const [t, o] = e;
|
|
150
150
|
if (!t || !o)
|
|
151
151
|
throw new Error("Datas não podem ser nulas");
|
|
152
|
-
return [
|
|
153
|
-
},
|
|
154
|
-
Hoje: () => [
|
|
152
|
+
return [M(t).toISOString(), M(o).toISOString()];
|
|
153
|
+
}, ve = {
|
|
154
|
+
Hoje: () => [D(), D()],
|
|
155
155
|
Ontem: () => [C(-1), C(-1)],
|
|
156
|
-
"7D": () => [C(-6),
|
|
157
|
-
"14D": () => [C(-13),
|
|
158
|
-
"30D": () => [C(-29),
|
|
156
|
+
"7D": () => [C(-6), D()],
|
|
157
|
+
"14D": () => [C(-13), D()],
|
|
158
|
+
"30D": () => [C(-29), D()],
|
|
159
159
|
Customizar: () => null
|
|
160
160
|
}, De = {
|
|
161
161
|
0: "Hoje",
|
|
@@ -163,25 +163,25 @@ const ie = I(
|
|
|
163
163
|
7: "7D",
|
|
164
164
|
14: "14D",
|
|
165
165
|
30: "30D"
|
|
166
|
-
},
|
|
166
|
+
}, N = (e) => {
|
|
167
167
|
if (!(!e || e.length === 0))
|
|
168
|
-
return e.map((t) => t instanceof Date ?
|
|
168
|
+
return e.map((t) => t instanceof Date ? M(t).toISOString() : String(t));
|
|
169
169
|
}, Ce = (e, t, o) => {
|
|
170
170
|
if (!e || e.length !== 2)
|
|
171
171
|
return "Customizar";
|
|
172
172
|
try {
|
|
173
|
-
const [d, f] = e, u = new Date(d),
|
|
174
|
-
if (isNaN(u.getTime()) || isNaN(
|
|
173
|
+
const [d, f] = e, u = new Date(d), p = new Date(f);
|
|
174
|
+
if (isNaN(u.getTime()) || isNaN(p.getTime()))
|
|
175
175
|
return "Customizar";
|
|
176
|
-
for (const
|
|
177
|
-
if (
|
|
178
|
-
const
|
|
179
|
-
if (!
|
|
180
|
-
const c =
|
|
176
|
+
for (const n of t) {
|
|
177
|
+
if (n === "Customizar") continue;
|
|
178
|
+
const s = o[n];
|
|
179
|
+
if (!s) continue;
|
|
180
|
+
const c = s();
|
|
181
181
|
if (!c || !Array.isArray(c) || c.length !== 2) continue;
|
|
182
|
-
const [F,
|
|
183
|
-
if (w(u, F) && w(
|
|
184
|
-
return
|
|
182
|
+
const [F, g] = c;
|
|
183
|
+
if (w(u, F) && w(p, g))
|
|
184
|
+
return n;
|
|
185
185
|
}
|
|
186
186
|
return "Customizar";
|
|
187
187
|
} catch {
|
|
@@ -205,89 +205,91 @@ const ie = I(
|
|
|
205
205
|
defaultSelected: d,
|
|
206
206
|
minDate: f,
|
|
207
207
|
maxDate: u,
|
|
208
|
-
modelValue:
|
|
209
|
-
dateRangeConfigs:
|
|
210
|
-
disabled:
|
|
208
|
+
modelValue: p,
|
|
209
|
+
dateRangeConfigs: n,
|
|
210
|
+
disabled: s,
|
|
211
211
|
card: c
|
|
212
|
-
} =
|
|
212
|
+
} = te(o), F = t, g = h(k), A = h(), m = h(null), y = h(!1), G = $(), O = B(() => !n.value || Object.keys(n.value).length === 0 ? ["Hoje", "Ontem", "7D", "14D", "30D"] : Object.keys(n.value)), q = B(
|
|
213
213
|
() => O.value.map((a) => ({
|
|
214
214
|
label: a,
|
|
215
215
|
value: a,
|
|
216
|
-
selected:
|
|
216
|
+
selected: g.value === a
|
|
217
217
|
}))
|
|
218
218
|
), R = B(() => ({
|
|
219
|
-
...
|
|
220
|
-
...
|
|
219
|
+
...ve,
|
|
220
|
+
...n.value
|
|
221
221
|
})), U = (a) => {
|
|
222
|
-
|
|
223
|
-
const
|
|
224
|
-
if (
|
|
225
|
-
const
|
|
226
|
-
|
|
222
|
+
g.value = a;
|
|
223
|
+
const r = R.value[a];
|
|
224
|
+
if (r) {
|
|
225
|
+
const l = r();
|
|
226
|
+
l && (y.value = !0, m.value = l);
|
|
227
227
|
}
|
|
228
|
-
},
|
|
229
|
-
if (
|
|
230
|
-
const
|
|
231
|
-
|
|
228
|
+
}, J = (a) => {
|
|
229
|
+
if (y.value) return;
|
|
230
|
+
const r = N(a), l = Ce(
|
|
231
|
+
r,
|
|
232
232
|
O.value,
|
|
233
233
|
R.value
|
|
234
234
|
);
|
|
235
|
-
if (
|
|
235
|
+
if (g.value !== l && (g.value = l), r && r.length === 2)
|
|
236
236
|
try {
|
|
237
|
-
const
|
|
238
|
-
new Date(
|
|
239
|
-
new Date(
|
|
237
|
+
const v = [
|
|
238
|
+
new Date(r[0]),
|
|
239
|
+
new Date(r[1])
|
|
240
240
|
];
|
|
241
|
-
(!m.value || !w(m.value[0],
|
|
242
|
-
} catch (
|
|
243
|
-
console.warn("Erro ao sincronizar datas do modelValue:",
|
|
241
|
+
(!m.value || !w(m.value[0], v[0]) || !w(m.value[1], v[1])) && (m.value = v);
|
|
242
|
+
} catch (v) {
|
|
243
|
+
console.warn("Erro ao sincronizar datas do modelValue:", v);
|
|
244
244
|
}
|
|
245
|
-
},
|
|
245
|
+
}, K = () => {
|
|
246
246
|
U(k);
|
|
247
|
-
}, K = (a) => {
|
|
248
|
-
U(a);
|
|
249
247
|
}, Q = (a) => {
|
|
248
|
+
U(a);
|
|
249
|
+
}, W = (a) => {
|
|
250
|
+
const r = N(p.value);
|
|
251
|
+
if (r && r.length === 2) return;
|
|
250
252
|
const l = a !== void 0 ? De[a] : k;
|
|
251
253
|
l && U(l);
|
|
252
254
|
};
|
|
253
|
-
return x(
|
|
255
|
+
return x(p, (a) => J(a), {
|
|
254
256
|
immediate: !0,
|
|
255
257
|
deep: !0
|
|
256
258
|
}), x(
|
|
257
259
|
m,
|
|
258
260
|
async (a) => {
|
|
259
|
-
var
|
|
261
|
+
var r, l;
|
|
260
262
|
if ((a == null ? void 0 : a.length) === 2 && a[0] && a[1])
|
|
261
263
|
try {
|
|
262
|
-
(
|
|
264
|
+
(l = (r = A.value) == null ? void 0 : r.popover) == null || l.hide(), F("update:modelValue", be(a)), await ae(), y.value = !1;
|
|
263
265
|
} catch {
|
|
264
|
-
|
|
266
|
+
y.value = !1;
|
|
265
267
|
}
|
|
266
268
|
},
|
|
267
269
|
{ deep: !0 }
|
|
268
|
-
), x(d, (a) =>
|
|
270
|
+
), x(d, (a) => W(a), { immediate: !0 }), (a, r) => (b(), _("div", {
|
|
269
271
|
role: "group",
|
|
270
272
|
"aria-label": "Filtro de período",
|
|
271
|
-
class: S(i(
|
|
273
|
+
class: S(i(ce)({ card: i(c), disabled: i(s) }, i(G).class))
|
|
272
274
|
}, [
|
|
273
|
-
T(
|
|
275
|
+
T(ge, {
|
|
274
276
|
ref_key: "pickerRef",
|
|
275
277
|
ref: A,
|
|
276
278
|
date: m.value,
|
|
277
|
-
"onUpdate:date":
|
|
278
|
-
selected:
|
|
279
|
-
disabled: i(
|
|
280
|
-
"min-date": i(f),
|
|
281
|
-
"max-date": i(u),
|
|
282
|
-
onClick:
|
|
279
|
+
"onUpdate:date": r[0] || (r[0] = (l) => m.value = l),
|
|
280
|
+
selected: g.value === k,
|
|
281
|
+
disabled: i(s),
|
|
282
|
+
"min-date": i(f) || void 0,
|
|
283
|
+
"max-date": i(u) || void 0,
|
|
284
|
+
onClick: K
|
|
283
285
|
}, null, 8, ["date", "selected", "disabled", "min-date", "max-date"]),
|
|
284
|
-
(
|
|
285
|
-
key:
|
|
286
|
-
selected:
|
|
287
|
-
disabled: i(
|
|
288
|
-
"data-test": `amdatefilter-toolbar-${
|
|
289
|
-
label:
|
|
290
|
-
onClick: (
|
|
286
|
+
(b(!0), _(I, null, oe(q.value, (l) => (b(), z(Y, {
|
|
287
|
+
key: l.value,
|
|
288
|
+
selected: l.selected,
|
|
289
|
+
disabled: i(s),
|
|
290
|
+
"data-test": `amdatefilter-toolbar-${l.value.toLowerCase()}`,
|
|
291
|
+
label: l.label,
|
|
292
|
+
onClick: (v) => Q(l.value)
|
|
291
293
|
}, null, 8, ["selected", "disabled", "data-test", "label", "onClick"]))), 128))
|
|
292
294
|
], 2));
|
|
293
295
|
}
|