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