@caipira/tamandua 0.0.49 → 0.0.51

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.
package/README.md CHANGED
@@ -18,6 +18,13 @@ You can analyze the bundle by running:
18
18
  npx vite-bundle-visualizer
19
19
  ```
20
20
 
21
+ ## Publishing
22
+
23
+ ```sh
24
+ npm version patch
25
+ npm publish
26
+ ```
27
+
21
28
  ## Reference
22
29
 
23
30
  [typescript](https://www.typescriptlang.org/docs)
@@ -1,5 +1,5 @@
1
- import { _ as i } from "./Pagination.vue_vue_type_script_setup_true_lang-PLZQJUd0.js";
2
- import { p as r } from "./plugin-YUomn9tF.js";
1
+ import { _ as i } from "./Pagination.vue_vue_type_script_setup_true_lang-BJO_aOJk.js";
2
+ import { p as r } from "./plugin-Da5BWlyX.js";
3
3
  export {
4
4
  i as Pagination,
5
5
  r as PaginationPlugin
@@ -0,0 +1,107 @@
1
+ import { defineComponent as B, computed as s, watch as S, resolveComponent as h, openBlock as p, createElementBlock as g, toDisplayString as V, createCommentVNode as v, createElementVNode as _, createVNode as b, normalizeClass as d, Fragment as L, renderList as N, createBlock as y } from "vue";
2
+ const O = { class: "flex gap-2 items-center flex-wrap" }, D = {
3
+ key: 0,
4
+ class: "md:block hidden"
5
+ }, I = { class: "h-9 flex" }, E = /* @__PURE__ */ B({
6
+ name: "TPagination",
7
+ __name: "Pagination",
8
+ props: {
9
+ disabled: { type: Boolean, default: !1 },
10
+ pagination: { default: () => ({}) },
11
+ hasPageSize: { type: Boolean, default: !0 },
12
+ pageLengths: { default: () => [12, 18, 24, 30, 36, 42] },
13
+ showDescription: { type: Boolean, default: !1 }
14
+ },
15
+ emits: ["updated"],
16
+ setup(P, { emit: k }) {
17
+ const e = P, u = k, c = s(() => e.pagination.page === 1), m = s(
18
+ () => e.pagination.page === e.pagination.pages
19
+ ), w = s(() => {
20
+ const a = e.pagination.pages || 1, n = e.pagination.page || 1, t = [], r = Math.max(2, n - 2), i = Math.min(a - 1, n + 2);
21
+ a > 1 && t.push(1);
22
+ for (let o = r; o <= i; o++)
23
+ o > 1 && o < a && t.push(o);
24
+ return a > 1 && t.push(a), t;
25
+ }), $ = s(() => e.pageLengths.map((a) => ({
26
+ label: `${a} / page`,
27
+ value: a
28
+ }))), C = s(() => {
29
+ if (e.pagination.items && e.pagination.skip && e.pagination.items) {
30
+ const a = e.pagination.skip + 1, n = e.pagination.skip + e.pagination.items, t = e.pagination.totalItems;
31
+ return `Showing ${a} to ${n} of ${t} entries`;
32
+ }
33
+ return `Page ${e.pagination.page} of ${e.pagination.pages}`;
34
+ }), f = (a = e.pagination.page) => {
35
+ const n = {
36
+ ...e.pagination,
37
+ page: a
38
+ };
39
+ "perPage" in e.pagination && "skip" in e.pagination && "totalItems" in e.pagination && (n.skip = a > 1 ? (a - 1) * e.pagination.perPage : 0, n.items = e.pagination.perPage ? e.pagination.perPage : e.pagination.totalItems - n.skip), JSON.stringify(e.pagination) !== JSON.stringify(n) && (Object.assign(e.pagination, n), u("updated", e.pagination));
40
+ }, l = (a) => {
41
+ a === e.pagination.page || a < 1 || a > e.pagination.pages || f(a);
42
+ }, z = (a) => {
43
+ Object.assign(e.pagination, {
44
+ ...e.pagination,
45
+ perPage: a,
46
+ page: 1
47
+ }), u("updated", e.pagination);
48
+ };
49
+ return S(
50
+ () => e.pagination,
51
+ () => f(),
52
+ { deep: !0, immediate: !0 }
53
+ ), (a, n) => {
54
+ const t = h("t-button"), r = h("t-input-select");
55
+ return p(), g("div", O, [
56
+ a.showDescription ? (p(), g("div", D, V(C.value), 1)) : v("", !0),
57
+ _("div", I, [
58
+ b(t, {
59
+ size: "sm",
60
+ variant: "primary",
61
+ "disable-style": !0,
62
+ class: d(["h-9 px-2 input-roundness rounded-r-none", { "opacity-50 cursor-not-allowed": c.value }]),
63
+ icon: "chevron-left",
64
+ disabled: c.value,
65
+ onClick: n[0] || (n[0] = (i) => l(a.pagination.page - 1))
66
+ }, null, 8, ["class", "disabled"]),
67
+ (p(!0), g(L, null, N(w.value, (i) => (p(), y(t, {
68
+ "disable-style": !0,
69
+ label: `${i}`,
70
+ disabled: i === a.pagination.page,
71
+ class: d([{
72
+ "opacity-50 cursor-not-allowed": i === a.pagination.page
73
+ }, "h-9 px-2 rounded-none"]),
74
+ size: "sm",
75
+ variant: "primary",
76
+ onClick: (o) => l(i)
77
+ }, null, 8, ["label", "disabled", "class", "onClick"]))), 256)),
78
+ b(t, {
79
+ size: "sm",
80
+ variant: "primary",
81
+ "disable-style": !0,
82
+ class: d(["h-9 px-2 input-roundness rounded-l-none", { "opacity-50 cursor-not-allowed": m.value }]),
83
+ icon: "chevron-right",
84
+ disabled: m.value,
85
+ onClick: n[1] || (n[1] = (i) => l(a.pagination.page + 1))
86
+ }, null, 8, ["class", "disabled"])
87
+ ]),
88
+ e.hasPageSize ? (p(), y(r, {
89
+ key: 1,
90
+ modelValue: a.pagination.perPage,
91
+ "onUpdate:modelValue": [
92
+ n[2] || (n[2] = (i) => a.pagination.perPage = i),
93
+ z
94
+ ],
95
+ "width-class": "",
96
+ class: "w-fit min-w-32",
97
+ "dropdown-placement": "top",
98
+ disabled: a.disabled,
99
+ options: $.value
100
+ }, null, 8, ["modelValue", "disabled", "options"])) : v("", !0)
101
+ ]);
102
+ };
103
+ }
104
+ });
105
+ export {
106
+ E as _
107
+ };
@@ -32,7 +32,7 @@ import { _ as sr } from "./InputTextarea.vue_vue_type_script_setup_true_lang-DRo
32
32
  import { _ as fr } from "./Link.vue_vue_type_script_setup_true_lang-gTf77Jvd.js";
33
33
  import { _ as nr } from "./Modal.vue_vue_type_script_setup_true_lang-CEaX1svl.js";
34
34
  import { _ as ur } from "./ModalForm.vue_vue_type_script_setup_true_lang-RfK0Mn81.js";
35
- import { _ as lr } from "./Pagination.vue_vue_type_script_setup_true_lang-PLZQJUd0.js";
35
+ import { _ as lr } from "./Pagination.vue_vue_type_script_setup_true_lang-BJO_aOJk.js";
36
36
  import { _ as cr } from "./Popconfirm.vue_vue_type_script_setup_true_lang-XyjBUx0p.js";
37
37
  import { _ as Tr } from "./Popover.vue_vue_type_script_setup_true_lang-dnL75W40.js";
38
38
  import { P as Cr } from "./ProgressCircle-Cpmi2CpO.js";
@@ -1,5 +1,5 @@
1
1
  import { r } from "./register-component-B-fdqewb.js";
2
- import { _ as s } from "./Pagination.vue_vue_type_script_setup_true_lang-PLZQJUd0.js";
2
+ import { _ as s } from "./Pagination.vue_vue_type_script_setup_true_lang-BJO_aOJk.js";
3
3
  const m = {
4
4
  install(o) {
5
5
  r(o, s);
@@ -44,7 +44,7 @@ import "./Link.vue_vue_type_script_setup_true_lang-gTf77Jvd.js";
44
44
  import { p as D } from "./plugin-DHstqRmE.js";
45
45
  import { p as F } from "./plugin-DKjcKBPg.js";
46
46
  import { p as L } from "./plugin-DNXazWwT.js";
47
- import { p as M } from "./plugin-YUomn9tF.js";
47
+ import { p as M } from "./plugin-Da5BWlyX.js";
48
48
  import "./Popconfirm.vue_vue_type_script_setup_true_lang-XyjBUx0p.js";
49
49
  import { p as _ } from "./plugin-Ee4Z5Rtp.js";
50
50
  import "./Popover.vue_vue_type_script_setup_true_lang-dnL75W40.js";
package/dist/plugins.js CHANGED
@@ -44,7 +44,7 @@ import "./Link.vue_vue_type_script_setup_true_lang-gTf77Jvd.js";
44
44
  import { p as vr } from "./plugin-DHstqRmE.js";
45
45
  import { p as Dr } from "./plugin-DKjcKBPg.js";
46
46
  import { p as Lr } from "./plugin-DNXazWwT.js";
47
- import { p as Ar } from "./plugin-YUomn9tF.js";
47
+ import { p as Ar } from "./plugin-Da5BWlyX.js";
48
48
  import "./Popconfirm.vue_vue_type_script_setup_true_lang-XyjBUx0p.js";
49
49
  import { p as Er } from "./plugin-Ee4Z5Rtp.js";
50
50
  import "./Popover.vue_vue_type_script_setup_true_lang-dnL75W40.js";
package/dist/tamandua.js CHANGED
@@ -1,4 +1,4 @@
1
- import { p as n } from "./plugins-CkB_la4g.js";
1
+ import { p as n } from "./plugins-BjwvJoNS.js";
2
2
  const o = {
3
3
  install(s) {
4
4
  for (const i in n)
@@ -1,5 +1,13 @@
1
1
  declare const _default: {
2
2
  title: string;
3
+ args: {
4
+ hasPageSize: boolean;
5
+ showDescription: boolean;
6
+ pagination: {
7
+ page: number;
8
+ pages: number;
9
+ };
10
+ };
3
11
  };
4
12
  export default _default;
5
13
  export declare const Pagination: (args: any) => {
@@ -4,6 +4,7 @@ import { Pagination } from '../../types/ui.js';
4
4
  declare const _default: import('vue').DefineComponent<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<PaginationProps>, {
5
5
  disabled: boolean;
6
6
  pagination: () => Pagination;
7
+ hasPageSize: boolean;
7
8
  pageLengths: () => number[];
8
9
  showDescription: boolean;
9
10
  }>, {}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
@@ -11,6 +12,7 @@ declare const _default: import('vue').DefineComponent<__VLS_WithDefaults<__VLS_T
11
12
  }, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<PaginationProps>, {
12
13
  disabled: boolean;
13
14
  pagination: () => Pagination;
15
+ hasPageSize: boolean;
14
16
  pageLengths: () => number[];
15
17
  showDescription: boolean;
16
18
  }>>> & {
@@ -18,6 +20,7 @@ declare const _default: import('vue').DefineComponent<__VLS_WithDefaults<__VLS_T
18
20
  }, {
19
21
  disabled: boolean;
20
22
  pagination: Pagination;
23
+ hasPageSize: boolean;
21
24
  pageLengths: number[];
22
25
  showDescription: boolean;
23
26
  }, {}>;
@@ -3,6 +3,7 @@ import { Pagination } from '../../types/ui.js';
3
3
  export type PaginationProps = {
4
4
  disabled?: boolean;
5
5
  pagination?: Pagination;
6
+ hasPageSize?: boolean;
6
7
  pageLengths?: Array<number>;
7
8
  showDescription: boolean;
8
9
  };
@@ -1,19 +1,19 @@
1
1
  import { ElementPosition, ToastVariant } from '../enums/ui.js';
2
2
 
3
- export interface Pagination {
3
+ export type Pagination = {
4
4
  /** Amount of items in current page */
5
- items: number;
5
+ items?: number;
6
6
  /** Current page */
7
7
  page: number;
8
8
  /** Amount of pages */
9
9
  pages: number;
10
10
  /** Amount of items per page */
11
- perPage: number;
11
+ perPage?: number;
12
12
  /** Amount of items being skipped */
13
- skip: number;
13
+ skip?: number;
14
14
  /** Total number of items */
15
- totalItems: number;
16
- }
15
+ totalItems?: number;
16
+ };
17
17
  export type TableColumn = {
18
18
  title?: string;
19
19
  } & ({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@caipira/tamandua",
3
- "version": "0.0.49",
3
+ "version": "0.0.51",
4
4
  "private": false,
5
5
  "description": "UI library for the Caipira ecosystem",
6
6
  "license": "GPL-3.0-only",
@@ -1,89 +0,0 @@
1
- import { defineComponent as w, computed as o, watch as C, resolveComponent as d, openBlock as g, createElementBlock as c, toDisplayString as V, createCommentVNode as x, createElementVNode as z, createVNode as s, normalizeClass as u } from "vue";
2
- const B = { class: "flex items-center justify-end w-full flex-wrap" }, I = {
3
- key: 0,
4
- class: "mr-3 grow md:block hidden"
5
- }, L = { class: "h-9 flex" }, $ = /* @__PURE__ */ w({
6
- name: "TPagination",
7
- __name: "Pagination",
8
- props: {
9
- disabled: { type: Boolean, default: !1 },
10
- pagination: { default: () => ({}) },
11
- pageLengths: { default: () => [12, 18, 24, 30, 36, 42] },
12
- showDescription: { type: Boolean, default: !1 }
13
- },
14
- emits: ["updated"],
15
- setup(m, { emit: b }) {
16
- const e = m, p = b, l = o(() => e.pagination.page === 1), r = o(() => e.pagination.totalItems - e.pagination?.skip <= e.pagination.perPage), f = o(() => e.pageLengths.map((n) => ({
17
- label: `${n} / page`,
18
- value: n
19
- }))), h = o(() => {
20
- const n = e.pagination.skip + 1, t = e.pagination.skip + e.pagination.items, a = e.pagination.totalItems;
21
- return `Showing ${n} to ${t} of ${a} entries`;
22
- }), i = (n = e.pagination.page) => {
23
- const t = n > 1 ? (n - 1) * e.pagination.perPage : 0, a = e.pagination.totalItems - t;
24
- Object.assign(e.pagination, {
25
- ...e.pagination,
26
- skip: t,
27
- page: n,
28
- items: a > e.pagination.perPage ? e.pagination.perPage : a
29
- }), p("updated", e.pagination);
30
- }, v = () => {
31
- i(e.pagination.page - 1);
32
- }, P = () => {
33
- i(e.pagination.page + 1);
34
- }, _ = (n) => {
35
- Object.assign(e.pagination, {
36
- ...e.pagination,
37
- perPage: n,
38
- page: 1
39
- }), p("updated", e.pagination);
40
- };
41
- return C(
42
- () => e.pagination,
43
- () => {
44
- e.pagination.totalItems > 0 && e.pagination.items === 0 && i();
45
- },
46
- { deep: !0, immediate: !0 }
47
- ), (n, t) => {
48
- const a = d("t-button"), y = d("t-input-select");
49
- return g(), c("div", B, [
50
- n.showDescription ? (g(), c("div", I, V(h.value), 1)) : x("", !0),
51
- z("div", L, [
52
- s(a, {
53
- size: "sm",
54
- variant: "primary",
55
- "disable-style": !0,
56
- class: u(["h-9 px-2 input-roundness rounded-r-none input-border border-r", { "opacity-50 cursor-not-allowed": l.value }]),
57
- icon: "chevron-left",
58
- disabled: l.value,
59
- onClick: v
60
- }, null, 8, ["class", "disabled"]),
61
- s(a, {
62
- size: "sm",
63
- variant: "primary",
64
- "disable-style": !0,
65
- class: u(["h-9 px-2 rounded-none", { "opacity-50 cursor-not-allowed": r.value }]),
66
- icon: "chevron-right",
67
- disabled: r.value,
68
- onClick: P
69
- }, null, 8, ["class", "disabled"]),
70
- s(y, {
71
- modelValue: n.pagination.perPage,
72
- "onUpdate:modelValue": [
73
- t[0] || (t[0] = (k) => n.pagination.perPage = k),
74
- _
75
- ],
76
- disabled: n.disabled,
77
- options: f.value,
78
- "disable-style": !0,
79
- "dropdown-placement": "top",
80
- class: "h-9 border input-border border-l-0 input-roundness rounded-l-none"
81
- }, null, 8, ["modelValue", "disabled", "options"])
82
- ])
83
- ]);
84
- };
85
- }
86
- });
87
- export {
88
- $ as _
89
- };