@gspa/ui 0.1.3 → 0.2.0

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 (280) hide show
  1. package/README.md +35 -0
  2. package/dist/Button.vue_vue_type_script_setup_true_lang-B3TkBTvG.js +205 -0
  3. package/dist/Button.vue_vue_type_script_setup_true_lang-DZxttvYH.cjs +1 -0
  4. package/dist/DataTable.css +1 -0
  5. package/dist/DataTableToolBar.css +1 -0
  6. package/dist/FormField.vue_vue_type_script_setup_true_lang-DimMUyA-.js +205 -0
  7. package/dist/FormField.vue_vue_type_script_setup_true_lang-mEO-VA6R.cjs +1 -0
  8. package/dist/Header.css +1 -0
  9. package/dist/Input.vue_vue_type_script_setup_true_lang-C1OQn24h.cjs +1 -0
  10. package/dist/Input.vue_vue_type_script_setup_true_lang-CpBoY97r.js +137 -0
  11. package/dist/Loader.css +1 -0
  12. package/dist/ReminderConfig.css +1 -0
  13. package/dist/ReusableForm.css +1 -0
  14. package/dist/Sidebar.css +1 -0
  15. package/dist/Toast.css +1 -0
  16. package/dist/_plugin-vue_export-helper-BHFhmbuH.cjs +1 -0
  17. package/dist/_plugin-vue_export-helper-CHgC5LLL.js +9 -0
  18. package/dist/components/Accordion.cjs +1 -0
  19. package/dist/components/Accordion.js +192 -0
  20. package/dist/components/AccordionItem.cjs +1 -0
  21. package/dist/components/AccordionItem.js +109 -0
  22. package/dist/components/AddReminderModal.cjs +1 -0
  23. package/dist/components/AddReminderModal.js +107 -0
  24. package/dist/components/Alert.cjs +1 -0
  25. package/dist/components/Alert.js +227 -0
  26. package/dist/components/Avatar.cjs +1 -0
  27. package/dist/components/Avatar.js +86 -0
  28. package/dist/components/Badge.cjs +1 -0
  29. package/dist/components/Badge.js +109 -0
  30. package/dist/components/Breadcrumb.cjs +1 -0
  31. package/dist/components/Breadcrumb.js +72 -0
  32. package/dist/components/Button.cjs +1 -0
  33. package/dist/components/Button.js +4 -0
  34. package/dist/components/ButtonGroup.cjs +1 -0
  35. package/dist/components/ButtonGroup.js +46 -0
  36. package/dist/components/Calendar.cjs +1 -0
  37. package/dist/components/Calendar.js +341 -0
  38. package/dist/components/Card.cjs +1 -0
  39. package/dist/components/Card.js +316 -0
  40. package/dist/components/CardBody.cjs +1 -0
  41. package/dist/components/CardBody.js +34 -0
  42. package/dist/components/CardContent.cjs +1 -0
  43. package/dist/components/CardContent.js +17 -0
  44. package/dist/components/CardFooter.cjs +1 -0
  45. package/dist/components/CardFooter.js +34 -0
  46. package/dist/components/CardHeader.cjs +1 -0
  47. package/dist/components/CardHeader.js +91 -0
  48. package/dist/components/CardTitle.cjs +1 -0
  49. package/dist/components/CardTitle.js +17 -0
  50. package/dist/components/Checkbox.cjs +1 -0
  51. package/dist/components/Checkbox.js +185 -0
  52. package/dist/components/CircularProgress.cjs +1 -0
  53. package/dist/components/CircularProgress.js +141 -0
  54. package/dist/components/DataTable.cjs +1 -0
  55. package/dist/components/DataTable.js +863 -0
  56. package/dist/components/DataTableCell.cjs +1 -0
  57. package/dist/components/DataTableCell.js +95 -0
  58. package/dist/components/DataTableFilters.cjs +1 -0
  59. package/dist/components/DataTableFilters.js +519 -0
  60. package/dist/components/DataTableHeader.cjs +1 -0
  61. package/dist/components/DataTableHeader.js +116 -0
  62. package/dist/components/DataTablePagination.cjs +1 -0
  63. package/dist/components/DataTablePagination.js +290 -0
  64. package/dist/components/DataTableRow.cjs +1 -0
  65. package/dist/components/DataTableRow.js +199 -0
  66. package/dist/components/DataTableToolBar.cjs +1 -0
  67. package/dist/components/DataTableToolBar.js +477 -0
  68. package/dist/components/DatePicker.cjs +1 -0
  69. package/dist/components/DatePicker.js +401 -0
  70. package/dist/components/Divider.cjs +1 -0
  71. package/dist/components/Divider.js +103 -0
  72. package/dist/components/Dropdown.cjs +1 -0
  73. package/dist/components/Dropdown.js +104 -0
  74. package/dist/components/DropdownItem.cjs +1 -0
  75. package/dist/components/DropdownItem.js +60 -0
  76. package/dist/components/EventsCalendar.cjs +1 -0
  77. package/dist/components/EventsCalendar.js +863 -0
  78. package/dist/components/FileUpload.cjs +1 -0
  79. package/dist/components/FileUpload.js +195 -0
  80. package/dist/components/FilterDrawer.cjs +1 -0
  81. package/dist/components/FilterDrawer.js +412 -0
  82. package/dist/components/Footer.cjs +1 -0
  83. package/dist/components/Footer.js +157 -0
  84. package/dist/components/FormField.cjs +1 -0
  85. package/dist/components/FormField.js +4 -0
  86. package/dist/components/Graph.cjs +1 -0
  87. package/dist/components/Graph.js +164 -0
  88. package/dist/components/GraphFilters.cjs +1 -0
  89. package/dist/components/GraphFilters.js +305 -0
  90. package/dist/components/Header.cjs +1 -0
  91. package/dist/components/Header.js +674 -0
  92. package/dist/components/Icon.cjs +1 -0
  93. package/dist/components/Icon.js +58 -0
  94. package/dist/components/Image.cjs +1 -0
  95. package/dist/components/Image.js +112 -0
  96. package/dist/components/Input.cjs +1 -0
  97. package/dist/components/Input.js +4 -0
  98. package/dist/components/InputGroup.cjs +1 -0
  99. package/dist/components/InputGroup.js +45 -0
  100. package/dist/components/Label.cjs +1 -0
  101. package/dist/components/Label.js +46 -0
  102. package/dist/components/Link.cjs +1 -0
  103. package/dist/components/Link.js +119 -0
  104. package/dist/components/ListItem.cjs +1 -0
  105. package/dist/components/ListItem.js +89 -0
  106. package/dist/components/Loader.cjs +1 -0
  107. package/dist/components/Loader.js +154 -0
  108. package/dist/components/Logo.cjs +1 -0
  109. package/dist/components/Logo.js +67 -0
  110. package/dist/components/MenuItem.cjs +1 -0
  111. package/dist/components/MenuItem.js +66 -0
  112. package/dist/components/Modal.cjs +1 -0
  113. package/dist/components/Modal.js +110 -0
  114. package/dist/components/ModalBody.cjs +1 -0
  115. package/dist/components/ModalBody.js +33 -0
  116. package/dist/components/ModalFooter.cjs +1 -0
  117. package/dist/components/ModalFooter.js +33 -0
  118. package/dist/components/ModalHeader.cjs +1 -0
  119. package/dist/components/ModalHeader.js +24 -0
  120. package/dist/components/MultiSelect.cjs +1 -0
  121. package/dist/components/MultiSelect.js +211 -0
  122. package/dist/components/Notification.cjs +1 -0
  123. package/dist/components/Notification.js +121 -0
  124. package/dist/components/Option.cjs +1 -0
  125. package/dist/components/Option.js +44 -0
  126. package/dist/components/Progress.cjs +1 -0
  127. package/dist/components/Progress.js +77 -0
  128. package/dist/components/ProgressBar.cjs +1 -0
  129. package/dist/components/ProgressBar.js +101 -0
  130. package/dist/components/Radio.cjs +1 -0
  131. package/dist/components/Radio.js +81 -0
  132. package/dist/components/RailNav.cjs +1 -0
  133. package/dist/components/RailNav.js +124 -0
  134. package/dist/components/ReminderConfig.cjs +1 -0
  135. package/dist/components/ReminderConfig.js +375 -0
  136. package/dist/components/ReusableForm.cjs +1 -0
  137. package/dist/components/ReusableForm.js +686 -0
  138. package/dist/components/ReusableFormModal.cjs +1 -0
  139. package/dist/components/ReusableFormModal.js +112 -0
  140. package/dist/components/RightDrawer.cjs +1 -0
  141. package/dist/components/RightDrawer.js +143 -0
  142. package/dist/components/Search.cjs +1 -0
  143. package/dist/components/Search.js +252 -0
  144. package/dist/components/Select.cjs +1 -0
  145. package/dist/components/Select.js +243 -0
  146. package/dist/components/Sidebar.cjs +1 -0
  147. package/dist/components/Sidebar.js +372 -0
  148. package/dist/components/Slider.cjs +1 -0
  149. package/dist/components/Slider.js +42 -0
  150. package/dist/components/Spinner.cjs +1 -0
  151. package/dist/components/Spinner.js +87 -0
  152. package/dist/components/Stepper.cjs +1 -0
  153. package/dist/components/Stepper.js +12 -0
  154. package/dist/components/StepperItem.cjs +1 -0
  155. package/dist/components/StepperItem.js +33 -0
  156. package/dist/components/Switch.cjs +1 -0
  157. package/dist/components/Switch.js +112 -0
  158. package/dist/components/Tab.cjs +1 -0
  159. package/dist/components/Tab.js +134 -0
  160. package/dist/components/TabPanel.cjs +1 -0
  161. package/dist/components/TabPanel.js +49 -0
  162. package/dist/components/Text.cjs +1 -0
  163. package/dist/components/Text.js +84 -0
  164. package/dist/components/Textarea.cjs +1 -0
  165. package/dist/components/Textarea.js +102 -0
  166. package/dist/components/ThemeConfigurator.cjs +1 -0
  167. package/dist/components/ThemeConfigurator.js +73 -0
  168. package/dist/components/Timeline.cjs +1 -0
  169. package/dist/components/Timeline.js +24 -0
  170. package/dist/components/TimelineItem.cjs +1 -0
  171. package/dist/components/TimelineItem.js +63 -0
  172. package/dist/components/Toast.cjs +1 -0
  173. package/dist/components/Toast.js +231 -0
  174. package/dist/components/Tooltip.cjs +1 -0
  175. package/dist/components/Tooltip.js +124 -0
  176. package/dist/components/Typography.cjs +1 -0
  177. package/dist/components/Typography.js +267 -0
  178. package/dist/components/charts/BarChart.cjs +1 -0
  179. package/dist/components/charts/BarChart.js +323 -0
  180. package/dist/components/charts/LineChart.cjs +1 -0
  181. package/dist/components/charts/LineChart.js +322 -0
  182. package/dist/components/charts/PieChart.cjs +1 -0
  183. package/dist/components/charts/PieChart.js +311 -0
  184. package/dist/components/charts/StackedBarChart.cjs +1 -0
  185. package/dist/components/charts/StackedBarChart.js +348 -0
  186. package/dist/components/widgets/DashboardWidget.cjs +1 -0
  187. package/dist/components/widgets/DashboardWidget.js +309 -0
  188. package/dist/directives/tooltip.cjs +47 -0
  189. package/dist/directives/tooltip.js +115 -0
  190. package/dist/gspa-ui.css +1 -1
  191. package/dist/index.cjs +1 -0
  192. package/dist/index.esm.js +315 -19546
  193. package/dist/layouts/AuthLayout.cjs +1 -0
  194. package/dist/layouts/AuthLayout.js +188 -0
  195. package/dist/layouts/DashboardLayout.cjs +1 -0
  196. package/dist/layouts/DashboardLayout.js +244 -0
  197. package/dist/layouts/DefaultLayout.cjs +1 -0
  198. package/dist/layouts/DefaultLayout.js +94 -0
  199. package/dist/layouts/ErrorLayout.cjs +1 -0
  200. package/dist/layouts/ErrorLayout.js +452 -0
  201. package/dist/lib/auth.cjs +1 -0
  202. package/dist/lib/auth.js +4 -0
  203. package/dist/lib/form-field.cjs +1 -0
  204. package/dist/lib/form-field.js +4 -0
  205. package/dist/lib/icon.cjs +1 -0
  206. package/dist/lib/icon.js +4 -0
  207. package/dist/lib/theme.cjs +1 -0
  208. package/dist/lib/theme.js +145 -0
  209. package/dist/lib/toast.cjs +1 -0
  210. package/dist/lib/toast.js +81 -0
  211. package/dist/src/components/Alert.vue.d.ts.map +1 -1
  212. package/dist/src/components/Button.vue.d.ts +127 -29
  213. package/dist/src/components/Button.vue.d.ts.map +1 -1
  214. package/dist/src/components/Checkbox.vue.d.ts +2 -2
  215. package/dist/src/components/DataTable.vue.d.ts +1 -1
  216. package/dist/src/components/FormField.vue.d.ts +106 -38
  217. package/dist/src/components/FormField.vue.d.ts.map +1 -1
  218. package/dist/src/components/Icon.vue.d.ts.map +1 -1
  219. package/dist/src/components/Input.vue.d.ts +137 -33
  220. package/dist/src/components/Input.vue.d.ts.map +1 -1
  221. package/dist/src/components/ReusableForm.vue.d.ts +1 -1
  222. package/dist/src/components/ReusableForm.vue.d.ts.map +1 -1
  223. package/dist/src/components/ReusableFormModal.vue.d.ts +1 -1
  224. package/dist/src/components/Textarea.vue.d.ts +2 -2
  225. package/dist/src/index.d.ts +9 -4
  226. package/dist/src/index.d.ts.map +1 -1
  227. package/dist/src/layouts/AuthLayout.vue.d.ts +2 -0
  228. package/dist/src/layouts/AuthLayout.vue.d.ts.map +1 -1
  229. package/dist/src/lib/form-field.d.ts +2 -0
  230. package/dist/src/lib/form-field.d.ts.map +1 -0
  231. package/dist/src/lib/icon.d.ts +2 -0
  232. package/dist/src/lib/icon.d.ts.map +1 -0
  233. package/dist/src/lib/theme.d.ts +4 -0
  234. package/dist/src/lib/theme.d.ts.map +1 -1
  235. package/dist/src/types.d.ts +44 -0
  236. package/dist/src/types.d.ts.map +1 -0
  237. package/dist/styles/auth-layout.css +1 -0
  238. package/dist/styles/button.css +1 -0
  239. package/dist/styles/form-field.css +1 -0
  240. package/dist/styles/input.css +1 -0
  241. package/dist/styles/tokens.css +1 -0
  242. package/dist/tsconfig.tsbuildinfo +1 -1
  243. package/dist/utils/cn.cjs +1 -0
  244. package/dist/utils/cn.js +7 -0
  245. package/package.json +45 -8
  246. package/dist/index.js +0 -605
  247. package/dist/src/__tests__/Alert.spec.d.ts +0 -2
  248. package/dist/src/__tests__/Alert.spec.d.ts.map +0 -1
  249. package/dist/src/__tests__/App.spec.d.ts +0 -2
  250. package/dist/src/__tests__/App.spec.d.ts.map +0 -1
  251. package/dist/src/__tests__/AuthLayout.spec.d.ts +0 -2
  252. package/dist/src/__tests__/AuthLayout.spec.d.ts.map +0 -1
  253. package/dist/src/__tests__/Badge.spec.d.ts +0 -2
  254. package/dist/src/__tests__/Badge.spec.d.ts.map +0 -1
  255. package/dist/src/__tests__/Button.spec.d.ts +0 -2
  256. package/dist/src/__tests__/Button.spec.d.ts.map +0 -1
  257. package/dist/src/__tests__/Card.spec.d.ts +0 -2
  258. package/dist/src/__tests__/Card.spec.d.ts.map +0 -1
  259. package/dist/src/__tests__/Checkbox.spec.d.ts +0 -2
  260. package/dist/src/__tests__/Checkbox.spec.d.ts.map +0 -1
  261. package/dist/src/__tests__/Dropdown.spec.d.ts +0 -2
  262. package/dist/src/__tests__/Dropdown.spec.d.ts.map +0 -1
  263. package/dist/src/__tests__/Input.spec.d.ts +0 -2
  264. package/dist/src/__tests__/Input.spec.d.ts.map +0 -1
  265. package/dist/src/__tests__/Modal.spec.d.ts +0 -2
  266. package/dist/src/__tests__/Modal.spec.d.ts.map +0 -1
  267. package/dist/src/__tests__/Radio.spec.d.ts +0 -2
  268. package/dist/src/__tests__/Radio.spec.d.ts.map +0 -1
  269. package/dist/src/__tests__/ReusableForm.spec.d.ts +0 -2
  270. package/dist/src/__tests__/ReusableForm.spec.d.ts.map +0 -1
  271. package/dist/src/__tests__/Tabs.spec.d.ts +0 -2
  272. package/dist/src/__tests__/Tabs.spec.d.ts.map +0 -1
  273. package/dist/src/__tests__/integration/CardIntegration.spec.d.ts +0 -2
  274. package/dist/src/__tests__/integration/CardIntegration.spec.d.ts.map +0 -1
  275. package/dist/src/__tests__/integration/FormIntegration.spec.d.ts +0 -2
  276. package/dist/src/__tests__/integration/FormIntegration.spec.d.ts.map +0 -1
  277. package/dist/src/__tests__/integration/ModalIntegration.spec.d.ts +0 -2
  278. package/dist/src/__tests__/integration/ModalIntegration.spec.d.ts.map +0 -1
  279. package/dist/src/__tests__/integration/NavigationIntegration.spec.d.ts +0 -2
  280. package/dist/src/__tests__/integration/NavigationIntegration.spec.d.ts.map +0 -1
@@ -0,0 +1,322 @@
1
+ import { ref as $, computed as u, onMounted as J, onBeforeUnmount as K, createElementBlock as i, openBlock as r, createCommentVNode as c, createElementVNode as M, Fragment as x, renderList as m, normalizeClass as y, toDisplayString as p, withDirectives as Q, vShow as _ } from "vue";
2
+ const ee = ["width", "height", "viewBox"], te = { key: 0 }, le = ["x1", "y1", "x2", "y2", "stroke"], ae = ["d", "stroke", "stroke-width"], ne = { key: 1 }, oe = ["cx", "cy", "r", "fill", "stroke", "onMouseenter"], ie = { key: 2 }, re = ["x", "y"], ue = ["d", "fill", "fill-opacity"], se = { key: 4 }, de = ["x", "y", "text-anchor", "transform"], he = { key: 5 }, ce = ["x", "y"], fe = { key: 6 }, ge = ["x", "y", "width", "height", "fill", "stroke"], ve = ["x", "y"], me = {
3
+ __name: "LineChart",
4
+ props: {
5
+ data: {
6
+ type: Array,
7
+ required: !0
8
+ },
9
+ labels: {
10
+ type: Array,
11
+ default: () => []
12
+ },
13
+ width: {
14
+ type: [Number, String],
15
+ default: "auto"
16
+ },
17
+ height: {
18
+ type: [Number, String],
19
+ default: "auto"
20
+ },
21
+ padding: {
22
+ type: Object,
23
+ default: () => ({ top: 20, right: 20, bottom: 60, left: 60 })
24
+ },
25
+ showGrid: {
26
+ type: Boolean,
27
+ default: !0
28
+ },
29
+ showXAxis: {
30
+ type: Boolean,
31
+ default: !0
32
+ },
33
+ showYAxis: {
34
+ type: Boolean,
35
+ default: !0
36
+ },
37
+ showPoints: {
38
+ type: Boolean,
39
+ default: !0
40
+ },
41
+ showValues: {
42
+ type: Boolean,
43
+ default: !0
44
+ },
45
+ valueSuffix: {
46
+ type: String,
47
+ default: ""
48
+ },
49
+ fillArea: {
50
+ type: Boolean,
51
+ default: !1
52
+ },
53
+ gridColor: {
54
+ type: String,
55
+ default: "#e5e7eb"
56
+ },
57
+ lineColor: {
58
+ type: String,
59
+ default: "#3b82f6"
60
+ },
61
+ strokeWidth: {
62
+ type: Number,
63
+ default: 2
64
+ },
65
+ pointRadius: {
66
+ type: Number,
67
+ default: 4
68
+ },
69
+ pointColor: {
70
+ type: String,
71
+ default: "#ffffff"
72
+ },
73
+ fillColor: {
74
+ type: String,
75
+ default: "#3b82f6"
76
+ },
77
+ fillOpacity: {
78
+ type: Number,
79
+ default: 0.1
80
+ },
81
+ lineClasses: {
82
+ type: String,
83
+ default: "transition-all duration-200"
84
+ },
85
+ pointClasses: {
86
+ type: String,
87
+ default: "transition-all duration-200 hover:r-6 cursor-pointer"
88
+ },
89
+ axisLabelClasses: {
90
+ type: String,
91
+ default: "fill-(--ui-text) text-xs font-medium"
92
+ },
93
+ autoSkipXAxisLabels: {
94
+ type: Boolean,
95
+ default: !0
96
+ },
97
+ minLabelSpacing: {
98
+ type: Number,
99
+ default: 72
100
+ },
101
+ maxLabelLength: {
102
+ type: Number,
103
+ default: 16
104
+ },
105
+ rotateLabelsWhenDense: {
106
+ type: Boolean,
107
+ default: !0
108
+ },
109
+ labelRotationDegrees: {
110
+ type: Number,
111
+ default: -35
112
+ },
113
+ tooltipBackground: {
114
+ type: String,
115
+ default: "#1f2937"
116
+ },
117
+ tooltipBorder: {
118
+ type: String,
119
+ default: "#374151"
120
+ },
121
+ tooltipTextClasses: {
122
+ type: String,
123
+ default: "fill-white text-xs font-semibold"
124
+ },
125
+ maxValue: {
126
+ type: Number,
127
+ default: null
128
+ }
129
+ },
130
+ emits: ["point-click", "point-hover"],
131
+ setup(n, { emit: P }) {
132
+ const t = n, D = P, w = $(null), g = $({ width: 0, height: 0 });
133
+ let b = null;
134
+ const s = $({
135
+ visible: !1,
136
+ x: 0,
137
+ y: 0,
138
+ width: 0,
139
+ height: 0,
140
+ content: ""
141
+ }), v = u(() => {
142
+ const e = Number(t.width);
143
+ return Number.isFinite(e) && e > 0 ? e : g.value.width > 0 ? g.value.width : 400;
144
+ }), h = u(() => {
145
+ const e = Number(t.height);
146
+ return Number.isFinite(e) && e > 0 ? e : g.value.height > 0 ? g.value.height : 300;
147
+ }), C = u(() => {
148
+ if (t.maxValue && t.maxValue > 0) return t.maxValue;
149
+ const e = t.data.map((a) => Number(a) || 0), l = Math.max(0, ...e);
150
+ return l > 0 ? l : 1;
151
+ }), d = u(() => t.data.map((e, l) => ({
152
+ x: k(l),
153
+ y: F(e),
154
+ value: e
155
+ }))), T = u(() => d.value.length === 0 ? "" : d.value.map((l, a) => `${a === 0 ? "M" : "L"} ${l.x} ${l.y}`).join(" ")), W = u(() => {
156
+ if (d.value.length === 0) return "";
157
+ const e = d.value.map((o, f) => `${f === 0 ? "M" : "L"} ${o.x} ${o.y}`).join(" "), l = h.value - t.padding.bottom, a = `L ${d.value[d.value.length - 1].x} ${l} L ${d.value[0].x} ${l} Z`;
158
+ return e + " " + a;
159
+ }), A = u(() => {
160
+ const e = [], l = h.value - t.padding.top - t.padding.bottom, a = 5;
161
+ for (let o = 0; o <= a; o++) {
162
+ const f = t.padding.top + l / a * o;
163
+ e.push(f);
164
+ }
165
+ return e;
166
+ }), N = u(() => v.value - t.padding.left - t.padding.right), B = u(() => {
167
+ if (!t.autoSkipXAxisLabels || !t.labels.length) return 1;
168
+ const e = Math.max(1, Math.floor(N.value / Math.max(1, t.minLabelSpacing)));
169
+ return Math.max(1, Math.ceil(t.labels.length / e));
170
+ }), L = u(() => t.rotateLabelsWhenDense ? B.value > 1 : !1), X = u(() => h.value - t.padding.bottom + (L.value ? 28 : 20)), H = u(() => L.value ? "end" : "middle"), V = u(() => {
171
+ const e = t.padding.left, l = v.value - t.padding.right - s.value.width, a = s.value.x - s.value.width / 2;
172
+ return Math.min(Math.max(a, e), Math.max(e, l));
173
+ }), R = u(() => {
174
+ const e = s.value.y - s.value.height - 10, l = t.padding.top + 4;
175
+ return Math.max(e, l);
176
+ }), O = u(() => V.value + s.value.width / 2), z = u(() => R.value + s.value.height / 2 + 0.5), k = (e) => {
177
+ const l = N.value / (t.data.length - 1 || 1);
178
+ return t.padding.left + e * l;
179
+ }, F = (e) => {
180
+ const l = h.value - t.padding.top - t.padding.bottom, a = l / C.value;
181
+ return t.padding.top + l - e * a;
182
+ }, j = (e) => {
183
+ const l = h.value - t.padding.top - t.padding.bottom, a = (h.value - t.padding.bottom - e) / l * C.value;
184
+ return S(Math.round(a));
185
+ }, S = (e) => `${e}${t.valueSuffix}`, E = (e, l) => {
186
+ const a = t.labels[l] || `Point ${l + 1}`, o = Number(e.value), f = Number.isFinite(o) ? o.toLocaleString() : String(e.value ?? 0), Y = `${a}: ${S(f)}`, I = Math.min(280, Math.max(120, Y.length * 7.2 + 20));
187
+ s.value = {
188
+ visible: !0,
189
+ x: Number(e.x) || 0,
190
+ y: Number(e.y) || 0,
191
+ width: I,
192
+ height: 28,
193
+ content: Y
194
+ }, D("point-hover", { value: e.value, index: l, label: a });
195
+ }, G = () => {
196
+ s.value.visible = !1;
197
+ }, q = (e) => !t.autoSkipXAxisLabels || t.labels.length <= 2 ? !0 : e % B.value === 0 || e === t.labels.length - 1, U = (e) => {
198
+ const l = String(e ?? "");
199
+ return l ? !t.maxLabelLength || t.maxLabelLength <= 0 || l.length <= t.maxLabelLength ? l : `${l.slice(0, Math.max(1, t.maxLabelLength - 1))}…` : "";
200
+ }, Z = (e) => {
201
+ if (!L.value) return;
202
+ const l = k(e), a = X.value;
203
+ return `rotate(${t.labelRotationDegrees} ${l} ${a})`;
204
+ };
205
+ return J(() => {
206
+ b = new ResizeObserver((e) => {
207
+ const l = e[0];
208
+ if (!l) return;
209
+ const { width: a, height: o } = l.contentRect;
210
+ g.value = {
211
+ width: Math.round(a),
212
+ height: Math.round(o)
213
+ };
214
+ }), w.value && b.observe(w.value);
215
+ }), K(() => {
216
+ b && b.disconnect();
217
+ }), (e, l) => (r(), i("div", {
218
+ ref_key: "containerRef",
219
+ ref: w,
220
+ class: "ui-surface w-full h-full"
221
+ }, [
222
+ (r(), i("svg", {
223
+ width: v.value,
224
+ height: h.value,
225
+ viewBox: `0 0 ${v.value} ${h.value}`,
226
+ class: "block mx-auto overflow-visible"
227
+ }, [
228
+ n.showGrid ? (r(), i("g", te, [
229
+ (r(!0), i(x, null, m(A.value, (a) => (r(), i("line", {
230
+ key: `grid-${a}`,
231
+ x1: n.padding.left,
232
+ y1: a,
233
+ x2: v.value - n.padding.right,
234
+ y2: a,
235
+ stroke: n.gridColor,
236
+ "stroke-width": "1",
237
+ "stroke-dasharray": "2,2"
238
+ }, null, 8, le))), 128))
239
+ ])) : c("", !0),
240
+ M("path", {
241
+ d: T.value,
242
+ stroke: n.lineColor,
243
+ "stroke-width": n.strokeWidth,
244
+ fill: "none",
245
+ class: y(n.lineClasses)
246
+ }, null, 10, ae),
247
+ n.showPoints ? (r(), i("g", ne, [
248
+ (r(!0), i(x, null, m(d.value, (a, o) => (r(), i("circle", {
249
+ key: `point-${o}`,
250
+ cx: a.x,
251
+ cy: a.y,
252
+ r: n.pointRadius,
253
+ fill: n.pointColor,
254
+ stroke: n.lineColor,
255
+ "stroke-width": 2,
256
+ class: y(n.pointClasses),
257
+ onMouseenter: (f) => E(a, o),
258
+ onMouseleave: G
259
+ }, null, 42, oe))), 128))
260
+ ])) : c("", !0),
261
+ n.showValues ? (r(), i("g", ie, [
262
+ (r(!0), i(x, null, m(d.value, (a, o) => (r(), i("text", {
263
+ key: `value-${o}`,
264
+ x: a.x,
265
+ y: a.y - 10,
266
+ class: "fill-(--ui-text) text-[10px] font-semibold",
267
+ "text-anchor": "middle"
268
+ }, p(S(a.value)), 9, re))), 128))
269
+ ])) : c("", !0),
270
+ n.fillArea ? (r(), i("path", {
271
+ key: 3,
272
+ d: W.value,
273
+ fill: n.fillColor,
274
+ "fill-opacity": n.fillOpacity
275
+ }, null, 8, ue)) : c("", !0),
276
+ n.showXAxis ? (r(), i("g", se, [
277
+ (r(!0), i(x, null, m(n.labels, (a, o) => Q((r(), i("text", {
278
+ key: `xlabel-${o}`,
279
+ x: k(o),
280
+ y: X.value,
281
+ class: y(n.axisLabelClasses),
282
+ "text-anchor": H.value,
283
+ transform: Z(o)
284
+ }, p(U(a)), 11, de)), [
285
+ [_, q(o)]
286
+ ])), 128))
287
+ ])) : c("", !0),
288
+ n.showYAxis ? (r(), i("g", he, [
289
+ (r(!0), i(x, null, m(A.value, (a) => (r(), i("text", {
290
+ key: `ylabel-${a}`,
291
+ x: n.padding.left - 10,
292
+ y: a + 4,
293
+ class: y(n.axisLabelClasses),
294
+ "text-anchor": "end"
295
+ }, p(j(a)), 11, ce))), 128))
296
+ ])) : c("", !0),
297
+ s.value.visible ? (r(), i("g", fe, [
298
+ M("rect", {
299
+ x: V.value,
300
+ y: R.value,
301
+ width: s.value.width,
302
+ height: s.value.height,
303
+ fill: n.tooltipBackground,
304
+ stroke: n.tooltipBorder,
305
+ "stroke-width": "1",
306
+ rx: "4"
307
+ }, null, 8, ge),
308
+ M("text", {
309
+ x: O.value,
310
+ y: z.value,
311
+ class: y(n.tooltipTextClasses),
312
+ "text-anchor": "middle",
313
+ "dominant-baseline": "middle"
314
+ }, p(s.value.content), 11, ve)
315
+ ])) : c("", !0)
316
+ ], 8, ee))
317
+ ], 512));
318
+ }
319
+ };
320
+ export {
321
+ me as default
322
+ };
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("vue"),Z={key:0,class:"ui-surface w-full h-full flex items-center justify-center"},U=["width","height","viewBox"],G=["d","fill","stroke","stroke-width","onMouseenter","onClick"],J=["cx","cy","r","fill"],K={key:1},Q=["x","y"],ee=["x","y"],te={key:2},le=["x","y"],oe={key:3},ae=["transform"],ne=["fill"],se={class:"ui-surface ui-text px-4 py-3 rounded-lg shadow-2xl border ui-border-strong min-w-[180px]"},re={class:"flex items-center gap-2 mb-1.5"},ie={class:"font-semibold text-sm"},ue={class:"flex items-baseline gap-2 ml-5"},ce={class:"text-2xl font-bold"},de={class:"mt-1 ml-5"},me={class:"text-xs ui-text"},_=2,T=24,he={__name:"PieChart",props:{data:{type:Array,required:!0},labels:{type:Array,default:()=>[]},colors:{type:Array,default:()=>["#3b82f6","#ef4444","#10b981","#f59e0b","#8b5cf6","#ec4899","#14b8a6","#f97316"]},width:{type:[Number,String],default:"auto"},height:{type:[Number,String],default:"auto"},doughnut:{type:Boolean,default:!1},innerRadiusRatio:{type:Number,default:.6},showValues:{type:Boolean,default:!0},minLabelPercentage:{type:Number,default:3},showPercentages:{type:Boolean,default:!0},valueSuffix:{type:String,default:""},showLegend:{type:Boolean,default:!0},showCenterText:{type:Boolean,default:!0},legendPosition:{type:String,default:"bottom",validator:s=>["bottom","right"].includes(s)},strokeColor:{type:String,default:"#ffffff"},strokeWidth:{type:Number,default:2},centerFill:{type:String,default:"#ffffff"},sliceClasses:{type:String,default:"transition-all duration-200 hover:opacity-80 cursor-pointer"},valueLabelClasses:{type:String,default:"fill-(--ui-surface) text-sm font-bold drop-shadow-md"},centerTextClasses:{type:String,default:"fill-(--ui-text) text-2xl font-bold"},centerLabelClasses:{type:String,default:"fill-(--ui-text) text-sm"},legendTextClasses:{type:String,default:"fill-(--ui-text) text-xs font-medium"}},emits:["slice-click","slice-hover"],setup(s,{emit:A}){const n=s,z=A,B=e.ref(null),h=e.ref({width:0,height:0});let y=null;const i=e.computed(()=>{const t=Number(n.width);return Number.isFinite(t)&&t>0?t:h.value.width>0?h.value.width:400}),v=e.computed(()=>{const t=Number(n.height);return Number.isFinite(t)&&t>0?t:h.value.height>0?h.value.height:300}),u=e.ref({visible:!1,x:0,y:0,label:"",value:0,percentage:"0",color:""}),k=e.computed(()=>Array.isArray(n.data)?n.data.map(t=>Number(t)||0):[]),$=e.computed(()=>k.value.reduce((l,o)=>l+o,0)||0),R=e.computed(()=>k.value.length>0&&$.value>0),F=e.computed(()=>k.value.filter(t=>t>0).length),D=e.computed(()=>!n.showLegend||n.legendPosition!=="bottom"?0:Math.max(1,Math.ceil(F.value/_))),C=e.computed(()=>n.showLegend&&n.legendPosition==="bottom"?D.value*T+8:0),f=e.computed(()=>n.showLegend&&n.legendPosition==="right"?i.value/3:i.value/2),g=e.computed(()=>(v.value-C.value)/2),x=e.computed(()=>{const t=v.value-C.value,l=n.showLegend&&n.legendPosition==="right"?i.value*.6:i.value;return Math.max(12,Math.min(l,t)/2-40)}),M=e.computed(()=>n.doughnut?x.value*n.innerRadiusRatio:0),N=e.computed(()=>{if(!R.value)return[];const t=$.value;let l=-Math.PI/2;return k.value.map((o,a)=>{const r=o,c=(r/t*100).toFixed(1),p=r/t*2*Math.PI,d=l+p,w=H(f.value,g.value,x.value,M.value,l,d),b=n.doughnut?(x.value+M.value)/2:x.value*.7,m=l+p/2,V=f.value+Math.cos(m)*b,P=g.value+Math.sin(m)*b,L={value:r,percentage:c,path:w,labelX:V,labelY:P,label:n.labels[a]||`Item ${a+1}`,startAngle:l,endAngle:d};return l=d,L}).filter(o=>o.value>0)}),I=e.computed(()=>N.value.filter(t=>Number(t.percentage)>=n.minLabelPercentage)),H=(t,l,o,a,r,c)=>{const p=t+o*Math.cos(r),d=l+o*Math.sin(r),w=t+o*Math.cos(c),b=l+o*Math.sin(c),m=c-r>Math.PI?1:0;if(a===0)return`M ${t} ${l} L ${p} ${d} A ${o} ${o} 0 ${m} 1 ${w} ${b} Z`;{const V=t+a*Math.cos(c),P=l+a*Math.sin(c),L=t+a*Math.cos(r),q=l+a*Math.sin(r);return`M ${p} ${d} A ${o} ${o} 0 ${m} 1 ${w} ${b} L ${V} ${P} A ${a} ${a} 0 ${m} 0 ${L} ${q} Z`}},E=t=>n.colors[t%n.colors.length],X=t=>{if(n.legendPosition==="right")return i.value*.65;const o=t%_;return i.value/4+o*(i.value/2)},Y=t=>{if(n.legendPosition==="right")return 40+t*25;const o=Math.floor(t/_);return v.value-C.value+6+o*T},j=(t,l,o)=>{u.value={visible:!0,x:t.clientX,y:t.clientY,label:l.label,value:l.value,percentage:l.percentage,color:E(o)},z("slice-hover",{value:l.value,index:o,label:l.label,percentage:l.percentage})},W=()=>{u.value.visible=!1},O=(t,l)=>{z("slice-click",{value:t.value,index:l,label:t.label,percentage:t.percentage})},S=t=>`${t}${n.valueSuffix}`;return e.onMounted(()=>{y=new ResizeObserver(t=>{const l=t[0];if(!l)return;const{width:o,height:a}=l.contentRect;h.value={width:Math.round(o),height:Math.round(a)}}),B.value&&y.observe(B.value)}),e.onBeforeUnmount(()=>{y&&y.disconnect()}),(t,l)=>(e.openBlock(),e.createElementBlock("div",{ref_key:"containerRef",ref:B,class:"ui-surface w-full h-full relative"},[R.value?(e.openBlock(),e.createElementBlock("svg",{key:1,width:i.value,height:v.value,viewBox:`0 0 ${i.value} ${v.value}`,class:"block mx-auto overflow-visible"},[e.createElementVNode("g",null,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(N.value,(o,a)=>(e.openBlock(),e.createElementBlock("path",{key:`slice-${a}`,d:o.path,fill:E(a),stroke:s.strokeColor,"stroke-width":s.strokeWidth,class:e.normalizeClass(s.sliceClasses),onMouseenter:r=>j(r,o,a),onMouseleave:W,onClick:r=>O(o,a)},null,42,G))),128))]),s.doughnut?(e.openBlock(),e.createElementBlock("circle",{key:0,cx:f.value,cy:g.value,r:M.value,fill:s.centerFill},null,8,J)):e.createCommentVNode("",!0),s.doughnut&&s.showCenterText?(e.openBlock(),e.createElementBlock("g",K,[e.createElementVNode("text",{x:f.value,y:g.value-5,class:e.normalizeClass(s.centerTextClasses),"text-anchor":"middle","dominant-baseline":"middle"},e.toDisplayString(S($.value)),11,Q),e.createElementVNode("text",{x:f.value,y:g.value+15,class:e.normalizeClass(s.centerLabelClasses),"text-anchor":"middle","dominant-baseline":"middle"}," Total ",10,ee)])):e.createCommentVNode("",!0),s.showValues?(e.openBlock(),e.createElementBlock("g",te,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(I.value,(o,a)=>(e.openBlock(),e.createElementBlock("text",{key:`value-${a}`,x:o.labelX,y:o.labelY,class:e.normalizeClass(s.valueLabelClasses),"text-anchor":"middle","dominant-baseline":"middle"},e.toDisplayString(s.showPercentages?`${o.percentage}%`:S(o.value)),11,le))),128))])):e.createCommentVNode("",!0),s.showLegend?(e.openBlock(),e.createElementBlock("g",oe,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(N.value,(o,a)=>(e.openBlock(),e.createElementBlock("g",{key:`legend-${a}`,transform:`translate(${X(a)}, ${Y(a)})`},[e.createElementVNode("rect",{width:12,height:12,fill:E(a),rx:"2"},null,8,ne),e.createElementVNode("text",{x:18,y:10,class:e.normalizeClass(s.legendTextClasses)},e.toDisplayString(o.label),3)],8,ae))),128))])):e.createCommentVNode("",!0)],8,U)):(e.openBlock(),e.createElementBlock("div",Z,[...l[0]||(l[0]=[e.createStaticVNode('<div class="text-center"><div class="ui-text mb-2"><svg class="w-16 h-16 mx-auto" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M11 3.055A9.001 9.001 0 1020.945 13H11V3.055z"></path><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M20.488 9H15V3.512A9.025 9.025 0 0120.488 9z"></path></svg></div><p class="text-sm ui-text"> No data available </p></div>',1)])])),u.value.visible?(e.openBlock(),e.createElementBlock("div",{key:2,style:e.normalizeStyle({position:"fixed",left:`${u.value.x}px`,top:`${u.value.y}px`,transform:"translate(-50%, -120%)",pointerEvents:"none",zIndex:9999}),class:"animate-in fade-in duration-200"},[e.createElementVNode("div",se,[e.createElementVNode("div",re,[e.createElementVNode("div",{style:e.normalizeStyle({backgroundColor:u.value.color}),class:"w-3 h-3 rounded-full shadow-sm"},null,4),e.createElementVNode("p",ie,e.toDisplayString(u.value.label),1)]),e.createElementVNode("div",ue,[e.createElementVNode("span",ce,e.toDisplayString(S(u.value.value)),1)]),e.createElementVNode("div",de,[e.createElementVNode("span",me,e.toDisplayString(u.value.percentage)+"% of total",1)]),l[1]||(l[1]=e.createElementVNode("div",{class:"absolute bottom-0 left-1/2 transform -translate-x-1/2 translate-y-1/2 rotate-45 w-2 h-2 ui-surface border-r border-b ui-border-strong"},null,-1))])],4)):e.createCommentVNode("",!0)],512))}};exports.default=he;
@@ -0,0 +1,311 @@
1
+ import { ref as H, computed as n, onMounted as oe, onBeforeUnmount as se, createElementBlock as r, openBlock as i, createCommentVNode as k, createStaticVNode as ne, createElementVNode as u, Fragment as X, renderList as Y, normalizeClass as M, toDisplayString as m, normalizeStyle as D } from "vue";
2
+ const re = {
3
+ key: 0,
4
+ class: "ui-surface w-full h-full flex items-center justify-center"
5
+ }, ie = ["width", "height", "viewBox"], ue = ["d", "fill", "stroke", "stroke-width", "onMouseenter", "onClick"], ce = ["cx", "cy", "r", "fill"], de = { key: 1 }, he = ["x", "y"], ve = ["x", "y"], fe = { key: 2 }, ge = ["x", "y"], me = { key: 3 }, be = ["transform"], xe = ["fill"], ye = { class: "ui-surface ui-text px-4 py-3 rounded-lg shadow-2xl border ui-border-strong min-w-[180px]" }, pe = { class: "flex items-center gap-2 mb-1.5" }, we = { class: "font-semibold text-sm" }, $e = { class: "flex items-baseline gap-2 ml-5" }, ke = { class: "text-2xl font-bold" }, Me = { class: "mt-1 ml-5" }, Ce = { class: "text-xs ui-text" }, E = 2, O = 24, Pe = {
6
+ __name: "PieChart",
7
+ props: {
8
+ data: {
9
+ type: Array,
10
+ required: !0
11
+ },
12
+ labels: {
13
+ type: Array,
14
+ default: () => []
15
+ },
16
+ colors: {
17
+ type: Array,
18
+ default: () => ["#3b82f6", "#ef4444", "#10b981", "#f59e0b", "#8b5cf6", "#ec4899", "#14b8a6", "#f97316"]
19
+ },
20
+ width: {
21
+ type: [Number, String],
22
+ default: "auto"
23
+ },
24
+ height: {
25
+ type: [Number, String],
26
+ default: "auto"
27
+ },
28
+ doughnut: {
29
+ type: Boolean,
30
+ default: !1
31
+ },
32
+ innerRadiusRatio: {
33
+ type: Number,
34
+ default: 0.6
35
+ },
36
+ showValues: {
37
+ type: Boolean,
38
+ default: !0
39
+ },
40
+ minLabelPercentage: {
41
+ type: Number,
42
+ default: 3
43
+ },
44
+ showPercentages: {
45
+ type: Boolean,
46
+ default: !0
47
+ },
48
+ valueSuffix: {
49
+ type: String,
50
+ default: ""
51
+ },
52
+ showLegend: {
53
+ type: Boolean,
54
+ default: !0
55
+ },
56
+ showCenterText: {
57
+ type: Boolean,
58
+ default: !0
59
+ },
60
+ legendPosition: {
61
+ type: String,
62
+ default: "bottom",
63
+ validator: (s) => ["bottom", "right"].includes(s)
64
+ },
65
+ strokeColor: {
66
+ type: String,
67
+ default: "#ffffff"
68
+ },
69
+ strokeWidth: {
70
+ type: Number,
71
+ default: 2
72
+ },
73
+ centerFill: {
74
+ type: String,
75
+ default: "#ffffff"
76
+ },
77
+ sliceClasses: {
78
+ type: String,
79
+ default: "transition-all duration-200 hover:opacity-80 cursor-pointer"
80
+ },
81
+ valueLabelClasses: {
82
+ type: String,
83
+ default: "fill-(--ui-surface) text-sm font-bold drop-shadow-md"
84
+ },
85
+ centerTextClasses: {
86
+ type: String,
87
+ default: "fill-(--ui-text) text-2xl font-bold"
88
+ },
89
+ centerLabelClasses: {
90
+ type: String,
91
+ default: "fill-(--ui-text) text-sm"
92
+ },
93
+ legendTextClasses: {
94
+ type: String,
95
+ default: "fill-(--ui-text) text-xs font-medium"
96
+ }
97
+ },
98
+ emits: ["slice-click", "slice-hover"],
99
+ setup(s, { emit: Z }) {
100
+ const o = s, W = Z, N = H(null), b = H({ width: 0, height: 0 });
101
+ let C = null;
102
+ const d = n(() => {
103
+ const e = Number(o.width);
104
+ return Number.isFinite(e) && e > 0 ? e : b.value.width > 0 ? b.value.width : 400;
105
+ }), x = n(() => {
106
+ const e = Number(o.height);
107
+ return Number.isFinite(e) && e > 0 ? e : b.value.height > 0 ? b.value.height : 300;
108
+ }), h = H({
109
+ visible: !1,
110
+ x: 0,
111
+ y: 0,
112
+ label: "",
113
+ value: 0,
114
+ percentage: "0",
115
+ color: ""
116
+ }), S = n(() => Array.isArray(o.data) ? o.data.map((e) => Number(e) || 0) : []), _ = n(() => S.value.reduce((t, l) => t + l, 0) || 0), j = n(() => S.value.length > 0 && _.value > 0), q = n(() => S.value.filter((e) => e > 0).length), U = n(() => !o.showLegend || o.legendPosition !== "bottom" ? 0 : Math.max(1, Math.ceil(q.value / E))), B = n(() => o.showLegend && o.legendPosition === "bottom" ? U.value * O + 8 : 0), y = n(() => o.showLegend && o.legendPosition === "right" ? d.value / 3 : d.value / 2), p = n(() => (x.value - B.value) / 2), P = n(() => {
117
+ const e = x.value - B.value, t = o.showLegend && o.legendPosition === "right" ? d.value * 0.6 : d.value;
118
+ return Math.max(12, Math.min(t, e) / 2 - 40);
119
+ }), V = n(() => o.doughnut ? P.value * o.innerRadiusRatio : 0), R = n(() => {
120
+ if (!j.value) return [];
121
+ const e = _.value;
122
+ let t = -Math.PI / 2;
123
+ return S.value.map((l, a) => {
124
+ const c = l, v = (c / e * 100).toFixed(1), w = c / e * 2 * Math.PI, f = t + w, L = J(
125
+ y.value,
126
+ p.value,
127
+ P.value,
128
+ V.value,
129
+ t,
130
+ f
131
+ ), $ = o.doughnut ? (P.value + V.value) / 2 : P.value * 0.7, g = t + w / 2, T = y.value + Math.cos(g) * $, F = p.value + Math.sin(g) * $, I = {
132
+ value: c,
133
+ percentage: v,
134
+ path: L,
135
+ labelX: T,
136
+ labelY: F,
137
+ label: o.labels[a] || `Item ${a + 1}`,
138
+ startAngle: t,
139
+ endAngle: f
140
+ };
141
+ return t = f, I;
142
+ }).filter((l) => l.value > 0);
143
+ }), G = n(() => R.value.filter((e) => Number(e.percentage) >= o.minLabelPercentage)), J = (e, t, l, a, c, v) => {
144
+ const w = e + l * Math.cos(c), f = t + l * Math.sin(c), L = e + l * Math.cos(v), $ = t + l * Math.sin(v), g = v - c > Math.PI ? 1 : 0;
145
+ if (a === 0)
146
+ return `M ${e} ${t} L ${w} ${f} A ${l} ${l} 0 ${g} 1 ${L} ${$} Z`;
147
+ {
148
+ const T = e + a * Math.cos(v), F = t + a * Math.sin(v), I = e + a * Math.cos(c), ae = t + a * Math.sin(c);
149
+ return `M ${w} ${f} A ${l} ${l} 0 ${g} 1 ${L} ${$} L ${T} ${F} A ${a} ${a} 0 ${g} 0 ${I} ${ae} Z`;
150
+ }
151
+ }, z = (e) => o.colors[e % o.colors.length], K = (e) => {
152
+ if (o.legendPosition === "right")
153
+ return d.value * 0.65;
154
+ const l = e % E;
155
+ return d.value / 4 + l * (d.value / 2);
156
+ }, Q = (e) => {
157
+ if (o.legendPosition === "right")
158
+ return 40 + e * 25;
159
+ const l = Math.floor(e / E);
160
+ return x.value - B.value + 6 + l * O;
161
+ }, ee = (e, t, l) => {
162
+ h.value = {
163
+ visible: !0,
164
+ x: e.clientX,
165
+ y: e.clientY,
166
+ label: t.label,
167
+ value: t.value,
168
+ percentage: t.percentage,
169
+ color: z(l)
170
+ }, W("slice-hover", {
171
+ value: t.value,
172
+ index: l,
173
+ label: t.label,
174
+ percentage: t.percentage
175
+ });
176
+ }, te = () => {
177
+ h.value.visible = !1;
178
+ }, le = (e, t) => {
179
+ W("slice-click", {
180
+ value: e.value,
181
+ index: t,
182
+ label: e.label,
183
+ percentage: e.percentage
184
+ });
185
+ }, A = (e) => `${e}${o.valueSuffix}`;
186
+ return oe(() => {
187
+ C = new ResizeObserver((e) => {
188
+ const t = e[0];
189
+ if (!t) return;
190
+ const { width: l, height: a } = t.contentRect;
191
+ b.value = {
192
+ width: Math.round(l),
193
+ height: Math.round(a)
194
+ };
195
+ }), N.value && C.observe(N.value);
196
+ }), se(() => {
197
+ C && C.disconnect();
198
+ }), (e, t) => (i(), r("div", {
199
+ ref_key: "containerRef",
200
+ ref: N,
201
+ class: "ui-surface w-full h-full relative"
202
+ }, [
203
+ j.value ? (i(), r("svg", {
204
+ key: 1,
205
+ width: d.value,
206
+ height: x.value,
207
+ viewBox: `0 0 ${d.value} ${x.value}`,
208
+ class: "block mx-auto overflow-visible"
209
+ }, [
210
+ u("g", null, [
211
+ (i(!0), r(X, null, Y(R.value, (l, a) => (i(), r("path", {
212
+ key: `slice-${a}`,
213
+ d: l.path,
214
+ fill: z(a),
215
+ stroke: s.strokeColor,
216
+ "stroke-width": s.strokeWidth,
217
+ class: M(s.sliceClasses),
218
+ onMouseenter: (c) => ee(c, l, a),
219
+ onMouseleave: te,
220
+ onClick: (c) => le(l, a)
221
+ }, null, 42, ue))), 128))
222
+ ]),
223
+ s.doughnut ? (i(), r("circle", {
224
+ key: 0,
225
+ cx: y.value,
226
+ cy: p.value,
227
+ r: V.value,
228
+ fill: s.centerFill
229
+ }, null, 8, ce)) : k("", !0),
230
+ s.doughnut && s.showCenterText ? (i(), r("g", de, [
231
+ u("text", {
232
+ x: y.value,
233
+ y: p.value - 5,
234
+ class: M(s.centerTextClasses),
235
+ "text-anchor": "middle",
236
+ "dominant-baseline": "middle"
237
+ }, m(A(_.value)), 11, he),
238
+ u("text", {
239
+ x: y.value,
240
+ y: p.value + 15,
241
+ class: M(s.centerLabelClasses),
242
+ "text-anchor": "middle",
243
+ "dominant-baseline": "middle"
244
+ }, " Total ", 10, ve)
245
+ ])) : k("", !0),
246
+ s.showValues ? (i(), r("g", fe, [
247
+ (i(!0), r(X, null, Y(G.value, (l, a) => (i(), r("text", {
248
+ key: `value-${a}`,
249
+ x: l.labelX,
250
+ y: l.labelY,
251
+ class: M(s.valueLabelClasses),
252
+ "text-anchor": "middle",
253
+ "dominant-baseline": "middle"
254
+ }, m(s.showPercentages ? `${l.percentage}%` : A(l.value)), 11, ge))), 128))
255
+ ])) : k("", !0),
256
+ s.showLegend ? (i(), r("g", me, [
257
+ (i(!0), r(X, null, Y(R.value, (l, a) => (i(), r("g", {
258
+ key: `legend-${a}`,
259
+ transform: `translate(${K(a)}, ${Q(a)})`
260
+ }, [
261
+ u("rect", {
262
+ width: 12,
263
+ height: 12,
264
+ fill: z(a),
265
+ rx: "2"
266
+ }, null, 8, xe),
267
+ u("text", {
268
+ x: 18,
269
+ y: 10,
270
+ class: M(s.legendTextClasses)
271
+ }, m(l.label), 3)
272
+ ], 8, be))), 128))
273
+ ])) : k("", !0)
274
+ ], 8, ie)) : (i(), r("div", re, [...t[0] || (t[0] = [
275
+ ne('<div class="text-center"><div class="ui-text mb-2"><svg class="w-16 h-16 mx-auto" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M11 3.055A9.001 9.001 0 1020.945 13H11V3.055z"></path><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M20.488 9H15V3.512A9.025 9.025 0 0120.488 9z"></path></svg></div><p class="text-sm ui-text"> No data available </p></div>', 1)
276
+ ])])),
277
+ h.value.visible ? (i(), r("div", {
278
+ key: 2,
279
+ style: D({
280
+ position: "fixed",
281
+ left: `${h.value.x}px`,
282
+ top: `${h.value.y}px`,
283
+ transform: "translate(-50%, -120%)",
284
+ pointerEvents: "none",
285
+ zIndex: 9999
286
+ }),
287
+ class: "animate-in fade-in duration-200"
288
+ }, [
289
+ u("div", ye, [
290
+ u("div", pe, [
291
+ u("div", {
292
+ style: D({ backgroundColor: h.value.color }),
293
+ class: "w-3 h-3 rounded-full shadow-sm"
294
+ }, null, 4),
295
+ u("p", we, m(h.value.label), 1)
296
+ ]),
297
+ u("div", $e, [
298
+ u("span", ke, m(A(h.value.value)), 1)
299
+ ]),
300
+ u("div", Me, [
301
+ u("span", Ce, m(h.value.percentage) + "% of total", 1)
302
+ ]),
303
+ t[1] || (t[1] = u("div", { class: "absolute bottom-0 left-1/2 transform -translate-x-1/2 translate-y-1/2 rotate-45 w-2 h-2 ui-surface border-r border-b ui-border-strong" }, null, -1))
304
+ ])
305
+ ], 4)) : k("", !0)
306
+ ], 512));
307
+ }
308
+ };
309
+ export {
310
+ Pe as default
311
+ };
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("vue"),O={key:0,class:"absolute top-3 left-3 z-10 ui-surface border ui-border-strong rounded-md px-2.5 py-2"},R={class:"flex items-center gap-3 flex-wrap"},W={class:"text-xs font-semibold ui-text"},H=["width","height","viewBox"],j={key:0},q=["x1","y1","x2","y2","stroke"],U=["id"],P=["stop-color"],J=["stop-color"],Q=["x","y","width","height","fill","onMouseenter","onClick"],Z=["to","begin"],_=["from","to","begin"],I={key:0},ee=["x","y"],te={key:1},le=["x","y"],oe={key:2},ne=["x","y"],ae={key:3},re=["x","y"],se={key:4},ie=["x","y"],ce=["x1","y1","x2","y2"],ue=["x1","y1","x2","y2"],de={class:"ui-surface ui-text px-4 py-3 rounded-lg shadow-2xl border ui-border-strong min-w-[180px]"},me={class:"flex items-center gap-2 mb-2"},ge={class:"font-semibold text-sm"},he={class:"ml-5"},ye={class:"text-xs ui-text mb-1"},fe={class:"text-2xl font-bold"},pe={__name:"StackedBarChart",props:{data:{type:Array,required:!0},labels:{type:Array,default:()=>[]},colors:{type:Array,default:()=>["#f97316","#10b981"]},groupKeys:{type:Array,default:()=>["complied","uncomplied"]},width:{type:[Number,String],default:"auto"},height:{type:[Number,String],default:"auto"},padding:{type:Object,default:()=>({top:20,right:20,bottom:60,left:60})},showGrid:{type:Boolean,default:!0},showXAxis:{type:Boolean,default:!0},showYAxis:{type:Boolean,default:!0},gridColor:{type:String,default:"#e5e7eb"},barClasses:{type:String,default:"transition-all duration-200 hover:opacity-90 cursor-pointer"},axisLabelClasses:{type:String,default:"fill-(--ui-text) text-xs font-medium"},maxValue:{type:Number,default:100},xAxisLabel:{type:String,default:""},yAxisLabel:{type:String,default:""},showValues:{type:Boolean,default:!0},valueSuffix:{type:String,default:""},showLegend:{type:Boolean,default:!0},legendLabels:{type:Array,default:()=>[]}},emits:["bar-click","bar-hover"],setup(l,{emit:$}){const n=l,E=$,p=e.ref(null),m=e.ref({width:0,height:0});let y=null;const g=e.computed(()=>{const t=Number(n.width);return Number.isFinite(t)&&t>0?t:m.value.width>0?m.value.width:400}),c=e.computed(()=>{const t=Number(n.height);return Number.isFinite(t)&&t>0?t:m.value.height>0?m.value.height:300}),u=e.ref({visible:!1,x:0,y:0,label:"",barLabel:"",value:0,color:""}),d=e.computed(()=>c.value-n.padding.top-n.padding.bottom),v=e.computed(()=>g.value-n.padding.left-n.padding.right),b=e.computed(()=>v.value/n.data.length*.8),N=e.computed(()=>v.value/n.data.length*.2),k=e.computed(()=>b.value/n.groupKeys.length),A=e.computed(()=>0),V=e.computed(()=>{const t=[];for(let o=0;o<=5;o++){const r=n.padding.top+d.value/5*o;t.push(r)}return t}),w=t=>n.padding.left+t*(b.value+N.value)+N.value/2,L=(t,a)=>w(t)+a*(k.value+A.value),x=t=>{const a=d.value/n.maxValue;return n.padding.top+d.value-t*a},S=t=>{const a=d.value/n.maxValue;return t*a},f=t=>n.colors[t%n.colors.length],z=t=>(Number(t)||0)<=0?n.padding.top+d.value-6:Math.max(x(t)+18,n.padding.top+16),M=t=>(Number(t)||0)<=0?"fill-(--ui-text) text-[10px] font-semibold":"fill-white text-[10px] font-semibold",F=t=>{const a=(c.value-n.padding.bottom-t)/d.value*n.maxValue;return B(Math.round(a))},C=t=>t.charAt(0).toUpperCase()+t.slice(1),D=e.computed(()=>n.valueSuffix?n.valueSuffix:String(n.yAxisLabel||"").includes("%")||n.maxValue===100?"%":""),B=t=>`${t}${D.value}`,K=e.computed(()=>n.groupKeys.map((t,a)=>({key:t,color:f(a),label:n.legendLabels[a]||C(t)}))),X=(t,a,o)=>{const r=n.data[a],i=n.groupKeys[o],s=r[i]||0,h=n.labels[a]||`Item ${a+1}`,T=C(i);u.value={visible:!0,x:t.clientX,y:t.clientY,label:h,barLabel:T,value:s,color:f(o)},E("bar-hover",{dataIndex:a,barIndex:o,key:i,value:s,label:h})},G=()=>{u.value.visible=!1},Y=(t,a)=>{const o=n.data[t],r=n.groupKeys[a],i=o[r]||0,s=n.labels[t]||`Item ${t+1}`;E("bar-click",{dataIndex:t,barIndex:a,key:r,value:i,label:s})};return e.onMounted(()=>{y=new ResizeObserver(t=>{const a=t[0];if(!a)return;const{width:o,height:r}=a.contentRect;m.value={width:Math.round(o),height:Math.round(r)}}),p.value&&y.observe(p.value)}),e.onBeforeUnmount(()=>{y&&y.disconnect()}),(t,a)=>(e.openBlock(),e.createElementBlock("div",{ref_key:"containerRef",ref:p,class:"w-full h-full relative"},[l.showLegend?(e.openBlock(),e.createElementBlock("div",O,[e.createElementVNode("div",R,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(K.value,o=>(e.openBlock(),e.createElementBlock("div",{key:`legend-${o.key}`,class:"flex items-center gap-1.5"},[e.createElementVNode("span",{class:"w-2.5 h-2.5 rounded-sm",style:e.normalizeStyle({backgroundColor:o.color})},null,4),e.createElementVNode("span",W,e.toDisplayString(o.label),1)]))),128))])])):e.createCommentVNode("",!0),(e.openBlock(),e.createElementBlock("svg",{width:g.value,height:c.value,viewBox:`0 0 ${g.value} ${c.value}`,class:"overflow-visible"},[l.showGrid?(e.openBlock(),e.createElementBlock("g",j,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(V.value,o=>(e.openBlock(),e.createElementBlock("line",{key:`grid-${o}`,x1:l.padding.left,y1:o,x2:g.value-l.padding.right,y2:o,stroke:l.gridColor,"stroke-width":"1","stroke-dasharray":"4,4",opacity:"0.3"},null,8,q))),128))])):e.createCommentVNode("",!0),e.createElementVNode("defs",null,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(l.groupKeys,(o,r)=>(e.openBlock(),e.createElementBlock("linearGradient",{id:`barGradient-${r}`,key:`gradient-${r}`,x1:"0%",y1:"0%",x2:"0%",y2:"100%"},[e.createElementVNode("stop",{offset:"0%","stop-color":f(r),"stop-opacity":"0.95"},null,8,P),e.createElementVNode("stop",{offset:"100%","stop-color":f(r),"stop-opacity":"0.85"},null,8,J)],8,U))),128))]),e.createElementVNode("g",null,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(l.data,(o,r)=>(e.openBlock(),e.createElementBlock("g",{key:`bar-group-${r}`},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(l.groupKeys,(i,s)=>(e.openBlock(),e.createElementBlock("rect",{key:`bar-${r}-${s}`,x:L(r,s),y:x(o[i]||0),width:k.value,height:S(o[i]||0),fill:`url(#barGradient-${s})`,class:e.normalizeClass(l.barClasses),rx:"4",onMouseenter:h=>X(h,r,s),onMouseleave:G,onClick:h=>Y(r,s)},[e.createElementVNode("animate",{attributeName:"height",from:0,to:S(o[i]||0),dur:"0.6s",begin:`${s*.1}s`,fill:"freeze"},null,8,Z),e.createElementVNode("animate",{attributeName:"y",from:l.padding.top+d.value,to:x(o[i]||0),dur:"0.6s",begin:`${s*.1}s`,fill:"freeze"},null,8,_)],42,Q))),128)),l.showValues?(e.openBlock(),e.createElementBlock("g",I,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(l.groupKeys,(i,s)=>(e.openBlock(),e.createElementBlock("text",{key:`bar-value-${r}-${s}`,x:L(r,s)+k.value/2,y:z(o[i]||0),class:e.normalizeClass(M(o[i]||0)),"text-anchor":"middle"},e.toDisplayString(B(o[i]||0)),11,ee))),128))])):e.createCommentVNode("",!0)]))),128))]),l.showXAxis?(e.openBlock(),e.createElementBlock("g",te,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(l.labels,(o,r)=>(e.openBlock(),e.createElementBlock("text",{key:`xlabel-${r}`,x:w(r)+b.value/2,y:c.value-l.padding.bottom+20,class:e.normalizeClass(l.axisLabelClasses),"text-anchor":"middle"},e.toDisplayString(o),11,le))),128))])):e.createCommentVNode("",!0),l.xAxisLabel?(e.openBlock(),e.createElementBlock("g",oe,[e.createElementVNode("text",{x:l.padding.left+v.value/2,y:c.value-10,class:"fill-(--ui-text) text-sm font-semibold","text-anchor":"middle"},e.toDisplayString(l.xAxisLabel),9,ne)])):e.createCommentVNode("",!0),l.showYAxis?(e.openBlock(),e.createElementBlock("g",ae,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(V.value,o=>(e.openBlock(),e.createElementBlock("text",{key:`ylabel-${o}`,x:l.padding.left-10,y:o+4,class:e.normalizeClass(l.axisLabelClasses),"text-anchor":"end"},e.toDisplayString(F(o)),11,re))),128))])):e.createCommentVNode("",!0),l.yAxisLabel?(e.openBlock(),e.createElementBlock("g",se,[e.createElementVNode("text",{x:-(l.padding.top+d.value/2),y:l.padding.left-40,class:"fill-(--ui-text) text-sm font-semibold","text-anchor":"middle",transform:"rotate(-90)"},e.toDisplayString(l.yAxisLabel),9,ie)])):e.createCommentVNode("",!0),e.createElementVNode("line",{x1:l.padding.left,y1:l.padding.top,x2:l.padding.left,y2:c.value-l.padding.bottom,stroke:"#cbd5e1","stroke-width":"2"},null,8,ce),e.createElementVNode("line",{x1:l.padding.left,y1:c.value-l.padding.bottom,x2:g.value-l.padding.right,y2:c.value-l.padding.bottom,stroke:"#cbd5e1","stroke-width":"2"},null,8,ue)],8,H)),u.value.visible?(e.openBlock(),e.createElementBlock("div",{key:1,style:e.normalizeStyle({position:"fixed",left:`${u.value.x}px`,top:`${u.value.y}px`,transform:"translate(-50%, -120%)",pointerEvents:"none",zIndex:9999}),class:"animate-in fade-in duration-200"},[e.createElementVNode("div",de,[e.createElementVNode("div",me,[e.createElementVNode("div",{style:e.normalizeStyle({backgroundColor:u.value.color}),class:"w-3 h-3 rounded shadow-sm"},null,4),e.createElementVNode("p",ge,e.toDisplayString(u.value.label),1)]),e.createElementVNode("div",he,[e.createElementVNode("p",ye,e.toDisplayString(u.value.barLabel),1),e.createElementVNode("span",fe,e.toDisplayString(B(u.value.value)),1)]),a[0]||(a[0]=e.createElementVNode("div",{class:"absolute bottom-0 left-1/2 transform -translate-x-1/2 translate-y-1/2 rotate-45 w-2 h-2 ui-surface border-r border-b ui-border-strong"},null,-1))])],4)):e.createCommentVNode("",!0)],512))}};exports.default=pe;