@kaspernj/api-maker 1.0.2011 → 1.0.2013

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 (413) hide show
  1. package/{.eslintrc.cjs → .eslintrc.js} +10 -1
  2. package/README.md +35 -0
  3. package/android/build.gradle +43 -0
  4. package/android/src/main/AndroidManifest.xml +2 -0
  5. package/android/src/main/java/expo/modules/api_maker/ApiMakerModule.kt +50 -0
  6. package/android/src/main/java/expo/modules/api_maker/ApiMakerView.kt +30 -0
  7. package/build/api.js +120 -0
  8. package/build/attribute-not-loaded-error.js +2 -0
  9. package/build/base-component.js +5 -0
  10. package/build/base-error.js +33 -0
  11. package/build/base-model/attribute.js +25 -0
  12. package/build/base-model/column.js +11 -0
  13. package/build/base-model/reflection.js +14 -0
  14. package/build/base-model/scope.js +11 -0
  15. package/build/base-model.js +828 -0
  16. package/build/bootstrap/attribute-row.js +135 -0
  17. package/build/bootstrap/attribute-rows.js +31 -0
  18. package/build/bootstrap/card.js +138 -0
  19. package/build/bootstrap/checkbox.js +97 -0
  20. package/build/bootstrap/checkboxes.js +183 -0
  21. package/build/bootstrap/index.js +2 -0
  22. package/build/bootstrap/input.js +129 -0
  23. package/build/bootstrap/invalid-feedback.js +27 -0
  24. package/build/bootstrap/paginate.js +150 -0
  25. package/build/bootstrap/radio-buttons.js +72 -0
  26. package/build/bootstrap/select.js +88 -0
  27. package/build/bootstrap/sort-link.js +131 -0
  28. package/build/cable-connection-pool.js +128 -0
  29. package/build/cable-subscription-pool.js +207 -0
  30. package/build/cable-subscription.js +21 -0
  31. package/build/cache-key-generator.js +81 -0
  32. package/build/can-can.js +134 -0
  33. package/build/channels-consumer.js +9 -0
  34. package/build/collection-loader.js +48 -0
  35. package/build/collection.js +280 -0
  36. package/build/command-submit-data.js +81 -0
  37. package/build/commands-pool.js +195 -0
  38. package/build/compose.js +9 -0
  39. package/build/config.js +62 -0
  40. package/build/custom-error.js +5 -0
  41. package/build/data-set-to-attributes.js +10 -0
  42. package/build/deserializer.js +56 -0
  43. package/build/destroy-error.js +5 -0
  44. package/build/devise.js +112 -0
  45. package/build/draggable-sort/controller.js +136 -0
  46. package/build/draggable-sort/index.js +114 -0
  47. package/build/draggable-sort/item.js +188 -0
  48. package/build/error-logger.js +101 -0
  49. package/build/error-messages.js +13 -0
  50. package/build/event-connection.js +32 -0
  51. package/build/event-emitter-listener.js +15 -0
  52. package/build/event-model-class.js +24 -0
  53. package/build/events.js +5 -0
  54. package/build/flash-message.js +79 -0
  55. package/build/form.js +83 -0
  56. package/build/history-expo.js +20 -0
  57. package/build/history-react-native.js +20 -0
  58. package/build/history.js +3 -0
  59. package/build/index.js +3 -0
  60. package/build/inputs/attachment.js +133 -0
  61. package/build/inputs/auto-submit.js +36 -0
  62. package/build/inputs/checkbox.js +138 -0
  63. package/build/inputs/checkboxes.js +112 -0
  64. package/build/inputs/id-for-component.js +15 -0
  65. package/build/inputs/input-wrapper.js +19 -0
  66. package/build/inputs/input.js +243 -0
  67. package/build/inputs/money.js +179 -0
  68. package/build/inputs/name-for-component.js +13 -0
  69. package/build/inputs/select.js +93 -0
  70. package/build/instance-of-class-name.js +23 -0
  71. package/build/is-expo.js +22 -0
  72. package/build/key-value-store.js +53 -0
  73. package/build/link.js +73 -0
  74. package/build/logger.js +30 -0
  75. package/build/modal.js +38 -0
  76. package/build/model-class-require.js +13 -0
  77. package/build/model-events.js +30 -0
  78. package/build/model-name.js +28 -0
  79. package/build/model-prop-type.js +101 -0
  80. package/build/model-recipes-loader.js +32 -0
  81. package/build/model-recipes-model-loader.js +357 -0
  82. package/build/models-response-reader.js +40 -0
  83. package/build/models.js +8 -0
  84. package/build/money-formatter.js +78 -0
  85. package/build/not-loaded-error.js +2 -0
  86. package/build/params.js +61 -0
  87. package/build/preloaded.js +38 -0
  88. package/build/resize-observer.js +11 -0
  89. package/build/result.js +13 -0
  90. package/build/router/route.js +270 -0
  91. package/build/router/switch.js +72 -0
  92. package/build/router.js +59 -0
  93. package/build/routes-native.js +202 -0
  94. package/build/routes.js +50 -0
  95. package/build/run-last.js +35 -0
  96. package/build/serializer.js +63 -0
  97. package/build/services.js +20 -0
  98. package/build/session-status-updater.js +134 -0
  99. package/build/source-maps-loader.js +184 -0
  100. package/build/super-admin/config-reader.js +85 -0
  101. package/build/super-admin/edit-page/edit-attribute-checkbox.js +85 -0
  102. package/build/super-admin/edit-page/edit-attribute-content.js +55 -0
  103. package/build/super-admin/edit-page/edit-attribute-input.js +79 -0
  104. package/build/super-admin/edit-page/edit-attribute.js +77 -0
  105. package/build/super-admin/edit-page.js +123 -0
  106. package/build/super-admin/has-edit-config.js +12 -0
  107. package/build/super-admin/index-page.js +25 -0
  108. package/build/super-admin/index.js +181 -0
  109. package/build/super-admin/layout/header/index.js +161 -0
  110. package/build/super-admin/layout/index.js +164 -0
  111. package/build/super-admin/layout/menu/index.js +206 -0
  112. package/build/super-admin/layout/menu/menu-content.js +46 -0
  113. package/build/super-admin/layout/menu/menu-item.js +84 -0
  114. package/build/super-admin/layout/no-access.js +27 -0
  115. package/build/super-admin/model-class-table.js +61 -0
  116. package/build/super-admin/models.js +8 -0
  117. package/build/super-admin/show-nav.js +51 -0
  118. package/build/super-admin/show-page/belongs-to-attribute-row.js +29 -0
  119. package/build/super-admin/show-page/index.js +141 -0
  120. package/build/super-admin/show-reflection-actions.js +47 -0
  121. package/build/super-admin/show-reflection-link.js +48 -0
  122. package/build/super-admin/show-reflection-page.js +48 -0
  123. package/build/table/column-content.js +117 -0
  124. package/build/table/column-identifier.js +18 -0
  125. package/build/table/column-visible.js +7 -0
  126. package/build/table/components/column.js +21 -0
  127. package/build/table/components/flat-list.js +21 -0
  128. package/build/table/components/header.js +26 -0
  129. package/build/table/components/row.js +26 -0
  130. package/build/table/filters/attribute-element.js +44 -0
  131. package/build/table/filters/filter-form.js +402 -0
  132. package/build/table/filters/filter.js +90 -0
  133. package/build/table/filters/index.js +184 -0
  134. package/build/table/filters/load-search-modal.js +175 -0
  135. package/build/table/filters/reflection-element.js +37 -0
  136. package/build/table/filters/save-search-modal.js +88 -0
  137. package/build/table/filters/scope-element.js +42 -0
  138. package/build/table/header-column-content.js +68 -0
  139. package/build/table/header-column.js +144 -0
  140. package/build/table/header-select.js +105 -0
  141. package/build/table/model-callback-args.js +10 -0
  142. package/build/table/model-column.js +97 -0
  143. package/build/table/model-row.js +193 -0
  144. package/build/table/select-calculator.js +63 -0
  145. package/build/table/settings/column-row.js +97 -0
  146. package/build/table/settings/download-action.js +79 -0
  147. package/build/table/settings/index.js +92 -0
  148. package/build/table/table-settings.js +219 -0
  149. package/build/table/table.js +972 -0
  150. package/build/table/use-sorting.js +34 -0
  151. package/build/table/widths.js +75 -0
  152. package/build/table/worker-plugins-check-all-checkbox.js +125 -0
  153. package/build/table/worker-plugins-checkbox.js +115 -0
  154. package/build/translated-attributes.js +10 -0
  155. package/build/translated-collections.js +12 -0
  156. package/build/updated-attribute.js +76 -0
  157. package/build/url-encode.js +15 -0
  158. package/build/use-breakpoint.js +71 -0
  159. package/build/use-can-can.js +55 -0
  160. package/build/use-collection.js +225 -0
  161. package/build/use-created-event.js +52 -0
  162. package/build/use-current-user.js +76 -0
  163. package/build/use-destroyed-event.js +60 -0
  164. package/build/use-event-emitter.js +13 -0
  165. package/build/use-event-listener.js +16 -0
  166. package/build/use-input.js +137 -0
  167. package/build/use-model-event.js +60 -0
  168. package/build/use-model.js +169 -0
  169. package/build/use-resize-observer.js +23 -0
  170. package/build/use-router.js +104 -0
  171. package/build/use-screen-layout.js +39 -0
  172. package/build/use-styles.js +41 -0
  173. package/build/use-updated-event.js +60 -0
  174. package/build/use-validation-errors.js +30 -0
  175. package/build/utils/card.js +51 -0
  176. package/build/utils/checkbox.js +78 -0
  177. package/build/utils/checkboxes.js +163 -0
  178. package/build/utils/default-style.js +18 -0
  179. package/build/utils/icon.js +23 -0
  180. package/build/utils/invalid-feedback.js +19 -0
  181. package/build/utils/modal.js +62 -0
  182. package/build/utils/text.js +44 -0
  183. package/build/validation-error.js +28 -0
  184. package/build/validation-errors.js +98 -0
  185. package/build/with-api-maker.js +29 -0
  186. package/build/with-collection.js +14 -0
  187. package/build/with-current-user.js +10 -0
  188. package/build/with-model.js +15 -0
  189. package/build/with-router.js +22 -0
  190. package/expo-module.config.json +17 -0
  191. package/ios/ApiMaker.podspec +29 -0
  192. package/ios/ApiMakerModule.swift +48 -0
  193. package/ios/ApiMakerView.swift +38 -0
  194. package/package.json +49 -46
  195. package/src/{api.mjs → api.js} +38 -37
  196. package/src/base-component.jsx +5 -0
  197. package/src/{base-error.mjs → base-error.js} +4 -6
  198. package/src/base-model/attribute.js +33 -0
  199. package/src/base-model/column.js +13 -0
  200. package/src/base-model/reflection.js +15 -0
  201. package/src/base-model/scope.js +12 -0
  202. package/src/{base-model.mjs → base-model.js} +302 -144
  203. package/src/bootstrap/attribute-row.jsx +135 -0
  204. package/src/bootstrap/attribute-rows.jsx +27 -0
  205. package/src/bootstrap/card.jsx +149 -0
  206. package/src/bootstrap/checkbox.jsx +86 -0
  207. package/src/bootstrap/checkboxes.jsx +185 -0
  208. package/src/bootstrap/index.js +0 -0
  209. package/src/bootstrap/input.jsx +173 -0
  210. package/src/bootstrap/invalid-feedback.jsx +31 -0
  211. package/src/bootstrap/paginate.jsx +187 -0
  212. package/src/bootstrap/radio-buttons.jsx +87 -0
  213. package/src/bootstrap/select.jsx +110 -0
  214. package/src/bootstrap/sort-link.jsx +106 -0
  215. package/src/{cable-connection-pool.mjs → cable-connection-pool.js} +16 -36
  216. package/src/{cable-subscription-pool.mjs → cable-subscription-pool.js} +26 -21
  217. package/src/{cable-subscription.mjs → cable-subscription.js} +6 -4
  218. package/src/cache-key-generator.js +100 -0
  219. package/src/{can-can.mjs → can-can.js} +13 -12
  220. package/src/channels-consumer.js +10 -0
  221. package/src/collection-loader.jsx +58 -224
  222. package/src/{collection.mjs → collection.js} +98 -44
  223. package/src/{command-submit-data.mjs → command-submit-data.js} +2 -7
  224. package/src/{commands-pool.mjs → commands-pool.js} +57 -41
  225. package/src/compose.js +11 -0
  226. package/src/{config.mjs → config.js} +6 -2
  227. package/src/{custom-error.mjs → custom-error.js} +1 -1
  228. package/src/data-set-to-attributes.js +13 -0
  229. package/src/{deserializer.mjs → deserializer.js} +3 -3
  230. package/src/destroy-error.js +7 -0
  231. package/src/devise.js +129 -0
  232. package/src/draggable-sort/controller.js +137 -0
  233. package/src/draggable-sort/index.jsx +108 -0
  234. package/src/draggable-sort/item.jsx +174 -0
  235. package/src/{error-logger.mjs → error-logger.js} +12 -7
  236. package/src/{error-messages.mjs → error-messages.js} +1 -0
  237. package/src/event-connection.jsx +1 -1
  238. package/src/event-emitter-listener.jsx +8 -27
  239. package/src/event-model-class.jsx +2 -4
  240. package/src/events.js +7 -0
  241. package/src/flash-message.js +70 -0
  242. package/src/form.jsx +91 -0
  243. package/src/history-expo.js +23 -0
  244. package/src/history-react-native.js +25 -0
  245. package/src/history.js +3 -0
  246. package/src/index.js +3 -0
  247. package/src/inputs/attachment.jsx +108 -0
  248. package/src/inputs/auto-submit.js +37 -0
  249. package/src/inputs/checkbox.jsx +125 -0
  250. package/src/inputs/checkboxes.jsx +116 -0
  251. package/src/inputs/id-for-component.js +15 -0
  252. package/src/inputs/input-wrapper.jsx +16 -0
  253. package/src/inputs/input.jsx +260 -0
  254. package/src/inputs/money.jsx +187 -0
  255. package/src/inputs/name-for-component.js +15 -0
  256. package/src/inputs/select.jsx +104 -0
  257. package/src/is-expo.js +18 -0
  258. package/src/{key-value-store.mjs → key-value-store.js} +1 -1
  259. package/src/link.jsx +54 -9
  260. package/src/logger.js +38 -0
  261. package/src/modal.jsx +37 -0
  262. package/src/model-class-require.js +17 -0
  263. package/src/{model-events.mjs → model-events.js} +1 -1
  264. package/src/{model-name.mjs → model-name.js} +8 -8
  265. package/src/{model-recipes-loader.mjs → model-recipes-loader.js} +1 -1
  266. package/src/{model-recipes-model-loader.mjs → model-recipes-model-loader.js} +5 -5
  267. package/src/{models-response-reader.mjs → models-response-reader.js} +3 -4
  268. package/src/models.js +7 -0
  269. package/src/{models.mjs.erb → models.js.erb} +6 -3
  270. package/src/{money-formatter.mjs → money-formatter.js} +5 -4
  271. package/src/{params.mjs → params.js} +17 -7
  272. package/src/{preloaded.mjs → preloaded.js} +2 -2
  273. package/src/resize-observer.jsx +10 -0
  274. package/src/result.js +13 -0
  275. package/src/router/route.jsx +246 -0
  276. package/src/router/switch.jsx +76 -0
  277. package/src/router.jsx +23 -21
  278. package/src/{routes-native.mjs → routes-native.js} +12 -6
  279. package/src/{routes.mjs → routes.js} +1 -1
  280. package/src/run-last.js +39 -0
  281. package/src/{serializer.mjs → serializer.js} +2 -2
  282. package/src/{services.mjs → services.js} +1 -1
  283. package/src/session-status-updater.js +172 -0
  284. package/src/{source-maps-loader.mjs → source-maps-loader.js} +54 -28
  285. package/src/super-admin/config-reader.jsx +93 -0
  286. package/src/super-admin/edit-page/edit-attribute-checkbox.jsx +81 -0
  287. package/src/super-admin/edit-page/edit-attribute-content.jsx +57 -0
  288. package/src/super-admin/edit-page/edit-attribute-input.jsx +71 -0
  289. package/src/super-admin/edit-page/edit-attribute.jsx +81 -0
  290. package/src/super-admin/edit-page.jsx +117 -0
  291. package/src/super-admin/has-edit-config.js +15 -0
  292. package/src/super-admin/index-page.jsx +23 -0
  293. package/src/super-admin/index.jsx +197 -0
  294. package/src/super-admin/layout/header/index.jsx +144 -0
  295. package/src/super-admin/layout/header/style.scss +45 -0
  296. package/src/super-admin/layout/index.jsx +154 -0
  297. package/src/super-admin/layout/menu/index.jsx +171 -0
  298. package/src/super-admin/layout/menu/menu-content.jsx +43 -0
  299. package/src/super-admin/layout/menu/menu-item.jsx +70 -0
  300. package/src/super-admin/layout/menu/style.scss +11 -0
  301. package/src/super-admin/layout/no-access.jsx +26 -0
  302. package/src/super-admin/model-class-table.jsx +66 -0
  303. package/src/super-admin/models.js +11 -0
  304. package/src/super-admin/show-nav.jsx +44 -0
  305. package/src/super-admin/show-page/belongs-to-attribute-row.jsx +30 -0
  306. package/src/super-admin/show-page/index.jsx +141 -0
  307. package/src/super-admin/show-reflection-actions.jsx +49 -0
  308. package/src/super-admin/show-reflection-link.jsx +40 -0
  309. package/src/super-admin/show-reflection-page.jsx +47 -0
  310. package/src/super-admin/stylesheets/variables.scss +11 -0
  311. package/src/table/column-content.jsx +122 -0
  312. package/src/table/column-identifier.js +23 -0
  313. package/src/table/column-visible.js +7 -0
  314. package/src/table/components/column.jsx +19 -0
  315. package/src/table/components/flat-list.jsx +19 -0
  316. package/src/table/components/header.jsx +21 -0
  317. package/src/table/components/row.jsx +23 -0
  318. package/src/table/filters/attribute-element.jsx +47 -0
  319. package/src/table/filters/filter-form.jsx +407 -0
  320. package/src/table/filters/filter.jsx +70 -0
  321. package/src/table/filters/index.jsx +170 -0
  322. package/src/table/filters/load-search-modal.jsx +146 -0
  323. package/src/table/filters/reflection-element.jsx +38 -0
  324. package/src/table/filters/save-search-modal.jsx +74 -0
  325. package/src/table/filters/scope-element.jsx +44 -0
  326. package/src/table/header-column-content.jsx +55 -0
  327. package/src/table/header-column.jsx +129 -0
  328. package/src/table/header-select.jsx +73 -0
  329. package/src/table/model-callback-args.js +10 -0
  330. package/src/table/model-column.jsx +82 -0
  331. package/src/table/model-row.jsx +136 -0
  332. package/src/table/select-calculator.js +65 -0
  333. package/src/table/settings/column-row.jsx +93 -0
  334. package/src/table/settings/download-action.jsx +68 -0
  335. package/src/table/settings/index.jsx +65 -0
  336. package/src/table/table-settings.js +263 -0
  337. package/src/table/table.jsx +950 -0
  338. package/src/table/use-sorting.js +35 -0
  339. package/src/table/variables.scss +11 -0
  340. package/src/table/widths.jsx +87 -0
  341. package/src/table/worker-plugins-check-all-checkbox.jsx +112 -0
  342. package/src/table/worker-plugins-checkbox.jsx +104 -0
  343. package/src/translated-attributes.js +11 -0
  344. package/src/{translated-collections.mjs → translated-collections.js} +3 -2
  345. package/src/updated-attribute.jsx +1 -1
  346. package/src/url-encode.js +18 -0
  347. package/src/use-breakpoint.js +87 -0
  348. package/src/use-can-can.js +55 -0
  349. package/src/use-collection.js +280 -0
  350. package/src/use-created-event.js +55 -0
  351. package/src/use-current-user.js +88 -0
  352. package/src/use-destroyed-event.js +60 -0
  353. package/src/use-event-emitter.js +15 -0
  354. package/src/use-event-listener.js +19 -0
  355. package/src/use-input.js +157 -0
  356. package/src/use-model-event.js +60 -0
  357. package/src/use-model.js +189 -0
  358. package/src/use-resize-observer.js +24 -0
  359. package/src/use-router.jsx +128 -0
  360. package/src/use-screen-layout.js +49 -0
  361. package/src/use-styles.js +50 -0
  362. package/src/use-updated-event.js +60 -0
  363. package/src/use-validation-errors.js +33 -0
  364. package/src/utils/card.jsx +49 -0
  365. package/src/utils/checkbox.jsx +80 -0
  366. package/src/utils/checkboxes.jsx +158 -0
  367. package/src/utils/default-style.jsx +25 -0
  368. package/src/utils/icon.jsx +21 -0
  369. package/src/utils/invalid-feedback.jsx +20 -0
  370. package/src/utils/modal.jsx +60 -0
  371. package/src/utils/text.jsx +38 -0
  372. package/src/{validation-error.mjs → validation-error.js} +9 -5
  373. package/src/{validation-errors.mjs → validation-errors.js} +15 -27
  374. package/src/with-api-maker.jsx +31 -0
  375. package/src/with-collection.jsx +17 -0
  376. package/src/with-current-user.jsx +7 -25
  377. package/src/with-model.jsx +16 -0
  378. package/src/with-router.jsx +7 -129
  379. package/__tests__/base-model.test.js +0 -71
  380. package/__tests__/cable-connection-pool.test.js +0 -227
  381. package/__tests__/cable-subscription-pool.test.js +0 -26
  382. package/__tests__/can-can.test.js +0 -34
  383. package/__tests__/collection.test.js +0 -51
  384. package/__tests__/custom-error.test.js +0 -13
  385. package/__tests__/model-name.test.js +0 -34
  386. package/__tests__/model-prop-type.test.js +0 -113
  387. package/__tests__/params.test.js +0 -40
  388. package/__tests__/routes-native.test.js +0 -103
  389. package/__tests__/routes.test.js +0 -46
  390. package/__tests__/serializer.test.js +0 -30
  391. package/__tests__/support/task.js +0 -27
  392. package/__tests__/support/user.js +0 -32
  393. package/index.js +0 -1
  394. package/jest.config.js +0 -4
  395. package/src/can-can-loader.jsx +0 -54
  396. package/src/channels-consumer.mjs +0 -3
  397. package/src/destroy-error.mjs +0 -7
  398. package/src/devise.mjs +0 -122
  399. package/src/event-created.jsx +0 -65
  400. package/src/event-destroyed.jsx +0 -29
  401. package/src/event-listener.jsx +0 -38
  402. package/src/event-updated.jsx +0 -74
  403. package/src/logger.mjs +0 -25
  404. package/src/model-class-require.mjs +0 -10
  405. package/src/model-load-wrapper.jsx +0 -116
  406. package/src/result.mjs +0 -29
  407. package/src/session-status-updater.mjs +0 -116
  408. package/webpack.config.js +0 -15
  409. /package/src/{attribute-not-loaded-error.mjs → attribute-not-loaded-error.js} +0 -0
  410. /package/src/{instance-of-class-name.mjs → instance-of-class-name.js} +0 -0
  411. /package/src/{model-prop-type.mjs → model-prop-type.js} +0 -0
  412. /package/src/{not-loaded-error.mjs → not-loaded-error.js} +0 -0
  413. /package/src/{translated-collections-data.mjs.erb → translated-collections-data.js.erb} +0 -0
@@ -0,0 +1,73 @@
1
+ import {Pressable, View} from "react-native"
2
+ import BaseComponent from "../base-component"
3
+ import Collection from "../collection"
4
+ import HeaderColumnContent from "./header-column-content"
5
+ import memo from "set-state-compare/src/memo"
6
+ import Modal from "../utils/modal"
7
+ import PropTypes from "prop-types"
8
+ import propTypesExact from "prop-types-exact"
9
+ import React from "react"
10
+ import {shapeComponent} from "set-state-compare/src/shape-component"
11
+ import Text from "../utils/text"
12
+ import useI18n from "i18n-on-steroids/src/use-i18n"
13
+ import useSorting from "./use-sorting"
14
+
15
+ export default memo(shapeComponent(class ApiMakerTableHeaderSelect extends BaseComponent {
16
+ static propTypes = propTypesExact({
17
+ preparedColumns: PropTypes.array.isRequired,
18
+ query: PropTypes.instanceOf(Collection).isRequired,
19
+ table: PropTypes.object
20
+ })
21
+
22
+ setup() {
23
+ const {t} = useI18n({namespace: "js.api_maker.table.header_select"})
24
+ const {preparedColumns, query} = this.p
25
+ const {qParams, searchKey, sortAttribute, sortMode} = useSorting({query})
26
+
27
+ this.useStates({
28
+ modalOpen: false
29
+ })
30
+ this.setInstance({qParams, searchKey, sortAttribute, sortMode, t})
31
+ this.sortedByPreparedColumn = preparedColumns.find((preparedColumn) => preparedColumn.tableSettingColumn.sortKey() == sortAttribute)
32
+ }
33
+
34
+ render() {
35
+ const {sortedByPreparedColumn, sortMode, t} = this.tt
36
+ const {table} = this.p
37
+ const column = sortedByPreparedColumn?.column
38
+ const columnLabel = column && table.headerLabelForColumn(column)
39
+
40
+ return (
41
+ <View dataSet={{component: "api-maker/table/header-select"}}>
42
+ {this.s.modalOpen &&
43
+ <Modal dataSet={{class: "table-header-select-modal"}} onRequestClose={this.tt.onModalRequestClose} transparent>
44
+ {this.p.preparedColumns.map(({column, tableSettingColumn}) =>
45
+ <View
46
+ key={tableSettingColumn.identifier()}
47
+ style={{marginVertical: 5}}
48
+ >
49
+ <HeaderColumnContent column={column} table={table} tableSettingColumn={tableSettingColumn} sortLinkProps={{usePressable: true}} />
50
+ </View>
51
+ )}
52
+ </Modal>
53
+ }
54
+ <Pressable onPress={this.tt.onSortedByPress}>
55
+ <Text>
56
+ {sortedByPreparedColumn && sortMode == "asc" &&
57
+ t(".sorted_by_column", {column: columnLabel, defaultValue: "Sorted by %{column}"})
58
+ }
59
+ {sortedByPreparedColumn && sortMode == "desc" &&
60
+ t(".sorted_by_column_reversed", {column: columnLabel, defaultValue: "Sorted by %{column} reversed"})
61
+ }
62
+ {!sortedByPreparedColumn &&
63
+ t(".not_sorted", {defaultValue: "Not sorted"})
64
+ }
65
+ </Text>
66
+ </Pressable>
67
+ </View>
68
+ )
69
+ }
70
+
71
+ onModalRequestClose = () => this.setState({modalOpen: false})
72
+ onSortedByPress = () => this.setState({modalOpen: true})
73
+ }))
@@ -0,0 +1,10 @@
1
+ import * as inflection from "inflection"
2
+
3
+ export default function modelCallbackArgs(table, model) {
4
+ const modelArgName = inflection.camelize(table.props.modelClass.modelClassData().name, true)
5
+ const modelCallbackArgs = {model}
6
+
7
+ modelCallbackArgs[modelArgName] = model
8
+
9
+ return modelCallbackArgs
10
+ }
@@ -0,0 +1,82 @@
1
+ import {Animated, View} from "react-native"
2
+ import BaseComponent from "../base-component"
3
+ import classNames from "classnames"
4
+ import Column from "./components/column"
5
+ import ColumnContent from "./column-content"
6
+ import columnIdentifier from "./column-identifier"
7
+ import EventEmitter from "events"
8
+ import PropTypes from "prop-types"
9
+ import propTypesExact from "prop-types-exact"
10
+ import memo from "set-state-compare/src/memo"
11
+ import React from "react"
12
+ import {shapeComponent} from "set-state-compare/src/shape-component"
13
+ import Text from "../utils/text"
14
+ import useBreakpoint from "../use-breakpoint"
15
+ import useI18n from "i18n-on-steroids/src/use-i18n"
16
+
17
+ export default memo(shapeComponent(class ApiMakerTableModelColumn extends BaseComponent {
18
+ static propTypes = propTypesExact({
19
+ animatedPosition: PropTypes.instanceOf(Animated.ValueXY).isRequired,
20
+ animatedWidth: PropTypes.instanceOf(Animated.Value).isRequired,
21
+ animatedZIndex: PropTypes.instanceOf(Animated.Value).isRequired,
22
+ column: PropTypes.object.isRequired,
23
+ columnIndex: PropTypes.number.isRequired,
24
+ even: PropTypes.bool.isRequired,
25
+ events: PropTypes.instanceOf(EventEmitter).isRequired,
26
+ model: PropTypes.object.isRequired,
27
+ table: PropTypes.object.isRequired,
28
+ tableSettingColumn: PropTypes.object.isRequired
29
+ })
30
+
31
+ render() {
32
+ const {l, t} = useI18n({namespace: "js.api_maker.table.model_column"})
33
+ const {mdUp} = useBreakpoint()
34
+ const {animatedWidth, animatedZIndex, column, columnIndex, even, model, table} = this.props
35
+ const columnProps = table.columnProps(column)
36
+ const {style, ...restColumnProps} = columnProps
37
+ const actualStyle = Object.assign(
38
+ table.styleForColumn({
39
+ column,
40
+ columnIndex,
41
+ even,
42
+ style: {
43
+ zIndex: animatedZIndex,
44
+ transform: this.p.animatedPosition.getTranslateTransform(),
45
+ width: mdUp ? animatedWidth : "100%"
46
+ }
47
+ }),
48
+ style
49
+ )
50
+
51
+ return (
52
+ <Column
53
+ dataSet={{
54
+ class: classNames(this.columnClassNamesForColumn(column)),
55
+ identifier: columnIdentifier(column)
56
+ }}
57
+ style={actualStyle}
58
+ {...restColumnProps}
59
+ >
60
+ {!mdUp &&
61
+ <View dataSet={{class: "table--column-label"}}>
62
+ <Text style={{fontWeight: "bold"}}>
63
+ {table.headerLabelForColumn(column)}
64
+ </Text>
65
+ </View>
66
+ }
67
+ <View dataSet={{class: "table--column-value"}}>
68
+ {new ColumnContent({column, l, model, t, table}).content()}
69
+ </View>
70
+ </Column>
71
+ )
72
+ }
73
+
74
+ columnClassNamesForColumn(column) {
75
+ const classNames = ["table--column"]
76
+
77
+ if (column.commonProps && column.commonProps.className) classNames.push(column.commonProps.className)
78
+ if (column.columnProps && column.columnProps.className) classNames.push(column.columnProps.className)
79
+
80
+ return classNames
81
+ }
82
+ }))
@@ -0,0 +1,136 @@
1
+ import {Pressable} from "react-native"
2
+ import BaseComponent from "../base-component"
3
+ import Column from "./components/column"
4
+ import columnIdentifier from "./column-identifier"
5
+ import EventEmitter from "events"
6
+ import FlashMessage from "../flash-message"
7
+ import Icon from "../utils/icon"
8
+ import * as inflection from "inflection"
9
+ import modelCallbackArgs from "./model-callback-args"
10
+ import Link from "../link"
11
+ import ModelColumn from "./model-column"
12
+ import PropTypes from "prop-types"
13
+ import propTypesExact from "prop-types-exact"
14
+ import React from "react"
15
+ import Row from "./components/row"
16
+ import memo from "set-state-compare/src/memo"
17
+ import {shapeComponent} from "set-state-compare/src/shape-component"
18
+ import useI18n from "i18n-on-steroids/src/use-i18n"
19
+
20
+ const WorkerPluginsCheckbox = React.lazy(() => import("./worker-plugins-checkbox"))
21
+
22
+ export default memo(shapeComponent(class ApiMakerBootStrapLiveTableModelRow extends BaseComponent {
23
+ static propTypes = propTypesExact({
24
+ cacheKey: PropTypes.string.isRequired,
25
+ columns: PropTypes.array,
26
+ columnWidths: PropTypes.object.isRequired,
27
+ events: PropTypes.instanceOf(EventEmitter).isRequired,
28
+ index: PropTypes.number.isRequired,
29
+ model: PropTypes.object.isRequired,
30
+ table: PropTypes.object.isRequired,
31
+ tableSettingFullCacheKey: PropTypes.string.isRequired
32
+ })
33
+
34
+ setup() {
35
+ const {t} = useI18n({namespace: "js.api_maker.table.model_row"})
36
+
37
+ this.t = t
38
+ }
39
+
40
+ render() {
41
+ const {index, table, model} = this.p
42
+ const {modelClass, workplace} = table.p
43
+ const {actionsContent, destroyEnabled, editModelPath, viewModelPath} = table.props
44
+ const {columns, currentWorkplace} = table.state
45
+ const {styleForColumn, styleForRow} = table.tt
46
+ const even = index % 2 == 0
47
+
48
+ this.modelCallbackArgs = modelCallbackArgs(table, model) // 'model' can change so this needs to be re-cached for every render
49
+
50
+ let editPath, viewPath
51
+
52
+ if (editModelPath && model.can("edit")) {
53
+ editPath = editModelPath(this.modelCallbackArgs)
54
+ }
55
+
56
+ if (viewModelPath && model.can("show")) {
57
+ viewPath = viewModelPath(this.modelCallbackArgs)
58
+ }
59
+
60
+ return (
61
+ <Row
62
+ dataSet={{class: `${inflection.dasherize(modelClass.modelClassData().paramKey)}-row`, modelId: model.id()}}
63
+ style={styleForRow({even})}
64
+ >
65
+ {workplace &&
66
+ <Column dataSet={{class: "workplace-column"}} style={styleForColumn({even, style: {width: 41}})}>
67
+ <WorkerPluginsCheckbox
68
+ currentWorkplace={currentWorkplace}
69
+ model={model}
70
+ style={{marginHorizontal: "auto"}}
71
+ />
72
+ </Column>
73
+ }
74
+ {columns && this.columnsContentFromColumns(model, even)}
75
+ <Column dataSet={{class: "actions-column"}} style={styleForColumn({even, style: {}, type: "actions"})}>
76
+ {actionsContent && actionsContent(this.tt.modelCallbackArgs)}
77
+ {viewPath &&
78
+ <Link dataSet={{class: "view-button"}} style={{marginLeft: 2, marginRight: 2}} to={viewPath}>
79
+ <Icon name="search" size={18} />
80
+ </Link>
81
+ }
82
+ {editPath &&
83
+ <Link dataSet={{class: "edit-button"}} style={{marginLeft: 2, marginRight: 2}} to={editPath}>
84
+ <Icon name="pencil" size={20} />
85
+ </Link>
86
+ }
87
+ {destroyEnabled && model.can("destroy") &&
88
+ <Pressable dataSet={{class: "destroy-button"}} style={{marginLeft: 2, marginRight: 2}} onPress={this.tt.onDestroyClicked}>
89
+ <Icon name="remove" size={22} />
90
+ </Pressable>
91
+ }
92
+ </Column>
93
+ </Row>
94
+ )
95
+ }
96
+
97
+ columnsContentFromColumns(model, even) {
98
+ const {columns, events, table} = this.p
99
+
100
+ return columns?.map(({animatedPosition, animatedWidth, animatedZIndex, column, tableSettingColumn}, columnIndex) =>
101
+ <ModelColumn
102
+ animatedPosition={animatedPosition}
103
+ animatedWidth={animatedWidth}
104
+ animatedZIndex={animatedZIndex}
105
+ column={column}
106
+ columnIndex={columnIndex}
107
+ even={even}
108
+ events={events}
109
+ key={columnIdentifier(column)}
110
+ model={model}
111
+ table={table}
112
+ tableSettingColumn={tableSettingColumn}
113
+ />
114
+ )
115
+ }
116
+
117
+ onDestroyClicked = async () => {
118
+ const {t} = this.tt
119
+ const {destroyMessage} = this.p.table.props
120
+ const {model} = this.p
121
+
122
+ if (!confirm(t("js.shared.are_you_sure"))) {
123
+ return
124
+ }
125
+
126
+ try {
127
+ await model.destroy()
128
+
129
+ if (destroyMessage) {
130
+ FlashMessage.success(destroyMessage)
131
+ }
132
+ } catch (error) {
133
+ FlashMessage.errorResponse(error)
134
+ }
135
+ }
136
+ }))
@@ -0,0 +1,65 @@
1
+ import {digg, digs} from "diggerize"
2
+ import * as inflection from "inflection"
3
+ import modelClassRequire from "../model-class-require"
4
+
5
+ class SelectCalculator {
6
+ constructor({table}) {
7
+ this.table = table
8
+ }
9
+
10
+ selects() {
11
+ const {modelClass} = digs(this.table.props, "modelClass")
12
+ const select = this.table.props.select || {}
13
+ const {preparedColumns} = digs(this.table.state, "preparedColumns")
14
+
15
+
16
+ // Ensure the primary key column is loader for the primary model class
17
+ const className = digg(modelClass.modelClassData(), "name")
18
+ const primaryKeyColumnName = modelClass.primaryKey()
19
+
20
+ if (!(className in select)) select[className] = []
21
+ if (!select[className].includes(primaryKeyColumnName)) select[className].push(primaryKeyColumnName)
22
+
23
+
24
+ // Ensure 'updatedAt' is selected if defined as an attribute, because it is used for cacheKey and updates in the table
25
+ if (modelClass.hasAttribute("updatedAt")) {
26
+ if (!(className in select)) select[className] = []
27
+ if (!select[className].includes("updatedAt")) select[className].push("updatedAt")
28
+ }
29
+
30
+
31
+ // Ensure columns used for columns are loaded
32
+ for (const preparedColumn of preparedColumns) {
33
+ const {column} = digs(preparedColumn, "column")
34
+
35
+ if (!column?.attribute) continue // 'column' might not exist if has been removed in code but still saved in DB
36
+
37
+ const {attribute} = digs(column, "attribute")
38
+ const {path} = column
39
+
40
+ let currentModelClass = modelClass
41
+
42
+ if (path) {
43
+ for (const pathPart of path) {
44
+ const relationships = digg(currentModelClass.modelClassData(), "relationships")
45
+ const relationship = relationships.find((relationshipInArray) => relationshipInArray.name == inflection.underscore(pathPart))
46
+
47
+ if (!relationship) throw new Error(`No such relationship: ${currentModelClass.modelClassData().name}#${pathPart}`)
48
+
49
+ currentModelClass = modelClassRequire(digg(relationship, "resource_name"))
50
+ }
51
+ }
52
+
53
+ const currentModelClassName = digg(currentModelClass.modelClassData(), "name")
54
+
55
+ if (!(currentModelClassName in select)) select[currentModelClassName] = []
56
+ if (!select[currentModelClassName].includes(attribute)) select[currentModelClassName].push(attribute)
57
+ }
58
+
59
+ return select
60
+ }
61
+ }
62
+
63
+ export default function selectCalculator(...props) {
64
+ return new SelectCalculator(...props).selects()
65
+ }
@@ -0,0 +1,93 @@
1
+ import React, {useEffect, useRef} from "react"
2
+ import BaseComponent from "../../base-component"
3
+ import columnIdentifier from "../column-identifier"
4
+ import memo from "set-state-compare/src/memo"
5
+ import PropTypes from "prop-types"
6
+ import propTypesExact from "prop-types-exact"
7
+ import {shapeComponent} from "set-state-compare/src/shape-component"
8
+ import Text from "../../utils/text"
9
+ import {View} from "react-native"
10
+
11
+ export default memo(shapeComponent(class ColumnRow extends BaseComponent {
12
+ static propTypes = propTypesExact({
13
+ column: PropTypes.object.isRequired,
14
+ table: PropTypes.object.isRequired,
15
+ tableSettingColumn: PropTypes.object.isRequired
16
+ })
17
+
18
+ setup() {
19
+ this.checked = this.p.tableSettingColumn.visible()
20
+ this.checkboxRef = useRef()
21
+
22
+ useEffect(() => {
23
+ this.updateCheckboxChecked()
24
+ }, [this.checked])
25
+ }
26
+
27
+ render() {
28
+ const {column, table, tableSettingColumn} = this.p
29
+ const checkboxProps = {}
30
+
31
+ if (tableSettingColumn.visible() === true) {
32
+ checkboxProps.checked = "checked"
33
+ } else if (tableSettingColumn.visible() === null) {
34
+ checkboxProps.indeterminate = "indeterminate"
35
+ }
36
+
37
+ return (
38
+ <View dataSet={{component: "api-maker--table--settings--column-row"}} style={{justifyContent: "center"}}>
39
+ <label style={{whiteSpace: "nowrap"}}>
40
+ <input
41
+ className="api-maker--table--setings--column-checkbox"
42
+ data-identifier={columnIdentifier(column)}
43
+ onChange={this.onCheckboxChange}
44
+ ref={this.checkboxRef}
45
+ type="checkbox"
46
+ {...checkboxProps}
47
+ />
48
+ <Text>
49
+ {table.headerLabelForColumn(column)}
50
+ </Text>
51
+ </label>
52
+ </View>
53
+ )
54
+ }
55
+
56
+ onCheckboxChange = () => {
57
+ const {checked} = this
58
+
59
+ if (checked === true) {
60
+ this.checked = null
61
+ } else if (checked === null) {
62
+ this.checked = false
63
+ } else {
64
+ this.checked = true
65
+ }
66
+
67
+ this.updateCheckboxChecked()
68
+ this.updateTableSettingColumn()
69
+ }
70
+
71
+ updateCheckboxChecked() {
72
+ const {checked} = this.tt
73
+
74
+ if (checked === true) {
75
+ this.checkboxRef.current.checked = true
76
+ this.checkboxRef.current.indeterminate = undefined
77
+ } else if (checked === null) {
78
+ this.checkboxRef.current.checked = undefined
79
+ this.checkboxRef.current.indeterminate = true
80
+ } else {
81
+ this.checkboxRef.current.checked = undefined
82
+ this.checkboxRef.current.indeterminate = undefined
83
+ }
84
+ }
85
+
86
+ async updateTableSettingColumn() {
87
+ const {table, tableSettingColumn} = this.p
88
+
89
+ await tableSettingColumn.update({visible: this.checked})
90
+
91
+ table.events.emit("columnVisibilityUpdated", {tableSettingColumn})
92
+ }
93
+ }))
@@ -0,0 +1,68 @@
1
+ import BaseComponent from "../../base-component"
2
+ import ColumnContent from "../column-content"
3
+ import columnIdentifier from "../column-identifier"
4
+ import columnVisible from "../column-visible"
5
+ import {saveAs} from "file-saver"
6
+ import Icon from "../../utils/icon"
7
+ import memo from "set-state-compare/src/memo"
8
+ import PropTypes from "prop-types"
9
+ import propTypesExact from "prop-types-exact"
10
+ import React from "react"
11
+ import {renderToString} from "react-dom/server"
12
+ import {shapeComponent} from "set-state-compare/src/shape-component"
13
+ import {Pressable} from "react-native"
14
+ import Text from "../../utils/text"
15
+
16
+ export default memo(shapeComponent(class ApiMakerTableSettingsDownloadAction extends BaseComponent {
17
+ static propTypes = propTypesExact({
18
+ table: PropTypes.object.isRequired
19
+ })
20
+
21
+ render() {
22
+ return (
23
+ <Pressable onPress={this.tt.onDownloadPress} style={{flexDirection: "row", alignItems: "center"}}>
24
+ <Icon name="download" size={20} />
25
+ <Text style={{marginLeft: 5}}>
26
+ Download
27
+ </Text>
28
+ </Pressable>
29
+ )
30
+ }
31
+
32
+ onDownloadPress = () => {
33
+ const {table} = this.p
34
+ const {modelClass} = table.p
35
+ const {collection} = table.tt
36
+ const {models} = collection
37
+ const {preparedColumns} = table.s
38
+ const tableElement = (
39
+ <table>
40
+ <thead>
41
+ <tr>
42
+ {preparedColumns?.map(({column, tableSettingColumn}) => columnVisible(column, tableSettingColumn) &&
43
+ <th key={columnIdentifier(column)}>
44
+ {table.headerLabelForColumn(column)}
45
+ </th>
46
+ )}
47
+ </tr>
48
+ </thead>
49
+ <tbody>
50
+ {models.map((model) =>
51
+ <tr key={model.id()}>
52
+ {preparedColumns?.map(({column, tableSettingColumn}) => columnVisible(column, tableSettingColumn) &&
53
+ <td key={columnIdentifier(column)}>
54
+ {new ColumnContent({column, mode: "html", model, table}).content()}
55
+ </td>
56
+ )}
57
+ </tr>
58
+ )}
59
+ </tbody>
60
+ </table>
61
+ )
62
+ const tableHTML = renderToString(tableElement)
63
+ const blob = new Blob([tableHTML], {type: "text/html;charset=utf-8"})
64
+ const fileName = `${modelClass.modelName().human({count: 2})}.html`
65
+
66
+ saveAs(blob, fileName)
67
+ }
68
+ }))
@@ -0,0 +1,65 @@
1
+ import React, {useRef} from "react"
2
+ import BaseComponent from "../../base-component"
3
+ import columnIdentifier from "../column-identifier"
4
+ import ColumnRow from "./column-row"
5
+ import DownloadAction from "./download-action"
6
+ import memo from "set-state-compare/src/memo"
7
+ import Modal from "../../modal"
8
+ import PropTypes from "prop-types"
9
+ import propTypesExact from "prop-types-exact"
10
+ import {shapeComponent} from "set-state-compare/src/shape-component"
11
+ import {View} from "react-native"
12
+ import Text from "../../utils/text"
13
+ import useI18n from "i18n-on-steroids/src/use-i18n"
14
+
15
+ export default memo(shapeComponent(class ApiMakerTableSettings extends BaseComponent {
16
+ static propTypes = propTypesExact({
17
+ onRequestClose: PropTypes.func.isRequired,
18
+ table: PropTypes.object.isRequired
19
+ })
20
+
21
+ setup() {
22
+ const {t} = useI18n({namespace: "js.api_maker.table.settings"})
23
+
24
+ this.rootRef = useRef()
25
+ this.t = t
26
+ }
27
+
28
+ tableSetting = () => this.p.table.s.tableSetting
29
+
30
+ render() {
31
+ const {t} = this.tt
32
+ const {table} = this.p
33
+ const {preparedColumns} = table.s
34
+
35
+ return (
36
+ <Modal onBackdropPress={this.p.onRequestClose} onRequestClose={this.p.onRequestClose} style={{backgroundColor: "#000"}} transparent>
37
+ <View
38
+ dataSet={{class: "api-maker--table--settings"}}
39
+ style={{
40
+ width: "100%",
41
+ maxWidth: 800,
42
+ padding: 20,
43
+ backgroundColor: "#fff",
44
+ border: "1px solid black"
45
+ }}
46
+ >
47
+ <View style={{marginBottom: 5}}>
48
+ <Text style={{fontSize: 16, fontWeight: "bold"}}>
49
+ {t(".settings", {defaultValue: "Settings"})}
50
+ </Text>
51
+ </View>
52
+ <DownloadAction table={table} />
53
+ <View style={{marginBottom: 5}}>
54
+ <Text style={{fontSize: 16, fontWeight: "bold"}}>
55
+ {t(".columns", {defaultValue: "Columns"})}
56
+ </Text>
57
+ </View>
58
+ {preparedColumns?.map(({column, tableSettingColumn}) =>
59
+ <ColumnRow column={column} key={columnIdentifier(column)} table={table} tableSettingColumn={tableSettingColumn} />
60
+ )}
61
+ </View>
62
+ </Modal>
63
+ )
64
+ }
65
+ }))