@orieljs/inertia-solid 0.0.0-stage → 0.1.0-alpha.10
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/LICENSE +202 -0
- package/NOTICE +16 -0
- package/README.md +47 -2
- package/TRADEMARKS.md +33 -0
- package/dist/index.d.ts +241 -0
- package/dist/index.js +873 -0
- package/dist/index.js.map +1 -0
- package/dist/server.d.ts +1 -0
- package/dist/server.js +6 -0
- package/dist/server.js.map +1 -0
- package/package.json +47 -3
package/LICENSE
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
package/NOTICE
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
Oriel
|
|
2
|
+
Copyright 2026 meeeet-dev and Oriel contributors
|
|
3
|
+
|
|
4
|
+
This product includes software developed by the Oriel project
|
|
5
|
+
(https://orieljs.vercel.app, https://github.com/orieljs).
|
|
6
|
+
|
|
7
|
+
Oriel is licensed under the Apache License, Version 2.0 (see LICENSE).
|
|
8
|
+
The Oriel name and logo are not covered by that license; see TRADEMARKS.md
|
|
9
|
+
(https://github.com/orieljs/framework/blob/main/TRADEMARKS.md).
|
|
10
|
+
|
|
11
|
+
@orieljs/support (and @orieljs/framework, which bundles it) includes transliteration data from
|
|
12
|
+
voku/portable-ascii (https://github.com/voku/portable-ascii), Copyright (C) 2019 Lars Moelleken, MIT License.
|
|
13
|
+
|
|
14
|
+
@orieljs/notifications (and @orieljs/framework, which bundles it) includes the HTML and CSS of
|
|
15
|
+
Laravel's default notification mail (laravel/framework, https://github.com/laravel/framework),
|
|
16
|
+
Copyright (c) Taylor Otwell, MIT License.
|
package/README.md
CHANGED
|
@@ -1,3 +1,48 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @orieljs/inertia-solid
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
The Oriel Solid adapter for Inertia. It is Oriel's own adapter, built on `@inertiajs/core`, with typed pages and Oriel route helpers. Apps load it through `oriel({ input, framework })` from `@orieljs/vite`.
|
|
4
|
+
|
|
5
|
+
```bash
|
|
6
|
+
npm install @orieljs/inertia-solid @orieljs/inertia-client solid-js
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
```tsx title="resources/js/app.tsx"
|
|
10
|
+
import { createInertiaApp } from '@orieljs/inertia-solid'
|
|
11
|
+
|
|
12
|
+
createInertiaApp({ pages: './pages' })
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
```tsx title="resources/js/pages/Posts/Index.tsx"
|
|
16
|
+
// @filename: resources/js/oriel/pages.d.ts
|
|
17
|
+
declare module '@orieljs/inertia-client' {
|
|
18
|
+
interface Pages { 'Posts/Index': { posts: { id: number; title: string }[] } }
|
|
19
|
+
}
|
|
20
|
+
export {}
|
|
21
|
+
// ---cut---
|
|
22
|
+
import { usePage } from '@orieljs/inertia-solid'
|
|
23
|
+
|
|
24
|
+
export default function Index() {
|
|
25
|
+
const page = usePage<'Posts/Index'>()
|
|
26
|
+
return <p>{page.props.posts.length} posts</p>
|
|
27
|
+
}
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
It provides `createInertiaApp`, `Link`, `Head`, `useForm`, `Form`, `Deferred`, `WhenVisible`, `InfiniteScroll`, `usePoll`, `usePrefetch`, `useRemember`, `router` and a typed `usePage<N>()`, plus `route()`, `hasRoute()`, `currentRoute()` and `isCurrentRoute()`. A `./server` export renders pages on the server. During server-side rendering `currentRoute()` and `isCurrentRoute()` read the URL of the page being rendered, so active links hydrate unchanged.
|
|
31
|
+
|
|
32
|
+
Known limitations:
|
|
33
|
+
|
|
34
|
+
- Its forms (`useForm` and `<Form>`) have no Precognition.
|
|
35
|
+
- No `useHttp` yet.
|
|
36
|
+
- Persistent layouts are set with `Page.layout = Layout`.
|
|
37
|
+
- `Deferred` and `WhenVisible` take top-level prop keys.
|
|
38
|
+
- `useForm` copies the objects along a dotted path on each write (`setData('items.1.name', value)`), so render form arrays with `<Index>`, not `<For>`: `<For>` keys rows by object and would recreate the row, losing input focus.
|
|
39
|
+
|
|
40
|
+
Documentation: https://orieljs.vercel.app/docs/inertia
|
|
41
|
+
|
|
42
|
+
Status: early alpha. APIs will change.
|
|
43
|
+
|
|
44
|
+
## License
|
|
45
|
+
|
|
46
|
+
Oriel is open-source software licensed under the Apache License 2.0 (Apache-2.0; see `LICENSE` and `NOTICE`). The Oriel name and logo are trademarks; see `TRADEMARKS.md`.
|
|
47
|
+
|
|
48
|
+
Website: https://orieljs.vercel.app
|
package/TRADEMARKS.md
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# Oriel trademark policy
|
|
2
|
+
|
|
3
|
+
The Oriel code is open source under the Apache License 2.0. The **Oriel name and logo** are not: the license covers
|
|
4
|
+
the code only (section 6 of the license says so), and the name and logo stay with the project. This page explains
|
|
5
|
+
what you can and can't do with them. The goal is simple: people should always be able to tell what is the real Oriel
|
|
6
|
+
and what isn't.
|
|
7
|
+
|
|
8
|
+
## You can, without asking
|
|
9
|
+
|
|
10
|
+
- Use, change, ship and sell the code, as the license allows.
|
|
11
|
+
- Say that your app or package is "built with Oriel", "for Oriel" or "compatible with Oriel".
|
|
12
|
+
- Name a package `oriel-<something>` or `<something>-for-oriel` when it works with Oriel, as long as it is clear that
|
|
13
|
+
it is not official (for example, don't publish it under the `@orieljs` npm scope).
|
|
14
|
+
- Use the name and logo to write about Oriel, teach it, or link to it, in articles, talks, videos and courses.
|
|
15
|
+
- Use the unmodified logo to point to the project, as it is (no recolouring, cropping or
|
|
16
|
+
distortion).
|
|
17
|
+
|
|
18
|
+
## You can't, without written permission
|
|
19
|
+
|
|
20
|
+
- Call a fork, a modified copy or a competing product "Oriel", or anything likely to be confused with it.
|
|
21
|
+
- Use the name or logo as the name, logo or domain of your own product, company or service.
|
|
22
|
+
- Suggest that the Oriel project made, endorses or supports your work when it doesn't.
|
|
23
|
+
- Sell merchandise with the name or logo.
|
|
24
|
+
|
|
25
|
+
## Forks
|
|
26
|
+
|
|
27
|
+
Forks are welcome. Please give yours a different name and logo, keep the `LICENSE` and `NOTICE` files, and say that
|
|
28
|
+
it is based on Oriel.
|
|
29
|
+
|
|
30
|
+
## Questions
|
|
31
|
+
|
|
32
|
+
Open an issue at https://github.com/orieljs/framework or email meeeet.dev@gmail.com. If you're unsure whether a use
|
|
33
|
+
is fine, ask; the answer is usually yes.
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,241 @@
|
|
|
1
|
+
import { Page, CreateInertiaAppOptions as CreateInertiaAppOptions$1, ProgressOptions, InertiaAppSSRResponse, VisitOptions, PrefetchOptions, ReloadOptions, PollOptions, InfiniteScrollComponentBaseProps, InfiniteScrollSlotProps, InfiniteScrollActionSlotProps, InfiniteScrollRef, FormComponentProps, Progress, FormDataConvertible } from '@inertiajs/core';
|
|
2
|
+
export { InfiniteScrollActionSlotProps, InfiniteScrollRef, InfiniteScrollSlotProps, router } from '@inertiajs/core';
|
|
3
|
+
import { PageName, TypedPage, LinkProps as LinkProps$1, FormHelper } from '@orieljs/inertia-client';
|
|
4
|
+
export { ErrorBags, Errors, PageName, PageProps, Pages, RouteError, RouteList, RouteName, SharedProps, TypedPage, currentRoute, hasRoute, isCurrentRoute, route } from '@orieljs/inertia-client';
|
|
5
|
+
import { Component, JSX, Accessor, Setter } from 'solid-js';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* The current page, typed by name: `usePage<'Posts/Index'>().props.posts`. The page is a store: read its fields
|
|
9
|
+
* inside JSX, an effect or a memo to react to visits. Call it inside a component rendered by the Inertia app.
|
|
10
|
+
*/
|
|
11
|
+
declare function usePage<N extends PageName = PageName>(): TypedPage<N>;
|
|
12
|
+
|
|
13
|
+
type AnyProps = any;
|
|
14
|
+
/** A persistent layout: it gets the page props, and the page (or the next layout) as `children`. */
|
|
15
|
+
type LayoutComponent = Component<AnyProps>;
|
|
16
|
+
/** A page component. `Home.layout = AppLayout` (or `[Outer, Inner]`) wraps it in layouts that survive visits. */
|
|
17
|
+
type PageComponent = Component<AnyProps> & {
|
|
18
|
+
layout?: LayoutComponent | LayoutComponent[];
|
|
19
|
+
};
|
|
20
|
+
/** What a resolver returns: the component, or its module (`{ default, layout? }`, e.g. `import('./pages/Home.tsx')`). */
|
|
21
|
+
type PageModule = PageComponent | {
|
|
22
|
+
default: PageComponent;
|
|
23
|
+
layout?: LayoutComponent | LayoutComponent[];
|
|
24
|
+
};
|
|
25
|
+
/** Finds the page component for a name: `(name) => import(`./pages/${name}.tsx`)`. */
|
|
26
|
+
type PageResolver = (name: string, page: Page) => PageModule | Promise<PageModule>;
|
|
27
|
+
/** A page ready to render: its component and its layouts, outermost first. */
|
|
28
|
+
interface ResolvedPage {
|
|
29
|
+
readonly component: PageComponent;
|
|
30
|
+
readonly layouts: readonly LayoutComponent[];
|
|
31
|
+
}
|
|
32
|
+
interface InertiaAppProps {
|
|
33
|
+
initialPage: Page;
|
|
34
|
+
initialComponent: ResolvedPage;
|
|
35
|
+
resolveComponent: (name: string, page?: Page) => Promise<ResolvedPage>;
|
|
36
|
+
/** Formats every page title (`(title) => `${title} - My App``). */
|
|
37
|
+
titleCallback?: (title: string) => string;
|
|
38
|
+
/** Receives the head tags on the server (SSR collects them into `head`). */
|
|
39
|
+
onHeadUpdate?: (elements: string[]) => void;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* The Inertia root: owns the current page (a store, read through usePage()), lets the router swap pages, and
|
|
43
|
+
* renders the page inside its layouts. A visit to another component, or one without preserveState, remounts the
|
|
44
|
+
* page; layouts that stay the same between two pages are kept, with their state.
|
|
45
|
+
*/
|
|
46
|
+
declare function App(props: InertiaAppProps): JSX.Element;
|
|
47
|
+
|
|
48
|
+
/** Renders one page on the server: what the SSR entry exports and `createServer()` serves. */
|
|
49
|
+
type RenderPage = (page: Page) => Promise<InertiaAppSSRResponse>;
|
|
50
|
+
/** In the browser: unmounts the app. On the server: renders a page (see RenderPage). */
|
|
51
|
+
type InertiaApp = (() => void) | RenderPage;
|
|
52
|
+
interface SetupOptions {
|
|
53
|
+
el: HTMLElement;
|
|
54
|
+
App: typeof App;
|
|
55
|
+
props: InertiaAppProps;
|
|
56
|
+
}
|
|
57
|
+
interface CreateInertiaAppOptions {
|
|
58
|
+
/** The id of the root element and of the page script (default `app`). */
|
|
59
|
+
id?: string;
|
|
60
|
+
/** Finds a page component by name: `(name) => import(`./pages/${name}.tsx`)`. */
|
|
61
|
+
resolve?: PageResolver;
|
|
62
|
+
/** The @inertiajs/vite shorthand (`pages: './pages'`), which the plugin turns into `resolve` at build time. */
|
|
63
|
+
pages?: CreateInertiaAppOptions$1<unknown, unknown, unknown, unknown>['pages'];
|
|
64
|
+
/** Mounts the app yourself (browser only); return a function that unmounts it. */
|
|
65
|
+
setup?: (options: SetupOptions) => (() => void) | void;
|
|
66
|
+
/** Formats every page title. */
|
|
67
|
+
title?: (title: string) => string;
|
|
68
|
+
/** The progress bar (core's NProgress-style bar); false turns it off. */
|
|
69
|
+
progress?: ProgressOptions | false;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Starts the Inertia app. In the browser it reads the page script (`<script data-page="app">`), resolves the page
|
|
73
|
+
* and mounts App on `#app` (hydrating server-rendered markup), then resolves to a function that unmounts it. On the
|
|
74
|
+
* server (Solid's server build) it resolves to the page renderer @inertiajs/vite's SSR entry exports.
|
|
75
|
+
*/
|
|
76
|
+
declare function createInertiaApp(options?: CreateInertiaAppOptions): Promise<InertiaApp>;
|
|
77
|
+
|
|
78
|
+
/** Link's props: Oriel's LinkProps, Inertia's visit callbacks and options, any attribute of the element, and children. */
|
|
79
|
+
type LinkProps = LinkProps$1 & Pick<VisitOptions, 'onCancelToken' | 'onBefore' | 'onStart' | 'onProgress' | 'onFinish' | 'onCancel' | 'onSuccess' | 'onError' | 'onPrefetching' | 'onPrefetched' | 'preserveUrl' | 'async' | 'queryStringArrayFormat' | 'viewTransition'> & Partial<PrefetchOptions> & {
|
|
80
|
+
children?: JSX.Element;
|
|
81
|
+
onClick?: (event: MouseEvent) => void;
|
|
82
|
+
onMouseEnter?: (event: MouseEvent) => void;
|
|
83
|
+
onMouseLeave?: (event: MouseEvent) => void;
|
|
84
|
+
onMouseDown?: (event: MouseEvent) => void;
|
|
85
|
+
[attribute: string]: unknown;
|
|
86
|
+
};
|
|
87
|
+
/**
|
|
88
|
+
* An Inertia link: `<Link href={route('posts.show', { post: 1 })}>`. A plain left click visits through the router
|
|
89
|
+
* instead of loading the page; modified clicks (new tab) are left to the browser. A non-GET link renders a button.
|
|
90
|
+
* `prefetch` (`true` = `'hover'`, `'click'`, `'mount'`) loads the page into core's prefetch cache ahead of the visit.
|
|
91
|
+
* The visit callbacks (`onBefore`, `onSuccess`, …) and options (`preserveUrl`, `async`, …) go to the router.
|
|
92
|
+
*/
|
|
93
|
+
declare function Link(props: LinkProps): JSX.Element;
|
|
94
|
+
|
|
95
|
+
/** The form helper as a Solid signal source: reading a field inside JSX or an effect tracks it. */
|
|
96
|
+
type SolidForm<T extends object> = Omit<FormHelper<T>, 'subscribe'>;
|
|
97
|
+
/**
|
|
98
|
+
* A form bound to the Inertia router: `const form = useForm({ title: '' })`, then `form.data.title`,
|
|
99
|
+
* `form.setData('title', value)`, `form.post(route('posts.store'))`, `form.errors.title`, `form.processing`.
|
|
100
|
+
* Built on @orieljs/inertia-client's createForm (no remember, no Precognition). Reading a field is reactive.
|
|
101
|
+
*/
|
|
102
|
+
declare function useForm<T extends object>(initial: T | (() => T)): SolidForm<T>;
|
|
103
|
+
|
|
104
|
+
interface DeferredProps {
|
|
105
|
+
/** The deferred prop (or props) to wait for. */
|
|
106
|
+
data: string | string[];
|
|
107
|
+
/** Shown until every prop has arrived. */
|
|
108
|
+
fallback: JSX.Element;
|
|
109
|
+
children?: JSX.Element;
|
|
110
|
+
}
|
|
111
|
+
/** Renders `fallback` until the deferred props in `data` have loaded, then the children. */
|
|
112
|
+
declare function Deferred(props: DeferredProps): JSX.Element;
|
|
113
|
+
|
|
114
|
+
interface WhenVisibleProps {
|
|
115
|
+
/** The props to load (a partial reload with `only`) when the element scrolls into view. */
|
|
116
|
+
data?: string | string[];
|
|
117
|
+
/** Extra reload options. */
|
|
118
|
+
params?: ReloadOptions;
|
|
119
|
+
/** Pixels around the viewport that count as visible (default 0). */
|
|
120
|
+
buffer?: number;
|
|
121
|
+
/** The placeholder element's tag (default `div`). */
|
|
122
|
+
as?: string;
|
|
123
|
+
/** Reload every time it becomes visible, not only the first time. */
|
|
124
|
+
always?: boolean;
|
|
125
|
+
/** Shown until the props have loaded. */
|
|
126
|
+
fallback?: JSX.Element;
|
|
127
|
+
children?: JSX.Element;
|
|
128
|
+
}
|
|
129
|
+
/** Loads props when a placeholder scrolls into view (IntersectionObserver), showing `fallback` until then. */
|
|
130
|
+
declare function WhenVisible(props: WhenVisibleProps): JSX.Element;
|
|
131
|
+
|
|
132
|
+
interface HeadProps {
|
|
133
|
+
/** The page title (passed through createInertiaApp's `title` callback). */
|
|
134
|
+
title?: string;
|
|
135
|
+
/** Head tags: `<meta>`, `<link>`, … A `head-key` attribute replaces the tag with the same key from a layout. */
|
|
136
|
+
children?: JSX.Element;
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* Sets the document title and head tags for the current page through core's head manager:
|
|
140
|
+
* `<Head title="Posts"><meta name="description" content="…" /></Head>`. On the server the tags go into the SSR
|
|
141
|
+
* response's `head`; in the browser they replace the previous page's tags.
|
|
142
|
+
*/
|
|
143
|
+
declare function Head(props: HeadProps): JSX.Element;
|
|
144
|
+
|
|
145
|
+
/** What usePoll() returns: `polling` is reactive (read it in JSX or an effect). */
|
|
146
|
+
interface SolidPoll {
|
|
147
|
+
readonly polling: boolean;
|
|
148
|
+
start(): void;
|
|
149
|
+
stop(): void;
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* Inertia's usePoll: reloads the page every `interval` ms (`{ only: ['messages'] }` for a partial reload), from mount
|
|
153
|
+
* (`autoStart: false` waits for `start()`) until the component goes away. Poll requests pause while the tab is hidden
|
|
154
|
+
* unless `keepAlive` is set.
|
|
155
|
+
*/
|
|
156
|
+
declare function usePoll(interval: number, requestOptions?: ReloadOptions | (() => ReloadOptions), options?: PollOptions): SolidPoll;
|
|
157
|
+
|
|
158
|
+
/** What usePrefetch() returns: every field is reactive. */
|
|
159
|
+
interface SolidPrefetch {
|
|
160
|
+
readonly lastUpdatedAt: number | null;
|
|
161
|
+
readonly isPrefetching: boolean;
|
|
162
|
+
readonly isPrefetched: boolean;
|
|
163
|
+
/** Drops the current page's prefetched response. */
|
|
164
|
+
flush(): void;
|
|
165
|
+
}
|
|
166
|
+
/** Inertia's usePrefetch: whether the current page is being (or has been) prefetched, and when it was last fetched. */
|
|
167
|
+
declare function usePrefetch(options?: VisitOptions): SolidPrefetch;
|
|
168
|
+
|
|
169
|
+
/**
|
|
170
|
+
* Inertia's useRemember: a signal whose value is kept in the browser history entry under `key`, so going back to the
|
|
171
|
+
* page (or making it again in the same entry) starts from it. `const [step, setStep] = useRemember(1, 'Wizard/step')`.
|
|
172
|
+
* Give each remembered value on a page its own key.
|
|
173
|
+
*/
|
|
174
|
+
declare function useRemember<T>(initialState: T, key?: string): [Accessor<T>, Setter<T>];
|
|
175
|
+
|
|
176
|
+
/** A slot: an element, or a function of the slot's state that returns one. */
|
|
177
|
+
type Slot<P> = JSX.Element | ((props: P) => JSX.Element);
|
|
178
|
+
interface InfiniteScrollProps extends InfiniteScrollComponentBaseProps {
|
|
179
|
+
/** The items: elements, or a function of `{ loading, loadingPrevious, loadingNext }` returning them. */
|
|
180
|
+
children?: Slot<InfiniteScrollSlotProps>;
|
|
181
|
+
/** Elements (or CSS selectors) to use as the triggers and the items container instead of the ones it renders. */
|
|
182
|
+
startElement?: string | HTMLElement;
|
|
183
|
+
endElement?: string | HTMLElement;
|
|
184
|
+
itemsElement?: string | HTMLElement;
|
|
185
|
+
/** What shows before and after the items (a "Load more" button in manual mode), and while a page loads. */
|
|
186
|
+
previous?: Slot<InfiniteScrollActionSlotProps>;
|
|
187
|
+
next?: Slot<InfiniteScrollActionSlotProps>;
|
|
188
|
+
loading?: Slot<InfiniteScrollActionSlotProps>;
|
|
189
|
+
/** Options of the reloads that fetch a page. */
|
|
190
|
+
params?: ReloadOptions;
|
|
191
|
+
/** Receives fetchNext(), fetchPrevious(), hasNext() and hasPrevious(). */
|
|
192
|
+
ref?: (scroll: InfiniteScrollRef) => void;
|
|
193
|
+
[attribute: string]: unknown;
|
|
194
|
+
}
|
|
195
|
+
/**
|
|
196
|
+
* Inertia's InfiniteScroll for a prop the server sends with `Inertia.scroll()`: as its end (or start) comes into view it
|
|
197
|
+
* loads the next (or previous) page and merges it in, keeping the URL's page in step. `manual` (or `manualAfter`)
|
|
198
|
+
* waits for the `next` slot's `fetch()`; `reverse` loads upwards, for chats. Extra attributes go on the items element
|
|
199
|
+
* (a `div`, or `as`).
|
|
200
|
+
*/
|
|
201
|
+
declare function InfiniteScroll(props: InfiniteScrollProps): JSX.Element;
|
|
202
|
+
|
|
203
|
+
type FormData_ = Record<string, FormDataConvertible>;
|
|
204
|
+
/** What `<Form>` gives its children and its `ref`: the form's state (reactive) and what can be done with it. */
|
|
205
|
+
interface FormSlot {
|
|
206
|
+
readonly errors: Record<string, string>;
|
|
207
|
+
readonly hasErrors: boolean;
|
|
208
|
+
readonly processing: boolean;
|
|
209
|
+
readonly progress: Progress | null;
|
|
210
|
+
readonly wasSuccessful: boolean;
|
|
211
|
+
readonly recentlySuccessful: boolean;
|
|
212
|
+
/** Whether the fields differ from their defaults (the values they had when the form mounted, or at defaults()). */
|
|
213
|
+
readonly isDirty: boolean;
|
|
214
|
+
clearErrors(...fields: string[]): void;
|
|
215
|
+
resetAndClearErrors(...fields: string[]): void;
|
|
216
|
+
setError(field: string | Record<string, string>, message?: string): void;
|
|
217
|
+
/** Puts the fields (all, or those named) back to their defaults. */
|
|
218
|
+
reset(...fields: string[]): void;
|
|
219
|
+
submit(submitter?: HTMLElement | null): void;
|
|
220
|
+
cancel(): void;
|
|
221
|
+
/** Makes the fields' current values their defaults. */
|
|
222
|
+
defaults(): void;
|
|
223
|
+
getData(): FormData_;
|
|
224
|
+
getFormData(): FormData;
|
|
225
|
+
}
|
|
226
|
+
type FormProps = Omit<FormComponentProps, 'validateFiles' | 'validationTimeout' | 'withAllErrors' | 'optimistic' | 'component' | 'instant'> & {
|
|
227
|
+
/** The fields: elements, or a function of the form's slot returning them. */
|
|
228
|
+
children?: JSX.Element | ((form: FormSlot) => JSX.Element);
|
|
229
|
+
/** Receives the form's slot. */
|
|
230
|
+
ref?: (form: FormSlot) => void;
|
|
231
|
+
[attribute: string]: unknown;
|
|
232
|
+
};
|
|
233
|
+
/**
|
|
234
|
+
* Inertia's `<Form>`: a plain HTML form whose fields are submitted with an Inertia visit to `action` (a URL or a
|
|
235
|
+
* `route()` url-method pair) by `method`, with no form state to keep in sync. Its children (or a function of its slot)
|
|
236
|
+
* read the errors, processing, progress and isDirty; `resetOnSuccess`, `resetOnError` and `setDefaultsOnSuccess` act
|
|
237
|
+
* on the fields. Other attributes go on the `<form>`. Precognition (`validate()`) is not offered here.
|
|
238
|
+
*/
|
|
239
|
+
declare function Form(props: FormProps): JSX.Element;
|
|
240
|
+
|
|
241
|
+
export { App, type CreateInertiaAppOptions, Deferred, type DeferredProps, Form, type FormProps, type FormSlot, Head, type HeadProps, type InertiaApp, type InertiaAppProps, InfiniteScroll, type InfiniteScrollProps, type LayoutComponent, Link, type LinkProps, type PageComponent, type PageModule, type PageResolver, type RenderPage, type ResolvedPage, type SetupOptions, type SolidForm, type SolidPoll, type SolidPrefetch, WhenVisible, type WhenVisibleProps, createInertiaApp, useForm, usePage, usePoll, usePrefetch, useRemember };
|