@appmax_npm/ds-prime 1.0.0-alpha.154 → 1.0.0-alpha.156
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 +139 -134
- package/css/index.css +1 -1
- package/package.json +1 -1
package/amdatefilter/index.js
CHANGED
|
@@ -1,186 +1,191 @@
|
|
|
1
|
-
import { defineComponent as
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
|
|
1
|
+
import { defineComponent as Z, toRefs as ee, ref as n, onMounted as te, onUnmounted as ae, computed as v, watch as x, nextTick as oe, openBlock as _, createElementBlock as F, createVNode as g, unref as i, withCtx as D, createTextVNode as T, toDisplayString as A, Fragment as re, renderList as ne, createBlock as se, normalizeClass as le, normalizeStyle as ie } from "vue";
|
|
2
|
+
import ce from "primevue/popover";
|
|
3
|
+
import ue from "primevue/datepicker";
|
|
4
|
+
import E from "../ambutton/index.js";
|
|
5
|
+
import de from "primevue/buttongroup";
|
|
6
|
+
import { _ as me } from "../_plugin-vue_export-helper-CHgC5LLL.js";
|
|
7
|
+
const fe = /* @__PURE__ */ Z({
|
|
7
8
|
__name: "AmDateFilter",
|
|
8
9
|
props: {
|
|
9
|
-
defaultSelected: {},
|
|
10
10
|
modelValue: {},
|
|
11
|
+
defaultSelected: {},
|
|
11
12
|
minDate: {},
|
|
12
13
|
maxDate: {},
|
|
13
|
-
|
|
14
|
-
style: {}
|
|
14
|
+
dateRangeConfigs: { default: () => ({}) }
|
|
15
15
|
},
|
|
16
16
|
emits: ["update:modelValue"],
|
|
17
|
-
setup(
|
|
18
|
-
const
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
itemIcon: {
|
|
32
|
-
class: "!text-[#858585] !text-sm"
|
|
33
|
-
}
|
|
34
|
-
})), s = () => {
|
|
17
|
+
setup(H, { emit: N }) {
|
|
18
|
+
const V = H, { defaultSelected: j, minDate: L, maxDate: I, modelValue: M, dateRangeConfigs: c } = ee(V), P = N, s = n("Customizar"), y = n(), o = n(null), u = n(!1), k = n(0), C = n(null), b = new ResizeObserver((e) => {
|
|
19
|
+
k.value = e[0].contentRect.width;
|
|
20
|
+
});
|
|
21
|
+
te(() => {
|
|
22
|
+
C.value && b.observe(C.value);
|
|
23
|
+
}), ae(() => {
|
|
24
|
+
b.disconnect();
|
|
25
|
+
});
|
|
26
|
+
const U = v(() => ((a) => a >= 670 ? "Customizar" : "")(k.value)), S = v(() => !c.value || Object.keys(c.value).length === 0 ? ["Hoje", "Ontem", "7D", "14D", "30D"] : Object.keys(c.value)), R = v(() => S.value.map((e) => ({
|
|
27
|
+
label: e,
|
|
28
|
+
value: e,
|
|
29
|
+
selected: s.value === e
|
|
30
|
+
}))), r = () => {
|
|
35
31
|
const e = /* @__PURE__ */ new Date();
|
|
36
32
|
return e.setHours(0, 0, 0, 0), e;
|
|
37
|
-
},
|
|
38
|
-
const
|
|
39
|
-
return
|
|
40
|
-
},
|
|
41
|
-
const
|
|
42
|
-
return
|
|
43
|
-
},
|
|
33
|
+
}, l = (e) => {
|
|
34
|
+
const a = r(), t = new Date(a);
|
|
35
|
+
return t.setDate(a.getDate() + e), t;
|
|
36
|
+
}, d = (e) => {
|
|
37
|
+
const a = new Date(e);
|
|
38
|
+
return a.setHours(0, 0, 0, 0), a;
|
|
39
|
+
}, m = (e, a) => e.getFullYear() === a.getFullYear() && e.getMonth() === a.getMonth() && e.getDate() === a.getDate(), Y = (e) => {
|
|
44
40
|
if (!e || e.length !== 2)
|
|
45
41
|
return "Customizar";
|
|
46
42
|
try {
|
|
47
|
-
const [
|
|
48
|
-
if (isNaN(
|
|
43
|
+
const [a, t] = e, f = d(new Date(a)), w = d(new Date(t));
|
|
44
|
+
if (isNaN(f.getTime()) || isNaN(w.getTime()))
|
|
49
45
|
return "Customizar";
|
|
50
|
-
|
|
51
|
-
|
|
46
|
+
for (const z of S.value) {
|
|
47
|
+
if (z === "Customizar") continue;
|
|
48
|
+
const B = O.value[z];
|
|
49
|
+
if (!B) continue;
|
|
50
|
+
const p = B();
|
|
51
|
+
if (!p || !Array.isArray(p) || p.length !== 2) continue;
|
|
52
|
+
const [Q, X] = p;
|
|
53
|
+
if (m(f, d(Q)) && m(w, d(X)))
|
|
54
|
+
return z;
|
|
55
|
+
}
|
|
56
|
+
return "Customizar";
|
|
52
57
|
} catch {
|
|
53
58
|
return "Customizar";
|
|
54
59
|
}
|
|
55
|
-
},
|
|
56
|
-
Hoje: () => [
|
|
57
|
-
Ontem: () => [
|
|
58
|
-
"7D": () => [
|
|
59
|
-
"14D": () => [
|
|
60
|
-
"30D": () => [
|
|
60
|
+
}, $ = {
|
|
61
|
+
Hoje: () => [r(), r()],
|
|
62
|
+
Ontem: () => [l(-1), l(-1)],
|
|
63
|
+
"7D": () => [l(-6), r()],
|
|
64
|
+
"14D": () => [l(-13), r()],
|
|
65
|
+
"30D": () => [l(-29), r()],
|
|
61
66
|
Customizar: () => null
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
67
|
+
}, O = v(() => ({
|
|
68
|
+
...$,
|
|
69
|
+
...c.value
|
|
70
|
+
})), h = (e) => {
|
|
71
|
+
s.value = e;
|
|
72
|
+
const a = O.value[e];
|
|
73
|
+
if (a) {
|
|
74
|
+
const t = a();
|
|
75
|
+
t && (u.value = !0, o.value = t);
|
|
68
76
|
}
|
|
69
|
-
},
|
|
70
|
-
if (
|
|
77
|
+
}, G = (e) => {
|
|
78
|
+
if (u.value)
|
|
71
79
|
return;
|
|
72
|
-
const
|
|
73
|
-
if (
|
|
80
|
+
const a = Y(e);
|
|
81
|
+
if (s.value !== a && (s.value = a), e && e.length === 2)
|
|
74
82
|
try {
|
|
75
|
-
const
|
|
83
|
+
const t = [
|
|
76
84
|
new Date(e[0]),
|
|
77
85
|
new Date(e[1])
|
|
78
86
|
];
|
|
79
|
-
(!
|
|
80
|
-
} catch (
|
|
81
|
-
console.warn("Erro ao sincronizar datas do modelValue:",
|
|
87
|
+
(!o.value || !m(o.value[0], t[0]) || !m(o.value[1], t[1])) && (o.value = t);
|
|
88
|
+
} catch (t) {
|
|
89
|
+
console.warn("Erro ao sincronizar datas do modelValue:", t);
|
|
82
90
|
}
|
|
83
|
-
},
|
|
84
|
-
var
|
|
85
|
-
(
|
|
86
|
-
},
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
label: "Customizar",
|
|
91
|
-
icon: "pi pi-calendar",
|
|
92
|
-
command: (a) => A(a.originalEvent),
|
|
93
|
-
class: [
|
|
94
|
-
"am-v3-date-filter-selector-item-customize",
|
|
95
|
-
"custom",
|
|
96
|
-
t("Customizar")
|
|
97
|
-
]
|
|
98
|
-
},
|
|
99
|
-
{
|
|
100
|
-
label: "Hoje",
|
|
101
|
-
command: () => l("Hoje"),
|
|
102
|
-
class: ["am-v3-date-filter-selector-item-today", t("Hoje")]
|
|
103
|
-
},
|
|
104
|
-
{
|
|
105
|
-
label: "Ontem",
|
|
106
|
-
command: () => l("Ontem"),
|
|
107
|
-
class: ["am-v3-date-filter-selector-item-yesterday", t("Ontem")]
|
|
108
|
-
},
|
|
109
|
-
{
|
|
110
|
-
label: "7D",
|
|
111
|
-
command: () => l("7D"),
|
|
112
|
-
class: ["am-v3-date-filter-selector-item-7d", t("7D")]
|
|
113
|
-
},
|
|
114
|
-
{
|
|
115
|
-
label: "14D",
|
|
116
|
-
command: () => l("14D"),
|
|
117
|
-
class: ["am-v3-date-filter-selector-item-14d", t("14D")]
|
|
118
|
-
},
|
|
119
|
-
{
|
|
120
|
-
label: "30D",
|
|
121
|
-
command: () => l("30D"),
|
|
122
|
-
class: ["am-v3-date-filter-selector-item-30d", t("30D")]
|
|
123
|
-
}
|
|
124
|
-
];
|
|
125
|
-
}), L = (e) => {
|
|
126
|
-
const a = e !== void 0 ? {
|
|
91
|
+
}, W = (e) => {
|
|
92
|
+
var a;
|
|
93
|
+
(a = y.value) == null || a.toggle(e), h("Customizar");
|
|
94
|
+
}, q = (e) => {
|
|
95
|
+
h(e);
|
|
96
|
+
}, J = (e) => {
|
|
97
|
+
const t = e !== void 0 ? {
|
|
127
98
|
0: "Hoje",
|
|
128
99
|
1: "Ontem",
|
|
129
100
|
7: "7D",
|
|
130
101
|
14: "14D",
|
|
131
102
|
30: "30D"
|
|
132
103
|
}[e] : "Customizar";
|
|
133
|
-
|
|
134
|
-
},
|
|
104
|
+
t && h(t);
|
|
105
|
+
}, K = (e) => {
|
|
135
106
|
if (!Array.isArray(e) || e.length !== 2)
|
|
136
107
|
throw new Error("Range de datas inválido");
|
|
137
|
-
const [
|
|
138
|
-
if (!
|
|
108
|
+
const [a, t] = e;
|
|
109
|
+
if (!a || !t)
|
|
139
110
|
throw new Error("Datas não podem ser nulas");
|
|
140
|
-
return [
|
|
111
|
+
return [a.toISOString(), t.toISOString()];
|
|
141
112
|
};
|
|
142
|
-
return
|
|
143
|
-
|
|
113
|
+
return x(
|
|
114
|
+
M,
|
|
144
115
|
(e) => {
|
|
145
|
-
|
|
116
|
+
G(e);
|
|
146
117
|
},
|
|
147
118
|
{ immediate: !0, deep: !0 }
|
|
148
|
-
),
|
|
149
|
-
|
|
119
|
+
), x(
|
|
120
|
+
o,
|
|
150
121
|
async (e) => {
|
|
151
|
-
var
|
|
122
|
+
var a;
|
|
152
123
|
if ((e == null ? void 0 : e.length) === 2 && e[0] && e[1])
|
|
153
124
|
try {
|
|
154
|
-
(
|
|
155
|
-
const
|
|
156
|
-
|
|
125
|
+
(a = y.value) == null || a.hide();
|
|
126
|
+
const t = K(e);
|
|
127
|
+
P("update:modelValue", t), await oe(), u.value = !1;
|
|
157
128
|
} catch {
|
|
158
|
-
|
|
129
|
+
u.value = !1;
|
|
159
130
|
}
|
|
160
131
|
},
|
|
161
132
|
{ deep: !0 }
|
|
162
|
-
),
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
133
|
+
), x(j, (e) => J(e), { immediate: !0 }), (e, a) => (_(), F("div", {
|
|
134
|
+
ref_key: "wrapperRef",
|
|
135
|
+
ref: C,
|
|
136
|
+
class: "am-date-filter-wrapper"
|
|
137
|
+
}, [
|
|
138
|
+
g(i(de), { class: "h-full w-full" }, {
|
|
139
|
+
default: D(() => [
|
|
140
|
+
g(E, {
|
|
141
|
+
size: "small",
|
|
142
|
+
text: s.value !== "Customizar",
|
|
143
|
+
icon: "calendar_today",
|
|
144
|
+
style: { "border-right": "1px solid #ddd" },
|
|
145
|
+
onClick: W,
|
|
146
|
+
"data-test": "amdatefilter-toolbar-custom",
|
|
147
|
+
class: "am-v3-date-filter-custom w-32"
|
|
148
|
+
}, {
|
|
149
|
+
default: D(() => [
|
|
150
|
+
T(A(U.value), 1)
|
|
151
|
+
]),
|
|
152
|
+
_: 1
|
|
153
|
+
}, 8, ["text"]),
|
|
154
|
+
(_(!0), F(re, null, ne(R.value, (t, f) => (_(), se(E, {
|
|
155
|
+
key: t.value,
|
|
156
|
+
size: "small",
|
|
157
|
+
class: le((t.selected, "w-32")),
|
|
158
|
+
disabled: t.selected,
|
|
159
|
+
text: !t.selected,
|
|
160
|
+
severity: t.selected ? void 0 : "secondary",
|
|
161
|
+
style: ie(t.selected || R.value.length - 1 === f ? "" : "border-right: 1px solid #ddd"),
|
|
162
|
+
onClick: (w) => q(t.value),
|
|
163
|
+
"data-test": `amdatefilter-toolbar-${t.value.toLowerCase()}`
|
|
164
|
+
}, {
|
|
165
|
+
default: D(() => [
|
|
166
|
+
T(A(t.label), 1)
|
|
167
|
+
]),
|
|
168
|
+
_: 2
|
|
169
|
+
}, 1032, ["class", "disabled", "text", "severity", "style", "onClick", "data-test"]))), 128))
|
|
170
|
+
]),
|
|
171
|
+
_: 1
|
|
172
|
+
}),
|
|
173
|
+
g(i(ce), {
|
|
169
174
|
"data-test": "amdatefilter-popover",
|
|
170
175
|
ref_key: "popover",
|
|
171
|
-
ref:
|
|
176
|
+
ref: y,
|
|
172
177
|
"pt:content": "!p-0"
|
|
173
178
|
}, {
|
|
174
|
-
default:
|
|
175
|
-
|
|
179
|
+
default: D(() => [
|
|
180
|
+
g(i(ue), {
|
|
176
181
|
"data-test": "amdatefilter-datepicker",
|
|
177
|
-
modelValue:
|
|
178
|
-
"onUpdate:modelValue":
|
|
182
|
+
modelValue: o.value,
|
|
183
|
+
"onUpdate:modelValue": a[0] || (a[0] = (t) => o.value = t),
|
|
179
184
|
selectionMode: "range",
|
|
180
185
|
inline: "",
|
|
181
186
|
dateFormat: "yyyy-mm-dd",
|
|
182
|
-
minDate:
|
|
183
|
-
maxDate:
|
|
187
|
+
minDate: i(L),
|
|
188
|
+
maxDate: i(I),
|
|
184
189
|
"pt:dayCell": "!p-0",
|
|
185
190
|
"pt:tableHeaderCell": "!p-0",
|
|
186
191
|
"pt:panel": "!p-0 !border-none",
|
|
@@ -189,9 +194,9 @@ const W = /* @__PURE__ */ V({
|
|
|
189
194
|
]),
|
|
190
195
|
_: 1
|
|
191
196
|
}, 512)
|
|
192
|
-
]));
|
|
197
|
+
], 512));
|
|
193
198
|
}
|
|
194
|
-
}),
|
|
199
|
+
}), he = /* @__PURE__ */ me(fe, [["__scopeId", "data-v-368d1bb6"]]);
|
|
195
200
|
export {
|
|
196
|
-
|
|
201
|
+
he as default
|
|
197
202
|
};
|