@caipira/tamandua 0.0.1

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 (295) hide show
  1. package/.editorconfig +12 -0
  2. package/.prettierrc +5 -0
  3. package/.storybook/main.ts +25 -0
  4. package/.storybook/preview-body.html +3 -0
  5. package/.storybook/preview.ts +24 -0
  6. package/App.vue +1 -0
  7. package/Dockerfile +21 -0
  8. package/LICENSE +674 -0
  9. package/README.md +11 -0
  10. package/assets/icons/account.svg +1 -0
  11. package/assets/icons/alert-octagon-outline.svg +1 -0
  12. package/assets/icons/alert-octagon.svg +1 -0
  13. package/assets/icons/archive-outline.svg +1 -0
  14. package/assets/icons/archive.svg +1 -0
  15. package/assets/icons/arrow-left.svg +1 -0
  16. package/assets/icons/arrow-right.svg +1 -0
  17. package/assets/icons/bank-outline.svg +1 -0
  18. package/assets/icons/bank.svg +1 -0
  19. package/assets/icons/camera.svg +1 -0
  20. package/assets/icons/cards-outline.svg +1 -0
  21. package/assets/icons/cards-variant.svg +1 -0
  22. package/assets/icons/cart-outline.svg +1 -0
  23. package/assets/icons/chart-box-outline.svg +1 -0
  24. package/assets/icons/chart-box.svg +1 -0
  25. package/assets/icons/check-circle-outline.svg +1 -0
  26. package/assets/icons/check-circle.svg +1 -0
  27. package/assets/icons/check.svg +1 -0
  28. package/assets/icons/checkbox-dark.svg +1 -0
  29. package/assets/icons/checkbox-indeterminate-dark.svg +1 -0
  30. package/assets/icons/checkbox-indeterminate.svg +1 -0
  31. package/assets/icons/checkbox.svg +1 -0
  32. package/assets/icons/chevron-down.svg +1 -0
  33. package/assets/icons/chevron-left.svg +1 -0
  34. package/assets/icons/chevron-right.svg +1 -0
  35. package/assets/icons/chevron-up.svg +1 -0
  36. package/assets/icons/circle.svg +1 -0
  37. package/assets/icons/clock.svg +1 -0
  38. package/assets/icons/close-circle-outline.svg +1 -0
  39. package/assets/icons/close-circle.svg +1 -0
  40. package/assets/icons/close.svg +1 -0
  41. package/assets/icons/cog.svg +1 -0
  42. package/assets/icons/color-fill.svg +1 -0
  43. package/assets/icons/copy.svg +1 -0
  44. package/assets/icons/credit-card-plus.svg +1 -0
  45. package/assets/icons/credit-card.svg +1 -0
  46. package/assets/icons/currency.svg +1 -0
  47. package/assets/icons/database.svg +1 -0
  48. package/assets/icons/dots-grid.svg +1 -0
  49. package/assets/icons/dots-vertical.svg +1 -0
  50. package/assets/icons/email-open-outline.svg +1 -0
  51. package/assets/icons/email-outline.svg +1 -0
  52. package/assets/icons/eye-off.svg +1 -0
  53. package/assets/icons/eye.svg +1 -0
  54. package/assets/icons/file-document-plus-outline.svg +1 -0
  55. package/assets/icons/filmstrip.svg +1 -0
  56. package/assets/icons/filter.svg +1 -0
  57. package/assets/icons/fullscreen-exit.svg +1 -0
  58. package/assets/icons/fullscreen.svg +1 -0
  59. package/assets/icons/group.svg +1 -0
  60. package/assets/icons/image-album-outline.svg +1 -0
  61. package/assets/icons/image-album.svg +1 -0
  62. package/assets/icons/image-outline.svg +1 -0
  63. package/assets/icons/image.svg +1 -0
  64. package/assets/icons/info-outline.svg +1 -0
  65. package/assets/icons/key-chain.svg +1 -0
  66. package/assets/icons/key-variant.svg +1 -0
  67. package/assets/icons/key.svg +1 -0
  68. package/assets/icons/listbox-outline.svg +1 -0
  69. package/assets/icons/loading.svg +1 -0
  70. package/assets/icons/lock-outline.svg +1 -0
  71. package/assets/icons/lock.svg +1 -0
  72. package/assets/icons/logout.svg +1 -0
  73. package/assets/icons/menu-down.svg +1 -0
  74. package/assets/icons/menu-left.svg +1 -0
  75. package/assets/icons/menu-right.svg +1 -0
  76. package/assets/icons/menu.svg +1 -0
  77. package/assets/icons/minus-circle-outline.svg +1 -0
  78. package/assets/icons/minus-circle.svg +1 -0
  79. package/assets/icons/minus.svg +1 -0
  80. package/assets/icons/moon.svg +1 -0
  81. package/assets/icons/open-in-new.svg +1 -0
  82. package/assets/icons/pencil.svg +1 -0
  83. package/assets/icons/people.svg +1 -0
  84. package/assets/icons/piggy-bank-outline.svg +1 -0
  85. package/assets/icons/plus-circle-outline.svg +1 -0
  86. package/assets/icons/plus-circle.svg +1 -0
  87. package/assets/icons/plus.svg +1 -0
  88. package/assets/icons/qrcode-scan.svg +1 -0
  89. package/assets/icons/radio-dark.svg +1 -0
  90. package/assets/icons/radio.svg +1 -0
  91. package/assets/icons/refresh.svg +1 -0
  92. package/assets/icons/save.svg +1 -0
  93. package/assets/icons/search.svg +1 -0
  94. package/assets/icons/spotlight.svg +1 -0
  95. package/assets/icons/store-outline.svg +1 -0
  96. package/assets/icons/sun.svg +1 -0
  97. package/assets/icons/swap-horizontal.svg +1 -0
  98. package/assets/icons/swap-left.svg +1 -0
  99. package/assets/icons/swap-right.svg +1 -0
  100. package/assets/icons/swap.svg +1 -0
  101. package/assets/icons/system-theme.svg +1 -0
  102. package/assets/icons/tag-outline.svg +1 -0
  103. package/assets/icons/trash-can-outline.svg +1 -0
  104. package/assets/icons/trash-can.svg +1 -0
  105. package/assets/icons/upload.svg +1 -0
  106. package/assets/icons/user-circle.svg +1 -0
  107. package/assets/icons/zip-box.svg +1 -0
  108. package/assets/images/fs/apk.svg +11 -0
  109. package/assets/images/fs/bmp.svg +7 -0
  110. package/assets/images/fs/css.svg +8 -0
  111. package/assets/images/fs/doc.svg +9 -0
  112. package/assets/images/fs/docx.svg +9 -0
  113. package/assets/images/fs/folder-adwaita.svg +8 -0
  114. package/assets/images/fs/folder-black.svg +8 -0
  115. package/assets/images/fs/folder-brown.svg +8 -0
  116. package/assets/images/fs/folder-grey.svg +8 -0
  117. package/assets/images/fs/folder-nordic.svg +8 -0
  118. package/assets/images/fs/folder-orange.svg +8 -0
  119. package/assets/images/fs/folder-palebrown.svg +8 -0
  120. package/assets/images/fs/folder-paleorange.svg +8 -0
  121. package/assets/images/fs/folder-teal.svg +8 -0
  122. package/assets/images/fs/folder-white.svg +8 -0
  123. package/assets/images/fs/folder-yellow.svg +8 -0
  124. package/assets/images/fs/gif.svg +7 -0
  125. package/assets/images/fs/go.svg +9 -0
  126. package/assets/images/fs/ics.svg +24 -0
  127. package/assets/images/fs/iso.svg +10 -0
  128. package/assets/images/fs/jpeg.svg +7 -0
  129. package/assets/images/fs/jpg.svg +7 -0
  130. package/assets/images/fs/js.svg +9 -0
  131. package/assets/images/fs/json.svg +9 -0
  132. package/assets/images/fs/lua.svg +9 -0
  133. package/assets/images/fs/m4v.svg +7 -0
  134. package/assets/images/fs/md.svg +10 -0
  135. package/assets/images/fs/mov.svg +7 -0
  136. package/assets/images/fs/mp3.svg +9 -0
  137. package/assets/images/fs/mp4.svg +7 -0
  138. package/assets/images/fs/pdf.svg +9 -0
  139. package/assets/images/fs/pgp.svg +8 -0
  140. package/assets/images/fs/php.svg +9 -0
  141. package/assets/images/fs/png.svg +7 -0
  142. package/assets/images/fs/ppt.svg +9 -0
  143. package/assets/images/fs/py.svg +9 -0
  144. package/assets/images/fs/rar.svg +20 -0
  145. package/assets/images/fs/rpm.svg +7 -0
  146. package/assets/images/fs/rs.svg +9 -0
  147. package/assets/images/fs/sh.svg +9 -0
  148. package/assets/images/fs/tar.svg +20 -0
  149. package/assets/images/fs/txt.svg +8 -0
  150. package/assets/images/fs/unknown.svg +8 -0
  151. package/assets/images/fs/xls.svg +9 -0
  152. package/assets/images/fs/xlsx.svg +9 -0
  153. package/assets/images/fs/xml.svg +8 -0
  154. package/assets/images/fs/yaml.svg +9 -0
  155. package/assets/images/fs/zip.svg +20 -0
  156. package/components/Avatar/Avatar.story.ts +55 -0
  157. package/components/Avatar/Avatar.vue +82 -0
  158. package/components/Avatar/index.ts +12 -0
  159. package/components/Backdrop/Backdrop.vue +27 -0
  160. package/components/Backdrop/index.ts +12 -0
  161. package/components/Button/Button.story.ts +74 -0
  162. package/components/Button/Button.vue +230 -0
  163. package/components/Button/index.ts +12 -0
  164. package/components/ButtonCopy/ButtonCopy.vue +61 -0
  165. package/components/ButtonCopy/index.ts +12 -0
  166. package/components/Drawer/Drawer.vue +102 -0
  167. package/components/Drawer/index.ts +12 -0
  168. package/components/Dropdown/Dropdown.vue +258 -0
  169. package/components/Dropdown/index.ts +12 -0
  170. package/components/EventListener/EventListener.vue +12 -0
  171. package/components/FileDrop/FileDrop.vue +116 -0
  172. package/components/FileDrop/index.ts +12 -0
  173. package/components/Form/Form.spec.ts +72 -0
  174. package/components/Form/Form.vue +134 -0
  175. package/components/Form/index.ts +12 -0
  176. package/components/FormItem/FormItem.vue +85 -0
  177. package/components/FormItem/index.ts +12 -0
  178. package/components/GraphyEmpty/GraphyEmpty.vue +16 -0
  179. package/components/GraphyEmpty/index.ts +12 -0
  180. package/components/GraphyLabel/GraphyLabel.vue +34 -0
  181. package/components/GraphyLabel/index.ts +12 -0
  182. package/components/GraphyPrice/GraphyPrice.story.ts +37 -0
  183. package/components/GraphyPrice/GraphyPrice.vue +65 -0
  184. package/components/GraphyPrice/index.ts +12 -0
  185. package/components/GraphySubtitle/GraphySubtitle.vue +22 -0
  186. package/components/GraphySubtitle/index.ts +12 -0
  187. package/components/GraphyTitle/GraphyTitle.vue +13 -0
  188. package/components/GraphyTitle/index.ts +12 -0
  189. package/components/Icon/Icon.vue +84 -0
  190. package/components/Icon/index.ts +12 -0
  191. package/components/IconButton/IconButton.vue +168 -0
  192. package/components/IconButton/index.ts +12 -0
  193. package/components/InputAvatar/InputAvatar.vue +63 -0
  194. package/components/InputAvatar/index.ts +12 -0
  195. package/components/InputCheckbox/InputCheckbox.vue +77 -0
  196. package/components/InputCheckbox/index.ts +12 -0
  197. package/components/InputColor/InputColor.vue +54 -0
  198. package/components/InputColor/index.ts +12 -0
  199. package/components/InputDate/InputDate.story.ts +15 -0
  200. package/components/InputDate/InputDate.vue +368 -0
  201. package/components/InputDate/index.ts +12 -0
  202. package/components/InputMultiplier/InputMultiplier.vue +144 -0
  203. package/components/InputMultiplier/index.ts +12 -0
  204. package/components/InputPassword/InputPassword.vue +168 -0
  205. package/components/InputPassword/index.ts +12 -0
  206. package/components/InputPhone/InputPhone.vue +125 -0
  207. package/components/InputPhone/index.ts +12 -0
  208. package/components/InputPrice/InputPrice.vue +96 -0
  209. package/components/InputPrice/index.ts +12 -0
  210. package/components/InputRadio/InputRadio.vue +41 -0
  211. package/components/InputRadio/InputRadioGroup.story.ts +24 -0
  212. package/components/InputRadio/InputRadioGroup.vue +48 -0
  213. package/components/InputRadio/index.ts +14 -0
  214. package/components/InputSelect/InputSelect.story.ts +87 -0
  215. package/components/InputSelect/InputSelect.vue +507 -0
  216. package/components/InputSelect/index.ts +12 -0
  217. package/components/InputSwitch/InputSwitch.story.ts +34 -0
  218. package/components/InputSwitch/InputSwitch.vue +82 -0
  219. package/components/InputSwitch/index.ts +12 -0
  220. package/components/InputText/InputText.vue +62 -0
  221. package/components/InputText/index.ts +12 -0
  222. package/components/InputTextarea/InputTextarea.vue +64 -0
  223. package/components/InputTextarea/index.ts +12 -0
  224. package/components/LineChart/LineChart.vue +14 -0
  225. package/components/LineChart/index.ts +12 -0
  226. package/components/Modal/Modal.vue +106 -0
  227. package/components/Modal/index.ts +12 -0
  228. package/components/ModalForm/ModalForm.vue +141 -0
  229. package/components/ModalForm/index.ts +12 -0
  230. package/components/Pagination/Pagination.story.ts +15 -0
  231. package/components/Pagination/Pagination.vue +138 -0
  232. package/components/Pagination/index.ts +12 -0
  233. package/components/PieChart/PieChart.vue +14 -0
  234. package/components/PieChart/index.ts +12 -0
  235. package/components/Popconfirm/Popconfirm.vue +80 -0
  236. package/components/Popconfirm/index.ts +12 -0
  237. package/components/Popover/Popover.vue +133 -0
  238. package/components/Popover/index.ts +12 -0
  239. package/components/ProgressCircle/ProgressCircle.story.ts +31 -0
  240. package/components/ProgressCircle/ProgressCircle.vue +82 -0
  241. package/components/ProgressCircle/index.ts +12 -0
  242. package/components/ProgressLine/ProgressLine.story.ts +27 -0
  243. package/components/ProgressLine/ProgressLine.vue +104 -0
  244. package/components/ProgressLine/index.ts +12 -0
  245. package/components/SensitiveInfo/SensitiveInfo.vue +18 -0
  246. package/components/SensitiveInfo/index.ts +12 -0
  247. package/components/Tab/Tab.vue +58 -0
  248. package/components/Tab/index.ts +12 -0
  249. package/components/Table/Table.story.ts +32 -0
  250. package/components/Table/Table.vue +318 -0
  251. package/components/Table/index.ts +12 -0
  252. package/components/Tag/Tag.vue +73 -0
  253. package/components/Tag/index.ts +12 -0
  254. package/components/Toast/Toast.vue +75 -0
  255. package/components/Toast/index.ts +12 -0
  256. package/components/index.ts +43 -0
  257. package/components/plugins.ts +89 -0
  258. package/composables/index.ts +2 -0
  259. package/composables/useBreakpoints.ts +30 -0
  260. package/composables/useRender.ts +29 -0
  261. package/entrypoint.sh +19 -0
  262. package/enums/app.ts +5 -0
  263. package/enums/form.ts +25 -0
  264. package/enums/ui.ts +160 -0
  265. package/env.d.ts +8 -0
  266. package/i18n.ts +20 -0
  267. package/index.css +383 -0
  268. package/index.html +22 -0
  269. package/index.ts +14 -0
  270. package/main.ts +31 -0
  271. package/package.json +70 -0
  272. package/plugins/register-component.ts +5 -0
  273. package/postcss.config.js +6 -0
  274. package/services/clipboard.ts +5 -0
  275. package/services/date.ts +27 -0
  276. package/services/form/crud.ts +109 -0
  277. package/services/form/form-data-transformers.ts +148 -0
  278. package/services/form/form-json-transformers.ts +91 -0
  279. package/services/form/form-transformer.ts +54 -0
  280. package/services/form/form-value-transformers.ts +35 -0
  281. package/services/form/form.test.ts +98 -0
  282. package/services/form/form.ts +80 -0
  283. package/services/password.ts +309 -0
  284. package/services/ui.ts +43 -0
  285. package/tailwind.config.js +16 -0
  286. package/tsconfig.json +23 -0
  287. package/types/address.ts +44 -0
  288. package/types/api.ts +28 -0
  289. package/types/common.ts +5 -0
  290. package/types/form.ts +144 -0
  291. package/types/index.ts +5 -0
  292. package/types/ui.ts +55 -0
  293. package/types/website.ts +16 -0
  294. package/vite.config.mts +38 -0
  295. package/vitest.setup.ts +21 -0
@@ -0,0 +1,18 @@
1
+ <script lang="ts" setup>
2
+ defineOptions({ name: "TSensitiveInfo" });
3
+
4
+ const props = defineProps<{
5
+ private: boolean;
6
+ }>();
7
+ </script>
8
+
9
+ <template>
10
+ <div
11
+ :class="{
12
+ 'blur-sm': props.private,
13
+ 'filter grayscale': false,
14
+ }"
15
+ >
16
+ <slot />
17
+ </div>
18
+ </template>
@@ -0,0 +1,12 @@
1
+ import type { App, Plugin } from "vue";
2
+ import registerComponent from "@/plugins/register-component";
3
+
4
+ import SensitiveInfo from "./SensitiveInfo.vue";
5
+
6
+ export default {
7
+ install(app: App) {
8
+ registerComponent(app, SensitiveInfo);
9
+ },
10
+ } as Plugin;
11
+
12
+ export { SensitiveInfo };
@@ -0,0 +1,58 @@
1
+ <script lang="ts" setup>
2
+ import { Tab } from "@/types/ui";
3
+
4
+ import { ref } from "vue";
5
+
6
+ defineOptions({ name: "TTab" });
7
+
8
+ const props = withDefaults(
9
+ defineProps<{
10
+ tabs?: Tab[];
11
+ }>(),
12
+ {
13
+ tabs: () => [],
14
+ },
15
+ );
16
+
17
+ const activeTabIndex = ref<number>(0);
18
+ </script>
19
+
20
+ <template>
21
+ <ul
22
+ class="flex flex-col md:flex-row flex-wrap rounded-sm list-none mb-6 pt-1 bg-caipira-tertiary"
23
+ role="tablist"
24
+ >
25
+ <li
26
+ role="presentation"
27
+ v-for="(tab, index) in props.tabs"
28
+ :key="index"
29
+ >
30
+ <a
31
+ class="block uppercase py-2 px-4"
32
+ :class="{
33
+ 'bg-caipira-primary': index === activeTabIndex,
34
+ }"
35
+ href="#"
36
+ role="tab"
37
+ aria-selected="true"
38
+ @click="activeTabIndex = index"
39
+ >
40
+ {{ tab.title }}
41
+ </a>
42
+ </li>
43
+ </ul>
44
+ <div
45
+ class="tab-content"
46
+ id="tabs-tabContent"
47
+ >
48
+ <div
49
+ v-for="(tab, index) in props.tabs"
50
+ :key="index"
51
+ class=""
52
+ :class="{ hidden: index !== activeTabIndex }"
53
+ role="tabpanel"
54
+ >
55
+ <slot :name="tab.slot" />
56
+ </div>
57
+ </div>
58
+ </template>
@@ -0,0 +1,12 @@
1
+ import type { App, Plugin } from "vue";
2
+ import registerComponent from "@/plugins/register-component";
3
+
4
+ import Tab from "./Tab.vue";
5
+
6
+ export default {
7
+ install(app: App) {
8
+ registerComponent(app, Tab);
9
+ },
10
+ } as Plugin;
11
+
12
+ export { Tab };
@@ -0,0 +1,32 @@
1
+ import { faker } from "@faker-js/faker";
2
+
3
+ import UITable from "./Table.vue";
4
+
5
+ export default {
6
+ components: UITable,
7
+ title: "Table",
8
+ };
9
+
10
+ const Template1 = (args: any) => ({
11
+ components: { UITable },
12
+ setup() {
13
+ return { args };
14
+ },
15
+ template: `<UITable v-bind="args" />`,
16
+ });
17
+
18
+ export const Table: any = Template1.bind({});
19
+ Table.args = {
20
+ loading: false,
21
+ data: (Array.from({ length: 10 }) as any).map(() => ({
22
+ id: faker.string.uuid(),
23
+ name: faker.person.fullName(),
24
+ email: faker.internet.email(),
25
+ job: faker.person.jobTitle(),
26
+ })),
27
+ columns: [
28
+ { title: "Name", property: "name" },
29
+ { title: "Email", property: "email" },
30
+ { title: "Job", property: "job" },
31
+ ],
32
+ };
@@ -0,0 +1,318 @@
1
+ <script lang="ts" setup generic="T extends object">
2
+ import { TableColumn } from "@/types/ui";
3
+
4
+ import { computed, reactive, ref, useSlots } from "vue";
5
+
6
+ export type TableProps<T = object> = {
7
+ data: T[];
8
+ rowKey?: string;
9
+ columns: TableColumn[];
10
+ loading?: boolean;
11
+ selectable?: boolean;
12
+ disableStyle?: boolean;
13
+ stickyHeader?: boolean;
14
+
15
+ rowClass?: string;
16
+ tableDataClass?: string;
17
+ };
18
+
19
+ defineOptions({ name: "TTable" });
20
+
21
+ const props = withDefaults(
22
+ defineProps<{
23
+ data: T[];
24
+ rowKey?: string;
25
+ columns: TableColumn[];
26
+ loading?: boolean;
27
+ selectable?: boolean;
28
+ disableStyle?: boolean;
29
+ stickyHeader?: boolean;
30
+
31
+ rowClass?: string;
32
+ tableDataClass?: string;
33
+ }>(),
34
+ {
35
+ data: () => [],
36
+ rowKey: "id",
37
+ columns: () => [],
38
+ loading: false,
39
+ selectable: false,
40
+ disableStyle: false,
41
+ stickyHeader: true,
42
+
43
+ rowClass: "hover:bg-hover",
44
+ tableDataClass: "px-2 py-2",
45
+ },
46
+ );
47
+
48
+ const emit = defineEmits<{
49
+ (e: "selected", val: any): void;
50
+ (e: "row-click", val: any): void;
51
+ }>();
52
+
53
+ const slots = useSlots();
54
+ const selectedAll = ref<boolean | undefined>(false);
55
+ const selectedRows = ref<any>({});
56
+ const expandedRows = ref<any>({});
57
+ const inSelectionMode = ref<boolean>(false);
58
+ const isIndeterminate = ref<boolean>(false);
59
+ const selectedRowsMeta = reactive<any>({});
60
+
61
+ const onClickRow = (e: MouseEvent) => {
62
+ e.stopPropagation();
63
+ };
64
+
65
+ const columnsLength = computed<number>(() => {
66
+ return (
67
+ props.columns.length +
68
+ (props.selectable ? 1 : 0) +
69
+ (slots.details ? 1 : 0) +
70
+ 1
71
+ );
72
+ });
73
+
74
+ const refreshSelectAllState = () => {
75
+ let trueCount = 0;
76
+ let falseCount = 0;
77
+
78
+ props.data.forEach((row: any) => {
79
+ if (selectedRows.value[row[props.rowKey]]) {
80
+ trueCount++;
81
+ } else {
82
+ falseCount++;
83
+ }
84
+ });
85
+
86
+ if (falseCount === 0 && trueCount > 0) {
87
+ isIndeterminate.value = false;
88
+ selectedAll.value = true;
89
+ } else if (trueCount === 0) {
90
+ isIndeterminate.value = false;
91
+ selectedAll.value = false;
92
+ } else if (falseCount !== trueCount) {
93
+ isIndeterminate.value = true;
94
+ selectedAll.value = undefined;
95
+ }
96
+
97
+ inSelectionMode.value = Object.keys(selectedRows.value).some(
98
+ (key: string) => selectedRows.value[key],
99
+ );
100
+ };
101
+
102
+ const onSelectRow = async (rowId: string, checked: boolean) => {
103
+ if (!checked) {
104
+ delete selectedRowsMeta[rowId];
105
+ } else {
106
+ selectedRowsMeta[rowId] = props.data.find(
107
+ (row: any) => row[props.rowKey] === rowId,
108
+ );
109
+ }
110
+
111
+ emit("selected", selectedRowsMeta);
112
+ refreshSelectAllState();
113
+ };
114
+
115
+ const clearSelection = () => {
116
+ Object.keys(selectedRows.value).forEach((key) => {
117
+ selectedRows.value[key] = false;
118
+ selectedAll.value = false;
119
+ isIndeterminate.value = false;
120
+ inSelectionMode.value = false;
121
+ });
122
+
123
+ Object.assign(selectedRowsMeta, {});
124
+ emit("selected", {});
125
+ };
126
+
127
+ const onSelectAllChange = () => {
128
+ if (selectedAll.value) {
129
+ props.data.forEach((row: any) => {
130
+ selectedRows.value[row[props.rowKey]] = true;
131
+ selectedRowsMeta[row[props.rowKey]] = row;
132
+ });
133
+ } else {
134
+ props.data.forEach((row: any) => {
135
+ selectedRows.value[row[props.rowKey]] = false;
136
+ delete selectedRowsMeta[row[props.rowKey]];
137
+ inSelectionMode.value = false;
138
+ });
139
+ }
140
+
141
+ refreshSelectAllState();
142
+ emit("selected", selectedRowsMeta);
143
+ };
144
+
145
+ const rows = computed<T[]>(() => {
146
+ if (props.loading && props.data.length === 0) {
147
+ return Array.from({ length: 5 }, (_, i) => i as unknown as T);
148
+ }
149
+
150
+ return props.data;
151
+ });
152
+
153
+ defineExpose({
154
+ clearSelection,
155
+ inSelectionMode,
156
+ });
157
+ </script>
158
+
159
+ <template>
160
+ <table class="min-w-full relative color-text">
161
+ <!-- Header -->
162
+ <thead>
163
+ <tr>
164
+ <!-- Collapse/expand details -->
165
+ <th
166
+ v-if="!!slots.details"
167
+ class="text-left border bg-caipira-primary"
168
+ :class="{
169
+ 'sticky top-0': props.stickyHeader,
170
+ [props.tableDataClass]: true,
171
+ }"
172
+ />
173
+
174
+ <!-- Selection -->
175
+ <th
176
+ v-if="props.selectable"
177
+ class="text-center w-12 bg-caipira-primary"
178
+ :class="{
179
+ 'sticky top-0': props.stickyHeader,
180
+ [props.tableDataClass]: true,
181
+ }"
182
+ >
183
+ <t-input-checkbox
184
+ v-model="selectedAll"
185
+ :is-indeterminate="isIndeterminate"
186
+ @input="onSelectAllChange"
187
+ />
188
+ </th>
189
+
190
+ <!-- Column header -->
191
+ <th
192
+ v-for="(column, index) in props.columns"
193
+ class="text-base text-left select-none px-2 py-2 font-normal bg-caipira-primary"
194
+ :key="index"
195
+ :class="{
196
+ 'sticky top-0': props.stickyHeader,
197
+ [props.tableDataClass]: true,
198
+ }"
199
+ >
200
+ {{ column.title ? column.title : "" }}
201
+ </th>
202
+ </tr>
203
+ </thead>
204
+
205
+ <!-- Body -->
206
+ <tbody>
207
+ <template
208
+ v-for="(row, index) in rows"
209
+ :key="row[props.rowKey]"
210
+ >
211
+ <!-- Row -->
212
+ <tr
213
+ class="cursor-pointer"
214
+ :class="{
215
+ 'bg-hover': selectedRows[row[props.rowKey]],
216
+ [props.rowClass]: true,
217
+ }"
218
+ @click="emit('row-click', row)"
219
+ >
220
+ <!-- Row details -->
221
+ <td
222
+ v-if="!!slots.details"
223
+ class="text-left"
224
+ :class="[props.tableDataClass]"
225
+ >
226
+ <div class="flex items-center">
227
+ <t-icon-button
228
+ v-if="'hasDetails' in row && row.hasDetails"
229
+ v-model="expandedRows[row[props.rowKey]]"
230
+ size="sm"
231
+ :icon="
232
+ expandedRows[row[props.rowKey]]
233
+ ? 'chevron-down'
234
+ : 'chevron-right'
235
+ "
236
+ @click="
237
+ expandedRows[row[props.rowKey]] =
238
+ !expandedRows[row[props.rowKey]]
239
+ "
240
+ />
241
+ </div>
242
+ </td>
243
+
244
+ <!-- Selection -->
245
+ <td
246
+ v-if="props.selectable"
247
+ class="text-center w-12"
248
+ :class="[props.tableDataClass]"
249
+ >
250
+ <t-input-checkbox
251
+ v-model="selectedRows[row[props.rowKey]]"
252
+ :initialize-value="true"
253
+ @click="onClickRow"
254
+ @input="
255
+ (checked: boolean) =>
256
+ onSelectRow(row[props.rowKey], checked)
257
+ "
258
+ />
259
+ </td>
260
+
261
+ <!-- Columns -->
262
+ <td
263
+ v-for="(column, index2) in props.columns"
264
+ class="whitespace-nowrap"
265
+ :class="{
266
+ [props.tableDataClass]: true,
267
+ }"
268
+ >
269
+ <!-- Skeleton, if loading -->
270
+ <template v-if="props.loading">
271
+ <div class="animate-pulse">
272
+ <div
273
+ class="h-4 bg-gray-100 my-1 mx-2 dark:bg-neutral-800 rounded"
274
+ />
275
+ </div>
276
+ </template>
277
+
278
+ <!-- Slot -->
279
+ <slot
280
+ v-else-if="'slot' in column && $slots[column.slot]"
281
+ :name="column.slot"
282
+ :row="row"
283
+ />
284
+
285
+ <!-- Property -->
286
+ <template v-else-if="'property' in column">
287
+ {{ row[column.property] }}
288
+ </template>
289
+ </td>
290
+ </tr>
291
+
292
+ <!-- Row details -->
293
+ <tr
294
+ v-if="slots.details && expandedRows[row[props.rowKey]]"
295
+ class="border-b"
296
+ >
297
+ <td :colspan="columnsLength">
298
+ <slot
299
+ name="details"
300
+ :row="row"
301
+ />
302
+ </td>
303
+ </tr>
304
+ </template>
305
+ </tbody>
306
+ </table>
307
+ </template>
308
+
309
+ <style scoped>
310
+ table > thead > tr {
311
+ border-top: 1px solid var(--border-color);
312
+ }
313
+
314
+ table th,
315
+ table td {
316
+ border-bottom: 1px solid var(--border-color);
317
+ }
318
+ </style>
@@ -0,0 +1,12 @@
1
+ import type { App, Plugin } from "vue";
2
+ import registerComponent from "@/plugins/register-component";
3
+
4
+ import Table from "./Table.vue";
5
+
6
+ export default {
7
+ install(app: App) {
8
+ registerComponent(app, Table);
9
+ },
10
+ } as Plugin;
11
+
12
+ export { Table };
@@ -0,0 +1,73 @@
1
+ <script lang="ts" setup>
2
+ import { ElementSize } from "@/enums/ui";
3
+
4
+ defineOptions({ name: "TTag" });
5
+
6
+ const props = withDefaults(defineProps<TagProps>(), {
7
+ text: "",
8
+ size: ElementSize.DEFAULT,
9
+ role: "",
10
+ color: "",
11
+ confirmClose: false,
12
+ hasCloseButton: false,
13
+ });
14
+
15
+ const emit = defineEmits<{
16
+ (e: "close"): void;
17
+ }>();
18
+ </script>
19
+
20
+ <template>
21
+ <div
22
+ :style="`background-color:${props.color}`"
23
+ :class="{
24
+ 'bg-neutral-700': !props.color,
25
+ }"
26
+ :role="props.role"
27
+ class="inline-flex items-center rounded-sm text-sm text-white w-max select-none"
28
+ >
29
+ <div
30
+ v-if="props.hasCloseButton"
31
+ class="bg-[#0000006b] hover:bg-[#000000a3] px-1 h-full"
32
+ >
33
+ <t-popconfirm
34
+ v-if="props.confirmClose"
35
+ title="Are you sure you want to remove this?"
36
+ placement="top"
37
+ class="h-full inline-flex items-center justify-center"
38
+ @confirm="emit('close')"
39
+ >
40
+ <t-icon
41
+ size="xs"
42
+ icon="close"
43
+ role="button"
44
+ aria-describedby="tooltip"
45
+ />
46
+ </t-popconfirm>
47
+ <t-icon
48
+ v-else="props.hasCloseButton"
49
+ size="xs"
50
+ icon="close"
51
+ role="button"
52
+ @click="emit('close')"
53
+ />
54
+ </div>
55
+ <div class="px-2 py-0.5">
56
+ <slot v-if="$slots.default" />
57
+ <span v-else>
58
+ {{ props.text }}
59
+ </span>
60
+ </div>
61
+ </div>
62
+ </template>
63
+
64
+ <script lang="ts">
65
+ export interface TagProps {
66
+ text?: string;
67
+ size?: ElementSize;
68
+ role?: string;
69
+ color?: string;
70
+ confirmClose?: boolean;
71
+ hasCloseButton?: boolean;
72
+ }
73
+ </script>
@@ -0,0 +1,12 @@
1
+ import type { App, Plugin } from "vue";
2
+ import registerComponent from "@/plugins/register-component";
3
+
4
+ import Tag from "./Tag.vue";
5
+
6
+ export default {
7
+ install(app: App) {
8
+ registerComponent(app, Tag);
9
+ },
10
+ } as Plugin;
11
+
12
+ export { Tag };
@@ -0,0 +1,75 @@
1
+ <script lang="ts" setup>
2
+ import { Message } from "@/types/ui";
3
+ import { ElementPosition, ElementVariant, Icon } from "@/enums/ui";
4
+
5
+ defineOptions({ name: "TToast" });
6
+
7
+ const props = defineProps<{
8
+ message: Message;
9
+ }>();
10
+
11
+ const emit = defineEmits(["close"]);
12
+
13
+ const getIcon = (variant: `${ElementVariant}`): `${Icon}` => {
14
+ switch (variant) {
15
+ case ElementVariant.SUCCESS:
16
+ return "check-circle";
17
+ case ElementVariant.WARNING:
18
+ return "alert-octagon";
19
+ case ElementVariant.DANGER:
20
+ return "close-circle";
21
+ default:
22
+ return "info-outline";
23
+ }
24
+ };
25
+
26
+ const getColor = (variant: `${ElementVariant}`): string => {
27
+ switch (variant) {
28
+ case ElementVariant.SUCCESS:
29
+ return "text-emerald-500";
30
+ case ElementVariant.WARNING:
31
+ return "text-amber-500";
32
+ case ElementVariant.DANGER:
33
+ return "text-red-400";
34
+ default:
35
+ return "text-blue-500";
36
+ }
37
+ };
38
+
39
+ const closeMessage = (id: Message["id"]) => {
40
+ emit("close", id);
41
+
42
+ // app.notifications.splice(
43
+ // app.notifications.findIndex((message: Message) => message.id === id),
44
+ // 1
45
+ // );
46
+ };
47
+ </script>
48
+
49
+ <template>
50
+ <div
51
+ class="shadow-md fixed flex bg-stone-100 dark:bg-zinc-700 w-min z-50 rounded px-4 py-2 text-base select-none"
52
+ :class="{
53
+ 'top-0 left-1/2 transform -translate-x-1/2':
54
+ props.message.position === ElementPosition.TOP,
55
+ }"
56
+ >
57
+ <t-icon
58
+ :icon="getIcon(props.message.variant)"
59
+ :class="[getColor(props.message.variant)]"
60
+ class="mr-2"
61
+ role="button"
62
+ />
63
+ <span
64
+ class="whitespace-nowrap overflow-x-hidden overflow-ellipsis max-w-2xl"
65
+ >
66
+ {{ props.message.message }}
67
+ </span>
68
+ <t-icon
69
+ icon="close"
70
+ class="text-stone-400 ml-4"
71
+ role="button"
72
+ @click="closeMessage(props.message.id)"
73
+ />
74
+ </div>
75
+ </template>
@@ -0,0 +1,12 @@
1
+ import type { App, Plugin } from "vue";
2
+ import registerComponent from "@/plugins/register-component";
3
+
4
+ import Toast from "./Toast.vue";
5
+
6
+ export default {
7
+ install(app: App) {
8
+ registerComponent(app, Toast);
9
+ },
10
+ } as Plugin;
11
+
12
+ export { Toast };
@@ -0,0 +1,43 @@
1
+ export * from "./Avatar";
2
+ export * from "./Backdrop";
3
+ export * from "./Button";
4
+ export * from "./ButtonCopy";
5
+ export * from "./Drawer";
6
+ export * from "./Dropdown";
7
+ export * from "./FileDrop";
8
+ export * from "./Form";
9
+ export * from "./FormItem";
10
+ export * from "./GraphyEmpty";
11
+ export * from "./GraphyLabel";
12
+ export * from "./GraphyPrice";
13
+ export * from "./GraphySubtitle";
14
+ export * from "./GraphyTitle";
15
+ export * from "./Icon";
16
+ export * from "./IconButton";
17
+ export * from "./InputAvatar";
18
+ export * from "./InputCheckbox";
19
+ export * from "./InputColor";
20
+ export * from "./InputDate";
21
+ export * from "./InputMultiplier";
22
+ export * from "./InputPassword";
23
+ export * from "./InputPhone";
24
+ export * from "./InputPrice";
25
+ export * from "./InputRadio";
26
+ export * from "./InputSelect";
27
+ export * from "./InputSwitch";
28
+ export * from "./InputText";
29
+ export * from "./InputTextarea";
30
+ export * from "./LineChart";
31
+ export * from "./Modal";
32
+ export * from "./ModalForm";
33
+ export * from "./Pagination";
34
+ export * from "./PieChart";
35
+ export * from "./Popconfirm";
36
+ export * from "./Popover";
37
+ export * from "./ProgressCircle";
38
+ export * from "./ProgressLine";
39
+ export * from "./SensitiveInfo";
40
+ export * from "./Tab";
41
+ export * from "./Table";
42
+ export * from "./Tag";
43
+ export * from "./Toast";