@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.
@@ -12,6 +12,7 @@ export interface AmDateFilterProps extends AllowedComponentProps {
12
12
  maxDate?: Date | null;
13
13
  disabled?: boolean;
14
14
  card?: boolean;
15
+ timeZone?: string;
15
16
  }
16
17
 
17
18
  export interface AmDateFilterEmits {
@@ -1,12 +1,12 @@
1
- import { defineComponent as V, useAttrs as N, openBlock as g, createElementBlock as _, normalizeClass as S, unref as i, createBlock as M, createCommentVNode as L, withCtx as $, createTextVNode as W, toDisplayString as X, mergeModels as E, useModel as Z, ref as y, Fragment as j, createVNode as T, toRefs as ee, computed as B, watch as x, nextTick as te, renderList as ae } from "vue";
2
- import { _ as oe } from "../AmText.vue_vue_type_script_setup_true_lang-ZUjjXA8M.js";
3
- import { _ as le } from "../AmIcon.vue_vue_type_script_setup_true_lang-DWxib5iw.js";
4
- import { cva as I } from "class-variance-authority";
5
- import { twMerge as P } from "tailwind-merge";
6
- import { _ as re } from "../_plugin-vue_export-helper-CHgC5LLL.js";
7
- import se from "primevue/popover";
8
- import ne from "primevue/datepicker";
9
- const ie = I(
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
- ), de = I(
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
- ), ue = (e, t) => P(ie(e), t), ce = (e, t) => P(de(e), t), me = ["disabled", "data-test"], fe = /* @__PURE__ */ V({
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 t = N();
62
- return (o, d) => (g(), _("button", {
61
+ const a = H();
62
+ return (t, n) => (g(), F("button", {
63
63
  type: "button",
64
- class: S([i(ce)({ selected: o.selected, disabled: o.disabled, isCustom: o.isCustom }, i(t).class), { "am-date-filter-button--custom": o.isCustom }]),
65
- disabled: o.disabled,
66
- "data-test": o.dataTest,
67
- onClick: d[0] || (d[0] = (f) => o.$emit("click", f))
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
- o.icon ? (g(), M(le, {
69
+ t.icon ? (g(), L(ie, {
70
70
  key: 0,
71
- icon: o.icon,
71
+ icon: t.icon,
72
72
  size: "sm"
73
- }, null, 8, ["icon"])) : L("", !0),
74
- o.label ? (g(), M(oe, {
73
+ }, null, 8, ["icon"])) : P("", !0),
74
+ t.label ? (g(), L(ne, {
75
75
  key: 1,
76
76
  as: "span",
77
- class: S(o.hideLabel ? "am-date-filter-label--responsive" : "")
77
+ class: V(t.hideLabel ? "am-date-filter-label--responsive" : "")
78
78
  }, {
79
- default: $(() => [
80
- W(X(o.label), 1)
79
+ default: Y(() => [
80
+ te(ae(t.label), 1)
81
81
  ]),
82
82
  _: 1
83
- }, 8, ["class"])) : L("", !0)
84
- ], 10, me));
83
+ }, 8, ["class"])) : P("", !0)
84
+ ], 10, be));
85
85
  }
86
- }), H = /* @__PURE__ */ re(fe, [["__scopeId", "data-v-e2a79444"]]), pe = /* @__PURE__ */ V({
86
+ }), J = /* @__PURE__ */ de(ve, [["__scopeId", "data-v-e2a79444"]]), De = /* @__PURE__ */ R({
87
87
  __name: "AmDateFilterPicker",
88
- props: /* @__PURE__ */ E({
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__ */ E(["click"], ["update:date"]),
98
- setup(e, { expose: t, emit: o }) {
99
- const d = Z(e, "date"), f = o, u = y(), b = (r) => {
100
- var n;
101
- (n = u.value) == null || n.toggle(r), f("click", r);
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 t({ popover: u }), (r, n) => (g(), _(j, null, [
104
- T(H, {
105
- selected: r.selected,
106
- disabled: r.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: b
112
+ onClick: p
113
113
  }, null, 8, ["selected", "disabled"]),
114
- T(i(se), {
114
+ _(d(ue), {
115
115
  "data-test": "amdatefilter-popover",
116
116
  ref_key: "popover",
117
- ref: u,
117
+ ref: c,
118
118
  "pt:content": "!p-0"
119
119
  }, {
120
- default: $(() => [
121
- T(i(ne), {
120
+ default: Y(() => [
121
+ _(d(ce), {
122
122
  "data-test": "amdatefilter-datepicker",
123
- modelValue: d.value,
124
- "onUpdate:modelValue": n[0] || (n[0] = (c) => d.value = c),
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: r.minDate,
129
- maxDate: r.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 e = /* @__PURE__ */ new Date();
142
- return new Date(Date.UTC(e.getFullYear(), e.getMonth(), e.getDate()));
143
- }, C = (e) => {
144
- const t = v(), o = new Date(t);
145
- return o.setUTCDate(t.getUTCDate() + e), o;
146
- }, z = (e) => new Date(Date.UTC(e.getUTCFullYear(), e.getUTCMonth(), e.getUTCDate())), w = (e, t) => e.getUTCFullYear() === t.getUTCFullYear() && e.getUTCMonth() === t.getUTCMonth() && e.getUTCDate() === t.getUTCDate(), ge = (e) => {
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 [t, o] = e;
150
- if (!t || !o)
155
+ const [a, t] = e;
156
+ if (!a || !t)
151
157
  throw new Error("Datas não podem ser nulas");
152
- return [z(t).toISOString(), z(o).toISOString()];
153
- }, be = {
154
- Hoje: () => [v(), v()],
155
- Ontem: () => [C(-1), C(-1)],
156
- "7D": () => [C(-6), v()],
157
- "14D": () => [C(-13), v()],
158
- "30D": () => [C(-29), v()],
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
- }, De = {
166
+ }), Ce = {
161
167
  0: "Hoje",
162
168
  1: "Ontem",
163
169
  7: "7D",
164
170
  14: "14D",
165
171
  30: "30D"
166
- }, ve = (e) => {
172
+ }, U = (e) => {
167
173
  if (!(!e || e.length === 0))
168
- return e.map((t) => t instanceof Date ? z(t).toISOString() : String(t));
169
- }, Ce = (e, t, o) => {
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 [d, f] = e, u = new Date(d), b = new Date(f);
174
- if (isNaN(u.getTime()) || isNaN(b.getTime()))
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 r of t) {
177
- if (r === "Customizar") continue;
178
- const n = o[r];
179
- if (!n) continue;
180
- const c = n();
181
- if (!c || !Array.isArray(c) || c.length !== 2) continue;
182
- const [F, p] = c;
183
- if (w(u, F) && w(b, p))
184
- return r;
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", Be = /* @__PURE__ */ V({
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: t }) {
204
- const o = e, {
205
- defaultSelected: d,
206
- minDate: f,
207
- maxDate: u,
208
- modelValue: b,
209
- dateRangeConfigs: r,
210
- disabled: n,
211
- card: c
212
- } = ee(o), F = t, p = y(k), A = y(), m = y(null), h = y(!1), Y = N(), O = B(() => !r.value || Object.keys(r.value).length === 0 ? ["Hoje", "Ontem", "7D", "14D", "30D"] : Object.keys(r.value)), G = B(
213
- () => O.value.map((a) => ({
214
- label: a,
215
- value: a,
216
- selected: p.value === a
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
- ), R = B(() => ({
219
- ...be,
220
- ...r.value
221
- })), U = (a) => {
222
- p.value = a;
223
- const l = R.value[a];
224
- if (l) {
225
- const s = l();
226
- s && (h.value = !0, m.value = s);
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
- }, q = (a) => {
229
- if (h.value) return;
230
- const l = ve(a), s = Ce(
231
- l,
232
- O.value,
233
- R.value
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 (p.value !== s && (p.value = s), l && l.length === 2)
243
+ if (D.value !== l && (D.value = l), r && r.length === 2)
236
244
  try {
237
- const D = [
238
- new Date(l[0]),
239
- new Date(l[1])
245
+ const b = [
246
+ S(r[0]),
247
+ S(r[1])
240
248
  ];
241
- (!m.value || !w(m.value[0], D[0]) || !w(m.value[1], D[1])) && (m.value = D);
242
- } catch (D) {
243
- console.warn("Erro ao sincronizar datas do modelValue:", D);
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
- }, J = () => {
246
- U(k);
247
- }, K = (a) => {
248
- U(a);
249
- }, Q = (a) => {
250
- const l = a !== void 0 ? De[a] : k;
251
- l && U(l);
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 x(b, (a) => q(a), {
263
+ return A(p, (o) => W(o), {
254
264
  immediate: !0,
255
265
  deep: !0
256
- }), x(
257
- m,
258
- async (a) => {
259
- var l, s;
260
- if ((a == null ? void 0 : a.length) === 2 && a[0] && a[1])
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
- (s = (l = A.value) == null ? void 0 : l.popover) == null || s.hide(), F("update:modelValue", ge(a)), await te(), h.value = !1;
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
- h.value = !1;
274
+ C.value = !1;
265
275
  }
266
276
  },
267
277
  { deep: !0 }
268
- ), x(d, (a) => Q(a), { immediate: !0 }), (a, l) => (g(), _("div", {
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: S(i(ue)({ card: i(c), disabled: i(n) }, i(Y).class))
281
+ class: V(d(pe)({ card: d(m), disabled: d(i) }, d(K).class))
272
282
  }, [
273
- T(pe, {
283
+ _(De, {
274
284
  ref_key: "pickerRef",
275
- ref: A,
276
- date: m.value,
277
- "onUpdate:date": l[0] || (l[0] = (s) => m.value = s),
278
- selected: p.value === k,
279
- disabled: i(n),
280
- "min-date": i(f),
281
- "max-date": i(u),
282
- onClick: J
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), _(j, null, ae(G.value, (s) => (g(), M(H, {
285
- key: s.value,
286
- selected: s.selected,
287
- disabled: i(n),
288
- "data-test": `amdatefilter-toolbar-${s.value.toLowerCase()}`,
289
- label: s.label,
290
- onClick: (D) => K(s.value)
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
- Be as default
306
+ Ae as default
297
307
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@appmax_npm/ds-prime",
3
- "version": "1.0.0-alpha.174",
3
+ "version": "1.0.0-alpha.176",
4
4
  "description": "Design System da Appmax baseado no Primevue",
5
5
  "author": "Appmax",
6
6
  "exports": {