tinacms 0.65.3 → 0.66.3

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,48 @@ 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-0 {
2136
+ width: 0px !important;
2137
+ }
2138
+
2139
+ .tina-tailwind .w-6 {
2140
+ width: 24px !important;
2029
2141
  }
2030
2142
 
2031
2143
  .tina-tailwind .max-w-lg {
2032
2144
  max-width: 32rem !important;
2033
2145
  }
2034
2146
 
2035
- .tina-tailwind .max-w-screen-md {
2036
- max-width: 768px !important;
2147
+ .tina-tailwind .max-w-screen-xl {
2148
+ max-width: 1280px !important;
2149
+ }
2150
+
2151
+ .tina-tailwind .max-w-form {
2152
+ max-width: 900px !important;
2037
2153
  }
2038
2154
 
2039
- .tina-tailwind .max-w-xs {
2040
- max-width: 20rem !important;
2155
+ .tina-tailwind .max-w-full {
2156
+ max-width: 100% !important;
2041
2157
  }
2042
2158
 
2043
2159
  .tina-tailwind .flex-1 {
2044
2160
  flex: 1 1 0% !important;
2045
2161
  }
2046
2162
 
2047
- .tina-tailwind .flex-shrink-0 {
2048
- flex-shrink: 0 !important;
2163
+ .tina-tailwind .table-auto {
2164
+ table-layout: auto !important;
2049
2165
  }
2050
2166
 
2051
2167
  .tina-tailwind .origin-top-right {
@@ -2067,16 +2183,6 @@ Document
2067
2183
  transform: var(--tw-transform) !important;
2068
2184
  }
2069
2185
 
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
2186
  .tina-tailwind .scale-95 {
2081
2187
  --tw-scale-x: .95 !important;
2082
2188
  --tw-scale-y: .95 !important;
@@ -2109,14 +2215,6 @@ Document
2109
2215
  align-items: stretch !important;
2110
2216
  }
2111
2217
 
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
2218
  .tina-tailwind .justify-center {
2121
2219
  justify-content: center !important;
2122
2220
  }
@@ -2137,18 +2235,10 @@ Document
2137
2235
  gap: 16px !important;
2138
2236
  }
2139
2237
 
2140
- .tina-tailwind .gap-1 {
2141
- gap: 4px !important;
2142
- }
2143
-
2144
2238
  .tina-tailwind .gap-3 {
2145
2239
  gap: 12px !important;
2146
2240
  }
2147
2241
 
2148
- .tina-tailwind .gap-1\\.5 {
2149
- gap: 6px !important;
2150
- }
2151
-
2152
2242
  .tina-tailwind .divide-y > :not([hidden]) ~ :not([hidden]) {
2153
2243
  --tw-divide-y-reverse: 0 !important;
2154
2244
  border-top-width: calc(1px * calc(1 - var(--tw-divide-y-reverse))) !important;
@@ -2163,10 +2253,6 @@ Document
2163
2253
  overflow-y: auto !important;
2164
2254
  }
2165
2255
 
2166
- .tina-tailwind .overflow-ellipsis {
2167
- text-overflow: ellipsis !important;
2168
- }
2169
-
2170
2256
  .tina-tailwind .whitespace-nowrap {
2171
2257
  white-space: nowrap !important;
2172
2258
  }
@@ -2191,10 +2277,6 @@ Document
2191
2277
  border-bottom-width: 1px !important;
2192
2278
  }
2193
2279
 
2194
- .tina-tailwind .border-r {
2195
- border-right-width: 1px !important;
2196
- }
2197
-
2198
2280
  .tina-tailwind .border-gray-200 {
2199
2281
  --tw-border-opacity: 1 !important;
2200
2282
  border-color: rgba(225, 221, 236, var(--tw-border-opacity)) !important;
@@ -2214,8 +2296,9 @@ Document
2214
2296
  background-color: rgba(246, 246, 249, var(--tw-bg-opacity)) !important;
2215
2297
  }
2216
2298
 
2217
- .tina-tailwind .bg-transparent {
2218
- background-color: transparent !important;
2299
+ .tina-tailwind .bg-blue-500 {
2300
+ --tw-bg-opacity: 1 !important;
2301
+ background-color: rgba(0, 132, 255, var(--tw-bg-opacity)) !important;
2219
2302
  }
2220
2303
 
2221
2304
  .tina-tailwind .bg-gradient-to-b {
@@ -2227,19 +2310,10 @@ Document
2227
2310
  --tw-gradient-stops: var(--tw-gradient-from), var(--tw-gradient-to, rgba(29, 44, 108, 0)) !important;
2228
2311
  }
2229
2312
 
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
2313
  .tina-tailwind .to-gray-900 {
2236
2314
  --tw-gradient-to: #252336 !important;
2237
2315
  }
2238
2316
 
2239
- .tina-tailwind .to-gray-50 {
2240
- --tw-gradient-to: #F6F6F9 !important;
2241
- }
2242
-
2243
2317
  .tina-tailwind .px-4 {
2244
2318
  padding-left: 16px !important;
2245
2319
  padding-right: 16px !important;
@@ -2260,6 +2334,21 @@ Document
2260
2334
  padding-bottom: 16px !important;
2261
2335
  }
2262
2336
 
2337
+ .tina-tailwind .px-12 {
2338
+ padding-left: 48px !important;
2339
+ padding-right: 48px !important;
2340
+ }
2341
+
2342
+ .tina-tailwind .py-10 {
2343
+ padding-top: 40px !important;
2344
+ padding-bottom: 40px !important;
2345
+ }
2346
+
2347
+ .tina-tailwind .px-20 {
2348
+ padding-left: 80px !important;
2349
+ padding-right: 80px !important;
2350
+ }
2351
+
2263
2352
  .tina-tailwind .px-6 {
2264
2353
  padding-left: 24px !important;
2265
2354
  padding-right: 24px !important;
@@ -2275,47 +2364,22 @@ Document
2275
2364
  padding-bottom: 8px !important;
2276
2365
  }
2277
2366
 
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
2367
  .tina-tailwind .py-3 {
2299
2368
  padding-top: 12px !important;
2300
2369
  padding-bottom: 12px !important;
2301
2370
  }
2302
2371
 
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;
2372
+ .tina-tailwind .px-8 {
2373
+ padding-left: 32px !important;
2374
+ padding-right: 32px !important;
2311
2375
  }
2312
2376
 
2313
- .tina-tailwind .pt-16 {
2314
- padding-top: 64px !important;
2377
+ .tina-tailwind .pb-4 {
2378
+ padding-bottom: 16px !important;
2315
2379
  }
2316
2380
 
2317
- .tina-tailwind .pb-10 {
2318
- padding-bottom: 40px !important;
2381
+ .tina-tailwind .pt-18 {
2382
+ padding-top: 72px !important;
2319
2383
  }
2320
2384
 
2321
2385
  .tina-tailwind .text-left {
@@ -2340,40 +2404,26 @@ Document
2340
2404
  line-height: 1.5 !important;
2341
2405
  }
2342
2406
 
2343
- .tina-tailwind .text-lg {
2344
- font-size: 18px !important;
2345
- line-height: 1.55 !important;
2346
- }
2347
-
2348
2407
  .tina-tailwind .text-sm {
2349
2408
  font-size: 14px !important;
2350
2409
  line-height: 1.43 !important;
2351
2410
  }
2352
2411
 
2412
+ .tina-tailwind .text-xl {
2413
+ font-size: 20px !important;
2414
+ line-height: 1.4 !important;
2415
+ }
2416
+
2353
2417
  .tina-tailwind .text-md {
2354
2418
  font-size: 16px !important;
2355
2419
  line-height: 1.5 !important;
2356
2420
  }
2357
2421
 
2358
- .tina-tailwind .text-3xl {
2359
- font-size: 30px !important;
2360
- line-height: 1.2 !important;
2361
- }
2362
-
2363
2422
  .tina-tailwind .text-xs {
2364
2423
  font-size: 13px !important;
2365
2424
  line-height: 1.33 !important;
2366
2425
  }
2367
2426
 
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
2427
  .tina-tailwind .font-medium {
2378
2428
  font-weight: 500 !important;
2379
2429
  }
@@ -2390,14 +2440,18 @@ Document
2390
2440
  line-height: 1.5 !important;
2391
2441
  }
2392
2442
 
2393
- .tina-tailwind .leading-4 {
2394
- line-height: 16px !important;
2443
+ .tina-tailwind .leading-tight {
2444
+ line-height: 1.25 !important;
2395
2445
  }
2396
2446
 
2397
2447
  .tina-tailwind .leading-5 {
2398
2448
  line-height: 20px !important;
2399
2449
  }
2400
2450
 
2451
+ .tina-tailwind .leading-4 {
2452
+ line-height: 16px !important;
2453
+ }
2454
+
2401
2455
  .tina-tailwind .tracking-wide {
2402
2456
  letter-spacing: 0.025em !important;
2403
2457
  }
@@ -2407,24 +2461,23 @@ Document
2407
2461
  color: rgba(67, 62, 82, var(--tw-text-opacity)) !important;
2408
2462
  }
2409
2463
 
2410
- .tina-tailwind .text-gray-800 {
2464
+ .tina-tailwind .text-blue-600 {
2411
2465
  --tw-text-opacity: 1 !important;
2412
- color: rgba(54, 49, 69, var(--tw-text-opacity)) !important;
2466
+ color: rgba(5, 116, 228, var(--tw-text-opacity)) !important;
2413
2467
  }
2414
2468
 
2415
- .tina-tailwind .text-gray-600 {
2469
+ .tina-tailwind .text-gray-500 {
2416
2470
  --tw-text-opacity: 1 !important;
2417
- color: rgba(86, 81, 101, var(--tw-text-opacity)) !important;
2471
+ color: rgba(113, 108, 127, var(--tw-text-opacity)) !important;
2418
2472
  }
2419
2473
 
2420
- .tina-tailwind .text-blue-400 {
2474
+ .tina-tailwind .text-gray-400 {
2421
2475
  --tw-text-opacity: 1 !important;
2422
- color: rgba(34, 150, 254, var(--tw-text-opacity)) !important;
2476
+ color: rgba(145, 140, 158, var(--tw-text-opacity)) !important;
2423
2477
  }
2424
2478
 
2425
- .tina-tailwind .text-blue-600 {
2426
- --tw-text-opacity: 1 !important;
2427
- color: rgba(5, 116, 228, var(--tw-text-opacity)) !important;
2479
+ .tina-tailwind .text-current {
2480
+ color: currentColor !important;
2428
2481
  }
2429
2482
 
2430
2483
  .tina-tailwind .text-white {
@@ -2432,56 +2485,66 @@ Document
2432
2485
  color: rgba(255, 255, 255, var(--tw-text-opacity)) !important;
2433
2486
  }
2434
2487
 
2435
- .tina-tailwind .text-gray-400 {
2488
+ .tina-tailwind .text-gray-600 {
2436
2489
  --tw-text-opacity: 1 !important;
2437
- color: rgba(145, 140, 158, var(--tw-text-opacity)) !important;
2490
+ color: rgba(86, 81, 101, var(--tw-text-opacity)) !important;
2438
2491
  }
2439
2492
 
2440
- .tina-tailwind .text-gray-300 {
2493
+ .tina-tailwind .text-gray-800 {
2441
2494
  --tw-text-opacity: 1 !important;
2442
- color: rgba(178, 173, 190, var(--tw-text-opacity)) !important;
2495
+ color: rgba(54, 49, 69, var(--tw-text-opacity)) !important;
2443
2496
  }
2444
2497
 
2445
- .tina-tailwind .text-gray-500 {
2498
+ .tina-tailwind .text-gray-900 {
2446
2499
  --tw-text-opacity: 1 !important;
2447
- color: rgba(113, 108, 127, var(--tw-text-opacity)) !important;
2500
+ color: rgba(37, 35, 54, var(--tw-text-opacity)) !important;
2448
2501
  }
2449
2502
 
2450
- .tina-tailwind .underline {
2451
- text-decoration: underline !important;
2503
+ .tina-tailwind .text-blue-500 {
2504
+ --tw-text-opacity: 1 !important;
2505
+ color: rgba(0, 132, 255, var(--tw-text-opacity)) !important;
2452
2506
  }
2453
2507
 
2454
- .tina-tailwind .opacity-80 {
2455
- opacity: .8 !important;
2508
+ .tina-tailwind .text-blue-400 {
2509
+ --tw-text-opacity: 1 !important;
2510
+ color: rgba(34, 150, 254, var(--tw-text-opacity)) !important;
2456
2511
  }
2457
2512
 
2458
- .tina-tailwind .opacity-50 {
2459
- opacity: .5 !important;
2513
+ .tina-tailwind .underline {
2514
+ text-decoration: underline !important;
2460
2515
  }
2461
2516
 
2462
2517
  .tina-tailwind .opacity-100 {
2463
2518
  opacity: 1 !important;
2464
2519
  }
2465
2520
 
2466
- .tina-tailwind .opacity-0 {
2467
- opacity: 0 !important;
2468
- }
2469
-
2470
2521
  .tina-tailwind .opacity-90 {
2471
2522
  opacity: .9 !important;
2472
2523
  }
2473
2524
 
2525
+ .tina-tailwind .opacity-80 {
2526
+ opacity: .8 !important;
2527
+ }
2528
+
2529
+ .tina-tailwind .opacity-50 {
2530
+ opacity: .5 !important;
2531
+ }
2532
+
2474
2533
  .tina-tailwind .opacity-70 {
2475
2534
  opacity: .7 !important;
2476
2535
  }
2477
2536
 
2537
+ .tina-tailwind .opacity-0 {
2538
+ opacity: 0 !important;
2539
+ }
2540
+
2478
2541
  .tina-tailwind .shadow-lg {
2479
2542
  --tw-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05) !important;
2480
2543
  box-shadow: var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow) !important;
2481
2544
  }
2482
2545
 
2483
- .tina-tailwind .shadow-sm {
2484
- --tw-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05) !important;
2546
+ .tina-tailwind .shadow-2xl {
2547
+ --tw-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25) !important;
2485
2548
  box-shadow: var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow) !important;
2486
2549
  }
2487
2550
 
@@ -2490,6 +2553,11 @@ Document
2490
2553
  box-shadow: var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow) !important;
2491
2554
  }
2492
2555
 
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
+
2493
2561
  .tina-tailwind .ring-1 {
2494
2562
  --tw-ring-offset-shadow: var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color) !important;
2495
2563
  --tw-ring-shadow: var(--tw-ring-inset) 0 0 0 calc(1px + var(--tw-ring-offset-width)) var(--tw-ring-color) !important;
@@ -2509,14 +2577,14 @@ Document
2509
2577
  filter: var(--tw-filter) !important;
2510
2578
  }
2511
2579
 
2512
- .tina-tailwind .transition-colors {
2513
- transition-property: background-color, border-color, color, fill, stroke !important;
2580
+ .tina-tailwind .transition-opacity {
2581
+ transition-property: opacity !important;
2514
2582
  transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1) !important;
2515
2583
  transition-duration: 150ms !important;
2516
2584
  }
2517
2585
 
2518
- .tina-tailwind .transition-opacity {
2519
- transition-property: opacity !important;
2586
+ .tina-tailwind .transition-colors {
2587
+ transition-property: background-color, border-color, color, fill, stroke !important;
2520
2588
  transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1) !important;
2521
2589
  transition-duration: 150ms !important;
2522
2590
  }
@@ -2533,38 +2601,55 @@ Document
2533
2601
  transition-duration: 150ms !important;
2534
2602
  }
2535
2603
 
2536
- .tina-tailwind .duration-150 {
2537
- transition-duration: 150ms !important;
2538
- }
2539
-
2540
2604
  .tina-tailwind .duration-300 {
2541
2605
  transition-duration: 300ms !important;
2542
2606
  }
2543
2607
 
2544
- .tina-tailwind .duration-75 {
2545
- transition-duration: 75ms !important;
2608
+ .tina-tailwind .duration-150 {
2609
+ transition-duration: 150ms !important;
2546
2610
  }
2547
2611
 
2548
2612
  .tina-tailwind .duration-100 {
2549
2613
  transition-duration: 100ms !important;
2550
2614
  }
2551
2615
 
2616
+ .tina-tailwind .duration-75 {
2617
+ transition-duration: 75ms !important;
2618
+ }
2619
+
2552
2620
  .tina-tailwind .ease-out {
2553
2621
  transition-timing-function: cubic-bezier(0, 0, 0.2, 1) !important;
2554
2622
  }
2555
2623
 
2624
+ .tina-tailwind .ease-in {
2625
+ transition-timing-function: cubic-bezier(0.4, 0, 1, 1) !important;
2626
+ }
2627
+
2556
2628
  .tina-tailwind .ease-in-out {
2557
2629
  transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1) !important;
2558
2630
  }
2559
2631
 
2560
- .tina-tailwind .ease-in {
2561
- transition-timing-function: cubic-bezier(0.4, 0, 1, 1) !important;
2562
- }
2632
+ .tina-tailwind .icon-parent svg {
2633
+ fill: currentColor !important;
2634
+ }
2563
2635
 
2564
2636
  .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));
2637
+ 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";
2638
+ --tw-text-opacity: 1;
2639
+ color: rgba(86, 81, 101, var(--tw-text-opacity));
2640
+ }
2641
+
2642
+ .first\\:pt-3:first-child {
2643
+ padding-top: 12px !important;
2644
+ }
2645
+
2646
+ .last\\:pb-3:last-child {
2647
+ padding-bottom: 12px !important;
2648
+ }
2649
+
2650
+ .hover\\:bg-blue-600:hover {
2651
+ --tw-bg-opacity: 1 !important;
2652
+ background-color: rgba(5, 116, 228, var(--tw-bg-opacity)) !important;
2568
2653
  }
2569
2654
 
2570
2655
  .hover\\:bg-gray-50:hover {
@@ -2577,9 +2662,9 @@ Document
2577
2662
  color: rgba(5, 116, 228, var(--tw-text-opacity)) !important;
2578
2663
  }
2579
2664
 
2580
- .hover\\:text-blue-500:hover {
2665
+ .hover\\:text-blue-400:hover {
2581
2666
  --tw-text-opacity: 1 !important;
2582
- color: rgba(0, 132, 255, var(--tw-text-opacity)) !important;
2667
+ color: rgba(34, 150, 254, var(--tw-text-opacity)) !important;
2583
2668
  }
2584
2669
 
2585
2670
  .hover\\:opacity-100:hover {
@@ -2590,31 +2675,38 @@ Document
2590
2675
  opacity: .8 !important;
2591
2676
  }
2592
2677
 
2593
- .focus\\:outline-none:focus {
2594
- outline: 2px solid transparent !important;
2595
- outline-offset: 2px !important;
2678
+ .focus\\:text-blue-400:focus {
2679
+ --tw-text-opacity: 1 !important;
2680
+ color: rgba(34, 150, 254, var(--tw-text-opacity)) !important;
2596
2681
  }
2597
2682
 
2598
- .group:hover .group-hover\\:opacity-100 {
2599
- opacity: 1 !important;
2683
+ .focus\\:underline:focus {
2684
+ text-decoration: underline !important;
2600
2685
  }
2601
2686
 
2602
- .group:hover .group-hover\\:opacity-80 {
2603
- opacity: .8 !important;
2687
+ .focus\\:shadow-outline:focus {
2688
+ --tw-shadow: 0 0 0 3px rgba(66, 153, 225, 0.5) !important;
2689
+ box-shadow: var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow) !important;
2604
2690
  }
2605
2691
 
2606
- @media (min-width: 640px) {
2692
+ .focus\\:outline-none:focus {
2693
+ outline: 2px solid transparent !important;
2694
+ outline-offset: 2px !important;
2695
+ }
2607
2696
 
2608
- .sm\\:rounded-lg {
2609
- border-radius: 8px !important;
2610
- }
2697
+ .focus\\:ring-2:focus {
2698
+ --tw-ring-offset-shadow: var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color) !important;
2699
+ --tw-ring-shadow: var(--tw-ring-inset) 0 0 0 calc(2px + var(--tw-ring-offset-width)) var(--tw-ring-color) !important;
2700
+ box-shadow: var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow, 0 0 #0000) !important;
2611
2701
  }
2612
2702
 
2613
- @media (min-width: 1024px) {
2703
+ .focus\\:ring-blue-500:focus {
2704
+ --tw-ring-opacity: 1 !important;
2705
+ --tw-ring-color: rgba(0, 132, 255, var(--tw-ring-opacity)) !important;
2706
+ }
2614
2707
 
2615
- .lg\\:w-96 {
2616
- width: 384px !important;
2617
- }
2708
+ .group:hover .group-hover\\:opacity-100 {
2709
+ opacity: 1 !important;
2618
2710
  }
2619
2711
  `;
2620
2712
  function useTina({
@@ -2671,7 +2763,7 @@ class ErrorBoundary extends React.Component {
2671
2763
  return { hasError: true, message: error.message };
2672
2764
  }
2673
2765
  render() {
2674
- const branchData = window.localStorage.getItem("tinacms-current-branch");
2766
+ const branchData = window.localStorage && window.localStorage.getItem("tinacms-current-branch");
2675
2767
  const hasBranchData = branchData && branchData.length > 0;
2676
2768
  if (this.state.hasError && !this.state.pageRefresh) {
2677
2769
  return /* @__PURE__ */ React.createElement("div", {
@@ -2786,7 +2878,7 @@ const TinaQueryInner = (_e) => {
2786
2878
  variables: props.variables,
2787
2879
  data: props.data
2788
2880
  });
2789
- return /* @__PURE__ */ React.createElement(React.Fragment, null, children(isLoading ? props : __spreadProps(__spreadValues({}, props), { data: liveData })));
2881
+ return /* @__PURE__ */ React.createElement(React.Fragment, null, children(isLoading || !props.query ? props : __spreadProps(__spreadValues({}, props), { data: liveData })));
2790
2882
  };
2791
2883
  const TinaDataProvider = ({
2792
2884
  children,
@@ -3064,210 +3156,70 @@ function IconBase(props) {
3064
3156
  return elem(conf);
3065
3157
  }) : elem(DefaultContext);
3066
3158
  }
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
3159
  function ImFilesEmpty(props) {
3083
3160
  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
3161
  }
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
3162
  const useGetCollections = (cms) => {
3178
- const api = new TinaAdminApi(cms.api.tina);
3179
- const [collections, setCollections] = useState([]);
3163
+ const api = new TinaAdminApi(cms);
3164
+ const [info, setInfo] = useState({ collections: [], loading: true, error: false });
3180
3165
  useEffect(() => {
3181
3166
  const fetchCollections = async () => {
3182
3167
  const response = await api.fetchCollections();
3183
- setCollections(response.getCollections);
3168
+ setInfo({
3169
+ collections: response.getCollections,
3170
+ loading: false,
3171
+ error: false
3172
+ });
3184
3173
  };
3185
3174
  fetchCollections();
3186
3175
  }, [cms]);
3187
- return collections;
3176
+ return info;
3188
3177
  };
3189
3178
  const GetCollections = ({ cms, children }) => {
3190
- const collections = useGetCollections(cms);
3179
+ const { collections, loading, error } = useGetCollections(cms);
3191
3180
  if (!collections)
3192
3181
  return null;
3193
- return /* @__PURE__ */ React.createElement(React.Fragment, null, children(collections));
3182
+ return /* @__PURE__ */ React.createElement(React.Fragment, null, children(collections, loading, error));
3183
+ };
3184
+ const slugify = (text) => {
3185
+ return text.toString().toLowerCase().trim().replace(/[^\w\s-]/g, "").replace(/[\s_-]+/g, "_").replace(/^-+|-+$/g, "");
3194
3186
  };
3195
3187
  const Sidebar = ({ cms }) => {
3196
- const { setEdit } = useEditState();
3197
- const logout2 = () => setEdit(false);
3188
+ const screens = cms.plugins.getType("screen").all();
3198
3189
  return /* @__PURE__ */ React.createElement(GetCollections, {
3199
3190
  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
- })))));
3191
+ }, (collections, loading, error) => /* @__PURE__ */ React.createElement(Nav, {
3192
+ sidebarWidth: 360,
3193
+ showCollections: true,
3194
+ collectionsInfo: {
3195
+ collections,
3196
+ loading,
3197
+ error
3198
+ },
3199
+ screens,
3200
+ contentCreators: [],
3201
+ RenderNavSite: ({ view }) => /* @__PURE__ */ React.createElement(SidebarLink, {
3202
+ label: view.name,
3203
+ to: `screens/${slugify(view.name)}`,
3204
+ Icon: view.Icon ? view.Icon : ImFilesEmpty
3205
+ }),
3206
+ RenderNavCollection: ({ collection }) => /* @__PURE__ */ React.createElement(SidebarLink, {
3207
+ label: collection.label ? collection.label : collection.name,
3208
+ to: `collections/${collection.name}`,
3209
+ Icon: ImFilesEmpty
3210
+ })
3211
+ }));
3212
+ };
3213
+ const SidebarLink = (props) => {
3214
+ const { to, label, Icon } = props;
3215
+ return /* @__PURE__ */ React.createElement(NavLink, {
3216
+ className: ({ isActive }) => {
3217
+ return `text-base tracking-wide ${isActive ? "text-blue-600" : "text-gray-500"} hover:text-blue-600 flex items-center opacity-90 hover:opacity-100`;
3218
+ },
3219
+ to
3220
+ }, /* @__PURE__ */ React.createElement(Icon, {
3221
+ className: "mr-2 h-6 opacity-80 w-auto"
3222
+ }), " ", label);
3271
3223
  };
3272
3224
  const GetCMS = ({ children }) => {
3273
3225
  try {
@@ -3277,6 +3229,21 @@ const GetCMS = ({ children }) => {
3277
3229
  return null;
3278
3230
  }
3279
3231
  };
3232
+ function BiEdit(props) {
3233
+ 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
+ }
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
+ function BiLogIn(props) {
3239
+ 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
+ }
3241
+ function BiLogOut(props) {
3242
+ 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);
3243
+ }
3244
+ function BiPlus(props) {
3245
+ return GenIcon({ "tag": "svg", "attr": { "viewBox": "0 0 24 24" }, "child": [{ "tag": "path", "attr": { "d": "M19 11h-6V5h-2v6H5v2h6v6h2v-6h6z" } }] })(props);
3246
+ }
3280
3247
  function MdOutlineArrowBack(props) {
3281
3248
  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
3249
  }
@@ -3345,25 +3312,50 @@ const LogoutPage = () => {
3345
3312
  className: "w-6 h-auto mr-1.5 opacity-80"
3346
3313
  }), " Log out"));
3347
3314
  };
3348
- const DashboardPage = () => {
3315
+ const PageWrapper = ({
3316
+ children
3317
+ }) => {
3349
3318
  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."))));
3319
+ 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"
3320
+ }, children);
3321
+ };
3322
+ const PageHeader = ({
3323
+ isLocalMode,
3324
+ children
3325
+ }) => /* @__PURE__ */ React.createElement(React.Fragment, null, isLocalMode && /* @__PURE__ */ React.createElement(LocalWarning, null), /* @__PURE__ */ React.createElement("div", {
3326
+ className: "bg-white pb-4 pt-18 border-b border-gray-200 px-12"
3327
+ }, /* @__PURE__ */ React.createElement("div", {
3328
+ className: "w-full mx-auto max-w-screen-xl"
3329
+ }, /* @__PURE__ */ React.createElement("div", {
3330
+ className: "w-full flex justify-between items-end"
3331
+ }, children))));
3332
+ const PageBody = ({
3333
+ children
3334
+ }) => /* @__PURE__ */ React.createElement("div", {
3335
+ className: "py-10 px-12"
3336
+ }, children);
3337
+ const PageBodyNarrow = ({
3338
+ children
3339
+ }) => /* @__PURE__ */ React.createElement("div", {
3340
+ className: "py-10 px-12"
3341
+ }, /* @__PURE__ */ React.createElement("div", {
3342
+ className: "w-full mx-auto max-w-screen-xl"
3343
+ }, children));
3344
+ const DashboardPage = () => {
3345
+ return /* @__PURE__ */ React.createElement(GetCMS, null, (cms) => {
3346
+ var _a, _b;
3347
+ return /* @__PURE__ */ React.createElement(PageWrapper, null, /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(PageHeader, {
3348
+ isLocalMode: (_b = (_a = cms.api) == null ? void 0 : _a.tina) == null ? void 0 : _b.isLocalMode
3349
+ }, /* @__PURE__ */ React.createElement("h3", {
3350
+ className: "text-2xl text-gray-700"
3351
+ }, "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
+ });
3364
3353
  };
3354
+ function FiMoreVertical(props) {
3355
+ return GenIcon({ "tag": "svg", "attr": { "viewBox": "0 0 24 24", "fill": "none", "stroke": "currentColor", "strokeWidth": "2", "strokeLinecap": "round", "strokeLinejoin": "round" }, "child": [{ "tag": "circle", "attr": { "cx": "12", "cy": "12", "r": "1" } }, { "tag": "circle", "attr": { "cx": "12", "cy": "5", "r": "1" } }, { "tag": "circle", "attr": { "cx": "12", "cy": "19", "r": "1" } }] })(props);
3356
+ }
3365
3357
  const useGetCollection = (cms, collectionName, includeDocuments = true) => {
3366
- const api = new TinaAdminApi(cms.api.tina);
3358
+ const api = new TinaAdminApi(cms);
3367
3359
  const [collection, setCollection] = useState(void 0);
3368
3360
  useEffect(() => {
3369
3361
  const fetchCollection = async () => {
@@ -3390,22 +3382,11 @@ const TemplateMenu = ({ templates }) => {
3390
3382
  return /* @__PURE__ */ React.createElement(Menu, {
3391
3383
  as: "div",
3392
3384
  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, {
3385
+ }, () => /* @__PURE__ */ React.createElement("div", null, /* @__PURE__ */ React.createElement("div", null, /* @__PURE__ */ React.createElement(Menu.Button, {
3386
+ 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"
3387
+ }, "Create New ", /* @__PURE__ */ React.createElement(BiPlus, {
3388
+ className: "w-5 h-full ml-1 opacity-70"
3389
+ }))), /* @__PURE__ */ React.createElement(Transition, {
3409
3390
  as: Fragment,
3410
3391
  enter: "transition ease-out duration-100",
3411
3392
  enterFrom: "transform opacity-0 scale-95",
@@ -3420,13 +3401,13 @@ const TemplateMenu = ({ templates }) => {
3420
3401
  }, templates.map((template) => /* @__PURE__ */ React.createElement(Menu.Item, {
3421
3402
  key: `${template.label}-${template.name}`
3422
3403
  }, ({ active }) => /* @__PURE__ */ React.createElement(Link, {
3423
- to: `${location.pathname}/${template.name}/new`,
3404
+ to: `${template.name}/new`,
3424
3405
  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
3406
  }, template.label))))))));
3426
3407
  };
3427
3408
  const CollectionListPage = () => {
3428
- const location2 = useLocation();
3429
3409
  const { collectionName } = useParams();
3410
+ const navigate = useNavigate();
3430
3411
  return /* @__PURE__ */ React.createElement(GetCMS, null, (cms) => {
3431
3412
  const plugins = cms.plugins.all("tina-admin");
3432
3413
  const routeMapping = plugins.find(({ name }) => name === "route-mapping");
@@ -3435,68 +3416,117 @@ const CollectionListPage = () => {
3435
3416
  collectionName,
3436
3417
  includeDocuments: true
3437
3418
  }, (collection) => {
3419
+ var _a, _b;
3438
3420
  const totalCount = collection.documents.totalCount;
3439
3421
  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, {
3422
+ return /* @__PURE__ */ React.createElement(PageWrapper, null, /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(PageHeader, {
3423
+ isLocalMode: (_b = (_a = cms == null ? void 0 : cms.api) == null ? void 0 : _a.tina) == null ? void 0 : _b.isLocalMode
3424
+ }, /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("h3", {
3425
+ className: "text-2xl text-gray-700"
3426
+ }, collection.label ? collection.label : collection.name), !collection.templates && /* @__PURE__ */ React.createElement(Link, {
3427
+ to: `new`,
3428
+ 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"
3429
+ }, "Create New", " ", /* @__PURE__ */ React.createElement(BiPlus, {
3430
+ className: "w-5 h-full ml-1 opacity-70"
3431
+ })), collection.templates && /* @__PURE__ */ React.createElement(TemplateMenu, {
3453
3432
  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"
3433
+ }))), /* @__PURE__ */ React.createElement(PageBody, null, /* @__PURE__ */ React.createElement("div", {
3434
+ className: "w-full mx-auto max-w-screen-xl"
3435
+ }, totalCount > 0 && /* @__PURE__ */ React.createElement("table", {
3436
+ className: "table-auto shadow bg-white border-b border-gray-200 w-full max-w-full rounded-lg"
3458
3437
  }, /* @__PURE__ */ React.createElement("tbody", {
3459
- className: "bg-white divide-y divide-gray-150"
3438
+ className: "divide-y divide-gray-150"
3460
3439
  }, documents.map((document) => {
3461
- const livesiteRoute = routeMapping ? routeMapping.mapper(collection, document.node) : void 0;
3440
+ const overrideRoute = routeMapping ? routeMapping.mapper(collection, document.node) : void 0;
3462
3441
  return /* @__PURE__ */ React.createElement("tr", {
3463
- key: document.node.sys.relativePath
3442
+ key: `document-${document.node.sys.filename}`,
3443
+ className: ""
3464
3444
  }, /* @__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"
3445
+ className: "px-6 py-2 whitespace-nowrap"
3446
+ }, overrideRoute && /* @__PURE__ */ React.createElement("a", {
3447
+ className: "text-blue-600 hover:text-blue-400 flex items-center gap-3",
3448
+ href: `${overrideRoute}`
3449
+ }, /* @__PURE__ */ React.createElement(BiEdit, {
3450
+ className: "inline-block h-6 w-auto opacity-70"
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}`
3458
+ }, /* @__PURE__ */ React.createElement(BiEdit, {
3459
+ className: "inline-block h-6 w-auto opacity-70"
3460
+ }), /* @__PURE__ */ React.createElement("span", null, /* @__PURE__ */ React.createElement("span", {
3461
+ className: "block text-xs text-gray-400 mb-1 uppercase"
3462
+ }, "Filename"), /* @__PURE__ */ React.createElement("span", {
3463
+ className: "h-5 leading-5 block whitespace-nowrap"
3464
+ }, document.node.sys.filename)))), /* @__PURE__ */ React.createElement("td", {
3465
+ className: "px-6 py-4 whitespace-nowrap"
3471
3466
  }, /* @__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"
3467
+ className: "block text-xs text-gray-400 mb-1 uppercase"
3468
+ }, "Extension"), /* @__PURE__ */ React.createElement("span", {
3469
+ className: "h-5 leading-5 block text-sm font-medium text-gray-900"
3470
+ }, document.node.sys.extension)), /* @__PURE__ */ React.createElement("td", {
3471
+ className: "px-6 py-4 whitespace-nowrap"
3477
3472
  }, /* @__PURE__ */ React.createElement("span", {
3478
- className: "block text-xs mb-0.5 text-gray-400 uppercase"
3473
+ className: "block text-xs text-gray-400 mb-1 uppercase"
3479
3474
  }, "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
- }))))));
3475
+ className: "h-5 leading-5 block text-sm font-medium text-gray-900"
3476
+ }, document.node.sys.template)), overrideRoute && /* @__PURE__ */ React.createElement("td", {
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
+ })));
3489
+ })))))));
3495
3490
  });
3496
3491
  });
3497
3492
  };
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
+ function HiChevronRight(props) {
3526
+ 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
+ }
3498
3528
  const useGetDocumentFields = (cms, collectionName, templateName) => {
3499
- const api = new TinaAdminApi(cms.api.tina);
3529
+ const api = new TinaAdminApi(cms);
3500
3530
  const [info, setInfo] = useState({
3501
3531
  collection: void 0,
3502
3532
  template: void 0,
@@ -3541,9 +3571,10 @@ const GetDocumentFields = ({
3541
3571
  return /* @__PURE__ */ React.createElement(React.Fragment, null, children({ collection, template, fields, mutationInfo }));
3542
3572
  };
3543
3573
  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"]);
3574
+ const api = new TinaAdminApi(cms);
3575
+ const _a = values, { filename } = _a, leftover = __objRest(_a, ["filename"]);
3546
3576
  const { includeCollection, includeTemplate } = mutationInfo;
3577
+ const relativePath = `${filename}.${collection.format}`;
3547
3578
  const params = transformDocumentIntoMutationRequestPayload(__spreadValues(__spreadValues({
3548
3579
  _collection: collection.name
3549
3580
  }, template && { _template: template.name }), leftover), {
@@ -3554,43 +3585,78 @@ const createDocument = async (cms, collection, template, mutationInfo, values) =
3554
3585
  };
3555
3586
  const CollectionCreatePage = () => {
3556
3587
  const { collectionName, templateName } = useParams();
3557
- const navigate = useNavigate();
3558
3588
  return /* @__PURE__ */ React.createElement(GetCMS, null, (cms) => /* @__PURE__ */ React.createElement(GetDocumentFields, {
3559
3589
  cms,
3560
3590
  collectionName,
3561
3591
  templateName
3562
- }, ({ collection, template, fields, mutationInfo }) => {
3563
- const form = new Form({
3592
+ }, ({ collection, template, fields, mutationInfo }) => /* @__PURE__ */ React.createElement(RenderForm$1, {
3593
+ cms,
3594
+ collection,
3595
+ template,
3596
+ fields,
3597
+ mutationInfo
3598
+ })));
3599
+ };
3600
+ const RenderForm$1 = ({ cms, collection, template, fields, mutationInfo }) => {
3601
+ var _a, _b;
3602
+ const navigate = useNavigate();
3603
+ const [formIsPristine, setFormIsPristine] = useState(true);
3604
+ const form = useMemo(() => {
3605
+ return new Form({
3564
3606
  id: "create-form",
3565
3607
  label: "form",
3566
3608
  fields: [
3567
3609
  {
3568
- name: "relativePath",
3569
- label: "Relative Path",
3610
+ name: "filename",
3611
+ label: "Filename",
3570
3612
  component: "text",
3571
- required: true,
3572
- defaultValue: `${collection.name}${Date.now()}.${collection.format}`
3613
+ description: `A unique filename for the content. Example: My_Document`,
3614
+ placeholder: `My_Document`,
3615
+ validate: (value, allValues, meta) => {
3616
+ if (!value) {
3617
+ if (meta.dirty) {
3618
+ return "Required";
3619
+ }
3620
+ return true;
3621
+ }
3622
+ const isValid = /^[_a-zA-Z][-,_a-zA-Z0-9]*$/.test(value);
3623
+ if (value && !isValid) {
3624
+ return "Must begin with a-z, A-Z, or _ and contain only a-z, A-Z, 0-9, - or _";
3625
+ }
3626
+ }
3573
3627
  },
3574
3628
  ...fields
3575
3629
  ],
3576
3630
  onSubmit: async (values) => {
3577
3631
  await createDocument(cms, collection, template, mutationInfo, values);
3578
- navigate(`/admin/collections/${collection.name}`);
3632
+ navigate(`/collections/${collection.name}`);
3579
3633
  }
3580
3634
  });
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
- }));
3635
+ }, [cms, collection, template, fields, mutationInfo]);
3636
+ 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", {
3637
+ className: "py-4 px-20 border-b border-gray-200 bg-white"
3638
+ }, /* @__PURE__ */ React.createElement("div", {
3639
+ className: "max-w-form mx-auto"
3640
+ }, /* @__PURE__ */ React.createElement("div", {
3641
+ className: "mb-2"
3642
+ }, /* @__PURE__ */ React.createElement("span", {
3643
+ className: "block text-sm leading-tight uppercase text-gray-400 mb-1"
3644
+ }, /* @__PURE__ */ React.createElement(Link, {
3645
+ to: `/collections/${collection.name}`,
3646
+ 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"
3647
+ }, collection.label ? collection.label : collection.name), /* @__PURE__ */ React.createElement(HiChevronRight, {
3648
+ className: "inline-block -mt-0.5 opacity-50"
3649
+ })), /* @__PURE__ */ React.createElement("span", {
3650
+ className: "text-xl text-gray-700 font-medium leading-tight"
3651
+ }, "Create New")), /* @__PURE__ */ React.createElement(FormStatus, {
3652
+ pristine: formIsPristine
3653
+ }))), /* @__PURE__ */ React.createElement(FormBuilder, {
3654
+ form,
3655
+ onPristineChange: setFormIsPristine
3656
+ })));
3591
3657
  };
3592
3658
  const useGetDocument = (cms, collectionName, relativePath) => {
3593
- const api = new TinaAdminApi(cms.api.tina);
3659
+ const api = new TinaAdminApi(cms);
3594
3660
  const [document, setDocument] = useState(void 0);
3595
3661
  useEffect(() => {
3596
3662
  const fetchDocument = async () => {
@@ -3614,7 +3680,7 @@ const GetDocument = ({
3614
3680
  return /* @__PURE__ */ React.createElement(React.Fragment, null, children(document));
3615
3681
  };
3616
3682
  const updateDocument = async (cms, relativePath, collection, mutationInfo, values) => {
3617
- const api = new TinaAdminApi(cms.api.tina);
3683
+ const api = new TinaAdminApi(cms);
3618
3684
  const { includeCollection, includeTemplate } = mutationInfo;
3619
3685
  const params = transformDocumentIntoMutationRequestPayload(values, {
3620
3686
  includeCollection,
@@ -3624,7 +3690,6 @@ const updateDocument = async (cms, relativePath, collection, mutationInfo, value
3624
3690
  };
3625
3691
  const CollectionUpdatePage = () => {
3626
3692
  const { collectionName, filename } = useParams();
3627
- const navigate = useNavigate();
3628
3693
  return /* @__PURE__ */ React.createElement(GetCMS, null, (cms) => /* @__PURE__ */ React.createElement(GetDocumentFields, {
3629
3694
  cms,
3630
3695
  collectionName
@@ -3634,28 +3699,77 @@ const CollectionUpdatePage = () => {
3634
3699
  cms,
3635
3700
  collectionName: collection.name,
3636
3701
  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
- });
3702
+ }, (document) => /* @__PURE__ */ React.createElement(RenderForm, {
3703
+ cms,
3704
+ document,
3705
+ filename,
3706
+ relativePath,
3707
+ collection,
3708
+ mutationInfo
3709
+ }));
3657
3710
  }));
3658
3711
  };
3712
+ const RenderForm = ({
3713
+ cms,
3714
+ document,
3715
+ filename,
3716
+ relativePath,
3717
+ collection,
3718
+ mutationInfo
3719
+ }) => {
3720
+ var _a, _b;
3721
+ const navigate = useNavigate();
3722
+ const [formIsPristine, setFormIsPristine] = useState(true);
3723
+ const form = useMemo(() => {
3724
+ return new Form({
3725
+ id: "update-form",
3726
+ label: "form",
3727
+ fields: document.form.fields,
3728
+ initialValues: document.values,
3729
+ onSubmit: async (values) => {
3730
+ await updateDocument(cms, relativePath, collection, mutationInfo, values);
3731
+ navigate(`/collections/${collection.name}`);
3732
+ }
3733
+ });
3734
+ }, [cms, document, relativePath, collection, mutationInfo]);
3735
+ 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", {
3736
+ className: "py-4 px-20 border-b border-gray-200 bg-white"
3737
+ }, /* @__PURE__ */ React.createElement("div", {
3738
+ className: "max-w-form mx-auto"
3739
+ }, /* @__PURE__ */ React.createElement("div", {
3740
+ className: "mb-2"
3741
+ }, /* @__PURE__ */ React.createElement("span", {
3742
+ className: "block text-sm leading-tight uppercase text-gray-400 mb-1"
3743
+ }, /* @__PURE__ */ React.createElement(Link, {
3744
+ to: `/collections/${collection.name}`,
3745
+ 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"
3746
+ }, collection.label ? collection.label : collection.name), /* @__PURE__ */ React.createElement(HiChevronRight, {
3747
+ className: "inline-block -mt-0.5 opacity-50"
3748
+ })), /* @__PURE__ */ React.createElement("span", {
3749
+ className: "text-xl text-gray-700 font-medium leading-tight"
3750
+ }, "Edit ", `${filename}.${collection.format}`)), /* @__PURE__ */ React.createElement(FormStatus, {
3751
+ pristine: formIsPristine
3752
+ }))), /* @__PURE__ */ React.createElement(FormBuilder, {
3753
+ form,
3754
+ onPristineChange: setFormIsPristine
3755
+ })));
3756
+ };
3757
+ const ScreenPage = () => {
3758
+ const { screenName } = useParams();
3759
+ return /* @__PURE__ */ React.createElement(GetCMS, null, (cms) => {
3760
+ var _a, _b;
3761
+ const screens = cms.plugins.getType("screen").all();
3762
+ const selectedScreen = screens.find(({ name }) => slugify(name) === screenName);
3763
+ return /* @__PURE__ */ React.createElement("div", {
3764
+ className: "relative w-full h-full flex flex-col items-stretch justify-between"
3765
+ }, ((_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", {
3766
+ className: "flex-1 overflow-y-auto relative flex flex-col items-stretch justify-between"
3767
+ }, /* @__PURE__ */ React.createElement(selectedScreen.Component, {
3768
+ close: () => {
3769
+ }
3770
+ })));
3771
+ });
3772
+ };
3659
3773
  const Redirect = () => {
3660
3774
  React.useEffect(() => {
3661
3775
  if (window) {
@@ -3676,34 +3790,41 @@ const TinaAdmin = () => {
3676
3790
  return /* @__PURE__ */ React.createElement(GetCMS, null, (cms) => {
3677
3791
  const isTinaAdminEnabled = cms.flags.get("tina-admin");
3678
3792
  if (isTinaAdminEnabled) {
3679
- return /* @__PURE__ */ React.createElement(Layout, null, /* @__PURE__ */ React.createElement(BrowserRouter, null, /* @__PURE__ */ React.createElement("div", {
3793
+ return /* @__PURE__ */ React.createElement(Layout, null, /* @__PURE__ */ React.createElement(BrowserRouter, {
3794
+ basename: "/admin"
3795
+ }, /* @__PURE__ */ React.createElement("div", {
3680
3796
  className: "flex items-stretch h-screen overflow-hidden"
3681
3797
  }, /* @__PURE__ */ React.createElement(Sidebar, {
3682
3798
  cms
3683
3799
  }), /* @__PURE__ */ React.createElement("div", {
3684
3800
  className: "flex-1"
3685
3801
  }, /* @__PURE__ */ React.createElement(Routes, null, /* @__PURE__ */ React.createElement(Route, {
3686
- path: "/admin/collections/:collectionName/new",
3802
+ path: "collections/:collectionName/new",
3687
3803
  element: /* @__PURE__ */ React.createElement(CollectionCreatePage, null)
3688
3804
  }), /* @__PURE__ */ React.createElement(Route, {
3689
- path: "/admin/collections/:collectionName/:templateName/new",
3805
+ path: "collections/:collectionName/:templateName/new",
3690
3806
  element: /* @__PURE__ */ React.createElement(CollectionCreatePage, null)
3691
3807
  }), /* @__PURE__ */ React.createElement(Route, {
3692
- path: "/admin/collections/:collectionName/:filename",
3808
+ path: "collections/:collectionName/:filename",
3693
3809
  element: /* @__PURE__ */ React.createElement(CollectionUpdatePage, null)
3694
3810
  }), /* @__PURE__ */ React.createElement(Route, {
3695
- path: "/admin/collections/:collectionName",
3811
+ path: "collections/:collectionName",
3696
3812
  element: /* @__PURE__ */ React.createElement(CollectionListPage, null)
3697
3813
  }), /* @__PURE__ */ React.createElement(Route, {
3698
- path: "/admin",
3814
+ path: "screens/:screenName",
3815
+ element: /* @__PURE__ */ React.createElement(ScreenPage, null)
3816
+ }), /* @__PURE__ */ React.createElement(Route, {
3817
+ path: "/",
3699
3818
  element: /* @__PURE__ */ React.createElement(DashboardPage, null)
3700
3819
  }))))));
3701
3820
  } 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",
3821
+ return /* @__PURE__ */ React.createElement(Layout, null, /* @__PURE__ */ React.createElement(BrowserRouter, {
3822
+ basename: "/admin"
3823
+ }, /* @__PURE__ */ React.createElement(Routes, null, /* @__PURE__ */ React.createElement(Route, {
3824
+ path: "logout",
3704
3825
  element: /* @__PURE__ */ React.createElement(LogoutPage, null)
3705
3826
  }), /* @__PURE__ */ React.createElement(Route, {
3706
- path: "/admin",
3827
+ path: "/",
3707
3828
  element: /* @__PURE__ */ React.createElement(Redirect, null)
3708
3829
  }))));
3709
3830
  }