tinacms 0.66.0 → 0.66.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.es.js CHANGED
@@ -29,18 +29,18 @@ var __objRest = (source, exclude) => {
29
29
  }
30
30
  return target;
31
31
  };
32
- import { EventBus, Modal, ModalPopup, ModalHeader, ModalBody, ModalActions, Button, LoadingDots, useLocalStorage, TinaCMS, BranchSwitcherPlugin, BranchDataProvider, TinaProvider, useCMS, useBranchData, FormMetaPlugin, Form, GlobalFormPlugin, FullscreenFormBuilder } from "@tinacms/toolkit";
32
+ import { EventBus, Modal, ModalPopup, ModalHeader, ModalBody, ModalActions, Button, LoadingDots, useLocalStorage, TinaCMS, BranchSwitcherPlugin, BranchDataProvider, TinaProvider, useCMS, useBranchData, FormMetaPlugin, Form, GlobalFormPlugin, Nav, LocalWarning, FormStatus, FormBuilder } from "@tinacms/toolkit";
33
33
  export * from "@tinacms/toolkit";
34
34
  import { TypeInfo, visit, visitWithTypeInfo, getNamedType, GraphQLObjectType, isLeafType, GraphQLUnionType, isScalarType, getIntrospectionQuery, buildClientSchema, print } from "graphql";
35
35
  import set from "lodash.set";
36
36
  import gql$1 from "graphql-tag";
37
- import React, { useState, useCallback, useEffect, Fragment } from "react";
37
+ import React, { useState, useCallback, useEffect, Fragment, useMemo } from "react";
38
38
  import styled from "styled-components";
39
39
  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, useLocation, useParams, Link, useNavigate, BrowserRouter, Routes, Route } from "react-router-dom";
43
+ import { NavLink, useParams, useNavigate, 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;
@@ -706,6 +706,104 @@ function safeAssertShape(value, yupSchema) {
706
706
  return false;
707
707
  }
708
708
  }
709
+ class TinaAdminApi {
710
+ constructor(cms) {
711
+ this.api = cms.api.tina;
712
+ }
713
+ async fetchCollections() {
714
+ const response = await this.api.request(`#graphql
715
+ query{
716
+ getCollections {
717
+ label,
718
+ name
719
+ }
720
+ }`, { variables: {} });
721
+ return response;
722
+ }
723
+ async fetchCollection(collectionName, includeDocuments) {
724
+ const response = await this.api.request(`#graphql
725
+ query($collection: String!, $includeDocuments: Boolean!){
726
+ getCollection(collection: $collection){
727
+ name
728
+ label
729
+ format
730
+ templates
731
+ documents @include(if: $includeDocuments) {
732
+ totalCount
733
+ edges {
734
+ node {
735
+ ... on Document {
736
+ sys {
737
+ template
738
+ breadcrumbs
739
+ path
740
+ basename
741
+ relativePath
742
+ filename
743
+ extension
744
+ }
745
+ }
746
+ }
747
+ }
748
+ }
749
+ }
750
+ }`, { variables: { collection: collectionName, includeDocuments } });
751
+ return response;
752
+ }
753
+ async fetchDocument(collectionName, relativePath) {
754
+ const response = await this.api.request(`#graphql
755
+ query($collection: String!, $relativePath: String!) {
756
+ getDocument(collection:$collection, relativePath:$relativePath) {
757
+ ... on Document {
758
+ form
759
+ values
760
+ }
761
+ }
762
+ }`, { variables: { collection: collectionName, relativePath } });
763
+ return response;
764
+ }
765
+ async fetchDocumentFields() {
766
+ const response = await this.api.request(`#graphql
767
+ query {
768
+ getDocumentFields
769
+ }`, { variables: {} });
770
+ return response;
771
+ }
772
+ async createDocument(collectionName, relativePath, params) {
773
+ const response = await this.api.request(`#graphql
774
+ mutation($collection: String!, $relativePath: String!, $params: DocumentMutation!) {
775
+ createDocument(
776
+ collection: $collection,
777
+ relativePath: $relativePath,
778
+ params: $params
779
+ ){__typename}
780
+ }`, {
781
+ variables: {
782
+ collection: collectionName,
783
+ relativePath,
784
+ params
785
+ }
786
+ });
787
+ return response;
788
+ }
789
+ async updateDocument(collectionName, relativePath, params) {
790
+ const response = await this.api.request(`#graphql
791
+ mutation($collection: String!, $relativePath: String!, $params: DocumentMutation!) {
792
+ updateDocument(
793
+ collection: $collection,
794
+ relativePath: $relativePath,
795
+ params: $params
796
+ ){__typename}
797
+ }`, {
798
+ variables: {
799
+ collection: collectionName,
800
+ relativePath,
801
+ params
802
+ }
803
+ });
804
+ return response;
805
+ }
806
+ }
709
807
  function sleep(ms) {
710
808
  return new Promise((resolve) => setTimeout(resolve, ms));
711
809
  }
@@ -803,6 +901,11 @@ const TinaCloudProvider = (props) => {
803
901
  return newBranch;
804
902
  };
805
903
  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")]);
806
909
  const [branchingEnabled, setBranchingEnabled] = React.useState(() => cms.flags.get("branch-switcher"));
807
910
  React.useEffect(() => {
808
911
  cms.events.subscribe("flag:set", ({ key, value }) => {
@@ -1904,40 +2007,49 @@ Document
1904
2007
  position: relative !important;
1905
2008
  }
1906
2009
 
1907
- .tina-tailwind .bottom-3 {
1908
- bottom: 12px !important;
1909
- }
1910
-
1911
- .tina-tailwind .right-5 {
1912
- right: 20px !important;
2010
+ .tina-tailwind .left-0 {
2011
+ left: 0px !important;
1913
2012
  }
1914
2013
 
1915
2014
  .tina-tailwind .right-0 {
1916
2015
  right: 0px !important;
1917
2016
  }
1918
2017
 
2018
+ .tina-tailwind .bottom-2 {
2019
+ bottom: 8px !important;
2020
+ }
2021
+
2022
+ .tina-tailwind .right-5 {
2023
+ right: 20px !important;
2024
+ }
2025
+
1919
2026
  .tina-tailwind .z-50 {
1920
2027
  z-index: 50 !important;
1921
2028
  }
1922
2029
 
1923
- .tina-tailwind .-ml-1 {
1924
- margin-left: -4px !important;
2030
+ .tina-tailwind .mx-auto {
2031
+ margin-left: auto !important;
2032
+ margin-right: auto !important;
1925
2033
  }
1926
2034
 
1927
- .tina-tailwind .mr-1\\.5 {
1928
- margin-right: 6px !important;
2035
+ .tina-tailwind .mr-2 {
2036
+ margin-right: 8px !important;
1929
2037
  }
1930
2038
 
1931
- .tina-tailwind .mr-1 {
1932
- margin-right: 4px !important;
2039
+ .tina-tailwind .mb-2 {
2040
+ margin-bottom: 8px !important;
1933
2041
  }
1934
2042
 
1935
- .tina-tailwind .mb-3 {
1936
- margin-bottom: 12px !important;
2043
+ .tina-tailwind .mb-1 {
2044
+ margin-bottom: 4px !important;
1937
2045
  }
1938
2046
 
1939
- .tina-tailwind .mr-2 {
1940
- margin-right: 8px !important;
2047
+ .tina-tailwind .-mt-0\\.5 {
2048
+ margin-top: -2px !important;
2049
+ }
2050
+
2051
+ .tina-tailwind .-mt-0 {
2052
+ margin-top: 0px !important;
1941
2053
  }
1942
2054
 
1943
2055
  .tina-tailwind .ml-1 {
@@ -1948,16 +2060,12 @@ Document
1948
2060
  margin-top: 8px !important;
1949
2061
  }
1950
2062
 
1951
- .tina-tailwind .mt-8 {
1952
- margin-top: 32px !important;
1953
- }
1954
-
1955
- .tina-tailwind .mb-0\\.5 {
1956
- margin-bottom: 2px !important;
2063
+ .tina-tailwind .mr-1\\.5 {
2064
+ margin-right: 6px !important;
1957
2065
  }
1958
2066
 
1959
- .tina-tailwind .mb-0 {
1960
- margin-bottom: 0px !important;
2067
+ .tina-tailwind .mr-1 {
2068
+ margin-right: 4px !important;
1961
2069
  }
1962
2070
 
1963
2071
  .tina-tailwind .block {
@@ -1988,10 +2096,18 @@ Document
1988
2096
  height: auto !important;
1989
2097
  }
1990
2098
 
2099
+ .tina-tailwind .h-full {
2100
+ height: 100% !important;
2101
+ }
2102
+
1991
2103
  .tina-tailwind .h-6 {
1992
2104
  height: 24px !important;
1993
2105
  }
1994
2106
 
2107
+ .tina-tailwind .h-10 {
2108
+ height: 40px !important;
2109
+ }
2110
+
1995
2111
  .tina-tailwind .h-5 {
1996
2112
  height: 20px !important;
1997
2113
  }
@@ -2004,48 +2120,44 @@ Document
2004
2120
  width: 40px !important;
2005
2121
  }
2006
2122
 
2007
- .tina-tailwind .w-80 {
2008
- width: 320px !important;
2009
- }
2010
-
2011
- .tina-tailwind .w-2\\/3 {
2012
- width: 66.666667% !important;
2013
- }
2014
-
2015
- .tina-tailwind .w-6 {
2016
- width: 24px !important;
2017
- }
2018
-
2019
2123
  .tina-tailwind .w-auto {
2020
2124
  width: auto !important;
2021
2125
  }
2022
2126
 
2127
+ .tina-tailwind .w-5 {
2128
+ width: 20px !important;
2129
+ }
2130
+
2023
2131
  .tina-tailwind .w-56 {
2024
2132
  width: 224px !important;
2025
2133
  }
2026
2134
 
2027
- .tina-tailwind .min-w-full {
2028
- min-width: 100% !important;
2135
+ .tina-tailwind .w-6 {
2136
+ width: 24px !important;
2029
2137
  }
2030
2138
 
2031
2139
  .tina-tailwind .max-w-lg {
2032
2140
  max-width: 32rem !important;
2033
2141
  }
2034
2142
 
2035
- .tina-tailwind .max-w-screen-md {
2036
- max-width: 768px !important;
2143
+ .tina-tailwind .max-w-screen-xl {
2144
+ max-width: 1280px !important;
2145
+ }
2146
+
2147
+ .tina-tailwind .max-w-form {
2148
+ max-width: 900px !important;
2037
2149
  }
2038
2150
 
2039
- .tina-tailwind .max-w-xs {
2040
- max-width: 20rem !important;
2151
+ .tina-tailwind .max-w-full {
2152
+ max-width: 100% !important;
2041
2153
  }
2042
2154
 
2043
2155
  .tina-tailwind .flex-1 {
2044
2156
  flex: 1 1 0% !important;
2045
2157
  }
2046
2158
 
2047
- .tina-tailwind .flex-shrink-0 {
2048
- flex-shrink: 0 !important;
2159
+ .tina-tailwind .table-auto {
2160
+ table-layout: auto !important;
2049
2161
  }
2050
2162
 
2051
2163
  .tina-tailwind .origin-top-right {
@@ -2067,16 +2179,6 @@ Document
2067
2179
  transform: var(--tw-transform) !important;
2068
2180
  }
2069
2181
 
2070
- .tina-tailwind .rotate-90 {
2071
- --tw-rotate: 90deg !important;
2072
- transform: var(--tw-transform) !important;
2073
- }
2074
-
2075
- .tina-tailwind .rotate-0 {
2076
- --tw-rotate: 0deg !important;
2077
- transform: var(--tw-transform) !important;
2078
- }
2079
-
2080
2182
  .tina-tailwind .scale-95 {
2081
2183
  --tw-scale-x: .95 !important;
2082
2184
  --tw-scale-y: .95 !important;
@@ -2109,14 +2211,6 @@ Document
2109
2211
  align-items: stretch !important;
2110
2212
  }
2111
2213
 
2112
- .tina-tailwind .justify-start {
2113
- justify-content: flex-start !important;
2114
- }
2115
-
2116
- .tina-tailwind .justify-end {
2117
- justify-content: flex-end !important;
2118
- }
2119
-
2120
2214
  .tina-tailwind .justify-center {
2121
2215
  justify-content: center !important;
2122
2216
  }
@@ -2137,18 +2231,10 @@ Document
2137
2231
  gap: 16px !important;
2138
2232
  }
2139
2233
 
2140
- .tina-tailwind .gap-1 {
2141
- gap: 4px !important;
2142
- }
2143
-
2144
2234
  .tina-tailwind .gap-3 {
2145
2235
  gap: 12px !important;
2146
2236
  }
2147
2237
 
2148
- .tina-tailwind .gap-1\\.5 {
2149
- gap: 6px !important;
2150
- }
2151
-
2152
2238
  .tina-tailwind .divide-y > :not([hidden]) ~ :not([hidden]) {
2153
2239
  --tw-divide-y-reverse: 0 !important;
2154
2240
  border-top-width: calc(1px * calc(1 - var(--tw-divide-y-reverse))) !important;
@@ -2163,10 +2249,6 @@ Document
2163
2249
  overflow-y: auto !important;
2164
2250
  }
2165
2251
 
2166
- .tina-tailwind .overflow-ellipsis {
2167
- text-overflow: ellipsis !important;
2168
- }
2169
-
2170
2252
  .tina-tailwind .whitespace-nowrap {
2171
2253
  white-space: nowrap !important;
2172
2254
  }
@@ -2191,10 +2273,6 @@ Document
2191
2273
  border-bottom-width: 1px !important;
2192
2274
  }
2193
2275
 
2194
- .tina-tailwind .border-r {
2195
- border-right-width: 1px !important;
2196
- }
2197
-
2198
2276
  .tina-tailwind .border-gray-200 {
2199
2277
  --tw-border-opacity: 1 !important;
2200
2278
  border-color: rgba(225, 221, 236, var(--tw-border-opacity)) !important;
@@ -2214,8 +2292,9 @@ Document
2214
2292
  background-color: rgba(246, 246, 249, var(--tw-bg-opacity)) !important;
2215
2293
  }
2216
2294
 
2217
- .tina-tailwind .bg-transparent {
2218
- background-color: transparent !important;
2295
+ .tina-tailwind .bg-blue-500 {
2296
+ --tw-bg-opacity: 1 !important;
2297
+ background-color: rgba(0, 132, 255, var(--tw-bg-opacity)) !important;
2219
2298
  }
2220
2299
 
2221
2300
  .tina-tailwind .bg-gradient-to-b {
@@ -2227,19 +2306,10 @@ Document
2227
2306
  --tw-gradient-stops: var(--tw-gradient-from), var(--tw-gradient-to, rgba(29, 44, 108, 0)) !important;
2228
2307
  }
2229
2308
 
2230
- .tina-tailwind .from-white {
2231
- --tw-gradient-from: #fff !important;
2232
- --tw-gradient-stops: var(--tw-gradient-from), var(--tw-gradient-to, rgba(255, 255, 255, 0)) !important;
2233
- }
2234
-
2235
2309
  .tina-tailwind .to-gray-900 {
2236
2310
  --tw-gradient-to: #252336 !important;
2237
2311
  }
2238
2312
 
2239
- .tina-tailwind .to-gray-50 {
2240
- --tw-gradient-to: #F6F6F9 !important;
2241
- }
2242
-
2243
2313
  .tina-tailwind .px-4 {
2244
2314
  padding-left: 16px !important;
2245
2315
  padding-right: 16px !important;
@@ -2260,6 +2330,21 @@ Document
2260
2330
  padding-bottom: 16px !important;
2261
2331
  }
2262
2332
 
2333
+ .tina-tailwind .px-12 {
2334
+ padding-left: 48px !important;
2335
+ padding-right: 48px !important;
2336
+ }
2337
+
2338
+ .tina-tailwind .py-10 {
2339
+ padding-top: 40px !important;
2340
+ padding-bottom: 40px !important;
2341
+ }
2342
+
2343
+ .tina-tailwind .px-20 {
2344
+ padding-left: 80px !important;
2345
+ padding-right: 80px !important;
2346
+ }
2347
+
2263
2348
  .tina-tailwind .px-6 {
2264
2349
  padding-left: 24px !important;
2265
2350
  padding-right: 24px !important;
@@ -2275,47 +2360,22 @@ Document
2275
2360
  padding-bottom: 8px !important;
2276
2361
  }
2277
2362
 
2278
- .tina-tailwind .py-7 {
2279
- padding-top: 28px !important;
2280
- padding-bottom: 28px !important;
2281
- }
2282
-
2283
- .tina-tailwind .px-8 {
2284
- padding-left: 32px !important;
2285
- padding-right: 32px !important;
2286
- }
2287
-
2288
- .tina-tailwind .py-2\\.5 {
2289
- padding-top: 10px !important;
2290
- padding-bottom: 10px !important;
2291
- }
2292
-
2293
- .tina-tailwind .py-14 {
2294
- padding-top: 56px !important;
2295
- padding-bottom: 56px !important;
2296
- }
2297
-
2298
2363
  .tina-tailwind .py-3 {
2299
2364
  padding-top: 12px !important;
2300
2365
  padding-bottom: 12px !important;
2301
2366
  }
2302
2367
 
2303
- .tina-tailwind .py-1\\.5 {
2304
- padding-top: 6px !important;
2305
- padding-bottom: 6px !important;
2306
- }
2307
-
2308
- .tina-tailwind .py-10 {
2309
- padding-top: 40px !important;
2310
- padding-bottom: 40px !important;
2368
+ .tina-tailwind .px-8 {
2369
+ padding-left: 32px !important;
2370
+ padding-right: 32px !important;
2311
2371
  }
2312
2372
 
2313
- .tina-tailwind .pt-16 {
2314
- padding-top: 64px !important;
2373
+ .tina-tailwind .pb-4 {
2374
+ padding-bottom: 16px !important;
2315
2375
  }
2316
2376
 
2317
- .tina-tailwind .pb-10 {
2318
- padding-bottom: 40px !important;
2377
+ .tina-tailwind .pt-18 {
2378
+ padding-top: 72px !important;
2319
2379
  }
2320
2380
 
2321
2381
  .tina-tailwind .text-left {
@@ -2340,40 +2400,26 @@ Document
2340
2400
  line-height: 1.5 !important;
2341
2401
  }
2342
2402
 
2343
- .tina-tailwind .text-lg {
2344
- font-size: 18px !important;
2345
- line-height: 1.55 !important;
2346
- }
2347
-
2348
2403
  .tina-tailwind .text-sm {
2349
2404
  font-size: 14px !important;
2350
2405
  line-height: 1.43 !important;
2351
2406
  }
2352
2407
 
2408
+ .tina-tailwind .text-xl {
2409
+ font-size: 20px !important;
2410
+ line-height: 1.4 !important;
2411
+ }
2412
+
2353
2413
  .tina-tailwind .text-md {
2354
2414
  font-size: 16px !important;
2355
2415
  line-height: 1.5 !important;
2356
2416
  }
2357
2417
 
2358
- .tina-tailwind .text-3xl {
2359
- font-size: 30px !important;
2360
- line-height: 1.2 !important;
2361
- }
2362
-
2363
2418
  .tina-tailwind .text-xs {
2364
2419
  font-size: 13px !important;
2365
2420
  line-height: 1.33 !important;
2366
2421
  }
2367
2422
 
2368
- .tina-tailwind .text-4xl {
2369
- font-size: 36px !important;
2370
- line-height: 1.1 !important;
2371
- }
2372
-
2373
- .tina-tailwind .font-bold {
2374
- font-weight: 700 !important;
2375
- }
2376
-
2377
2423
  .tina-tailwind .font-medium {
2378
2424
  font-weight: 500 !important;
2379
2425
  }
@@ -2390,14 +2436,18 @@ Document
2390
2436
  line-height: 1.5 !important;
2391
2437
  }
2392
2438
 
2393
- .tina-tailwind .leading-4 {
2394
- line-height: 16px !important;
2439
+ .tina-tailwind .leading-tight {
2440
+ line-height: 1.25 !important;
2395
2441
  }
2396
2442
 
2397
2443
  .tina-tailwind .leading-5 {
2398
2444
  line-height: 20px !important;
2399
2445
  }
2400
2446
 
2447
+ .tina-tailwind .leading-4 {
2448
+ line-height: 16px !important;
2449
+ }
2450
+
2401
2451
  .tina-tailwind .tracking-wide {
2402
2452
  letter-spacing: 0.025em !important;
2403
2453
  }
@@ -2407,24 +2457,23 @@ Document
2407
2457
  color: rgba(67, 62, 82, var(--tw-text-opacity)) !important;
2408
2458
  }
2409
2459
 
2410
- .tina-tailwind .text-gray-800 {
2460
+ .tina-tailwind .text-blue-600 {
2411
2461
  --tw-text-opacity: 1 !important;
2412
- color: rgba(54, 49, 69, var(--tw-text-opacity)) !important;
2462
+ color: rgba(5, 116, 228, var(--tw-text-opacity)) !important;
2413
2463
  }
2414
2464
 
2415
- .tina-tailwind .text-gray-600 {
2465
+ .tina-tailwind .text-gray-500 {
2416
2466
  --tw-text-opacity: 1 !important;
2417
- color: rgba(86, 81, 101, var(--tw-text-opacity)) !important;
2467
+ color: rgba(113, 108, 127, var(--tw-text-opacity)) !important;
2418
2468
  }
2419
2469
 
2420
- .tina-tailwind .text-blue-400 {
2470
+ .tina-tailwind .text-gray-400 {
2421
2471
  --tw-text-opacity: 1 !important;
2422
- color: rgba(34, 150, 254, var(--tw-text-opacity)) !important;
2472
+ color: rgba(145, 140, 158, var(--tw-text-opacity)) !important;
2423
2473
  }
2424
2474
 
2425
- .tina-tailwind .text-blue-600 {
2426
- --tw-text-opacity: 1 !important;
2427
- color: rgba(5, 116, 228, var(--tw-text-opacity)) !important;
2475
+ .tina-tailwind .text-current {
2476
+ color: currentColor !important;
2428
2477
  }
2429
2478
 
2430
2479
  .tina-tailwind .text-white {
@@ -2432,56 +2481,66 @@ Document
2432
2481
  color: rgba(255, 255, 255, var(--tw-text-opacity)) !important;
2433
2482
  }
2434
2483
 
2435
- .tina-tailwind .text-gray-400 {
2484
+ .tina-tailwind .text-gray-600 {
2436
2485
  --tw-text-opacity: 1 !important;
2437
- color: rgba(145, 140, 158, var(--tw-text-opacity)) !important;
2486
+ color: rgba(86, 81, 101, var(--tw-text-opacity)) !important;
2438
2487
  }
2439
2488
 
2440
- .tina-tailwind .text-gray-300 {
2489
+ .tina-tailwind .text-gray-800 {
2441
2490
  --tw-text-opacity: 1 !important;
2442
- color: rgba(178, 173, 190, var(--tw-text-opacity)) !important;
2491
+ color: rgba(54, 49, 69, var(--tw-text-opacity)) !important;
2443
2492
  }
2444
2493
 
2445
- .tina-tailwind .text-gray-500 {
2494
+ .tina-tailwind .text-gray-900 {
2446
2495
  --tw-text-opacity: 1 !important;
2447
- color: rgba(113, 108, 127, var(--tw-text-opacity)) !important;
2496
+ color: rgba(37, 35, 54, var(--tw-text-opacity)) !important;
2448
2497
  }
2449
2498
 
2450
- .tina-tailwind .underline {
2451
- text-decoration: underline !important;
2499
+ .tina-tailwind .text-blue-500 {
2500
+ --tw-text-opacity: 1 !important;
2501
+ color: rgba(0, 132, 255, var(--tw-text-opacity)) !important;
2452
2502
  }
2453
2503
 
2454
- .tina-tailwind .opacity-80 {
2455
- opacity: .8 !important;
2504
+ .tina-tailwind .text-blue-400 {
2505
+ --tw-text-opacity: 1 !important;
2506
+ color: rgba(34, 150, 254, var(--tw-text-opacity)) !important;
2456
2507
  }
2457
2508
 
2458
- .tina-tailwind .opacity-50 {
2459
- opacity: .5 !important;
2509
+ .tina-tailwind .underline {
2510
+ text-decoration: underline !important;
2460
2511
  }
2461
2512
 
2462
2513
  .tina-tailwind .opacity-100 {
2463
2514
  opacity: 1 !important;
2464
2515
  }
2465
2516
 
2466
- .tina-tailwind .opacity-0 {
2467
- opacity: 0 !important;
2468
- }
2469
-
2470
2517
  .tina-tailwind .opacity-90 {
2471
2518
  opacity: .9 !important;
2472
2519
  }
2473
2520
 
2521
+ .tina-tailwind .opacity-80 {
2522
+ opacity: .8 !important;
2523
+ }
2524
+
2525
+ .tina-tailwind .opacity-50 {
2526
+ opacity: .5 !important;
2527
+ }
2528
+
2474
2529
  .tina-tailwind .opacity-70 {
2475
2530
  opacity: .7 !important;
2476
2531
  }
2477
2532
 
2533
+ .tina-tailwind .opacity-0 {
2534
+ opacity: 0 !important;
2535
+ }
2536
+
2478
2537
  .tina-tailwind .shadow-lg {
2479
2538
  --tw-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05) !important;
2480
2539
  box-shadow: var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow) !important;
2481
2540
  }
2482
2541
 
2483
- .tina-tailwind .shadow-sm {
2484
- --tw-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05) !important;
2542
+ .tina-tailwind .shadow-2xl {
2543
+ --tw-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25) !important;
2485
2544
  box-shadow: var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow) !important;
2486
2545
  }
2487
2546
 
@@ -2490,8 +2549,13 @@ Document
2490
2549
  box-shadow: var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow) !important;
2491
2550
  }
2492
2551
 
2493
- .tina-tailwind .ring-1 {
2494
- --tw-ring-offset-shadow: var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color) !important;
2552
+ .tina-tailwind .shadow-sm {
2553
+ --tw-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05) !important;
2554
+ box-shadow: var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow) !important;
2555
+ }
2556
+
2557
+ .tina-tailwind .ring-1 {
2558
+ --tw-ring-offset-shadow: var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color) !important;
2495
2559
  --tw-ring-shadow: var(--tw-ring-inset) 0 0 0 calc(1px + var(--tw-ring-offset-width)) var(--tw-ring-color) !important;
2496
2560
  box-shadow: var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow, 0 0 #0000) !important;
2497
2561
  }
@@ -2509,14 +2573,14 @@ Document
2509
2573
  filter: var(--tw-filter) !important;
2510
2574
  }
2511
2575
 
2512
- .tina-tailwind .transition-colors {
2513
- transition-property: background-color, border-color, color, fill, stroke !important;
2576
+ .tina-tailwind .transition-opacity {
2577
+ transition-property: opacity !important;
2514
2578
  transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1) !important;
2515
2579
  transition-duration: 150ms !important;
2516
2580
  }
2517
2581
 
2518
- .tina-tailwind .transition-opacity {
2519
- transition-property: opacity !important;
2582
+ .tina-tailwind .transition-colors {
2583
+ transition-property: background-color, border-color, color, fill, stroke !important;
2520
2584
  transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1) !important;
2521
2585
  transition-duration: 150ms !important;
2522
2586
  }
@@ -2533,38 +2597,55 @@ Document
2533
2597
  transition-duration: 150ms !important;
2534
2598
  }
2535
2599
 
2536
- .tina-tailwind .duration-150 {
2537
- transition-duration: 150ms !important;
2538
- }
2539
-
2540
2600
  .tina-tailwind .duration-300 {
2541
2601
  transition-duration: 300ms !important;
2542
2602
  }
2543
2603
 
2544
- .tina-tailwind .duration-75 {
2545
- transition-duration: 75ms !important;
2604
+ .tina-tailwind .duration-150 {
2605
+ transition-duration: 150ms !important;
2546
2606
  }
2547
2607
 
2548
2608
  .tina-tailwind .duration-100 {
2549
2609
  transition-duration: 100ms !important;
2550
2610
  }
2551
2611
 
2612
+ .tina-tailwind .duration-75 {
2613
+ transition-duration: 75ms !important;
2614
+ }
2615
+
2552
2616
  .tina-tailwind .ease-out {
2553
2617
  transition-timing-function: cubic-bezier(0, 0, 0.2, 1) !important;
2554
2618
  }
2555
2619
 
2620
+ .tina-tailwind .ease-in {
2621
+ transition-timing-function: cubic-bezier(0.4, 0, 1, 1) !important;
2622
+ }
2623
+
2556
2624
  .tina-tailwind .ease-in-out {
2557
2625
  transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1) !important;
2558
2626
  }
2559
2627
 
2560
- .tina-tailwind .ease-in {
2561
- transition-timing-function: cubic-bezier(0.4, 0, 1, 1) !important;
2562
- }
2628
+ .tina-tailwind .icon-parent svg {
2629
+ fill: currentColor !important;
2630
+ }
2563
2631
 
2564
2632
  .tina-tailwind {
2565
- font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
2566
- --tw-text-opacity: 1;
2567
- color: rgba(86, 81, 101, var(--tw-text-opacity));
2633
+ font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
2634
+ --tw-text-opacity: 1;
2635
+ color: rgba(86, 81, 101, var(--tw-text-opacity));
2636
+ }
2637
+
2638
+ .first\\:pt-3:first-child {
2639
+ padding-top: 12px !important;
2640
+ }
2641
+
2642
+ .last\\:pb-3:last-child {
2643
+ padding-bottom: 12px !important;
2644
+ }
2645
+
2646
+ .hover\\:bg-blue-600:hover {
2647
+ --tw-bg-opacity: 1 !important;
2648
+ background-color: rgba(5, 116, 228, var(--tw-bg-opacity)) !important;
2568
2649
  }
2569
2650
 
2570
2651
  .hover\\:bg-gray-50:hover {
@@ -2577,9 +2658,9 @@ Document
2577
2658
  color: rgba(5, 116, 228, var(--tw-text-opacity)) !important;
2578
2659
  }
2579
2660
 
2580
- .hover\\:text-blue-500:hover {
2661
+ .hover\\:text-blue-400:hover {
2581
2662
  --tw-text-opacity: 1 !important;
2582
- color: rgba(0, 132, 255, var(--tw-text-opacity)) !important;
2663
+ color: rgba(34, 150, 254, var(--tw-text-opacity)) !important;
2583
2664
  }
2584
2665
 
2585
2666
  .hover\\:opacity-100:hover {
@@ -2590,31 +2671,38 @@ Document
2590
2671
  opacity: .8 !important;
2591
2672
  }
2592
2673
 
2593
- .focus\\:outline-none:focus {
2594
- outline: 2px solid transparent !important;
2595
- outline-offset: 2px !important;
2674
+ .focus\\:text-blue-400:focus {
2675
+ --tw-text-opacity: 1 !important;
2676
+ color: rgba(34, 150, 254, var(--tw-text-opacity)) !important;
2596
2677
  }
2597
2678
 
2598
- .group:hover .group-hover\\:opacity-100 {
2599
- opacity: 1 !important;
2679
+ .focus\\:underline:focus {
2680
+ text-decoration: underline !important;
2600
2681
  }
2601
2682
 
2602
- .group:hover .group-hover\\:opacity-80 {
2603
- opacity: .8 !important;
2683
+ .focus\\:shadow-outline:focus {
2684
+ --tw-shadow: 0 0 0 3px rgba(66, 153, 225, 0.5) !important;
2685
+ box-shadow: var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow) !important;
2604
2686
  }
2605
2687
 
2606
- @media (min-width: 640px) {
2688
+ .focus\\:outline-none:focus {
2689
+ outline: 2px solid transparent !important;
2690
+ outline-offset: 2px !important;
2691
+ }
2607
2692
 
2608
- .sm\\:rounded-lg {
2609
- border-radius: 8px !important;
2610
- }
2693
+ .focus\\:ring-2:focus {
2694
+ --tw-ring-offset-shadow: var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color) !important;
2695
+ --tw-ring-shadow: var(--tw-ring-inset) 0 0 0 calc(2px + var(--tw-ring-offset-width)) var(--tw-ring-color) !important;
2696
+ box-shadow: var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow, 0 0 #0000) !important;
2611
2697
  }
2612
2698
 
2613
- @media (min-width: 1024px) {
2699
+ .focus\\:ring-blue-500:focus {
2700
+ --tw-ring-opacity: 1 !important;
2701
+ --tw-ring-color: rgba(0, 132, 255, var(--tw-ring-opacity)) !important;
2702
+ }
2614
2703
 
2615
- .lg\\:w-96 {
2616
- width: 384px !important;
2617
- }
2704
+ .group:hover .group-hover\\:opacity-100 {
2705
+ opacity: 1 !important;
2618
2706
  }
2619
2707
  `;
2620
2708
  function useTina({
@@ -2671,7 +2759,7 @@ class ErrorBoundary extends React.Component {
2671
2759
  return { hasError: true, message: error.message };
2672
2760
  }
2673
2761
  render() {
2674
- const branchData = window.localStorage.getItem("tinacms-current-branch");
2762
+ const branchData = window.localStorage && window.localStorage.getItem("tinacms-current-branch");
2675
2763
  const hasBranchData = branchData && branchData.length > 0;
2676
2764
  if (this.state.hasError && !this.state.pageRefresh) {
2677
2765
  return /* @__PURE__ */ React.createElement("div", {
@@ -3064,210 +3152,70 @@ function IconBase(props) {
3064
3152
  return elem(conf);
3065
3153
  }) : elem(DefaultContext);
3066
3154
  }
3067
- function BiEdit(props) {
3068
- 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);
3069
- }
3070
- function BiExit(props) {
3071
- 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);
3072
- }
3073
- function BiLinkExternal(props) {
3074
- return GenIcon({ "tag": "svg", "attr": { "viewBox": "0 0 24 24" }, "child": [{ "tag": "path", "attr": { "d": "m13 3 3.293 3.293-7 7 1.414 1.414 7-7L21 11V3z" } }, { "tag": "path", "attr": { "d": "M19 19H5V5h7l-2-2H5c-1.103 0-2 .897-2 2v14c0 1.103.897 2 2 2h14c1.103 0 2-.897 2-2v-5l-2-2v7z" } }] })(props);
3075
- }
3076
- function BiLogIn(props) {
3077
- 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);
3078
- }
3079
- function BiLogOut(props) {
3080
- return GenIcon({ "tag": "svg", "attr": { "viewBox": "0 0 24 24" }, "child": [{ "tag": "path", "attr": { "d": "M16 13v-2H7V8l-5 4 5 4v-3z" } }, { "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);
3081
- }
3082
3155
  function ImFilesEmpty(props) {
3083
3156
  return GenIcon({ "tag": "svg", "attr": { "version": "1.1", "viewBox": "0 0 16 16" }, "child": [{ "tag": "path", "attr": { "d": "M14.341 5.579c-0.347-0.473-0.831-1.027-1.362-1.558s-1.085-1.015-1.558-1.362c-0.806-0.591-1.197-0.659-1.421-0.659h-5.75c-0.689 0-1.25 0.561-1.25 1.25v11.5c0 0.689 0.561 1.25 1.25 1.25h9.5c0.689 0 1.25-0.561 1.25-1.25v-7.75c0-0.224-0.068-0.615-0.659-1.421zM12.271 4.729c0.48 0.48 0.856 0.912 1.134 1.271h-2.406v-2.405c0.359 0.278 0.792 0.654 1.271 1.134v0zM14 14.75c0 0.136-0.114 0.25-0.25 0.25h-9.5c-0.136 0-0.25-0.114-0.25-0.25v-11.5c0-0.135 0.114-0.25 0.25-0.25 0 0 5.749-0 5.75 0v3.5c0 0.276 0.224 0.5 0.5 0.5h3.5v7.75z" } }, { "tag": "path", "attr": { "d": "M9.421 0.659c-0.806-0.591-1.197-0.659-1.421-0.659h-5.75c-0.689 0-1.25 0.561-1.25 1.25v11.5c0 0.604 0.43 1.109 1 1.225v-12.725c0-0.135 0.115-0.25 0.25-0.25h7.607c-0.151-0.124-0.297-0.238-0.437-0.341z" } }] })(props);
3084
3157
  }
3085
- function VscOpenPreview(props) {
3086
- return GenIcon({ "tag": "svg", "attr": { "viewBox": "0 0 16 16", "fill": "currentColor" }, "child": [{ "tag": "path", "attr": { "fillRule": "evenodd", "clipRule": "evenodd", "d": "M3 1h11l1 1v5.3a3.21 3.21 0 0 0-1-.3V2H9v10.88L7.88 14H3l-1-1V2l1-1zm0 12h5V2H3v11zm10.379-4.998a2.53 2.53 0 0 0-1.19.348h-.03a2.51 2.51 0 0 0-.799 3.53L9 14.23l.71.71 2.35-2.36c.325.22.7.358 1.09.4a2.47 2.47 0 0 0 1.14-.13 2.51 2.51 0 0 0 1-.63 2.46 2.46 0 0 0 .58-1 2.63 2.63 0 0 0 .07-1.15 2.53 2.53 0 0 0-1.35-1.81 2.53 2.53 0 0 0-1.211-.258zm.24 3.992a1.5 1.5 0 0 1-.979-.244 1.55 1.55 0 0 1-.56-.68 1.49 1.49 0 0 1-.08-.86 1.49 1.49 0 0 1 1.18-1.18 1.49 1.49 0 0 1 .86.08c.276.117.512.311.68.56a1.5 1.5 0 0 1-1.1 2.324z" } }] })(props);
3087
- }
3088
- class TinaAdminApi {
3089
- constructor(TinaApi) {
3090
- this.api = TinaApi;
3091
- }
3092
- async fetchCollections() {
3093
- const response = await this.api.request(`query{ getCollections { label, name } }`, { variables: {} });
3094
- return response;
3095
- }
3096
- async fetchCollection(collectionName, includeDocuments) {
3097
- const response = await this.api.request(`
3098
- query($collection: String!, $includeDocuments: Boolean!){
3099
- getCollection(collection: $collection){
3100
- name
3101
- label
3102
- format
3103
- templates
3104
- documents @include(if: $includeDocuments) {
3105
- totalCount
3106
- edges {
3107
- node {
3108
- ... on Document {
3109
- sys {
3110
- template
3111
- breadcrumbs
3112
- path
3113
- basename
3114
- relativePath
3115
- filename
3116
- extension
3117
- }
3118
- }
3119
- }
3120
- }
3121
- }
3122
- }
3123
- }`, { variables: { collection: collectionName, includeDocuments } });
3124
- return response;
3125
- }
3126
- async fetchDocument(collectionName, relativePath) {
3127
- const response = await this.api.request(`
3128
- query($collection: String!, $relativePath: String!) {
3129
- getDocument(collection:$collection, relativePath:$relativePath) {
3130
- ... on Document {
3131
- form
3132
- values
3133
- }
3134
- }
3135
- }`, { variables: { collection: collectionName, relativePath } });
3136
- return response;
3137
- }
3138
- async fetchDocumentFields() {
3139
- const response = await this.api.request(`query { getDocumentFields }`, { variables: {} });
3140
- return response;
3141
- }
3142
- async createDocument(collectionName, relativePath, params) {
3143
- const response = await this.api.request(`#graphql
3144
- mutation($collection: String!, $relativePath: String!, $params: DocumentMutation!) {
3145
- createDocument(
3146
- collection: $collection,
3147
- relativePath: $relativePath,
3148
- params: $params
3149
- ){__typename}
3150
- }`, {
3151
- variables: {
3152
- collection: collectionName,
3153
- relativePath,
3154
- params
3155
- }
3156
- });
3157
- return response;
3158
- }
3159
- async updateDocument(collectionName, relativePath, params) {
3160
- const response = await this.api.request(`#graphql
3161
- mutation($collection: String!, $relativePath: String!, $params: DocumentMutation!) {
3162
- updateDocument(
3163
- collection: $collection,
3164
- relativePath: $relativePath,
3165
- params: $params
3166
- ){__typename}
3167
- }`, {
3168
- variables: {
3169
- collection: collectionName,
3170
- relativePath,
3171
- params
3172
- }
3173
- });
3174
- return response;
3175
- }
3176
- }
3177
3158
  const useGetCollections = (cms) => {
3178
- const api = new TinaAdminApi(cms.api.tina);
3179
- const [collections, setCollections] = useState([]);
3159
+ const api = new TinaAdminApi(cms);
3160
+ const [info, setInfo] = useState({ collections: [], loading: true, error: false });
3180
3161
  useEffect(() => {
3181
3162
  const fetchCollections = async () => {
3182
3163
  const response = await api.fetchCollections();
3183
- setCollections(response.getCollections);
3164
+ setInfo({
3165
+ collections: response.getCollections,
3166
+ loading: false,
3167
+ error: false
3168
+ });
3184
3169
  };
3185
3170
  fetchCollections();
3186
3171
  }, [cms]);
3187
- return collections;
3172
+ return info;
3188
3173
  };
3189
3174
  const GetCollections = ({ cms, children }) => {
3190
- const collections = useGetCollections(cms);
3175
+ const { collections, loading, error } = useGetCollections(cms);
3191
3176
  if (!collections)
3192
3177
  return null;
3193
- return /* @__PURE__ */ React.createElement(React.Fragment, null, children(collections));
3178
+ return /* @__PURE__ */ React.createElement(React.Fragment, null, children(collections, loading, error));
3179
+ };
3180
+ const slugify = (text) => {
3181
+ return text.toString().toLowerCase().trim().replace(/[^\w\s-]/g, "").replace(/[\s_-]+/g, "_").replace(/^-+|-+$/g, "");
3194
3182
  };
3195
3183
  const Sidebar = ({ cms }) => {
3196
- const { setEdit } = useEditState();
3197
- const logout2 = () => setEdit(false);
3184
+ const screens = cms.plugins.getType("screen").all();
3198
3185
  return /* @__PURE__ */ React.createElement(GetCollections, {
3199
3186
  cms
3200
- }, (collections) => /* @__PURE__ */ React.createElement("div", {
3201
- className: "flex flex-col w-80 lg:w-96 flex-shrink-0 bg-gradient-to-b from-white to-gray-50 border-r border-gray-200"
3202
- }, /* @__PURE__ */ React.createElement("div", {
3203
- className: "border-b border-gray-200"
3204
- }, /* @__PURE__ */ React.createElement(Menu, {
3205
- as: "div",
3206
- className: "relative block"
3207
- }, ({ open }) => /* @__PURE__ */ React.createElement("div", null, /* @__PURE__ */ React.createElement(Menu.Button, {
3208
- className: `group w-full px-6 py-4 flex justify-between items-center transition-colors duration-150 ease-out ${open ? `bg-gray-50` : `bg-transparent`}`
3209
- }, /* @__PURE__ */ React.createElement("span", {
3210
- className: "text-left inline-flex items-center text-2xl tracking-wide text-gray-800 flex-1 gap-1 opacity-80 group-hover:opacity-100 transition-opacity duration-150 ease-out"
3211
- }, /* @__PURE__ */ React.createElement("svg", {
3212
- viewBox: "0 0 32 32",
3213
- fill: "#EC4815",
3214
- xmlns: "http://www.w3.org/2000/svg",
3215
- className: "w-10 h-auto -ml-1"
3216
- }, /* @__PURE__ */ React.createElement("path", {
3217
- 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"
3218
- }), /* @__PURE__ */ React.createElement("path", {
3219
- 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"
3220
- })), /* @__PURE__ */ React.createElement("span", null, "Tina Admin")), /* @__PURE__ */ React.createElement("svg", {
3221
- width: "20",
3222
- height: "20",
3223
- viewBox: "0 0 20 20",
3224
- fill: "none",
3225
- xmlns: "http://www.w3.org/2000/svg",
3226
- className: `flex-0 inline-block opacity-50 group-hover:opacity-80 transition-all duration-300 ease-in-out transform ${open ? `rotate-90 opacity-100` : `rotate-0`}`
3227
- }, /* @__PURE__ */ React.createElement("g", {
3228
- opacity: "0.3"
3229
- }, /* @__PURE__ */ React.createElement("path", {
3230
- d: "M7.91675 13.8086L9.16675 15.0586L14.2253 10L9.16675 4.9414L7.91675 6.1914L11.7253 10L7.91675 13.8086Z",
3231
- fill: "currentColor"
3232
- })))), /* @__PURE__ */ React.createElement("div", {
3233
- className: "transform translate-y-full absolute bottom-3 right-5 w-2/3 z-50"
3234
- }, /* @__PURE__ */ React.createElement(Transition, {
3235
- enter: "transition duration-150 ease-out",
3236
- enterFrom: "transform opacity-0 -translate-y-2",
3237
- enterTo: "transform opacity-100 translate-y-0",
3238
- leave: "transition duration-75 ease-in",
3239
- leaveFrom: "transform opacity-100 translate-y-0",
3240
- leaveTo: "transform opacity-0 -translate-y-2"
3241
- }, /* @__PURE__ */ React.createElement(Menu.Items, {
3242
- className: "w-full py-1 bg-white border border-gray-150 rounded-lg shadow-lg"
3243
- }, /* @__PURE__ */ React.createElement(Menu.Item, null, ({ active }) => /* @__PURE__ */ React.createElement("a", {
3244
- className: `w-full text-lg px-4 py-2 tracking-wide flex items-center opacity-80 text-gray-600 ${active && "text-gray-800 opacity-100"}`,
3245
- href: "/"
3246
- }, /* @__PURE__ */ React.createElement(VscOpenPreview, {
3247
- className: "w-6 h-auto mr-1.5 text-blue-400"
3248
- }), " ", "View Website")), /* @__PURE__ */ React.createElement(Menu.Item, null, ({ active }) => /* @__PURE__ */ React.createElement("button", {
3249
- className: `w-full text-lg px-4 py-2 tracking-wide flex items-center opacity-80 text-gray-600 ${active && "text-gray-800 opacity-100"}`,
3250
- onClick: () => logout2()
3251
- }, /* @__PURE__ */ React.createElement(BiExit, {
3252
- className: "w-6 h-auto mr-1.5 text-blue-400"
3253
- }), " ", "Log out")))))))), /* @__PURE__ */ React.createElement("div", {
3254
- className: "px-6 py-7 flex-1"
3255
- }, /* @__PURE__ */ React.createElement("h4", {
3256
- className: "uppercase font-bold text-sm mb-3"
3257
- }, "Collections"), /* @__PURE__ */ React.createElement("ul", {
3258
- className: "flex flex-col gap-4"
3259
- }, collections.map((collection) => {
3260
- return /* @__PURE__ */ React.createElement("li", {
3261
- key: `${collection.name}-link`
3262
- }, /* @__PURE__ */ React.createElement(NavLink, {
3263
- className: ({ isActive }) => {
3264
- return `text-lg tracking-wide ${isActive ? "text-blue-600" : ""} hover:text-blue-600 flex items-center opacity-90 hover:opacity-100`;
3265
- },
3266
- to: `/admin/collections/${collection.name}`
3267
- }, /* @__PURE__ */ React.createElement(ImFilesEmpty, {
3268
- className: "mr-2 h-6 opacity-80 w-auto"
3269
- }), " ", collection.label));
3270
- })))));
3187
+ }, (collections, loading, error) => /* @__PURE__ */ React.createElement(Nav, {
3188
+ sidebarWidth: 360,
3189
+ showCollections: true,
3190
+ collectionsInfo: {
3191
+ collections,
3192
+ loading,
3193
+ error
3194
+ },
3195
+ screens,
3196
+ contentCreators: [],
3197
+ RenderNavSite: ({ view }) => /* @__PURE__ */ React.createElement(SidebarLink, {
3198
+ label: view.name,
3199
+ to: `screens/${slugify(view.name)}`,
3200
+ Icon: view.Icon ? view.Icon : ImFilesEmpty
3201
+ }),
3202
+ RenderNavCollection: ({ collection }) => /* @__PURE__ */ React.createElement(SidebarLink, {
3203
+ label: collection.label ? collection.label : collection.name,
3204
+ to: `collections/${collection.name}`,
3205
+ Icon: ImFilesEmpty
3206
+ })
3207
+ }));
3208
+ };
3209
+ const SidebarLink = (props) => {
3210
+ const { to, label, Icon } = props;
3211
+ return /* @__PURE__ */ React.createElement(NavLink, {
3212
+ className: ({ isActive }) => {
3213
+ return `text-base tracking-wide ${isActive ? "text-blue-600" : "text-gray-500"} hover:text-blue-600 flex items-center opacity-90 hover:opacity-100`;
3214
+ },
3215
+ to
3216
+ }, /* @__PURE__ */ React.createElement(Icon, {
3217
+ className: "mr-2 h-6 opacity-80 w-auto"
3218
+ }), " ", label);
3271
3219
  };
3272
3220
  const GetCMS = ({ children }) => {
3273
3221
  try {
@@ -3277,6 +3225,18 @@ const GetCMS = ({ children }) => {
3277
3225
  return null;
3278
3226
  }
3279
3227
  };
3228
+ function BiEdit(props) {
3229
+ 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);
3230
+ }
3231
+ function BiLogIn(props) {
3232
+ 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);
3233
+ }
3234
+ function BiLogOut(props) {
3235
+ return GenIcon({ "tag": "svg", "attr": { "viewBox": "0 0 24 24" }, "child": [{ "tag": "path", "attr": { "d": "M16 13v-2H7V8l-5 4 5 4v-3z" } }, { "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);
3236
+ }
3237
+ function BiPlus(props) {
3238
+ return GenIcon({ "tag": "svg", "attr": { "viewBox": "0 0 24 24" }, "child": [{ "tag": "path", "attr": { "d": "M19 11h-6V5h-2v6H5v2h6v6h2v-6h6z" } }] })(props);
3239
+ }
3280
3240
  function MdOutlineArrowBack(props) {
3281
3241
  return GenIcon({ "tag": "svg", "attr": { "viewBox": "0 0 24 24" }, "child": [{ "tag": "path", "attr": { "fill": "none", "d": "M0 0h24v24H0V0z" } }, { "tag": "path", "attr": { "d": "M20 11H7.83l5.59-5.59L12 4l-8 8 8 8 1.41-1.41L7.83 13H20v-2z" } }] })(props);
3282
3242
  }
@@ -3345,25 +3305,47 @@ const LogoutPage = () => {
3345
3305
  className: "w-6 h-auto mr-1.5 opacity-80"
3346
3306
  }), " Log out"));
3347
3307
  };
3348
- const DashboardPage = () => {
3308
+ const PageWrapper = ({
3309
+ children
3310
+ }) => {
3349
3311
  return /* @__PURE__ */ React.createElement("div", {
3350
- className: "h-screen overflow-y-auto flex flex-col justify-start items-stretch"
3351
- }, /* @__PURE__ */ React.createElement("div", {
3352
- className: "flex-0 px-6 pt-16 pb-10 w-full flex justify-center bg-white border-b border-gray-150"
3353
- }, /* @__PURE__ */ React.createElement("div", {
3354
- className: "max-w-screen-md w-full"
3355
- }, /* @__PURE__ */ React.createElement("h3", {
3356
- className: "text-4xl"
3357
- }, "Welcome to Tina CMS."))), /* @__PURE__ */ React.createElement("div", {
3358
- className: "w-full px-6 py-10 flex justify-center"
3359
- }, /* @__PURE__ */ React.createElement("div", {
3360
- className: "max-w-screen-md w-full"
3361
- }, /* @__PURE__ */ React.createElement("p", {
3362
- className: "text-gray-700 text-lg"
3363
- }, "This is your dashboard for editing or creating content. Select a collection on the left to begin."))));
3312
+ className: "relative left-0 w-full h-full bg-gray-50 shadow-2xl overflow-y-auto transition-opacity duration-300 ease-out flex flex-col opacity-100"
3313
+ }, children);
3314
+ };
3315
+ const PageHeader = ({
3316
+ isLocalMode,
3317
+ children
3318
+ }) => /* @__PURE__ */ React.createElement(React.Fragment, null, isLocalMode && /* @__PURE__ */ React.createElement(LocalWarning, null), /* @__PURE__ */ React.createElement("div", {
3319
+ className: "bg-white pb-4 pt-18 border-b border-gray-200 px-12"
3320
+ }, /* @__PURE__ */ React.createElement("div", {
3321
+ className: "w-full mx-auto max-w-screen-xl"
3322
+ }, /* @__PURE__ */ React.createElement("div", {
3323
+ className: "w-full flex justify-between items-end"
3324
+ }, children))));
3325
+ const PageBody = ({
3326
+ children
3327
+ }) => /* @__PURE__ */ React.createElement("div", {
3328
+ className: "py-10 px-12"
3329
+ }, children);
3330
+ const PageBodyNarrow = ({
3331
+ children
3332
+ }) => /* @__PURE__ */ React.createElement("div", {
3333
+ className: "py-10 px-12"
3334
+ }, /* @__PURE__ */ React.createElement("div", {
3335
+ className: "w-full mx-auto max-w-screen-xl"
3336
+ }, children));
3337
+ const DashboardPage = () => {
3338
+ return /* @__PURE__ */ React.createElement(GetCMS, null, (cms) => {
3339
+ var _a, _b;
3340
+ return /* @__PURE__ */ React.createElement(PageWrapper, null, /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(PageHeader, {
3341
+ isLocalMode: (_b = (_a = cms.api) == null ? void 0 : _a.tina) == null ? void 0 : _b.isLocalMode
3342
+ }, /* @__PURE__ */ React.createElement("h3", {
3343
+ className: "text-2xl text-gray-700"
3344
+ }, "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.")));
3345
+ });
3364
3346
  };
3365
3347
  const useGetCollection = (cms, collectionName, includeDocuments = true) => {
3366
- const api = new TinaAdminApi(cms.api.tina);
3348
+ const api = new TinaAdminApi(cms);
3367
3349
  const [collection, setCollection] = useState(void 0);
3368
3350
  useEffect(() => {
3369
3351
  const fetchCollection = async () => {
@@ -3390,22 +3372,11 @@ const TemplateMenu = ({ templates }) => {
3390
3372
  return /* @__PURE__ */ React.createElement(Menu, {
3391
3373
  as: "div",
3392
3374
  className: "relative inline-block text-left"
3393
- }, ({ open }) => /* @__PURE__ */ React.createElement("div", null, /* @__PURE__ */ React.createElement("div", null, /* @__PURE__ */ React.createElement(Menu.Button, {
3394
- className: "inline-flex items-center px-8 py-2.5 shadow-sm border border-transparent text-sm leading-4 font-medium rounded-full text-white hover:opacity-80 focus:outline-none focus:shadow-outline-blue transition duration-150 ease-out",
3395
- style: { background: "#0084FF" }
3396
- }, "Create New", /* @__PURE__ */ React.createElement("svg", {
3397
- width: "20",
3398
- height: "20",
3399
- viewBox: "0 0 20 20",
3400
- fill: "none",
3401
- xmlns: "http://www.w3.org/2000/svg",
3402
- className: `ml-1 flex-0 inline-block opacity-50 group-hover:opacity-80 transition-all duration-300 ease-in-out transform ${open ? `rotate-90 opacity-100` : `rotate-0`}`
3403
- }, /* @__PURE__ */ React.createElement("g", {
3404
- opacity: "1.0"
3405
- }, /* @__PURE__ */ React.createElement("path", {
3406
- d: "M7.91675 13.8086L9.16675 15.0586L14.2253 10L9.16675 4.9414L7.91675 6.1914L11.7253 10L7.91675 13.8086Z",
3407
- fill: "currentColor"
3408
- }))))), /* @__PURE__ */ React.createElement(Transition, {
3375
+ }, () => /* @__PURE__ */ React.createElement("div", null, /* @__PURE__ */ React.createElement("div", null, /* @__PURE__ */ React.createElement(Menu.Button, {
3376
+ className: "icon-parent inline-flex items-center font-medium focus:outline-none focus:ring-2 focus:shadow-outline text-center rounded-full justify-center transition-all duration-150 ease-out shadow text-white bg-blue-500 hover:bg-blue-600 focus:ring-blue-500 text-sm h-10 px-6"
3377
+ }, "Create New ", /* @__PURE__ */ React.createElement(BiPlus, {
3378
+ className: "w-5 h-full ml-1 opacity-70"
3379
+ }))), /* @__PURE__ */ React.createElement(Transition, {
3409
3380
  as: Fragment,
3410
3381
  enter: "transition ease-out duration-100",
3411
3382
  enterFrom: "transform opacity-0 scale-95",
@@ -3420,13 +3391,13 @@ const TemplateMenu = ({ templates }) => {
3420
3391
  }, templates.map((template) => /* @__PURE__ */ React.createElement(Menu.Item, {
3421
3392
  key: `${template.label}-${template.name}`
3422
3393
  }, ({ active }) => /* @__PURE__ */ React.createElement(Link, {
3423
- to: `${location.pathname}/${template.name}/new`,
3394
+ to: `${template.name}/new`,
3424
3395
  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"}`
3425
3396
  }, template.label))))))));
3426
3397
  };
3427
3398
  const CollectionListPage = () => {
3428
- const location2 = useLocation();
3429
3399
  const { collectionName } = useParams();
3400
+ useNavigate();
3430
3401
  return /* @__PURE__ */ React.createElement(GetCMS, null, (cms) => {
3431
3402
  const plugins = cms.plugins.all("tina-admin");
3432
3403
  const routeMapping = plugins.find(({ name }) => name === "route-mapping");
@@ -3435,68 +3406,73 @@ const CollectionListPage = () => {
3435
3406
  collectionName,
3436
3407
  includeDocuments: true
3437
3408
  }, (collection) => {
3409
+ var _a, _b;
3438
3410
  const totalCount = collection.documents.totalCount;
3439
3411
  const documents = collection.documents.edges;
3440
- return /* @__PURE__ */ React.createElement("div", {
3441
- className: "px-6 py-14 h-screen overflow-y-auto flex justify-center"
3442
- }, /* @__PURE__ */ React.createElement("div", {
3443
- className: "max-w-screen-md w-full"
3444
- }, /* @__PURE__ */ React.createElement("div", {
3445
- className: "w-full flex justify-between items-end"
3446
- }, /* @__PURE__ */ React.createElement("h3", {
3447
- className: "text-3xl"
3448
- }, collection.label), !collection.templates && /* @__PURE__ */ React.createElement(Link, {
3449
- to: `${location2.pathname}/new`,
3450
- className: "inline-flex items-center px-8 py-3 shadow-sm border border-transparent text-sm leading-4 font-medium rounded-full text-white hover:opacity-80 focus:outline-none focus:shadow-outline-blue transition duration-150 ease-out",
3451
- style: { background: "#0084FF" }
3452
- }, "Create New"), collection.templates && /* @__PURE__ */ React.createElement(TemplateMenu, {
3412
+ return /* @__PURE__ */ React.createElement(PageWrapper, null, /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(PageHeader, {
3413
+ isLocalMode: (_b = (_a = cms == null ? void 0 : cms.api) == null ? void 0 : _a.tina) == null ? void 0 : _b.isLocalMode
3414
+ }, /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("h3", {
3415
+ className: "text-2xl text-gray-700"
3416
+ }, collection.label ? collection.label : collection.name), !collection.templates && /* @__PURE__ */ React.createElement(Link, {
3417
+ to: `new`,
3418
+ className: "icon-parent inline-flex items-center font-medium focus:outline-none focus:ring-2 focus:shadow-outline text-center rounded-full justify-center transition-all duration-150 ease-out shadow text-white bg-blue-500 hover:bg-blue-600 focus:ring-blue-500 text-sm h-10 px-6"
3419
+ }, "Create New", " ", /* @__PURE__ */ React.createElement(BiPlus, {
3420
+ className: "w-5 h-full ml-1 opacity-70"
3421
+ })), collection.templates && /* @__PURE__ */ React.createElement(TemplateMenu, {
3453
3422
  templates: collection.templates
3454
- })), totalCount > 0 && /* @__PURE__ */ React.createElement("div", {
3455
- className: "mt-8 shadow overflow-hidden border-b border-gray-200 sm:rounded-lg"
3456
- }, /* @__PURE__ */ React.createElement("table", {
3457
- className: "min-w-full"
3423
+ }))), /* @__PURE__ */ React.createElement(PageBody, null, /* @__PURE__ */ React.createElement("div", {
3424
+ className: "w-full mx-auto max-w-screen-xl"
3425
+ }, totalCount > 0 && /* @__PURE__ */ React.createElement("table", {
3426
+ className: "table-auto shadow bg-white border-b border-gray-200 w-full max-w-full rounded-lg"
3458
3427
  }, /* @__PURE__ */ React.createElement("tbody", {
3459
- className: "bg-white divide-y divide-gray-150"
3428
+ className: "divide-y divide-gray-150"
3460
3429
  }, documents.map((document) => {
3461
- const livesiteRoute = routeMapping ? routeMapping.mapper(collection, document.node) : void 0;
3430
+ const overrideRoute = routeMapping ? routeMapping.mapper(collection, document.node) : void 0;
3462
3431
  return /* @__PURE__ */ React.createElement("tr", {
3463
- key: document.node.sys.relativePath
3432
+ key: `document-${document.node.sys.filename}`,
3433
+ className: ""
3464
3434
  }, /* @__PURE__ */ React.createElement("td", {
3465
- className: "px-5 py-3 whitespace-nowrap"
3466
- }, /* @__PURE__ */ React.createElement("span", {
3467
- className: "block text-xs mb-0.5 text-gray-400 uppercase"
3468
- }, "Filename"), /* @__PURE__ */ React.createElement(Link, {
3469
- to: `${location2.pathname}/${document.node.sys.filename}`,
3470
- className: "h-5 leading-5 flex max-w-xs"
3435
+ className: "px-6 py-2 whitespace-nowrap"
3436
+ }, overrideRoute && /* @__PURE__ */ React.createElement("a", {
3437
+ className: "text-blue-600 hover:text-blue-400 flex items-center gap-3",
3438
+ href: `${overrideRoute}`
3439
+ }, /* @__PURE__ */ React.createElement(BiEdit, {
3440
+ className: "inline-block h-6 w-auto opacity-70"
3441
+ }), /* @__PURE__ */ React.createElement("span", null, /* @__PURE__ */ React.createElement("span", {
3442
+ className: "block text-xs text-gray-400 mb-1 uppercase"
3443
+ }, "Filename"), /* @__PURE__ */ React.createElement("span", {
3444
+ className: "h-5 leading-5 block whitespace-nowrap"
3445
+ }, document.node.sys.filename))), !overrideRoute && /* @__PURE__ */ React.createElement(Link, {
3446
+ className: "text-blue-600 hover:text-blue-400 flex items-center gap-3",
3447
+ to: `${document.node.sys.filename}`
3448
+ }, /* @__PURE__ */ React.createElement(BiEdit, {
3449
+ className: "inline-block h-6 w-auto opacity-70"
3450
+ }), /* @__PURE__ */ React.createElement("span", null, /* @__PURE__ */ React.createElement("span", {
3451
+ className: "block text-xs text-gray-400 mb-1 uppercase"
3452
+ }, "Filename"), /* @__PURE__ */ React.createElement("span", {
3453
+ className: "h-5 leading-5 block whitespace-nowrap"
3454
+ }, document.node.sys.filename)))), /* @__PURE__ */ React.createElement("td", {
3455
+ className: "px-6 py-4 whitespace-nowrap"
3471
3456
  }, /* @__PURE__ */ React.createElement("span", {
3472
- className: "flex-shrink-1 leading-5 font-medium text-base overflow-ellipsis overflow-hidden whitespace-nowrap text-gray-700"
3473
- }, document.node.sys.filename), /* @__PURE__ */ React.createElement("span", {
3474
- className: "flex-shrink-0 leading-5 text-base font-medium text-gray-300"
3475
- }, document.node.sys.extension))), /* @__PURE__ */ React.createElement("td", {
3476
- className: "px-5 py-3 whitespace-nowrap"
3457
+ className: "block text-xs text-gray-400 mb-1 uppercase"
3458
+ }, "Extension"), /* @__PURE__ */ React.createElement("span", {
3459
+ className: "h-5 leading-5 block text-sm font-medium text-gray-900"
3460
+ }, document.node.sys.extension)), /* @__PURE__ */ React.createElement("td", {
3461
+ className: "px-6 py-4 whitespace-nowrap"
3477
3462
  }, /* @__PURE__ */ React.createElement("span", {
3478
- className: "block text-xs mb-0.5 text-gray-400 uppercase"
3463
+ className: "block text-xs text-gray-400 mb-1 uppercase"
3479
3464
  }, "Template"), /* @__PURE__ */ React.createElement("span", {
3480
- className: "h-5 block leading-5 font-regular text-base overflow-ellipsis overflow-hidden whitespace-nowrap text-gray-500"
3481
- }, document.node.sys.template)), /* @__PURE__ */ React.createElement("td", {
3482
- className: "px-5 py-3 whitespace-nowrap flex gap-3 items-center justify-end"
3483
- }, livesiteRoute && /* @__PURE__ */ React.createElement("a", {
3484
- href: livesiteRoute,
3485
- className: "flex gap-1.5 items-center text-base px-4 py-1.5 rounded-full transition-all ease-out duration-150 text-gray-500 hover:text-blue-500"
3486
- }, /* @__PURE__ */ React.createElement(BiLinkExternal, {
3487
- className: "inline-block h-5 w-auto opacity-70"
3488
- }), " ", "View"), /* @__PURE__ */ React.createElement(Link, {
3489
- to: `${location2.pathname}/${document.node.sys.filename}`,
3490
- className: "flex gap-1.5 items-center text-base px-4 py-1.5 rounded-full border border-gray-150 transition-all ease-out duration-150 text-gray-700 hover:bg-gray-50 hover:text-blue-500"
3491
- }, /* @__PURE__ */ React.createElement(BiEdit, {
3492
- className: "inline-block h-5 w-auto opacity-70"
3493
- }), " ", "Edit")));
3494
- }))))));
3465
+ className: "h-5 leading-5 block text-sm font-medium text-gray-900"
3466
+ }, document.node.sys.template)));
3467
+ })))))));
3495
3468
  });
3496
3469
  });
3497
3470
  };
3471
+ function HiChevronRight(props) {
3472
+ 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);
3473
+ }
3498
3474
  const useGetDocumentFields = (cms, collectionName, templateName) => {
3499
- const api = new TinaAdminApi(cms.api.tina);
3475
+ const api = new TinaAdminApi(cms);
3500
3476
  const [info, setInfo] = useState({
3501
3477
  collection: void 0,
3502
3478
  template: void 0,
@@ -3541,9 +3517,10 @@ const GetDocumentFields = ({
3541
3517
  return /* @__PURE__ */ React.createElement(React.Fragment, null, children({ collection, template, fields, mutationInfo }));
3542
3518
  };
3543
3519
  const createDocument = async (cms, collection, template, mutationInfo, values) => {
3544
- const api = new TinaAdminApi(cms.api.tina);
3545
- const _a = values, { relativePath } = _a, leftover = __objRest(_a, ["relativePath"]);
3520
+ const api = new TinaAdminApi(cms);
3521
+ const _a = values, { filename } = _a, leftover = __objRest(_a, ["filename"]);
3546
3522
  const { includeCollection, includeTemplate } = mutationInfo;
3523
+ const relativePath = `${filename}.${collection.format}`;
3547
3524
  const params = transformDocumentIntoMutationRequestPayload(__spreadValues(__spreadValues({
3548
3525
  _collection: collection.name
3549
3526
  }, template && { _template: template.name }), leftover), {
@@ -3554,43 +3531,78 @@ const createDocument = async (cms, collection, template, mutationInfo, values) =
3554
3531
  };
3555
3532
  const CollectionCreatePage = () => {
3556
3533
  const { collectionName, templateName } = useParams();
3557
- const navigate = useNavigate();
3558
3534
  return /* @__PURE__ */ React.createElement(GetCMS, null, (cms) => /* @__PURE__ */ React.createElement(GetDocumentFields, {
3559
3535
  cms,
3560
3536
  collectionName,
3561
3537
  templateName
3562
- }, ({ collection, template, fields, mutationInfo }) => {
3563
- const form = new Form({
3538
+ }, ({ collection, template, fields, mutationInfo }) => /* @__PURE__ */ React.createElement(RenderForm$1, {
3539
+ cms,
3540
+ collection,
3541
+ template,
3542
+ fields,
3543
+ mutationInfo
3544
+ })));
3545
+ };
3546
+ const RenderForm$1 = ({ cms, collection, template, fields, mutationInfo }) => {
3547
+ var _a, _b;
3548
+ const navigate = useNavigate();
3549
+ const [formIsPristine, setFormIsPristine] = useState(true);
3550
+ const form = useMemo(() => {
3551
+ return new Form({
3564
3552
  id: "create-form",
3565
3553
  label: "form",
3566
3554
  fields: [
3567
3555
  {
3568
- name: "relativePath",
3569
- label: "Relative Path",
3556
+ name: "filename",
3557
+ label: "Filename",
3570
3558
  component: "text",
3571
- required: true,
3572
- defaultValue: `${collection.name}${Date.now()}.${collection.format}`
3559
+ description: `A unique filename for the content. Example: My_Document`,
3560
+ placeholder: `My_Document`,
3561
+ validate: (value, allValues, meta) => {
3562
+ if (!value) {
3563
+ if (meta.dirty) {
3564
+ return "Required";
3565
+ }
3566
+ return true;
3567
+ }
3568
+ const isValid = /^[_a-zA-Z][-,_a-zA-Z0-9]*$/.test(value);
3569
+ if (value && !isValid) {
3570
+ return "Must begin with a-z, A-Z, or _ and contain only a-z, A-Z, 0-9, - or _";
3571
+ }
3572
+ }
3573
3573
  },
3574
3574
  ...fields
3575
3575
  ],
3576
3576
  onSubmit: async (values) => {
3577
3577
  await createDocument(cms, collection, template, mutationInfo, values);
3578
- navigate(`/admin/collections/${collection.name}`);
3578
+ navigate(`/collections/${collection.name}`);
3579
3579
  }
3580
3580
  });
3581
- const formLabel = template ? `${collection.label} - Create New ${template.label}` : `${collection.label} - Create New`;
3582
- return /* @__PURE__ */ React.createElement("div", {
3583
- className: "w-full h-screen"
3584
- }, /* @__PURE__ */ React.createElement("div", {
3585
- className: "flex flex-col items-center w-full flex-1"
3586
- }, /* @__PURE__ */ React.createElement(FullscreenFormBuilder, {
3587
- label: formLabel,
3588
- form
3589
- })));
3590
- }));
3581
+ }, [cms, collection, template, fields, mutationInfo]);
3582
+ return /* @__PURE__ */ React.createElement(PageWrapper, null, /* @__PURE__ */ React.createElement(React.Fragment, null, ((_b = (_a = cms == null ? void 0 : cms.api) == null ? void 0 : _a.tina) == null ? void 0 : _b.isLocalMode) && /* @__PURE__ */ React.createElement(LocalWarning, null), /* @__PURE__ */ React.createElement("div", {
3583
+ className: "py-4 px-20 border-b border-gray-200 bg-white"
3584
+ }, /* @__PURE__ */ React.createElement("div", {
3585
+ className: "max-w-form mx-auto"
3586
+ }, /* @__PURE__ */ React.createElement("div", {
3587
+ className: "mb-2"
3588
+ }, /* @__PURE__ */ React.createElement("span", {
3589
+ className: "block text-sm leading-tight uppercase text-gray-400 mb-1"
3590
+ }, /* @__PURE__ */ React.createElement(Link, {
3591
+ to: `/collections/${collection.name}`,
3592
+ className: "inline-block text-current hover:text-blue-400 focus:underline focus:outline-none focus:text-blue-400 font-medium transition-colors duration-150 ease-out"
3593
+ }, collection.label ? collection.label : collection.name), /* @__PURE__ */ React.createElement(HiChevronRight, {
3594
+ className: "inline-block -mt-0.5 opacity-50"
3595
+ })), /* @__PURE__ */ React.createElement("span", {
3596
+ className: "text-xl text-gray-700 font-medium leading-tight"
3597
+ }, "Create New")), /* @__PURE__ */ React.createElement(FormStatus, {
3598
+ pristine: formIsPristine
3599
+ }))), /* @__PURE__ */ React.createElement(FormBuilder, {
3600
+ form,
3601
+ onPristineChange: setFormIsPristine
3602
+ })));
3591
3603
  };
3592
3604
  const useGetDocument = (cms, collectionName, relativePath) => {
3593
- const api = new TinaAdminApi(cms.api.tina);
3605
+ const api = new TinaAdminApi(cms);
3594
3606
  const [document, setDocument] = useState(void 0);
3595
3607
  useEffect(() => {
3596
3608
  const fetchDocument = async () => {
@@ -3614,7 +3626,7 @@ const GetDocument = ({
3614
3626
  return /* @__PURE__ */ React.createElement(React.Fragment, null, children(document));
3615
3627
  };
3616
3628
  const updateDocument = async (cms, relativePath, collection, mutationInfo, values) => {
3617
- const api = new TinaAdminApi(cms.api.tina);
3629
+ const api = new TinaAdminApi(cms);
3618
3630
  const { includeCollection, includeTemplate } = mutationInfo;
3619
3631
  const params = transformDocumentIntoMutationRequestPayload(values, {
3620
3632
  includeCollection,
@@ -3624,7 +3636,6 @@ const updateDocument = async (cms, relativePath, collection, mutationInfo, value
3624
3636
  };
3625
3637
  const CollectionUpdatePage = () => {
3626
3638
  const { collectionName, filename } = useParams();
3627
- const navigate = useNavigate();
3628
3639
  return /* @__PURE__ */ React.createElement(GetCMS, null, (cms) => /* @__PURE__ */ React.createElement(GetDocumentFields, {
3629
3640
  cms,
3630
3641
  collectionName
@@ -3634,28 +3645,77 @@ const CollectionUpdatePage = () => {
3634
3645
  cms,
3635
3646
  collectionName: collection.name,
3636
3647
  relativePath
3637
- }, (document) => {
3638
- const form = new Form({
3639
- id: "update-form",
3640
- label: "form",
3641
- fields: document.form.fields,
3642
- initialValues: document.values,
3643
- onSubmit: async (values) => {
3644
- await updateDocument(cms, relativePath, collection, mutationInfo, values);
3645
- navigate(`/collections/${collection.name}`);
3646
- }
3647
- });
3648
- return /* @__PURE__ */ React.createElement("div", {
3649
- className: "w-full h-screen"
3650
- }, /* @__PURE__ */ React.createElement("div", {
3651
- className: "flex flex-col items-center w-full flex-1"
3652
- }, /* @__PURE__ */ React.createElement(FullscreenFormBuilder, {
3653
- label: collection.label + ` - ` + filename,
3654
- form
3655
- })));
3656
- });
3648
+ }, (document) => /* @__PURE__ */ React.createElement(RenderForm, {
3649
+ cms,
3650
+ document,
3651
+ filename,
3652
+ relativePath,
3653
+ collection,
3654
+ mutationInfo
3655
+ }));
3657
3656
  }));
3658
3657
  };
3658
+ const RenderForm = ({
3659
+ cms,
3660
+ document,
3661
+ filename,
3662
+ relativePath,
3663
+ collection,
3664
+ mutationInfo
3665
+ }) => {
3666
+ var _a, _b;
3667
+ const navigate = useNavigate();
3668
+ const [formIsPristine, setFormIsPristine] = useState(true);
3669
+ const form = useMemo(() => {
3670
+ return new Form({
3671
+ id: "update-form",
3672
+ label: "form",
3673
+ fields: document.form.fields,
3674
+ initialValues: document.values,
3675
+ onSubmit: async (values) => {
3676
+ await updateDocument(cms, relativePath, collection, mutationInfo, values);
3677
+ navigate(`/collections/${collection.name}`);
3678
+ }
3679
+ });
3680
+ }, [cms, document, relativePath, collection, mutationInfo]);
3681
+ return /* @__PURE__ */ React.createElement(PageWrapper, null, /* @__PURE__ */ React.createElement(React.Fragment, null, ((_b = (_a = cms == null ? void 0 : cms.api) == null ? void 0 : _a.tina) == null ? void 0 : _b.isLocalMode) && /* @__PURE__ */ React.createElement(LocalWarning, null), /* @__PURE__ */ React.createElement("div", {
3682
+ className: "py-4 px-20 border-b border-gray-200 bg-white"
3683
+ }, /* @__PURE__ */ React.createElement("div", {
3684
+ className: "max-w-form mx-auto"
3685
+ }, /* @__PURE__ */ React.createElement("div", {
3686
+ className: "mb-2"
3687
+ }, /* @__PURE__ */ React.createElement("span", {
3688
+ className: "block text-sm leading-tight uppercase text-gray-400 mb-1"
3689
+ }, /* @__PURE__ */ React.createElement(Link, {
3690
+ to: `/collections/${collection.name}`,
3691
+ className: "inline-block text-current hover:text-blue-400 focus:underline focus:outline-none focus:text-blue-400 font-medium transition-colors duration-150 ease-out"
3692
+ }, collection.label ? collection.label : collection.name), /* @__PURE__ */ React.createElement(HiChevronRight, {
3693
+ className: "inline-block -mt-0.5 opacity-50"
3694
+ })), /* @__PURE__ */ React.createElement("span", {
3695
+ className: "text-xl text-gray-700 font-medium leading-tight"
3696
+ }, "Edit ", `${filename}.${collection.format}`)), /* @__PURE__ */ React.createElement(FormStatus, {
3697
+ pristine: formIsPristine
3698
+ }))), /* @__PURE__ */ React.createElement(FormBuilder, {
3699
+ form,
3700
+ onPristineChange: setFormIsPristine
3701
+ })));
3702
+ };
3703
+ const ScreenPage = () => {
3704
+ const { screenName } = useParams();
3705
+ return /* @__PURE__ */ React.createElement(GetCMS, null, (cms) => {
3706
+ var _a, _b;
3707
+ const screens = cms.plugins.getType("screen").all();
3708
+ const selectedScreen = screens.find(({ name }) => slugify(name) === screenName);
3709
+ return /* @__PURE__ */ React.createElement("div", {
3710
+ className: "relative w-full h-full flex flex-col items-stretch justify-between"
3711
+ }, ((_b = (_a = cms == null ? void 0 : cms.api) == null ? void 0 : _a.tina) == null ? void 0 : _b.isLocalMode) && /* @__PURE__ */ React.createElement(LocalWarning, null), /* @__PURE__ */ React.createElement("div", {
3712
+ className: "flex-1 overflow-y-auto relative flex flex-col items-stretch justify-between"
3713
+ }, /* @__PURE__ */ React.createElement(selectedScreen.Component, {
3714
+ close: () => {
3715
+ }
3716
+ })));
3717
+ });
3718
+ };
3659
3719
  const Redirect = () => {
3660
3720
  React.useEffect(() => {
3661
3721
  if (window) {
@@ -3676,34 +3736,41 @@ const TinaAdmin = () => {
3676
3736
  return /* @__PURE__ */ React.createElement(GetCMS, null, (cms) => {
3677
3737
  const isTinaAdminEnabled = cms.flags.get("tina-admin");
3678
3738
  if (isTinaAdminEnabled) {
3679
- return /* @__PURE__ */ React.createElement(Layout, null, /* @__PURE__ */ React.createElement(BrowserRouter, null, /* @__PURE__ */ React.createElement("div", {
3739
+ return /* @__PURE__ */ React.createElement(Layout, null, /* @__PURE__ */ React.createElement(BrowserRouter, {
3740
+ basename: "/admin"
3741
+ }, /* @__PURE__ */ React.createElement("div", {
3680
3742
  className: "flex items-stretch h-screen overflow-hidden"
3681
3743
  }, /* @__PURE__ */ React.createElement(Sidebar, {
3682
3744
  cms
3683
3745
  }), /* @__PURE__ */ React.createElement("div", {
3684
3746
  className: "flex-1"
3685
3747
  }, /* @__PURE__ */ React.createElement(Routes, null, /* @__PURE__ */ React.createElement(Route, {
3686
- path: "/admin/collections/:collectionName/new",
3748
+ path: "collections/:collectionName/new",
3687
3749
  element: /* @__PURE__ */ React.createElement(CollectionCreatePage, null)
3688
3750
  }), /* @__PURE__ */ React.createElement(Route, {
3689
- path: "/admin/collections/:collectionName/:templateName/new",
3751
+ path: "collections/:collectionName/:templateName/new",
3690
3752
  element: /* @__PURE__ */ React.createElement(CollectionCreatePage, null)
3691
3753
  }), /* @__PURE__ */ React.createElement(Route, {
3692
- path: "/admin/collections/:collectionName/:filename",
3754
+ path: "collections/:collectionName/:filename",
3693
3755
  element: /* @__PURE__ */ React.createElement(CollectionUpdatePage, null)
3694
3756
  }), /* @__PURE__ */ React.createElement(Route, {
3695
- path: "/admin/collections/:collectionName",
3757
+ path: "collections/:collectionName",
3696
3758
  element: /* @__PURE__ */ React.createElement(CollectionListPage, null)
3697
3759
  }), /* @__PURE__ */ React.createElement(Route, {
3698
- path: "/admin",
3760
+ path: "screens/:screenName",
3761
+ element: /* @__PURE__ */ React.createElement(ScreenPage, null)
3762
+ }), /* @__PURE__ */ React.createElement(Route, {
3763
+ path: "/",
3699
3764
  element: /* @__PURE__ */ React.createElement(DashboardPage, null)
3700
3765
  }))))));
3701
3766
  } else {
3702
- return /* @__PURE__ */ React.createElement(Layout, null, /* @__PURE__ */ React.createElement(BrowserRouter, null, /* @__PURE__ */ React.createElement(Routes, null, /* @__PURE__ */ React.createElement(Route, {
3703
- path: "/admin/logout",
3767
+ return /* @__PURE__ */ React.createElement(Layout, null, /* @__PURE__ */ React.createElement(BrowserRouter, {
3768
+ basename: "/admin"
3769
+ }, /* @__PURE__ */ React.createElement(Routes, null, /* @__PURE__ */ React.createElement(Route, {
3770
+ path: "logout",
3704
3771
  element: /* @__PURE__ */ React.createElement(LogoutPage, null)
3705
3772
  }), /* @__PURE__ */ React.createElement(Route, {
3706
- path: "/admin",
3773
+ path: "/",
3707
3774
  element: /* @__PURE__ */ React.createElement(Redirect, null)
3708
3775
  }))));
3709
3776
  }