@appmax_npm/ds-prime 1.0.0-alpha.175 → 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 $, openBlock as b, createElementBlock as _, normalizeClass as S, unref as i, createBlock as z, createCommentVNode as L, withCtx as j, createTextVNode as X, toDisplayString as Z, mergeModels as E, useModel as ee, ref as h, Fragment as I, createVNode as T, toRefs as te, computed as B, watch as x, nextTick as ae, renderList as oe } from "vue";
2
- import { _ as le } from "../AmText.vue_vue_type_script_setup_true_lang-ZUjjXA8M.js";
3
- import { _ as re } from "../AmIcon.vue_vue_type_script_setup_true_lang-DWxib5iw.js";
4
- import { cva as P } from "class-variance-authority";
5
- import { twMerge as H } from "tailwind-merge";
6
- import { _ as ne } from "../_plugin-vue_export-helper-CHgC5LLL.js";
7
- import se from "primevue/popover";
8
- import ie from "primevue/datepicker";
9
- const de = P(
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 de = P(
20
20
  }
21
21
  }
22
22
  }
23
- ), ue = P(
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
- ), ce = (e, t) => H(de(e), t), me = (e, t) => H(ue(e), t), fe = ["disabled", "data-test"], pe = /* @__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 de = P(
58
58
  },
59
59
  emits: ["click"],
60
60
  setup(e) {
61
- const t = $();
62
- return (o, d) => (b(), _("button", {
61
+ const a = H();
62
+ return (t, n) => (g(), F("button", {
63
63
  type: "button",
64
- class: S([i(me)({ 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 ? (b(), z(re, {
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 ? (b(), z(le, {
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: j(() => [
80
- X(Z(o.label), 1)
79
+ default: Y(() => [
80
+ te(ae(t.label), 1)
81
81
  ]),
82
82
  _: 1
83
- }, 8, ["class"])) : L("", !0)
84
- ], 10, fe));
83
+ }, 8, ["class"])) : P("", !0)
84
+ ], 10, be));
85
85
  }
86
- }), Y = /* @__PURE__ */ ne(pe, [["__scopeId", "data-v-e2a79444"]]), ge = /* @__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,16 +94,16 @@ const de = P(
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 = ee(e, "date"), f = o, u = h(), p = (n) => {
100
- var s;
101
- (s = u.value) == null || s.toggle(n), f("click", n);
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 }), (n, s) => (b(), _(I, null, [
104
- T(Y, {
105
- selected: n.selected,
106
- disabled: n.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",
@@ -111,22 +111,22 @@ const de = P(
111
111
  "hide-label": "",
112
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: j(() => [
121
- T(i(ie), {
120
+ default: Y(() => [
121
+ _(d(ce), {
122
122
  "data-test": "amdatefilter-datepicker",
123
- modelValue: d.value,
124
- "onUpdate:modelValue": s[0] || (s[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: n.minDate,
129
- maxDate: n.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 de = P(
137
137
  }, 512)
138
138
  ], 64));
139
139
  }
140
- }), D = () => {
141
- const e = /* @__PURE__ */ new Date();
142
- return new Date(Date.UTC(e.getFullYear(), e.getMonth(), e.getDate()));
143
- }, C = (e) => {
144
- const t = D(), o = new Date(t);
145
- return o.setUTCDate(t.getUTCDate() + e), o;
146
- }, M = (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(), be = (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 [M(t).toISOString(), M(o).toISOString()];
153
- }, ve = {
154
- Hoje: () => [D(), D()],
155
- Ontem: () => [C(-1), C(-1)],
156
- "7D": () => [C(-6), D()],
157
- "14D": () => [C(-13), D()],
158
- "30D": () => [C(-29), D()],
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
- }, N = (e) => {
172
+ }, U = (e) => {
167
173
  if (!(!e || e.length === 0))
168
- return e.map((t) => t instanceof Date ? M(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), p = new Date(f);
174
- if (isNaN(u.getTime()) || isNaN(p.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 n of t) {
177
- if (n === "Customizar") continue;
178
- const s = o[n];
179
- if (!s) continue;
180
- const c = s();
181
- if (!c || !Array.isArray(c) || c.length !== 2) continue;
182
- const [F, g] = c;
183
- if (w(u, F) && w(p, g))
184
- return n;
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,103 +203,105 @@ const de = P(
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,
210
+ setup(e, { emit: a }) {
211
+ const t = e, {
212
+ defaultSelected: n,
213
+ minDate: u,
214
+ maxDate: c,
208
215
  modelValue: p,
209
- dateRangeConfigs: n,
210
- disabled: s,
211
- card: c
212
- } = te(o), F = t, g = h(k), A = h(), m = h(null), y = h(!1), G = $(), O = B(() => !n.value || Object.keys(n.value).length === 0 ? ["Hoje", "Ontem", "7D", "14D", "30D"] : Object.keys(n.value)), q = B(
213
- () => O.value.map((a) => ({
214
- label: a,
215
- value: a,
216
- selected: g.value === a
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
- ...ve,
220
- ...n.value
221
- })), U = (a) => {
222
- g.value = a;
223
- const r = R.value[a];
226
+ ), O = M(() => ({
227
+ ...he(w.value),
228
+ ...s.value
229
+ })), z = (o) => {
230
+ D.value = o;
231
+ const r = O.value[o];
224
232
  if (r) {
225
233
  const l = r();
226
- l && (y.value = !0, m.value = l);
234
+ l && (C.value = !0, f.value = l);
227
235
  }
228
- }, J = (a) => {
229
- if (y.value) return;
230
- const r = N(a), l = Ce(
236
+ }, W = (o) => {
237
+ if (C.value) return;
238
+ const r = U(o), l = ke(
231
239
  r,
232
- O.value,
233
- R.value
240
+ N.value,
241
+ O.value
234
242
  );
235
- if (g.value !== l && (g.value = l), r && r.length === 2)
243
+ if (D.value !== l && (D.value = l), r && r.length === 2)
236
244
  try {
237
- const v = [
238
- new Date(r[0]),
239
- new Date(r[1])
245
+ const b = [
246
+ S(r[0]),
247
+ S(r[1])
240
248
  ];
241
- (!m.value || !w(m.value[0], v[0]) || !w(m.value[1], v[1])) && (m.value = v);
242
- } catch (v) {
243
- console.warn("Erro ao sincronizar datas do modelValue:", v);
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
- }, K = () => {
246
- U(k);
247
- }, Q = (a) => {
248
- U(a);
249
- }, W = (a) => {
250
- const r = N(p.value);
253
+ }, X = () => {
254
+ z(k);
255
+ }, Z = (o) => {
256
+ z(o);
257
+ }, ee = (o) => {
258
+ const r = U(p.value);
251
259
  if (r && r.length === 2) return;
252
- const l = a !== void 0 ? De[a] : k;
253
- l && U(l);
260
+ const l = o !== void 0 ? Ce[o] : k;
261
+ l && z(l);
254
262
  };
255
- return x(p, (a) => J(a), {
263
+ return A(p, (o) => W(o), {
256
264
  immediate: !0,
257
265
  deep: !0
258
- }), x(
259
- m,
260
- async (a) => {
266
+ }), A(
267
+ f,
268
+ async (o) => {
261
269
  var r, l;
262
- if ((a == null ? void 0 : a.length) === 2 && a[0] && a[1])
270
+ if ((o == null ? void 0 : o.length) === 2 && o[0] && o[1])
263
271
  try {
264
- (l = (r = A.value) == null ? void 0 : r.popover) == null || l.hide(), F("update:modelValue", be(a)), await ae(), y.value = !1;
272
+ (l = (r = $.value) == null ? void 0 : r.popover) == null || l.hide(), x("update:modelValue", ye(o)), await re(), C.value = !1;
265
273
  } catch {
266
- y.value = !1;
274
+ C.value = !1;
267
275
  }
268
276
  },
269
277
  { deep: !0 }
270
- ), x(d, (a) => W(a), { immediate: !0 }), (a, r) => (b(), _("div", {
278
+ ), A(n, (o) => ee(o), { immediate: !0 }), (o, r) => (g(), F("div", {
271
279
  role: "group",
272
280
  "aria-label": "Filtro de período",
273
- class: S(i(ce)({ card: i(c), disabled: i(s) }, i(G).class))
281
+ class: V(d(pe)({ card: d(m), disabled: d(i) }, d(K).class))
274
282
  }, [
275
- T(ge, {
283
+ _(De, {
276
284
  ref_key: "pickerRef",
277
- ref: A,
278
- date: m.value,
279
- "onUpdate:date": r[0] || (r[0] = (l) => m.value = l),
280
- selected: g.value === k,
281
- disabled: i(s),
282
- "min-date": i(f) || void 0,
283
- "max-date": i(u) || void 0,
284
- onClick: K
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
285
293
  }, null, 8, ["date", "selected", "disabled", "min-date", "max-date"]),
286
- (b(!0), _(I, null, oe(q.value, (l) => (b(), z(Y, {
294
+ (g(!0), F(I, null, se(Q.value, (l) => (g(), L(J, {
287
295
  key: l.value,
288
296
  selected: l.selected,
289
- disabled: i(s),
297
+ disabled: d(i),
290
298
  "data-test": `amdatefilter-toolbar-${l.value.toLowerCase()}`,
291
299
  label: l.label,
292
- onClick: (v) => Q(l.value)
300
+ onClick: (b) => Z(l.value)
293
301
  }, null, 8, ["selected", "disabled", "data-test", "label", "onClick"]))), 128))
294
302
  ], 2));
295
303
  }
296
304
  });
297
305
  export {
298
- Be as default
306
+ Ae as default
299
307
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@appmax_npm/ds-prime",
3
- "version": "1.0.0-alpha.175",
3
+ "version": "1.0.0-alpha.176",
4
4
  "description": "Design System da Appmax baseado no Primevue",
5
5
  "author": "Appmax",
6
6
  "exports": {