zignal-stencil-library 1.0.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 (294) hide show
  1. package/LICENSE +21 -0
  2. package/dist/cjs/app-globals-V2Kpy_OQ.js +8 -0
  3. package/dist/cjs/app-globals-V2Kpy_OQ.js.map +1 -0
  4. package/dist/cjs/autocomplete-select_18.cjs.entry.js +41433 -0
  5. package/dist/cjs/autocomplete-select_18.cjs.entry.js.map +1 -0
  6. package/dist/cjs/index-C4CtrJXU.js +2199 -0
  7. package/dist/cjs/index-C4CtrJXU.js.map +1 -0
  8. package/dist/cjs/index-tRPYdc8n.js +1927 -0
  9. package/dist/cjs/index-tRPYdc8n.js.map +1 -0
  10. package/dist/cjs/index.cjs.js +7 -0
  11. package/dist/cjs/index.cjs.js.map +1 -0
  12. package/dist/cjs/loader.cjs.js +16 -0
  13. package/dist/cjs/loader.cjs.js.map +1 -0
  14. package/dist/cjs/zignal-stencil-library.cjs.js +28 -0
  15. package/dist/cjs/zignal-stencil-library.cjs.js.map +1 -0
  16. package/dist/collection/api/index.js +132 -0
  17. package/dist/collection/api/index.js.map +1 -0
  18. package/dist/collection/collection-manifest.json +29 -0
  19. package/dist/collection/components/autocomplete-select/autocomplete-select.css +1 -0
  20. package/dist/collection/components/autocomplete-select/autocomplete-select.js +230 -0
  21. package/dist/collection/components/autocomplete-select/autocomplete-select.js.map +1 -0
  22. package/dist/collection/components/channel-box/channel-box.css +1 -0
  23. package/dist/collection/components/channel-box/channel-box.js +93 -0
  24. package/dist/collection/components/channel-box/channel-box.js.map +1 -0
  25. package/dist/collection/components/chat-app/chat-app.css +1 -0
  26. package/dist/collection/components/chat-app/chat-app.js +227 -0
  27. package/dist/collection/components/chat-app/chat-app.js.map +1 -0
  28. package/dist/collection/components/chat-header/chat-header.css +1 -0
  29. package/dist/collection/components/chat-header/chat-header.js +45 -0
  30. package/dist/collection/components/chat-header/chat-header.js.map +1 -0
  31. package/dist/collection/components/chat-input/chat-input.css +1 -0
  32. package/dist/collection/components/chat-input/chat-input.js +118 -0
  33. package/dist/collection/components/chat-input/chat-input.js.map +1 -0
  34. package/dist/collection/components/dialog-editor/dialog-editor.css +1 -0
  35. package/dist/collection/components/dialog-editor/dialog-editor.js +176 -0
  36. package/dist/collection/components/dialog-editor/dialog-editor.js.map +1 -0
  37. package/dist/collection/components/dialog-preview-media/dialog-preview-media.css +1 -0
  38. package/dist/collection/components/dialog-preview-media/dialog-preview-media.js +96 -0
  39. package/dist/collection/components/dialog-preview-media/dialog-preview-media.js.map +1 -0
  40. package/dist/collection/components/dialog-search/dialog-search.css +1 -0
  41. package/dist/collection/components/dialog-search/dialog-search.js +105 -0
  42. package/dist/collection/components/dialog-search/dialog-search.js.map +1 -0
  43. package/dist/collection/components/internal-component/chat-item.js +28 -0
  44. package/dist/collection/components/internal-component/chat-item.js.map +1 -0
  45. package/dist/collection/components/internal-component/icon.js +9 -0
  46. package/dist/collection/components/internal-component/icon.js.map +1 -0
  47. package/dist/collection/components/internal-component/tag-or-status-item.js +9 -0
  48. package/dist/collection/components/internal-component/tag-or-status-item.js.map +1 -0
  49. package/dist/collection/components/internal-component/z-button.js +24 -0
  50. package/dist/collection/components/internal-component/z-button.js.map +1 -0
  51. package/dist/collection/components/internal-component/z-icon-button.js +23 -0
  52. package/dist/collection/components/internal-component/z-icon-button.js.map +1 -0
  53. package/dist/collection/components/internal-component/z-input-area.js +8 -0
  54. package/dist/collection/components/internal-component/z-input-area.js.map +1 -0
  55. package/dist/collection/components/internal-component/z-input.js +8 -0
  56. package/dist/collection/components/internal-component/z-input.js.map +1 -0
  57. package/dist/collection/components/internal-component/z-select-input.js +9 -0
  58. package/dist/collection/components/internal-component/z-select-input.js.map +1 -0
  59. package/dist/collection/components/menu-list/menu-list.css +1 -0
  60. package/dist/collection/components/menu-list/menu-list.js +168 -0
  61. package/dist/collection/components/menu-list/menu-list.js.map +1 -0
  62. package/dist/collection/components/message-box/message-box.css +1 -0
  63. package/dist/collection/components/message-box/message-box.js +179 -0
  64. package/dist/collection/components/message-box/message-box.js.map +1 -0
  65. package/dist/collection/components/message-content/message-content.css +1 -0
  66. package/dist/collection/components/message-content/message-content.js +98 -0
  67. package/dist/collection/components/message-content/message-content.js.map +1 -0
  68. package/dist/collection/components/message-item/message-item.css +1 -0
  69. package/dist/collection/components/message-item/message-item.js +115 -0
  70. package/dist/collection/components/message-item/message-item.js.map +1 -0
  71. package/dist/collection/components/profile-history/profile-history.css +1 -0
  72. package/dist/collection/components/profile-history/profile-history.js +18 -0
  73. package/dist/collection/components/profile-history/profile-history.js.map +1 -0
  74. package/dist/collection/components/profile-info/profile-info.css +1 -0
  75. package/dist/collection/components/profile-info/profile-info.js +255 -0
  76. package/dist/collection/components/profile-info/profile-info.js.map +1 -0
  77. package/dist/collection/components/profile-media/profile-media.css +1 -0
  78. package/dist/collection/components/profile-media/profile-media.js +18 -0
  79. package/dist/collection/components/profile-media/profile-media.js.map +1 -0
  80. package/dist/collection/components/profile-tabs/profile-tabs.css +1 -0
  81. package/dist/collection/components/profile-tabs/profile-tabs.js +43 -0
  82. package/dist/collection/components/profile-tabs/profile-tabs.js.map +1 -0
  83. package/dist/collection/components/search-box/search-box.css +1 -0
  84. package/dist/collection/components/search-box/search-box.js +71 -0
  85. package/dist/collection/components/search-box/search-box.js.map +1 -0
  86. package/dist/collection/components/tag-popper/tag-popper.css +1 -0
  87. package/dist/collection/components/tag-popper/tag-popper.js +124 -0
  88. package/dist/collection/components/tag-popper/tag-popper.js.map +1 -0
  89. package/dist/collection/global/i18n.js +13 -0
  90. package/dist/collection/global/i18n.js.map +1 -0
  91. package/dist/collection/index.js +11 -0
  92. package/dist/collection/index.js.map +1 -0
  93. package/dist/collection/postcss/property-to-variable.js +54 -0
  94. package/dist/collection/store/store.js +25 -0
  95. package/dist/collection/store/store.js.map +1 -0
  96. package/dist/collection/utils/axios.js +11 -0
  97. package/dist/collection/utils/axios.js.map +1 -0
  98. package/dist/collection/utils/constant.js +5 -0
  99. package/dist/collection/utils/constant.js.map +1 -0
  100. package/dist/collection/utils/dayjs.js +175 -0
  101. package/dist/collection/utils/dayjs.js.map +1 -0
  102. package/dist/collection/utils/socket.js +59 -0
  103. package/dist/collection/utils/socket.js.map +1 -0
  104. package/dist/collection/utils/utils.js +8 -0
  105. package/dist/collection/utils/utils.js.map +1 -0
  106. package/dist/components/autocomplete-select.d.ts +11 -0
  107. package/dist/components/autocomplete-select.js +9 -0
  108. package/dist/components/autocomplete-select.js.map +1 -0
  109. package/dist/components/channel-box.d.ts +11 -0
  110. package/dist/components/channel-box.js +9 -0
  111. package/dist/components/channel-box.js.map +1 -0
  112. package/dist/components/chat-app.d.ts +11 -0
  113. package/dist/components/chat-app.js +226 -0
  114. package/dist/components/chat-app.js.map +1 -0
  115. package/dist/components/chat-header.d.ts +11 -0
  116. package/dist/components/chat-header.js +9 -0
  117. package/dist/components/chat-header.js.map +1 -0
  118. package/dist/components/chat-input.d.ts +11 -0
  119. package/dist/components/chat-input.js +9 -0
  120. package/dist/components/chat-input.js.map +1 -0
  121. package/dist/components/dialog-editor.d.ts +11 -0
  122. package/dist/components/dialog-editor.js +9 -0
  123. package/dist/components/dialog-editor.js.map +1 -0
  124. package/dist/components/dialog-preview-media.d.ts +11 -0
  125. package/dist/components/dialog-preview-media.js +9 -0
  126. package/dist/components/dialog-preview-media.js.map +1 -0
  127. package/dist/components/dialog-search.d.ts +11 -0
  128. package/dist/components/dialog-search.js +9 -0
  129. package/dist/components/dialog-search.js.map +1 -0
  130. package/dist/components/index.d.ts +33 -0
  131. package/dist/components/index.js +2199 -0
  132. package/dist/components/index.js.map +1 -0
  133. package/dist/components/menu-list.d.ts +11 -0
  134. package/dist/components/menu-list.js +9 -0
  135. package/dist/components/menu-list.js.map +1 -0
  136. package/dist/components/message-box.d.ts +11 -0
  137. package/dist/components/message-box.js +9 -0
  138. package/dist/components/message-box.js.map +1 -0
  139. package/dist/components/message-content.d.ts +11 -0
  140. package/dist/components/message-content.js +9 -0
  141. package/dist/components/message-content.js.map +1 -0
  142. package/dist/components/message-item.d.ts +11 -0
  143. package/dist/components/message-item.js +9 -0
  144. package/dist/components/message-item.js.map +1 -0
  145. package/dist/components/p-6xqe-pLQ.js +1509 -0
  146. package/dist/components/p-6xqe-pLQ.js.map +1 -0
  147. package/dist/components/p-B8jcXcXq.js +10 -0
  148. package/dist/components/p-B8jcXcXq.js.map +1 -0
  149. package/dist/components/p-BAxNTWPI.js +32 -0
  150. package/dist/components/p-BAxNTWPI.js.map +1 -0
  151. package/dist/components/p-BZ4TvILZ.js +24 -0
  152. package/dist/components/p-BZ4TvILZ.js.map +1 -0
  153. package/dist/components/p-BZ_KFdA7.js +99 -0
  154. package/dist/components/p-BZ_KFdA7.js.map +1 -0
  155. package/dist/components/p-BaEi6GXz.js +27448 -0
  156. package/dist/components/p-BaEi6GXz.js.map +1 -0
  157. package/dist/components/p-BcC6bTqM.js +104 -0
  158. package/dist/components/p-BcC6bTqM.js.map +1 -0
  159. package/dist/components/p-Beycm8NN.js +3027 -0
  160. package/dist/components/p-Beycm8NN.js.map +1 -0
  161. package/dist/components/p-Bf89k6bd.js +3932 -0
  162. package/dist/components/p-Bf89k6bd.js.map +1 -0
  163. package/dist/components/p-BtkLsQfZ.js +17 -0
  164. package/dist/components/p-BtkLsQfZ.js.map +1 -0
  165. package/dist/components/p-C9EokLnL.js +102 -0
  166. package/dist/components/p-C9EokLnL.js.map +1 -0
  167. package/dist/components/p-CHaS9akB.js +33 -0
  168. package/dist/components/p-CHaS9akB.js.map +1 -0
  169. package/dist/components/p-CQZRPVaY.js +1715 -0
  170. package/dist/components/p-CQZRPVaY.js.map +1 -0
  171. package/dist/components/p-CS8eN-II.js +60 -0
  172. package/dist/components/p-CS8eN-II.js.map +1 -0
  173. package/dist/components/p-CUmphmPD.js +48 -0
  174. package/dist/components/p-CUmphmPD.js.map +1 -0
  175. package/dist/components/p-ChdOg2lI.js +90 -0
  176. package/dist/components/p-ChdOg2lI.js.map +1 -0
  177. package/dist/components/p-CkqA8kPB.js +210 -0
  178. package/dist/components/p-CkqA8kPB.js.map +1 -0
  179. package/dist/components/p-CmWIRJ5t.js +91 -0
  180. package/dist/components/p-CmWIRJ5t.js.map +1 -0
  181. package/dist/components/p-CzESq-LE.js +88 -0
  182. package/dist/components/p-CzESq-LE.js.map +1 -0
  183. package/dist/components/p-DD3M-jE2.js +87 -0
  184. package/dist/components/p-DD3M-jE2.js.map +1 -0
  185. package/dist/components/p-DFjLV5Vy.js +71 -0
  186. package/dist/components/p-DFjLV5Vy.js.map +1 -0
  187. package/dist/components/p-DYI8iHdE.js +279 -0
  188. package/dist/components/p-DYI8iHdE.js.map +1 -0
  189. package/dist/components/p-DfRY75vS.js +16 -0
  190. package/dist/components/p-DfRY75vS.js.map +1 -0
  191. package/dist/components/p-DspEZ2pG.js +85 -0
  192. package/dist/components/p-DspEZ2pG.js.map +1 -0
  193. package/dist/components/p-LCZ_Vyoy.js +4084 -0
  194. package/dist/components/p-LCZ_Vyoy.js.map +1 -0
  195. package/dist/components/p-N-wb2wDd.js +236 -0
  196. package/dist/components/p-N-wb2wDd.js.map +1 -0
  197. package/dist/components/p-Urxy5c9-.js +154 -0
  198. package/dist/components/p-Urxy5c9-.js.map +1 -0
  199. package/dist/components/p-nz95LAGz.js +33 -0
  200. package/dist/components/p-nz95LAGz.js.map +1 -0
  201. package/dist/components/profile-history.d.ts +11 -0
  202. package/dist/components/profile-history.js +9 -0
  203. package/dist/components/profile-history.js.map +1 -0
  204. package/dist/components/profile-info.d.ts +11 -0
  205. package/dist/components/profile-info.js +9 -0
  206. package/dist/components/profile-info.js.map +1 -0
  207. package/dist/components/profile-media.d.ts +11 -0
  208. package/dist/components/profile-media.js +9 -0
  209. package/dist/components/profile-media.js.map +1 -0
  210. package/dist/components/profile-tabs.d.ts +11 -0
  211. package/dist/components/profile-tabs.js +9 -0
  212. package/dist/components/profile-tabs.js.map +1 -0
  213. package/dist/components/search-box.d.ts +11 -0
  214. package/dist/components/search-box.js +9 -0
  215. package/dist/components/search-box.js.map +1 -0
  216. package/dist/components/tag-popper.d.ts +11 -0
  217. package/dist/components/tag-popper.js +9 -0
  218. package/dist/components/tag-popper.js.map +1 -0
  219. package/dist/esm/app-globals-DQuL1Twl.js +6 -0
  220. package/dist/esm/app-globals-DQuL1Twl.js.map +1 -0
  221. package/dist/esm/autocomplete-select.channel-box.chat-app.chat-header.chat-input.dialog-editor.dialog-preview-media.dialog-search.menu-list.message-box.message-content.message-item.profile-history.profile-info.profile-media.profile-tabs.search-box.tag-popper.entry.js.map +1 -0
  222. package/dist/esm/autocomplete-select_18.entry.js +41414 -0
  223. package/dist/esm/autocomplete-select_18.entry.js.map +1 -0
  224. package/dist/esm/index-C0ey1F02.js +1917 -0
  225. package/dist/esm/index-C0ey1F02.js.map +1 -0
  226. package/dist/esm/index-DasOEma2.js +2197 -0
  227. package/dist/esm/index-DasOEma2.js.map +1 -0
  228. package/dist/esm/index.js +4 -0
  229. package/dist/esm/index.js.map +1 -0
  230. package/dist/esm/loader.js +14 -0
  231. package/dist/esm/loader.js.map +1 -0
  232. package/dist/esm/zignal-stencil-library.js +24 -0
  233. package/dist/esm/zignal-stencil-library.js.map +1 -0
  234. package/dist/index.cjs.js +1 -0
  235. package/dist/index.js +1 -0
  236. package/dist/types/api/index.d.ts +12 -0
  237. package/dist/types/api/index.type.d.ts +98 -0
  238. package/dist/types/components/autocomplete-select/autocomplete-select.d.ts +19 -0
  239. package/dist/types/components/channel-box/channel-box.d.ts +11 -0
  240. package/dist/types/components/chat-app/chat-app.d.ts +25 -0
  241. package/dist/types/components/chat-header/chat-header.d.ts +3 -0
  242. package/dist/types/components/chat-input/chat-input.d.ts +9 -0
  243. package/dist/types/components/dialog-editor/dialog-editor.d.ts +16 -0
  244. package/dist/types/components/dialog-preview-media/dialog-preview-media.d.ts +8 -0
  245. package/dist/types/components/dialog-search/dialog-search.d.ts +18 -0
  246. package/dist/types/components/internal-component/chat-item.d.ts +6 -0
  247. package/dist/types/components/internal-component/icon.d.ts +7 -0
  248. package/dist/types/components/internal-component/tag-or-status-item.d.ts +7 -0
  249. package/dist/types/components/internal-component/z-button.d.ts +15 -0
  250. package/dist/types/components/internal-component/z-icon-button.d.ts +13 -0
  251. package/dist/types/components/internal-component/z-input-area.d.ts +13 -0
  252. package/dist/types/components/internal-component/z-input.d.ts +13 -0
  253. package/dist/types/components/internal-component/z-select-input.d.ts +13 -0
  254. package/dist/types/components/menu-list/menu-list.d.ts +17 -0
  255. package/dist/types/components/message-box/message-box.d.ts +19 -0
  256. package/dist/types/components/message-content/message-content.d.ts +8 -0
  257. package/dist/types/components/message-item/message-item.d.ts +9 -0
  258. package/dist/types/components/profile-history/profile-history.d.ts +3 -0
  259. package/dist/types/components/profile-info/profile-info.d.ts +29 -0
  260. package/dist/types/components/profile-media/profile-media.d.ts +3 -0
  261. package/dist/types/components/profile-tabs/profile-tabs.d.ts +8 -0
  262. package/dist/types/components/search-box/search-box.d.ts +10 -0
  263. package/dist/types/components/tag-popper/tag-popper.d.ts +13 -0
  264. package/dist/types/components.d.ts +498 -0
  265. package/dist/types/global/i18n.d.ts +2 -0
  266. package/dist/types/index.d.ts +11 -0
  267. package/dist/types/stencil-public-runtime.d.ts +1709 -0
  268. package/dist/types/store/store.d.ts +16 -0
  269. package/dist/types/store/store.type.d.ts +132 -0
  270. package/dist/types/utils/axios.d.ts +1 -0
  271. package/dist/types/utils/constant.d.ts +1 -0
  272. package/dist/types/utils/dayjs.d.ts +31 -0
  273. package/dist/types/utils/socket.d.ts +6 -0
  274. package/dist/types/utils/utils.d.ts +2 -0
  275. package/dist/zignal-stencil-library/index.esm.js +2 -0
  276. package/dist/zignal-stencil-library/index.esm.js.map +1 -0
  277. package/dist/zignal-stencil-library/loader.esm.js.map +1 -0
  278. package/dist/zignal-stencil-library/p-C0ey1F02.js +3 -0
  279. package/dist/zignal-stencil-library/p-C0ey1F02.js.map +1 -0
  280. package/dist/zignal-stencil-library/p-DQuL1Twl.js +2 -0
  281. package/dist/zignal-stencil-library/p-DQuL1Twl.js.map +1 -0
  282. package/dist/zignal-stencil-library/p-DasOEma2.js +2 -0
  283. package/dist/zignal-stencil-library/p-DasOEma2.js.map +1 -0
  284. package/dist/zignal-stencil-library/p-ee2ebe92.entry.js +9777 -0
  285. package/dist/zignal-stencil-library/p-ee2ebe92.entry.js.map +1 -0
  286. package/dist/zignal-stencil-library/zignal-stencil-library.css +1 -0
  287. package/dist/zignal-stencil-library/zignal-stencil-library.esm.js +2 -0
  288. package/dist/zignal-stencil-library/zignal-stencil-library.esm.js.map +1 -0
  289. package/loader/cdn.js +1 -0
  290. package/loader/index.cjs.js +1 -0
  291. package/loader/index.d.ts +24 -0
  292. package/loader/index.es2017.js +1 -0
  293. package/loader/index.js +2 -0
  294. package/package.json +73 -0
@@ -0,0 +1,124 @@
1
+ import { Host, h } from "@stencil/core";
2
+ import { ZButton } from "../internal-component/z-button";
3
+ import { configStore } from "../../store/store";
4
+ import { TagOrStatusItem } from "../internal-component/tag-or-status-item";
5
+ import { computePosition, autoUpdate, offset, flip, shift } from "@floating-ui/dom";
6
+ export class TagPopper {
7
+ tags = [];
8
+ referenceSelector;
9
+ isOpen = false;
10
+ triggerEl;
11
+ popperEl;
12
+ cleanup;
13
+ componentDidLoad() {
14
+ document.addEventListener('click', this.handleClickOutside);
15
+ }
16
+ disconnectedCallback() {
17
+ document.removeEventListener('click', this.handleClickOutside);
18
+ this.cleanup?.();
19
+ this.popperEl?.remove();
20
+ }
21
+ handleClickOutside = (e) => {
22
+ const path = e.composedPath();
23
+ if (!path.includes(this.triggerEl)) {
24
+ this.isOpen = false;
25
+ }
26
+ };
27
+ async togglePopper() {
28
+ this.isOpen = !this.isOpen;
29
+ if (this.isOpen) {
30
+ const referenceEl = document.querySelector(this.referenceSelector);
31
+ if (!referenceEl || !this.popperEl)
32
+ return;
33
+ document.body.appendChild(this.popperEl);
34
+ this.cleanup = autoUpdate(referenceEl, this.popperEl, () => {
35
+ computePosition(referenceEl, this.popperEl, {
36
+ placement: 'bottom-start',
37
+ middleware: [offset(8), flip(), shift()]
38
+ }).then(({ x, y }) => {
39
+ Object.assign(this.popperEl.style, {
40
+ left: `${x}px`,
41
+ top: `${y}px`,
42
+ zIndex: '9999'
43
+ });
44
+ });
45
+ });
46
+ }
47
+ else {
48
+ this.cleanup?.();
49
+ this.popperEl?.remove();
50
+ }
51
+ }
52
+ render() {
53
+ const theme = configStore.get('theme');
54
+ return (h(Host, { key: 'f3fd39d557917b71759df69b23275c7e4162a9f4' }, h("slot", { key: 'd53693c9382affc79cc956920850991f9d4596c7' }, h("div", { key: '3f9c9aea7ba2030e9d55c692e899fa9d8717b66d', class: "relative" }, h(ZButton, { key: '0f7e627a7f1a621f2a0089eb0be2a9dd1631b437', label: "\u0E14\u0E39\u0E40\u0E1E\u0E34\u0E48\u0E21", variant: 'outlined', size: 'small', onClick: (event) => {
55
+ event.stopPropagation();
56
+ this.togglePopper();
57
+ }, ref: (el) => (this.triggerEl = el) }), this.isOpen && (h("div", { key: '7f1a03c34efdf8f007f94cd9f5aeb3118112cef7', ref: (el) => (this.popperEl = el), class: `absolute mt-1 z-50 z-paper-${theme} p-4 rounded-md shadow-lg w-52 flex flex-wrap gap-2` }, this.tags.map((tag) => h(TagOrStatusItem, { item: tag }))))))));
58
+ }
59
+ static get is() { return "tag-popper"; }
60
+ static get originalStyleUrls() {
61
+ return {
62
+ "$": ["tag-popper.css"]
63
+ };
64
+ }
65
+ static get styleUrls() {
66
+ return {
67
+ "$": ["tag-popper.css"]
68
+ };
69
+ }
70
+ static get properties() {
71
+ return {
72
+ "tags": {
73
+ "type": "unknown",
74
+ "attribute": "tags",
75
+ "mutable": false,
76
+ "complexType": {
77
+ "original": "TagOrStatusItem[]",
78
+ "resolved": "TagOrStatusItem[]",
79
+ "references": {
80
+ "TagOrStatusItem": {
81
+ "location": "import",
82
+ "path": "../internal-component/tag-or-status-item",
83
+ "id": "src/components/internal-component/tag-or-status-item.tsx::TagOrStatusItem"
84
+ }
85
+ }
86
+ },
87
+ "required": false,
88
+ "optional": false,
89
+ "docs": {
90
+ "tags": [],
91
+ "text": ""
92
+ },
93
+ "getter": false,
94
+ "setter": false,
95
+ "defaultValue": "[]"
96
+ },
97
+ "referenceSelector": {
98
+ "type": "string",
99
+ "attribute": "reference-selector",
100
+ "mutable": false,
101
+ "complexType": {
102
+ "original": "string",
103
+ "resolved": "string",
104
+ "references": {}
105
+ },
106
+ "required": false,
107
+ "optional": false,
108
+ "docs": {
109
+ "tags": [],
110
+ "text": ""
111
+ },
112
+ "getter": false,
113
+ "setter": false,
114
+ "reflect": false
115
+ }
116
+ };
117
+ }
118
+ static get states() {
119
+ return {
120
+ "isOpen": {}
121
+ };
122
+ }
123
+ }
124
+ //# sourceMappingURL=tag-popper.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tag-popper.js","sourceRoot":"","sources":["../../../src/components/tag-popper/tag-popper.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AAChE,OAAO,EAAE,OAAO,EAAE,MAAM,gCAAgC,CAAC;AACzD,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,eAAe,EAAE,MAAM,0CAA0C,CAAC;AAC3E,OAAO,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAMpF,MAAM,OAAO,SAAS;IAEZ,IAAI,GAAsB,EAAE,CAAC;IAC7B,iBAAiB,CAAS;IAEzB,MAAM,GAAG,KAAK,CAAC;IAEhB,SAAS,CAAe;IACxB,QAAQ,CAAiB;IAEzB,OAAO,CAAc;IAE7B,gBAAgB;QACd,QAAQ,CAAC,gBAAgB,CAAC,OAAO,EAAE,IAAI,CAAC,kBAAkB,CAAC,CAAC;IAC9D,CAAC;IAED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AAG,CAAC,IAAI;wBACd,GAAG,EAAE,GAAG,CAAC,IAAI;wBACb,MAAM,EAAE,MAAM;qBACf,CAAC,CAAC;gBACL,CAAC,CAAC,CAAC;YACL,CAAC,CAAC,CAAC;QACL,CAAC;aAAM,CAAC;YACN,IAAI,CAAC,OAAO,EAAE,EAAE,CAAC;YACjB,IAAI,CAAC,QAAQ,EAAE,MAAM,EAAE,CAAC;QAC1B,CAAC;IACH,CAAC;IAED,MAAM;QACJ,MAAM,KAAK,GAAG,WAAW,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;QAEvC,OAAO,CACL,EAAC,IAAI;YACH;gBACE,4DAAK,KAAK,EAAC,UAAU;oBACnB,EAAC,OAAO,qDACN,KAAK,EAAC,4CAAS,EACf,OAAO,EAAC,UAAU,EAClB,IAAI,EAAC,OAAO,EACZ,OAAO,EAAE,CAAC,KAAK,EAAE,EAAE;4BACjB,KAAK,CAAC,eAAe,EAAE,CAAA;4BACvB,IAAI,CAAC,YAAY,EAAE,CAAC;wBACtB,CAAC,EACD,GAAG,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,SAAS,GAAG,EAAE,CAAC,GAClC;oBACD,IAAI,CAAC,MAAM,IAAI,CACd,4DACE,GAAG,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,QAAQ,GAAG,EAAE,CAAC,EACjC,KAAK,EAAE,8BAA8B,KAAK,qDAAqD,IAE9F,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,EAAC,eAAe,IAAC,IAAI,EAAE,GAAG,GAAI,CAAC,CACnD,CACP,CACG,CACD,CACF,CACR,CAAC;IACJ,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF","sourcesContent":["import { Component, Host, State, h, Prop } from '@stencil/core';\nimport { ZButton } from '../internal-component/z-button';\nimport { configStore } from '../../store/store';\nimport { TagOrStatusItem } from '../internal-component/tag-or-status-item';\nimport { computePosition, autoUpdate, offset, flip, shift } from '@floating-ui/dom';\n\n@Component({\n tag: 'tag-popper',\n styleUrl: 'tag-popper.css',\n})\nexport class TagPopper {\n\n @Prop() tags: TagOrStatusItem[] = [];\n @Prop() referenceSelector: string;\n\n @State() isOpen = false;\n\n private triggerEl!: HTMLElement;\n private popperEl: HTMLDivElement;\n\n private cleanup?: () => void;\n\n componentDidLoad() {\n document.addEventListener('click', this.handleClickOutside);\n }\n\n disconnectedCallback() {\n document.removeEventListener('click', this.handleClickOutside);\n this.cleanup?.()\n this.popperEl?.remove();\n }\n\n handleClickOutside = (e: MouseEvent) => {\n const path = e.composedPath();\n if (!path.includes(this.triggerEl)) {\n this.isOpen = false;\n }\n };\n\n async togglePopper() {\n this.isOpen = !this.isOpen;\n\n if (this.isOpen) {\n const referenceEl = document.querySelector(this.referenceSelector);\n if (!referenceEl || !this.popperEl) return;\n\n document.body.appendChild(this.popperEl);\n\n this.cleanup = autoUpdate(referenceEl, this.popperEl, () => {\n computePosition(referenceEl, this.popperEl, {\n placement: 'bottom-start',\n middleware: [offset(8), flip(), shift()]\n }).then(({ x, y }) => {\n Object.assign(this.popperEl.style, {\n left: `${x}px`,\n top: `${y}px`,\n zIndex: '9999'\n });\n });\n });\n } else {\n this.cleanup?.();\n this.popperEl?.remove();\n }\n }\n\n render() {\n const theme = configStore.get('theme');\n\n return (\n <Host>\n <slot>\n <div class=\"relative\">\n <ZButton\n label=\"ดูเพิ่ม\"\n variant='outlined'\n size='small'\n onClick={(event) => {\n event.stopPropagation()\n this.togglePopper();\n }}\n ref={(el) => (this.triggerEl = el)}\n />\n {this.isOpen && (\n <div\n ref={(el) => (this.popperEl = el)}\n class={`absolute mt-1 z-50 z-paper-${theme} p-4 rounded-md shadow-lg w-52 flex flex-wrap gap-2`}\n >\n {this.tags.map((tag) => <TagOrStatusItem item={tag} />)}\n </div>\n )}\n </div>\n </slot>\n </Host>\n );\n }\n}\n"]}
@@ -0,0 +1,13 @@
1
+ import i18n from "i18next";
2
+ import en from "../locales/en.json";
3
+ import th from "../locales/th.json";
4
+ i18n.init({
5
+ resources: {
6
+ en: { translation: en },
7
+ th: { translation: th },
8
+ },
9
+ fallbackLng: 'en',
10
+ interpolation: { escapeValue: false },
11
+ });
12
+ export default i18n;
13
+ //# sourceMappingURL=i18n.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"i18n.js","sourceRoot":"","sources":["../../src/global/i18n.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,SAAS,CAAC;AAC3B,OAAO,EAAE,MAAM,oBAAoB,CAAC;AACpC,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAEpC,IAAI,CAAC,IAAI,CAAC;IACR,SAAS,EAAE;QACT,EAAE,EAAE,EAAE,WAAW,EAAE,EAAE,EAAE;QACvB,EAAE,EAAE,EAAE,WAAW,EAAE,EAAE,EAAE;KACxB;IACD,WAAW,EAAE,IAAI;IACjB,aAAa,EAAE,EAAE,WAAW,EAAE,KAAK,EAAE;CACtC,CAAC,CAAC;AAEH,eAAe,IAAI,CAAC","sourcesContent":["import i18n from 'i18next';\nimport en from '../locales/en.json';\nimport th from '../locales/th.json';\n\ni18n.init({\n resources: {\n en: { translation: en },\n th: { translation: th },\n },\n fallbackLng: 'en',\n interpolation: { escapeValue: false },\n});\n\nexport default i18n;\n"]}
@@ -0,0 +1,11 @@
1
+ /**
2
+ * @fileoverview entry point for your component library
3
+ *
4
+ * This is the entry point for your component library. Use this file to export utilities,
5
+ * constants or data structure that accompany your components.
6
+ *
7
+ * DO NOT use this file to export your components. Instead, use the recommended approaches
8
+ * to consume components of this package as outlined in the `README.md`.
9
+ */
10
+ import "./global/i18n";
11
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,eAAe,CAAC","sourcesContent":["/**\n * @fileoverview entry point for your component library\n *\n * This is the entry point for your component library. Use this file to export utilities,\n * constants or data structure that accompany your components.\n *\n * DO NOT use this file to export your components. Instead, use the recommended approaches\n * to consume components of this package as outlined in the `README.md`.\n */\n\nimport './global/i18n';\nexport type * from './components';\n"]}
@@ -0,0 +1,54 @@
1
+ /** @type {import('postcss-load-config').Config} */
2
+ const postcss = require('postcss');
3
+
4
+ const buildFallbackSelectorGroup = decls => [
5
+ '@layer base {',
6
+ '*,::backdrop,:after,:before{',
7
+ decls.join(';'),
8
+ '}}',
9
+ ].join('');
10
+
11
+ /**
12
+ * This plugin convert @property to normal css variables. @property is not yet supported
13
+ * by web components
14
+ */
15
+ const propertyToCssVariablePolyfill = (pluginOptions = {}) => {
16
+ return {
17
+ postcssPlugin: 'postcss-property-to-variable',
18
+ Once(root) {
19
+ const fallbackVariableDecls = [];
20
+
21
+ root.walkAtRules('property', (atRule) => {
22
+
23
+ atRule.walkDecls((decl) => {
24
+ if (decl.prop === 'initial-value') {
25
+ const cssVariableName = atRule.params.trim();
26
+ fallbackVariableDecls.push(`${cssVariableName}:${decl.value}`)
27
+ }
28
+ });
29
+ });
30
+
31
+ if (fallbackVariableDecls.length > 0) {
32
+ const fallbackSelectors = buildFallbackSelectorGroup(fallbackVariableDecls);
33
+
34
+ const sourceFile = root.source?.input?.file || root.source?.input?.from;
35
+ const fallbackSelectorsAst = postcss.parse(fallbackSelectors, { from: sourceFile });
36
+
37
+ let lastImportIndex = -1;
38
+ for (const [i, node] of root.nodes.entries()) {
39
+ if (node.type === 'atrule' && node.name === 'import') {
40
+ lastImportIndex = i
41
+ }
42
+ }
43
+
44
+ lastImportIndex === -1
45
+ ? root.prepend(fallbackSelectorsAst)
46
+ : root.insertAfter(root.nodes[lastImportIndex], fallbackSelectorsAst);
47
+ }
48
+ },
49
+ };
50
+ };
51
+
52
+ propertyToCssVariablePolyfill.postcss = true;
53
+
54
+ module.exports = propertyToCssVariablePolyfill;
@@ -0,0 +1,25 @@
1
+ import { createStore } from "@stencil/store";
2
+ export const configStore = createStore({
3
+ language: 'en',
4
+ theme: 'light',
5
+ businessId: null,
6
+ shopId: null,
7
+ accessToken: null,
8
+ isProduction: false
9
+ });
10
+ export const messagesStore = createStore({
11
+ messages: [],
12
+ });
13
+ export const chatsStore = createStore({
14
+ chats: [],
15
+ });
16
+ export const userStore = createStore({
17
+ user: null,
18
+ });
19
+ export const selectedChatStore = createStore({
20
+ selectedChat: null,
21
+ });
22
+ export const selectedMessageToReplyStore = createStore({
23
+ selectedMessageToReply: null,
24
+ });
25
+ //# sourceMappingURL=store.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"store.js","sourceRoot":"","sources":["../../src/store/store.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAE7C,MAAM,CAAC,MAAM,WAAW,GAAG,WAAW,CAAc;IAClD,QAAQ,EAAE,IAAI;IACd,KAAK,EAAE,OAAO;IACd,UAAU,EAAE,IAAI;IAChB,MAAM,EAAE,IAAI;IACZ,WAAW,EAAE,IAAI;IACjB,YAAY,EAAE,KAAK;CACpB,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,aAAa,GAAG,WAAW,CAAkC;IACxE,QAAQ,EAAE,EAAE;CACb,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,UAAU,GAAG,WAAW,CAAwB;IAC3D,KAAK,EAAE,EAAE;CACV,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,SAAS,GAAG,WAAW,CAA4B;IAC9D,IAAI,EAAE,IAAI;CACX,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,iBAAiB,GAAG,WAAW,CAAoC;IAC9E,YAAY,EAAE,IAAI;CACnB,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,2BAA2B,GAAG,WAAW,CAAqD;IACzG,sBAAsB,EAAE,IAAI;CAC7B,CAAC,CAAC","sourcesContent":["import { createStore } from '@stencil/store';\n\nexport const configStore = createStore<ConfigStore>({\n language: 'en',\n theme: 'light',\n businessId: null,\n shopId: null,\n accessToken: null,\n isProduction: false\n});\n\nexport const messagesStore = createStore<{ messages: ChatMessageItem[] }>({\n messages: [],\n});\n\nexport const chatsStore = createStore<{ chats: ChatItem[] }>({\n chats: [],\n});\n\nexport const userStore = createStore<{ user: UserItem | null }>({\n user: null,\n});\n\nexport const selectedChatStore = createStore<{ selectedChat: ChatItem | null }>({\n selectedChat: null,\n});\n\nexport const selectedMessageToReplyStore = createStore<{ selectedMessageToReply: ChatMessageItem | null }>({\n selectedMessageToReply: null,\n});\n"]}
@@ -0,0 +1,11 @@
1
+ import axios from "axios";
2
+ import { configStore } from "../store/store";
3
+ import { baseURL } from "./constant";
4
+ export const apiService = () => axios.create({
5
+ headers: {
6
+ Authorization: configStore.get('accessToken')
7
+ },
8
+ baseURL,
9
+ timeout: 30000
10
+ });
11
+ //# sourceMappingURL=axios.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"axios.js","sourceRoot":"","sources":["../../src/utils/axios.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAErC,MAAM,CAAC,MAAM,UAAU,GAAG,GAAG,EAAE,CAC7B,KAAK,CAAC,MAAM,CAAC;IACX,OAAO,EAAE;QACP,aAAa,EAAE,WAAW,CAAC,GAAG,CAAC,aAAa,CAAC;KAC9C;IACD,OAAO;IACP,OAAO,EAAE,KAAK;CACf,CAAC,CAAA","sourcesContent":["import axios from \"axios\";\nimport { configStore } from \"../store/store\";\nimport { baseURL } from \"./constant\";\n\nexport const apiService = () =>\n axios.create({\n headers: {\n Authorization: configStore.get('accessToken')\n },\n baseURL,\n timeout: 30000\n })\n"]}
@@ -0,0 +1,5 @@
1
+ import { configStore } from "../store/store";
2
+ export const baseURL = configStore.get('isProduction')
3
+ ? 'https://d1cl6ecu5d3v2r.cloudfront.net'
4
+ : 'https://dp46r1vjkg63g.cloudfront.net';
5
+ //# sourceMappingURL=constant.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constant.js","sourceRoot":"","sources":["../../src/utils/constant.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAE7C,MAAM,CAAC,MAAM,OAAO,GAAG,WAAW,CAAC,GAAG,CAAC,cAAc,CAAC;IACpD,CAAC,CAAC,uCAAuC;IACzC,CAAC,CAAC,sCAAsC,CAAC","sourcesContent":["import { configStore } from \"../store/store\";\n\nexport const baseURL = configStore.get('isProduction')\n ? 'https://d1cl6ecu5d3v2r.cloudfront.net'\n : 'https://dp46r1vjkg63g.cloudfront.net';\n"]}
@@ -0,0 +1,175 @@
1
+ import dayjs from "dayjs";
2
+ import utc from "dayjs/plugin/utc";
3
+ import timezone from "dayjs/plugin/timezone";
4
+ dayjs.extend(utc);
5
+ dayjs.extend(timezone);
6
+ dayjs.tz.setDefault('Asia/Bangkok');
7
+ import relativeTime from "dayjs/plugin/relativeTime";
8
+ dayjs.extend(relativeTime);
9
+ import duration from "dayjs/plugin/duration";
10
+ dayjs.extend(duration);
11
+ import "dayjs/locale/th";
12
+ // import buddhistEra from 'dayjs/plugin/buddhistEra'
13
+ import isSameOrBefore from "dayjs/plugin/isSameOrBefore";
14
+ dayjs.extend(isSameOrBefore);
15
+ import isSameOrAfter from "dayjs/plugin/isSameOrAfter";
16
+ dayjs.extend(isSameOrAfter);
17
+ import isBetween from "dayjs/plugin/isBetween";
18
+ dayjs.extend(isBetween);
19
+ export const DATE_TIME_FORMAT_CALENDAR = {
20
+ year: 'BBBB',
21
+ monthAndYear: 'MMMM BBBB',
22
+ keyboardDate: 'DD/MM/BBBB'
23
+ };
24
+ dayjs.locale('th');
25
+ // dayjs.extend(buddhistEra)
26
+ export const convertMinuteToArrayNumber = (minutes) => {
27
+ const days = Math.floor(minutes / 1440); // 1440 minutes in a day (24 hours)
28
+ const hours = Math.floor((minutes % 1440) / 60);
29
+ const remainingMinutes = minutes % 60;
30
+ return [days, hours, remainingMinutes];
31
+ };
32
+ export const convertArrayNumberToMinute = (arr) => {
33
+ //[day, hour, minute]
34
+ const minutes = (arr[0] ? (arr[0] * (60 * 24)) : 0) + (arr[1] ? (arr[1] * 60) : 0) + (arr[2] ? arr[2] : 0);
35
+ return minutes;
36
+ };
37
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
38
+ export const convertMinuteToDuration = (value, type) => {
39
+ const tempValue = dayjs.duration(value, 'minutes');
40
+ let transformValue = tempValue.minutes();
41
+ switch (type.value) {
42
+ case 'minutes':
43
+ transformValue = tempValue.minutes();
44
+ break;
45
+ case 'hours':
46
+ transformValue = tempValue.hours();
47
+ break;
48
+ case 'days':
49
+ transformValue = tempValue.days()
50
+ + dayjs.duration({ 'months': tempValue.months() }).asDays() + dayjs.duration({ 'years': tempValue.years() }).asDays();
51
+ break;
52
+ case 'months':
53
+ transformValue = tempValue.months();
54
+ break;
55
+ case 'years':
56
+ transformValue = tempValue.years();
57
+ break;
58
+ }
59
+ return transformValue;
60
+ };
61
+ export const convertDurationToMinute = (value, type) => {
62
+ const tempValue = dayjs.duration({ [type]: value });
63
+ return tempValue.asMinutes();
64
+ };
65
+ export const isExpired = (date) => {
66
+ try {
67
+ return dayjs().isAfter(dayjs(date));
68
+ }
69
+ catch {
70
+ return true;
71
+ }
72
+ };
73
+ export const isCardExpired = (expiration) => {
74
+ const [month, year] = expiration.split('/').map(Number);
75
+ if (!month || !year)
76
+ return true;
77
+ const expDate = dayjs(`${2000 + year}-${month}-01`).endOf('month');
78
+ return dayjs().isAfter(expDate, 'day');
79
+ };
80
+ export const convertTimeToMinutes = (timeString) => {
81
+ // Parse the time string using Day.js
82
+ const parsedTime = dayjs(`2000-01-01 ${timeString}`);
83
+ // Check if the parsing was successful
84
+ if (!parsedTime.isValid()) {
85
+ console.error('Invalid time format');
86
+ return 0;
87
+ }
88
+ // Calculate the total minutes
89
+ const totalMinutes = parsedTime.hour() * 60 + parsedTime.minute();
90
+ return totalMinutes;
91
+ };
92
+ export const convertMinutesToTime = (totalMinutes) => {
93
+ // Calculate hours and minutes
94
+ const hours = Math.floor(totalMinutes / 60);
95
+ const minutes = totalMinutes % 60;
96
+ // Format the result as "HH:mm"
97
+ const formattedTime = dayjs().set('hour', hours).set('minute', minutes).format('HH:mm');
98
+ return formattedTime;
99
+ };
100
+ export const convertMinutesToDayjs = (totalMinutes) => {
101
+ // Calculate hours and minutes
102
+ const hours = Math.floor(totalMinutes / 60);
103
+ const minutes = totalMinutes % 60;
104
+ // Format the result as "HH:mm"
105
+ const formattedTime = dayjs().set('hour', hours).set('minute', minutes).set('ms', 0).set('s', 0).local();
106
+ return formattedTime;
107
+ };
108
+ export const isTimeBefore = (time1, time2) => {
109
+ //String Format HH:mm:ss
110
+ const parseTime = (time) => {
111
+ const [hours, minutes, seconds] = time.split(':').map(Number);
112
+ const date = new Date();
113
+ date.setHours(hours, minutes, seconds || 0, 0);
114
+ return date;
115
+ };
116
+ const date1 = parseTime(time1);
117
+ const date2 = parseTime(time2);
118
+ return date1.getTime() < date2.getTime();
119
+ };
120
+ export const isTimeAfter = (time1, time2) => {
121
+ const parseTime = (time) => {
122
+ const [hours, minutes, seconds] = time.split(':').map(Number);
123
+ const date = new Date();
124
+ date.setHours(hours, minutes, seconds || 0, 0);
125
+ return date;
126
+ };
127
+ const date1 = parseTime(time1);
128
+ const date2 = parseTime(time2);
129
+ return date1.getTime() > date2.getTime();
130
+ };
131
+ export const isTimeInRange = (start_time, end_time, current_time) => {
132
+ const format = 'HH:mm:ss';
133
+ const startTime = dayjs(start_time, format);
134
+ const endTime = dayjs(end_time, format);
135
+ const currentTime = dayjs(current_time, format);
136
+ return currentTime.isBetween(startTime, endTime, null, '[]'); // '[]' includes both start and end times
137
+ };
138
+ export const isTimeRangeOverlapping = (range1, range2) => {
139
+ const startTime1 = dayjs(range1.start_time, 'HH:mm:ss');
140
+ const endTime1 = dayjs(range1.end_time, 'HH:mm:ss').subtract(1, 'minutes');
141
+ const startTime2 = dayjs(range2.start_time, 'HH:mm:ss');
142
+ const endTime2 = dayjs(range2.end_time, 'HH:mm:ss').subtract(1, 'minutes');
143
+ // Check if range1 starts before or at the same time as range2 ends
144
+ // and range1 ends after or at the same time as range2 starts
145
+ return ((startTime1.isBefore(endTime2) || startTime1.isSame(endTime2)) &&
146
+ (endTime1.isAfter(startTime2) || endTime1.isSame(startTime2)));
147
+ };
148
+ export const getDates = (startDate, endDate, format) => {
149
+ const dates = [];
150
+ let currentDate = dayjs(startDate);
151
+ const endDateObj = dayjs(endDate);
152
+ while (currentDate.isBefore(endDateObj) || currentDate.isSame(endDateObj, 'day')) {
153
+ dates.push(currentDate.format(format));
154
+ currentDate = currentDate.add(1, 'day');
155
+ }
156
+ return dates;
157
+ };
158
+ export const checkOverlappingDayjs = (timeRanges) => {
159
+ for (let i = 0; i < timeRanges.length; i++) {
160
+ const { startTime: startTime1, endTime: endTime1 } = timeRanges[i];
161
+ if (!startTime1 || !endTime1)
162
+ continue; // Skip if either is null
163
+ for (let j = i + 1; j < timeRanges.length; j++) {
164
+ const { startTime: startTime2, endTime: endTime2 } = timeRanges[j];
165
+ if (!startTime2 || !endTime2)
166
+ continue; // Skip if either is null
167
+ if (startTime1.isBefore(endTime2) &&
168
+ startTime2.isBefore(endTime1)) {
169
+ return true; // Overlap found
170
+ }
171
+ }
172
+ }
173
+ return false; // No overlap
174
+ };
175
+ //# sourceMappingURL=dayjs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dayjs.js","sourceRoot":"","sources":["../../src/utils/dayjs.ts"],"names":[],"mappings":"AAAA,OAAO,KAAgB,MAAM,OAAO,CAAA;AAEpC,OAAO,GAAG,MAAM,kBAAkB,CAAA;AAClC,OAAO,QAAQ,MAAM,uBAAuB,CAAA;AAE5C,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,C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E,IACE,UAAU,CAAC,QAAQ,CAAC,QAAQ,CAAC;gBAC7B,UAAU,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAC7B,CAAC;gBACD,OAAO,IAAI,CAAC,CAAC,gBAAgB;YAC/B,CAAC;QACH,CAAC;IACH,CAAC;IACD,OAAO,KAAK,CAAC,CAAC,aAAa;AAC7B,CAAC,CAAC","sourcesContent":["import dayjs, { Dayjs } from 'dayjs'\n\nimport utc from 'dayjs/plugin/utc'\nimport timezone from 'dayjs/plugin/timezone'\n\ndayjs.extend(utc)\ndayjs.extend(timezone)\ndayjs.tz.setDefault('Asia/Bangkok')\n\nimport relativeTime from 'dayjs/plugin/relativeTime'\ndayjs.extend(relativeTime)\nimport duration from 'dayjs/plugin/duration'\ndayjs.extend(duration)\nimport 'dayjs/locale/th'\nimport { DurationUnitType } from 'dayjs/plugin/duration'\n// import buddhistEra from 'dayjs/plugin/buddhistEra'\n\nimport isSameOrBefore from 'dayjs/plugin/isSameOrBefore'\ndayjs.extend(isSameOrBefore)\nimport isSameOrAfter from 'dayjs/plugin/isSameOrAfter'\ndayjs.extend(isSameOrAfter)\n\nimport isBetween from 'dayjs/plugin/isBetween'\ndayjs.extend(isBetween)\n\nexport const DATE_TIME_FORMAT_CALENDAR = {\n year: 'BBBB',\n monthAndYear: 'MMMM BBBB',\n keyboardDate: 'DD/MM/BBBB'\n}\ndayjs.locale('th')\n\n// dayjs.extend(buddhistEra)\n\nexport const convertMinuteToArrayNumber = (minutes: number) => {\n const days = Math.floor(minutes / 1440); // 1440 minutes in a day (24 hours)\n const hours = Math.floor((minutes % 1440) / 60);\n const remainingMinutes = minutes % 60;\n return [days, hours, remainingMinutes];\n}\n\nexport const convertArrayNumberToMinute = (arr: (number | undefined)[]) => {\n //[day, hour, minute]\n const minutes = (arr[0] ? (arr[0] * (60 * 24)) : 0) + (arr[1] ? (arr[1] * 60) : 0) + (arr[2] ? arr[2] : 0)\n return minutes\n}\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport const convertMinuteToDuration = (value: number, type: any) => {\n const tempValue = dayjs.duration(value, 'minutes')\n let transformValue = tempValue.minutes()\n switch (type.value) {\n case 'minutes':\n transformValue = tempValue.minutes()\n break\n case 'hours':\n transformValue = tempValue.hours()\n break\n case 'days':\n transformValue = tempValue.days()\n + dayjs.duration({ 'months': tempValue.months() }).asDays() + dayjs.duration({ 'years': tempValue.years() }).asDays()\n break\n case 'months':\n transformValue = tempValue.months()\n break\n case 'years':\n transformValue = tempValue.years()\n break\n }\n return transformValue\n}\n\nexport const convertDurationToMinute = (value: number, type: DurationUnitType) => {\n const tempValue = dayjs.duration({ [type]: value })\n return tempValue.asMinutes()\n}\n\nexport const isExpired = (date: string | Date) => {\n try {\n return dayjs().isAfter(dayjs(date))\n } catch {\n return true\n }\n}\nexport const isCardExpired = (expiration: string): boolean => {\n const [month, year] = expiration.split('/').map(Number)\n\n if (!month || !year) return true\n\n const expDate = dayjs(`${2000 + year}-${month}-01`).endOf('month')\n\n return dayjs().isAfter(expDate, 'day')\n}\n\nexport const convertTimeToMinutes = (timeString: string): number => {\n // Parse the time string using Day.js\n const parsedTime = dayjs(`2000-01-01 ${timeString}`);\n\n // Check if the parsing was successful\n if (!parsedTime.isValid()) {\n console.error('Invalid time format');\n return 0;\n }\n\n // Calculate the total minutes\n const totalMinutes = parsedTime.hour() * 60 + parsedTime.minute();\n return totalMinutes;\n}\nexport const convertMinutesToTime = (totalMinutes: number): string => {\n // Calculate hours and minutes\n const hours = Math.floor(totalMinutes / 60);\n const minutes = totalMinutes % 60;\n\n // Format the result as \"HH:mm\"\n const formattedTime = dayjs().set('hour', hours).set('minute', minutes).format('HH:mm');\n return formattedTime;\n}\n\nexport const convertMinutesToDayjs = (totalMinutes: number): Dayjs => {\n // Calculate hours and minutes\n const hours = Math.floor(totalMinutes / 60);\n const minutes = totalMinutes % 60;\n\n // Format the result as \"HH:mm\"\n const formattedTime = dayjs().set('hour', hours).set('minute', minutes).set('ms', 0).set('s', 0).local();\n return formattedTime;\n}\n\nexport const isTimeBefore = (time1: string, time2: string): boolean => {\n //String Format HH:mm:ss\n const parseTime = (time: string): Date => {\n const [hours, minutes, seconds] = time.split(':').map(Number);\n const date = new Date();\n date.setHours(hours, minutes, seconds || 0, 0);\n return date;\n };\n\n const date1 = parseTime(time1);\n const date2 = parseTime(time2);\n\n return date1.getTime() < date2.getTime();\n}\n\nexport const isTimeAfter = (time1: string, time2: string): boolean => {\n const parseTime = (time: string): Date => {\n const [hours, minutes, seconds] = time.split(':').map(Number);\n const date = new Date();\n date.setHours(hours, minutes, seconds || 0, 0);\n return date;\n };\n\n const date1 = parseTime(time1);\n const date2 = parseTime(time2);\n\n return date1.getTime() > date2.getTime();\n}\n\nexport const isTimeInRange = (start_time: string, end_time: string, current_time: string): boolean => {\n const format = 'HH:mm:ss';\n\n const startTime = dayjs(start_time, format);\n const endTime = dayjs(end_time, format);\n const currentTime = dayjs(current_time, format);\n\n return currentTime.isBetween(startTime, endTime, null, '[]'); // '[]' includes both start and end times\n}\n\nexport interface TimeRange {\n start_time: string;\n end_time: string;\n}\nexport const isTimeRangeOverlapping = (\n range1: TimeRange,\n range2: TimeRange\n): boolean => {\n const startTime1 = dayjs(range1.start_time, 'HH:mm:ss');\n const endTime1 = dayjs(range1.end_time, 'HH:mm:ss').subtract(1, 'minutes');\n const startTime2 = dayjs(range2.start_time, 'HH:mm:ss');\n const endTime2 = dayjs(range2.end_time, 'HH:mm:ss').subtract(1, 'minutes');\n // Check if range1 starts before or at the same time as range2 ends\n // and range1 ends after or at the same time as range2 starts\n return (\n (startTime1.isBefore(endTime2) || startTime1.isSame(endTime2)) &&\n (endTime1.isAfter(startTime2) || endTime1.isSame(startTime2))\n );\n};\nexport const getDates = (\n startDate: string,\n endDate: string,\n format: 'DD/MM/YYYY' | 'YYYY-MM-DD'\n): string[] => {\n const dates: string[] = [];\n let currentDate = dayjs(startDate);\n const endDateObj = dayjs(endDate);\n\n while (currentDate.isBefore(endDateObj) || currentDate.isSame(endDateObj, 'day')) {\n dates.push(currentDate.format(format));\n currentDate = currentDate.add(1, 'day');\n }\n\n return dates;\n}\n\nexport interface TimeRangeDayjs {\n startTime: Dayjs | null\n endTime: Dayjs | null\n}\nexport const checkOverlappingDayjs = (timeRanges: TimeRangeDayjs[]): boolean => {\n for (let i = 0; i < timeRanges.length; i++) {\n const { startTime: startTime1, endTime: endTime1 } = timeRanges[i];\n if (!startTime1 || !endTime1) continue; // Skip if either is null\n\n for (let j = i + 1; j < timeRanges.length; j++) {\n const { startTime: startTime2, endTime: endTime2 } = timeRanges[j];\n if (!startTime2 || !endTime2) continue; // Skip if either is null\n\n if (\n startTime1.isBefore(endTime2) &&\n startTime2.isBefore(endTime1)\n ) {\n return true; // Overlap found\n }\n }\n }\n return false; // No overlap\n};"]}
@@ -0,0 +1,59 @@
1
+ import { io } from "socket.io-client";
2
+ import { baseURL } from "./constant";
3
+ import { configStore } from "../store/store";
4
+ let socket = null;
5
+ export function initSocket(options = {}) {
6
+ if (!socket) {
7
+ const url = baseURL + '/chat';
8
+ socket = io(url, {
9
+ transports: ['websocket'],
10
+ autoConnect: true,
11
+ reconnection: true,
12
+ reconnectionDelay: 1000,
13
+ reconnectionDelayMax: 10000,
14
+ reconnectionAttempts: 10,
15
+ timeout: 20000,
16
+ forceNew: true,
17
+ auth: {
18
+ accessToken: configStore.get('accessToken'),
19
+ },
20
+ ...options
21
+ });
22
+ socket.on('connect', () => {
23
+ console.log('[socket] Connected:', socket?.id);
24
+ });
25
+ socket.on('disconnect', () => {
26
+ console.log('[socket] Disconnected');
27
+ });
28
+ }
29
+ return socket;
30
+ }
31
+ export function getSocket() {
32
+ return socket;
33
+ }
34
+ export function disconnectSocket() {
35
+ if (socket) {
36
+ socket.removeAllListeners();
37
+ socket.disconnect();
38
+ socket = null;
39
+ }
40
+ }
41
+ export function joinRoom(room) {
42
+ if (socket && socket.connected) {
43
+ socket.emit('subscribe', { room });
44
+ console.log(`[socket] Joined room: ${room}`);
45
+ }
46
+ else {
47
+ console.warn('[socket] Cannot join room: socket not connected');
48
+ }
49
+ }
50
+ export function leaveRoom(room) {
51
+ if (socket && socket.connected) {
52
+ socket.emit('unsubscribe', { room });
53
+ console.log(`[socket] Leaved room: ${room}`);
54
+ }
55
+ else {
56
+ console.warn('[socket] Cannot leaved room: socket not connected');
57
+ }
58
+ }
59
+ //# sourceMappingURL=socket.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"socket.js","sourceRoot":"","sources":["../../src/utils/socket.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAU,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AACrC,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAE7C,IAAI,MAAM,GAAkB,IAAI,CAAC;AAEjC,MAAM,UAAU,UAAU,CAAC,OAAO,GAAG,EAAE;IACrC,IAAI,CAAC,MAAM,EAAE,CAAC;QACZ,MAAM,GAAG,GAAG,OAAO,GAAG,OAAO,CAAA;QAC7B,MAAM,GAAG,EAAE,CAAC,GAAG,EAAE;YACf,UAAU,EAAE,CAAC,WAAW,CAAC;YACzB,WAAW,EAAE,IAAI;YACjB,YAAY,EAAE,IAAI;YAClB,iBAAiB,EAAE,IAAI;YACvB,oBAAoB,EAAE,KAAK;YAC3B,oBAAoB,EAAE,EAAE;YACxB,OAAO,EAAE,KAAK;YACd,QAAQ,EAAE,IAAI;YACd,IAAI,EAAE;gBACJ,WAAW,EAAE,WAAW,CAAC,GAAG,CAAC,aAAa,CAAC;aAC5C;YACD,GAAG,OAAO;SACX,CAAC,CAAC;QAEH,MAAM,CAAC,EAAE,CAAC,SAAS,EAAE,GAAG,EAAE;YACxB,OAAO,CAAC,GAAG,CAAC,qBAAqB,EAAE,MAAM,EAAE,EAAE,CAAC,CAAC;QACjD,CAAC,CAAC,CAAC;QAEH,MAAM,CAAC,EAAE,CAAC,YAAY,EAAE,GAAG,EAAE;YAC3B,OAAO,CAAC,GAAG,CAAC,uBAAuB,CAAC,CAAC;QACvC,CAAC,CAAC,CAAC;IACL,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,MAAM,UAAU,SAAS;IACvB,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,MAAM,UAAU,gBAAgB;IAC9B,IAAI,MAAM,EAAE,CAAC;QACX,MAAM,CAAC,kBAAkB,EAAE,CAAC;QAC5B,MAAM,CAAC,UAAU,EAAE,CAAC;QACpB,MAAM,GAAG,IAAI,CAAC;IAChB,CAAC;AACH,CAAC;AAED,MAAM,UAAU,QAAQ,CAAC,IAAY;IACnC,IAAI,MAAM,IAAI,MAAM,CAAC,SAAS,EAAE,CAAC;QAC/B,MAAM,CAAC,IAAI,CAAC,WAAW,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC;QACnC,OAAO,CAAC,GAAG,CAAC,yBAAyB,IAAI,EAAE,CAAC,CAAC;IAC/C,CAAC;SAAM,CAAC;QACN,OAAO,CAAC,IAAI,CAAC,iDAAiD,CAAC,CAAC;IAClE,CAAC;AACH,CAAC;AAED,MAAM,UAAU,SAAS,CAAC,IAAY;IACpC,IAAI,MAAM,IAAI,MAAM,CAAC,SAAS,EAAE,CAAC;QAC/B,MAAM,CAAC,IAAI,CAAC,aAAa,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC;QACrC,OAAO,CAAC,GAAG,CAAC,yBAAyB,IAAI,EAAE,CAAC,CAAC;IAC/C,CAAC;SAAM,CAAC;QACN,OAAO,CAAC,IAAI,CAAC,mDAAmD,CAAC,CAAC;IACpE,CAAC;AACH,CAAC","sourcesContent":["import { io, Socket } from 'socket.io-client';\nimport { baseURL } from './constant';\nimport { configStore } from '../store/store';\n\nlet socket: Socket | null = null;\n\nexport function initSocket(options = {}): Socket {\n if (!socket) {\n const url = baseURL + '/chat'\n socket = io(url, {\n transports: ['websocket'],\n autoConnect: true,\n reconnection: true,\n reconnectionDelay: 1000,\n reconnectionDelayMax: 10000,\n reconnectionAttempts: 10,\n timeout: 20000,\n forceNew: true,\n auth: {\n accessToken: configStore.get('accessToken'),\n },\n ...options\n });\n\n socket.on('connect', () => {\n console.log('[socket] Connected:', socket?.id);\n });\n\n socket.on('disconnect', () => {\n console.log('[socket] Disconnected');\n });\n }\n\n return socket;\n}\n\nexport function getSocket(): Socket | null {\n return socket;\n}\n\nexport function disconnectSocket() {\n if (socket) {\n socket.removeAllListeners();\n socket.disconnect();\n socket = null;\n }\n}\n\nexport function joinRoom(room: string) {\n if (socket && socket.connected) {\n socket.emit('subscribe', { room });\n console.log(`[socket] Joined room: ${room}`);\n } else {\n console.warn('[socket] Cannot join room: socket not connected');\n }\n}\n\nexport function leaveRoom(room: string) {\n if (socket && socket.connected) {\n socket.emit('unsubscribe', { room });\n console.log(`[socket] Leaved room: ${room}`);\n } else {\n console.warn('[socket] Cannot leaved room: socket not connected');\n }\n}"]}
@@ -0,0 +1,8 @@
1
+ import i18n from "../global/i18n";
2
+ export function format(first, middle, last) {
3
+ return (first || '') + (middle ? ` ${middle}` : '') + (last ? ` ${last}` : '');
4
+ }
5
+ export function useTranslation() {
6
+ return i18n.t;
7
+ }
8
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/utils/utils.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,gBAAgB,CAAC;AAElC,MAAM,UAAU,MAAM,CAAC,KAAc,EAAE,MAAe,EAAE,IAAa;IACnE,OAAO,CAAC,KAAK,IAAI,EAAE,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;AACjF,CAAC;AAED,MAAM,UAAU,cAAc;IAC5B,OAAO,IAAI,CAAC,CAAC,CAAC;AAChB,CAAC","sourcesContent":["import i18n from \"../global/i18n\";\n\nexport function format(first?: string, middle?: string, last?: string): string {\n return (first || '') + (middle ? ` ${middle}` : '') + (last ? ` ${last}` : '');\n}\n\nexport function useTranslation() {\n return i18n.t;\n}"]}
@@ -0,0 +1,11 @@
1
+ import type { Components, JSX } from "../types/components";
2
+
3
+ interface AutocompleteSelect extends Components.AutocompleteSelect, HTMLElement {}
4
+ export const AutocompleteSelect: {
5
+ prototype: AutocompleteSelect;
6
+ new (): AutocompleteSelect;
7
+ };
8
+ /**
9
+ * Used to define this component and all nested components recursively.
10
+ */
11
+ export const defineCustomElement: () => void;
@@ -0,0 +1,9 @@
1
+ import { A as AutocompleteSelect$1, d as defineCustomElement$1 } from './p-CmWIRJ5t.js';
2
+
3
+ const AutocompleteSelect = AutocompleteSelect$1;
4
+ const defineCustomElement = defineCustomElement$1;
5
+
6
+ export { AutocompleteSelect, defineCustomElement };
7
+ //# sourceMappingURL=autocomplete-select.js.map
8
+
9
+ //# sourceMappingURL=autocomplete-select.js.map
@@ -0,0 +1 @@
1
+ {"file":"autocomplete-select.js","mappings":";;;;;;;","names":[],"sources":[],"sourcesContent":[],"version":3}
@@ -0,0 +1,11 @@
1
+ import type { Components, JSX } from "../types/components";
2
+
3
+ interface ChannelBox extends Components.ChannelBox, HTMLElement {}
4
+ export const ChannelBox: {
5
+ prototype: ChannelBox;
6
+ new (): ChannelBox;
7
+ };
8
+ /**
9
+ * Used to define this component and all nested components recursively.
10
+ */
11
+ export const defineCustomElement: () => void;
@@ -0,0 +1,9 @@
1
+ import { C as ChannelBox$1, d as defineCustomElement$1 } from './p-Urxy5c9-.js';
2
+
3
+ const ChannelBox = ChannelBox$1;
4
+ const defineCustomElement = defineCustomElement$1;
5
+
6
+ export { ChannelBox, defineCustomElement };
7
+ //# sourceMappingURL=channel-box.js.map
8
+
9
+ //# sourceMappingURL=channel-box.js.map
@@ -0,0 +1 @@
1
+ {"file":"channel-box.js","mappings":";;;;;;;","names":[],"sources":[],"sourcesContent":[],"version":3}
@@ -0,0 +1,11 @@
1
+ import type { Components, JSX } from "../types/components";
2
+
3
+ interface ChatApp extends Components.ChatApp, HTMLElement {}
4
+ export const ChatApp: {
5
+ prototype: ChatApp;
6
+ new (): ChatApp;
7
+ };
8
+ /**
9
+ * Used to define this component and all nested components recursively.
10
+ */
11
+ export const defineCustomElement: () => void;