@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.
@@ -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 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
- ), 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), 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 t = $();
62
- return (o, d) => (b(), _("button", {
61
+ const a = H();
62
+ return (t, n) => (b(), w("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(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
- o.icon ? (b(), z(re, {
69
+ t.icon ? (b(), T(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"])) : $("", !0),
74
+ t.label ? (b(), T(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: I(() => [
80
+ te(ae(t.label), 1)
81
81
  ]),
82
82
  _: 1
83
- }, 8, ["class"])) : L("", !0)
84
- ], 10, fe));
83
+ }, 8, ["class"])) : $("", !0)
84
+ ], 10, ve));
85
85
  }
86
- }), Y = /* @__PURE__ */ ne(pe, [["__scopeId", "data-v-e2a79444"]]), ge = /* @__PURE__ */ V({
86
+ }), J = /* @__PURE__ */ de(ge, [["__scopeId", "data-v-e2a79444"]]), De = /* @__PURE__ */ E({
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 = 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 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) => (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
- T(i(se), {
114
+ B(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: I(() => [
121
+ B(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,60 @@ 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
+ }), 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, o] = e;
150
- if (!t || !o)
152
+ const [t, n] = e;
153
+ if (!t || !n)
151
154
  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()],
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
- }, De = {
163
+ }), Ce = {
161
164
  0: "Hoje",
162
165
  1: "Ontem",
163
166
  7: "7D",
164
167
  14: "14D",
165
168
  30: "30D"
166
- }, N = (e) => {
169
+ }, U = (e, a = v) => {
167
170
  if (!(!e || e.length === 0))
168
- return e.map((t) => t instanceof Date ? M(t).toISOString() : String(t));
169
- }, Ce = (e, t, o) => {
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 [d, f] = e, u = new Date(d), p = new Date(f);
174
- if (isNaN(u.getTime()) || isNaN(p.getTime()))
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 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;
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
- }, k = "Customizar", Be = /* @__PURE__ */ V({
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: t }) {
204
- const o = e, {
205
- defaultSelected: d,
206
- minDate: f,
207
- maxDate: u,
207
+ setup(e, { emit: a }) {
208
+ const t = e, {
209
+ defaultSelected: n,
210
+ minDate: u,
211
+ maxDate: c,
208
212
  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
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
- ), R = B(() => ({
219
- ...ve,
220
- ...n.value
221
- })), U = (a) => {
222
- g.value = a;
223
- const r = R.value[a];
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 l = r();
226
- l && (y.value = !0, m.value = l);
230
+ const o = r();
231
+ o && (_.value = !0, f.value = o);
227
232
  }
228
- }, J = (a) => {
229
- if (y.value) return;
230
- const r = N(a), l = Ce(
233
+ }, W = (l) => {
234
+ if (_.value) return;
235
+ const r = U(l, g.value), o = ke(
231
236
  r,
232
237
  O.value,
233
- R.value
238
+ P.value
234
239
  );
235
- if (g.value !== l && (g.value = l), r && r.length === 2)
240
+ if (h.value !== o && (h.value = o), r && r.length === 2)
236
241
  try {
237
- const v = [
238
- new Date(r[0]),
239
- new Date(r[1])
242
+ const D = [
243
+ x(r[0]),
244
+ x(r[1])
240
245
  ];
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);
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
- }, K = () => {
246
- U(k);
247
- }, Q = (a) => {
248
- U(a);
249
- }, W = (a) => {
250
- const r = N(p.value);
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 l = a !== void 0 ? De[a] : k;
253
- l && U(l);
257
+ const o = l !== void 0 ? Ce[l] : F;
258
+ o && M(o);
254
259
  };
255
- return x(p, (a) => J(a), {
260
+ return L(p, (l) => W(l), {
256
261
  immediate: !0,
257
262
  deep: !0
258
- }), x(
259
- m,
260
- async (a) => {
261
- var r, l;
262
- if ((a == null ? void 0 : a.length) === 2 && a[0] && a[1])
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
- (l = (r = A.value) == null ? void 0 : r.popover) == null || l.hide(), F("update:modelValue", be(a)), await ae(), y.value = !1;
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
- y.value = !1;
271
+ _.value = !1;
267
272
  }
268
273
  },
269
274
  { deep: !0 }
270
- ), x(d, (a) => W(a), { immediate: !0 }), (a, r) => (b(), _("div", {
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: S(i(ce)({ card: i(c), disabled: i(s) }, i(G).class))
278
+ class: V(d(pe)({ card: d(m), disabled: d(i) }, d(K).class))
274
279
  }, [
275
- T(ge, {
280
+ B(De, {
276
281
  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
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), _(I, null, oe(q.value, (l) => (b(), z(Y, {
287
- key: l.value,
288
- selected: l.selected,
289
- disabled: i(s),
290
- "data-test": `amdatefilter-toolbar-${l.value.toLowerCase()}`,
291
- label: l.label,
292
- onClick: (v) => Q(l.value)
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
- Be as default
303
+ Se as default
299
304
  };
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.177",
4
4
  "description": "Design System da Appmax baseado no Primevue",
5
5
  "author": "Appmax",
6
6
  "exports": {