@appmax_npm/ds-prime 1.0.0-alpha.175 → 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.d.ts +1 -0
- package/amdatefilter/index.js +150 -145
- 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 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
|
+
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 de = P(
|
|
|
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 de = P(
|
|
|
44
44
|
}
|
|
45
45
|
}
|
|
46
46
|
}
|
|
47
|
-
),
|
|
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: {
|
|
@@ -58,34 +58,34 @@ const de = P(
|
|
|
58
58
|
},
|
|
59
59
|
emits: ["click"],
|
|
60
60
|
setup(e) {
|
|
61
|
-
const
|
|
62
|
-
return (
|
|
61
|
+
const a = H();
|
|
62
|
+
return (t, n) => (b(), w("button", {
|
|
63
63
|
type: "button",
|
|
64
|
-
class:
|
|
65
|
-
disabled:
|
|
66
|
-
"data-test":
|
|
67
|
-
onClick:
|
|
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
|
+
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 ? (b(), T(ie, {
|
|
70
70
|
key: 0,
|
|
71
|
-
icon:
|
|
71
|
+
icon: t.icon,
|
|
72
72
|
size: "sm"
|
|
73
|
-
}, null, 8, ["icon"])) :
|
|
74
|
-
|
|
73
|
+
}, null, 8, ["icon"])) : $("", !0),
|
|
74
|
+
t.label ? (b(), T(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: I(() => [
|
|
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
|
-
}),
|
|
86
|
+
}), J = /* @__PURE__ */ de(ge, [["__scopeId", "data-v-e2a79444"]]), De = /* @__PURE__ */ E({
|
|
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,16 +94,16 @@ const de = P(
|
|
|
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 = le(e, "date"), u = t, c = k(), 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) => (b(), w(Y, null, [
|
|
104
|
+
B(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",
|
|
@@ -111,22 +111,22 @@ const de = P(
|
|
|
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
|
-
ref:
|
|
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
|
-
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,60 @@ const de = P(
|
|
|
137
137
|
}, 512)
|
|
138
138
|
], 64));
|
|
139
139
|
}
|
|
140
|
-
}),
|
|
141
|
-
const
|
|
142
|
-
return new Date(
|
|
143
|
-
}, C = (e) => {
|
|
144
|
-
const t =
|
|
145
|
-
return
|
|
146
|
-
},
|
|
140
|
+
}), v = "America/Sao_Paulo", y = (e = v) => {
|
|
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
|
+
}, C = (e, a = v) => {
|
|
144
|
+
const t = y(a);
|
|
145
|
+
return t.setDate(t.getDate() + e), t;
|
|
146
|
+
}, R = (e, a = v) => e.toLocaleDateString("en-CA", { timeZone: a }), x = (e) => {
|
|
147
|
+
const a = e.split("T")[0], [t, n, u] = a.split("-").map(Number);
|
|
148
|
+
return new Date(t, n - 1, u);
|
|
149
|
+
}, z = (e, a) => e.getFullYear() === a.getFullYear() && e.getMonth() === a.getMonth() && e.getDate() === a.getDate(), ye = (e, a = v) => {
|
|
147
150
|
if (!Array.isArray(e) || e.length !== 2)
|
|
148
151
|
throw new Error("Range de datas inválido");
|
|
149
|
-
const [t,
|
|
150
|
-
if (!t || !
|
|
152
|
+
const [t, n] = e;
|
|
153
|
+
if (!t || !n)
|
|
151
154
|
throw new Error("Datas não podem ser nulas");
|
|
152
|
-
return [
|
|
153
|
-
},
|
|
154
|
-
Hoje: () => [
|
|
155
|
-
Ontem: () => [C(-1), C(-1)],
|
|
156
|
-
"7D": () => [C(-6),
|
|
157
|
-
"14D": () => [C(-13),
|
|
158
|
-
"30D": () => [C(-29),
|
|
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)],
|
|
159
162
|
Customizar: () => null
|
|
160
|
-
},
|
|
163
|
+
}), Ce = {
|
|
161
164
|
0: "Hoje",
|
|
162
165
|
1: "Ontem",
|
|
163
166
|
7: "7D",
|
|
164
167
|
14: "14D",
|
|
165
168
|
30: "30D"
|
|
166
|
-
},
|
|
169
|
+
}, U = (e, a = v) => {
|
|
167
170
|
if (!(!e || e.length === 0))
|
|
168
|
-
return e.map((t) => t instanceof Date ?
|
|
169
|
-
},
|
|
171
|
+
return e.map((t) => t instanceof Date ? R(t, a) : String(t));
|
|
172
|
+
}, ke = (e, a, t) => {
|
|
170
173
|
if (!e || e.length !== 2)
|
|
171
174
|
return "Customizar";
|
|
172
175
|
try {
|
|
173
|
-
const [
|
|
174
|
-
if (isNaN(
|
|
176
|
+
const [n, u] = e, c = x(n), p = x(u);
|
|
177
|
+
if (isNaN(c.getTime()) || isNaN(p.getTime()))
|
|
175
178
|
return "Customizar";
|
|
176
|
-
for (const
|
|
177
|
-
if (
|
|
178
|
-
const
|
|
179
|
-
if (!
|
|
180
|
-
const
|
|
181
|
-
if (!
|
|
182
|
-
const [
|
|
183
|
-
if (
|
|
184
|
-
return
|
|
179
|
+
for (const s of a) {
|
|
180
|
+
if (s === "Customizar") continue;
|
|
181
|
+
const i = t[s];
|
|
182
|
+
if (!i) continue;
|
|
183
|
+
const m = i();
|
|
184
|
+
if (!m || !Array.isArray(m) || m.length !== 2) continue;
|
|
185
|
+
const [g, A] = m;
|
|
186
|
+
if (z(c, g) && z(p, A))
|
|
187
|
+
return s;
|
|
185
188
|
}
|
|
186
189
|
return "Customizar";
|
|
187
190
|
} catch {
|
|
188
191
|
return "Customizar";
|
|
189
192
|
}
|
|
190
|
-
},
|
|
193
|
+
}, F = "Customizar", Se = /* @__PURE__ */ E({
|
|
191
194
|
inheritAttrs: !1,
|
|
192
195
|
__name: "AmDateFilter",
|
|
193
196
|
props: {
|
|
@@ -197,103 +200,105 @@ const de = P(
|
|
|
197
200
|
maxDate: {},
|
|
198
201
|
dateRangeConfigs: { default: () => ({}) },
|
|
199
202
|
disabled: { type: Boolean },
|
|
200
|
-
card: { type: Boolean }
|
|
203
|
+
card: { type: Boolean },
|
|
204
|
+
timeZone: { default: v }
|
|
201
205
|
},
|
|
202
206
|
emits: ["update:modelValue"],
|
|
203
|
-
setup(e, { emit:
|
|
204
|
-
const
|
|
205
|
-
defaultSelected:
|
|
206
|
-
minDate:
|
|
207
|
-
maxDate:
|
|
207
|
+
setup(e, { emit: a }) {
|
|
208
|
+
const t = e, {
|
|
209
|
+
defaultSelected: n,
|
|
210
|
+
minDate: u,
|
|
211
|
+
maxDate: c,
|
|
208
212
|
modelValue: p,
|
|
209
|
-
dateRangeConfigs:
|
|
210
|
-
disabled:
|
|
211
|
-
card:
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
213
|
+
dateRangeConfigs: s,
|
|
214
|
+
disabled: i,
|
|
215
|
+
card: m,
|
|
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
|
|
217
222
|
}))
|
|
218
|
-
),
|
|
219
|
-
...
|
|
220
|
-
...
|
|
221
|
-
})),
|
|
222
|
-
|
|
223
|
-
const r =
|
|
223
|
+
), P = S(() => ({
|
|
224
|
+
...he(g.value),
|
|
225
|
+
...s.value
|
|
226
|
+
})), M = (l) => {
|
|
227
|
+
h.value = l;
|
|
228
|
+
const r = P.value[l];
|
|
224
229
|
if (r) {
|
|
225
|
-
const
|
|
226
|
-
|
|
230
|
+
const o = r();
|
|
231
|
+
o && (_.value = !0, f.value = o);
|
|
227
232
|
}
|
|
228
|
-
},
|
|
229
|
-
if (
|
|
230
|
-
const r =
|
|
233
|
+
}, W = (l) => {
|
|
234
|
+
if (_.value) return;
|
|
235
|
+
const r = U(l, g.value), o = ke(
|
|
231
236
|
r,
|
|
232
237
|
O.value,
|
|
233
|
-
|
|
238
|
+
P.value
|
|
234
239
|
);
|
|
235
|
-
if (
|
|
240
|
+
if (h.value !== o && (h.value = o), r && r.length === 2)
|
|
236
241
|
try {
|
|
237
|
-
const
|
|
238
|
-
|
|
239
|
-
|
|
242
|
+
const D = [
|
|
243
|
+
x(r[0]),
|
|
244
|
+
x(r[1])
|
|
240
245
|
];
|
|
241
|
-
(!
|
|
242
|
-
} catch (
|
|
243
|
-
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);
|
|
244
249
|
}
|
|
245
|
-
},
|
|
246
|
-
|
|
247
|
-
},
|
|
248
|
-
|
|
249
|
-
},
|
|
250
|
-
const r =
|
|
250
|
+
}, X = () => {
|
|
251
|
+
M(F);
|
|
252
|
+
}, Z = (l) => {
|
|
253
|
+
M(l);
|
|
254
|
+
}, ee = (l) => {
|
|
255
|
+
const r = U(p.value, g.value);
|
|
251
256
|
if (r && r.length === 2) return;
|
|
252
|
-
const
|
|
253
|
-
|
|
257
|
+
const o = l !== void 0 ? Ce[l] : F;
|
|
258
|
+
o && M(o);
|
|
254
259
|
};
|
|
255
|
-
return
|
|
260
|
+
return L(p, (l) => W(l), {
|
|
256
261
|
immediate: !0,
|
|
257
262
|
deep: !0
|
|
258
|
-
}),
|
|
259
|
-
|
|
260
|
-
async (
|
|
261
|
-
var r,
|
|
262
|
-
if ((
|
|
263
|
+
}), L(
|
|
264
|
+
f,
|
|
265
|
+
async (l) => {
|
|
266
|
+
var r, o;
|
|
267
|
+
if ((l == null ? void 0 : l.length) === 2 && l[0] && l[1])
|
|
263
268
|
try {
|
|
264
|
-
(
|
|
269
|
+
(o = (r = N.value) == null ? void 0 : r.popover) == null || o.hide(), A("update:modelValue", ye(l, g.value)), await re(), _.value = !1;
|
|
265
270
|
} catch {
|
|
266
|
-
|
|
271
|
+
_.value = !1;
|
|
267
272
|
}
|
|
268
273
|
},
|
|
269
274
|
{ deep: !0 }
|
|
270
|
-
),
|
|
275
|
+
), L(n, (l) => ee(l), { immediate: !0 }), (l, r) => (b(), w("div", {
|
|
271
276
|
role: "group",
|
|
272
277
|
"aria-label": "Filtro de período",
|
|
273
|
-
class:
|
|
278
|
+
class: V(d(pe)({ card: d(m), disabled: d(i) }, d(K).class))
|
|
274
279
|
}, [
|
|
275
|
-
|
|
280
|
+
B(De, {
|
|
276
281
|
ref_key: "pickerRef",
|
|
277
|
-
ref:
|
|
278
|
-
date:
|
|
279
|
-
"onUpdate:date": r[0] || (r[0] = (
|
|
280
|
-
selected:
|
|
281
|
-
disabled: i
|
|
282
|
-
"min-date":
|
|
283
|
-
"max-date":
|
|
284
|
-
onClick:
|
|
282
|
+
ref: N,
|
|
283
|
+
date: f.value,
|
|
284
|
+
"onUpdate:date": r[0] || (r[0] = (o) => f.value = o),
|
|
285
|
+
selected: h.value === F,
|
|
286
|
+
disabled: d(i),
|
|
287
|
+
"min-date": d(u) || void 0,
|
|
288
|
+
"max-date": d(c) || void 0,
|
|
289
|
+
onClick: X
|
|
285
290
|
}, null, 8, ["date", "selected", "disabled", "min-date", "max-date"]),
|
|
286
|
-
(b(!0),
|
|
287
|
-
key:
|
|
288
|
-
selected:
|
|
289
|
-
disabled: i
|
|
290
|
-
"data-test": `amdatefilter-toolbar-${
|
|
291
|
-
label:
|
|
292
|
-
onClick: (
|
|
291
|
+
(b(!0), w(Y, null, se(Q.value, (o) => (b(), T(J, {
|
|
292
|
+
key: o.value,
|
|
293
|
+
selected: o.selected,
|
|
294
|
+
disabled: d(i),
|
|
295
|
+
"data-test": `amdatefilter-toolbar-${o.value.toLowerCase()}`,
|
|
296
|
+
label: o.label,
|
|
297
|
+
onClick: (D) => Z(o.value)
|
|
293
298
|
}, null, 8, ["selected", "disabled", "data-test", "label", "onClick"]))), 128))
|
|
294
299
|
], 2));
|
|
295
300
|
}
|
|
296
301
|
});
|
|
297
302
|
export {
|
|
298
|
-
|
|
303
|
+
Se as default
|
|
299
304
|
};
|