@raketa-cloud/admin 0.0.31 → 0.0.34

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@raketa-cloud/admin",
3
- "version": "0.0.31",
3
+ "version": "0.0.34",
4
4
  "main": "src/index.js",
5
5
  "scripts": {
6
6
  "dev": "npx tailwindcss -i ./src/styles/application.css -o ../../apps/admin/static/application.css --watch",
package/src/Adapter.js CHANGED
@@ -1,12 +1,14 @@
1
1
  import { existsSync, readFileSync } from "node:fs";
2
2
  import path from "node:path";
3
3
  import ejs from "ejs";
4
+ import Logger from "./Logger";
4
5
  import currentPath from "./currentPath.cjs";
5
6
  import FormBuilder from "./helpers/FormBuilder";
6
7
  import HTMLBuilder from "./helpers/HTMLBuilder";
7
8
  import form_for from "./helpers/form_for";
8
9
  import pagination from "./helpers/pagination_helper";
9
10
  import sort_button from "./helpers/sort_button";
11
+ import Inflector from "./helpers/Inflector";
10
12
 
11
13
  function escapeHtml(string) {
12
14
  var matchHtmlRegExp = /["'&<>]/;
@@ -66,12 +68,6 @@ const renderError = (message, stack) => {
66
68
  return `<style>${errorCSS}</style><div class="fail-squid">🦑</div><h1>${message}</h1><pre>${escapeHtml(stack)}</pre>`;
67
69
  };
68
70
 
69
- const Logger = {
70
- error: (msg) => {
71
- console.error(`\x1b[31m🦑 ${msg}\x1b[0m`);
72
- },
73
- };
74
-
75
71
  function putIn(result, key, value) {
76
72
  const segments = key.split(/[\[\]]+/).filter(Boolean);
77
73
  let current = result;
@@ -164,6 +160,7 @@ export default class Adapter {
164
160
  form_for: form_for(viewHelpersConfig),
165
161
  sort_button,
166
162
  pagination,
163
+ Inflector,
167
164
  };
168
165
  }
169
166
 
@@ -1,4 +1,5 @@
1
1
  import Adapter from "./Adapter";
2
+ import Logger from "./Logger";
2
3
  import RaketaContext from "./RaketaContext";
3
4
  import setupAuthentication from "./setupAuthentication";
4
5
 
@@ -101,6 +102,7 @@ export default class HonoAdapter extends Adapter {
101
102
  ctx.defaultLocale = this.globalConfig.i18n.defaultLocale;
102
103
  ctx.locale = currentLocale;
103
104
  ctx.remoteConfig = { ...this.globalConfig.remoteConfig };
105
+ ctx.logger = Logger;
104
106
 
105
107
  const _context = {
106
108
  timezones: this.globalConfig.i18n.timezones,
@@ -115,9 +117,7 @@ export default class HonoAdapter extends Adapter {
115
117
  resourceConfig: resourceConfig,
116
118
  };
117
119
 
118
- console.info(
119
- `\x1b[35m[${ctx.method}] ${ctx.rawPath}\x1b[0m -> ${resource}/${action} | ${JSON.stringify(ctx.params)}`
120
- );
120
+ ctx.logger.info(`${ctx.method} "${ctx.rawPath}" -> ${resource}/${action} | ${JSON.stringify(ctx.params)}`);
121
121
 
122
122
  const assigns = {
123
123
  beforeFilterAssigns: {},
package/src/Logger.js ADDED
@@ -0,0 +1,21 @@
1
+ import { inspect } from 'node:util';
2
+
3
+
4
+ const dump = (item) => inspect(item, { depth: null }).replace(/^\'/, '').replace(/\'$/, '')
5
+
6
+ const Logger = {
7
+ error: (item) => {
8
+ console.error('[ERROR]', dump(item));
9
+ },
10
+
11
+ info: (item) => {
12
+ console.info('[INFO]', dump(item));
13
+ },
14
+
15
+ debug: (item) => {
16
+ console.debug('[DEBUG]', dump(item));
17
+ },
18
+ }
19
+
20
+ export default Logger;
21
+
@@ -215,18 +215,30 @@ export default class FormBuilder extends HTMLBuilder {
215
215
  }
216
216
 
217
217
  checkbox(name, opts = {}) {
218
- const { value: desiredValue } = opts;
218
+ const { value: desiredValue, default_value: defaultValue } = opts;
219
219
 
220
220
  const value = this.__getValue(name);
221
221
  const selected = value === desiredValue ? { checked: "checked" } : {};
222
222
 
223
- return this.tag("input", null, {
223
+ const checkboxItem = this.tag("input", null, {
224
224
  type: "checkbox",
225
- name,
226
225
  value,
227
226
  ...opts,
228
227
  ...selected,
229
228
  });
229
+
230
+ if (defaultValue === undefined) {
231
+ return checkboxItem;
232
+ }
233
+
234
+ // Make sure to submit the negative value if unchecked
235
+ const hiddenComplementaryItem = this.tag("input", null, {
236
+ type: "hidden",
237
+ name: toFormName(name),
238
+ value: defaultValue,
239
+ });
240
+
241
+ return [hiddenComplementaryItem, checkboxItem].join("");
230
242
  }
231
243
 
232
244
  label(name, children, opts = {}) {
@@ -261,12 +273,11 @@ export default class FormBuilder extends HTMLBuilder {
261
273
  label: innerOpts.label,
262
274
  class: "no-margin",
263
275
  });
264
- } else {
265
- return this.field(`${name}.${key}`, {
266
- label: innerOpts.label,
267
- class: "no-margin",
268
- });
269
276
  }
277
+ return this.field(`${name}.${key}`, {
278
+ label: innerOpts.label,
279
+ class: "no-margin",
280
+ });
270
281
  });
271
282
 
272
283
  return this.tag(
@@ -291,12 +302,11 @@ export default class FormBuilder extends HTMLBuilder {
291
302
  label: innerOpts.label,
292
303
  class: "no-margin",
293
304
  });
294
- } else {
295
- return this.field(`${name}.${key}`, {
296
- label: innerOpts.label,
297
- class: "no-margin",
298
- });
299
305
  }
306
+ return this.field(`${name}.${key}`, {
307
+ label: innerOpts.label,
308
+ class: "no-margin",
309
+ });
300
310
  });
301
311
 
302
312
  return this.tag(
@@ -0,0 +1,6 @@
1
+ const Inflector = {
2
+ capitalize: (str) => str[0].toUpperCase() + str.slice(1),
3
+ };
4
+
5
+ export default Inflector;
6
+
package/src/index.js CHANGED
@@ -88,3 +88,5 @@ export { default as EventURLsHandler } from "./handlers/events/URLsHandler";
88
88
  export { default as EventsHandler } from "./handlers/events/EventsHandler";
89
89
 
90
90
  export { default as Factory } from "./tests/support/factory";
91
+ export { default as Logger } from "./Logger";
92
+
@@ -6,17 +6,12 @@
6
6
  --background: 255, 255, 255;
7
7
  --foreground: 0, 0, 0;
8
8
 
9
- /* --primary: 110, 110, 178; */
10
- /* --primary: 0, 0, 0; */
11
- /* --primary: 15, 82, 186; */
12
- /* --primary: 0, 67, 206; */
13
9
  --primary: 91, 95, 198;
14
10
 
15
- /* --primary-dark: 88, 88, 142; */
16
- /* --primary-dark: 0, 0, 0; */
17
11
  --primary-dark: var(--primary);
18
12
  }
19
13
 
14
+ /*
20
15
  @media (prefers-color-scheme: dark) {
21
16
  :root {
22
17
  --foreground: 255, 255, 255;
@@ -24,12 +19,14 @@
24
19
  --primary: 130, 133, 212;
25
20
  }
26
21
  }
22
+ */
27
23
 
28
24
  body {
29
25
  @apply text-raketa-foreground bg-raketa-background;
30
26
  }
31
27
 
32
28
  @layer components {
29
+
33
30
  /* Utils */
34
31
  .dbg {
35
32
  @apply outline-1 outline-dashed outline-red-500;
@@ -278,7 +275,7 @@ body {
278
275
  .pagination {
279
276
  @apply text-center py-8 text-raketa-foreground/50;
280
277
 
281
- & > div {
278
+ &>div {
282
279
  @apply inline-flex items-center gap-4;
283
280
  }
284
281
 
@@ -521,6 +518,7 @@ body {
521
518
  0% {
522
519
  transform: scale(1);
523
520
  }
521
+
524
522
  100% {
525
523
  transform: scale(1.5);
526
524
  }
@@ -534,9 +532,11 @@ body {
534
532
  0% {
535
533
  transform: translatey(0px);
536
534
  }
535
+
537
536
  50% {
538
537
  transform: translatey(-40px);
539
538
  }
539
+
540
540
  100% {
541
541
  transform: translatey(0px);
542
542
  }
@@ -1,6 +1,6 @@
1
1
  <div class="page-wrapper">
2
2
  <div class="page-title">
3
- <h1 class="heading-1"><%= _context.resourceConfig.articleTypePlural %></h1>
3
+ <h1 class="heading-1"><%= Inflector.capitalize(_context.resourceConfig.articleTypePlural) %></h1>
4
4
 
5
5
  <div class="actions-toolbar">
6
6
  <a href="<%= `/${_context.locale}/${_context.resourceConfig.articleTypePlural}/new` %>" class="btn-primary">
@@ -1,6 +1,6 @@
1
1
  <div class="page-wrapper">
2
2
  <div class="page-title">
3
- <h1 class="heading-1"><%= _context.resourceConfig.eventTypePlural %></h1>
3
+ <h1 class="heading-1"><%= Inflector.capitalize(_context.resourceConfig.eventTypePlural) %></h1>
4
4
 
5
5
  <div class="actions-toolbar">
6
6
  <a href="<%= `/${_context.locale}/${_context.resourceConfig.eventTypePlural}/new` %>" class="btn-primary">
@@ -1,6 +1,6 @@
1
1
  <div class="page-wrapper">
2
2
  <div class="page-title">
3
- <h1 class="heading-1"><%= _context.resourceConfig.pageTypePlural %></h1>
3
+ <h1 class="heading-1"><%= Inflector.capitalize(_context.resourceConfig.pageTypePlural) %></h1>
4
4
 
5
5
  <div class="actions-toolbar">
6
6
  <a href="<%= `/${_context.locale}/${_context.resourceConfig.pageTypePlural}/new` %>" class="btn-primary">
@@ -1,6 +1,7 @@
1
1
  /** @type {import('tailwindcss').Config} */
2
2
  module.exports = {
3
3
  content: ["./src/**/*.{html,js,ejs}", "../../apps/**/*.{html,js,ejs}"],
4
+ darkMode: 'selector',
4
5
  theme: {
5
6
  extend: {
6
7
  colors: {