@inertiajs/vue3 3.0.0-beta.2 → 3.0.0-beta.4
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/index.js +279 -277
- package/dist/index.js.map +3 -3
- package/package.json +5 -6
- package/types/app.d.ts +2 -1
- package/types/createInertiaApp.d.ts +17 -8
- package/types/deferred.d.ts +3 -9
- package/types/index.d.ts +2 -2
- package/types/layoutProps.d.ts +13 -12
- package/types/types.d.ts +3 -1
- package/types/useHttp.d.ts +6 -6
- package/types/whenVisible.d.ts +5 -10
package/dist/index.js
CHANGED
|
@@ -9,8 +9,8 @@ import {
|
|
|
9
9
|
router as router4
|
|
10
10
|
} from "@inertiajs/core";
|
|
11
11
|
import {
|
|
12
|
-
computed
|
|
13
|
-
defineComponent
|
|
12
|
+
computed,
|
|
13
|
+
defineComponent,
|
|
14
14
|
h,
|
|
15
15
|
markRaw,
|
|
16
16
|
reactive as reactive2,
|
|
@@ -19,8 +19,8 @@ import {
|
|
|
19
19
|
} from "vue";
|
|
20
20
|
|
|
21
21
|
// src/layoutProps.ts
|
|
22
|
-
import { createLayoutPropsStore
|
|
23
|
-
import {
|
|
22
|
+
import { createLayoutPropsStore } from "@inertiajs/core";
|
|
23
|
+
import { ref } from "vue";
|
|
24
24
|
var store = createLayoutPropsStore();
|
|
25
25
|
var state = ref(store.get());
|
|
26
26
|
store.subscribe(() => {
|
|
@@ -34,31 +34,12 @@ function setLayoutPropsFor(name, props) {
|
|
|
34
34
|
}
|
|
35
35
|
function resetLayoutProps() {
|
|
36
36
|
store.reset();
|
|
37
|
-
|
|
38
|
-
var LAYOUT_CONTEXT_KEY = /* @__PURE__ */ Symbol("inertia-layout");
|
|
39
|
-
var LayoutProvider = defineComponent({
|
|
40
|
-
inheritAttrs: false,
|
|
41
|
-
props: {
|
|
42
|
-
layoutName: String
|
|
43
|
-
},
|
|
44
|
-
setup(props, { slots }) {
|
|
45
|
-
provide(LAYOUT_CONTEXT_KEY, props.layoutName);
|
|
46
|
-
return () => slots.default?.();
|
|
47
|
-
}
|
|
48
|
-
});
|
|
49
|
-
function useLayoutProps(defaults) {
|
|
50
|
-
const attrs = useAttrs();
|
|
51
|
-
const name = inject(LAYOUT_CONTEXT_KEY, void 0);
|
|
52
|
-
return computed(() => {
|
|
53
|
-
const { shared, named } = state.value;
|
|
54
|
-
const dynamicProps = name ? { ...shared, ...named[name] } : shared;
|
|
55
|
-
return mergeLayoutProps(defaults, attrs, dynamicProps);
|
|
56
|
-
});
|
|
37
|
+
state.value = store.get();
|
|
57
38
|
}
|
|
58
39
|
|
|
59
40
|
// src/remember.ts
|
|
60
41
|
import { router } from "@inertiajs/core";
|
|
61
|
-
import { cloneDeep } from "
|
|
42
|
+
import { cloneDeep } from "es-toolkit";
|
|
62
43
|
var remember = {
|
|
63
44
|
created() {
|
|
64
45
|
if (!this.$options.remember) {
|
|
@@ -111,19 +92,20 @@ import {
|
|
|
111
92
|
router as router3,
|
|
112
93
|
UseFormUtils as UseFormUtils2
|
|
113
94
|
} from "@inertiajs/core";
|
|
114
|
-
import { cloneDeep as cloneDeep3 } from "
|
|
95
|
+
import { cloneDeep as cloneDeep3 } from "es-toolkit";
|
|
115
96
|
|
|
116
97
|
// src/useFormState.ts
|
|
117
98
|
import {
|
|
118
99
|
router as router2,
|
|
119
100
|
UseFormUtils
|
|
120
101
|
} from "@inertiajs/core";
|
|
102
|
+
import { cloneDeep as cloneDeep2, isEqual } from "es-toolkit";
|
|
103
|
+
import { get, has, set } from "es-toolkit/compat";
|
|
121
104
|
import {
|
|
122
105
|
createValidator,
|
|
123
106
|
resolveName,
|
|
124
107
|
toSimpleValidationErrors
|
|
125
108
|
} from "laravel-precognition";
|
|
126
|
-
import { cloneDeep as cloneDeep2, get, has, isEqual, set } from "lodash-es";
|
|
127
109
|
import { reactive, watch } from "vue";
|
|
128
110
|
function useFormState(options) {
|
|
129
111
|
const { data: dataOption, rememberKey } = options;
|
|
@@ -525,7 +507,7 @@ var pageAccessor = null;
|
|
|
525
507
|
var layout = shallowRef(null);
|
|
526
508
|
var key = ref2(void 0);
|
|
527
509
|
var headManager;
|
|
528
|
-
var App =
|
|
510
|
+
var App = defineComponent({
|
|
529
511
|
name: "Inertia",
|
|
530
512
|
props: {
|
|
531
513
|
initialPage: {
|
|
@@ -602,7 +584,13 @@ var App = defineComponent2({
|
|
|
602
584
|
if (component.value.layout && isRenderFunction(component.value.layout)) {
|
|
603
585
|
return component.value.layout(h, child);
|
|
604
586
|
}
|
|
605
|
-
|
|
587
|
+
let effectiveLayout;
|
|
588
|
+
const layoutValue = component.value.layout;
|
|
589
|
+
if (typeof layoutValue === "function" && layoutValue.length <= 1 && typeof layoutValue.prototype === "undefined") {
|
|
590
|
+
effectiveLayout = layoutValue(page.value.props);
|
|
591
|
+
} else {
|
|
592
|
+
effectiveLayout = layoutValue ?? defaultLayout?.(page.value.component, page.value);
|
|
593
|
+
}
|
|
606
594
|
if (effectiveLayout) {
|
|
607
595
|
const layouts = normalizeLayouts(
|
|
608
596
|
effectiveLayout,
|
|
@@ -610,13 +598,19 @@ var App = defineComponent2({
|
|
|
610
598
|
component.value.layout ? isRenderFunction : void 0
|
|
611
599
|
);
|
|
612
600
|
if (layouts.length > 0) {
|
|
601
|
+
const dynamicProps = isServer ? { shared: {}, named: {} } : state.value;
|
|
613
602
|
return layouts.reduceRight((childNode, layout2) => {
|
|
614
603
|
const layoutComponent = layout2.component;
|
|
615
604
|
layoutComponent.inheritAttrs = !!layoutComponent.inheritAttrs;
|
|
616
605
|
return h(
|
|
617
|
-
|
|
618
|
-
{
|
|
619
|
-
|
|
606
|
+
layoutComponent,
|
|
607
|
+
{
|
|
608
|
+
...page.value.props,
|
|
609
|
+
...layout2.props,
|
|
610
|
+
...dynamicProps.shared,
|
|
611
|
+
...layout2.name ? dynamicProps.named[layout2.name] || {} : {}
|
|
612
|
+
},
|
|
613
|
+
() => childNode
|
|
620
614
|
);
|
|
621
615
|
}, child);
|
|
622
616
|
}
|
|
@@ -639,19 +633,20 @@ var plugin = {
|
|
|
639
633
|
function usePage() {
|
|
640
634
|
if (!pageAccessor) {
|
|
641
635
|
pageAccessor = reactive2({
|
|
642
|
-
props:
|
|
643
|
-
url:
|
|
644
|
-
component:
|
|
645
|
-
version:
|
|
646
|
-
clearHistory:
|
|
647
|
-
deferredProps:
|
|
648
|
-
mergeProps:
|
|
649
|
-
prependProps:
|
|
650
|
-
deepMergeProps:
|
|
651
|
-
matchPropsOn:
|
|
652
|
-
rememberedState:
|
|
653
|
-
encryptHistory:
|
|
654
|
-
|
|
636
|
+
props: computed(() => page.value?.props),
|
|
637
|
+
url: computed(() => page.value?.url),
|
|
638
|
+
component: computed(() => page.value?.component),
|
|
639
|
+
version: computed(() => page.value?.version),
|
|
640
|
+
clearHistory: computed(() => page.value?.clearHistory),
|
|
641
|
+
deferredProps: computed(() => page.value?.deferredProps),
|
|
642
|
+
mergeProps: computed(() => page.value?.mergeProps),
|
|
643
|
+
prependProps: computed(() => page.value?.prependProps),
|
|
644
|
+
deepMergeProps: computed(() => page.value?.deepMergeProps),
|
|
645
|
+
matchPropsOn: computed(() => page.value?.matchPropsOn),
|
|
646
|
+
rememberedState: computed(() => page.value?.rememberedState),
|
|
647
|
+
encryptHistory: computed(() => page.value?.encryptHistory),
|
|
648
|
+
scrollProps: computed(() => page.value?.scrollProps),
|
|
649
|
+
flash: computed(() => page.value?.flash)
|
|
655
650
|
});
|
|
656
651
|
}
|
|
657
652
|
return pageAccessor;
|
|
@@ -676,7 +671,8 @@ async function createInertiaApp({
|
|
|
676
671
|
render,
|
|
677
672
|
defaults = {},
|
|
678
673
|
http: http3,
|
|
679
|
-
layout: layout2
|
|
674
|
+
layout: layout2,
|
|
675
|
+
withApp
|
|
680
676
|
} = {}) {
|
|
681
677
|
config.replace(defaults);
|
|
682
678
|
if (http3) {
|
|
@@ -707,6 +703,9 @@ async function createInertiaApp({
|
|
|
707
703
|
} else {
|
|
708
704
|
vueApp2 = createSSRApp({ render: () => h2(app_default, props) });
|
|
709
705
|
vueApp2.use(plugin);
|
|
706
|
+
if (withApp) {
|
|
707
|
+
withApp(vueApp2, { ssr: true });
|
|
708
|
+
}
|
|
710
709
|
}
|
|
711
710
|
const html = await renderToString(vueApp2);
|
|
712
711
|
const body = buildSSRBody(id, page3, html);
|
|
@@ -748,10 +747,16 @@ async function createInertiaApp({
|
|
|
748
747
|
if (el.hasAttribute("data-server-rendered")) {
|
|
749
748
|
const app = createSSRApp({ render: () => h2(app_default, props) });
|
|
750
749
|
app.use(plugin);
|
|
750
|
+
if (withApp) {
|
|
751
|
+
withApp(app, { ssr: false });
|
|
752
|
+
}
|
|
751
753
|
app.mount(el);
|
|
752
754
|
} else {
|
|
753
755
|
const app = createApp({ render: () => h2(app_default, props) });
|
|
754
756
|
app.use(plugin);
|
|
757
|
+
if (withApp) {
|
|
758
|
+
withApp(app, { ssr: false });
|
|
759
|
+
}
|
|
755
760
|
app.mount(el);
|
|
756
761
|
}
|
|
757
762
|
});
|
|
@@ -767,8 +772,8 @@ async function createInertiaApp({
|
|
|
767
772
|
|
|
768
773
|
// src/deferred.ts
|
|
769
774
|
import { isSameUrlWithoutQueryOrHash, router as router6 } from "@inertiajs/core";
|
|
770
|
-
import { get as get2 } from "
|
|
771
|
-
import { defineComponent as
|
|
775
|
+
import { get as get2 } from "es-toolkit/compat";
|
|
776
|
+
import { defineComponent as defineComponent2, onMounted, onUnmounted, ref as ref3 } from "vue";
|
|
772
777
|
var keysAreBeingReloaded = (only, except, keys) => {
|
|
773
778
|
if (only.length === 0 && except.length === 0) {
|
|
774
779
|
return true;
|
|
@@ -778,7 +783,7 @@ var keysAreBeingReloaded = (only, except, keys) => {
|
|
|
778
783
|
}
|
|
779
784
|
return keys.some((key2) => !except.includes(key2));
|
|
780
785
|
};
|
|
781
|
-
var deferred_default =
|
|
786
|
+
var deferred_default = defineComponent2({
|
|
782
787
|
name: "Deferred",
|
|
783
788
|
props: {
|
|
784
789
|
data: {
|
|
@@ -790,6 +795,7 @@ var deferred_default = defineComponent3({
|
|
|
790
795
|
setup(props, { slots }) {
|
|
791
796
|
const reloading = ref3(false);
|
|
792
797
|
const activeReloads = /* @__PURE__ */ new Set();
|
|
798
|
+
const page2 = usePage();
|
|
793
799
|
let removeStartListener = null;
|
|
794
800
|
let removeFinishListener = null;
|
|
795
801
|
onMounted(() => {
|
|
@@ -814,14 +820,13 @@ var deferred_default = defineComponent3({
|
|
|
814
820
|
removeFinishListener?.();
|
|
815
821
|
activeReloads.clear();
|
|
816
822
|
});
|
|
817
|
-
return
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
}
|
|
824
|
-
return keys.every((key2) => get2(this.$page.props, key2) !== void 0) ? this.$slots.default?.({ reloading: this.reloading }) : this.$slots.fallback({});
|
|
823
|
+
return () => {
|
|
824
|
+
const keys = Array.isArray(props.data) ? props.data : [props.data];
|
|
825
|
+
if (!slots.fallback) {
|
|
826
|
+
throw new Error("`<Deferred>` requires a `<template #fallback>` slot");
|
|
827
|
+
}
|
|
828
|
+
return keys.every((key2) => get2(page2.props, key2) !== void 0) ? slots.default?.({ reloading: reloading.value }) : slots.fallback({});
|
|
829
|
+
};
|
|
825
830
|
}
|
|
826
831
|
});
|
|
827
832
|
|
|
@@ -836,21 +841,21 @@ import {
|
|
|
836
841
|
resolveUrlMethodPairComponent,
|
|
837
842
|
UseFormUtils as UseFormUtils3
|
|
838
843
|
} from "@inertiajs/core";
|
|
839
|
-
import { isEqual as isEqual2 } from "
|
|
844
|
+
import { isEqual as isEqual2 } from "es-toolkit";
|
|
840
845
|
import {
|
|
841
|
-
computed as
|
|
842
|
-
defineComponent as
|
|
846
|
+
computed as computed2,
|
|
847
|
+
defineComponent as defineComponent3,
|
|
843
848
|
h as h3,
|
|
844
|
-
inject
|
|
849
|
+
inject,
|
|
845
850
|
onBeforeUnmount,
|
|
846
851
|
onMounted as onMounted2,
|
|
847
|
-
provide
|
|
852
|
+
provide,
|
|
848
853
|
ref as ref4,
|
|
849
854
|
watch as watch2
|
|
850
855
|
} from "vue";
|
|
851
856
|
var noop = () => void 0;
|
|
852
857
|
var FormContextKey = /* @__PURE__ */ Symbol("InertiaFormContext");
|
|
853
|
-
var Form =
|
|
858
|
+
var Form = defineComponent3({
|
|
854
859
|
name: "Form",
|
|
855
860
|
slots: Object,
|
|
856
861
|
props: {
|
|
@@ -983,10 +988,10 @@ var Form = defineComponent4({
|
|
|
983
988
|
form.withAllErrors();
|
|
984
989
|
}
|
|
985
990
|
const formElement = ref4();
|
|
986
|
-
const method =
|
|
991
|
+
const method = computed2(
|
|
987
992
|
() => isUrlMethodPair(props.action) ? props.action.method : props.method.toLowerCase()
|
|
988
993
|
);
|
|
989
|
-
const resolvedComponent =
|
|
994
|
+
const resolvedComponent = computed2(() => {
|
|
990
995
|
if (props.component) {
|
|
991
996
|
return props.component;
|
|
992
997
|
}
|
|
@@ -1133,7 +1138,7 @@ var Form = defineComponent4({
|
|
|
1133
1138
|
validator: () => form.validator()
|
|
1134
1139
|
};
|
|
1135
1140
|
expose(exposed);
|
|
1136
|
-
|
|
1141
|
+
provide(FormContextKey, exposed);
|
|
1137
1142
|
return () => {
|
|
1138
1143
|
return h3(
|
|
1139
1144
|
"form",
|
|
@@ -1154,7 +1159,7 @@ var Form = defineComponent4({
|
|
|
1154
1159
|
}
|
|
1155
1160
|
});
|
|
1156
1161
|
function useFormContext() {
|
|
1157
|
-
return
|
|
1162
|
+
return inject(FormContextKey);
|
|
1158
1163
|
}
|
|
1159
1164
|
function createForm() {
|
|
1160
1165
|
return Form;
|
|
@@ -1162,131 +1167,127 @@ function createForm() {
|
|
|
1162
1167
|
var form_default = Form;
|
|
1163
1168
|
|
|
1164
1169
|
// src/head.ts
|
|
1165
|
-
import { escape } from "
|
|
1166
|
-
import { defineComponent as
|
|
1167
|
-
|
|
1170
|
+
import { escape } from "es-toolkit/compat";
|
|
1171
|
+
import { defineComponent as defineComponent4, onBeforeUnmount as onBeforeUnmount2 } from "vue";
|
|
1172
|
+
function isUnaryTag(node) {
|
|
1173
|
+
return typeof node.type === "string" && [
|
|
1174
|
+
"area",
|
|
1175
|
+
"base",
|
|
1176
|
+
"br",
|
|
1177
|
+
"col",
|
|
1178
|
+
"embed",
|
|
1179
|
+
"hr",
|
|
1180
|
+
"img",
|
|
1181
|
+
"input",
|
|
1182
|
+
"keygen",
|
|
1183
|
+
"link",
|
|
1184
|
+
"meta",
|
|
1185
|
+
"param",
|
|
1186
|
+
"source",
|
|
1187
|
+
"track",
|
|
1188
|
+
"wbr"
|
|
1189
|
+
].indexOf(node.type) > -1;
|
|
1190
|
+
}
|
|
1191
|
+
function renderTagStart(node) {
|
|
1192
|
+
node.props = node.props || {};
|
|
1193
|
+
node.props["data-inertia"] = node.props["head-key"] !== void 0 ? node.props["head-key"] : "";
|
|
1194
|
+
const attrs = Object.keys(node.props).reduce((carry, name) => {
|
|
1195
|
+
const value = String(node.props[name]);
|
|
1196
|
+
if (["key", "head-key"].includes(name)) {
|
|
1197
|
+
return carry;
|
|
1198
|
+
} else if (value === "") {
|
|
1199
|
+
return carry + ` ${name}`;
|
|
1200
|
+
} else {
|
|
1201
|
+
return carry + ` ${name}="${escape(value)}"`;
|
|
1202
|
+
}
|
|
1203
|
+
}, "");
|
|
1204
|
+
return `<${String(node.type)}${attrs}>`;
|
|
1205
|
+
}
|
|
1206
|
+
function renderTagChildren(node) {
|
|
1207
|
+
const { children } = node;
|
|
1208
|
+
if (typeof children === "string") {
|
|
1209
|
+
return children;
|
|
1210
|
+
}
|
|
1211
|
+
if (Array.isArray(children)) {
|
|
1212
|
+
return children.reduce((html, child) => {
|
|
1213
|
+
return html + renderTag(child);
|
|
1214
|
+
}, "");
|
|
1215
|
+
}
|
|
1216
|
+
return "";
|
|
1217
|
+
}
|
|
1218
|
+
function isFunctionNode(node) {
|
|
1219
|
+
return typeof node.type === "function";
|
|
1220
|
+
}
|
|
1221
|
+
function isComponentNode(node) {
|
|
1222
|
+
return typeof node.type === "object";
|
|
1223
|
+
}
|
|
1224
|
+
function isCommentNode(node) {
|
|
1225
|
+
return /(comment|cmt)/i.test(node.type.toString());
|
|
1226
|
+
}
|
|
1227
|
+
function isFragmentNode(node) {
|
|
1228
|
+
return /(fragment|fgt|symbol\(\))/i.test(node.type.toString());
|
|
1229
|
+
}
|
|
1230
|
+
function isTextNode(node) {
|
|
1231
|
+
return /(text|txt)/i.test(node.type.toString());
|
|
1232
|
+
}
|
|
1233
|
+
function renderTag(node) {
|
|
1234
|
+
if (isTextNode(node)) {
|
|
1235
|
+
return String(node.children);
|
|
1236
|
+
} else if (isFragmentNode(node)) {
|
|
1237
|
+
return "";
|
|
1238
|
+
} else if (isCommentNode(node)) {
|
|
1239
|
+
return "";
|
|
1240
|
+
}
|
|
1241
|
+
let html = renderTagStart(node);
|
|
1242
|
+
if (node.children) {
|
|
1243
|
+
html += renderTagChildren(node);
|
|
1244
|
+
}
|
|
1245
|
+
if (!isUnaryTag(node)) {
|
|
1246
|
+
html += `</${String(node.type)}>`;
|
|
1247
|
+
}
|
|
1248
|
+
return html;
|
|
1249
|
+
}
|
|
1250
|
+
function addTitleElement(elements, title) {
|
|
1251
|
+
if (title && !elements.find((tag) => tag.startsWith("<title"))) {
|
|
1252
|
+
elements.push(`<title data-inertia="">${title}</title>`);
|
|
1253
|
+
}
|
|
1254
|
+
return elements;
|
|
1255
|
+
}
|
|
1256
|
+
function renderNodes(nodes, title) {
|
|
1257
|
+
const elements = nodes.flatMap((node) => resolveNode(node)).map((node) => renderTag(node)).filter((node) => node);
|
|
1258
|
+
return addTitleElement(elements, title);
|
|
1259
|
+
}
|
|
1260
|
+
function resolveNode(node) {
|
|
1261
|
+
if (isFunctionNode(node)) {
|
|
1262
|
+
return resolveNode(node.type());
|
|
1263
|
+
} else if (isComponentNode(node)) {
|
|
1264
|
+
console.warn(`Using components in the <Head> component is not supported.`);
|
|
1265
|
+
return [];
|
|
1266
|
+
} else if (isTextNode(node) && node.children) {
|
|
1267
|
+
return node;
|
|
1268
|
+
} else if (isFragmentNode(node) && node.children) {
|
|
1269
|
+
return node.children.flatMap((child) => resolveNode(child));
|
|
1270
|
+
} else if (isCommentNode(node)) {
|
|
1271
|
+
return [];
|
|
1272
|
+
} else {
|
|
1273
|
+
return node;
|
|
1274
|
+
}
|
|
1275
|
+
}
|
|
1276
|
+
var Head = defineComponent4({
|
|
1168
1277
|
props: {
|
|
1169
1278
|
title: {
|
|
1170
1279
|
type: String,
|
|
1171
1280
|
required: false
|
|
1172
1281
|
}
|
|
1173
1282
|
},
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1283
|
+
setup(props, { slots }) {
|
|
1284
|
+
const provider = headManager.createProvider();
|
|
1285
|
+
onBeforeUnmount2(() => {
|
|
1286
|
+
provider.disconnect();
|
|
1287
|
+
});
|
|
1288
|
+
return () => {
|
|
1289
|
+
provider.update(renderNodes(slots.default ? slots.default() : [], props.title));
|
|
1177
1290
|
};
|
|
1178
|
-
},
|
|
1179
|
-
beforeUnmount() {
|
|
1180
|
-
this.provider.disconnect();
|
|
1181
|
-
},
|
|
1182
|
-
methods: {
|
|
1183
|
-
isUnaryTag(node) {
|
|
1184
|
-
return typeof node.type === "string" && [
|
|
1185
|
-
"area",
|
|
1186
|
-
"base",
|
|
1187
|
-
"br",
|
|
1188
|
-
"col",
|
|
1189
|
-
"embed",
|
|
1190
|
-
"hr",
|
|
1191
|
-
"img",
|
|
1192
|
-
"input",
|
|
1193
|
-
"keygen",
|
|
1194
|
-
"link",
|
|
1195
|
-
"meta",
|
|
1196
|
-
"param",
|
|
1197
|
-
"source",
|
|
1198
|
-
"track",
|
|
1199
|
-
"wbr"
|
|
1200
|
-
].indexOf(node.type) > -1;
|
|
1201
|
-
},
|
|
1202
|
-
renderTagStart(node) {
|
|
1203
|
-
node.props = node.props || {};
|
|
1204
|
-
node.props["data-inertia"] = node.props["head-key"] !== void 0 ? node.props["head-key"] : "";
|
|
1205
|
-
const attrs = Object.keys(node.props).reduce((carry, name) => {
|
|
1206
|
-
const value = String(node.props[name]);
|
|
1207
|
-
if (["key", "head-key"].includes(name)) {
|
|
1208
|
-
return carry;
|
|
1209
|
-
} else if (value === "") {
|
|
1210
|
-
return carry + ` ${name}`;
|
|
1211
|
-
} else {
|
|
1212
|
-
return carry + ` ${name}="${escape(value)}"`;
|
|
1213
|
-
}
|
|
1214
|
-
}, "");
|
|
1215
|
-
return `<${String(node.type)}${attrs}>`;
|
|
1216
|
-
},
|
|
1217
|
-
renderTagChildren(node) {
|
|
1218
|
-
const { children } = node;
|
|
1219
|
-
if (typeof children === "string") {
|
|
1220
|
-
return children;
|
|
1221
|
-
}
|
|
1222
|
-
if (Array.isArray(children)) {
|
|
1223
|
-
return children.reduce((html, child) => {
|
|
1224
|
-
return html + this.renderTag(child);
|
|
1225
|
-
}, "");
|
|
1226
|
-
}
|
|
1227
|
-
return "";
|
|
1228
|
-
},
|
|
1229
|
-
isFunctionNode(node) {
|
|
1230
|
-
return typeof node.type === "function";
|
|
1231
|
-
},
|
|
1232
|
-
isComponentNode(node) {
|
|
1233
|
-
return typeof node.type === "object";
|
|
1234
|
-
},
|
|
1235
|
-
isCommentNode(node) {
|
|
1236
|
-
return /(comment|cmt)/i.test(node.type.toString());
|
|
1237
|
-
},
|
|
1238
|
-
isFragmentNode(node) {
|
|
1239
|
-
return /(fragment|fgt|symbol\(\))/i.test(node.type.toString());
|
|
1240
|
-
},
|
|
1241
|
-
isTextNode(node) {
|
|
1242
|
-
return /(text|txt)/i.test(node.type.toString());
|
|
1243
|
-
},
|
|
1244
|
-
renderTag(node) {
|
|
1245
|
-
if (this.isTextNode(node)) {
|
|
1246
|
-
return String(node.children);
|
|
1247
|
-
} else if (this.isFragmentNode(node)) {
|
|
1248
|
-
return "";
|
|
1249
|
-
} else if (this.isCommentNode(node)) {
|
|
1250
|
-
return "";
|
|
1251
|
-
}
|
|
1252
|
-
let html = this.renderTagStart(node);
|
|
1253
|
-
if (node.children) {
|
|
1254
|
-
html += this.renderTagChildren(node);
|
|
1255
|
-
}
|
|
1256
|
-
if (!this.isUnaryTag(node)) {
|
|
1257
|
-
html += `</${String(node.type)}>`;
|
|
1258
|
-
}
|
|
1259
|
-
return html;
|
|
1260
|
-
},
|
|
1261
|
-
addTitleElement(elements) {
|
|
1262
|
-
if (this.title && !elements.find((tag) => tag.startsWith("<title"))) {
|
|
1263
|
-
elements.push(`<title data-inertia="">${this.title}</title>`);
|
|
1264
|
-
}
|
|
1265
|
-
return elements;
|
|
1266
|
-
},
|
|
1267
|
-
renderNodes(nodes) {
|
|
1268
|
-
const elements = nodes.flatMap((node) => this.resolveNode(node)).map((node) => this.renderTag(node)).filter((node) => node);
|
|
1269
|
-
return this.addTitleElement(elements);
|
|
1270
|
-
},
|
|
1271
|
-
resolveNode(node) {
|
|
1272
|
-
if (this.isFunctionNode(node)) {
|
|
1273
|
-
return this.resolveNode(node.type());
|
|
1274
|
-
} else if (this.isComponentNode(node)) {
|
|
1275
|
-
console.warn(`Using components in the <Head> component is not supported.`);
|
|
1276
|
-
return [];
|
|
1277
|
-
} else if (this.isTextNode(node) && node.children) {
|
|
1278
|
-
return node;
|
|
1279
|
-
} else if (this.isFragmentNode(node) && node.children) {
|
|
1280
|
-
return node.children.flatMap((child) => this.resolveNode(child));
|
|
1281
|
-
} else if (this.isCommentNode(node)) {
|
|
1282
|
-
return [];
|
|
1283
|
-
} else {
|
|
1284
|
-
return node;
|
|
1285
|
-
}
|
|
1286
|
-
}
|
|
1287
|
-
},
|
|
1288
|
-
render() {
|
|
1289
|
-
this.provider.update(this.renderNodes(this.$slots.default ? this.$slots.default() : []));
|
|
1290
1291
|
}
|
|
1291
1292
|
});
|
|
1292
1293
|
var head_default = Head;
|
|
@@ -1296,7 +1297,7 @@ import {
|
|
|
1296
1297
|
getScrollableParent,
|
|
1297
1298
|
useInfiniteScroll
|
|
1298
1299
|
} from "@inertiajs/core";
|
|
1299
|
-
import { computed as
|
|
1300
|
+
import { computed as computed3, defineComponent as defineComponent5, Fragment, h as h4, onMounted as onMounted3, onUnmounted as onUnmounted2, ref as ref5, watch as watch3 } from "vue";
|
|
1300
1301
|
var resolveHTMLElement = (value, fallback) => {
|
|
1301
1302
|
if (!value) {
|
|
1302
1303
|
return fallback;
|
|
@@ -1309,7 +1310,7 @@ var resolveHTMLElement = (value, fallback) => {
|
|
|
1309
1310
|
}
|
|
1310
1311
|
return fallback;
|
|
1311
1312
|
};
|
|
1312
|
-
var InfiniteScroll =
|
|
1313
|
+
var InfiniteScroll = defineComponent5({
|
|
1313
1314
|
name: "InfiniteScroll",
|
|
1314
1315
|
slots: Object,
|
|
1315
1316
|
props: {
|
|
@@ -1375,14 +1376,14 @@ var InfiniteScroll = defineComponent6({
|
|
|
1375
1376
|
const itemsElementRef = ref5(null);
|
|
1376
1377
|
const startElementRef = ref5(null);
|
|
1377
1378
|
const endElementRef = ref5(null);
|
|
1378
|
-
const itemsElement =
|
|
1379
|
+
const itemsElement = computed3(
|
|
1379
1380
|
() => resolveHTMLElement(props.itemsElement, itemsElementRef.value)
|
|
1380
1381
|
);
|
|
1381
|
-
const scrollableParent =
|
|
1382
|
-
const startElement =
|
|
1382
|
+
const scrollableParent = computed3(() => getScrollableParent(itemsElement.value));
|
|
1383
|
+
const startElement = computed3(
|
|
1383
1384
|
() => resolveHTMLElement(props.startElement, startElementRef.value)
|
|
1384
1385
|
);
|
|
1385
|
-
const endElement =
|
|
1386
|
+
const endElement = computed3(() => resolveHTMLElement(props.endElement, endElementRef.value));
|
|
1386
1387
|
const loadingPrevious = ref5(false);
|
|
1387
1388
|
const loadingNext = ref5(false);
|
|
1388
1389
|
const requestCount = ref5(0);
|
|
@@ -1425,8 +1426,15 @@ var InfiniteScroll = defineComponent6({
|
|
|
1425
1426
|
onDataReset: syncStateFromDataManager
|
|
1426
1427
|
});
|
|
1427
1428
|
syncStateFromDataManager();
|
|
1428
|
-
|
|
1429
|
-
|
|
1429
|
+
if (typeof window === "undefined") {
|
|
1430
|
+
const scrollProp = usePage().scrollProps?.[props.data];
|
|
1431
|
+
if (scrollProp) {
|
|
1432
|
+
hasPreviousPage.value = !!scrollProp.previousPage;
|
|
1433
|
+
hasNextPage.value = !!scrollProp.nextPage;
|
|
1434
|
+
}
|
|
1435
|
+
}
|
|
1436
|
+
const autoLoad = computed3(() => !manualMode.value);
|
|
1437
|
+
const manualMode = computed3(
|
|
1430
1438
|
() => props.manual || props.manualAfter > 0 && requestCount.value >= props.manualAfter
|
|
1431
1439
|
);
|
|
1432
1440
|
const scrollToBottom = () => {
|
|
@@ -1536,10 +1544,10 @@ import {
|
|
|
1536
1544
|
shouldIntercept,
|
|
1537
1545
|
shouldNavigate
|
|
1538
1546
|
} from "@inertiajs/core";
|
|
1539
|
-
import { computed as
|
|
1547
|
+
import { computed as computed4, defineComponent as defineComponent6, h as h5, onMounted as onMounted4, onUnmounted as onUnmounted3, ref as ref6 } from "vue";
|
|
1540
1548
|
var noop2 = () => {
|
|
1541
1549
|
};
|
|
1542
|
-
var Link =
|
|
1550
|
+
var Link = defineComponent6({
|
|
1543
1551
|
name: "Link",
|
|
1544
1552
|
props: {
|
|
1545
1553
|
as: {
|
|
@@ -1666,7 +1674,7 @@ var Link = defineComponent7({
|
|
|
1666
1674
|
setup(props, { slots, attrs }) {
|
|
1667
1675
|
const inFlightCount = ref6(0);
|
|
1668
1676
|
const hoverTimeout = ref6();
|
|
1669
|
-
const prefetchModes =
|
|
1677
|
+
const prefetchModes = computed4(() => {
|
|
1670
1678
|
if (props.prefetch === true) {
|
|
1671
1679
|
return ["hover"];
|
|
1672
1680
|
}
|
|
@@ -1678,7 +1686,7 @@ var Link = defineComponent7({
|
|
|
1678
1686
|
}
|
|
1679
1687
|
return [props.prefetch];
|
|
1680
1688
|
});
|
|
1681
|
-
const cacheForValue =
|
|
1689
|
+
const cacheForValue = computed4(() => {
|
|
1682
1690
|
if (props.cacheFor !== 0) {
|
|
1683
1691
|
return props.cacheFor;
|
|
1684
1692
|
}
|
|
@@ -1695,16 +1703,16 @@ var Link = defineComponent7({
|
|
|
1695
1703
|
onUnmounted3(() => {
|
|
1696
1704
|
clearTimeout(hoverTimeout.value);
|
|
1697
1705
|
});
|
|
1698
|
-
const method =
|
|
1706
|
+
const method = computed4(
|
|
1699
1707
|
() => isUrlMethodPair2(props.href) ? props.href.method : (props.method ?? "get").toLowerCase()
|
|
1700
1708
|
);
|
|
1701
|
-
const as =
|
|
1709
|
+
const as = computed4(() => {
|
|
1702
1710
|
if (typeof props.as !== "string" || props.as.toLowerCase() !== "a") {
|
|
1703
1711
|
return props.as;
|
|
1704
1712
|
}
|
|
1705
1713
|
return method.value !== "get" ? "button" : props.as.toLowerCase();
|
|
1706
1714
|
});
|
|
1707
|
-
const mergeDataArray =
|
|
1715
|
+
const mergeDataArray = computed4(
|
|
1708
1716
|
() => mergeDataIntoQueryString2(
|
|
1709
1717
|
method.value,
|
|
1710
1718
|
isUrlMethodPair2(props.href) ? props.href.url : props.href,
|
|
@@ -1712,9 +1720,9 @@ var Link = defineComponent7({
|
|
|
1712
1720
|
props.queryStringArrayFormat
|
|
1713
1721
|
)
|
|
1714
1722
|
);
|
|
1715
|
-
const href =
|
|
1716
|
-
const data =
|
|
1717
|
-
const resolvedComponent =
|
|
1723
|
+
const href = computed4(() => mergeDataArray.value[0]);
|
|
1724
|
+
const data = computed4(() => mergeDataArray.value[1]);
|
|
1725
|
+
const resolvedComponent = computed4(() => {
|
|
1718
1726
|
if (props.component) {
|
|
1719
1727
|
return props.component;
|
|
1720
1728
|
}
|
|
@@ -1723,7 +1731,7 @@ var Link = defineComponent7({
|
|
|
1723
1731
|
}
|
|
1724
1732
|
return null;
|
|
1725
1733
|
});
|
|
1726
|
-
const elProps =
|
|
1734
|
+
const elProps = computed4(() => {
|
|
1727
1735
|
if (as.value === "button") {
|
|
1728
1736
|
return { type: "button" };
|
|
1729
1737
|
}
|
|
@@ -1732,7 +1740,7 @@ var Link = defineComponent7({
|
|
|
1732
1740
|
}
|
|
1733
1741
|
return {};
|
|
1734
1742
|
});
|
|
1735
|
-
const baseParams =
|
|
1743
|
+
const baseParams = computed4(() => ({
|
|
1736
1744
|
data: data.value,
|
|
1737
1745
|
method: method.value,
|
|
1738
1746
|
replace: props.replace,
|
|
@@ -1746,7 +1754,7 @@ var Link = defineComponent7({
|
|
|
1746
1754
|
component: resolvedComponent.value,
|
|
1747
1755
|
pageProps: props.pageProps
|
|
1748
1756
|
}));
|
|
1749
|
-
const visitParams =
|
|
1757
|
+
const visitParams = computed4(() => ({
|
|
1750
1758
|
...baseParams.value,
|
|
1751
1759
|
viewTransition: props.viewTransition,
|
|
1752
1760
|
onCancelToken: props.onCancelToken,
|
|
@@ -1862,8 +1870,8 @@ import {
|
|
|
1862
1870
|
objectToFormData,
|
|
1863
1871
|
UseFormUtils as UseFormUtils4
|
|
1864
1872
|
} from "@inertiajs/core";
|
|
1873
|
+
import { cloneDeep as cloneDeep4 } from "es-toolkit";
|
|
1865
1874
|
import { toSimpleValidationErrors as toSimpleValidationErrors2 } from "laravel-precognition";
|
|
1866
|
-
import { cloneDeep as cloneDeep4 } from "lodash-es";
|
|
1867
1875
|
function useHttp(...args) {
|
|
1868
1876
|
const { rememberKey, data, precognitionEndpoint } = UseFormUtils4.parseUseFormArguments(...args);
|
|
1869
1877
|
let abortController = null;
|
|
@@ -1949,7 +1957,7 @@ function useHttp(...args) {
|
|
|
1949
1957
|
options.onProgress?.(event);
|
|
1950
1958
|
}
|
|
1951
1959
|
});
|
|
1952
|
-
const responseData = JSON.parse(response.data);
|
|
1960
|
+
const responseData = response.data ? JSON.parse(response.data) : null;
|
|
1953
1961
|
if (response.status >= 200 && response.status < 300) {
|
|
1954
1962
|
markAsSuccessful();
|
|
1955
1963
|
form.response = responseData;
|
|
@@ -2094,7 +2102,7 @@ function usePrefetch(options = {}) {
|
|
|
2094
2102
|
|
|
2095
2103
|
// src/useRemember.ts
|
|
2096
2104
|
import { router as router10 } from "@inertiajs/core";
|
|
2097
|
-
import { cloneDeep as cloneDeep5 } from "
|
|
2105
|
+
import { cloneDeep as cloneDeep5 } from "es-toolkit";
|
|
2098
2106
|
import { isReactive, reactive as reactive3, ref as ref8, watch as watch4 } from "vue";
|
|
2099
2107
|
function useRemember(data, key2) {
|
|
2100
2108
|
if (typeof data === "object" && data !== null && data.__rememberable === false) {
|
|
@@ -2118,9 +2126,9 @@ function useRemember(data, key2) {
|
|
|
2118
2126
|
|
|
2119
2127
|
// src/whenVisible.ts
|
|
2120
2128
|
import { router as router11 } from "@inertiajs/core";
|
|
2121
|
-
import { get as get3 } from "
|
|
2122
|
-
import { defineComponent as
|
|
2123
|
-
var whenVisible_default =
|
|
2129
|
+
import { get as get3 } from "es-toolkit/compat";
|
|
2130
|
+
import { computed as computed5, defineComponent as defineComponent7, h as h6, nextTick, onUnmounted as onUnmounted6, ref as ref9, watch as watch5 } from "vue";
|
|
2131
|
+
var whenVisible_default = defineComponent7({
|
|
2124
2132
|
name: "WhenVisible",
|
|
2125
2133
|
slots: Object,
|
|
2126
2134
|
props: {
|
|
@@ -2143,95 +2151,90 @@ var whenVisible_default = defineComponent8({
|
|
|
2143
2151
|
default: false
|
|
2144
2152
|
}
|
|
2145
2153
|
},
|
|
2146
|
-
|
|
2147
|
-
|
|
2148
|
-
|
|
2149
|
-
|
|
2150
|
-
|
|
2151
|
-
};
|
|
2152
|
-
},
|
|
2153
|
-
unmounted() {
|
|
2154
|
-
this.observer?.disconnect();
|
|
2155
|
-
},
|
|
2156
|
-
computed: {
|
|
2157
|
-
keys() {
|
|
2158
|
-
return this.data ? Array.isArray(this.data) ? this.data : [this.data] : [];
|
|
2159
|
-
}
|
|
2160
|
-
},
|
|
2161
|
-
created() {
|
|
2154
|
+
setup(props, { slots }) {
|
|
2155
|
+
const loaded = ref9(false);
|
|
2156
|
+
const fetching = ref9(false);
|
|
2157
|
+
const observer = ref9(null);
|
|
2158
|
+
const elementRef = ref9(null);
|
|
2162
2159
|
const page2 = usePage();
|
|
2163
|
-
|
|
2164
|
-
|
|
2165
|
-
|
|
2166
|
-
|
|
2167
|
-
|
|
2168
|
-
|
|
2169
|
-
|
|
2170
|
-
|
|
2171
|
-
|
|
2172
|
-
|
|
2173
|
-
|
|
2174
|
-
|
|
2175
|
-
|
|
2176
|
-
);
|
|
2177
|
-
},
|
|
2178
|
-
methods: {
|
|
2179
|
-
registerObserver() {
|
|
2180
|
-
this.observer?.disconnect();
|
|
2181
|
-
this.observer = new IntersectionObserver(
|
|
2160
|
+
const keys = computed5(() => {
|
|
2161
|
+
return props.data ? Array.isArray(props.data) ? props.data : [props.data] : [];
|
|
2162
|
+
});
|
|
2163
|
+
function getReloadParams() {
|
|
2164
|
+
const reloadParams = { preserveErrors: true, ...props.params };
|
|
2165
|
+
if (props.data) {
|
|
2166
|
+
reloadParams.only = Array.isArray(props.data) ? props.data : [props.data];
|
|
2167
|
+
}
|
|
2168
|
+
return reloadParams;
|
|
2169
|
+
}
|
|
2170
|
+
function registerObserver() {
|
|
2171
|
+
observer.value?.disconnect();
|
|
2172
|
+
observer.value = new IntersectionObserver(
|
|
2182
2173
|
(entries) => {
|
|
2183
2174
|
if (!entries[0].isIntersecting) {
|
|
2184
2175
|
return;
|
|
2185
2176
|
}
|
|
2186
|
-
if (
|
|
2177
|
+
if (fetching.value) {
|
|
2187
2178
|
return;
|
|
2188
2179
|
}
|
|
2189
|
-
if (!
|
|
2180
|
+
if (!props.always && loaded.value) {
|
|
2190
2181
|
return;
|
|
2191
2182
|
}
|
|
2192
|
-
|
|
2193
|
-
const reloadParams =
|
|
2183
|
+
fetching.value = true;
|
|
2184
|
+
const reloadParams = getReloadParams();
|
|
2194
2185
|
router11.reload({
|
|
2195
2186
|
...reloadParams,
|
|
2196
2187
|
onStart: (e) => {
|
|
2197
|
-
|
|
2188
|
+
fetching.value = true;
|
|
2198
2189
|
reloadParams.onStart?.(e);
|
|
2199
2190
|
},
|
|
2200
2191
|
onFinish: (e) => {
|
|
2201
|
-
|
|
2202
|
-
|
|
2192
|
+
loaded.value = true;
|
|
2193
|
+
fetching.value = false;
|
|
2203
2194
|
reloadParams.onFinish?.(e);
|
|
2204
|
-
if (!
|
|
2205
|
-
|
|
2195
|
+
if (!props.always) {
|
|
2196
|
+
observer.value?.disconnect();
|
|
2206
2197
|
}
|
|
2207
2198
|
}
|
|
2208
2199
|
});
|
|
2209
2200
|
},
|
|
2210
2201
|
{
|
|
2211
|
-
rootMargin: `${
|
|
2202
|
+
rootMargin: `${props.buffer}px`
|
|
2212
2203
|
}
|
|
2213
2204
|
);
|
|
2214
|
-
|
|
2215
|
-
|
|
2216
|
-
getReloadParams() {
|
|
2217
|
-
const reloadParams = { preserveErrors: true, ...this.$props.params };
|
|
2218
|
-
if (this.$props.data) {
|
|
2219
|
-
reloadParams.only = Array.isArray(this.$props.data) ? this.$props.data : [this.$props.data];
|
|
2205
|
+
if (elementRef.value) {
|
|
2206
|
+
observer.value.observe(elementRef.value);
|
|
2220
2207
|
}
|
|
2221
|
-
return reloadParams;
|
|
2222
|
-
}
|
|
2223
|
-
},
|
|
2224
|
-
render() {
|
|
2225
|
-
const els = [];
|
|
2226
|
-
if (this.$props.always || !this.loaded) {
|
|
2227
|
-
els.push(h6(this.$props.as));
|
|
2228
2208
|
}
|
|
2229
|
-
|
|
2230
|
-
|
|
2231
|
-
|
|
2232
|
-
|
|
2233
|
-
|
|
2234
|
-
|
|
2209
|
+
watch5(
|
|
2210
|
+
() => keys.value.map((key2) => get3(page2.props, key2)),
|
|
2211
|
+
() => {
|
|
2212
|
+
const exists = keys.value.length > 0 && keys.value.every((key2) => get3(page2.props, key2) !== void 0);
|
|
2213
|
+
loaded.value = exists;
|
|
2214
|
+
if (exists && !props.always) {
|
|
2215
|
+
return;
|
|
2216
|
+
}
|
|
2217
|
+
if (!observer.value || !exists) {
|
|
2218
|
+
nextTick(registerObserver);
|
|
2219
|
+
}
|
|
2220
|
+
},
|
|
2221
|
+
{ immediate: true }
|
|
2222
|
+
);
|
|
2223
|
+
onUnmounted6(() => {
|
|
2224
|
+
observer.value?.disconnect();
|
|
2225
|
+
});
|
|
2226
|
+
return () => {
|
|
2227
|
+
const els = [];
|
|
2228
|
+
if (props.always || !loaded.value) {
|
|
2229
|
+
els.push(h6(props.as, { ref: elementRef }));
|
|
2230
|
+
}
|
|
2231
|
+
if (!loaded.value) {
|
|
2232
|
+
els.push(slots.fallback ? slots.fallback({}) : null);
|
|
2233
|
+
} else if (slots.default) {
|
|
2234
|
+
els.push(slots.default({ fetching: fetching.value }));
|
|
2235
|
+
}
|
|
2236
|
+
return els;
|
|
2237
|
+
};
|
|
2235
2238
|
}
|
|
2236
2239
|
});
|
|
2237
2240
|
|
|
@@ -2257,7 +2260,6 @@ export {
|
|
|
2257
2260
|
useForm,
|
|
2258
2261
|
useFormContext,
|
|
2259
2262
|
useHttp,
|
|
2260
|
-
useLayoutProps,
|
|
2261
2263
|
usePage,
|
|
2262
2264
|
usePoll,
|
|
2263
2265
|
usePrefetch,
|