inertia_rails-contrib 0.2.2 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (52) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +12 -1
  3. data/README.md +3 -2
  4. data/lib/generators/inertia/install/frameworks.yml +28 -3
  5. data/lib/generators/inertia/install/install_generator.rb +6 -2
  6. data/lib/generators/inertia/install/templates/react/inertia.ts +4 -4
  7. data/lib/generators/inertia/install/templates/svelte/InertiaExample.svelte +3 -7
  8. data/lib/generators/inertia/install/templates/svelte/InertiaExample.ts.svelte +3 -7
  9. data/lib/generators/inertia/install/templates/svelte/inertia.js +3 -2
  10. data/lib/generators/inertia/install/templates/svelte/inertia.ts +7 -9
  11. data/lib/generators/inertia/install/templates/svelte4/InertiaExample.svelte +116 -0
  12. data/lib/generators/inertia/install/templates/svelte4/InertiaExample.ts.svelte +116 -0
  13. data/lib/generators/inertia/install/templates/svelte4/inertia.js +29 -0
  14. data/lib/generators/inertia/install/templates/svelte4/inertia.ts +29 -0
  15. data/lib/generators/inertia/install/templates/svelte4/svelte.config.js +7 -0
  16. data/lib/generators/inertia/install/templates/svelte4/tsconfig.json +21 -0
  17. data/lib/generators/inertia/install/templates/svelte4/tsconfig.node.json +12 -0
  18. data/lib/generators/inertia/install/templates/svelte4/vite-env.d.ts +2 -0
  19. data/lib/generators/inertia/install/templates/vue/inertia.ts +3 -3
  20. data/lib/generators/inertia_templates/controller/templates/svelte4/view.svelte.tt +2 -0
  21. data/lib/generators/inertia_templates/scaffold/templates/react/Form.jsx.tt +2 -2
  22. data/lib/generators/inertia_templates/scaffold/templates/svelte/Edit.svelte.tt +3 -4
  23. data/lib/generators/inertia_templates/scaffold/templates/svelte/Form.svelte.tt +12 -10
  24. data/lib/generators/inertia_templates/scaffold/templates/svelte/Index.svelte.tt +1 -8
  25. data/lib/generators/inertia_templates/scaffold/templates/svelte/New.svelte.tt +3 -4
  26. data/lib/generators/inertia_templates/scaffold/templates/svelte/One.svelte.tt +1 -1
  27. data/lib/generators/inertia_templates/scaffold/templates/svelte/Show.svelte.tt +4 -9
  28. data/lib/generators/inertia_templates/scaffold/templates/svelte4/Edit.svelte.tt +37 -0
  29. data/lib/generators/inertia_templates/scaffold/templates/svelte4/Form.svelte.tt +96 -0
  30. data/lib/generators/inertia_templates/scaffold/templates/svelte4/Index.svelte.tt +36 -0
  31. data/lib/generators/inertia_templates/scaffold/templates/svelte4/New.svelte.tt +30 -0
  32. data/lib/generators/inertia_templates/scaffold/templates/svelte4/One.svelte.tt +28 -0
  33. data/lib/generators/inertia_templates/scaffold/templates/svelte4/Show.svelte.tt +46 -0
  34. data/lib/generators/inertia_templates/scaffold/templates/vue/Form.vue.tt +1 -1
  35. data/lib/generators/inertia_tw_templates/controller/templates/svelte4/view.svelte.tt +2 -0
  36. data/lib/generators/inertia_tw_templates/scaffold/templates/react/Form.jsx.tt +2 -2
  37. data/lib/generators/inertia_tw_templates/scaffold/templates/svelte/Edit.svelte.tt +3 -4
  38. data/lib/generators/inertia_tw_templates/scaffold/templates/svelte/Form.svelte.tt +12 -13
  39. data/lib/generators/inertia_tw_templates/scaffold/templates/svelte/Index.svelte.tt +1 -8
  40. data/lib/generators/inertia_tw_templates/scaffold/templates/svelte/New.svelte.tt +3 -4
  41. data/lib/generators/inertia_tw_templates/scaffold/templates/svelte/One.svelte.tt +1 -1
  42. data/lib/generators/inertia_tw_templates/scaffold/templates/svelte/Show.svelte.tt +7 -8
  43. data/lib/generators/inertia_tw_templates/scaffold/templates/svelte4/Edit.svelte.tt +45 -0
  44. data/lib/generators/inertia_tw_templates/scaffold/templates/svelte4/Form.svelte.tt +120 -0
  45. data/lib/generators/inertia_tw_templates/scaffold/templates/svelte4/Index.svelte.tt +43 -0
  46. data/lib/generators/inertia_tw_templates/scaffold/templates/svelte4/New.svelte.tt +33 -0
  47. data/lib/generators/inertia_tw_templates/scaffold/templates/svelte4/One.svelte.tt +28 -0
  48. data/lib/generators/inertia_tw_templates/scaffold/templates/svelte4/Show.svelte.tt +58 -0
  49. data/lib/generators/inertia_tw_templates/scaffold/templates/vue/Form.vue.tt +2 -2
  50. data/lib/inertia_rails_contrib/generators_helper.rb +4 -3
  51. data/lib/inertia_rails_contrib/version.rb +1 -1
  52. metadata +24 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 918249a8473355fbcec2ce48a47c56a468601587623ff25a684b9d168f3405e1
4
- data.tar.gz: 06a83350918c230d4006b8be40a763a444d26d8aee7133967342d4f5bcb77e27
3
+ metadata.gz: 27c11a71a3acff524328e14dd27d4265a5365a113a58ae636b6877dbfb294d12
4
+ data.tar.gz: 8150b80e446aebe35e9e5a58026d2d633ce06c693254c2849229ceeee0f30a1a
5
5
  SHA512:
6
- metadata.gz: 53145888f043896709756bc40a08c86c7d57e947952d3ec0f84040ec766695c6b0815f1d13ed74301fd7c5a6e93b62bc9cf455b444e2607e517d90c4e38d6ed4
7
- data.tar.gz: d7986308cd3c945a3ac65ff44b363dd56c11bb1c8f2dda893fbfdcc7e2e71a6e6d0b0478c239f30722afed4f2528ee5dc49b619c717f30945392f39581bef6d7
6
+ metadata.gz: c2c94b176f794229063106b9ca1bd28a73c0b766cb657479bc75656cbc2ef4de74e94a85c61aaa64e1ae20e6659bc5cf9923c1c75fd069f224e0403eb63fab74
7
+ data.tar.gz: c3030cd27b25dbc309d6e3ea7a2b410563b794724fad3f7043a53d86430ea8b1fae7eb122c62bfdaa69bf9301e0da9fdec7525f114c7e98df825eee0877ff1c5
data/CHANGELOG.md CHANGED
@@ -7,6 +7,16 @@ and this project adheres to [Semantic Versioning].
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [0.3.0] - 2024-10-25
11
+
12
+ Added:
13
+
14
+ - [BREAKING] Svelte 5 support ([@skryukov])
15
+ - The `--framework=svelte` option now installs Svelte 5
16
+ - New `--framework=svelte4` option installs Svelte 4
17
+ - Support for Svelte 5 in the installation generator
18
+ - Support for Svelte 5 in the scaffold templates
19
+
10
20
  ## [0.2.2] - 2024-10-09
11
21
 
12
22
  Added:
@@ -62,7 +72,8 @@ Added:
62
72
  [@Shaglock]: https://github.com/Shaglock
63
73
  [@skryukov]: https://github.com/skryukov
64
74
 
65
- [Unreleased]: https://github.com/skryukov/inertia_rails-contrib/compare/v0.2.2...HEAD
75
+ [Unreleased]: https://github.com/skryukov/inertia_rails-contrib/compare/v0.3.0...HEAD
76
+ [0.3.0]: https://github.com/skryukov/inertia_rails-contrib/compare/v0.2.2...v0.3.0
66
77
  [0.2.2]: https://github.com/skryukov/inertia_rails-contrib/compare/v0.2.1...v0.2.2
67
78
  [0.2.1]: https://github.com/skryukov/inertia_rails-contrib/compare/v0.2.0...v0.2.1
68
79
  [0.2.0]: https://github.com/skryukov/inertia_rails-contrib/compare/v0.1.1...v0.2.0
data/README.md CHANGED
@@ -31,7 +31,8 @@ bin/rails generate inertia:install
31
31
 
32
32
  This command will:
33
33
  - Check for Vite Rails and install it if not present
34
- - Ask you to choose your preferred frontend framework (React, Vue, or Svelte)
34
+ - Ask if you want to use TypeScript
35
+ - Ask you to choose your preferred frontend framework (React, Vue, Svelte 4, or Svelte 5)
35
36
  - Ask if you want to install Tailwind CSS
36
37
  - Install necessary dependencies
37
38
  - Set up the application to work with Inertia
@@ -50,7 +51,7 @@ Vite Rails gem successfully installed
50
51
  Vite Rails successfully installed
51
52
  Would you like to use TypeScript? (y/n) y
52
53
  Adding TypeScript support
53
- What framework do you want to use with Inertia? [react, vue, svelte] (react)
54
+ What framework do you want to use with Inertia? [react, vue, svelte4, svelte] (react)
54
55
  run npm add @types/react @types/react-dom typescript --silent from "."
55
56
  Would you like to install Tailwind CSS? (y/n) y
56
57
  Installing Tailwind CSS
@@ -47,13 +47,38 @@ vue:
47
47
  copy_files_js:
48
48
  "InertiaExample.vue": "%{js_destination_path}/pages/InertiaExample.vue"
49
49
 
50
+ svelte4:
51
+ inertia_package: "@inertiajs/svelte"
52
+ packages:
53
+ - "svelte@4"
54
+ - "@sveltejs/vite-plugin-svelte@3"
55
+ packages_ts:
56
+ - "@tsconfig/svelte@4"
57
+ - "svelte-check"
58
+ - "typescript"
59
+ - "tslib"
60
+ vite_plugin_import: "import { svelte } from '@sveltejs/vite-plugin-svelte'"
61
+ vite_plugin_call: "svelte()"
62
+ copy_files_ts:
63
+ "InertiaExample.ts.svelte": "%{js_destination_path}/pages/InertiaExample.svelte"
64
+ "tsconfig.json": "tsconfig.json"
65
+ "tsconfig.node.json": "tsconfig.node.json"
66
+ "vite-env.d.ts": "%{js_destination_path}/vite-env.d.ts"
67
+ copy_files_js:
68
+ "InertiaExample.svelte": "%{js_destination_path}/pages/InertiaExample.svelte"
69
+ copy_files:
70
+ "svelte.config.js": "svelte.config.js"
71
+ "../assets/svelte.svg": "%{js_destination_path}/assets/svelte.svg"
72
+ "../assets/inertia.svg": "%{js_destination_path}/assets/inertia.svg"
73
+ "../assets/vite_ruby.svg": "%{js_destination_path}/assets/vite_ruby.svg"
74
+
50
75
  svelte:
51
76
  inertia_package: "@inertiajs/svelte"
52
77
  packages:
53
- - "svelte"
54
- - "@sveltejs/vite-plugin-svelte"
78
+ - "svelte@5"
79
+ - "@sveltejs/vite-plugin-svelte@4"
55
80
  packages_ts:
56
- - "@tsconfig/svelte"
81
+ - "@tsconfig/svelte@5"
57
82
  - "svelte-check"
58
83
  - "typescript"
59
84
  - "tslib"
@@ -99,7 +99,7 @@ module Inertia
99
99
  insert_into_file application_layout.to_s, "<%= vite_react_refresh_tag %>\n ", before: "<%= vite_client_tag %>"
100
100
  end
101
101
 
102
- gsub_file application_layout.to_s, /<title>/, "<title inertia>" if framework != "svelte"
102
+ gsub_file application_layout.to_s, /<title>/, "<title inertia>" unless svelte?
103
103
  else
104
104
  say_error "Could not find the application layout file. Please add the following tags manually:", :red
105
105
  say_error "- <title>...</title>"
@@ -112,7 +112,7 @@ module Inertia
112
112
 
113
113
  def install_typescript
114
114
  say "Adding TypeScript support"
115
- if framework == "svelte" && inertia_resolved_version.release < Gem::Version.new("1.3.0")
115
+ if svelte? && inertia_resolved_version.release < Gem::Version.new("1.3.0")
116
116
  say "WARNING: @inertiajs/svelte < 1.3.0 does not support TypeScript (resolved version: #{inertia_resolved_version}).", :yellow
117
117
  say "Skipping TypeScript support for @inertiajs/svelte", :yellow
118
118
  @typescript = false
@@ -270,6 +270,10 @@ module Inertia
270
270
  options[:verbose]
271
271
  end
272
272
 
273
+ def svelte?
274
+ framework.start_with? "svelte"
275
+ end
276
+
273
277
  def inertia_package
274
278
  "#{FRAMEWORKS[framework]["inertia_package"]}@#{options[:inertia_version]}"
275
279
  end
@@ -2,7 +2,7 @@ import { createInertiaApp } from '@inertiajs/react'
2
2
  import { createElement, ReactNode } from 'react'
3
3
  import { createRoot } from 'react-dom/client'
4
4
 
5
- type Component = { default: ReactNode & { layout?: (page: ReactNode) => ReactNode } }
5
+ type ResolvedComponent = { default: ReactNode, layout?: (page: ReactNode) => ReactNode }
6
6
 
7
7
  createInertiaApp({
8
8
  // Set default page title
@@ -16,14 +16,14 @@ createInertiaApp({
16
16
  // progress: false,
17
17
 
18
18
  resolve: (name) => {
19
- const pages = import.meta.glob('../pages/**/*.tsx', { eager: true })
20
- return pages[`../pages/${name}.tsx`] as Component
19
+ const pages = import.meta.glob<ResolvedComponent>('../pages/**/*.tsx', { eager: true })
20
+ return pages[`../pages/${name}.tsx`]
21
21
 
22
22
  // To use a default layout, import the Layout component
23
23
  // and use the following lines.
24
24
  // see https://inertia-rails.netlify.app/guide/pages#default-layouts
25
25
  //
26
- // const page = pages[`../pages/${name}.tsx`] as Component
26
+ // const page = pages[`../pages/${name}.tsx`]
27
27
  // page.default.layout ||= (page) => createElement(Layout, null, page)
28
28
  // return page
29
29
  },
@@ -3,13 +3,9 @@
3
3
  import inertiaSvg from '/assets/inertia.svg'
4
4
  import viteRubySvg from '/assets/vite_ruby.svg'
5
5
 
6
- export let name
6
+ let { name } = $props()
7
7
 
8
- let count = 0
9
-
10
- function handleClick() {
11
- count += 1
12
- }
8
+ let count = $state(0)
13
9
  </script>
14
10
 
15
11
  <svelte:head>
@@ -34,7 +30,7 @@
34
30
  <h2>Inertia + Vite Ruby + Svelte</h2>
35
31
 
36
32
  <div class="card">
37
- <button on:click={handleClick}>
33
+ <button onclick={() => count++}>
38
34
  count is {count}
39
35
  </button>
40
36
  <p>
@@ -3,13 +3,9 @@
3
3
  import inertiaSvg from '/assets/inertia.svg'
4
4
  import viteRubySvg from '/assets/vite_ruby.svg'
5
5
 
6
- export let name: string
6
+ let { name }: { name: string } = $props()
7
7
 
8
- let count = 0
9
-
10
- function handleClick() {
11
- count += 1
12
- }
8
+ let count = $state(0)
13
9
  </script>
14
10
 
15
11
  <svelte:head>
@@ -34,7 +30,7 @@
34
30
  <h2>Inertia + Vite Ruby + Svelte</h2>
35
31
 
36
32
  <div class="card">
37
- <button on:click={handleClick}>
33
+ <button onclick={() => count++}>
38
34
  count is {count}
39
35
  </button>
40
36
  <p>
@@ -1,4 +1,5 @@
1
1
  import { createInertiaApp } from '@inertiajs/svelte'
2
+ import { mount } from 'svelte';
2
3
 
3
4
  createInertiaApp({
4
5
  // Set default page title
@@ -23,7 +24,7 @@ createInertiaApp({
23
24
  // return { default: page.default, layout: page.layout || Layout }
24
25
  },
25
26
 
26
- setup({ el, App }) {
27
- new App({ target: el })
27
+ setup({ el, App, props }) {
28
+ mount(App, { target: el, props })
28
29
  },
29
30
  })
@@ -1,7 +1,5 @@
1
- import { createInertiaApp } from '@inertiajs/svelte'
2
- import type { ComponentType } from 'svelte';
3
-
4
- type ResolvedComponent = { default: ComponentType, layout?: ComponentType }
1
+ import { createInertiaApp, type ResolvedComponent } from '@inertiajs/svelte'
2
+ import { mount } from 'svelte'
5
3
 
6
4
  createInertiaApp({
7
5
  // Set default page title
@@ -15,18 +13,18 @@ createInertiaApp({
15
13
  // progress: false,
16
14
 
17
15
  resolve: (name) => {
18
- const pages = import.meta.glob('../pages/**/*.svelte', { eager: true })
19
- return pages[`../pages/${name}.svelte`] as ResolvedComponent
16
+ const pages = import.meta.glob<ResolvedComponent>('../pages/**/*.svelte', { eager: true })
17
+ return pages[`../pages/${name}.svelte`]
20
18
 
21
19
  // To use a default layout, import the Layout component
22
20
  // and use the following lines.
23
21
  // see https://inertia-rails.netlify.app/guide/pages#default-layouts
24
22
  //
25
- // const page = pages[`../pages/${name}.svelte`] as ResolvedComponent
23
+ // const page = pages[`../pages/${name}.svelte`]
26
24
  // return { default: page.default, layout: page.layout || Layout }
27
25
  },
28
26
 
29
- setup({ el, App }) {
30
- new App({ target: el })
27
+ setup({ el, App, props }) {
28
+ mount(App, { target: el, props })
31
29
  },
32
30
  })
@@ -0,0 +1,116 @@
1
+ <script>
2
+ import svelteSvg from '/assets/svelte.svg'
3
+ import inertiaSvg from '/assets/inertia.svg'
4
+ import viteRubySvg from '/assets/vite_ruby.svg'
5
+
6
+ export let name
7
+
8
+ let count = 0
9
+
10
+ function handleClick() {
11
+ count += 1
12
+ }
13
+ </script>
14
+
15
+ <svelte:head>
16
+ <title>Inertia + Vite Ruby + Svelte Example</title>
17
+ </svelte:head>
18
+
19
+ <div class="inertia_example">
20
+ <h1>Hello {name}!</h1>
21
+
22
+ <div>
23
+ <a href="https://inertia-rails.netlify.app" target="_blank">
24
+ <img class="logo" src={inertiaSvg} alt="Inertia logo" />
25
+ </a>
26
+ <a href="https://vite-ruby.netlify.app" target="_blank">
27
+ <img class="logo vite" src={viteRubySvg} alt="Vite Ruby logo" />
28
+ </a>
29
+ <a href="https://svelte.dev" target="_blank">
30
+ <img class="logo svelte" src={svelteSvg} alt="Svelte logo" />
31
+ </a>
32
+ </div>
33
+
34
+ <h2>Inertia + Vite Ruby + Svelte</h2>
35
+
36
+ <div class="card">
37
+ <button on:click={handleClick}>
38
+ count is {count}
39
+ </button>
40
+ <p>
41
+ Edit <code>app/frontend/pages/InertiaExample.svelte</code> and save to test
42
+ HMR
43
+ </p>
44
+ </div>
45
+ <p class="read-the-docs">
46
+ Click on the Inertia, Vite Ruby, and Svelte logos to learn more
47
+ </p>
48
+ </div>
49
+
50
+ <style>
51
+ .inertia_example {
52
+ font-family: Inter, system-ui, Avenir, Helvetica, Arial, sans-serif;
53
+ line-height: 1.5;
54
+ font-weight: 400;
55
+ color: #213547;
56
+ background-color: #ffffff;
57
+ max-width: 1280px;
58
+ margin: 0 auto;
59
+ padding: 2rem;
60
+ text-align: center;
61
+ }
62
+
63
+ h1 {
64
+ font-size: 3.2em;
65
+ line-height: 1.1;
66
+ }
67
+
68
+ h2 {
69
+ font-size: 2.6em;
70
+ line-height: 1.1;
71
+ }
72
+
73
+ button {
74
+ border-radius: 8px;
75
+ border: 1px solid transparent;
76
+ padding: 0.6em 1.2em;
77
+ font-size: 1em;
78
+ font-weight: 500;
79
+ font-family: inherit;
80
+ background-color: #f9f9f9;
81
+ cursor: pointer;
82
+ transition: border-color 0.25s;
83
+ }
84
+ button:hover {
85
+ border-color: #646cff;
86
+ }
87
+ button:focus,
88
+ button:focus-visible {
89
+ outline: 4px auto -webkit-focus-ring-color;
90
+ }
91
+
92
+ .logo {
93
+ display: inline-block;
94
+ height: 6em;
95
+ padding: 1.5em;
96
+ will-change: filter;
97
+ transition: filter 300ms;
98
+ }
99
+ .logo:hover {
100
+ filter: drop-shadow(0 0 2em #646cffaa);
101
+ }
102
+ .logo.vite:hover {
103
+ filter: drop-shadow(0 0 2em #e4023baa);
104
+ }
105
+ .logo.svelte:hover {
106
+ filter: drop-shadow(0 0 2em #ff3e00aa);
107
+ }
108
+
109
+ .card {
110
+ padding: 2em;
111
+ }
112
+
113
+ .read-the-docs {
114
+ color: #888;
115
+ }
116
+ </style>
@@ -0,0 +1,116 @@
1
+ <script lang="ts">
2
+ import svelteSvg from '/assets/svelte.svg'
3
+ import inertiaSvg from '/assets/inertia.svg'
4
+ import viteRubySvg from '/assets/vite_ruby.svg'
5
+
6
+ export let name: string
7
+
8
+ let count = 0
9
+
10
+ function handleClick() {
11
+ count += 1
12
+ }
13
+ </script>
14
+
15
+ <svelte:head>
16
+ <title>Inertia + Vite Ruby + Svelte Example</title>
17
+ </svelte:head>
18
+
19
+ <div class="inertia_example">
20
+ <h1>Hello {name}!</h1>
21
+
22
+ <div>
23
+ <a href="https://inertia-rails.netlify.app" target="_blank">
24
+ <img class="logo" src={inertiaSvg} alt="Inertia logo" />
25
+ </a>
26
+ <a href="https://vite-ruby.netlify.app" target="_blank">
27
+ <img class="logo vite" src={viteRubySvg} alt="Vite Ruby logo" />
28
+ </a>
29
+ <a href="https://svelte.dev" target="_blank">
30
+ <img class="logo svelte" src={svelteSvg} alt="Svelte logo" />
31
+ </a>
32
+ </div>
33
+
34
+ <h2>Inertia + Vite Ruby + Svelte</h2>
35
+
36
+ <div class="card">
37
+ <button on:click={handleClick}>
38
+ count is {count}
39
+ </button>
40
+ <p>
41
+ Edit <code>app/frontend/pages/InertiaExample.svelte</code> and save to test
42
+ HMR
43
+ </p>
44
+ </div>
45
+ <p class="read-the-docs">
46
+ Click on the Inertia, Vite Ruby, and Svelte logos to learn more
47
+ </p>
48
+ </div>
49
+
50
+ <style>
51
+ .inertia_example {
52
+ font-family: Inter, system-ui, Avenir, Helvetica, Arial, sans-serif;
53
+ line-height: 1.5;
54
+ font-weight: 400;
55
+ color: #213547;
56
+ background-color: #ffffff;
57
+ max-width: 1280px;
58
+ margin: 0 auto;
59
+ padding: 2rem;
60
+ text-align: center;
61
+ }
62
+
63
+ h1 {
64
+ font-size: 3.2em;
65
+ line-height: 1.1;
66
+ }
67
+
68
+ h2 {
69
+ font-size: 2.6em;
70
+ line-height: 1.1;
71
+ }
72
+
73
+ button {
74
+ border-radius: 8px;
75
+ border: 1px solid transparent;
76
+ padding: 0.6em 1.2em;
77
+ font-size: 1em;
78
+ font-weight: 500;
79
+ font-family: inherit;
80
+ background-color: #f9f9f9;
81
+ cursor: pointer;
82
+ transition: border-color 0.25s;
83
+ }
84
+ button:hover {
85
+ border-color: #646cff;
86
+ }
87
+ button:focus,
88
+ button:focus-visible {
89
+ outline: 4px auto -webkit-focus-ring-color;
90
+ }
91
+
92
+ .logo {
93
+ display: inline-block;
94
+ height: 6em;
95
+ padding: 1.5em;
96
+ will-change: filter;
97
+ transition: filter 300ms;
98
+ }
99
+ .logo:hover {
100
+ filter: drop-shadow(0 0 2em #646cffaa);
101
+ }
102
+ .logo.vite:hover {
103
+ filter: drop-shadow(0 0 2em #e4023baa);
104
+ }
105
+ .logo.svelte:hover {
106
+ filter: drop-shadow(0 0 2em #ff3e00aa);
107
+ }
108
+
109
+ .card {
110
+ padding: 2em;
111
+ }
112
+
113
+ .read-the-docs {
114
+ color: #888;
115
+ }
116
+ </style>
@@ -0,0 +1,29 @@
1
+ import { createInertiaApp } from '@inertiajs/svelte'
2
+
3
+ createInertiaApp({
4
+ // Set default page title
5
+ // see https://inertia-rails.netlify.app/guide/title-and-meta
6
+ //
7
+ // title: title => title ? `${title} - App` : 'App',
8
+
9
+ // Disable progress bar
10
+ //
11
+ // see https://inertia-rails.netlify.app/guide/progress-indicators
12
+ // progress: false,
13
+
14
+ resolve: (name) => {
15
+ const pages = import.meta.glob('../pages/**/*.svelte', { eager: true })
16
+ return pages[`../pages/${name}.svelte`]
17
+
18
+ // To use a default layout, import the Layout component
19
+ // and use the following lines.
20
+ // see https://inertia-rails.netlify.app/guide/pages#default-layouts
21
+ //
22
+ // const page = pages[`../pages/${name}.svelte`]
23
+ // return { default: page.default, layout: page.layout || Layout }
24
+ },
25
+
26
+ setup({ el, App, props }) {
27
+ new App({ target: el, props })
28
+ },
29
+ })
@@ -0,0 +1,29 @@
1
+ import { createInertiaApp, type ResolvedComponent } from '@inertiajs/svelte'
2
+
3
+ createInertiaApp({
4
+ // Set default page title
5
+ // see https://inertia-rails.netlify.app/guide/title-and-meta
6
+ //
7
+ // title: title => title ? `${title} - App` : 'App',
8
+
9
+ // Disable progress bar
10
+ //
11
+ // see https://inertia-rails.netlify.app/guide/progress-indicators
12
+ // progress: false,
13
+
14
+ resolve: (name) => {
15
+ const pages = import.meta.glob<ResolvedComponent>('../pages/**/*.svelte', { eager: true })
16
+ return pages[`../pages/${name}.svelte`]
17
+
18
+ // To use a default layout, import the Layout component
19
+ // and use the following lines.
20
+ // see https://inertia-rails.netlify.app/guide/pages#default-layouts
21
+ //
22
+ // const page = pages[`../pages/${name}.svelte`]
23
+ // return { default: page.default, layout: page.layout || Layout }
24
+ },
25
+
26
+ setup({ el, App, props }) {
27
+ new App({ target: el, props })
28
+ },
29
+ })
@@ -0,0 +1,7 @@
1
+ import { vitePreprocess } from '@sveltejs/vite-plugin-svelte'
2
+
3
+ export default {
4
+ // Consult https://svelte.dev/docs#compile-time-svelte-preprocess
5
+ // for more information about preprocessors
6
+ preprocess: vitePreprocess(),
7
+ }
@@ -0,0 +1,21 @@
1
+ {
2
+ "extends": "@tsconfig/svelte/tsconfig.json",
3
+ "compilerOptions": {
4
+ "target": "ESNext",
5
+ "useDefineForClassFields": true,
6
+ "module": "ESNext",
7
+ "resolveJsonModule": true,
8
+ /**
9
+ * Typecheck JS in `.svelte` and `.js` files by default.
10
+ * Disable checkJs if you'd like to use dynamic types in JS.
11
+ * Note that setting allowJs false does not prevent the use
12
+ * of JS in `.svelte` files.
13
+ */
14
+ "allowJs": true,
15
+ "checkJs": true,
16
+ "isolatedModules": true,
17
+ "moduleDetection": "force",
18
+ },
19
+ "include": ["<%= js_destination_path %>/**/*.ts", "<%= js_destination_path %>/**/*.js", "<%= js_destination_path %>/**/*.svelte"],
20
+ "references": [{ "path": "./tsconfig.node.json" }]
21
+ }
@@ -0,0 +1,12 @@
1
+ {
2
+ "compilerOptions": {
3
+ "composite": true,
4
+ "tsBuildInfoFile": "./node_modules/.tmp/tsconfig.node.tsbuildinfo",
5
+ "skipLibCheck": true,
6
+ "module": "ESNext",
7
+ "moduleResolution": "bundler",
8
+ "strict": true,
9
+ "noEmit": true,
10
+ },
11
+ "include": ["vite.config.ts"]
12
+ }
@@ -0,0 +1,2 @@
1
+ /// <reference types="svelte" />
2
+ /// <reference types="vite/client" />
@@ -13,14 +13,14 @@ createInertiaApp({
13
13
  // progress: false,
14
14
 
15
15
  resolve: (name) => {
16
- const pages = import.meta.glob('../pages/**/*.vue', { eager: true })
17
- return pages[`../pages/${name}.vue`] as DefineComponent
16
+ const pages = import.meta.glob<DefineComponent>('../pages/**/*.vue', { eager: true })
17
+ return pages[`../pages/${name}.vue`]
18
18
 
19
19
  // To use a default layout, import the Layout component
20
20
  // and use the following lines.
21
21
  // see https://inertia-rails.netlify.app/guide/pages#default-layouts
22
22
  //
23
- // const page = pages[`../pages/${name}.vue`] as DefineComponent
23
+ // const page = pages[`../pages/${name}.vue`]
24
24
  // page.default.layout = page.default.layout || Layout
25
25
  // return page
26
26
  },
@@ -0,0 +1,2 @@
1
+ <h1><%= class_name %>#<%= @action %></h1>
2
+ <p>Find me in <%= @path %></p>
@@ -73,12 +73,12 @@ export default function Form({ <%= singular_table_name %>, onSubmit, submitText
73
73
  <% elsif attribute.attachments? -%>
74
74
  <input
75
75
  type="file"
76
- multiple="multiple"
76
+ multiple
77
77
  name="<%= attribute.singular_name %>[]"
78
78
  id="<%= attribute.singular_name %>"
79
79
  onChange={(e) => setData('<%= attribute.column_name %>', Array.from(e.target.files))}
80
80
  />
81
- <% elsif attribute.field_type == :check_box -%>
81
+ <% elsif input_type(attribute) == "checkbox" -%>
82
82
  <input
83
83
  type="<%= input_type(attribute) %>"
84
84
  name="<%= attribute.singular_name %>"
@@ -2,10 +2,9 @@
2
2
  import { Link } from '@inertiajs/svelte'
3
3
  import Form from './Form.svelte'
4
4
 
5
- export let <%= singular_table_name %>
5
+ let { <%= singular_table_name %> } = $props()
6
6
 
7
- const handleSubmit = (e) => {
8
- const { form } = e.detail
7
+ const handleSubmit = ({ form }) => {
9
8
  form.transform((data) => ({ <%= singular_table_name %>: data }))
10
9
  <% if attributes.any?(&:attachments?) -%>
11
10
  form.post(`<%= js_resource_path %>`, {
@@ -26,7 +25,7 @@
26
25
  <Form
27
26
  {<%= singular_table_name %>}
28
27
  submitText="Update <%= human_name.downcase %>"
29
- on:submit={handleSubmit}
28
+ onSubmit={handleSubmit}
30
29
  />
31
30
 
32
31
  <br />