@archbase/components 3.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 (573) hide show
  1. package/dist/admin/types.d.ts +65 -0
  2. package/dist/archbase-components-3.0.0.tgz +0 -0
  3. package/dist/buttons/ActionsDemo.d.ts +2 -0
  4. package/dist/buttons/ArchbaseActionButtons.d.ts +61 -0
  5. package/dist/buttons/index.d.ts +2 -0
  6. package/dist/charts/ArchbaseTimeline.d.ts +24 -0
  7. package/dist/charts/index.d.ts +3 -0
  8. package/dist/charts/vis-timeline/ArchbaseVisTimeline.d.ts +9 -0
  9. package/dist/charts/vis-timeline/ArchbaseVisTimeline.types.d.ts +284 -0
  10. package/dist/charts/vis-timeline/index.d.ts +9 -0
  11. package/dist/charts/vis-timeline/utils/timelineOptions.d.ts +68 -0
  12. package/dist/datagrid/components/index.d.ts +6 -0
  13. package/dist/datagrid/components/pagination/grid-pagination.d.ts +7 -0
  14. package/dist/datagrid/components/render/archbase-data-grid-item-renderer.d.ts +10 -0
  15. package/dist/datagrid/components/toolbar/global-search-input.d.ts +16 -0
  16. package/dist/datagrid/components/toolbar/grid-toolbar.d.ts +19 -0
  17. package/dist/datagrid/hooks/index.d.ts +3 -0
  18. package/dist/datagrid/hooks/use-grid-data-stable-rendering.d.ts +15 -0
  19. package/dist/datagrid/hooks/use-grid-data.d.ts +32 -0
  20. package/dist/datagrid/hooks/use-grid-details-panel.d.ts +51 -0
  21. package/dist/datagrid/index.d.ts +6 -0
  22. package/dist/datagrid/main/archbase-data-grid-column.d.ts +26 -0
  23. package/dist/datagrid/main/archbase-data-grid-formatters.d.ts +57 -0
  24. package/dist/datagrid/main/archbase-data-grid-pagination.d.ts +8 -0
  25. package/dist/datagrid/main/archbase-data-grid-toolbar.d.ts +7 -0
  26. package/dist/datagrid/main/archbase-data-grid-types.d.ts +252 -0
  27. package/dist/datagrid/main/archbase-data-grid-utils.d.ts +45 -0
  28. package/dist/datagrid/main/archbase-data-grid.d.ts +9 -0
  29. package/dist/datagrid/main/archbase-detail-panel-component.d.ts +52 -0
  30. package/dist/datagrid/main/archbase-expand-button.d.ts +22 -0
  31. package/dist/datagrid/main/archbase-grid-popover.d.ts +37 -0
  32. package/dist/datagrid/main/grid-row-actions.d.ts +15 -0
  33. package/dist/datagrid/main/index.d.ts +21 -0
  34. package/dist/datagrid/modals/export-data.d.ts +13 -0
  35. package/dist/datagrid/modals/export-modal.d.ts +9 -0
  36. package/dist/datagrid/modals/index.d.ts +6 -0
  37. package/dist/datagrid/modals/print-data.d.ts +16 -0
  38. package/dist/datagrid/modals/print-modal.d.ts +9 -0
  39. package/dist/datagrid/types/grid-props.d.ts +48 -0
  40. package/dist/datagrid/types/index.d.ts +1 -0
  41. package/dist/datagrid/utils/formatter.d.ts +39 -0
  42. package/dist/datagrid/utils/index.d.ts +1 -0
  43. package/dist/debug/index.d.ts +4 -0
  44. package/dist/debug/jsonpathpicker/ArchbaseJsonPathPicker.d.ts +37 -0
  45. package/dist/debug/jsonpathpicker/index.d.ts +1 -0
  46. package/dist/debug/jsonview/ArchbaseJsonViewDataRenderer.d.ts +34 -0
  47. package/dist/debug/jsonview/ArchbaseJsonViewDataTypeDetection.d.ts +8 -0
  48. package/dist/debug/jsonview/index.d.ts +11 -0
  49. package/dist/debug/objectinspector/ArchbaseDebugInspector.d.ts +23 -0
  50. package/dist/debug/objectinspector/ArchbaseFloatingWindow.d.ts +24 -0
  51. package/dist/debug/objectinspector/ArchbaseObjectInspector.d.ts +6 -0
  52. package/dist/debug/objectinspector/index.d.ts +3 -0
  53. package/dist/display/index.d.ts +4 -0
  54. package/dist/editors/ArchbaseAsyncMultiSelect.d.ts +112 -0
  55. package/dist/editors/ArchbaseAsyncSelect.context.d.ts +8 -0
  56. package/dist/editors/ArchbaseAsyncSelect.d.ts +102 -0
  57. package/dist/editors/ArchbaseAvatarEdit.d.ts +49 -0
  58. package/dist/editors/ArchbaseCheckbox.d.ts +45 -0
  59. package/dist/editors/ArchbaseChip.d.ts +43 -0
  60. package/dist/editors/ArchbaseChipGroup.d.ts +42 -0
  61. package/dist/editors/ArchbaseChipItem.d.ts +18 -0
  62. package/dist/editors/ArchbaseColorPicker.d.ts +3 -0
  63. package/dist/editors/ArchbaseCountdownProgress.d.ts +5 -0
  64. package/dist/editors/ArchbaseCronExpressionEdit.d.ts +16 -0
  65. package/dist/editors/ArchbaseCronExpressionEditor.d.ts +8 -0
  66. package/dist/editors/ArchbaseDatePicker.d.ts +2 -0
  67. package/dist/editors/ArchbaseDatePickerEdit.d.ts +85 -0
  68. package/dist/editors/ArchbaseDatePickerRange.d.ts +47 -0
  69. package/dist/editors/ArchbaseDateTimePickerEdit.d.ts +43 -0
  70. package/dist/editors/ArchbaseDateTimePickerRange.d.ts +58 -0
  71. package/dist/editors/ArchbaseEdit.d.ts +56 -0
  72. package/dist/editors/ArchbaseEdit.example.d.ts +8 -0
  73. package/dist/editors/ArchbaseFileAttachment.d.ts +17 -0
  74. package/dist/editors/ArchbaseImageEdit.d.ts +50 -0
  75. package/dist/editors/ArchbaseJsonEdit.d.ts +49 -0
  76. package/dist/editors/ArchbaseKeyValueEditor.d.ts +22 -0
  77. package/dist/editors/ArchbaseLookupEdit.d.ts +57 -0
  78. package/dist/editors/ArchbaseLookupNumber.d.ts +69 -0
  79. package/dist/editors/ArchbaseLookupSelect.d.ts +9 -0
  80. package/dist/editors/ArchbaseMarkdownEdit.d.ts +52 -0
  81. package/dist/editors/ArchbaseMaskEdit.d.ts +79 -0
  82. package/dist/editors/ArchbaseNumberEdit.d.ts +51 -0
  83. package/dist/editors/ArchbaseNumberInput.d.ts +2 -0
  84. package/dist/editors/ArchbaseOperationHoursEditor.d.ts +8 -0
  85. package/dist/editors/ArchbasePasswordEdit.d.ts +44 -0
  86. package/dist/editors/ArchbasePasswordInput.d.ts +2 -0
  87. package/dist/editors/ArchbaseRadio.d.ts +2 -0
  88. package/dist/editors/ArchbaseRadioGroup.d.ts +45 -0
  89. package/dist/editors/ArchbaseRadioItem.d.ts +12 -0
  90. package/dist/editors/ArchbaseRating.d.ts +52 -0
  91. package/dist/editors/ArchbaseRichTextEdit.d.ts +80 -0
  92. package/dist/editors/ArchbaseSelect.context.d.ts +8 -0
  93. package/dist/editors/ArchbaseSelect.d.ts +107 -0
  94. package/dist/editors/ArchbaseSelectItem.d.ts +15 -0
  95. package/dist/editors/ArchbaseSwitch.d.ts +53 -0
  96. package/dist/editors/ArchbaseTextArea.d.ts +47 -0
  97. package/dist/editors/ArchbaseTimeEdit.d.ts +52 -0
  98. package/dist/editors/ArchbaseTimeRangeSelector.d.ts +40 -0
  99. package/dist/editors/ArchbaseTreeSelect.d.ts +65 -0
  100. package/dist/editors/index.d.ts +81 -0
  101. package/dist/feedback/index.d.ts +4 -0
  102. package/dist/filters/ArchbaseCompositeFilters.d.ts +23 -0
  103. package/dist/filters/ArchbaseCompositeFilters.types.d.ts +303 -0
  104. package/dist/filters/ArchbaseCompositeFilters.utils.d.ts +69 -0
  105. package/dist/filters/components/FilterPill.d.ts +5 -0
  106. package/dist/filters/hooks/index.d.ts +4 -0
  107. package/dist/filters/hooks/useArchbaseFilterHistory.d.ts +24 -0
  108. package/dist/filters/hooks/useArchbaseFilterPresets.d.ts +23 -0
  109. package/dist/filters/hooks/useArchbaseFilters.d.ts +32 -0
  110. package/dist/filters/hooks/useArchbaseQuickFilters.d.ts +26 -0
  111. package/dist/filters/index.d.ts +8 -0
  112. package/dist/forms/index.d.ts +3 -0
  113. package/dist/hooks/index.d.ts +5 -0
  114. package/dist/hooks/useArchbaseContainerDimensions.d.ts +4 -0
  115. package/dist/hooks/useArchbaseElementSizeArea.d.ts +6 -0
  116. package/dist/hooks/useArchbaseListContext.d.ts +2 -0
  117. package/dist/hooks/useArchbaseNavigateParams.d.ts +3 -0
  118. package/dist/hooks/useArchbaseVisible.d.ts +2 -0
  119. package/dist/image/ArchbaseImage.d.ts +33 -0
  120. package/dist/image/ArchbaseMicrosoftAvatar.d.ts +7 -0
  121. package/dist/image/editor/components/BasicFilters/BasicFilter.d.ts +9 -0
  122. package/dist/image/editor/components/CropprWrapper/ArchbaseCropperWrapper.d.ts +12 -0
  123. package/dist/image/editor/components/EditImage/ArchbaseEditImage.d.ts +11 -0
  124. package/dist/image/editor/components/Input/Input.d.ts +9 -0
  125. package/dist/image/editor/components/Tab/Tab.d.ts +23 -0
  126. package/dist/image/editor/functions/croppr/box.d.ts +95 -0
  127. package/dist/image/editor/functions/croppr/core.d.ts +121 -0
  128. package/dist/image/editor/functions/croppr/croppr.d.ts +68 -0
  129. package/dist/image/editor/functions/croppr/handle.d.ts +23 -0
  130. package/dist/image/editor/functions/croppr/index.d.ts +2 -0
  131. package/dist/image/editor/functions/croppr/touch.d.ts +10 -0
  132. package/dist/image/editor/functions/image-processing.d.ts +11 -0
  133. package/dist/image/editor/index.d.ts +12 -0
  134. package/dist/image/editor/models/index.models.d.ts +45 -0
  135. package/dist/image/index.d.ts +7 -0
  136. package/dist/image/languages.d.ts +299 -0
  137. package/dist/index.css +1 -0
  138. package/dist/index.d.ts +27 -0
  139. package/dist/index.js +18368 -0
  140. package/dist/jsonschema/ArchbaseJsonSchemaEditor.types.d.ts +131 -0
  141. package/dist/jsonschema/JsonSchemaEditor/ArchbaseJsonSchemaEditor.context.d.ts +7 -0
  142. package/dist/jsonschema/JsonSchemaEditor/ArchbaseJsonSchemaEditor.d.ts +9 -0
  143. package/dist/jsonschema/JsonSchemaEditor/advanced-boolean/index.d.ts +2 -0
  144. package/dist/jsonschema/JsonSchemaEditor/advanced-number/index.d.ts +2 -0
  145. package/dist/jsonschema/JsonSchemaEditor/advanced-string/index.d.ts +2 -0
  146. package/dist/jsonschema/JsonSchemaEditor/drop-plus/index.d.ts +10 -0
  147. package/dist/jsonschema/JsonSchemaEditor/index.d.ts +2 -0
  148. package/dist/jsonschema/JsonSchemaEditor/schema-advanced/index.d.ts +6 -0
  149. package/dist/jsonschema/JsonSchemaEditor/schema-array/index.d.ts +8 -0
  150. package/dist/jsonschema/JsonSchemaEditor/schema-item/index.d.ts +11 -0
  151. package/dist/jsonschema/JsonSchemaEditor/schema-object/index.d.ts +7 -0
  152. package/dist/jsonschema/JsonSchemaEditor/schema-root/index.d.ts +8 -0
  153. package/dist/jsonschema/JsonSchemaEditor/utils.d.ts +25 -0
  154. package/dist/jsonschema/JsonSchemaEditor/whoops.d.ts +2 -0
  155. package/dist/jsonschema/index.d.ts +2 -0
  156. package/dist/list/ArchbaseList.context.d.ts +27 -0
  157. package/dist/list/ArchbaseList.d.ts +104 -0
  158. package/dist/list/ArchbaseListItem.d.ts +59 -0
  159. package/dist/list/index.d.ts +8 -0
  160. package/dist/list/treeview/ArchbaseTreeView.d.ts +44 -0
  161. package/dist/list/treeview/ArchbaseTreeView.types.d.ts +40 -0
  162. package/dist/list/treeview/ArchbaseTreeViewItem.d.ts +19 -0
  163. package/dist/list/treeview/index.d.ts +5 -0
  164. package/dist/list-view/ArchbaseListViewTable.d.ts +111 -0
  165. package/dist/list-view/index.d.ts +2 -0
  166. package/dist/markdown/ArchbaseMarkdown.d.ts +23 -0
  167. package/dist/markdown/ArchbaseMarkdown.types.d.ts +181 -0
  168. package/dist/markdown/components/CodeBlock.d.ts +23 -0
  169. package/dist/markdown/components/LinkRenderer.d.ts +16 -0
  170. package/dist/markdown/index.d.ts +11 -0
  171. package/dist/masonry/ArchbaseMasonry.context.d.ts +21 -0
  172. package/dist/masonry/ArchbaseMasonry.d.ts +35 -0
  173. package/dist/masonry/index.d.ts +5 -0
  174. package/dist/navigation/index.d.ts +3 -0
  175. package/dist/notification/ArchbaseAlert.d.ts +22 -0
  176. package/dist/notification/ArchbaseDialog.d.ts +16 -0
  177. package/dist/notification/ArchbaseNotifications.d.ts +5 -0
  178. package/dist/notification/index.d.ts +4 -0
  179. package/dist/onboarding/ArchbaseOnboardingTour.d.ts +99 -0
  180. package/dist/onboarding/index.d.ts +2 -0
  181. package/dist/printer/ArchbaseThermalPrinter.d.ts +27 -0
  182. package/dist/printer/ArchbaseThermalPrinter.types.d.ts +199 -0
  183. package/dist/printer/index.d.ts +9 -0
  184. package/dist/printer/utils/escpos.d.ts +127 -0
  185. package/dist/spreadsheet/ArchbaseSpreadsheetImport.d.ts +4 -0
  186. package/dist/spreadsheet/ArchbaseSpreadsheetImport.types.d.ts +65 -0
  187. package/dist/spreadsheet/index.d.ts +2 -0
  188. package/dist/theme-editor/ArchbaseThemeEditor.d.ts +17 -0
  189. package/dist/theme-editor/ArchbaseThemeEditor.types.d.ts +187 -0
  190. package/dist/theme-editor/index.d.ts +9 -0
  191. package/dist/theme-editor/utils/themeExport.d.ts +198 -0
  192. package/dist/themes/ArchbaseThemeEditor.d.ts +49 -0
  193. package/dist/types/index.d.ts +106 -0
  194. package/dist/video/ArchbaseVideoPlayer.d.ts +18 -0
  195. package/dist/video/ArchbaseVideoPlayer.types.d.ts +200 -0
  196. package/dist/video/hooks/useVideoPlayer.d.ts +58 -0
  197. package/dist/video/index.d.ts +10 -0
  198. package/dist/viewers/ArchbasePDFViewer.annotations.d.ts +20 -0
  199. package/dist/viewers/ArchbasePDFViewer.d.ts +2 -0
  200. package/dist/viewers/ArchbasePDFViewer.toolbar.d.ts +20 -0
  201. package/dist/viewers/ArchbasePDFViewer.types.d.ts +68 -0
  202. package/dist/viewers/file-preview/ArchbaseFilePreviewer.d.ts +19 -0
  203. package/dist/viewers/file-preview/ArchbaseFilePreviewer.types.d.ts +153 -0
  204. package/dist/viewers/file-preview/index.d.ts +13 -0
  205. package/dist/viewers/file-preview/utils/fileTypeDetector.d.ts +33 -0
  206. package/dist/viewers/index.d.ts +5 -0
  207. package/package.json +154 -0
  208. package/src/admin/types.ts +73 -0
  209. package/src/arco.css +6 -0
  210. package/src/buttons/ActionsDemo.tsx +107 -0
  211. package/src/buttons/ArchbaseActionButtons.d.ts.map +1 -0
  212. package/src/buttons/ArchbaseActionButtons.tsx +387 -0
  213. package/src/buttons/index.d.ts.map +1 -0
  214. package/src/buttons/index.ts +7 -0
  215. package/src/charts/ArchbaseTimeline.d.ts.map +1 -0
  216. package/src/charts/ArchbaseTimeline.tsx +332 -0
  217. package/src/charts/index.d.ts.map +1 -0
  218. package/src/charts/index.ts +5 -0
  219. package/src/charts/vis-timeline/ArchbaseVisTimeline.tsx +401 -0
  220. package/src/charts/vis-timeline/ArchbaseVisTimeline.types.ts +294 -0
  221. package/src/charts/vis-timeline/index.ts +36 -0
  222. package/src/charts/vis-timeline/utils/timelineOptions.ts +213 -0
  223. package/src/datagrid/components/index.d.ts.map +1 -0
  224. package/src/datagrid/components/index.tsx +14 -0
  225. package/src/datagrid/components/pagination/grid-pagination.d.ts.map +1 -0
  226. package/src/datagrid/components/pagination/grid-pagination.tsx +150 -0
  227. package/src/datagrid/components/render/archbase-data-grid-item-renderer.tsx +26 -0
  228. package/src/datagrid/components/toolbar/global-search-input.d.ts.map +1 -0
  229. package/src/datagrid/components/toolbar/global-search-input.tsx +118 -0
  230. package/src/datagrid/components/toolbar/grid-toolbar.d.ts.map +1 -0
  231. package/src/datagrid/components/toolbar/grid-toolbar.tsx +106 -0
  232. package/src/datagrid/hooks/index.d.ts.map +1 -0
  233. package/src/datagrid/hooks/index.tsx +18 -0
  234. package/src/datagrid/hooks/use-grid-data-stable-rendering.d.ts.map +1 -0
  235. package/src/datagrid/hooks/use-grid-data-stable-rendering.ts +168 -0
  236. package/src/datagrid/hooks/use-grid-data.d.ts.map +1 -0
  237. package/src/datagrid/hooks/use-grid-data.tsx +598 -0
  238. package/src/datagrid/hooks/use-grid-details-panel.d.ts.map +1 -0
  239. package/src/datagrid/hooks/use-grid-details-panel.ts +316 -0
  240. package/src/datagrid/index.d.ts.map +1 -0
  241. package/src/datagrid/index.tsx +12 -0
  242. package/src/datagrid/main/archbase-data-grid-column.d.ts.map +1 -0
  243. package/src/datagrid/main/archbase-data-grid-column.ts +46 -0
  244. package/src/datagrid/main/archbase-data-grid-formatters.d.ts.map +1 -0
  245. package/src/datagrid/main/archbase-data-grid-formatters.tsx +384 -0
  246. package/src/datagrid/main/archbase-data-grid-pagination.d.ts.map +1 -0
  247. package/src/datagrid/main/archbase-data-grid-pagination.tsx +63 -0
  248. package/src/datagrid/main/archbase-data-grid-toolbar.d.ts.map +1 -0
  249. package/src/datagrid/main/archbase-data-grid-toolbar.tsx +160 -0
  250. package/src/datagrid/main/archbase-data-grid-types.d.ts.map +1 -0
  251. package/src/datagrid/main/archbase-data-grid-types.tsx +327 -0
  252. package/src/datagrid/main/archbase-data-grid-utils.d.ts.map +1 -0
  253. package/src/datagrid/main/archbase-data-grid-utils.ts +494 -0
  254. package/src/datagrid/main/archbase-data-grid.d.ts.map +1 -0
  255. package/src/datagrid/main/archbase-data-grid.tsx +1462 -0
  256. package/src/datagrid/main/archbase-detail-panel-component.d.ts.map +1 -0
  257. package/src/datagrid/main/archbase-detail-panel-component.tsx +186 -0
  258. package/src/datagrid/main/archbase-expand-button.d.ts.map +1 -0
  259. package/src/datagrid/main/archbase-expand-button.tsx +83 -0
  260. package/src/datagrid/main/archbase-grid-popover.d.ts.map +1 -0
  261. package/src/datagrid/main/archbase-grid-popover.tsx +188 -0
  262. package/src/datagrid/main/grid-row-actions.d.ts.map +1 -0
  263. package/src/datagrid/main/grid-row-actions.tsx +97 -0
  264. package/src/datagrid/main/index.d.ts.map +1 -0
  265. package/src/datagrid/main/index.tsx +75 -0
  266. package/src/datagrid/modals/export-data.d.ts.map +1 -0
  267. package/src/datagrid/modals/export-data.tsx +183 -0
  268. package/src/datagrid/modals/export-modal.d.ts.map +1 -0
  269. package/src/datagrid/modals/export-modal.tsx +168 -0
  270. package/src/datagrid/modals/index.d.ts.map +1 -0
  271. package/src/datagrid/modals/index.tsx +6 -0
  272. package/src/datagrid/modals/print-data.d.ts.map +1 -0
  273. package/src/datagrid/modals/print-data.tsx +267 -0
  274. package/src/datagrid/modals/print-modal.d.ts.map +1 -0
  275. package/src/datagrid/modals/print-modal.tsx +200 -0
  276. package/src/datagrid/types/grid-props.d.ts.map +1 -0
  277. package/src/datagrid/types/grid-props.tsx +53 -0
  278. package/src/datagrid/types/index.d.ts.map +1 -0
  279. package/src/datagrid/types/index.tsx +1 -0
  280. package/src/datagrid/utils/formatter.d.ts.map +1 -0
  281. package/src/datagrid/utils/formatter.tsx +308 -0
  282. package/src/datagrid/utils/index.d.ts.map +1 -0
  283. package/src/datagrid/utils/index.tsx +1 -0
  284. package/src/debug/index.d.ts.map +1 -0
  285. package/src/debug/index.ts +4 -0
  286. package/src/debug/jsonpathpicker/ArchbaseJsonPathPicker.css +46 -0
  287. package/src/debug/jsonpathpicker/ArchbaseJsonPathPicker.d.ts.map +1 -0
  288. package/src/debug/jsonpathpicker/ArchbaseJsonPathPicker.tsx +341 -0
  289. package/src/debug/jsonpathpicker/index.d.ts.map +1 -0
  290. package/src/debug/jsonpathpicker/index.ts +1 -0
  291. package/src/debug/jsonview/.eslintrc +5 -0
  292. package/src/debug/jsonview/ArchbaseJsonViewDataRenderer.d.ts.map +1 -0
  293. package/src/debug/jsonview/ArchbaseJsonViewDataRenderer.tsx +206 -0
  294. package/src/debug/jsonview/ArchbaseJsonViewDataTypeDetection.d.ts.map +1 -0
  295. package/src/debug/jsonview/ArchbaseJsonViewDataTypeDetection.ts +31 -0
  296. package/src/debug/jsonview/index.d.ts.map +1 -0
  297. package/src/debug/jsonview/index.tsx +60 -0
  298. package/src/debug/jsonview/styles.module.css +118 -0
  299. package/src/debug/jsonview/styles.module.css.d.ts +4 -0
  300. package/src/debug/objectinspector/ArchbaseDebugInspector.d.ts.map +1 -0
  301. package/src/debug/objectinspector/ArchbaseDebugInspector.tsx +79 -0
  302. package/src/debug/objectinspector/ArchbaseFloatingWindow.css +70 -0
  303. package/src/debug/objectinspector/ArchbaseFloatingWindow.d.ts.map +1 -0
  304. package/src/debug/objectinspector/ArchbaseFloatingWindow.tsx +266 -0
  305. package/src/debug/objectinspector/ArchbaseObjectInspector.d.ts.map +1 -0
  306. package/src/debug/objectinspector/ArchbaseObjectInspector.tsx +21 -0
  307. package/src/debug/objectinspector/index.d.ts.map +1 -0
  308. package/src/debug/objectinspector/index.ts +3 -0
  309. package/src/display/index.d.ts.map +1 -0
  310. package/src/display/index.ts +5 -0
  311. package/src/editors/ArchbaseAsyncMultiSelect.d.ts.map +1 -0
  312. package/src/editors/ArchbaseAsyncMultiSelect.tsx +667 -0
  313. package/src/editors/ArchbaseAsyncSelect.context.d.ts.map +1 -0
  314. package/src/editors/ArchbaseAsyncSelect.context.ts +9 -0
  315. package/src/editors/ArchbaseAsyncSelect.d.ts.map +1 -0
  316. package/src/editors/ArchbaseAsyncSelect.tsx +581 -0
  317. package/src/editors/ArchbaseAvatarEdit.d.ts.map +1 -0
  318. package/src/editors/ArchbaseAvatarEdit.tsx +625 -0
  319. package/src/editors/ArchbaseCheckbox.d.ts.map +1 -0
  320. package/src/editors/ArchbaseCheckbox.tsx +250 -0
  321. package/src/editors/ArchbaseChip.d.ts.map +1 -0
  322. package/src/editors/ArchbaseChip.tsx +233 -0
  323. package/src/editors/ArchbaseChipGroup.d.ts.map +1 -0
  324. package/src/editors/ArchbaseChipGroup.tsx +282 -0
  325. package/src/editors/ArchbaseChipItem.d.ts.map +1 -0
  326. package/src/editors/ArchbaseChipItem.tsx +21 -0
  327. package/src/editors/ArchbaseColorPicker.d.ts.map +1 -0
  328. package/src/editors/ArchbaseColorPicker.tsx +7 -0
  329. package/src/editors/ArchbaseCountdownProgress.d.ts.map +1 -0
  330. package/src/editors/ArchbaseCountdownProgress.tsx +57 -0
  331. package/src/editors/ArchbaseCronExpressionEdit.d.ts.map +1 -0
  332. package/src/editors/ArchbaseCronExpressionEdit.tsx +86 -0
  333. package/src/editors/ArchbaseCronExpressionEditor.d.ts.map +1 -0
  334. package/src/editors/ArchbaseCronExpressionEditor.tsx +133 -0
  335. package/src/editors/ArchbaseDatePicker.tsx +3 -0
  336. package/src/editors/ArchbaseDatePickerEdit.d.ts.map +1 -0
  337. package/src/editors/ArchbaseDatePickerEdit.tsx +785 -0
  338. package/src/editors/ArchbaseDatePickerRange.d.ts.map +1 -0
  339. package/src/editors/ArchbaseDatePickerRange.tsx +142 -0
  340. package/src/editors/ArchbaseDateTimePickerEdit.d.ts.map +1 -0
  341. package/src/editors/ArchbaseDateTimePickerEdit.tsx +259 -0
  342. package/src/editors/ArchbaseDateTimePickerRange.d.ts.map +1 -0
  343. package/src/editors/ArchbaseDateTimePickerRange.tsx +220 -0
  344. package/src/editors/ArchbaseEdit.d.ts.map +1 -0
  345. package/src/editors/ArchbaseEdit.example.tsx +240 -0
  346. package/src/editors/ArchbaseEdit.tsx +325 -0
  347. package/src/editors/ArchbaseFileAttachment.d.ts.map +1 -0
  348. package/src/editors/ArchbaseFileAttachment.tsx +259 -0
  349. package/src/editors/ArchbaseImageEdit.d.ts.map +1 -0
  350. package/src/editors/ArchbaseImageEdit.tsx +255 -0
  351. package/src/editors/ArchbaseJsonEdit.d.ts.map +1 -0
  352. package/src/editors/ArchbaseJsonEdit.tsx +257 -0
  353. package/src/editors/ArchbaseKeyValueEditor.d.ts.map +1 -0
  354. package/src/editors/ArchbaseKeyValueEditor.tsx +180 -0
  355. package/src/editors/ArchbaseLookupEdit.d.ts.map +1 -0
  356. package/src/editors/ArchbaseLookupEdit.tsx +368 -0
  357. package/src/editors/ArchbaseLookupNumber.d.ts.map +1 -0
  358. package/src/editors/ArchbaseLookupNumber.tsx +390 -0
  359. package/src/editors/ArchbaseLookupSelect.d.ts.map +1 -0
  360. package/src/editors/ArchbaseLookupSelect.tsx +225 -0
  361. package/src/editors/ArchbaseMarkdownEdit.tsx +367 -0
  362. package/src/editors/ArchbaseMaskEdit.d.ts.map +1 -0
  363. package/src/editors/ArchbaseMaskEdit.tsx +346 -0
  364. package/src/editors/ArchbaseNumberEdit.d.ts.map +1 -0
  365. package/src/editors/ArchbaseNumberEdit.tsx +626 -0
  366. package/src/editors/ArchbaseNumberInput.tsx +3 -0
  367. package/src/editors/ArchbaseOperationHoursEditor.d.ts.map +1 -0
  368. package/src/editors/ArchbaseOperationHoursEditor.tsx +206 -0
  369. package/src/editors/ArchbasePasswordEdit.d.ts.map +1 -0
  370. package/src/editors/ArchbasePasswordEdit.tsx +265 -0
  371. package/src/editors/ArchbasePasswordInput.tsx +3 -0
  372. package/src/editors/ArchbaseRadio.tsx +3 -0
  373. package/src/editors/ArchbaseRadioGroup.d.ts.map +1 -0
  374. package/src/editors/ArchbaseRadioGroup.tsx +293 -0
  375. package/src/editors/ArchbaseRadioItem.d.ts.map +1 -0
  376. package/src/editors/ArchbaseRadioItem.tsx +14 -0
  377. package/src/editors/ArchbaseRating.d.ts.map +1 -0
  378. package/src/editors/ArchbaseRating.tsx +236 -0
  379. package/src/editors/ArchbaseRichTextEdit.d.ts.map +1 -0
  380. package/src/editors/ArchbaseRichTextEdit.tsx +435 -0
  381. package/src/editors/ArchbaseSelect.context.d.ts.map +1 -0
  382. package/src/editors/ArchbaseSelect.context.ts +9 -0
  383. package/src/editors/ArchbaseSelect.d.ts.map +1 -0
  384. package/src/editors/ArchbaseSelect.tsx +550 -0
  385. package/src/editors/ArchbaseSelectItem.d.ts.map +1 -0
  386. package/src/editors/ArchbaseSelectItem.tsx +18 -0
  387. package/src/editors/ArchbaseSwitch.d.ts.map +1 -0
  388. package/src/editors/ArchbaseSwitch.tsx +266 -0
  389. package/src/editors/ArchbaseTextArea.d.ts.map +1 -0
  390. package/src/editors/ArchbaseTextArea.tsx +263 -0
  391. package/src/editors/ArchbaseTimeEdit.d.ts.map +1 -0
  392. package/src/editors/ArchbaseTimeEdit.tsx +319 -0
  393. package/src/editors/ArchbaseTimeRangeSelector.d.ts.map +1 -0
  394. package/src/editors/ArchbaseTimeRangeSelector.tsx +397 -0
  395. package/src/editors/ArchbaseTreeSelect.d.ts.map +1 -0
  396. package/src/editors/ArchbaseTreeSelect.tsx +434 -0
  397. package/src/editors/index.d.ts.map +1 -0
  398. package/src/editors/index.tsx +121 -0
  399. package/src/editors/intro.mdx +4 -0
  400. package/src/feedback/index.d.ts.map +1 -0
  401. package/src/feedback/index.ts +5 -0
  402. package/src/filters/ArchbaseCompositeFilters.tsx +696 -0
  403. package/src/filters/ArchbaseCompositeFilters.types.ts +402 -0
  404. package/src/filters/ArchbaseCompositeFilters.utils.ts +378 -0
  405. package/src/filters/components/FilterPill.tsx +100 -0
  406. package/src/filters/hooks/index.ts +4 -0
  407. package/src/filters/hooks/useArchbaseFilterHistory.ts +111 -0
  408. package/src/filters/hooks/useArchbaseFilterPresets.ts +157 -0
  409. package/src/filters/hooks/useArchbaseFilters.ts +279 -0
  410. package/src/filters/hooks/useArchbaseQuickFilters.ts +80 -0
  411. package/src/filters/index.ts +55 -0
  412. package/src/forms/index.d.ts.map +1 -0
  413. package/src/forms/index.ts +4 -0
  414. package/src/hooks/index.d.ts.map +1 -0
  415. package/src/hooks/index.ts +5 -0
  416. package/src/hooks/useArchbaseContainerDimensions.d.ts.map +1 -0
  417. package/src/hooks/useArchbaseContainerDimensions.ts +28 -0
  418. package/src/hooks/useArchbaseElementSizeArea.d.ts.map +1 -0
  419. package/src/hooks/useArchbaseElementSizeArea.ts +39 -0
  420. package/src/hooks/useArchbaseListContext.d.ts.map +1 -0
  421. package/src/hooks/useArchbaseListContext.ts +10 -0
  422. package/src/hooks/useArchbaseNavigateParams.d.ts.map +1 -0
  423. package/src/hooks/useArchbaseNavigateParams.ts +17 -0
  424. package/src/hooks/useArchbaseVisible.d.ts.map +1 -0
  425. package/src/hooks/useArchbaseVisible.ts +35 -0
  426. package/src/image/.placeholder +0 -0
  427. package/src/image/ArchbaseImage.d.ts.map +1 -0
  428. package/src/image/ArchbaseImage.tsx +56 -0
  429. package/src/image/ArchbaseMicrosoftAvatar.d.ts.map +1 -0
  430. package/src/image/ArchbaseMicrosoftAvatar.tsx +50 -0
  431. package/src/image/editor/components/BasicFilters/BasicFilter.d.ts.map +1 -0
  432. package/src/image/editor/components/BasicFilters/BasicFilter.tsx +179 -0
  433. package/src/image/editor/components/CropprWrapper/ArchbaseCropper.scss +73 -0
  434. package/src/image/editor/components/CropprWrapper/ArchbaseCropperWrapper.d.ts.map +1 -0
  435. package/src/image/editor/components/CropprWrapper/ArchbaseCropperWrapper.tsx +50 -0
  436. package/src/image/editor/components/EditImage/ArchbaseEditImage.d.ts.map +1 -0
  437. package/src/image/editor/components/EditImage/ArchbaseEditImage.scss +221 -0
  438. package/src/image/editor/components/EditImage/ArchbaseEditImage.tsx +469 -0
  439. package/src/image/editor/components/Input/Input.d.ts.map +1 -0
  440. package/src/image/editor/components/Input/Input.tsx +70 -0
  441. package/src/image/editor/components/Tab/Tab.d.ts.map +1 -0
  442. package/src/image/editor/components/Tab/Tab.tsx +150 -0
  443. package/src/image/editor/components/Tab/TabsStyles.scss +72 -0
  444. package/src/image/editor/functions/croppr/box.d.ts.map +1 -0
  445. package/src/image/editor/functions/croppr/box.ts +272 -0
  446. package/src/image/editor/functions/croppr/core.d.ts.map +1 -0
  447. package/src/image/editor/functions/croppr/core.ts +820 -0
  448. package/src/image/editor/functions/croppr/croppr.d.ts.map +1 -0
  449. package/src/image/editor/functions/croppr/croppr.ts +136 -0
  450. package/src/image/editor/functions/croppr/handle.d.ts.map +1 -0
  451. package/src/image/editor/functions/croppr/handle.ts +75 -0
  452. package/src/image/editor/functions/croppr/index.d.ts.map +1 -0
  453. package/src/image/editor/functions/croppr/index.ts +4 -0
  454. package/src/image/editor/functions/croppr/touch.d.ts.map +1 -0
  455. package/src/image/editor/functions/croppr/touch.ts +41 -0
  456. package/src/image/editor/functions/image-processing.d.ts.map +1 -0
  457. package/src/image/editor/functions/image-processing.ts +202 -0
  458. package/src/image/editor/image_editor_styles.scss +284 -0
  459. package/src/image/editor/index.d.ts.map +1 -0
  460. package/src/image/editor/index.tsx +437 -0
  461. package/src/image/editor/models/index.models.d.ts.map +1 -0
  462. package/src/image/editor/models/index.models.ts +48 -0
  463. package/src/image/index.d.ts.map +1 -0
  464. package/src/image/index.ts +7 -0
  465. package/src/image/intro.mdx +4 -0
  466. package/src/image/languages.d.ts.map +1 -0
  467. package/src/image/languages.ts +302 -0
  468. package/src/index.d.ts.map +1 -0
  469. package/src/index.ts +50 -0
  470. package/src/jsonschema/ArchbaseJsonSchemaEditor.types.d.ts.map +1 -0
  471. package/src/jsonschema/ArchbaseJsonSchemaEditor.types.ts +171 -0
  472. package/src/jsonschema/JsonSchemaEditor/ArchbaseJsonSchemaEditor.context.d.ts.map +1 -0
  473. package/src/jsonschema/JsonSchemaEditor/ArchbaseJsonSchemaEditor.context.tsx +8 -0
  474. package/src/jsonschema/JsonSchemaEditor/ArchbaseJsonSchemaEditor.d.ts.map +1 -0
  475. package/src/jsonschema/JsonSchemaEditor/ArchbaseJsonSchemaEditor.tsx +99 -0
  476. package/src/jsonschema/JsonSchemaEditor/JsonSchemaEditor.scss +19 -0
  477. package/src/jsonschema/JsonSchemaEditor/advanced-boolean/index.d.ts.map +1 -0
  478. package/src/jsonschema/JsonSchemaEditor/advanced-boolean/index.tsx +33 -0
  479. package/src/jsonschema/JsonSchemaEditor/advanced-number/index.d.ts.map +1 -0
  480. package/src/jsonschema/JsonSchemaEditor/advanced-number/index.tsx +119 -0
  481. package/src/jsonschema/JsonSchemaEditor/advanced-string/index.d.ts.map +1 -0
  482. package/src/jsonschema/JsonSchemaEditor/advanced-string/index.tsx +146 -0
  483. package/src/jsonschema/JsonSchemaEditor/drop-plus/index.d.ts.map +1 -0
  484. package/src/jsonschema/JsonSchemaEditor/drop-plus/index.tsx +80 -0
  485. package/src/jsonschema/JsonSchemaEditor/index.ts +2 -0
  486. package/src/jsonschema/JsonSchemaEditor/schema-advanced/index.d.ts.map +1 -0
  487. package/src/jsonschema/JsonSchemaEditor/schema-advanced/index.tsx +32 -0
  488. package/src/jsonschema/JsonSchemaEditor/schema-array/index.d.ts.map +1 -0
  489. package/src/jsonschema/JsonSchemaEditor/schema-array/index.tsx +164 -0
  490. package/src/jsonschema/JsonSchemaEditor/schema-item/index.d.ts.map +1 -0
  491. package/src/jsonschema/JsonSchemaEditor/schema-item/index.tsx +213 -0
  492. package/src/jsonschema/JsonSchemaEditor/schema-object/index.d.ts.map +1 -0
  493. package/src/jsonschema/JsonSchemaEditor/schema-object/index.tsx +68 -0
  494. package/src/jsonschema/JsonSchemaEditor/schema-root/index.d.ts.map +1 -0
  495. package/src/jsonschema/JsonSchemaEditor/schema-root/index.tsx +103 -0
  496. package/src/jsonschema/JsonSchemaEditor/utils.d.ts.map +1 -0
  497. package/src/jsonschema/JsonSchemaEditor/utils.ts +195 -0
  498. package/src/jsonschema/JsonSchemaEditor/whoops.tsx +79 -0
  499. package/src/jsonschema/index.d.ts.map +1 -0
  500. package/src/jsonschema/index.ts +2 -0
  501. package/src/list/ArchbaseList.context.d.ts.map +1 -0
  502. package/src/list/ArchbaseList.context.ts +28 -0
  503. package/src/list/ArchbaseList.d.ts.map +1 -0
  504. package/src/list/ArchbaseList.tsx +533 -0
  505. package/src/list/ArchbaseListItem.d.ts.map +1 -0
  506. package/src/list/ArchbaseListItem.tsx +161 -0
  507. package/src/list/index.d.ts.map +1 -0
  508. package/src/list/index.ts +9 -0
  509. package/src/list/treeview/ArchbaseTreeView.d.ts.map +1 -0
  510. package/src/list/treeview/ArchbaseTreeView.module.css +66 -0
  511. package/src/list/treeview/ArchbaseTreeView.tsx +657 -0
  512. package/src/list/treeview/ArchbaseTreeView.types.d.ts.map +1 -0
  513. package/src/list/treeview/ArchbaseTreeView.types.tsx +42 -0
  514. package/src/list/treeview/ArchbaseTreeViewItem.d.ts.map +1 -0
  515. package/src/list/treeview/ArchbaseTreeViewItem.tsx +210 -0
  516. package/src/list/treeview/index.d.ts.map +1 -0
  517. package/src/list/treeview/index.ts +5 -0
  518. package/src/list-view/ArchbaseListViewTable.tsx +150 -0
  519. package/src/list-view/index.ts +2 -0
  520. package/src/markdown/ArchbaseMarkdown.tsx +463 -0
  521. package/src/markdown/ArchbaseMarkdown.types.ts +213 -0
  522. package/src/markdown/components/CodeBlock.tsx +197 -0
  523. package/src/markdown/components/LinkRenderer.tsx +98 -0
  524. package/src/markdown/index.ts +29 -0
  525. package/src/masonry/ArchbaseMasonry.context.d.ts.map +1 -0
  526. package/src/masonry/ArchbaseMasonry.context.ts +24 -0
  527. package/src/masonry/ArchbaseMasonry.d.ts.map +1 -0
  528. package/src/masonry/ArchbaseMasonry.tsx +156 -0
  529. package/src/masonry/index.d.ts.map +1 -0
  530. package/src/masonry/index.ts +5 -0
  531. package/src/navigation/index.d.ts.map +1 -0
  532. package/src/navigation/index.ts +4 -0
  533. package/src/notification/ArchbaseAlert.d.ts.map +1 -0
  534. package/src/notification/ArchbaseAlert.tsx +77 -0
  535. package/src/notification/ArchbaseDialog.d.ts.map +1 -0
  536. package/src/notification/ArchbaseDialog.tsx +212 -0
  537. package/src/notification/ArchbaseNotifications.d.ts.map +1 -0
  538. package/src/notification/ArchbaseNotifications.tsx +64 -0
  539. package/src/notification/index.d.ts.map +1 -0
  540. package/src/notification/index.ts +4 -0
  541. package/src/notification/intro.mdx +4 -0
  542. package/src/onboarding/ArchbaseOnboardingTour.tsx +147 -0
  543. package/src/onboarding/index.ts +2 -0
  544. package/src/printer/ArchbaseThermalPrinter.tsx +465 -0
  545. package/src/printer/ArchbaseThermalPrinter.types.ts +221 -0
  546. package/src/printer/index.ts +54 -0
  547. package/src/printer/utils/escpos.ts +531 -0
  548. package/src/spreadsheet/ArchbaseSpreadsheetImport.tsx +223 -0
  549. package/src/spreadsheet/ArchbaseSpreadsheetImport.types.ts +66 -0
  550. package/src/spreadsheet/index.ts +10 -0
  551. package/src/theme-editor/ArchbaseThemeEditor.tsx +728 -0
  552. package/src/theme-editor/ArchbaseThemeEditor.types.ts +207 -0
  553. package/src/theme-editor/index.ts +45 -0
  554. package/src/theme-editor/utils/themeExport.ts +351 -0
  555. package/src/themes/.placeholder +0 -0
  556. package/src/themes/ArchbaseThemeEditor.d.ts.map +1 -0
  557. package/src/themes/ArchbaseThemeEditor.tsx +110 -0
  558. package/src/treeviews.scss +80 -0
  559. package/src/types/index.d.ts.map +1 -0
  560. package/src/types/index.ts +115 -0
  561. package/src/video/ArchbaseVideoPlayer.tsx +706 -0
  562. package/src/video/ArchbaseVideoPlayer.types.ts +221 -0
  563. package/src/video/hooks/useVideoPlayer.ts +362 -0
  564. package/src/video/index.ts +28 -0
  565. package/src/viewers/ArchbasePDFViewer.annotations.tsx +423 -0
  566. package/src/viewers/ArchbasePDFViewer.toolbar.tsx +218 -0
  567. package/src/viewers/ArchbasePDFViewer.tsx +317 -0
  568. package/src/viewers/ArchbasePDFViewer.types.ts +85 -0
  569. package/src/viewers/file-preview/ArchbaseFilePreviewer.tsx +756 -0
  570. package/src/viewers/file-preview/ArchbaseFilePreviewer.types.ts +186 -0
  571. package/src/viewers/file-preview/index.ts +43 -0
  572. package/src/viewers/file-preview/utils/fileTypeDetector.ts +317 -0
  573. package/src/viewers/index.ts +17 -0
@@ -0,0 +1,820 @@
1
+ /**
2
+ * CropprCore
3
+ * Here lies the main logic.
4
+ */
5
+
6
+ import Handle from "./handle";
7
+ import Box from "./box";
8
+ import enableTouch from "./touch";
9
+
10
+ /**
11
+ * Define a list of handles to create.
12
+ *
13
+ * @property {Array} position - The x and y ratio position of the handle within
14
+ * the crop region. Accepts a value between 0 to 1 in the order of [X, Y].
15
+ * @property {Array} constraints - Define the side of the crop region that is to
16
+ * be affected by this handle. Accepts a value of 0 or 1 in the order of
17
+ * [TOP, RIGHT, BOTTOM, LEFT].
18
+ * @property {String} cursor - The CSS cursor of this handle.
19
+ */
20
+ const HANDLES = [
21
+ { position: [0.0, 0.0], constraints: [1, 0, 0, 1], cursor: "nw-resize" },
22
+ { position: [0.5, 0.0], constraints: [1, 0, 0, 0], cursor: "n-resize" },
23
+ { position: [1.0, 0.0], constraints: [1, 1, 0, 0], cursor: "ne-resize" },
24
+ { position: [1.0, 0.5], constraints: [0, 1, 0, 0], cursor: "e-resize" },
25
+ { position: [1.0, 1.0], constraints: [0, 1, 1, 0], cursor: "se-resize" },
26
+ { position: [0.5, 1.0], constraints: [0, 0, 1, 0], cursor: "s-resize" },
27
+ { position: [0.0, 1.0], constraints: [0, 0, 1, 1], cursor: "sw-resize" },
28
+ { position: [0.0, 0.5], constraints: [0, 0, 0, 1], cursor: "w-resize" },
29
+ ];
30
+
31
+ /**
32
+ * Core class for Croppr containing most of its functional logic.
33
+ */
34
+ export default class CropprCore {
35
+ options: any;
36
+ _initialized: any;
37
+ _restore: any;
38
+ cropperEl: any;
39
+ box: any;
40
+ containerEl: any;
41
+ imageEl: any;
42
+ eventBus: any;
43
+ imageClippedEl: any;
44
+ regionEl: HTMLElement;
45
+ overlayEl: any;
46
+ handles: any;
47
+ activeHandle: any;
48
+ currentMove: any;
49
+
50
+ constructor(element: any, options: any, deferred = false) {
51
+ // console.log("🚀 ~ file: core.ts ~ line 51 ~ CropprCore ~ constructor ~ element", element)
52
+ // Parse options
53
+ this.options = CropprCore.parseOptions(options || {});
54
+
55
+ // Get target img element
56
+ if (!element.nodeName) {
57
+ element = document.querySelector(element);
58
+ // console.log("🚀 ~ file: core.ts ~ line 58 ~ CropprCore ~ constructor ~ element", element)
59
+ if (element == null) {
60
+ throw "Unable to find element.";
61
+ }
62
+ }
63
+ if (!element.getAttribute("src")) {
64
+ throw "Image src not provided.";
65
+ }
66
+
67
+ // Define internal props
68
+ this._initialized = false;
69
+ this._restore = {
70
+ parent: element.parentNode,
71
+ element: element,
72
+ };
73
+
74
+ // Wait until image is loaded before proceeding
75
+ if (!deferred) {
76
+ if (element.width === 0 || element.height === 0) {
77
+ element.onload = () => {
78
+ this.initialize(element);
79
+ };
80
+ } else {
81
+ this.initialize(element);
82
+ }
83
+ }
84
+ }
85
+
86
+ /**
87
+ * Initialize the Croppr instance
88
+ */
89
+ initialize(element: any) {
90
+ // Create DOM elements
91
+ this.createDOM(element);
92
+
93
+ // Process option values
94
+ this.options.convertToPixels(this.cropperEl);
95
+
96
+ // Listen for events from children
97
+ this.attachHandlerEvents();
98
+ this.attachRegionEvents();
99
+ this.attachOverlayEvents();
100
+
101
+ // Bootstrap this cropper instance
102
+ this.box = this.initializeBox(this.options);
103
+ this.redraw();
104
+
105
+ // Set the initalized flag to true and call the callback
106
+ this._initialized = true;
107
+ if (this.options.onInitialize !== null) {
108
+ this.options.onInitialize(this);
109
+ }
110
+ }
111
+
112
+ /**
113
+ * Create Croppr's DOM elements
114
+ */
115
+ createDOM(targetEl: any) {
116
+ // Create main container and use it as the main event listeners
117
+ this.containerEl = document.createElement("div");
118
+ this.containerEl.className = "croppr-container";
119
+ this.eventBus = this.containerEl;
120
+ enableTouch(this.containerEl);
121
+
122
+ // Create cropper element
123
+ this.cropperEl = document.createElement("div");
124
+ this.cropperEl.className = "croppr";
125
+
126
+ // Create image element
127
+ this.imageEl = document.createElement("img");
128
+ this.imageEl.setAttribute("src", targetEl.getAttribute("src"));
129
+ this.imageEl.setAttribute("alt", targetEl.getAttribute("alt"));
130
+ this.imageEl.className = "croppr-image";
131
+
132
+ // Create clipped image element
133
+ this.imageClippedEl = this.imageEl.cloneNode();
134
+ this.imageClippedEl.className = "croppr-imageClipped";
135
+
136
+ // Create region box element
137
+ this.regionEl = document.createElement("div");
138
+ this.regionEl.innerHTML = new Array(9)
139
+ .fill(1)
140
+ .map(() => `<div style="border: 1px dashed #fafafa"></div>`)
141
+ .join("");
142
+ this.regionEl.className = "croppr-region";
143
+
144
+ // Create overlay element
145
+ this.overlayEl = document.createElement("div");
146
+ this.overlayEl.className = "croppr-overlay";
147
+
148
+ // Create handles element
149
+ let handleContainerEl = document.createElement("div");
150
+ handleContainerEl.className = "croppr-handleContainer";
151
+ this.handles = [];
152
+ for (let i = 0; i < HANDLES.length; i++) {
153
+ const handle = new Handle(
154
+ HANDLES[i].position,
155
+ HANDLES[i].constraints,
156
+ HANDLES[i].cursor,
157
+ this.eventBus
158
+ );
159
+ this.handles.push(handle);
160
+ handleContainerEl.appendChild(handle.el);
161
+ }
162
+
163
+ // And then we piece it all together!
164
+ this.cropperEl.appendChild(this.imageEl);
165
+ this.cropperEl.appendChild(this.imageClippedEl);
166
+ this.cropperEl.appendChild(this.regionEl);
167
+ this.cropperEl.appendChild(this.overlayEl);
168
+ this.cropperEl.appendChild(handleContainerEl);
169
+ this.containerEl.appendChild(this.cropperEl);
170
+
171
+ // And then finally insert it into the document
172
+ targetEl.parentElement.replaceChild(this.containerEl, targetEl);
173
+ }
174
+
175
+ /**
176
+ * Changes the image src.
177
+ * @param {String} src
178
+ */
179
+ setImage(src: any) {
180
+ // Add onload listener to reinitialize box
181
+ this.imageEl.onload = () => {
182
+ this.box = this.initializeBox(this.options);
183
+ this.redraw();
184
+ };
185
+
186
+ // Change image source
187
+ this.imageEl.src = src;
188
+ this.imageClippedEl.src = src;
189
+ return this;
190
+ }
191
+
192
+ /**
193
+ * Destroy the Croppr instance and replace with the original element.
194
+ */
195
+ destroy() {
196
+ this._restore.parent.replaceChild(this._restore.element, this.containerEl);
197
+ }
198
+
199
+ /**
200
+ * Create a new box region with a set of options.
201
+ * @param {Object} opts The options.
202
+ * @returns {Box}
203
+ */
204
+ initializeBox(opts: any) {
205
+ // Create initial box
206
+ const width = opts.startSize.width;
207
+ const height = opts.startSize.height;
208
+ let box = new Box(0, 0, width, height);
209
+ // console.log("🚀 ~ file: core.ts ~ line 202 ~ CropprCore ~ initializeBox ~ box", box)
210
+
211
+ // Maintain ratio
212
+ box.constrainToRatio(opts.aspectRatio, [0.5, 0.5]);
213
+
214
+ // Maintain minimum/maximum size
215
+ const min = opts.minSize;
216
+ const max = opts.maxSize;
217
+ box.constrainToSize(
218
+ max.width,
219
+ max.height,
220
+ min.width,
221
+ min.height,
222
+ [0.5, 0.5],
223
+ opts.aspectRatio
224
+ );
225
+
226
+ // Constrain to boundary
227
+ const parentWidth = this.cropperEl.offsetWidth;
228
+ const parentHeight = this.cropperEl.offsetHeight;
229
+ box.constrainToBoundary(parentWidth, parentHeight, [0.5, 0.5]);
230
+
231
+ // // Move to center
232
+ const x = this.cropperEl.offsetWidth / 2 - box.width() / 2;
233
+ const y = this.cropperEl.offsetHeight / 2 - box.height() / 2;
234
+
235
+ // console.log("🚀 ~ file: core.ts ~ line 219 ~ CropprCore ~ initializeBox ~ this.cropperEl", this.cropperEl.offsetWidth)
236
+ // console.log("🚀 ~ file: core.ts ~ line 223 ~ CropprCore ~ initializeBox ~ x, y", x, y)
237
+ box.move(x as any, y as any);
238
+
239
+ return box;
240
+ }
241
+
242
+ /**
243
+ * Draw visuals (border, handles, etc) for the current box.
244
+ */
245
+ redraw() {
246
+ // Round positional values to prevent subpixel coordinates, which can
247
+ // result in element that is rendered blurly
248
+ const width = Math.round(this.box.width()),
249
+ height = Math.round(this.box.height()),
250
+ x1 = Math.round(this.box.x1),
251
+ y1 = Math.round(this.box.y1),
252
+ x2 = Math.round(this.box.x2),
253
+ y2 = Math.round(this.box.y2);
254
+
255
+ window.requestAnimationFrame(() => {
256
+ // Update region element
257
+ this.regionEl.style.transform = `translate(${x1}px, ${y1}px)`;
258
+ this.regionEl.style.width = width + "px";
259
+ this.regionEl.style.height = height + "px";
260
+
261
+ // Update clipped image element
262
+ this.imageClippedEl.style.clip = `rect(${y1}px, ${x2}px, ${y2}px, ${x1}px)`;
263
+
264
+ // Determine which handle to bring forward. The following code
265
+ // calculates the quadrant the box is in using bitwise operators.
266
+ // Reference: https://stackoverflow.com/questions/9718059
267
+ const center = this.box.getAbsolutePoint([0.5, 0.5]);
268
+ const xSign = (center[0] - this.cropperEl.offsetWidth / 2) >> 31;
269
+ const ySign = (center[1] - this.cropperEl.offsetHeight / 2) >> 31;
270
+ const quadrant = (xSign ^ ySign) + ySign + ySign + 4;
271
+
272
+ // The following equation calculates which handle index to bring
273
+ // forward. The equation is derived using algebra (if youre curious)
274
+ const foregroundHandleIndex = -2 * quadrant + 8;
275
+
276
+ // Update handle positions
277
+ for (let i = 0; i < this.handles.length; i++) {
278
+ let handle = this.handles[i];
279
+
280
+ // Calculate handle position
281
+ const handleWidth = handle.el.offsetWidth;
282
+ const handleHeight = handle.el.offsetHeight;
283
+ const left = x1 + width * handle.position[0] - handleWidth / 2;
284
+ const top = y1 + height * handle.position[1] - handleHeight / 2;
285
+
286
+ // Apply new position. The positional values are rounded to
287
+ // prevent subpixel positions which can result in a blurry element
288
+ handle.el.style.transform = `translate(${Math.round(
289
+ left
290
+ )}px, ${Math.round(top)}px)`;
291
+ handle.el.style.zIndex = foregroundHandleIndex == i ? 5 : 4;
292
+ }
293
+ });
294
+ }
295
+
296
+ /**
297
+ * Attach listeners for events emitted by the handles.
298
+ * Enables resizing of the region element.
299
+ */
300
+ attachHandlerEvents() {
301
+ const eventBus = this.eventBus;
302
+ eventBus.addEventListener("handlestart", this.onHandleMoveStart.bind(this));
303
+ eventBus.addEventListener("handlemove", this.onHandleMoveMoving.bind(this));
304
+ eventBus.addEventListener("handleend", this.onHandleMoveEnd.bind(this));
305
+ }
306
+
307
+ /**
308
+ * Attach event listeners for the crop region element.
309
+ * Enables dragging/moving of the region element.
310
+ */
311
+ attachRegionEvents() {
312
+ const eventBus = this.eventBus;
313
+ const self = this;
314
+
315
+ this.regionEl.addEventListener("mousedown", onMouseDown);
316
+ eventBus.addEventListener("regionstart", this.onRegionMoveStart.bind(this));
317
+ eventBus.addEventListener("regionmove", this.onRegionMoveMoving.bind(this));
318
+ eventBus.addEventListener("regionend", this.onRegionMoveEnd.bind(this));
319
+
320
+ function onMouseDown(e: any) {
321
+ e.stopPropagation();
322
+ document.addEventListener("mouseup", onMouseUp);
323
+ document.addEventListener("mousemove", onMouseMove);
324
+
325
+ // Notify parent
326
+ eventBus.dispatchEvent(
327
+ new CustomEvent("regionstart", {
328
+ detail: { mouseX: e.clientX, mouseY: e.clientY },
329
+ })
330
+ );
331
+ }
332
+
333
+ function onMouseMove(e: any) {
334
+ e.stopPropagation();
335
+
336
+ // Notify parent
337
+ eventBus.dispatchEvent(
338
+ new CustomEvent("regionmove", {
339
+ detail: { mouseX: e.clientX, mouseY: e.clientY },
340
+ })
341
+ );
342
+ }
343
+
344
+ function onMouseUp(e: any) {
345
+ e.stopPropagation();
346
+ document.removeEventListener("mouseup", onMouseUp);
347
+ document.removeEventListener("mousemove", onMouseMove);
348
+
349
+ // Notify parent
350
+ eventBus.dispatchEvent(
351
+ new CustomEvent("regionend", {
352
+ detail: { mouseX: e.clientX, mouseY: e.clientY },
353
+ })
354
+ );
355
+ }
356
+ }
357
+
358
+ /**
359
+ * Attach event listeners for the overlay element.
360
+ * Enables the creation of a new selection by dragging an empty area.
361
+ */
362
+ attachOverlayEvents() {
363
+ const SOUTHEAST_HANDLE_IDX = 4;
364
+ const self = this;
365
+ let tmpBox: any = null;
366
+ this.overlayEl.addEventListener("mousedown", onMouseDown);
367
+
368
+ function onMouseDown(e: any) {
369
+ e.stopPropagation();
370
+ document.addEventListener("mouseup", onMouseUp);
371
+ document.addEventListener("mousemove", onMouseMove);
372
+
373
+ // Calculate mouse's position in relative to the container
374
+ const container = self.cropperEl.getBoundingClientRect();
375
+ const mouseX = e.clientX - container.left;
376
+ const mouseY = e.clientY - container.top;
377
+
378
+ // Create new box at mouse position
379
+ tmpBox = self.box;
380
+ self.box = new Box(mouseX, mouseY, mouseX + 1, mouseY + 1);
381
+
382
+ // Activate the bottom right handle
383
+ self.eventBus.dispatchEvent(
384
+ new CustomEvent("handlestart", {
385
+ detail: { handle: self.handles[SOUTHEAST_HANDLE_IDX] },
386
+ })
387
+ );
388
+ }
389
+
390
+ function onMouseMove(e: any) {
391
+ e.stopPropagation();
392
+ self.eventBus.dispatchEvent(
393
+ new CustomEvent("handlemove", {
394
+ detail: { mouseX: e.clientX, mouseY: e.clientY },
395
+ })
396
+ );
397
+ }
398
+
399
+ function onMouseUp(e: any) {
400
+ e.stopPropagation();
401
+ document.removeEventListener("mouseup", onMouseUp);
402
+ document.removeEventListener("mousemove", onMouseMove);
403
+
404
+ // If the new box has no width and height, it suggests that
405
+ // the user had just clicked on an empty area and did not drag
406
+ // a new box (ie. an accidental click). In this scenario, we
407
+ // simply replace it with the previous box.
408
+ if (self.box.width() === 1 && self.box.height() === 1) {
409
+ self.box = tmpBox;
410
+ return;
411
+ }
412
+
413
+ self.eventBus.dispatchEvent(
414
+ new CustomEvent("handleend", {
415
+ detail: { mouseX: e.clientX, mouseY: e.clientY },
416
+ })
417
+ );
418
+ }
419
+ }
420
+
421
+ /**
422
+ * EVENT HANDLER
423
+ * Executes when user begins dragging a handle.
424
+ */
425
+ onHandleMoveStart(e: any) {
426
+ let handle = e.detail.handle;
427
+
428
+ // The origin point is the point where the box is scaled from.
429
+ // This is usually the opposite side/corner of the active handle.
430
+ const originPoint = [1 - handle.position[0], 1 - handle.position[1]];
431
+ let [originX, originY] = this.box.getAbsolutePoint(originPoint);
432
+
433
+ this.activeHandle = { handle, originPoint, originX, originY };
434
+
435
+ // Trigger callback
436
+ if (this.options.onCropStart !== null) {
437
+ this.options.onCropStart(this.getValue());
438
+ }
439
+ }
440
+
441
+ /**
442
+ * EVENT HANDLER
443
+ * Executes on handle move. Main logic to manage the movement of handles.
444
+ */
445
+ onHandleMoveMoving(e: any) {
446
+ let { mouseX, mouseY } = e.detail;
447
+
448
+ // Calculate mouse's position in relative to the container
449
+ let container = this.cropperEl.getBoundingClientRect();
450
+ mouseX = mouseX - container.left;
451
+ mouseY = mouseY - container.top;
452
+
453
+ // Ensure mouse is within the boundaries
454
+ if (mouseX < 0) {
455
+ mouseX = 0;
456
+ } else if (mouseX > container.width) {
457
+ mouseX = container.width;
458
+ }
459
+
460
+ if (mouseY < 0) {
461
+ mouseY = 0;
462
+ } else if (mouseY > container.height) {
463
+ mouseY = container.height;
464
+ }
465
+
466
+ // Bootstrap helper variables
467
+ let origin = this.activeHandle.originPoint.slice();
468
+ const originX = this.activeHandle.originX;
469
+ const originY = this.activeHandle.originY;
470
+ const handle = this.activeHandle.handle;
471
+ const TOP_MOVABLE = handle.constraints[0] === 1;
472
+ const RIGHT_MOVABLE = handle.constraints[1] === 1;
473
+ const BOTTOM_MOVABLE = handle.constraints[2] === 1;
474
+ const LEFT_MOVABLE = handle.constraints[3] === 1;
475
+ const MULTI_AXIS =
476
+ (LEFT_MOVABLE || RIGHT_MOVABLE) && (TOP_MOVABLE || BOTTOM_MOVABLE);
477
+
478
+ // Apply movement to respective sides according to the handle's
479
+ // constraint values.
480
+ let x1 = LEFT_MOVABLE || RIGHT_MOVABLE ? originX : this.box.x1;
481
+ let x2 = LEFT_MOVABLE || RIGHT_MOVABLE ? originX : this.box.x2;
482
+ let y1 = TOP_MOVABLE || BOTTOM_MOVABLE ? originY : this.box.y1;
483
+ let y2 = TOP_MOVABLE || BOTTOM_MOVABLE ? originY : this.box.y2;
484
+ x1 = LEFT_MOVABLE ? mouseX : x1;
485
+ x2 = RIGHT_MOVABLE ? mouseX : x2;
486
+ y1 = TOP_MOVABLE ? mouseY : y1;
487
+ y2 = BOTTOM_MOVABLE ? mouseY : y2;
488
+
489
+ // Check if the user dragged past the origin point. If it did,
490
+ // we set the flipped flag to true.
491
+ let [isFlippedX, isFlippedY] = [false, false];
492
+ if (LEFT_MOVABLE || RIGHT_MOVABLE) {
493
+ isFlippedX = LEFT_MOVABLE ? mouseX > originX : mouseX < originX;
494
+ }
495
+ if (TOP_MOVABLE || BOTTOM_MOVABLE) {
496
+ isFlippedY = TOP_MOVABLE ? mouseY > originY : mouseY < originY;
497
+ }
498
+
499
+ // If it is flipped, we swap the coordinates and flip the origin point.
500
+ if (isFlippedX) {
501
+ const tmp = x1;
502
+ x1 = x2;
503
+ x2 = tmp; // Swap x1 and x2
504
+ origin[0] = 1 - origin[0]; // Flip origin x point
505
+ }
506
+ if (isFlippedY) {
507
+ const tmp = y1;
508
+ y1 = y2;
509
+ y2 = tmp; // Swap y1 and y2
510
+ origin[1] = 1 - origin[1]; // Flip origin y point
511
+ }
512
+
513
+ // Create new box object
514
+ let box = new Box(x1, y1, x2, y2);
515
+
516
+ // Maintain aspect ratio
517
+ if (this.options.aspectRatio) {
518
+ const ratio = this.options.aspectRatio;
519
+ let isVerticalMovement = false;
520
+ if (MULTI_AXIS) {
521
+ isVerticalMovement =
522
+ mouseY > box.y1 + ratio * box.width() ||
523
+ mouseY < box.y2 - ratio * box.width();
524
+ } else if (TOP_MOVABLE || BOTTOM_MOVABLE) {
525
+ isVerticalMovement = true;
526
+ }
527
+ const ratioMode = isVerticalMovement ? "width" : "height";
528
+ box.constrainToRatio(ratio, origin, ratioMode);
529
+ }
530
+
531
+ // Maintain minimum/maximum size
532
+ const min = this.options.minSize;
533
+ const max = this.options.maxSize;
534
+ box.constrainToSize(
535
+ max.width,
536
+ max.height,
537
+ min.width,
538
+ min.height,
539
+ origin,
540
+ this.options.aspectRatio
541
+ );
542
+
543
+ // Constrain to boundary
544
+ const parentWidth = this.cropperEl.offsetWidth;
545
+ const parentHeight = this.cropperEl.offsetHeight;
546
+ box.constrainToBoundary(parentWidth, parentHeight, origin);
547
+
548
+ // Finally, update the visuals (border, handles, clipped image, etc)
549
+ this.box = box;
550
+ this.redraw();
551
+
552
+ // Trigger callback
553
+ if (this.options.onCropMove !== null) {
554
+ this.options.onCropMove(this.getValue());
555
+ }
556
+ }
557
+
558
+ /**
559
+ * EVENT HANDLER
560
+ * Executes on handle move end.
561
+ */
562
+ onHandleMoveEnd(e: any) {
563
+ // Trigger callback
564
+ if (this.options.onCropEnd !== null) {
565
+ this.options.onCropEnd(this.getValue());
566
+ }
567
+ }
568
+
569
+ /**
570
+ * EVENT HANDLER
571
+ * Executes when user starts moving the crop region.
572
+ */
573
+ onRegionMoveStart(e: any) {
574
+ let { mouseX, mouseY } = e.detail;
575
+
576
+ // Calculate mouse's position in relative to the container
577
+ let container = this.cropperEl.getBoundingClientRect();
578
+ mouseX = mouseX - container.left;
579
+ mouseY = mouseY - container.top;
580
+
581
+ this.currentMove = {
582
+ offsetX: mouseX - this.box.x1,
583
+ offsetY: mouseY - this.box.y1,
584
+ };
585
+
586
+ // Trigger callback
587
+ if (this.options.onCropStart !== null) {
588
+ this.options.onCropStart(this.getValue());
589
+ }
590
+ }
591
+
592
+ /**
593
+ * EVENT HANDLER
594
+ * Executes when user moves the crop region.
595
+ */
596
+ onRegionMoveMoving(e: any) {
597
+ let { mouseX, mouseY } = e.detail;
598
+ let { offsetX, offsetY } = this.currentMove;
599
+
600
+ // Calculate mouse's position in relative to the container
601
+ let container = this.cropperEl.getBoundingClientRect();
602
+ mouseX = mouseX - container.left;
603
+ mouseY = mouseY - container.top;
604
+
605
+ this.box.move(mouseX - offsetX, mouseY - offsetY);
606
+
607
+ // Ensure box is within the boundaries
608
+ if (this.box.x1 < 0) {
609
+ this.box.move(0, null);
610
+ }
611
+ if (this.box.x2 > container.width) {
612
+ this.box.move(container.width - this.box.width(), null);
613
+ }
614
+ if (this.box.y1 < 0) {
615
+ this.box.move(null, 0);
616
+ }
617
+ if (this.box.y2 > container.height) {
618
+ this.box.move(null, container.height - this.box.height());
619
+ }
620
+
621
+ // Update visuals
622
+ this.redraw();
623
+
624
+ // Trigger callback
625
+ if (this.options.onCropMove !== null) {
626
+ this.options.onCropMove(this.getValue());
627
+ }
628
+ }
629
+
630
+ /**
631
+ * EVENT HANDLER
632
+ * Executes when user stops moving the crop region (mouse up).
633
+ */
634
+ onRegionMoveEnd(e: any) {
635
+ // Trigger callback
636
+ if (this.options.onCropEnd !== null) {
637
+ this.options.onCropEnd(this.getValue());
638
+ }
639
+ }
640
+
641
+ /**
642
+ * Calculate the value of the crop region.
643
+ */
644
+ getValue(mode = null) {
645
+ if (mode === null) {
646
+ mode = this.options.returnMode;
647
+ }
648
+ if (mode == "real") {
649
+ const actualWidth = this.imageEl.naturalWidth;
650
+ const actualHeight = this.imageEl.naturalHeight;
651
+ const { width: elementWidth, height: elementHeight } =
652
+ this.imageEl.getBoundingClientRect();
653
+ const factorX = actualWidth / elementWidth;
654
+ const factorY = actualHeight / elementHeight;
655
+ return {
656
+ x: Math.round(this.box.x1 * factorX),
657
+ y: Math.round(this.box.y1 * factorY),
658
+ width: Math.round(this.box.width() * factorX),
659
+ height: Math.round(this.box.height() * factorY),
660
+ };
661
+ } else if (mode == "ratio") {
662
+ const { width: elementWidth, height: elementHeight } =
663
+ this.imageEl.getBoundingClientRect();
664
+ return {
665
+ x: round(this.box.x1 / elementWidth, 3),
666
+ y: round(this.box.y1 / elementHeight, 3),
667
+ width: round(this.box.width() / elementWidth, 3),
668
+ height: round(this.box.height() / elementHeight, 3),
669
+ };
670
+ } else if (mode == "raw") {
671
+ return {
672
+ x: Math.round(this.box.x1),
673
+ y: Math.round(this.box.y1),
674
+ width: Math.round(this.box.width()),
675
+ height: Math.round(this.box.height()),
676
+ };
677
+ }
678
+ }
679
+
680
+ /**
681
+ * Parse user options and set default values.
682
+ */
683
+ static parseOptions(opts: any) {
684
+ const defaults = {
685
+ aspectRatio: null,
686
+ maxSize: { width: null, height: null },
687
+ minSize: { width: null, height: null },
688
+ startSize: { width: 100, height: 100, unit: "%" },
689
+ returnMode: "real",
690
+ onInitialize: null,
691
+ onCropStart: null,
692
+ onCropMove: null,
693
+ onCropEnd: null,
694
+ };
695
+
696
+ // Parse aspect ratio
697
+ let aspectRatio = null;
698
+ if (opts.aspectRatio !== undefined) {
699
+ if (typeof opts.aspectRatio === "number") {
700
+ aspectRatio = opts.aspectRatio;
701
+ } else if (opts.aspectRatio instanceof Array) {
702
+ aspectRatio = opts.aspectRatio[1] / opts.aspectRatio[0];
703
+ }
704
+ }
705
+
706
+ // Parse max width/height
707
+ let maxSize = null;
708
+ if (opts.maxSize !== undefined && opts.maxSize !== null) {
709
+ maxSize = {
710
+ width: opts.maxSize[0] || null,
711
+ height: opts.maxSize[1] || null,
712
+ unit: opts.maxSize[2] || "px",
713
+ };
714
+ }
715
+
716
+ // Parse min width/height
717
+ let minSize = null;
718
+ if (opts.minSize !== undefined && opts.minSize !== null) {
719
+ minSize = {
720
+ width: opts.minSize[0] || null,
721
+ height: opts.minSize[1] || null,
722
+ unit: opts.minSize[2] || "px",
723
+ };
724
+ }
725
+
726
+ // Parse start size
727
+ let startSize = null;
728
+ if (opts.startSize !== undefined && opts.startSize !== null) {
729
+ startSize = {
730
+ width: opts.startSize[0] || null,
731
+ height: opts.startSize[1] || null,
732
+ unit: opts.startSize[2] || "%",
733
+ };
734
+ }
735
+
736
+ // Parse callbacks
737
+ let onInitialize = null;
738
+ if (typeof opts.onInitialize === "function") {
739
+ onInitialize = opts.onInitialize;
740
+ }
741
+
742
+ let onCropStart = null;
743
+ if (typeof opts.onCropStart === "function") {
744
+ onCropStart = opts.onCropStart;
745
+ }
746
+
747
+ let onCropEnd = null;
748
+ if (typeof opts.onCropEnd === "function") {
749
+ onCropEnd = opts.onCropEnd;
750
+ }
751
+
752
+ let onCropMove = null;
753
+ if (typeof opts.onUpdate === "function") {
754
+ // DEPRECATED: onUpdate is deprecated to create a more uniform
755
+ // callback API, such as: onCropStart, onCropMove, onCropEnd
756
+ console.warn(
757
+ "Croppr.js: `onUpdate` is deprecated and will be removed in the next major release. Please use `onCropMove` or `onCropEnd` instead."
758
+ );
759
+ onCropMove = opts.onUpdate;
760
+ }
761
+ if (typeof opts.onCropMove === "function") {
762
+ onCropMove = opts.onCropMove;
763
+ }
764
+
765
+ // Parse returnMode value
766
+ let returnMode = null;
767
+ if (opts.returnMode !== undefined) {
768
+ const s = opts.returnMode.toLowerCase();
769
+ if (["real", "ratio", "raw"].indexOf(s) === -1) {
770
+ throw "Invalid return mode.";
771
+ }
772
+ returnMode = s;
773
+ }
774
+
775
+ // Create function to convert % values to pixels
776
+ const convertToPixels = function (this: any, container: any) {
777
+ const width = container.offsetWidth;
778
+ const height = container.offsetHeight;
779
+
780
+ // Convert sizes
781
+ const sizeKeys = ["maxSize", "minSize", "startSize"];
782
+ for (let i = 0; i < sizeKeys.length; i++) {
783
+ const key = sizeKeys[i];
784
+ if (this[key] !== null) {
785
+ if (this[key].unit == "%") {
786
+ if (this[key].width !== null) {
787
+ this[key].width = (this[key].width / 100) * width;
788
+ }
789
+ if (this[key].height !== null) {
790
+ this[key].height = (this[key].height / 100) * height;
791
+ }
792
+ }
793
+ delete this[key].unit;
794
+ }
795
+ }
796
+ };
797
+
798
+ const defaultValue = (v: any, d: any) => (v !== null ? v : d);
799
+ return {
800
+ aspectRatio: defaultValue(aspectRatio, defaults.aspectRatio),
801
+ maxSize: defaultValue(maxSize, defaults.maxSize),
802
+ minSize: defaultValue(minSize, defaults.minSize),
803
+ startSize: defaultValue(startSize, defaults.startSize),
804
+ returnMode: defaultValue(returnMode, defaults.returnMode),
805
+ onInitialize: defaultValue(onInitialize, defaults.onInitialize),
806
+ onCropStart: defaultValue(onCropStart, defaults.onCropStart),
807
+ onCropMove: defaultValue(onCropMove, defaults.onCropMove),
808
+ onCropEnd: defaultValue(onCropEnd, defaults.onCropEnd),
809
+ convertToPixels: convertToPixels,
810
+ };
811
+ }
812
+ }
813
+
814
+ /**
815
+ * HELPER FUNCTIONS
816
+ */
817
+
818
+ function round(value: any, decimals: any) {
819
+ return Number(Math.round((value + "e" + decimals) as any) + "e-" + decimals);
820
+ }