@appmax_npm/ds-prime 1.0.0-alpha.174 → 1.0.0-alpha.175

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.
Files changed (2) hide show
  1. package/amdatefilter/index.js +101 -99
  2. package/package.json +1 -1
@@ -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";
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
7
  import se from "primevue/popover";
8
- import ne from "primevue/datepicker";
9
- const ie = I(
8
+ import ie from "primevue/datepicker";
9
+ const de = P(
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
+ ), ue = P(
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
+ ), ce = (e, t) => H(de(e), t), me = (e, t) => H(ue(e), t), fe = ["disabled", "data-test"], pe = /* @__PURE__ */ V({
48
48
  inheritAttrs: !1,
49
49
  __name: "AmDateFilterButton",
50
50
  props: {
@@ -58,32 +58,32 @@ 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 t = $();
62
+ return (o, d) => (b(), _("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 }]),
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
65
  disabled: o.disabled,
66
66
  "data-test": o.dataTest,
67
67
  onClick: d[0] || (d[0] = (f) => o.$emit("click", f))
68
68
  }, [
69
- o.icon ? (g(), M(le, {
69
+ o.icon ? (b(), z(re, {
70
70
  key: 0,
71
71
  icon: o.icon,
72
72
  size: "sm"
73
73
  }, null, 8, ["icon"])) : L("", !0),
74
- o.label ? (g(), M(oe, {
74
+ o.label ? (b(), z(le, {
75
75
  key: 1,
76
76
  as: "span",
77
77
  class: S(o.hideLabel ? "am-date-filter-label--responsive" : "")
78
78
  }, {
79
- default: $(() => [
80
- W(X(o.label), 1)
79
+ default: j(() => [
80
+ X(Z(o.label), 1)
81
81
  ]),
82
82
  _: 1
83
83
  }, 8, ["class"])) : L("", !0)
84
- ], 10, me));
84
+ ], 10, fe));
85
85
  }
86
- }), H = /* @__PURE__ */ re(fe, [["__scopeId", "data-v-e2a79444"]]), pe = /* @__PURE__ */ V({
86
+ }), Y = /* @__PURE__ */ ne(pe, [["__scopeId", "data-v-e2a79444"]]), ge = /* @__PURE__ */ V({
87
87
  __name: "AmDateFilterPicker",
88
88
  props: /* @__PURE__ */ E({
89
89
  selected: { type: Boolean, default: !1 },
@@ -96,20 +96,20 @@ const ie = I(
96
96
  }),
97
97
  emits: /* @__PURE__ */ E(["click"], ["update:date"]),
98
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);
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);
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 t({ popover: u }), (n, s) => (b(), _(I, null, [
104
+ T(Y, {
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: b
112
+ onClick: p
113
113
  }, null, 8, ["selected", "disabled"]),
114
114
  T(i(se), {
115
115
  "data-test": "amdatefilter-popover",
@@ -117,16 +117,16 @@ const ie = I(
117
117
  ref: u,
118
118
  "pt:content": "!p-0"
119
119
  }, {
120
- default: $(() => [
121
- T(i(ne), {
120
+ default: j(() => [
121
+ T(i(ie), {
122
122
  "data-test": "amdatefilter-datepicker",
123
123
  modelValue: d.value,
124
- "onUpdate:modelValue": n[0] || (n[0] = (c) => d.value = c),
124
+ "onUpdate:modelValue": s[0] || (s[0] = (c) => d.value = c),
125
125
  selectionMode: "range",
126
126
  inline: "",
127
127
  dateFormat: "yyyy-mm-dd",
128
- minDate: r.minDate,
129
- maxDate: r.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,25 +137,25 @@ const ie = I(
137
137
  }, 512)
138
138
  ], 64));
139
139
  }
140
- }), v = () => {
140
+ }), D = () => {
141
141
  const e = /* @__PURE__ */ new Date();
142
142
  return new Date(Date.UTC(e.getFullYear(), e.getMonth(), e.getDate()));
143
143
  }, C = (e) => {
144
- const t = v(), o = new Date(t);
144
+ const t = D(), o = new Date(t);
145
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) => {
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) => {
147
147
  if (!Array.isArray(e) || e.length !== 2)
148
148
  throw new Error("Range de datas inválido");
149
149
  const [t, o] = e;
150
150
  if (!t || !o)
151
151
  throw new Error("Datas não podem ser nulas");
152
- return [z(t).toISOString(), z(o).toISOString()];
153
- }, be = {
154
- Hoje: () => [v(), v()],
152
+ return [M(t).toISOString(), M(o).toISOString()];
153
+ }, ve = {
154
+ Hoje: () => [D(), D()],
155
155
  Ontem: () => [C(-1), C(-1)],
156
- "7D": () => [C(-6), v()],
157
- "14D": () => [C(-13), v()],
158
- "30D": () => [C(-29), v()],
156
+ "7D": () => [C(-6), D()],
157
+ "14D": () => [C(-13), D()],
158
+ "30D": () => [C(-29), D()],
159
159
  Customizar: () => null
160
160
  }, De = {
161
161
  0: "Hoje",
@@ -163,25 +163,25 @@ const ie = I(
163
163
  7: "7D",
164
164
  14: "14D",
165
165
  30: "30D"
166
- }, ve = (e) => {
166
+ }, N = (e) => {
167
167
  if (!(!e || e.length === 0))
168
- return e.map((t) => t instanceof Date ? z(t).toISOString() : String(t));
168
+ return e.map((t) => t instanceof Date ? M(t).toISOString() : String(t));
169
169
  }, Ce = (e, t, o) => {
170
170
  if (!e || e.length !== 2)
171
171
  return "Customizar";
172
172
  try {
173
- const [d, f] = e, u = new Date(d), b = new Date(f);
174
- if (isNaN(u.getTime()) || isNaN(b.getTime()))
173
+ const [d, f] = e, u = new Date(d), p = new Date(f);
174
+ if (isNaN(u.getTime()) || isNaN(p.getTime()))
175
175
  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();
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
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
+ const [F, g] = c;
183
+ if (w(u, F) && w(p, g))
184
+ return n;
185
185
  }
186
186
  return "Customizar";
187
187
  } catch {
@@ -205,89 +205,91 @@ const ie = I(
205
205
  defaultSelected: d,
206
206
  minDate: f,
207
207
  maxDate: u,
208
- modelValue: b,
209
- dateRangeConfigs: r,
210
- disabled: n,
208
+ modelValue: p,
209
+ dateRangeConfigs: n,
210
+ disabled: s,
211
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(
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
213
  () => O.value.map((a) => ({
214
214
  label: a,
215
215
  value: a,
216
- selected: p.value === a
216
+ selected: g.value === a
217
217
  }))
218
218
  ), R = B(() => ({
219
- ...be,
220
- ...r.value
219
+ ...ve,
220
+ ...n.value
221
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);
222
+ g.value = a;
223
+ const r = R.value[a];
224
+ if (r) {
225
+ const l = r();
226
+ l && (y.value = !0, m.value = l);
227
227
  }
228
- }, q = (a) => {
229
- if (h.value) return;
230
- const l = ve(a), s = Ce(
231
- l,
228
+ }, J = (a) => {
229
+ if (y.value) return;
230
+ const r = N(a), l = Ce(
231
+ r,
232
232
  O.value,
233
233
  R.value
234
234
  );
235
- if (p.value !== s && (p.value = s), l && l.length === 2)
235
+ if (g.value !== l && (g.value = l), r && r.length === 2)
236
236
  try {
237
- const D = [
238
- new Date(l[0]),
239
- new Date(l[1])
237
+ const v = [
238
+ new Date(r[0]),
239
+ new Date(r[1])
240
240
  ];
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);
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);
244
244
  }
245
- }, J = () => {
245
+ }, K = () => {
246
246
  U(k);
247
- }, K = (a) => {
248
- U(a);
249
247
  }, Q = (a) => {
248
+ U(a);
249
+ }, W = (a) => {
250
+ const r = N(p.value);
251
+ if (r && r.length === 2) return;
250
252
  const l = a !== void 0 ? De[a] : k;
251
253
  l && U(l);
252
254
  };
253
- return x(b, (a) => q(a), {
255
+ return x(p, (a) => J(a), {
254
256
  immediate: !0,
255
257
  deep: !0
256
258
  }), x(
257
259
  m,
258
260
  async (a) => {
259
- var l, s;
261
+ var r, l;
260
262
  if ((a == null ? void 0 : a.length) === 2 && a[0] && a[1])
261
263
  try {
262
- (s = (l = A.value) == null ? void 0 : l.popover) == null || s.hide(), F("update:modelValue", ge(a)), await te(), h.value = !1;
264
+ (l = (r = A.value) == null ? void 0 : r.popover) == null || l.hide(), F("update:modelValue", be(a)), await ae(), y.value = !1;
263
265
  } catch {
264
- h.value = !1;
266
+ y.value = !1;
265
267
  }
266
268
  },
267
269
  { deep: !0 }
268
- ), x(d, (a) => Q(a), { immediate: !0 }), (a, l) => (g(), _("div", {
270
+ ), x(d, (a) => W(a), { immediate: !0 }), (a, r) => (b(), _("div", {
269
271
  role: "group",
270
272
  "aria-label": "Filtro de período",
271
- class: S(i(ue)({ card: i(c), disabled: i(n) }, i(Y).class))
273
+ class: S(i(ce)({ card: i(c), disabled: i(s) }, i(G).class))
272
274
  }, [
273
- T(pe, {
275
+ T(ge, {
274
276
  ref_key: "pickerRef",
275
277
  ref: A,
276
278
  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
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
283
285
  }, 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)
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
293
  }, null, 8, ["selected", "disabled", "data-test", "label", "onClick"]))), 128))
292
294
  ], 2));
293
295
  }
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.175",
4
4
  "description": "Design System da Appmax baseado no Primevue",
5
5
  "author": "Appmax",
6
6
  "exports": {