@appmax_npm/ds-prime 1.0.0-alpha.179 → 1.0.0-alpha.180
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.d.ts +2 -1
- package/amdatefilter/index.js +67 -67
- package/package.json +1 -1
package/amdatefilter/index.d.ts
CHANGED
|
@@ -10,10 +10,11 @@ export type DateRangeOffsets = [number, number];
|
|
|
10
10
|
export interface DateRangePeriod {
|
|
11
11
|
label: string;
|
|
12
12
|
offsets: DateRangeOffsets;
|
|
13
|
+
defaultKey?: number;
|
|
13
14
|
}
|
|
14
15
|
|
|
15
16
|
export interface AmDateFilterProps extends AllowedComponentProps {
|
|
16
|
-
defaultSelected?:
|
|
17
|
+
defaultSelected?: number;
|
|
17
18
|
modelValue?: string[] | Date[];
|
|
18
19
|
minDate?: Date | null;
|
|
19
20
|
maxDate?: Date | null;
|
package/amdatefilter/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { defineComponent as
|
|
1
|
+
import { defineComponent as V, useAttrs as P, openBlock as v, createElementBlock as k, normalizeClass as x, unref as i, createBlock as E, createCommentVNode as z, withCtx as U, createTextVNode as te, toDisplayString as ae, mergeModels as K, useModel as le, ref as C, Fragment as $, createVNode as T, toRefs as oe, computed as N, watch as w, nextTick as se, renderList as re } 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 I } from "class-variance-authority";
|
|
@@ -44,7 +44,7 @@ const fe = I(
|
|
|
44
44
|
}
|
|
45
45
|
}
|
|
46
46
|
}
|
|
47
|
-
), pe = (e, a) => j(fe(e), a), be = (e, a) => j(me(e), a), De = ["disabled", "data-test"], ve = /* @__PURE__ */
|
|
47
|
+
), pe = (e, a) => j(fe(e), a), be = (e, a) => j(me(e), a), De = ["disabled", "data-test"], ve = /* @__PURE__ */ V({
|
|
48
48
|
inheritAttrs: !1,
|
|
49
49
|
__name: "AmDateFilterButton",
|
|
50
50
|
props: {
|
|
@@ -59,19 +59,19 @@ const fe = I(
|
|
|
59
59
|
emits: ["click"],
|
|
60
60
|
setup(e) {
|
|
61
61
|
const a = P();
|
|
62
|
-
return (t, r) => (
|
|
62
|
+
return (t, r) => (v(), k("button", {
|
|
63
63
|
type: "button",
|
|
64
64
|
class: x([i(be)({ selected: t.selected, disabled: t.disabled, isCustom: t.isCustom }, i(a).class), { "am-date-filter-button--custom": t.isCustom }]),
|
|
65
65
|
disabled: t.disabled,
|
|
66
66
|
"data-test": t.dataTest,
|
|
67
67
|
onClick: r[0] || (r[0] = (u) => t.$emit("click", u))
|
|
68
68
|
}, [
|
|
69
|
-
t.icon ? (
|
|
69
|
+
t.icon ? (v(), E(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"])) : z("", !0),
|
|
74
|
+
t.label ? (v(), E(ne, {
|
|
75
75
|
key: 1,
|
|
76
76
|
as: "span",
|
|
77
77
|
class: x(t.hideLabel ? "am-date-filter-label--responsive" : "")
|
|
@@ -80,10 +80,10 @@ const fe = I(
|
|
|
80
80
|
te(ae(t.label), 1)
|
|
81
81
|
]),
|
|
82
82
|
_: 1
|
|
83
|
-
}, 8, ["class"])) :
|
|
83
|
+
}, 8, ["class"])) : z("", !0)
|
|
84
84
|
], 10, De));
|
|
85
85
|
}
|
|
86
|
-
}), G = /* @__PURE__ */ de(ve, [["__scopeId", "data-v-e2a79444"]]), ge = /* @__PURE__ */
|
|
86
|
+
}), G = /* @__PURE__ */ de(ve, [["__scopeId", "data-v-e2a79444"]]), ge = /* @__PURE__ */ V({
|
|
87
87
|
__name: "AmDateFilterPicker",
|
|
88
88
|
props: /* @__PURE__ */ K({
|
|
89
89
|
selected: { type: Boolean, default: !1 },
|
|
@@ -96,12 +96,12 @@ const fe = I(
|
|
|
96
96
|
}),
|
|
97
97
|
emits: /* @__PURE__ */ K(["click"], ["update:date"]),
|
|
98
98
|
setup(e, { expose: a, emit: t }) {
|
|
99
|
-
const r = le(e, "date"), u = t, c =
|
|
99
|
+
const r = le(e, "date"), u = t, c = C(), b = (n) => {
|
|
100
100
|
var d;
|
|
101
101
|
(d = c.value) == null || d.toggle(n), u("click", n);
|
|
102
102
|
};
|
|
103
|
-
return a({ popover: c }), (n, d) => (
|
|
104
|
-
|
|
103
|
+
return a({ popover: c }), (n, d) => (v(), k($, null, [
|
|
104
|
+
T(G, {
|
|
105
105
|
selected: n.selected,
|
|
106
106
|
disabled: n.disabled,
|
|
107
107
|
"is-custom": "",
|
|
@@ -111,17 +111,17 @@ const fe = I(
|
|
|
111
111
|
"hide-label": "",
|
|
112
112
|
onClick: b
|
|
113
113
|
}, null, 8, ["selected", "disabled"]),
|
|
114
|
-
|
|
114
|
+
T(i(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
120
|
default: U(() => [
|
|
121
|
-
|
|
121
|
+
T(i(ce), {
|
|
122
122
|
"data-test": "amdatefilter-datepicker",
|
|
123
123
|
modelValue: r.value,
|
|
124
|
-
"onUpdate:modelValue": d[0] || (d[0] = (
|
|
124
|
+
"onUpdate:modelValue": d[0] || (d[0] = (g) => r.value = g),
|
|
125
125
|
selectionMode: "range",
|
|
126
126
|
inline: "",
|
|
127
127
|
dateFormat: "yyyy-mm-dd",
|
|
@@ -137,23 +137,23 @@ const fe = I(
|
|
|
137
137
|
}, 512)
|
|
138
138
|
], 64));
|
|
139
139
|
}
|
|
140
|
-
}), p = "America/Sao_Paulo", ye = (e = p) => {
|
|
140
|
+
}), p = "America/Sao_Paulo", D = "Customizar", ye = (e = p) => {
|
|
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
143
|
}, O = (e, a = p) => {
|
|
144
144
|
const t = ye(a);
|
|
145
145
|
return t.setDate(t.getDate() + e), t;
|
|
146
|
-
},
|
|
146
|
+
}, M = (e, a = p) => e.toLocaleDateString("en-CA", { timeZone: a }), L = (e) => {
|
|
147
147
|
const a = e.split("T")[0], [t, r, u] = a.split("-").map(Number);
|
|
148
148
|
return new Date(t, r - 1, u);
|
|
149
|
-
},
|
|
149
|
+
}, F = (e, a) => e.getFullYear() === a.getFullYear() && e.getMonth() === a.getMonth() && e.getDate() === a.getDate(), he = (e, a = p) => {
|
|
150
150
|
if (!Array.isArray(e) || e.length !== 2)
|
|
151
151
|
throw new Error("Range de datas inválido");
|
|
152
152
|
const [t, r] = e;
|
|
153
153
|
if (!t || !r)
|
|
154
154
|
throw new Error("Datas não podem ser nulas");
|
|
155
|
-
return [
|
|
156
|
-
}, H = (e, a = p) => [O(e[0], a), O(e[1], a)],
|
|
155
|
+
return [M(t, a), M(r, a)];
|
|
156
|
+
}, H = (e, a = p) => [O(e[0], a), O(e[1], a)], _ = {
|
|
157
157
|
TODAY: { label: "Hoje", offsets: [0, 0], defaultKey: 0 },
|
|
158
158
|
YESTERDAY: { label: "Ontem", offsets: [-1, -1], defaultKey: 1 },
|
|
159
159
|
LAST_7D: { label: "7D", offsets: [-6, 0], defaultKey: 7 },
|
|
@@ -163,31 +163,31 @@ const fe = I(
|
|
|
163
163
|
LAST_90D: { label: "90D", offsets: [-89, 0], defaultKey: 90 },
|
|
164
164
|
LAST_365D: { label: "365D", offsets: [-364, 0], defaultKey: 365 }
|
|
165
165
|
}, _e = [
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
166
|
+
_.TODAY,
|
|
167
|
+
_.YESTERDAY,
|
|
168
|
+
_.LAST_7D,
|
|
169
|
+
_.LAST_14D,
|
|
170
|
+
_.LAST_30D
|
|
171
171
|
], Y = (e, a = p) => {
|
|
172
172
|
if (!(!e || e.length === 0))
|
|
173
|
-
return e.map((t) => t instanceof Date ?
|
|
173
|
+
return e.map((t) => t instanceof Date ? M(t, a) : String(t));
|
|
174
174
|
}, Ce = (e, a, t = p) => {
|
|
175
175
|
if (!e || e.length !== 2)
|
|
176
|
-
return
|
|
176
|
+
return D;
|
|
177
177
|
try {
|
|
178
|
-
const [r, u] = e, c =
|
|
178
|
+
const [r, u] = e, c = L(r), b = L(u);
|
|
179
179
|
if (isNaN(c.getTime()) || isNaN(b.getTime()))
|
|
180
|
-
return
|
|
180
|
+
return D;
|
|
181
181
|
for (const n of a) {
|
|
182
|
-
const [d,
|
|
183
|
-
if (
|
|
182
|
+
const [d, g] = H(n.offsets, t);
|
|
183
|
+
if (F(c, d) && F(b, g))
|
|
184
184
|
return n.label;
|
|
185
185
|
}
|
|
186
|
-
return
|
|
186
|
+
return D;
|
|
187
187
|
} catch {
|
|
188
|
-
return
|
|
188
|
+
return D;
|
|
189
189
|
}
|
|
190
|
-
},
|
|
190
|
+
}, xe = /* @__PURE__ */ V({
|
|
191
191
|
inheritAttrs: !1,
|
|
192
192
|
__name: "AmDateFilter",
|
|
193
193
|
props: {
|
|
@@ -209,80 +209,80 @@ const fe = I(
|
|
|
209
209
|
modelValue: b,
|
|
210
210
|
dateRangeConfigs: n,
|
|
211
211
|
disabled: d,
|
|
212
|
-
card:
|
|
213
|
-
timeZone:
|
|
214
|
-
} = oe(t), Z = a,
|
|
215
|
-
() =>
|
|
212
|
+
card: g,
|
|
213
|
+
timeZone: y
|
|
214
|
+
} = oe(t), Z = a, h = C(D), R = C(), f = C(null), A = C(!1), q = P(), S = N(() => !n.value || n.value.length === 0 ? _e : n.value), J = N(
|
|
215
|
+
() => S.value.map((l) => ({
|
|
216
216
|
label: l.label,
|
|
217
217
|
value: l.label,
|
|
218
|
-
selected:
|
|
218
|
+
selected: h.value === l.label
|
|
219
219
|
}))
|
|
220
|
-
),
|
|
221
|
-
|
|
222
|
-
const s =
|
|
220
|
+
), B = (l) => {
|
|
221
|
+
h.value = l;
|
|
222
|
+
const s = S.value.find((o) => o.label === l);
|
|
223
223
|
if (s) {
|
|
224
|
-
const o = H(s.offsets,
|
|
225
|
-
|
|
224
|
+
const o = H(s.offsets, y.value);
|
|
225
|
+
A.value = !0, f.value = o;
|
|
226
226
|
}
|
|
227
227
|
}, Q = (l) => {
|
|
228
|
-
if (
|
|
229
|
-
const s = Y(l,
|
|
228
|
+
if (A.value) return;
|
|
229
|
+
const s = Y(l, y.value), o = Ce(
|
|
230
230
|
s,
|
|
231
|
-
|
|
232
|
-
|
|
231
|
+
S.value,
|
|
232
|
+
y.value
|
|
233
233
|
);
|
|
234
|
-
if (
|
|
234
|
+
if (h.value !== o && (h.value = o), s && s.length === 2)
|
|
235
235
|
try {
|
|
236
236
|
const m = [
|
|
237
|
-
|
|
238
|
-
|
|
237
|
+
L(s[0]),
|
|
238
|
+
L(s[1])
|
|
239
239
|
];
|
|
240
|
-
(!f.value || !
|
|
240
|
+
(!f.value || !F(f.value[0], m[0]) || !F(f.value[1], m[1])) && (f.value = m);
|
|
241
241
|
} catch (m) {
|
|
242
242
|
console.warn("Erro ao sincronizar datas do modelValue:", m);
|
|
243
243
|
}
|
|
244
244
|
}, W = () => {
|
|
245
|
-
|
|
245
|
+
B(D);
|
|
246
246
|
}, X = (l) => {
|
|
247
|
-
|
|
247
|
+
B(l);
|
|
248
248
|
}, ee = (l) => {
|
|
249
|
-
const s = Y(b.value,
|
|
249
|
+
const s = Y(b.value, y.value);
|
|
250
250
|
if (s && s.length === 2 || l === void 0) return;
|
|
251
|
-
const o =
|
|
252
|
-
o &&
|
|
251
|
+
const o = S.value.find((m) => m.defaultKey === l);
|
|
252
|
+
o && B(o.label);
|
|
253
253
|
};
|
|
254
|
-
return
|
|
254
|
+
return w(b, (l) => Q(l), {
|
|
255
255
|
immediate: !0,
|
|
256
256
|
deep: !0
|
|
257
|
-
}),
|
|
257
|
+
}), w(
|
|
258
258
|
f,
|
|
259
259
|
async (l) => {
|
|
260
260
|
var s, o;
|
|
261
261
|
if ((l == null ? void 0 : l.length) === 2 && l[0] && l[1])
|
|
262
262
|
try {
|
|
263
|
-
(o = (s =
|
|
263
|
+
(o = (s = R.value) == null ? void 0 : s.popover) == null || o.hide(), Z("update:modelValue", he(l, y.value)), await se(), A.value = !1;
|
|
264
264
|
} catch {
|
|
265
|
-
|
|
265
|
+
A.value = !1;
|
|
266
266
|
}
|
|
267
267
|
},
|
|
268
268
|
{ deep: !0 }
|
|
269
|
-
),
|
|
269
|
+
), w(r, (l) => ee(l), { immediate: !0 }), (l, s) => (v(), k("div", {
|
|
270
270
|
role: "group",
|
|
271
271
|
"aria-label": "Filtro de período",
|
|
272
|
-
class: x(i(pe)({ card: i(
|
|
272
|
+
class: x(i(pe)({ card: i(g), disabled: i(d) }, i(q).class))
|
|
273
273
|
}, [
|
|
274
|
-
|
|
274
|
+
T(ge, {
|
|
275
275
|
ref_key: "pickerRef",
|
|
276
|
-
ref:
|
|
276
|
+
ref: R,
|
|
277
277
|
date: f.value,
|
|
278
278
|
"onUpdate:date": s[0] || (s[0] = (o) => f.value = o),
|
|
279
|
-
selected:
|
|
279
|
+
selected: h.value === i(D),
|
|
280
280
|
disabled: i(d),
|
|
281
281
|
"min-date": i(u) || void 0,
|
|
282
282
|
"max-date": i(c) || void 0,
|
|
283
283
|
onClick: W
|
|
284
284
|
}, null, 8, ["date", "selected", "disabled", "min-date", "max-date"]),
|
|
285
|
-
(
|
|
285
|
+
(v(!0), k($, null, re(J.value, (o) => (v(), E(G, {
|
|
286
286
|
key: o.value,
|
|
287
287
|
selected: o.selected,
|
|
288
288
|
disabled: i(d),
|
|
@@ -294,6 +294,6 @@ const fe = I(
|
|
|
294
294
|
}
|
|
295
295
|
});
|
|
296
296
|
export {
|
|
297
|
-
|
|
297
|
+
_ as AmDateFilterPeriods,
|
|
298
298
|
xe as default
|
|
299
299
|
};
|