@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.
@@ -1,186 +1,191 @@
1
- import { defineComponent as V, toRefs as B, ref as p, computed as v, watch as g, nextTick as R, openBlock as U, createElementBlock as Y, createVNode as y, unref as u, withCtx as q } from "vue";
2
- import G from "primevue/menu";
3
- import J from "primevue/popover";
4
- import K from "primevue/datepicker";
5
- import { _ as Q } from "../_plugin-vue_export-helper-CHgC5LLL.js";
6
- const W = /* @__PURE__ */ V({
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
- class: {},
14
- style: {}
14
+ dateRangeConfigs: { default: () => ({}) }
15
15
  },
16
16
  emits: ["update:modelValue"],
17
- setup(b, { emit: x }) {
18
- const z = b, { defaultSelected: w, minDate: E, maxDate: _, modelValue: F } = B(z), O = x, d = p("Customizar"), D = p(), n = p(null), f = p(!1), S = v(() => ({
19
- root: {
20
- class: "!min-w-0 am-date-filter"
21
- },
22
- list: {
23
- class: "!flex-row !p-0"
24
- },
25
- item: {
26
- class: "w-full"
27
- },
28
- itemLink: {
29
- class: "!px-[7px] !py-[5px] hover:bg-[#EBE1FE] !text-[#858585] !text-sm !min-h-[34px] justify-center"
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
- }, r = (e) => {
38
- const t = s(), a = new Date(t);
39
- return a.setDate(t.getDate() + e), a;
40
- }, h = (e) => {
41
- const t = new Date(e);
42
- return t.setHours(0, 0, 0, 0), t;
43
- }, o = (e, t) => e.getFullYear() === t.getFullYear() && e.getMonth() === t.getMonth() && e.getDate() === t.getDate(), H = (e) => {
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 [t, a] = e, i = h(new Date(t)), c = h(new Date(a));
48
- if (isNaN(i.getTime()) || isNaN(c.getTime()))
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
- const m = s(), C = r(-1), N = r(-6), P = r(-13), T = r(-29);
51
- return o(i, m) && o(c, m) ? "Hoje" : o(i, C) && o(c, C) ? "Ontem" : o(i, N) && o(c, m) ? "7D" : o(i, P) && o(c, m) ? "14D" : o(i, T) && o(c, m) ? "30D" : "Customizar";
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
- }, k = v(() => ({
56
- Hoje: () => [s(), s()],
57
- Ontem: () => [r(-1), r(-1)],
58
- "7D": () => [r(-6), s()],
59
- "14D": () => [r(-13), s()],
60
- "30D": () => [r(-29), s()],
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
- })), l = (e) => {
63
- d.value = e;
64
- const t = k.value[e];
65
- if (t) {
66
- const a = t();
67
- a && (f.value = !0, n.value = a);
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
- }, j = (e) => {
70
- if (f.value)
77
+ }, G = (e) => {
78
+ if (u.value)
71
79
  return;
72
- const t = H(e);
73
- if (d.value !== t && (d.value = t), e && e.length === 2)
80
+ const a = Y(e);
81
+ if (s.value !== a && (s.value = a), e && e.length === 2)
74
82
  try {
75
- const a = [
83
+ const t = [
76
84
  new Date(e[0]),
77
85
  new Date(e[1])
78
86
  ];
79
- (!n.value || !o(n.value[0], a[0]) || !o(n.value[1], a[1])) && (n.value = a);
80
- } catch (a) {
81
- console.warn("Erro ao sincronizar datas do modelValue:", a);
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
- }, A = (e) => {
84
- var t;
85
- (t = D.value) == null || t.toggle(e), l("Customizar");
86
- }, I = v(() => {
87
- const e = d.value, t = (a) => e === a ? "bg-[#EBE1FE]" : "";
88
- return [
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
- a && l(a);
134
- }, M = (e) => {
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 [t, a] = e;
138
- if (!t || !a)
108
+ const [a, t] = e;
109
+ if (!a || !t)
139
110
  throw new Error("Datas não podem ser nulas");
140
- return [t.toISOString(), a.toISOString()];
111
+ return [a.toISOString(), t.toISOString()];
141
112
  };
142
- return g(
143
- F,
113
+ return x(
114
+ M,
144
115
  (e) => {
145
- j(e);
116
+ G(e);
146
117
  },
147
118
  { immediate: !0, deep: !0 }
148
- ), g(
149
- n,
119
+ ), x(
120
+ o,
150
121
  async (e) => {
151
- var t;
122
+ var a;
152
123
  if ((e == null ? void 0 : e.length) === 2 && e[0] && e[1])
153
124
  try {
154
- (t = D.value) == null || t.hide();
155
- const a = M(e);
156
- O("update:modelValue", a), await R(), f.value = !1;
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
- f.value = !1;
129
+ u.value = !1;
159
130
  }
160
131
  },
161
132
  { deep: !0 }
162
- ), g(w, (e) => L(e), { immediate: !0 }), (e, t) => (U(), Y("div", null, [
163
- y(u(G), {
164
- "data-test": "amdatefilter-toolbar",
165
- model: I.value,
166
- pt: S.value
167
- }, null, 8, ["model", "pt"]),
168
- y(u(J), {
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: D,
176
+ ref: y,
172
177
  "pt:content": "!p-0"
173
178
  }, {
174
- default: q(() => [
175
- y(u(K), {
179
+ default: D(() => [
180
+ g(i(ue), {
176
181
  "data-test": "amdatefilter-datepicker",
177
- modelValue: n.value,
178
- "onUpdate:modelValue": t[0] || (t[0] = (a) => n.value = a),
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: u(E),
183
- maxDate: u(_),
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
- }), ae = /* @__PURE__ */ Q(W, [["__scopeId", "data-v-5f5e9eaf"]]);
199
+ }), he = /* @__PURE__ */ me(fe, [["__scopeId", "data-v-368d1bb6"]]);
195
200
  export {
196
- ae as default
201
+ he as default
197
202
  };