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