@inertiajs/svelte 1.3.0-beta.1 → 1.3.0-beta.2
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/dist/components/App.svelte +1 -2
- package/dist/components/Link.svelte +7 -14
- package/dist/components/Link.svelte.d.ts +2 -2
- package/dist/createInertiaApp.d.ts +1 -1
- package/dist/createInertiaApp.js +2 -2
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/link.d.ts +14 -4
- package/dist/link.js +5 -5
- package/dist/page.d.ts +1 -1
- package/dist/store.d.ts +2 -2
- package/dist/types.d.ts +3 -2
- package/package.json +2 -2
|
@@ -2,14 +2,13 @@
|
|
|
2
2
|
import store, {} from "../store";
|
|
3
3
|
$: props = resolveProps($store);
|
|
4
4
|
function resolveProps({ component, page, key = null }) {
|
|
5
|
-
if (!component?.default || !page) return null;
|
|
6
5
|
const child = h(component.default, page.props, [], key);
|
|
7
6
|
const layout = component.layout;
|
|
8
7
|
return layout ? resolveLayout(layout, child, page.props, key) : child;
|
|
9
8
|
}
|
|
10
9
|
function resolveLayout(layout, child, pageProps, key) {
|
|
11
10
|
if (Array.isArray(layout)) {
|
|
12
|
-
return layout.
|
|
11
|
+
return layout.slice().reverse().reduce((currentRender, layoutComponent) => h(layoutComponent, pageProps, [currentRender], key), child);
|
|
13
12
|
}
|
|
14
13
|
return h(layout, pageProps, child ? [child] : [], key);
|
|
15
14
|
}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
<script>import {
|
|
2
|
-
import { inertia } from "../index";
|
|
1
|
+
<script>import { inertia } from "../index";
|
|
3
2
|
export let href;
|
|
4
3
|
export let as = "a";
|
|
5
4
|
export let data = {};
|
|
@@ -11,17 +10,11 @@ export let only = [];
|
|
|
11
10
|
export let except = [];
|
|
12
11
|
export let headers = {};
|
|
13
12
|
export let queryStringArrayFormat = "brackets";
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
Please specify a more appropriate element using the "as" attribute. For example:
|
|
20
|
-
|
|
21
|
-
<Link href="${href}" method="${method}" as="button">...</Link>`
|
|
22
|
-
);
|
|
23
|
-
}
|
|
24
|
-
});
|
|
13
|
+
$: asProp = method !== "get" ? "button" : as.toLowerCase();
|
|
14
|
+
$: elProps = {
|
|
15
|
+
a: { href },
|
|
16
|
+
button: { type: "button" }
|
|
17
|
+
}[asProp] || {};
|
|
25
18
|
</script>
|
|
26
19
|
|
|
27
20
|
<!-- svelte-ignore a11y-no-static-element-interactions -->
|
|
@@ -39,8 +32,8 @@ Please specify a more appropriate element using the "as" attribute. For example:
|
|
|
39
32
|
headers,
|
|
40
33
|
queryStringArrayFormat,
|
|
41
34
|
}}
|
|
42
|
-
{...as === 'a' ? { href } : {}}
|
|
43
35
|
{...$$restProps}
|
|
36
|
+
{...elProps}
|
|
44
37
|
on:focus
|
|
45
38
|
on:blur
|
|
46
39
|
on:click
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { SvelteComponentTyped } from "svelte";
|
|
2
|
-
import type { Method, PreserveStateOption
|
|
2
|
+
import type { FormDataConvertible, Method, PreserveStateOption } from '@inertiajs/core';
|
|
3
3
|
declare const __propDef: {
|
|
4
4
|
props: {
|
|
5
5
|
[x: string]: any;
|
|
6
6
|
href: string;
|
|
7
7
|
as?: keyof HTMLElementTagNameMap | undefined;
|
|
8
|
-
data?:
|
|
8
|
+
data?: Record<string, FormDataConvertible> | undefined;
|
|
9
9
|
method?: Method | undefined;
|
|
10
10
|
replace?: boolean | undefined;
|
|
11
11
|
preserveScroll?: PreserveStateOption | undefined;
|
package/dist/createInertiaApp.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { router, setupProgress } from '@inertiajs/core';
|
|
2
2
|
import escape from 'html-escape';
|
|
3
|
-
import {
|
|
3
|
+
import { version as SVELTE_VERSION } from 'svelte/package.json';
|
|
4
4
|
import App from './components/App.svelte';
|
|
5
5
|
import store from './store';
|
|
6
6
|
export default async function createInertiaApp({ id = 'app', resolve, setup, progress = {}, page, }) {
|
|
@@ -16,7 +16,7 @@ export default async function createInertiaApp({ id = 'app', resolve, setup, pro
|
|
|
16
16
|
});
|
|
17
17
|
});
|
|
18
18
|
if (isServer) {
|
|
19
|
-
const isSvelte5 =
|
|
19
|
+
const isSvelte5 = SVELTE_VERSION.startsWith('5');
|
|
20
20
|
const { html, head, css } = await (async () => {
|
|
21
21
|
if (isSvelte5) {
|
|
22
22
|
const { render } = await dynamicImport('svelte/server');
|
package/dist/index.d.ts
CHANGED
|
@@ -4,4 +4,5 @@ export { default as createInertiaApp } from './createInertiaApp';
|
|
|
4
4
|
export { default as inertia } from './link';
|
|
5
5
|
export { default as page } from './page';
|
|
6
6
|
export { default as remember } from './remember';
|
|
7
|
+
export { type ResolvedComponent } from './types';
|
|
7
8
|
export { default as useForm, type InertiaForm, type InertiaFormProps } from './useForm';
|
package/dist/index.js
CHANGED
|
@@ -4,4 +4,5 @@ export { default as createInertiaApp } from './createInertiaApp';
|
|
|
4
4
|
export { default as inertia } from './link';
|
|
5
5
|
export { default as page } from './page';
|
|
6
6
|
export { default as remember } from './remember';
|
|
7
|
+
export {} from './types';
|
|
7
8
|
export { default as useForm } from './useForm';
|
package/dist/link.d.ts
CHANGED
|
@@ -1,10 +1,20 @@
|
|
|
1
|
-
import { type VisitOptions } from '@inertiajs/core';
|
|
2
|
-
import type {
|
|
1
|
+
import { type FormDataConvertible, type GlobalEventsMap, type VisitOptions } from '@inertiajs/core';
|
|
2
|
+
import type { CancelTokenSource } from 'axios';
|
|
3
|
+
import type { ActionReturn } from 'svelte/action';
|
|
3
4
|
interface ActionElement extends HTMLElement {
|
|
4
5
|
href?: string;
|
|
5
6
|
}
|
|
6
|
-
type ActionParameters = VisitOptions & {
|
|
7
|
+
type ActionParameters = Omit<VisitOptions, 'data'> & {
|
|
7
8
|
href?: string;
|
|
9
|
+
data?: Record<string, FormDataConvertible>;
|
|
8
10
|
};
|
|
9
|
-
|
|
11
|
+
type SelectedEventKeys = 'start' | 'progress' | 'finish' | 'before' | 'cancel' | 'success' | 'error';
|
|
12
|
+
type SelectedGlobalEventsMap = Pick<GlobalEventsMap, SelectedEventKeys>;
|
|
13
|
+
type ActionAttributes = {
|
|
14
|
+
[K in keyof SelectedGlobalEventsMap as `on:${K}` | `on${K}`]?: (event: CustomEvent<SelectedGlobalEventsMap[K]['details']>) => void;
|
|
15
|
+
} & {
|
|
16
|
+
'on:cancel-token'?: (event: CustomEvent<CancelTokenSource>) => void;
|
|
17
|
+
oncanceltoken?: (event: CustomEvent<CancelTokenSource>) => void;
|
|
18
|
+
};
|
|
19
|
+
declare function link(node: ActionElement, options?: ActionParameters): ActionReturn<ActionParameters, ActionAttributes>;
|
|
10
20
|
export default link;
|
package/dist/link.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { mergeDataIntoQueryString, router, shouldIntercept } from '@inertiajs/core';
|
|
2
|
-
|
|
1
|
+
import { mergeDataIntoQueryString, router, shouldIntercept, } from '@inertiajs/core';
|
|
2
|
+
function link(node, options = {}) {
|
|
3
3
|
const [href, data] = hrefAndData(options);
|
|
4
4
|
node.href = href;
|
|
5
5
|
options.data = data;
|
|
@@ -16,8 +16,8 @@ const link = (node, options = {}) => {
|
|
|
16
16
|
if (shouldIntercept(event)) {
|
|
17
17
|
event.preventDefault();
|
|
18
18
|
router.visit(node.href, {
|
|
19
|
-
onCancelToken: () => fireEvent('cancel-token'),
|
|
20
|
-
onBefore: (visit) => fireEvent('before', { detail: { visit } }),
|
|
19
|
+
onCancelToken: (token) => fireEvent('cancel-token', { detail: { token } }),
|
|
20
|
+
onBefore: (visit) => fireEvent('before', { cancelable: true, detail: { visit } }),
|
|
21
21
|
onStart: (visit) => fireEvent('start', { detail: { visit } }),
|
|
22
22
|
onProgress: (progress) => fireEvent('progress', { detail: { progress } }),
|
|
23
23
|
onFinish: (visit) => fireEvent('finish', { detail: { visit } }),
|
|
@@ -39,5 +39,5 @@ const link = (node, options = {}) => {
|
|
|
39
39
|
node.removeEventListener('click', visit);
|
|
40
40
|
},
|
|
41
41
|
};
|
|
42
|
-
}
|
|
42
|
+
}
|
|
43
43
|
export default link;
|
package/dist/page.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const page: import("svelte/store").Readable<import("@inertiajs/core").Page<import("@inertiajs/core").PageProps
|
|
1
|
+
declare const page: import("svelte/store").Readable<import("@inertiajs/core").Page<import("@inertiajs/core").PageProps>>;
|
|
2
2
|
export default page;
|
package/dist/store.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { Page } from '@inertiajs/core';
|
|
2
2
|
import type { ResolvedComponent } from './types';
|
|
3
3
|
export interface InertiaStore {
|
|
4
|
-
component: ResolvedComponent
|
|
5
|
-
page: Page
|
|
4
|
+
component: ResolvedComponent;
|
|
5
|
+
page: Page;
|
|
6
6
|
key: number | null;
|
|
7
7
|
}
|
|
8
8
|
declare const store: import("svelte/store").Writable<InertiaStore>;
|
package/dist/types.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { ComponentType } from 'svelte';
|
|
2
2
|
export type ComponentResolver = (name: string) => ResolvedComponent | Promise<ResolvedComponent>;
|
|
3
|
+
export type LayoutType = ComponentType | ComponentType[];
|
|
3
4
|
export type ResolvedComponent = {
|
|
4
|
-
default
|
|
5
|
-
layout?:
|
|
5
|
+
default: ComponentType;
|
|
6
|
+
layout?: LayoutType;
|
|
6
7
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@inertiajs/svelte",
|
|
3
|
-
"version": "1.3.0-beta.
|
|
3
|
+
"version": "1.3.0-beta.2",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "The Svelte adapter for Inertia.js",
|
|
6
6
|
"contributors": [
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
"svelte": "^3.20.0 || ^4.0.0 || ^5.0.0 || ^5.0.0-next.244"
|
|
44
44
|
},
|
|
45
45
|
"dependencies": {
|
|
46
|
-
"@inertiajs/core": "1.3.0-beta.
|
|
46
|
+
"@inertiajs/core": "1.3.0-beta.2",
|
|
47
47
|
"html-escape": "^2.0.0",
|
|
48
48
|
"lodash": "^4.5.0"
|
|
49
49
|
},
|