tinacms 0.66.2 → 0.66.5
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/CHANGELOG.md +28 -0
- package/dist/admin/components/GetCollection.d.ts +4 -1
- package/dist/admin/components/GetCollections.d.ts +0 -1
- package/dist/admin/components/GetDocument.d.ts +4 -1
- package/dist/admin/components/GetDocumentFields.d.ts +10 -1
- package/dist/admin/components/LoadingPage.d.ts +14 -0
- package/dist/index.es.js +212 -160
- package/dist/index.js +211 -159
- package/dist/rich-text.es.js +0 -1
- package/dist/rich-text.js +0 -1
- package/dist/style.css +22 -29
- package/package.json +2 -2
package/dist/index.es.js
CHANGED
|
@@ -40,7 +40,7 @@ import * as yup from "yup";
|
|
|
40
40
|
import { setEditing, TinaDataContext, useEditState } from "@tinacms/sharedctx";
|
|
41
41
|
import { getIn, setIn } from "final-form";
|
|
42
42
|
import UrlPattern from "url-pattern";
|
|
43
|
-
import { NavLink,
|
|
43
|
+
import { NavLink, useNavigate, useParams, Link, BrowserRouter, Routes, Route } from "react-router-dom";
|
|
44
44
|
import { Menu, Transition } from "@headlessui/react";
|
|
45
45
|
function popupWindow(url, title, window2, w, h) {
|
|
46
46
|
const y = window2.top.outerHeight / 2 + window2.top.screenY - h / 2;
|
|
@@ -519,7 +519,7 @@ mutation addPendingDocumentMutation(
|
|
|
519
519
|
async getRefreshedToken(tokens) {
|
|
520
520
|
const { access_token, id_token, refresh_token } = JSON.parse(tokens);
|
|
521
521
|
const { exp, iss, client_id } = this.parseJwt(access_token);
|
|
522
|
-
if (Date.now() / 1e3 >= exp) {
|
|
522
|
+
if (Date.now() / 1e3 >= exp - 120) {
|
|
523
523
|
const refreshResponse = await fetch(iss, {
|
|
524
524
|
method: "POST",
|
|
525
525
|
headers: {
|
|
@@ -877,6 +877,9 @@ const TinaCloudProvider = (props) => {
|
|
|
877
877
|
if (!cms.api.tina) {
|
|
878
878
|
cms.registerApi("tina", createClient(props));
|
|
879
879
|
}
|
|
880
|
+
if (!cms.api.admin) {
|
|
881
|
+
cms.registerApi("admin", new TinaAdminApi(cms));
|
|
882
|
+
}
|
|
880
883
|
const setupMedia = async () => {
|
|
881
884
|
var _a;
|
|
882
885
|
if (props.mediaStore) {
|
|
@@ -901,11 +904,6 @@ const TinaCloudProvider = (props) => {
|
|
|
901
904
|
return newBranch;
|
|
902
905
|
};
|
|
903
906
|
setupMedia();
|
|
904
|
-
React.useMemo(() => {
|
|
905
|
-
if (cms.flags.get("tina-admin") === true) {
|
|
906
|
-
cms.registerApi("admin", new TinaAdminApi(cms));
|
|
907
|
-
}
|
|
908
|
-
}, [cms, cms.flags.get("tina-admin")]);
|
|
909
907
|
const [branchingEnabled, setBranchingEnabled] = React.useState(() => cms.flags.get("branch-switcher"));
|
|
910
908
|
React.useEffect(() => {
|
|
911
909
|
cms.events.subscribe("flag:set", ({ key, value }) => {
|
|
@@ -2112,6 +2110,10 @@ Document
|
|
|
2112
2110
|
height: 20px !important;
|
|
2113
2111
|
}
|
|
2114
2112
|
|
|
2113
|
+
.tina-tailwind .h-12 {
|
|
2114
|
+
height: 48px !important;
|
|
2115
|
+
}
|
|
2116
|
+
|
|
2115
2117
|
.tina-tailwind .w-full {
|
|
2116
2118
|
width: 100% !important;
|
|
2117
2119
|
}
|
|
@@ -2132,10 +2134,6 @@ Document
|
|
|
2132
2134
|
width: 224px !important;
|
|
2133
2135
|
}
|
|
2134
2136
|
|
|
2135
|
-
.tina-tailwind .w-0 {
|
|
2136
|
-
width: 0px !important;
|
|
2137
|
-
}
|
|
2138
|
-
|
|
2139
2137
|
.tina-tailwind .w-6 {
|
|
2140
2138
|
width: 24px !important;
|
|
2141
2139
|
}
|
|
@@ -2160,6 +2158,14 @@ Document
|
|
|
2160
2158
|
flex: 1 1 0% !important;
|
|
2161
2159
|
}
|
|
2162
2160
|
|
|
2161
|
+
.tina-tailwind .flex-shrink-0 {
|
|
2162
|
+
flex-shrink: 0 !important;
|
|
2163
|
+
}
|
|
2164
|
+
|
|
2165
|
+
.tina-tailwind .flex-grow-0 {
|
|
2166
|
+
flex-grow: 0 !important;
|
|
2167
|
+
}
|
|
2168
|
+
|
|
2163
2169
|
.tina-tailwind .table-auto {
|
|
2164
2170
|
table-layout: auto !important;
|
|
2165
2171
|
}
|
|
@@ -2199,6 +2205,10 @@ Document
|
|
|
2199
2205
|
transform: var(--tw-transform) !important;
|
|
2200
2206
|
}
|
|
2201
2207
|
|
|
2208
|
+
.tina-tailwind .cursor-pointer {
|
|
2209
|
+
cursor: pointer !important;
|
|
2210
|
+
}
|
|
2211
|
+
|
|
2202
2212
|
.tina-tailwind .flex-col {
|
|
2203
2213
|
flex-direction: column !important;
|
|
2204
2214
|
}
|
|
@@ -2215,6 +2225,10 @@ Document
|
|
|
2215
2225
|
align-items: stretch !important;
|
|
2216
2226
|
}
|
|
2217
2227
|
|
|
2228
|
+
.tina-tailwind .justify-end {
|
|
2229
|
+
justify-content: flex-end !important;
|
|
2230
|
+
}
|
|
2231
|
+
|
|
2218
2232
|
.tina-tailwind .justify-center {
|
|
2219
2233
|
justify-content: center !important;
|
|
2220
2234
|
}
|
|
@@ -2282,10 +2296,6 @@ Document
|
|
|
2282
2296
|
border-color: rgba(225, 221, 236, var(--tw-border-opacity)) !important;
|
|
2283
2297
|
}
|
|
2284
2298
|
|
|
2285
|
-
.tina-tailwind .border-transparent {
|
|
2286
|
-
border-color: transparent !important;
|
|
2287
|
-
}
|
|
2288
|
-
|
|
2289
2299
|
.tina-tailwind .bg-white {
|
|
2290
2300
|
--tw-bg-opacity: 1 !important;
|
|
2291
2301
|
background-color: rgba(255, 255, 255, var(--tw-bg-opacity)) !important;
|
|
@@ -2369,9 +2379,8 @@ Document
|
|
|
2369
2379
|
padding-bottom: 12px !important;
|
|
2370
2380
|
}
|
|
2371
2381
|
|
|
2372
|
-
.tina-tailwind .
|
|
2373
|
-
padding-
|
|
2374
|
-
padding-right: 32px !important;
|
|
2382
|
+
.tina-tailwind .pt-4 {
|
|
2383
|
+
padding-top: 16px !important;
|
|
2375
2384
|
}
|
|
2376
2385
|
|
|
2377
2386
|
.tina-tailwind .pb-4 {
|
|
@@ -2448,10 +2457,6 @@ Document
|
|
|
2448
2457
|
line-height: 20px !important;
|
|
2449
2458
|
}
|
|
2450
2459
|
|
|
2451
|
-
.tina-tailwind .leading-4 {
|
|
2452
|
-
line-height: 16px !important;
|
|
2453
|
-
}
|
|
2454
|
-
|
|
2455
2460
|
.tina-tailwind .tracking-wide {
|
|
2456
2461
|
letter-spacing: 0.025em !important;
|
|
2457
2462
|
}
|
|
@@ -2553,11 +2558,6 @@ Document
|
|
|
2553
2558
|
box-shadow: var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow) !important;
|
|
2554
2559
|
}
|
|
2555
2560
|
|
|
2556
|
-
.tina-tailwind .shadow-sm {
|
|
2557
|
-
--tw-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05) !important;
|
|
2558
|
-
box-shadow: var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow) !important;
|
|
2559
|
-
}
|
|
2560
|
-
|
|
2561
2561
|
.tina-tailwind .ring-1 {
|
|
2562
2562
|
--tw-ring-offset-shadow: var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color) !important;
|
|
2563
2563
|
--tw-ring-shadow: var(--tw-ring-inset) 0 0 0 calc(1px + var(--tw-ring-offset-width)) var(--tw-ring-color) !important;
|
|
@@ -2652,11 +2652,6 @@ Document
|
|
|
2652
2652
|
background-color: rgba(5, 116, 228, var(--tw-bg-opacity)) !important;
|
|
2653
2653
|
}
|
|
2654
2654
|
|
|
2655
|
-
.hover\\:bg-gray-50:hover {
|
|
2656
|
-
--tw-bg-opacity: 1 !important;
|
|
2657
|
-
background-color: rgba(246, 246, 249, var(--tw-bg-opacity)) !important;
|
|
2658
|
-
}
|
|
2659
|
-
|
|
2660
2655
|
.hover\\:text-blue-600:hover {
|
|
2661
2656
|
--tw-text-opacity: 1 !important;
|
|
2662
2657
|
color: rgba(5, 116, 228, var(--tw-text-opacity)) !important;
|
|
@@ -2671,10 +2666,6 @@ Document
|
|
|
2671
2666
|
opacity: 1 !important;
|
|
2672
2667
|
}
|
|
2673
2668
|
|
|
2674
|
-
.hover\\:opacity-80:hover {
|
|
2675
|
-
opacity: .8 !important;
|
|
2676
|
-
}
|
|
2677
|
-
|
|
2678
2669
|
.focus\\:text-blue-400:focus {
|
|
2679
2670
|
--tw-text-opacity: 1 !important;
|
|
2680
2671
|
color: rgba(34, 150, 254, var(--tw-text-opacity)) !important;
|
|
@@ -3161,41 +3152,29 @@ function ImFilesEmpty(props) {
|
|
|
3161
3152
|
}
|
|
3162
3153
|
const useGetCollections = (cms) => {
|
|
3163
3154
|
const api = new TinaAdminApi(cms);
|
|
3164
|
-
const [
|
|
3155
|
+
const [collections, setCollections] = useState([]);
|
|
3156
|
+
const [loading, setLoading] = useState(true);
|
|
3165
3157
|
useEffect(() => {
|
|
3166
3158
|
const fetchCollections = async () => {
|
|
3167
3159
|
const response = await api.fetchCollections();
|
|
3168
|
-
|
|
3169
|
-
|
|
3170
|
-
loading: false,
|
|
3171
|
-
error: false
|
|
3172
|
-
});
|
|
3160
|
+
setCollections(response.getCollections);
|
|
3161
|
+
setLoading(false);
|
|
3173
3162
|
};
|
|
3163
|
+
setLoading(true);
|
|
3174
3164
|
fetchCollections();
|
|
3175
3165
|
}, [cms]);
|
|
3176
|
-
return
|
|
3177
|
-
};
|
|
3178
|
-
const GetCollections = ({ cms, children }) => {
|
|
3179
|
-
const { collections, loading, error } = useGetCollections(cms);
|
|
3180
|
-
if (!collections)
|
|
3181
|
-
return null;
|
|
3182
|
-
return /* @__PURE__ */ React.createElement(React.Fragment, null, children(collections, loading, error));
|
|
3166
|
+
return { collections, loading };
|
|
3183
3167
|
};
|
|
3184
3168
|
const slugify = (text) => {
|
|
3185
3169
|
return text.toString().toLowerCase().trim().replace(/[^\w\s-]/g, "").replace(/[\s_-]+/g, "_").replace(/^-+|-+$/g, "");
|
|
3186
3170
|
};
|
|
3187
3171
|
const Sidebar = ({ cms }) => {
|
|
3172
|
+
const collectionsInfo = useGetCollections(cms);
|
|
3188
3173
|
const screens = cms.plugins.getType("screen").all();
|
|
3189
|
-
return /* @__PURE__ */ React.createElement(
|
|
3190
|
-
cms
|
|
3191
|
-
}, (collections, loading, error) => /* @__PURE__ */ React.createElement(Nav, {
|
|
3174
|
+
return /* @__PURE__ */ React.createElement(Nav, {
|
|
3192
3175
|
sidebarWidth: 360,
|
|
3193
3176
|
showCollections: true,
|
|
3194
|
-
collectionsInfo
|
|
3195
|
-
collections,
|
|
3196
|
-
loading,
|
|
3197
|
-
error
|
|
3198
|
-
},
|
|
3177
|
+
collectionsInfo,
|
|
3199
3178
|
screens,
|
|
3200
3179
|
contentCreators: [],
|
|
3201
3180
|
RenderNavSite: ({ view }) => /* @__PURE__ */ React.createElement(SidebarLink, {
|
|
@@ -3208,7 +3187,7 @@ const Sidebar = ({ cms }) => {
|
|
|
3208
3187
|
to: `collections/${collection.name}`,
|
|
3209
3188
|
Icon: ImFilesEmpty
|
|
3210
3189
|
})
|
|
3211
|
-
})
|
|
3190
|
+
});
|
|
3212
3191
|
};
|
|
3213
3192
|
const SidebarLink = (props) => {
|
|
3214
3193
|
const { to, label, Icon } = props;
|
|
@@ -3232,9 +3211,6 @@ const GetCMS = ({ children }) => {
|
|
|
3232
3211
|
function BiEdit(props) {
|
|
3233
3212
|
return GenIcon({ "tag": "svg", "attr": { "viewBox": "0 0 24 24" }, "child": [{ "tag": "path", "attr": { "d": "m7 17.013 4.413-.015 9.632-9.54c.378-.378.586-.88.586-1.414s-.208-1.036-.586-1.414l-1.586-1.586c-.756-.756-2.075-.752-2.825-.003L7 12.583v4.43zM18.045 4.458l1.589 1.583-1.597 1.582-1.586-1.585 1.594-1.58zM9 13.417l6.03-5.973 1.586 1.586-6.029 5.971L9 15.006v-1.589z" } }, { "tag": "path", "attr": { "d": "M5 21h14c1.103 0 2-.897 2-2v-8.668l-2 2V19H8.158c-.026 0-.053.01-.079.01-.033 0-.066-.009-.1-.01H5V5h6.847l2-2H5c-1.103 0-2 .897-2 2v14c0 1.103.897 2 2 2z" } }] })(props);
|
|
3234
3213
|
}
|
|
3235
|
-
function BiExit(props) {
|
|
3236
|
-
return GenIcon({ "tag": "svg", "attr": { "viewBox": "0 0 24 24" }, "child": [{ "tag": "path", "attr": { "d": "M19.002 3h-14c-1.103 0-2 .897-2 2v4h2V5h14v14h-14v-4h-2v4c0 1.103.897 2 2 2h14c1.103 0 2-.897 2-2V5c0-1.103-.898-2-2-2z" } }, { "tag": "path", "attr": { "d": "m11 16 5-4-5-4v3.001H3v2h8z" } }] })(props);
|
|
3237
|
-
}
|
|
3238
3214
|
function BiLogIn(props) {
|
|
3239
3215
|
return GenIcon({ "tag": "svg", "attr": { "viewBox": "0 0 24 24" }, "child": [{ "tag": "path", "attr": { "d": "m13 16 5-4-5-4v3H4v2h9z" } }, { "tag": "path", "attr": { "d": "M20 3h-9c-1.103 0-2 .897-2 2v4h2V5h9v14h-9v-4H9v4c0 1.103.897 2 2 2h9c1.103 0 2-.897 2-2V5c0-1.103-.897-2-2-2z" } }] })(props);
|
|
3240
3216
|
}
|
|
@@ -3268,8 +3244,8 @@ const AuthTemplate = ({
|
|
|
3268
3244
|
d: "M18.6466 14.5553C19.9018 13.5141 20.458 7.36086 21.0014 5.14903C21.5447 2.9372 23.7919 3.04938 23.7919 3.04938C23.7919 3.04938 23.2085 4.06764 23.4464 4.82751C23.6844 5.58738 25.3145 6.26662 25.3145 6.26662L24.9629 7.19622C24.9629 7.19622 24.2288 7.10204 23.7919 7.9785C23.355 8.85496 24.3392 17.4442 24.3392 17.4442C24.3392 17.4442 21.4469 22.7275 21.4469 24.9206C21.4469 27.1136 22.4819 28.9515 22.4819 28.9515H21.0296C21.0296 28.9515 18.899 26.4086 18.462 25.1378C18.0251 23.8669 18.1998 22.596 18.1998 22.596C18.1998 22.596 15.8839 22.4646 13.8303 22.596C11.7767 22.7275 10.4072 24.498 10.16 25.4884C9.91287 26.4787 9.81048 28.9515 9.81048 28.9515H8.66211C7.96315 26.7882 7.40803 26.0129 7.70918 24.9206C8.54334 21.8949 8.37949 20.1788 8.18635 19.4145C7.99321 18.6501 6.68552 17.983 6.68552 17.983C7.32609 16.6741 7.97996 16.0452 10.7926 15.9796C13.6052 15.914 17.3915 15.5965 18.6466 14.5553Z"
|
|
3269
3245
|
}), /* @__PURE__ */ React.createElement("path", {
|
|
3270
3246
|
d: "M11.1268 24.7939C11.1268 24.7939 11.4236 27.5481 13.0001 28.9516H14.3511C13.0001 27.4166 12.8527 23.4155 12.8527 23.4155C12.1656 23.6399 11.3045 24.3846 11.1268 24.7939Z"
|
|
3271
|
-
})), /* @__PURE__ */ React.createElement("span", null, "Tina
|
|
3272
|
-
className: "px-5
|
|
3247
|
+
})), /* @__PURE__ */ React.createElement("span", null, "Tina"))), message && /* @__PURE__ */ React.createElement("div", {
|
|
3248
|
+
className: "px-5 pt-4"
|
|
3273
3249
|
}, /* @__PURE__ */ React.createElement("p", {
|
|
3274
3250
|
className: "text-base font-sans leading-normal"
|
|
3275
3251
|
}, message)), /* @__PURE__ */ React.createElement("div", {
|
|
@@ -3279,38 +3255,52 @@ const AuthTemplate = ({
|
|
|
3279
3255
|
const LoginPage = () => {
|
|
3280
3256
|
const { setEdit } = useEditState();
|
|
3281
3257
|
const login = () => setEdit(true);
|
|
3282
|
-
return /* @__PURE__ */ React.createElement(AuthTemplate, null, /* @__PURE__ */ React.createElement("
|
|
3283
|
-
|
|
3284
|
-
|
|
3258
|
+
return /* @__PURE__ */ React.createElement(AuthTemplate, null, /* @__PURE__ */ React.createElement("div", {
|
|
3259
|
+
className: "flex w-full flex-1 gap-4 items-center justify-end"
|
|
3260
|
+
}, /* @__PURE__ */ React.createElement(Button, {
|
|
3261
|
+
onClick: () => {
|
|
3262
|
+
window.location.href = "/";
|
|
3263
|
+
},
|
|
3264
|
+
variant: "white",
|
|
3265
|
+
size: "custom",
|
|
3266
|
+
className: "text-base h-12 px-6 flex-shrink-0 flex-grow-0"
|
|
3285
3267
|
}, /* @__PURE__ */ React.createElement(MdOutlineArrowBack, {
|
|
3286
3268
|
className: "w-6 h-auto mr-1.5 opacity-80"
|
|
3287
|
-
}), " Back
|
|
3288
|
-
type: "submit",
|
|
3269
|
+
}), " Back To Site"), /* @__PURE__ */ React.createElement(Button, {
|
|
3289
3270
|
onClick: () => login(),
|
|
3290
|
-
|
|
3291
|
-
|
|
3271
|
+
variant: "primary",
|
|
3272
|
+
size: "custom",
|
|
3273
|
+
className: "text-base h-12 px-6 flex-1",
|
|
3274
|
+
type: "submit"
|
|
3292
3275
|
}, /* @__PURE__ */ React.createElement(BiLogIn, {
|
|
3293
|
-
className: "w-6 h-auto mr-
|
|
3294
|
-
}), "
|
|
3276
|
+
className: "w-6 h-auto mr-2 opacity-80"
|
|
3277
|
+
}), " Edit With Tina")));
|
|
3295
3278
|
};
|
|
3296
3279
|
const logout = () => {
|
|
3297
3280
|
setEditing(false);
|
|
3298
3281
|
window.location.href = "/";
|
|
3299
3282
|
};
|
|
3300
3283
|
const LogoutPage = () => {
|
|
3301
|
-
return /* @__PURE__ */ React.createElement(AuthTemplate, null, /* @__PURE__ */ React.createElement("
|
|
3302
|
-
|
|
3303
|
-
|
|
3284
|
+
return /* @__PURE__ */ React.createElement(AuthTemplate, null, /* @__PURE__ */ React.createElement("div", {
|
|
3285
|
+
className: "flex w-full flex-1 gap-4 items-center justify-end"
|
|
3286
|
+
}, /* @__PURE__ */ React.createElement(Button, {
|
|
3287
|
+
onClick: () => {
|
|
3288
|
+
window.location.href = "/";
|
|
3289
|
+
},
|
|
3290
|
+
variant: "white",
|
|
3291
|
+
size: "custom",
|
|
3292
|
+
className: "text-base h-12 px-6 flex-shrink-0 flex-grow-0"
|
|
3304
3293
|
}, /* @__PURE__ */ React.createElement(MdOutlineArrowBack, {
|
|
3305
3294
|
className: "w-6 h-auto mr-1.5 opacity-80"
|
|
3306
|
-
}), " Back
|
|
3307
|
-
type: "submit",
|
|
3295
|
+
}), " Back To Site"), /* @__PURE__ */ React.createElement(Button, {
|
|
3308
3296
|
onClick: () => logout(),
|
|
3309
|
-
|
|
3310
|
-
|
|
3297
|
+
type: "submit",
|
|
3298
|
+
variant: "primary",
|
|
3299
|
+
size: "custom",
|
|
3300
|
+
className: "text-base h-12 px-6 flex-1"
|
|
3311
3301
|
}, /* @__PURE__ */ React.createElement(BiLogOut, {
|
|
3312
3302
|
className: "w-6 h-auto mr-1.5 opacity-80"
|
|
3313
|
-
}), " Log
|
|
3303
|
+
}), " Log Out of Tina")));
|
|
3314
3304
|
};
|
|
3315
3305
|
const PageWrapper = ({
|
|
3316
3306
|
children
|
|
@@ -3351,20 +3341,119 @@ const DashboardPage = () => {
|
|
|
3351
3341
|
}, "Welcome to Tina!")), /* @__PURE__ */ React.createElement(PageBodyNarrow, null, "This is your dashboard for editing or creating content. Select a collection on the left to begin.")));
|
|
3352
3342
|
});
|
|
3353
3343
|
};
|
|
3354
|
-
|
|
3355
|
-
|
|
3356
|
-
|
|
3344
|
+
const LoadingPage = () => /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("div", {
|
|
3345
|
+
style: {
|
|
3346
|
+
position: "absolute",
|
|
3347
|
+
top: 0,
|
|
3348
|
+
left: 0,
|
|
3349
|
+
width: "100%",
|
|
3350
|
+
height: "100%",
|
|
3351
|
+
zIndex: 200,
|
|
3352
|
+
opacity: "0.8",
|
|
3353
|
+
display: "flex",
|
|
3354
|
+
alignItems: "start",
|
|
3355
|
+
justifyContent: "center",
|
|
3356
|
+
padding: "120px 40px 40px 40px"
|
|
3357
|
+
}
|
|
3358
|
+
}, /* @__PURE__ */ React.createElement("div", {
|
|
3359
|
+
style: {
|
|
3360
|
+
background: "#FFF",
|
|
3361
|
+
border: "1px solid #EDECF3",
|
|
3362
|
+
boxShadow: "0px 2px 3px rgba(0, 0, 0, 0.05), 0 4px 12px rgba(0, 0, 0, 0.1)",
|
|
3363
|
+
borderRadius: "8px",
|
|
3364
|
+
padding: "32px 24px",
|
|
3365
|
+
width: "460px",
|
|
3366
|
+
maxWidth: "90%",
|
|
3367
|
+
display: "flex",
|
|
3368
|
+
alignItems: "center",
|
|
3369
|
+
justifyContent: "center",
|
|
3370
|
+
flexDirection: "column"
|
|
3371
|
+
}
|
|
3372
|
+
}, /* @__PURE__ */ React.createElement("svg", {
|
|
3373
|
+
style: {
|
|
3374
|
+
width: "64px",
|
|
3375
|
+
color: "#2296fe",
|
|
3376
|
+
marginTop: "-8px",
|
|
3377
|
+
marginBottom: "16px"
|
|
3378
|
+
},
|
|
3379
|
+
version: "1.1",
|
|
3380
|
+
id: "L5",
|
|
3381
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
3382
|
+
xmlnsXlink: "http://www.w3.org/1999/xlink",
|
|
3383
|
+
x: "0px",
|
|
3384
|
+
y: "0px",
|
|
3385
|
+
viewBox: "0 0 100 64",
|
|
3386
|
+
enableBackground: "new 0 0 0 0",
|
|
3387
|
+
xmlSpace: "preserve"
|
|
3388
|
+
}, /* @__PURE__ */ React.createElement("circle", {
|
|
3389
|
+
fill: "currentColor",
|
|
3390
|
+
stroke: "none",
|
|
3391
|
+
cx: 6,
|
|
3392
|
+
cy: 32,
|
|
3393
|
+
r: 6
|
|
3394
|
+
}, /* @__PURE__ */ React.createElement("animateTransform", {
|
|
3395
|
+
attributeName: "transform",
|
|
3396
|
+
dur: "1s",
|
|
3397
|
+
type: "translate",
|
|
3398
|
+
values: "0 15 ; 0 -15; 0 15",
|
|
3399
|
+
calcMode: "spline",
|
|
3400
|
+
keySplines: "0.8 0 0.4 1; 0.4 0 0.2 1",
|
|
3401
|
+
repeatCount: "indefinite",
|
|
3402
|
+
begin: "0.1"
|
|
3403
|
+
})), /* @__PURE__ */ React.createElement("circle", {
|
|
3404
|
+
fill: "currentColor",
|
|
3405
|
+
stroke: "none",
|
|
3406
|
+
cx: 30,
|
|
3407
|
+
cy: 32,
|
|
3408
|
+
r: 6
|
|
3409
|
+
}, /* @__PURE__ */ React.createElement("animateTransform", {
|
|
3410
|
+
attributeName: "transform",
|
|
3411
|
+
dur: "1s",
|
|
3412
|
+
type: "translate",
|
|
3413
|
+
values: "0 15 ; 0 -10; 0 15",
|
|
3414
|
+
calcMode: "spline",
|
|
3415
|
+
keySplines: "0.8 0 0.4 1; 0.4 0 0.2 1",
|
|
3416
|
+
repeatCount: "indefinite",
|
|
3417
|
+
begin: "0.2"
|
|
3418
|
+
})), /* @__PURE__ */ React.createElement("circle", {
|
|
3419
|
+
fill: "currentColor",
|
|
3420
|
+
stroke: "none",
|
|
3421
|
+
cx: 54,
|
|
3422
|
+
cy: 32,
|
|
3423
|
+
r: 6
|
|
3424
|
+
}, /* @__PURE__ */ React.createElement("animateTransform", {
|
|
3425
|
+
attributeName: "transform",
|
|
3426
|
+
dur: "1s",
|
|
3427
|
+
type: "translate",
|
|
3428
|
+
values: "0 15 ; 0 -5; 0 15",
|
|
3429
|
+
calcMode: "spline",
|
|
3430
|
+
keySplines: "0.8 0 0.4 1; 0.4 0 0.2 1",
|
|
3431
|
+
repeatCount: "indefinite",
|
|
3432
|
+
begin: "0.3"
|
|
3433
|
+
}))), /* @__PURE__ */ React.createElement("p", {
|
|
3434
|
+
style: {
|
|
3435
|
+
fontSize: "16px",
|
|
3436
|
+
color: "#716c7f",
|
|
3437
|
+
textAlign: "center",
|
|
3438
|
+
lineHeight: "1.3",
|
|
3439
|
+
fontFamily: "'Inter', sans-serif",
|
|
3440
|
+
fontWeight: "normal"
|
|
3441
|
+
}
|
|
3442
|
+
}, "Please wait, Tina is loading data..."))));
|
|
3357
3443
|
const useGetCollection = (cms, collectionName, includeDocuments = true) => {
|
|
3358
3444
|
const api = new TinaAdminApi(cms);
|
|
3359
3445
|
const [collection, setCollection] = useState(void 0);
|
|
3446
|
+
const [loading, setLoading] = useState(true);
|
|
3360
3447
|
useEffect(() => {
|
|
3361
3448
|
const fetchCollection = async () => {
|
|
3362
3449
|
const response = await api.fetchCollection(collectionName, includeDocuments);
|
|
3363
3450
|
setCollection(response.getCollection);
|
|
3451
|
+
setLoading(false);
|
|
3364
3452
|
};
|
|
3453
|
+
setLoading(true);
|
|
3365
3454
|
fetchCollection();
|
|
3366
3455
|
}, [cms, collectionName]);
|
|
3367
|
-
return collection;
|
|
3456
|
+
return { collection, loading };
|
|
3368
3457
|
};
|
|
3369
3458
|
const GetCollection = ({
|
|
3370
3459
|
cms,
|
|
@@ -3372,11 +3461,11 @@ const GetCollection = ({
|
|
|
3372
3461
|
includeDocuments = true,
|
|
3373
3462
|
children
|
|
3374
3463
|
}) => {
|
|
3375
|
-
const collection = useGetCollection(cms, collectionName, includeDocuments);
|
|
3376
|
-
if (!collection) {
|
|
3377
|
-
return null;
|
|
3464
|
+
const { collection, loading } = useGetCollection(cms, collectionName, includeDocuments);
|
|
3465
|
+
if (!collection || loading === true) {
|
|
3466
|
+
return /* @__PURE__ */ React.createElement(LoadingPage, null);
|
|
3378
3467
|
}
|
|
3379
|
-
return /* @__PURE__ */ React.createElement(React.Fragment, null, children(collection));
|
|
3468
|
+
return /* @__PURE__ */ React.createElement(React.Fragment, null, children(collection, loading));
|
|
3380
3469
|
};
|
|
3381
3470
|
const TemplateMenu = ({ templates }) => {
|
|
3382
3471
|
return /* @__PURE__ */ React.createElement(Menu, {
|
|
@@ -3405,12 +3494,21 @@ const TemplateMenu = ({ templates }) => {
|
|
|
3405
3494
|
className: `w-full text-md px-4 py-2 tracking-wide flex items-center opacity-80 text-gray-600 ${active && "text-gray-800 opacity-100"}`
|
|
3406
3495
|
}, template.label))))))));
|
|
3407
3496
|
};
|
|
3497
|
+
const handleNavigate = (navigate, cms, collection, document) => {
|
|
3498
|
+
const plugins = cms.plugins.all("tina-admin");
|
|
3499
|
+
const routeMapping = plugins.find(({ name }) => name === "route-mapping");
|
|
3500
|
+
const routeOverride = routeMapping ? routeMapping.mapper(collection, document) : void 0;
|
|
3501
|
+
if (routeOverride) {
|
|
3502
|
+
window.location.href = routeOverride;
|
|
3503
|
+
return null;
|
|
3504
|
+
} else {
|
|
3505
|
+
navigate(document.sys.filename);
|
|
3506
|
+
}
|
|
3507
|
+
};
|
|
3408
3508
|
const CollectionListPage = () => {
|
|
3409
|
-
const { collectionName } = useParams();
|
|
3410
3509
|
const navigate = useNavigate();
|
|
3510
|
+
const { collectionName } = useParams();
|
|
3411
3511
|
return /* @__PURE__ */ React.createElement(GetCMS, null, (cms) => {
|
|
3412
|
-
const plugins = cms.plugins.all("tina-admin");
|
|
3413
|
-
const routeMapping = plugins.find(({ name }) => name === "route-mapping");
|
|
3414
3512
|
return /* @__PURE__ */ React.createElement(GetCollection, {
|
|
3415
3513
|
cms,
|
|
3416
3514
|
collectionName,
|
|
@@ -3437,24 +3535,16 @@ const CollectionListPage = () => {
|
|
|
3437
3535
|
}, /* @__PURE__ */ React.createElement("tbody", {
|
|
3438
3536
|
className: "divide-y divide-gray-150"
|
|
3439
3537
|
}, documents.map((document) => {
|
|
3440
|
-
const overrideRoute = routeMapping ? routeMapping.mapper(collection, document.node) : void 0;
|
|
3441
3538
|
return /* @__PURE__ */ React.createElement("tr", {
|
|
3442
3539
|
key: `document-${document.node.sys.filename}`,
|
|
3443
3540
|
className: ""
|
|
3444
3541
|
}, /* @__PURE__ */ React.createElement("td", {
|
|
3445
3542
|
className: "px-6 py-2 whitespace-nowrap"
|
|
3446
|
-
},
|
|
3447
|
-
className: "text-blue-600 hover:text-blue-400 flex items-center gap-3",
|
|
3448
|
-
|
|
3449
|
-
|
|
3450
|
-
|
|
3451
|
-
}), /* @__PURE__ */ React.createElement("span", null, /* @__PURE__ */ React.createElement("span", {
|
|
3452
|
-
className: "block text-xs text-gray-400 mb-1 uppercase"
|
|
3453
|
-
}, "Filename"), /* @__PURE__ */ React.createElement("span", {
|
|
3454
|
-
className: "h-5 leading-5 block whitespace-nowrap"
|
|
3455
|
-
}, document.node.sys.filename))), !overrideRoute && /* @__PURE__ */ React.createElement(Link, {
|
|
3456
|
-
className: "text-blue-600 hover:text-blue-400 flex items-center gap-3",
|
|
3457
|
-
to: `${document.node.sys.filename}`
|
|
3543
|
+
}, /* @__PURE__ */ React.createElement("a", {
|
|
3544
|
+
className: "text-blue-600 hover:text-blue-400 flex items-center gap-3 cursor-pointer",
|
|
3545
|
+
onClick: () => {
|
|
3546
|
+
handleNavigate(navigate, cms, collection, document.node);
|
|
3547
|
+
}
|
|
3458
3548
|
}, /* @__PURE__ */ React.createElement(BiEdit, {
|
|
3459
3549
|
className: "inline-block h-6 w-auto opacity-70"
|
|
3460
3550
|
}), /* @__PURE__ */ React.createElement("span", null, /* @__PURE__ */ React.createElement("span", {
|
|
@@ -3473,55 +3563,11 @@ const CollectionListPage = () => {
|
|
|
3473
3563
|
className: "block text-xs text-gray-400 mb-1 uppercase"
|
|
3474
3564
|
}, "Template"), /* @__PURE__ */ React.createElement("span", {
|
|
3475
3565
|
className: "h-5 leading-5 block text-sm font-medium text-gray-900"
|
|
3476
|
-
}, document.node.sys.template))
|
|
3477
|
-
className: "w-0"
|
|
3478
|
-
}, /* @__PURE__ */ React.createElement(OverflowMenu, {
|
|
3479
|
-
items: [
|
|
3480
|
-
{
|
|
3481
|
-
label: "Edit in Admin",
|
|
3482
|
-
icon: BiEdit,
|
|
3483
|
-
onClick: () => {
|
|
3484
|
-
navigate(`${document.node.sys.filename}`, { replace: true });
|
|
3485
|
-
}
|
|
3486
|
-
}
|
|
3487
|
-
]
|
|
3488
|
-
})));
|
|
3566
|
+
}, document.node.sys.template)));
|
|
3489
3567
|
})))))));
|
|
3490
3568
|
});
|
|
3491
3569
|
});
|
|
3492
3570
|
};
|
|
3493
|
-
const OverflowMenu = ({ items = [] }) => {
|
|
3494
|
-
if (items.length === 0)
|
|
3495
|
-
return null;
|
|
3496
|
-
return /* @__PURE__ */ React.createElement(Menu, null, ({ open }) => /* @__PURE__ */ React.createElement("div", {
|
|
3497
|
-
className: "relative"
|
|
3498
|
-
}, /* @__PURE__ */ React.createElement(Menu.Button, {
|
|
3499
|
-
className: `flex-1 group px-5 py-3 flex justify-between items-center transition-all duration-300 ease-in-out transform`
|
|
3500
|
-
}, /* @__PURE__ */ React.createElement(FiMoreVertical, {
|
|
3501
|
-
className: `flex-0 w-6 h-full inline-block text-gray-400 transition-all duration-300 ease-in-out transform ${open ? `opacity-100 text-blue-500` : `opacity-70 group-hover:opacity-100`}`
|
|
3502
|
-
})), /* @__PURE__ */ React.createElement("div", {
|
|
3503
|
-
className: "transform translate-y-full absolute bottom-2 right-5 z-50"
|
|
3504
|
-
}, /* @__PURE__ */ React.createElement(Transition, {
|
|
3505
|
-
enter: "transition duration-150 ease-out",
|
|
3506
|
-
enterFrom: "transform opacity-0 -translate-y-2",
|
|
3507
|
-
enterTo: "transform opacity-100 translate-y-0",
|
|
3508
|
-
leave: "transition duration-75 ease-in",
|
|
3509
|
-
leaveFrom: "transform opacity-100 translate-y-0",
|
|
3510
|
-
leaveTo: "transform opacity-0 -translate-y-2"
|
|
3511
|
-
}, /* @__PURE__ */ React.createElement(Menu.Items, {
|
|
3512
|
-
className: "bg-white border border-gray-150 rounded-lg shadow-lg"
|
|
3513
|
-
}, items.map((item) => {
|
|
3514
|
-
const Icon = item.icon ? item.icon : BiExit;
|
|
3515
|
-
return /* @__PURE__ */ React.createElement(Menu.Item, {
|
|
3516
|
-
key: `menu-item-${item.label}`
|
|
3517
|
-
}, ({ active }) => /* @__PURE__ */ React.createElement("button", {
|
|
3518
|
-
className: `w-full text-base px-4 py-2 first:pt-3 last:pb-3 tracking-wide whitespace-nowrap flex items-center opacity-80 text-gray-600 ${active && "text-blue-400 bg-gray-50 opacity-100"}`,
|
|
3519
|
-
onClick: item.onClick
|
|
3520
|
-
}, /* @__PURE__ */ React.createElement(Icon, {
|
|
3521
|
-
className: "w-6 h-auto mr-2 text-blue-400"
|
|
3522
|
-
}), " ", item.label));
|
|
3523
|
-
}))))));
|
|
3524
|
-
};
|
|
3525
3571
|
function HiChevronRight(props) {
|
|
3526
3572
|
return GenIcon({ "tag": "svg", "attr": { "viewBox": "0 0 20 20", "fill": "currentColor" }, "child": [{ "tag": "path", "attr": { "fillRule": "evenodd", "d": "M7.293 14.707a1 1 0 010-1.414L10.586 10 7.293 6.707a1 1 0 011.414-1.414l4 4a1 1 0 010 1.414l-4 4a1 1 0 01-1.414 0z", "clipRule": "evenodd" } }] })(props);
|
|
3527
3573
|
}
|
|
@@ -3533,6 +3579,7 @@ const useGetDocumentFields = (cms, collectionName, templateName) => {
|
|
|
3533
3579
|
fields: void 0,
|
|
3534
3580
|
mutationInfo: void 0
|
|
3535
3581
|
});
|
|
3582
|
+
const [loading, setLoading] = useState(true);
|
|
3536
3583
|
useEffect(() => {
|
|
3537
3584
|
const fetchDocumentFields = async () => {
|
|
3538
3585
|
const response = await api.fetchDocumentFields();
|
|
@@ -3553,10 +3600,12 @@ const useGetDocumentFields = (cms, collectionName, templateName) => {
|
|
|
3553
3600
|
fields,
|
|
3554
3601
|
mutationInfo
|
|
3555
3602
|
});
|
|
3603
|
+
setLoading(false);
|
|
3556
3604
|
};
|
|
3605
|
+
setLoading(true);
|
|
3557
3606
|
fetchDocumentFields();
|
|
3558
3607
|
}, [cms, collectionName]);
|
|
3559
|
-
return info;
|
|
3608
|
+
return __spreadProps(__spreadValues({}, info), { loading });
|
|
3560
3609
|
};
|
|
3561
3610
|
const GetDocumentFields = ({
|
|
3562
3611
|
cms,
|
|
@@ -3564,11 +3613,11 @@ const GetDocumentFields = ({
|
|
|
3564
3613
|
templateName,
|
|
3565
3614
|
children
|
|
3566
3615
|
}) => {
|
|
3567
|
-
const { collection, template, fields, mutationInfo } = useGetDocumentFields(cms, collectionName, templateName);
|
|
3568
|
-
if (!collection) {
|
|
3569
|
-
return null;
|
|
3616
|
+
const { collection, template, fields, mutationInfo, loading } = useGetDocumentFields(cms, collectionName, templateName);
|
|
3617
|
+
if (!collection || loading) {
|
|
3618
|
+
return /* @__PURE__ */ React.createElement(LoadingPage, null);
|
|
3570
3619
|
}
|
|
3571
|
-
return /* @__PURE__ */ React.createElement(React.Fragment, null, children({ collection, template, fields, mutationInfo }));
|
|
3620
|
+
return /* @__PURE__ */ React.createElement(React.Fragment, null, children({ collection, template, fields, mutationInfo, loading }));
|
|
3572
3621
|
};
|
|
3573
3622
|
const createDocument = async (cms, collection, template, mutationInfo, values) => {
|
|
3574
3623
|
const api = new TinaAdminApi(cms);
|
|
@@ -3658,14 +3707,17 @@ const RenderForm$1 = ({ cms, collection, template, fields, mutationInfo }) => {
|
|
|
3658
3707
|
const useGetDocument = (cms, collectionName, relativePath) => {
|
|
3659
3708
|
const api = new TinaAdminApi(cms);
|
|
3660
3709
|
const [document, setDocument] = useState(void 0);
|
|
3710
|
+
const [loading, setLoading] = useState(true);
|
|
3661
3711
|
useEffect(() => {
|
|
3662
3712
|
const fetchDocument = async () => {
|
|
3663
3713
|
const response = await api.fetchDocument(collectionName, relativePath);
|
|
3664
3714
|
setDocument(response.getDocument);
|
|
3715
|
+
setLoading(false);
|
|
3665
3716
|
};
|
|
3717
|
+
setLoading(true);
|
|
3666
3718
|
fetchDocument();
|
|
3667
3719
|
}, [cms, collectionName, relativePath]);
|
|
3668
|
-
return document;
|
|
3720
|
+
return { document, loading };
|
|
3669
3721
|
};
|
|
3670
3722
|
const GetDocument = ({
|
|
3671
3723
|
cms,
|
|
@@ -3673,11 +3725,11 @@ const GetDocument = ({
|
|
|
3673
3725
|
relativePath,
|
|
3674
3726
|
children
|
|
3675
3727
|
}) => {
|
|
3676
|
-
const document = useGetDocument(cms, collectionName, relativePath);
|
|
3677
|
-
if (!document) {
|
|
3678
|
-
return null;
|
|
3728
|
+
const { document, loading } = useGetDocument(cms, collectionName, relativePath);
|
|
3729
|
+
if (!document || loading) {
|
|
3730
|
+
return /* @__PURE__ */ React.createElement(LoadingPage, null);
|
|
3679
3731
|
}
|
|
3680
|
-
return /* @__PURE__ */ React.createElement(React.Fragment, null, children(document));
|
|
3732
|
+
return /* @__PURE__ */ React.createElement(React.Fragment, null, children(document, loading));
|
|
3681
3733
|
};
|
|
3682
3734
|
const updateDocument = async (cms, relativePath, collection, mutationInfo, values) => {
|
|
3683
3735
|
const api = new TinaAdminApi(cms);
|
|
@@ -3797,7 +3849,7 @@ const TinaAdmin = () => {
|
|
|
3797
3849
|
}, /* @__PURE__ */ React.createElement(Sidebar, {
|
|
3798
3850
|
cms
|
|
3799
3851
|
}), /* @__PURE__ */ React.createElement("div", {
|
|
3800
|
-
className: "flex-1"
|
|
3852
|
+
className: "flex-1 relative"
|
|
3801
3853
|
}, /* @__PURE__ */ React.createElement(Routes, null, /* @__PURE__ */ React.createElement(Route, {
|
|
3802
3854
|
path: "collections/:collectionName/new",
|
|
3803
3855
|
element: /* @__PURE__ */ React.createElement(CollectionCreatePage, null)
|