@sikka/hawa 0.1.1 → 0.1.2-next

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 (389) hide show
  1. package/README.md +21 -43
  2. package/dist/index.css +1385 -0
  3. package/dist/index.d.mts +15 -0
  4. package/dist/index.d.ts +15 -0
  5. package/dist/index.js +246 -0
  6. package/dist/index.mjs +157 -0
  7. package/package.json +48 -115
  8. package/.github/workflows/hawa-actions.yml +0 -112
  9. package/.github/workflows/hawa-publish-push.yml +0 -74
  10. package/.github/workflows/hawa-publish.yml +0 -48
  11. package/.prettierrc +0 -28
  12. package/_config.yml +0 -1
  13. package/dist/styles.css +0 -3511
  14. package/es/blocks/Account/HawaApiBox.d.ts +0 -8
  15. package/es/blocks/Account/UserProfileForm.d.ts +0 -8
  16. package/es/blocks/Account/UserSettingsForm.d.ts +0 -9
  17. package/es/blocks/Account/index.d.ts +0 -2
  18. package/es/blocks/AuthForms/AppLanding.d.ts +0 -14
  19. package/es/blocks/AuthForms/CodeConfirmation.d.ts +0 -22
  20. package/es/blocks/AuthForms/NewPasswordForm.d.ts +0 -18
  21. package/es/blocks/AuthForms/ResetPasswordForm.d.ts +0 -18
  22. package/es/blocks/AuthForms/SignInBlock.d.ts +0 -2
  23. package/es/blocks/AuthForms/SignInForm.d.ts +0 -51
  24. package/es/blocks/AuthForms/SignInPhone.d.ts +0 -13
  25. package/es/blocks/AuthForms/SignUpForm.d.ts +0 -55
  26. package/es/blocks/AuthForms/index.d.ts +0 -8
  27. package/es/blocks/Misc/EmptyState.d.ts +0 -11
  28. package/es/blocks/Misc/LeadGenerator.d.ts +0 -12
  29. package/es/blocks/Misc/Newsletter.d.ts +0 -12
  30. package/es/blocks/Misc/NoPermission.d.ts +0 -10
  31. package/es/blocks/Misc/NotFound.d.ts +0 -11
  32. package/es/blocks/Misc/Testimonial.d.ts +0 -6
  33. package/es/blocks/Misc/index.d.ts +0 -6
  34. package/es/blocks/Payment/ChargeWalletForm.d.ts +0 -12
  35. package/es/blocks/Payment/CheckoutForm.d.ts +0 -27
  36. package/es/blocks/Payment/Confirmation.d.ts +0 -38
  37. package/es/blocks/Payment/CreditCardForm.d.ts +0 -7
  38. package/es/blocks/Payment/PayWithWallet.d.ts +0 -8
  39. package/es/blocks/Payment/SelectPayment.d.ts +0 -26
  40. package/es/blocks/Payment/index.d.ts +0 -6
  41. package/es/blocks/Pricing/ComparingPlans.d.ts +0 -39
  42. package/es/blocks/Pricing/HorizontalPricing.d.ts +0 -47
  43. package/es/blocks/Pricing/PricingPlans.d.ts +0 -47
  44. package/es/blocks/Pricing/index.d.ts +0 -3
  45. package/es/blocks/Referral/ReferralAccount.d.ts +0 -7
  46. package/es/blocks/Referral/ReferralSettlement.d.ts +0 -8
  47. package/es/blocks/Referral/ReferralStats.d.ts +0 -8
  48. package/es/blocks/Referral/index.d.ts +0 -3
  49. package/es/blocks/index.d.ts +0 -6
  50. package/es/countries.d.ts +0 -2
  51. package/es/elements/ArrowCarousel.d.ts +0 -13
  52. package/es/elements/AutoCompleteField.d.ts +0 -8
  53. package/es/elements/BackToTop.d.ts +0 -10
  54. package/es/elements/Breadcrumb.d.ts +0 -12
  55. package/es/elements/Button.d.ts +0 -12
  56. package/es/elements/Card.d.ts +0 -10
  57. package/es/elements/DragDropImages.d.ts +0 -28
  58. package/es/elements/DraggableCard.d.ts +0 -6
  59. package/es/elements/FloatingComment.d.ts +0 -32
  60. package/es/elements/FloatingCommentExec.d.ts +0 -4
  61. package/es/elements/FloatingCommentSlate.d.ts +0 -19
  62. package/es/elements/HawaAccordion.d.ts +0 -11
  63. package/es/elements/HawaAdCard.d.ts +0 -10
  64. package/es/elements/HawaAlert.d.ts +0 -23
  65. package/es/elements/HawaButton.d.ts +0 -21
  66. package/es/elements/HawaCardInput.d.ts +0 -25
  67. package/es/elements/HawaCheckbox.d.ts +0 -11
  68. package/es/elements/HawaChip.d.ts +0 -17
  69. package/es/elements/HawaCodeBlock.d.ts +0 -15
  70. package/es/elements/HawaColorPicker.d.ts +0 -9
  71. package/es/elements/HawaCopyrights.d.ts +0 -15
  72. package/es/elements/HawaDatepicker.d.ts +0 -4
  73. package/es/elements/HawaDropdownMenu.d.ts +0 -7
  74. package/es/elements/HawaIconCount.d.ts +0 -9
  75. package/es/elements/HawaInlineCode.d.ts +0 -6
  76. package/es/elements/HawaItemCard.d.ts +0 -32
  77. package/es/elements/HawaLandingCard.d.ts +0 -18
  78. package/es/elements/HawaLoading.d.ts +0 -8
  79. package/es/elements/HawaLogoButton.d.ts +0 -10
  80. package/es/elements/HawaMenu.d.ts +0 -24
  81. package/es/elements/HawaModal.d.ts +0 -21
  82. package/es/elements/HawaPanelTabs.d.ts +0 -13
  83. package/es/elements/HawaPhoneInput.d.ts +0 -11
  84. package/es/elements/HawaPinInput.d.ts +0 -10
  85. package/es/elements/HawaPricingCard.d.ts +0 -21
  86. package/es/elements/HawaRadio.d.ts +0 -16
  87. package/es/elements/HawaRange.d.ts +0 -12
  88. package/es/elements/HawaSearchBar.d.ts +0 -4
  89. package/es/elements/HawaSelect.d.ts +0 -23
  90. package/es/elements/HawaSettingsRow.d.ts +0 -44
  91. package/es/elements/HawaSnackbar.d.ts +0 -19
  92. package/es/elements/HawaStats.d.ts +0 -14
  93. package/es/elements/HawaStepper.d.ts +0 -8
  94. package/es/elements/HawaStoreButtons.d.ts +0 -7
  95. package/es/elements/HawaSwitch.d.ts +0 -7
  96. package/es/elements/HawaTable.d.ts +0 -45
  97. package/es/elements/HawaTabs.d.ts +0 -13
  98. package/es/elements/HawaTextField.d.ts +0 -31
  99. package/es/elements/HawaTooltip.d.ts +0 -12
  100. package/es/elements/HawaTypography.d.ts +0 -7
  101. package/es/elements/Icons.d.ts +0 -19
  102. package/es/elements/Input.d.ts +0 -5
  103. package/es/elements/InvoiceAccordion.d.ts +0 -31
  104. package/es/elements/Label.d.ts +0 -5
  105. package/es/elements/SubsectionList.d.ts +0 -19
  106. package/es/elements/TabPanel.d.ts +0 -8
  107. package/es/elements/Timeline.d.ts +0 -13
  108. package/es/elements/UsageCard.d.ts +0 -9
  109. package/es/elements/UserFeedback.d.ts +0 -14
  110. package/es/elements/index.d.ts +0 -52
  111. package/es/hooks/index.d.ts +0 -2
  112. package/es/hooks/useBreakpoint.d.ts +0 -2
  113. package/es/hooks/useDiscloser.d.ts +0 -7
  114. package/es/hooks/useHover.d.ts +0 -3
  115. package/es/hooks/useScrollPosition.d.ts +0 -2
  116. package/es/hooks/useTable.d.ts +0 -5
  117. package/es/index.d.ts +0 -4
  118. package/es/index.es.js +0 -16
  119. package/es/layout/AppSidebar.d.ts +0 -11
  120. package/es/layout/Banner.d.ts +0 -14
  121. package/es/layout/Box.d.ts +0 -2
  122. package/es/layout/Footer.d.ts +0 -20
  123. package/es/layout/HawaAppLayout.d.ts +0 -31
  124. package/es/layout/HawaAppLayoutSimplified.d.ts +0 -33
  125. package/es/layout/HawaBottomAppBar.d.ts +0 -8
  126. package/es/layout/HawaContainer.d.ts +0 -10
  127. package/es/layout/HawaGrid.d.ts +0 -6
  128. package/es/layout/HawaSiteLayout.d.ts +0 -23
  129. package/es/layout/index.d.ts +0 -10
  130. package/es/stories/ElementsStories/Breadcrumb.stories.d.ts +0 -6
  131. package/es/stories/ManualStories/BlocksIntroduction.stories.d.ts +0 -21
  132. package/es/stories/ManualStories/Customization.stories.d.ts +0 -21
  133. package/es/stories/ManualStories/ElementsIntroduction.stories.d.ts +0 -21
  134. package/es/stories/ManualStories/Installation.stories.d.ts +0 -21
  135. package/es/stories/ManualStories/LayoutIntroduction.stories.d.ts +0 -21
  136. package/es/stories/ManualStories/Overview.stories.d.ts +0 -22
  137. package/es/stories/ManualStories/Usage.stories.d.ts +0 -21
  138. package/es/util.d.ts +0 -10
  139. package/lib/blocks/Account/HawaApiBox.d.ts +0 -8
  140. package/lib/blocks/Account/UserProfileForm.d.ts +0 -8
  141. package/lib/blocks/Account/UserSettingsForm.d.ts +0 -9
  142. package/lib/blocks/Account/index.d.ts +0 -2
  143. package/lib/blocks/AuthForms/AppLanding.d.ts +0 -14
  144. package/lib/blocks/AuthForms/CodeConfirmation.d.ts +0 -22
  145. package/lib/blocks/AuthForms/NewPasswordForm.d.ts +0 -18
  146. package/lib/blocks/AuthForms/ResetPasswordForm.d.ts +0 -18
  147. package/lib/blocks/AuthForms/SignInBlock.d.ts +0 -2
  148. package/lib/blocks/AuthForms/SignInForm.d.ts +0 -51
  149. package/lib/blocks/AuthForms/SignInPhone.d.ts +0 -13
  150. package/lib/blocks/AuthForms/SignUpForm.d.ts +0 -55
  151. package/lib/blocks/AuthForms/index.d.ts +0 -8
  152. package/lib/blocks/Misc/EmptyState.d.ts +0 -11
  153. package/lib/blocks/Misc/LeadGenerator.d.ts +0 -12
  154. package/lib/blocks/Misc/Newsletter.d.ts +0 -12
  155. package/lib/blocks/Misc/NoPermission.d.ts +0 -10
  156. package/lib/blocks/Misc/NotFound.d.ts +0 -11
  157. package/lib/blocks/Misc/Testimonial.d.ts +0 -6
  158. package/lib/blocks/Misc/index.d.ts +0 -6
  159. package/lib/blocks/Payment/ChargeWalletForm.d.ts +0 -12
  160. package/lib/blocks/Payment/CheckoutForm.d.ts +0 -27
  161. package/lib/blocks/Payment/Confirmation.d.ts +0 -38
  162. package/lib/blocks/Payment/CreditCardForm.d.ts +0 -7
  163. package/lib/blocks/Payment/PayWithWallet.d.ts +0 -8
  164. package/lib/blocks/Payment/SelectPayment.d.ts +0 -26
  165. package/lib/blocks/Payment/index.d.ts +0 -6
  166. package/lib/blocks/Pricing/ComparingPlans.d.ts +0 -39
  167. package/lib/blocks/Pricing/HorizontalPricing.d.ts +0 -47
  168. package/lib/blocks/Pricing/PricingPlans.d.ts +0 -47
  169. package/lib/blocks/Pricing/index.d.ts +0 -3
  170. package/lib/blocks/Referral/ReferralAccount.d.ts +0 -7
  171. package/lib/blocks/Referral/ReferralSettlement.d.ts +0 -8
  172. package/lib/blocks/Referral/ReferralStats.d.ts +0 -8
  173. package/lib/blocks/Referral/index.d.ts +0 -3
  174. package/lib/blocks/index.d.ts +0 -6
  175. package/lib/countries.d.ts +0 -2
  176. package/lib/elements/ArrowCarousel.d.ts +0 -13
  177. package/lib/elements/AutoCompleteField.d.ts +0 -8
  178. package/lib/elements/BackToTop.d.ts +0 -10
  179. package/lib/elements/Breadcrumb.d.ts +0 -12
  180. package/lib/elements/Button.d.ts +0 -12
  181. package/lib/elements/Card.d.ts +0 -10
  182. package/lib/elements/DragDropImages.d.ts +0 -28
  183. package/lib/elements/DraggableCard.d.ts +0 -6
  184. package/lib/elements/FloatingComment.d.ts +0 -32
  185. package/lib/elements/FloatingCommentExec.d.ts +0 -4
  186. package/lib/elements/FloatingCommentSlate.d.ts +0 -19
  187. package/lib/elements/HawaAccordion.d.ts +0 -11
  188. package/lib/elements/HawaAdCard.d.ts +0 -10
  189. package/lib/elements/HawaAlert.d.ts +0 -23
  190. package/lib/elements/HawaButton.d.ts +0 -21
  191. package/lib/elements/HawaCardInput.d.ts +0 -25
  192. package/lib/elements/HawaCheckbox.d.ts +0 -11
  193. package/lib/elements/HawaChip.d.ts +0 -17
  194. package/lib/elements/HawaCodeBlock.d.ts +0 -15
  195. package/lib/elements/HawaColorPicker.d.ts +0 -9
  196. package/lib/elements/HawaCopyrights.d.ts +0 -15
  197. package/lib/elements/HawaDatepicker.d.ts +0 -4
  198. package/lib/elements/HawaDropdownMenu.d.ts +0 -7
  199. package/lib/elements/HawaIconCount.d.ts +0 -9
  200. package/lib/elements/HawaInlineCode.d.ts +0 -6
  201. package/lib/elements/HawaItemCard.d.ts +0 -32
  202. package/lib/elements/HawaLandingCard.d.ts +0 -18
  203. package/lib/elements/HawaLoading.d.ts +0 -8
  204. package/lib/elements/HawaLogoButton.d.ts +0 -10
  205. package/lib/elements/HawaMenu.d.ts +0 -24
  206. package/lib/elements/HawaModal.d.ts +0 -21
  207. package/lib/elements/HawaPanelTabs.d.ts +0 -13
  208. package/lib/elements/HawaPhoneInput.d.ts +0 -11
  209. package/lib/elements/HawaPinInput.d.ts +0 -10
  210. package/lib/elements/HawaPricingCard.d.ts +0 -21
  211. package/lib/elements/HawaRadio.d.ts +0 -16
  212. package/lib/elements/HawaRange.d.ts +0 -12
  213. package/lib/elements/HawaSearchBar.d.ts +0 -4
  214. package/lib/elements/HawaSelect.d.ts +0 -23
  215. package/lib/elements/HawaSettingsRow.d.ts +0 -44
  216. package/lib/elements/HawaSnackbar.d.ts +0 -19
  217. package/lib/elements/HawaStats.d.ts +0 -14
  218. package/lib/elements/HawaStepper.d.ts +0 -8
  219. package/lib/elements/HawaStoreButtons.d.ts +0 -7
  220. package/lib/elements/HawaSwitch.d.ts +0 -7
  221. package/lib/elements/HawaTable.d.ts +0 -45
  222. package/lib/elements/HawaTabs.d.ts +0 -13
  223. package/lib/elements/HawaTextField.d.ts +0 -31
  224. package/lib/elements/HawaTooltip.d.ts +0 -12
  225. package/lib/elements/HawaTypography.d.ts +0 -7
  226. package/lib/elements/Icons.d.ts +0 -19
  227. package/lib/elements/Input.d.ts +0 -5
  228. package/lib/elements/InvoiceAccordion.d.ts +0 -31
  229. package/lib/elements/Label.d.ts +0 -5
  230. package/lib/elements/SubsectionList.d.ts +0 -19
  231. package/lib/elements/TabPanel.d.ts +0 -8
  232. package/lib/elements/Timeline.d.ts +0 -13
  233. package/lib/elements/UsageCard.d.ts +0 -9
  234. package/lib/elements/UserFeedback.d.ts +0 -14
  235. package/lib/elements/index.d.ts +0 -52
  236. package/lib/hooks/index.d.ts +0 -2
  237. package/lib/hooks/useBreakpoint.d.ts +0 -2
  238. package/lib/hooks/useDiscloser.d.ts +0 -7
  239. package/lib/hooks/useHover.d.ts +0 -3
  240. package/lib/hooks/useScrollPosition.d.ts +0 -2
  241. package/lib/hooks/useTable.d.ts +0 -5
  242. package/lib/index.d.ts +0 -4
  243. package/lib/index.js +0 -16
  244. package/lib/layout/AppSidebar.d.ts +0 -11
  245. package/lib/layout/Banner.d.ts +0 -14
  246. package/lib/layout/Box.d.ts +0 -2
  247. package/lib/layout/Footer.d.ts +0 -20
  248. package/lib/layout/HawaAppLayout.d.ts +0 -31
  249. package/lib/layout/HawaAppLayoutSimplified.d.ts +0 -33
  250. package/lib/layout/HawaBottomAppBar.d.ts +0 -8
  251. package/lib/layout/HawaContainer.d.ts +0 -10
  252. package/lib/layout/HawaGrid.d.ts +0 -6
  253. package/lib/layout/HawaSiteLayout.d.ts +0 -23
  254. package/lib/layout/index.d.ts +0 -10
  255. package/lib/stories/ElementsStories/Breadcrumb.stories.d.ts +0 -6
  256. package/lib/stories/ManualStories/BlocksIntroduction.stories.d.ts +0 -21
  257. package/lib/stories/ManualStories/Customization.stories.d.ts +0 -21
  258. package/lib/stories/ManualStories/ElementsIntroduction.stories.d.ts +0 -21
  259. package/lib/stories/ManualStories/Installation.stories.d.ts +0 -21
  260. package/lib/stories/ManualStories/LayoutIntroduction.stories.d.ts +0 -21
  261. package/lib/stories/ManualStories/Overview.stories.d.ts +0 -22
  262. package/lib/stories/ManualStories/Usage.stories.d.ts +0 -21
  263. package/lib/util.d.ts +0 -10
  264. package/postcss.config.js +0 -6
  265. package/rollup.config.js +0 -61
  266. package/src/blocks/Account/HawaApiBox.tsx +0 -12
  267. package/src/blocks/Account/UserProfileForm.tsx +0 -113
  268. package/src/blocks/Account/UserSettingsForm.tsx +0 -27
  269. package/src/blocks/Account/index.ts +0 -2
  270. package/src/blocks/AuthForms/AppLanding.tsx +0 -34
  271. package/src/blocks/AuthForms/CodeConfirmation.tsx +0 -71
  272. package/src/blocks/AuthForms/NewPasswordForm.tsx +0 -101
  273. package/src/blocks/AuthForms/ResetPasswordForm.tsx +0 -89
  274. package/src/blocks/AuthForms/SignInBlock.tsx +0 -60
  275. package/src/blocks/AuthForms/SignInForm.tsx +0 -230
  276. package/src/blocks/AuthForms/SignInPhone.tsx +0 -56
  277. package/src/blocks/AuthForms/SignUpForm.tsx +0 -342
  278. package/src/blocks/AuthForms/index.ts +0 -8
  279. package/src/blocks/Misc/EmptyState.tsx +0 -43
  280. package/src/blocks/Misc/LeadGenerator.tsx +0 -44
  281. package/src/blocks/Misc/Newsletter.tsx +0 -50
  282. package/src/blocks/Misc/NoPermission.tsx +0 -40
  283. package/src/blocks/Misc/NotFound.tsx +0 -34
  284. package/src/blocks/Misc/Testimonial.tsx +0 -44
  285. package/src/blocks/Misc/index.ts +0 -6
  286. package/src/blocks/Payment/ChargeWalletForm.tsx +0 -82
  287. package/src/blocks/Payment/CheckoutForm.tsx +0 -260
  288. package/src/blocks/Payment/Confirmation.tsx +0 -94
  289. package/src/blocks/Payment/CreditCardForm.tsx +0 -109
  290. package/src/blocks/Payment/PayWithWallet.tsx +0 -26
  291. package/src/blocks/Payment/SelectPayment.tsx +0 -84
  292. package/src/blocks/Payment/index.ts +0 -6
  293. package/src/blocks/Pricing/ComparingPlans.tsx +0 -154
  294. package/src/blocks/Pricing/HorizontalPricing.tsx +0 -148
  295. package/src/blocks/Pricing/PricingPlans.tsx +0 -81
  296. package/src/blocks/Pricing/index.ts +0 -3
  297. package/src/blocks/Referral/ReferralAccount.tsx +0 -65
  298. package/src/blocks/Referral/ReferralSettlement.tsx +0 -170
  299. package/src/blocks/Referral/ReferralStats.tsx +0 -85
  300. package/src/blocks/Referral/index.ts +0 -3
  301. package/src/blocks/index.ts +0 -6
  302. package/src/countries.ts +0 -1940
  303. package/src/elements/ArrowCarousel.tsx +0 -94
  304. package/src/elements/AutoCompleteField.tsx +0 -37
  305. package/src/elements/BackToTop.tsx +0 -129
  306. package/src/elements/Breadcrumb.tsx +0 -41
  307. package/src/elements/Button.tsx +0 -77
  308. package/src/elements/Card.tsx +0 -87
  309. package/src/elements/DragDropImages.tsx +0 -251
  310. package/src/elements/DraggableCard.tsx +0 -27
  311. package/src/elements/FloatingComment.tsx +0 -1107
  312. package/src/elements/FloatingCommentExec.tsx +0 -106
  313. package/src/elements/FloatingCommentSlate.tsx +0 -149
  314. package/src/elements/HawaAccordion.tsx +0 -57
  315. package/src/elements/HawaAdCard.tsx +0 -49
  316. package/src/elements/HawaAlert.tsx +0 -195
  317. package/src/elements/HawaButton.tsx +0 -241
  318. package/src/elements/HawaCardInput.tsx +0 -318
  319. package/src/elements/HawaCheckbox.tsx +0 -54
  320. package/src/elements/HawaChip.tsx +0 -59
  321. package/src/elements/HawaCodeBlock.tsx +0 -156
  322. package/src/elements/HawaColorPicker.tsx +0 -40
  323. package/src/elements/HawaCopyrights.tsx +0 -30
  324. package/src/elements/HawaDatepicker.tsx +0 -23
  325. package/src/elements/HawaDropdownMenu.tsx +0 -267
  326. package/src/elements/HawaIconCount.tsx +0 -17
  327. package/src/elements/HawaInlineCode.tsx +0 -9
  328. package/src/elements/HawaItemCard.tsx +0 -157
  329. package/src/elements/HawaLandingCard.tsx +0 -68
  330. package/src/elements/HawaLoading.tsx +0 -83
  331. package/src/elements/HawaLogoButton.tsx +0 -154
  332. package/src/elements/HawaMenu.tsx +0 -226
  333. package/src/elements/HawaModal.tsx +0 -89
  334. package/src/elements/HawaPanelTabs.tsx +0 -57
  335. package/src/elements/HawaPhoneInput.tsx +0 -171
  336. package/src/elements/HawaPinInput.tsx +0 -78
  337. package/src/elements/HawaPricingCard.tsx +0 -107
  338. package/src/elements/HawaRadio.tsx +0 -180
  339. package/src/elements/HawaRange.tsx +0 -49
  340. package/src/elements/HawaSearchBar.tsx +0 -7
  341. package/src/elements/HawaSelect.tsx +0 -209
  342. package/src/elements/HawaSettingsRow.tsx +0 -74
  343. package/src/elements/HawaSnackbar.tsx +0 -137
  344. package/src/elements/HawaStats.tsx +0 -72
  345. package/src/elements/HawaStepper.tsx +0 -109
  346. package/src/elements/HawaStoreButtons.tsx +0 -129
  347. package/src/elements/HawaSwitch.tsx +0 -41
  348. package/src/elements/HawaTable.tsx +0 -587
  349. package/src/elements/HawaTabs.tsx +0 -143
  350. package/src/elements/HawaTextField.tsx +0 -148
  351. package/src/elements/HawaTooltip.tsx +0 -137
  352. package/src/elements/HawaTypography.tsx +0 -9
  353. package/src/elements/Icons.tsx +0 -145
  354. package/src/elements/Input.tsx +0 -25
  355. package/src/elements/InvoiceAccordion.tsx +0 -155
  356. package/src/elements/Label.tsx +0 -26
  357. package/src/elements/SubsectionList.tsx +0 -77
  358. package/src/elements/TabPanel.tsx +0 -25
  359. package/src/elements/Timeline.tsx +0 -35
  360. package/src/elements/UsageCard.tsx +0 -45
  361. package/src/elements/UserFeedback.tsx +0 -126
  362. package/src/elements/index.ts +0 -55
  363. package/src/hooks/index.ts +0 -2
  364. package/src/hooks/useBreakpoint.ts +0 -24
  365. package/src/hooks/useDiscloser.ts +0 -21
  366. package/src/hooks/useHover.ts +0 -25
  367. package/src/hooks/useScrollPosition.ts +0 -30
  368. package/src/hooks/useTable.ts +0 -159
  369. package/src/index.ts +0 -4
  370. package/src/layout/AppSidebar.tsx +0 -39
  371. package/src/layout/Banner.tsx +0 -122
  372. package/src/layout/Box.tsx +0 -5
  373. package/src/layout/Footer.tsx +0 -71
  374. package/src/layout/HawaAppLayout.tsx +0 -527
  375. package/src/layout/HawaAppLayoutSimplified.tsx +0 -568
  376. package/src/layout/HawaBottomAppBar.tsx +0 -55
  377. package/src/layout/HawaContainer.tsx +0 -43
  378. package/src/layout/HawaGrid.tsx +0 -15
  379. package/src/layout/HawaSiteLayout.tsx +0 -159
  380. package/src/layout/index.ts +0 -10
  381. package/src/styles.css +0 -3511
  382. package/src/tailwind.css +0 -179
  383. package/src/translations/ar.json +0 -30
  384. package/src/translations/en.json +0 -29
  385. package/src/translations/i18n.js +0 -15
  386. package/src/util.ts +0 -149
  387. package/tailwind.config.js +0 -227
  388. package/tools/build-styles.js +0 -17
  389. package/tsconfig.json +0 -31
@@ -1,1107 +0,0 @@
1
- import React, { useRef, useState, useEffect } from "react"
2
- import clsx from "clsx"
3
-
4
- const Property = (props) => {
5
- return (
6
- <div
7
- className="border-box mr-[10px] flex h-[32px] w-[32px] items-center justify-center rounded bg-gray-300 p-2"
8
- onMouseDown={props.onMouseDown}
9
- >
10
- {props.name}
11
- </div>
12
- )
13
- }
14
-
15
- type ComponentTypes = {
16
- rtl?: "enabled" | "disabled" | "auto"
17
- onSubmit?: (
18
- content: string,
19
- stylings: { type: keyof typeof stylers; start: number; finish: number }[]
20
- ) => void
21
- }
22
-
23
- const stylers = {
24
- bold: { css: "font-bold", content: "B" },
25
- italic: { id: "italic", css: "italic", content: "I" },
26
- under: { id: "under", css: "underline", content: "U" },
27
- strike: { id: "strike", css: "line-through", content: "S" },
28
- }
29
-
30
- // FIXME: ? Highlighting a part of styled text with a bit on the left with an overall length not equal to clipboard copied text will result in paste issues
31
-
32
- // FIXME: Highlighting the beginning characters of styled text and then pasting text sometimes doesn't register as right intersecting
33
- // This expecially happens when the selection is for example, [0, 2] and the styling is [0, 3], this might be failure of addition which doesn't offset the styling
34
-
35
- // TODO: Refactor styling splicing into one method
36
- // TODO: Refactor function that simplifies a list of stylings
37
- // TODO: Turn stylings into a class, this should also change .finish to .end
38
-
39
- // Possible logic changes:
40
- // Paste = Removal + Addition -> Styling Removal + Styling Addition
41
- // Drag & Drop = Removal + Addition -> Styling Removal + Styling Addition
42
-
43
- // FIXME:
44
- // - Creating a new line, and typing data in it, and then setting two different stylings on the same text
45
- // FIXME:
46
- // - Type characters, create new line, remove the new line immediately
47
-
48
- // FIXME: Line at first index of content editable
49
-
50
- // FIXME: Typing behind a line break identifier
51
- // One way to prevent it, is to check in the onChange event if the data added (removed might not be needed here), is behind a line break identifier
52
- // if so, move the start and end index by the length of the added, and replace the added, and then add the added back in the offset index
53
-
54
- // FIXME:
55
- // Deleting all text in a line removes that line entirely
56
-
57
- const lineBreakIdentifier = "​"
58
-
59
- export const FloatingComment: React.FunctionComponent<ComponentTypes> = (
60
- props
61
- ) => {
62
- const [text, _setText] = useState({
63
- content: "",
64
- stylings: [], // A styling is an object with 2 indices specifying a substring of text, and the applied effect
65
- revert: [0, 0],
66
- clipboard: [],
67
- events: {
68
- paste: { is: false, length: null },
69
- drop: { is: false, text: null, drag: null },
70
- },
71
- })
72
-
73
- const field = useRef(null)
74
- const _text = useRef(text)
75
- const setText = (data) => {
76
- _text.current = data
77
- _setText(data)
78
- }
79
-
80
- const getChildIndex = (child) => {
81
- for (var i = 0; (child = child.previousSibling); i++);
82
- return i
83
- }
84
-
85
- const getRelativePrecedingSum = (element, endIndex) => {
86
- let nodes: any = Array.from(element.childNodes)
87
- let sum = nodes
88
- .slice(0, endIndex)
89
- .map((node) => node.textContent.length)
90
- .reduce((a, b) => a + b, 0)
91
- return sum
92
- }
93
-
94
- const getLinePrecedingSum = (endIndex) => {
95
- let fieldNodes = Array.from(field.current.childNodes)
96
- let sum = fieldNodes
97
- .slice(0, endIndex)
98
- .map((lineNode: any) => {
99
- let lineNodes = Array.from(lineNode.childNodes)
100
- return getRelativePrecedingSum(lineNode, lineNodes.length)
101
- })
102
- .reduce((a, b) => a + b, 0)
103
-
104
- return sum
105
- }
106
-
107
- const getSelectionPrecedingSum = (name) => {
108
- let selection = window.getSelection()
109
- let nodes = Array.from(field.current.childNodes)
110
-
111
- // All current occurences for text or br:
112
- // Pasting on empty text (text)
113
- // Cutting/removing all text (br)
114
- // Typing the first character in empty text (text)
115
- // Dragging text to the end of the text (text)
116
-
117
- nodes = nodes.filter(
118
- (item: any) => !["#text", "BR"].includes(item.nodeName)
119
- )
120
-
121
- let node = selection[name]
122
- let parent: any = node.parentNode
123
- let sum = 0
124
- // let special = 0
125
-
126
- const isNodeLine =
127
- node.nodeName == "DIV" && Array.from(node.classList).includes("line")
128
-
129
- // If the parent node is a span, this must be a text node
130
- if (parent.nodeName == "SPAN") {
131
- // Get index of span within line
132
- let spanIndex = getChildIndex(parent)
133
-
134
- // Get relative sum within line
135
- sum += getRelativePrecedingSum(parent.parentNode, spanIndex)
136
-
137
- // Get parent line index
138
- let lineIndex = getChildIndex(parent.parentNode)
139
-
140
- // Get relative sum within entire field
141
- sum += getLinePrecedingSum(lineIndex)
142
- }
143
-
144
- // If the parent node is a line element, this must be a new line, so return the preceding sum
145
- if (Array.from(parent.classList).includes("line")) {
146
- // If the node is a text node, then that must mean this is a non-styled drop
147
- if (node.nodeName == "#text") {
148
- let spanIndex = getChildIndex(node)
149
-
150
- sum += getRelativePrecedingSum(parent, spanIndex)
151
- }
152
-
153
- // Get line element index
154
- let lineIndex = getChildIndex(parent)
155
-
156
- // Get relative sum within entire field
157
- sum += getLinePrecedingSum(lineIndex)
158
- }
159
-
160
- if (isNodeLine) {
161
- // Get line element index
162
- let lineIndex = getChildIndex(node)
163
-
164
- // Get relative sum within entire field
165
- sum = getLinePrecedingSum(lineIndex)
166
- }
167
-
168
- // If the parent is the field, return zero
169
- // FIXME: Should we return zero here?
170
- if (parent == field.current && !isNodeLine) {
171
- return 0
172
- }
173
-
174
- // // Special case for dropping text near or inside styled text
175
- // if (!Array.from(parent.parentNode.classList).includes("selection-ignore")) {
176
- // parent = parent.parentNode
177
-
178
- // let index = getChildIndex(selection[name].parentNode)
179
- // special = Array.from(parent.childNodes)
180
- // .slice(0, index)
181
- // .map((e: any) => e.textContent.length)
182
- // .reduce((a, b) => a + b, 0)
183
- // }
184
-
185
- // let index = parent == field.current ? nodes.length : getChildIndex(parent)
186
-
187
- // let sum =
188
- // nodes
189
- // .slice(0, index)
190
- // .map((span: any) => span.textContent.length)
191
- // .reduce((a, b) => a + b, 0) + special
192
-
193
- return sum
194
- }
195
-
196
- const getFieldSelection = () => {
197
- if (document.activeElement != field.current) return [0, 0]
198
- let selection = window.getSelection()
199
-
200
- let startPrecedingSum = getSelectionPrecedingSum("anchorNode")
201
- let endPrecedingSum = getSelectionPrecedingSum("focusNode")
202
-
203
- let result = [
204
- startPrecedingSum + selection.anchorOffset,
205
- endPrecedingSum + selection.focusOffset,
206
- ]
207
-
208
- // Sort to make the minimum selection the start selection
209
- return result.sort((a, b) => a - b)
210
- }
211
-
212
- useEffect(() => {
213
- setTimeout(function () {
214
- let [start, end] = _text.current.revert
215
-
216
- if (start == 0 && end == 0) return
217
-
218
- let startNode = null
219
- let endNode = null
220
-
221
- let total = 0
222
- // let nodes = Array.from(field.current.childNodes)
223
- let nodes = Array.from(field.current.getElementsByTagName("span"))
224
-
225
- for (let i = 0; i < nodes.length; i++) {
226
- let node: any = nodes[i]
227
- let sum = node.textContent.length + total
228
-
229
- if (startNode == null && start >= total && start <= sum) {
230
- startNode = nodes[i]
231
- start -= total
232
- }
233
-
234
- if (endNode == null && end > total && end <= sum) {
235
- endNode = nodes[i]
236
- end -= total
237
- }
238
-
239
- total += node.textContent.length
240
- }
241
-
242
- var range = document.createRange()
243
- var sel = window.getSelection()
244
-
245
- range.setStart(startNode.firstChild, start)
246
- range.setEnd(endNode.firstChild, end)
247
-
248
- sel.removeAllRanges()
249
- sel.addRange(range)
250
- }, 1)
251
- }, [text.revert])
252
-
253
- // utility functions
254
- const getRange = (start, end) => {
255
- let result = []
256
- for (let i = start; i <= end; i++) {
257
- result.push(i)
258
- }
259
- return result
260
- }
261
-
262
- const intersection = (setA, setB) => {
263
- const _intersection = new Set()
264
- for (const elem of setB) {
265
- if (setA.has(elem)) {
266
- _intersection.add(elem)
267
- }
268
- }
269
- return _intersection
270
- }
271
-
272
- const getMinimum = (array) => {
273
- return array.sort((a, b) => a - b)[0]
274
- }
275
-
276
- const getMaximum = (array) => {
277
- return array.sort((a, b) => b - a)[0]
278
- }
279
-
280
- // -1 - types dont match
281
- // 0 - s1 is surrounded or on the edge of the s2
282
- // 1 - s1 intersects with s2
283
- // 2 - s1 does not intersect with s2
284
- const getCorrelation = (styling1, styling2) => {
285
- if (styling1.type != styling2.type) return -1
286
-
287
- if (
288
- styling2.start <= styling1.start &&
289
- styling2.finish >= styling1.finish
290
- ) {
291
- return 0
292
- }
293
-
294
- let indices1 = new Set(getRange(styling1.start - 1, styling1.finish - 1))
295
- let indices2 = new Set(getRange(styling2.start - 1, styling2.finish - 1))
296
-
297
- let result = intersection(indices1, indices2)
298
-
299
- return result.size == 0 ? 2 : 1
300
- }
301
-
302
- // Correlation handler
303
- const stylingSplice = (correlations, stylings, current, type) => {
304
- // Only one surround correlation is possible at one time, so use .find to fetch it
305
-
306
- let [_, index, styling] = correlations.find(([c, _, __]) => c == 0)
307
-
308
- // Remove correlated styling
309
- stylings = stylings.filter((_, _index) => _index != index)
310
-
311
- // Get splices
312
- let added = [
313
- {
314
- type: type,
315
- start: getMinimum([styling.start, current.start]),
316
- finish: getMaximum([styling.start, current.start]),
317
- },
318
- {
319
- type: type,
320
- start: getMinimum([styling.finish, current.finish]),
321
- finish: getMaximum([styling.finish, current.finish]),
322
- },
323
- ]
324
-
325
- // Remove empty splices (edge cases)
326
- added = added.filter((item) => item.start != item.finish)
327
-
328
- // Add to current stylings
329
- stylings = [...stylings, ...added]
330
-
331
- return stylings
332
- }
333
-
334
- // Correlation handler
335
- const stylingIntersect = (correlations, stylings, current, type) => {
336
- // Filter out all intersected stylings
337
- let intersections = correlations
338
- .filter(([c, _, __]) => c == 1)
339
- .map(([_, index, styling]) => {
340
- return [index, styling]
341
- })
342
-
343
- // Add current styling with no index for the sake for endpoint indices
344
- intersections.push([-1, current])
345
-
346
- // Get minimum intersection start index
347
- let start = intersections
348
- .map(([_, styling]) => styling.start)
349
- .sort((a, b) => a - b)[0]
350
-
351
- // Get maximum intersection start index
352
- let finish = intersections
353
- .map(([_, styling]) => styling.finish)
354
- .sort((a, b) => b - a)[0]
355
-
356
- // Get indices of all intersection
357
- let indices = intersections.map((e) => e[0])
358
-
359
- // Remove all from resulting styling array
360
- stylings = stylings.filter((_, index) => !indices.includes(index))
361
-
362
- // Add widest styling which encompasses all intersections
363
- stylings.push({
364
- type: type,
365
- start: start,
366
- finish: finish,
367
- })
368
-
369
- return stylings
370
- }
371
-
372
- const perform = (id) => {
373
- let stylings = _text.current.stylings.slice()
374
- let [selectionStart, selectionEnd] = getFieldSelection()
375
-
376
- if (selectionStart == selectionEnd) return
377
-
378
- let current = {
379
- type: id,
380
- start: selectionStart,
381
- finish: selectionEnd,
382
- }
383
-
384
- let correlations = []
385
-
386
- // Check the correlation between this requested styling and all other stylings
387
- for (let i = 0; i < stylings.length; i++) {
388
- let styling = stylings[i]
389
- let correlation = getCorrelation(current, styling)
390
-
391
- if (correlation != -1) correlations.push([correlation, i, styling])
392
- }
393
-
394
- let result
395
-
396
- if (correlations.find(([c, _, __]) => c == 1)) {
397
- result = stylingIntersect(correlations, stylings, current, id)
398
- } else if (correlations.find(([c, _, __]) => c == 0)) {
399
- result = stylingSplice(correlations, stylings, current, id)
400
- } else if (
401
- correlations.find(([c, _, __]) => c == 2) ||
402
- correlations.length == 0
403
- ) {
404
- result = [...stylings, current]
405
- }
406
-
407
- setText({
408
- ...text,
409
- stylings: result,
410
- revert: [selectionStart, selectionEnd],
411
- })
412
- }
413
-
414
- // Get stylings encompassing an index within it's range
415
- const getIntersectStylings = (
416
- stylings,
417
- index,
418
- startOffset = 0,
419
- finishOffset = 0
420
- ) => {
421
- // Find all stylings with encompassing range
422
- let matches = stylings.filter(
423
- ({ start, finish }) =>
424
- index >= start + startOffset && index < finish + finishOffset
425
- )
426
-
427
- return matches
428
- }
429
-
430
- const getStylingsInRange = (stylings, startIndex, endIndex) => {
431
- // Get all intersecting stylings within range
432
- let result = stylings.filter(
433
- ({ start, finish }) =>
434
- (finish > startIndex && start < endIndex) ||
435
- (start < endIndex && finish > startIndex)
436
- )
437
-
438
- // Clamp start and end values, and offset by start index to reach the relative minimum
439
- result = result.map((styling) => {
440
- return {
441
- ...styling,
442
- start: getMaximum([styling.start, startIndex]) - startIndex,
443
- finish: getMinimum([styling.finish, endIndex]) - startIndex,
444
- }
445
- })
446
-
447
- return result
448
- }
449
-
450
- const splitStyling = (styling, index, offset = 0) => {
451
- // Get first split
452
- let first = {
453
- ...styling,
454
- start: styling.start,
455
- finish: index,
456
- }
457
-
458
- // Get second split
459
- let second = {
460
- ...styling,
461
- start: index + offset,
462
- finish: styling.finish + offset,
463
- }
464
-
465
- return [first, second]
466
- }
467
-
468
- const additionTo = (stylings, startIndex, length, defaultBehavior = true) => {
469
- // console.log(`Adding text of length ${length} at index ${startIndex}`)
470
-
471
- // Required operations:
472
- // Offset succeeding stylings
473
- // Split intersecting stylings
474
- // Styling continuation at end (only for normal addition)
475
-
476
- stylings = stylings.map((styling) => {
477
- // A succeeding styling
478
- if (styling.start >= startIndex && styling.finish > startIndex) {
479
- console.log("succeeding")
480
- return {
481
- ...styling,
482
- start: styling.start + length,
483
- finish: styling.finish + length,
484
- }
485
- }
486
-
487
- // An intersecting styling
488
- if (styling.start < startIndex && styling.finish > startIndex) {
489
- // Normal addition (non-drop & non-paste), adds to the length of the styling
490
- if (defaultBehavior) {
491
- return {
492
- ...styling,
493
- finish: styling.finish + length,
494
- }
495
- } else {
496
- // Special addition (drop & paste), splits the styling and offsets the second half by length of addition
497
- return splitStyling(styling, startIndex, length)
498
- }
499
- }
500
-
501
- // A connected styling at the end
502
- if (styling.finish == startIndex) {
503
- // Normal addition (non-drop & non-paste), continues the styling by addition length
504
- if (defaultBehavior) {
505
- return {
506
- ...styling,
507
- finish: styling.finish + length,
508
- }
509
- }
510
- }
511
-
512
- return styling
513
- })
514
-
515
- return stylings.flat()
516
- }
517
-
518
- const deletionOf = (stylings, startIndex, endIndex) => {
519
- // console.log(`Removing text from ${startIndex} to ${endIndex}`)
520
-
521
- let length = Math.abs(endIndex - startIndex)
522
-
523
- // Required operations:
524
- // Offset succeeding stylings
525
- // Remove stylings completely within range
526
- // Shrink stylings surrounding range
527
- // Clamp left resumptions and offset
528
- // Clamp right resumptions
529
-
530
- stylings = stylings.map((styling) => {
531
- // A succeeding styling, but not a right resumption
532
- if (
533
- styling.start >= startIndex &&
534
- styling.start >= endIndex &&
535
- styling.finish >= startIndex &&
536
- styling.finish >= endIndex
537
- ) {
538
- return {
539
- ...styling,
540
- start: styling.start - length,
541
- finish: styling.finish - length,
542
- }
543
- }
544
-
545
- // A styling completely within deletion range
546
- if (styling.start >= startIndex && styling.finish <= endIndex) {
547
- return null
548
- }
549
-
550
- // A styling surrounding deletion range
551
- if (styling.start <= startIndex && styling.finish >= endIndex) {
552
- return {
553
- ...styling,
554
- finish: styling.finish - length,
555
- }
556
- }
557
-
558
- // A styling not fully within deletion range, while the range exceeds to the left
559
- if (styling.start > startIndex && styling.start < endIndex) {
560
- return {
561
- ...styling,
562
- start: getMaximum([styling.start, endIndex]) - length,
563
- finish: styling.finish - length,
564
- }
565
- }
566
-
567
- // A styling not full within deletion range, while the range exceeds to the right
568
- if (styling.finish > startIndex && styling.finish < endIndex) {
569
- return {
570
- ...styling,
571
- finish: getMinimum([styling.finish, startIndex]),
572
- }
573
- }
574
-
575
- return styling
576
- })
577
-
578
- return stylings.flat().filter((styling) => styling)
579
- }
580
-
581
- const processNormal = (
582
- stylings,
583
- difference,
584
- selectionStart,
585
- selectionEnd
586
- ) => {
587
- if (difference == 0) return stylings
588
-
589
- if (difference > 0) {
590
- stylings = additionTo(stylings, selectionStart - difference, difference)
591
- } else {
592
- stylings = deletionOf(
593
- stylings,
594
- selectionStart,
595
- selectionEnd + Math.abs(difference)
596
- )
597
- }
598
-
599
- return stylings
600
- }
601
-
602
- const processPaste = (stylings, difference, selectionStart, selectionEnd) => {
603
- let pasteLength = _text.current.events.paste.length
604
-
605
- // console.log(
606
- // `Pasting for length ${pasteLength} at [${selectionStart}, ${selectionEnd}]`
607
- // )
608
- // console.log(
609
- // `Accompanied stylings: ${JSON.stringify(
610
- // _text.current.clipboard,
611
- // null,
612
- // 2
613
- // )}`
614
- // )
615
-
616
- // Get addition start index
617
- let additionStart = selectionStart - pasteLength
618
-
619
- // Get removal range
620
- let removalStart = additionStart
621
- let removalEnd = additionStart + pasteLength - difference
622
-
623
- // Compute deletion
624
- stylings = deletionOf(stylings, removalStart, removalEnd)
625
-
626
- // Compute addition
627
- stylings = additionTo(stylings, additionStart, pasteLength, false)
628
-
629
- // Add rich copied stylings offset by paste start index
630
- stylings = stylings.concat(
631
- _text.current.clipboard.map((styling) => {
632
- return {
633
- ...styling,
634
- start: styling.start + additionStart,
635
- finish: styling.finish + additionStart,
636
- }
637
- })
638
- )
639
-
640
- // console.log(`End result: ${JSON.stringify(stylings, null, 2)}`)
641
-
642
- return stylings
643
- }
644
-
645
- const processDrop = (stylings, difference, dropStart, dropEnd) => {
646
- console.log(`Dropped at: ${[dropStart, dropEnd]}`)
647
-
648
- let dropLength = _text.current.events.drop.text.length
649
-
650
- let [dragStart, dragEnd] = _text.current.events.drop.drag
651
-
652
- let dropDifference = dropStart - dragStart
653
-
654
- // Get stylings at drag range
655
- let dragStylings = getStylingsInRange(stylings, dragStart, dragEnd)
656
-
657
- // Removal range
658
- let removalStart = dragStart
659
- let removalEnd = dragEnd
660
-
661
- // If the drag precedes the drop (positive difference)
662
- if (dropDifference > 0) {
663
- // Addition start index
664
- let additionStart = dropEnd
665
-
666
- // Compute addition first
667
- stylings = additionTo(stylings, additionStart, dropLength, false)
668
-
669
- // Compute removal second
670
- stylings = deletionOf(stylings, removalStart, removalEnd)
671
- }
672
-
673
- // If the drop precedes the drag (negative difference)
674
- if (dropDifference < 0) {
675
- // Addition start index
676
- let additionStart = dropStart
677
-
678
- // Compute removal first
679
- stylings = deletionOf(stylings, removalStart, removalEnd)
680
-
681
- // Compute addition second
682
- stylings = additionTo(stylings, additionStart, dropLength, false)
683
- }
684
-
685
- // Add rich dragged stylings offset
686
- stylings = stylings.concat(
687
- dragStylings.map((styling) => {
688
- return {
689
- ...styling,
690
- start: styling.start + dropStart,
691
- finish: styling.finish + dropStart,
692
- }
693
- })
694
- )
695
-
696
- return stylings
697
- }
698
-
699
- const onChange = (value, selectionStart, selectionEnd) => {
700
- // Since drop events cause onChange to invoke twice, ignore the first incomplete event
701
- if (
702
- _text.current.events.drop.is &&
703
- value.length != _text.current.content.length
704
- )
705
- return
706
-
707
- console.log(`Changed at: ${[selectionStart, selectionEnd]}`)
708
-
709
- setTimeout(function () {
710
- // let [selectionStart, selectionEnd] = getFieldSelection()
711
- let difference = value.length - _text.current.content.length
712
- let stylings = _text.current.stylings
713
-
714
- // Paste event
715
- if (_text.current.events.paste.is) {
716
- stylings = processPaste(
717
- stylings,
718
- difference,
719
- selectionStart,
720
- selectionEnd
721
- )
722
- } else if (_text.current.events.drop.is) {
723
- stylings = processDrop(
724
- stylings,
725
- difference,
726
- selectionStart,
727
- selectionEnd
728
- )
729
- } else {
730
- stylings = processNormal(
731
- stylings,
732
- difference,
733
- selectionStart,
734
- selectionEnd
735
- )
736
- }
737
-
738
- setText({
739
- ..._text.current,
740
- content: value,
741
- stylings: stylings,
742
- revert: [selectionStart, selectionEnd],
743
- events: {
744
- paste: { is: false, length: null },
745
- drop: { is: false, text: null, drag: null },
746
- },
747
- })
748
- }, 0)
749
- }
750
-
751
- const getContent = () => {
752
- // console.clear()
753
- let content = _text.current.content
754
- let stylings = [..._text.current.stylings]
755
-
756
- let result = []
757
-
758
- // Get line indices
759
- let lineIndices = content
760
- .split("")
761
- .map((character, index) => {
762
- if (character == lineBreakIdentifier) return index
763
- return null
764
- })
765
- .filter((item) => item)
766
-
767
- // Add end point
768
- lineIndices.unshift(0)
769
- lineIndices.push(content.length)
770
-
771
- // Ignore last element
772
- for (let i = 0; i < lineIndices.length - 1; i++) {
773
- let lineStart = lineIndices[i]
774
- let lineEnd = lineIndices[i + 1]
775
-
776
- let lineContent = content.slice(lineStart, lineEnd)
777
-
778
- // console.log(
779
- // `Line: ${lineStart} -> ${lineEnd}, with content: ${lineContent}`
780
- // )
781
-
782
- // Get all stylings within line
783
- let lineStylings = getStylingsInRange(stylings, lineStart, lineEnd)
784
-
785
- // Collect all spans relative to stylings within line
786
- let spans = []
787
-
788
- // Acquire all flattened unique indices
789
- let indices = lineStylings
790
- .map(({ start, finish }) => [start, finish])
791
- .flat()
792
- .sort((a, b) => a - b)
793
-
794
- indices = indices.filter(
795
- (element, index) => indices.indexOf(element) == index
796
- )
797
-
798
- // Add first index if not present
799
- if (indices[0] != 0) indices.unshift(0)
800
-
801
- // Add last index if not present
802
- let last = lineContent.length
803
- if (indices[indices.length - 1] != last) indices.push(last)
804
-
805
- // Iterate through all indices except the last
806
- for (let i = 0; i < indices.length - 1; i++) {
807
- let startIndex = indices[i]
808
- let endIndex = indices[i + 1]
809
-
810
- spans.push({
811
- content: lineContent.substring(startIndex, endIndex),
812
- types: getIntersectStylings(lineStylings, startIndex).map(
813
- (styling) => styling.type
814
- ),
815
- })
816
- }
817
-
818
- result.push(spans)
819
- }
820
-
821
- // // Get all styling indices
822
- // let indices = _text.current.stylings
823
- // .map(({ start, finish }) => [start, finish])
824
- // .flat()
825
-
826
- // // Sort ascendingly
827
- // indices = indices.sort((a, b) => a - b)
828
-
829
- // // Remove duplicates
830
- // indices = indices.filter(
831
- // (element, index) => indices.indexOf(element) == index
832
- // )
833
-
834
- // // Add first index if not present
835
- // if (indices[0] != 0) indices.unshift(0)
836
-
837
- // // Add last index if not present
838
- // let last = content.length
839
- // if (indices[indices.length - 1] != last) indices.push(last)
840
-
841
- // // let result = []
842
-
843
- // for (let i = 0; i < indices.length - 1; i++) {
844
- // result.push([indices[i], content.substring(indices[i], indices[i + 1])])
845
- // }
846
-
847
- return result
848
- }
849
-
850
- // dangerouslySetInnerHTML incorrectly renders when the entire text is highlighted, copied, and then pasted in succession
851
- useEffect(() => {
852
- let html = getContent()
853
- .map((line, index) => {
854
- return `<div class="line" data-line-index="${index}">${line
855
- .map((span, _index) => {
856
- return `<span class="${span.types
857
- .map((type) => stylers[type].css)
858
- .join(" ")}" data-child-index="${_index}">${span.content}</span>`
859
- })
860
- .join("")}</div>`
861
- })
862
- .join("")
863
-
864
- // let html = getContent()
865
- // .map((_data, index) => {
866
- // let [start, data] = _data
867
-
868
- // // Get stylings encompassing an index within it's range
869
- // let stylings = getIntersectStylings(_text.current.stylings, start)
870
- // return `<span class="${stylings
871
- // .map((styling) => stylers[styling.type].css)
872
- // .join(" ")}" data-child-index="${index}">${data}</span>`
873
- // })
874
- // .join("")
875
-
876
- field.current.innerHTML = html
877
- }, [text.content, text.stylings, text.revert])
878
-
879
- const getTextDirection = () => {
880
- let value = props.rtl || "disabled"
881
-
882
- switch (value) {
883
- case "enabled":
884
- return "rtl"
885
- case "disabled":
886
- return "ltr"
887
- case "auto":
888
- return "ltr"
889
- }
890
- }
891
-
892
- return (
893
- <div className="align-center box-border flex h-min w-[400px] flex-col items-center justify-center rounded shadow-md">
894
- <div className={clsx("flex w-full flex-row justify-start p-2")}>
895
- {Object.entries(stylers).map(([id, data]) => {
896
- return (
897
- <Property
898
- name={data.content}
899
- key={`property-${id}`}
900
- onMouseDown={(event) => {
901
- event.preventDefault()
902
- perform(id)
903
- }}
904
- />
905
- )
906
- })}
907
- </div>
908
- <div className="h-[1px] w-full bg-slate-600">&nbsp;</div>
909
- {/* <div className="selection-ignore rtl h-[150px] w-full resize-none overflow-auto overflow-x-hidden border-none font-['Arial'] text-[16px] outline-none">
910
- <div className="line" data-line-index="0">
911
- <span className="" data-child-index="0">
912
- asd
913
- </span>
914
- </div>
915
- <div className="line" data-line-index="1">
916
- <br />
917
- </div>
918
- </div>
919
- */}
920
- <div className="selection-ignore box-border w-full p-2">
921
- <div
922
- ref={field}
923
- contentEditable="true"
924
- className="selection-ignore rtl h-[150px] w-full resize-none overflow-auto overflow-x-hidden border-none font-['Arial'] text-[16px] outline-none"
925
- style={{
926
- direction: getTextDirection(),
927
- }}
928
- onPaste={(event) => {
929
- // pastes all copied text from the content editable as plain text
930
- event.preventDefault()
931
- let data = event.clipboardData.getData("text/plain")
932
- data = data.replaceAll("\n", "")
933
- data = data.replaceAll("\r", "")
934
-
935
- document.execCommand("insertHTML", false, data)
936
-
937
- // selection.anchorOffset <= 1 &&
938
- // selection.focusOffset <= 1
939
- // ) {
940
- // let lineIndex = getChildIndex(anchorNode.parentNode.parentNode)
941
-
942
- // let _content = content
943
- // if (content.startsWith(lineBreakIdentifier)) {
944
- // _content = _content.slice(1)
945
- // }
946
-
947
- // let originalLine: any =
948
- // _content.split(lineBreakIdentifier)[lineIndex]
949
-
950
- // console.log(_content.split(lineBreakIdentifier))
951
-
952
- // originalLine = originalLine.split("")
953
- // originalLine.splice(0, 0, eventData)
954
- // originalLine = originalLine.join("")
955
-
956
- // let lines = _content.split(lineBreakIdentifier)
957
-
958
- // lines[lineIndex] = originalLine
959
-
960
- // textContent = lines.join(lineBreakIdentifier)
961
-
962
- // if (content.startsWith(lineBreakIdentifier)) {
963
- // textContent = lineBreakIdentifier + textContent
964
- // }
965
-
966
- // start += 1
967
- // end += 1
968
- // }
969
-
970
- setText({
971
- ..._text.current,
972
- events: {
973
- ..._text.current.events,
974
- paste: { is: true, length: data.length },
975
- },
976
- })
977
- }}
978
- onInput={(event: any) => {
979
- // console.log(event)
980
- // console.log(event.target.textContent)
981
- // console.log(event.target.textContent.split(""))
982
-
983
- let [start, end] = getFieldSelection()
984
- let textContent = event.target.textContent
985
- let content = _text.current.content
986
- // Try creating twice the lines if the index is at 0,0
987
- // if (!textContent.startsWith(lineBreakIdentifier)) {
988
- // textContent = lineBreakIdentifier + textContent
989
- // }
990
-
991
- let eventType = event.nativeEvent.inputType
992
-
993
- if (eventType == "insertParagraph") {
994
- console.log(`Inserted new line at [${start}, ${end}]`)
995
-
996
- let split = textContent.split("")
997
-
998
- split.splice(start, 0, lineBreakIdentifier)
999
- if (start == 0 && !content.startsWith(lineBreakIdentifier)) {
1000
- split.splice(start, 0, lineBreakIdentifier)
1001
- start += 1
1002
- end += 1
1003
- }
1004
-
1005
- textContent = split.join("")
1006
-
1007
- // Increase selection by one to accomodate for the new line
1008
- start += 1
1009
- end += 1
1010
- } else {
1011
- let selection = window.getSelection()
1012
- let { anchorNode, focusNode } = selection
1013
-
1014
- let eventData = event.nativeEvent.data
1015
-
1016
- // Handle typing behind lines
1017
- if (
1018
- anchorNode.parentNode == focusNode.parentNode &&
1019
- anchorNode.parentNode.nodeName == "SPAN" &&
1020
- selection.anchorOffset <= 1 &&
1021
- selection.focusOffset <= 1 &&
1022
- eventType == "insertText"
1023
- ) {
1024
- let lineIndex = getChildIndex(anchorNode.parentNode.parentNode)
1025
-
1026
- let _content = content
1027
- if (content.startsWith(lineBreakIdentifier)) {
1028
- _content = _content.slice(1)
1029
- }
1030
-
1031
- let originalLine: any =
1032
- _content.split(lineBreakIdentifier)[lineIndex]
1033
-
1034
- console.log(_content.split(lineBreakIdentifier))
1035
-
1036
- originalLine = originalLine.split("")
1037
- originalLine.splice(0, 0, eventData)
1038
- originalLine = originalLine.join("")
1039
-
1040
- let lines = _content.split(lineBreakIdentifier)
1041
-
1042
- lines[lineIndex] = originalLine
1043
-
1044
- textContent = lines.join(lineBreakIdentifier)
1045
-
1046
- if (content.startsWith(lineBreakIdentifier)) {
1047
- textContent = lineBreakIdentifier + textContent
1048
- }
1049
-
1050
- start += 1
1051
- end += 1
1052
- }
1053
- }
1054
-
1055
- // if (
1056
- // eventData != null &&
1057
- // start - eventData.length == 0 &&
1058
- // end - eventData.length == 0 &&
1059
- // content.startsWith(lineBreakIdentifier)
1060
- // ) {
1061
- // console.log("STOP")
1062
- // }
1063
-
1064
- // console.log(event.nativeEvent.inputType)
1065
-
1066
- onChange(textContent, start, end)
1067
- }}
1068
- onCopy={() => {
1069
- let [start, end] = getFieldSelection()
1070
-
1071
- let stylings = _text.current.stylings.slice()
1072
- stylings = getStylingsInRange(stylings, start, end)
1073
-
1074
- setText({
1075
- ...text,
1076
- clipboard: stylings,
1077
- })
1078
- }}
1079
- onDrop={(event) => {
1080
- let text = event.dataTransfer.getData("text")
1081
-
1082
- if (text.trim() == "") return
1083
-
1084
- setText({
1085
- ..._text.current,
1086
- events: {
1087
- ..._text.current.events,
1088
- drop: { is: true, text: text, drag: getFieldSelection() },
1089
- },
1090
- })
1091
- }}
1092
- ></div>
1093
- </div>
1094
- <div className="h-[1px] w-full bg-slate-600">&nbsp;</div>
1095
- <button
1096
- className="my-1 rounded bg-cyan-800 p-2 py-1 text-white"
1097
- onClick={() => {
1098
- let onSubmit = props.onSubmit || (() => {})
1099
-
1100
- onSubmit(text.content, text.stylings)
1101
- }}
1102
- >
1103
- Submit
1104
- </button>
1105
- </div>
1106
- )
1107
- }