tinacms 1.1.5 → 1.2.1

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.
Files changed (58) hide show
  1. package/LICENSE +8 -0
  2. package/dist/admin/api.d.ts +9 -11
  3. package/dist/admin/components/AuthTemplate.d.ts +2 -10
  4. package/dist/admin/components/GetCMS.d.ts +2 -10
  5. package/dist/admin/components/GetCollection.d.ts +6 -12
  6. package/dist/admin/components/GetCollections.d.ts +2 -10
  7. package/dist/admin/components/GetDocument.d.ts +2 -10
  8. package/dist/admin/components/Layout.d.ts +2 -10
  9. package/dist/admin/components/LoadingPage.d.ts +2 -10
  10. package/dist/admin/components/Page.d.ts +1 -10
  11. package/dist/admin/components/Sidebar.d.ts +2 -10
  12. package/dist/admin/index.d.ts +2 -10
  13. package/dist/admin/pages/CollectionCreatePage.d.ts +2 -10
  14. package/dist/admin/pages/CollectionListPage.d.ts +2 -10
  15. package/dist/admin/pages/CollectionUpdatePage.d.ts +2 -10
  16. package/dist/admin/pages/DashboardPage.d.ts +2 -10
  17. package/dist/admin/pages/LoginPage.d.ts +2 -10
  18. package/dist/admin/pages/LogoutPage.d.ts +2 -10
  19. package/dist/admin/pages/ScreenPage.d.ts +2 -10
  20. package/dist/admin/plugins/route-mapping.d.ts +1 -10
  21. package/dist/admin/types.d.ts +1 -10
  22. package/dist/auth/AuthModal.d.ts +2 -10
  23. package/dist/auth/TinaCloudProvider.d.ts +1 -10
  24. package/dist/auth/authenticate.d.ts +3 -12
  25. package/dist/auth/index.d.ts +1 -10
  26. package/dist/auth/popupWindow.d.ts +1 -10
  27. package/dist/auth/useGenerator.d.ts +1 -10
  28. package/dist/auth/useTinaAuthRedirect.d.ts +1 -10
  29. package/dist/client.d.ts +1 -10
  30. package/dist/client.es.js +1 -29
  31. package/dist/client.js +3 -31
  32. package/dist/edit-state.d.ts +1 -10
  33. package/dist/hooks/create-page-plugin.d.ts +1 -10
  34. package/dist/hooks/formify/formify-utils.d.ts +1 -10
  35. package/dist/hooks/formify/formify.d.ts +1 -10
  36. package/dist/hooks/formify/index.d.ts +1 -10
  37. package/dist/hooks/formify/reducer.d.ts +1 -10
  38. package/dist/hooks/formify/spec/runner.d.ts +1 -10
  39. package/dist/hooks/formify/spec/util.d.ts +1 -10
  40. package/dist/hooks/formify/types.d.ts +1 -10
  41. package/dist/hooks/formify/util.d.ts +1 -10
  42. package/dist/hooks/use-content-creator.d.ts +1 -10
  43. package/dist/hooks/use-graphql-forms.d.ts +1 -10
  44. package/dist/index.d.ts +1 -10
  45. package/dist/index.es.js +369 -87
  46. package/dist/index.js +370 -88
  47. package/dist/internalClient/formify.d.ts +1 -10
  48. package/dist/internalClient/index.d.ts +2 -13
  49. package/dist/rich-text/index.d.ts +2 -10
  50. package/dist/rich-text/prism.d.ts +2 -10
  51. package/dist/style.css +46 -8
  52. package/dist/tina-cms.d.ts +2 -10
  53. package/dist/types/cms.d.ts +1 -10
  54. package/dist/unifiedClient/index.d.ts +1 -11
  55. package/dist/utils/client.d.ts +1 -10
  56. package/dist/utils/index.d.ts +1 -10
  57. package/package.json +5 -6
  58. package/dist/utils/parseUrl.d.ts +0 -18
package/dist/index.es.js CHANGED
@@ -1,4 +1,4 @@
1
- import { useCMS, Form, GlobalFormPlugin, EventBus, Modal, ModalPopup, ModalHeader, ModalBody, ModalActions, Button, LoadingDots, useLocalStorage, TinaCMS, BranchSwitcherPlugin, BranchDataProvider, TinaProvider, TinaMediaStore, DummyMediaStore, Nav, LocalWarning, BillingWarning, Select, OverflowMenu, CursorPaginator, PopupModal, BaseTextField, wrapFieldsWithMeta, FormStatus, FormBuilder } from "@tinacms/toolkit";
1
+ import { useCMS, Form, GlobalFormPlugin, EventBus, Modal, ModalPopup, ModalHeader, ModalBody, ModalActions, Button, LoadingDots, useLocalStorage, TinaCMS, BranchSwitcherPlugin, BranchDataProvider, TinaProvider, TinaMediaStore, DummyMediaStore, Nav, BranchBanner, LocalWarning, BillingWarning, Select, Input, ReactDateTimeWithStyles, textFieldClasses, Toggle, OverflowMenu, CursorPaginator, PopupModal, BaseTextField, wrapFieldsWithMeta, FormStatus, FormBuilder } from "@tinacms/toolkit";
2
2
  export * from "@tinacms/toolkit";
3
3
  export { MdxFieldPluginExtendible } from "@tinacms/toolkit";
4
4
  import * as G from "graphql";
@@ -6,12 +6,11 @@ import { TypeInfo, visit, visitWithTypeInfo, getNamedType, GraphQLObjectType, is
6
6
  import set from "lodash.set";
7
7
  import React, { useState, useCallback, useEffect, Fragment, useMemo } from "react";
8
8
  import { getIn, setIn } from "final-form";
9
- import { resolveForm, TinaSchema, addNamespaceToSchema, validateSchema } from "@tinacms/schema-tools";
9
+ import { resolveForm, TinaSchema, addNamespaceToSchema, parseURL, validateSchema } from "@tinacms/schema-tools";
10
10
  export { NAMER, resolveForm } from "@tinacms/schema-tools";
11
11
  import gql$1 from "graphql-tag";
12
12
  import * as yup from "yup";
13
13
  import { setEditing, TinaDataContext, EditContext, useEditState } from "@tinacms/sharedctx";
14
- import UrlPattern from "url-pattern";
15
14
  import { NavLink, useSearchParams, useNavigate, useParams, useLocation, Link, HashRouter, Routes, Route } from "react-router-dom";
16
15
  import { Transition, Menu } from "@headlessui/react";
17
16
  import { useWindowWidth } from "@react-hook/window-size";
@@ -2117,7 +2116,7 @@ const parseRefForBranchName = (ref) => {
2117
2116
  };
2118
2117
  class Client {
2119
2118
  constructor({ tokenStorage = "MEMORY", ...options }) {
2120
- var _a, _b, _c, _d, _e, _f, _g, _h;
2119
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B, _C, _D, _E, _F, _G, _H, _I, _J, _K, _L, _M, _N, _O, _P;
2121
2120
  this.events = new EventBus();
2122
2121
  this.addPendingContent = async (props) => {
2123
2122
  const mutation = `#graphql
@@ -2167,6 +2166,15 @@ mutation addPendingDocumentMutation(
2167
2166
  };
2168
2167
  this.onLogin = (_d = (_c = (_b = (_a = options.schema) == null ? void 0 : _a.config) == null ? void 0 : _b.admin) == null ? void 0 : _c.auth) == null ? void 0 : _d.onLogin;
2169
2168
  this.onLogout = (_h = (_g = (_f = (_e = options.schema) == null ? void 0 : _e.config) == null ? void 0 : _f.admin) == null ? void 0 : _g.auth) == null ? void 0 : _h.onLogout;
2169
+ if ((_l = (_k = (_j = (_i = options.schema) == null ? void 0 : _i.config) == null ? void 0 : _j.admin) == null ? void 0 : _k.auth) == null ? void 0 : _l.logout) {
2170
+ this.onLogout = (_p = (_o = (_n = (_m = options.schema) == null ? void 0 : _m.config) == null ? void 0 : _n.admin) == null ? void 0 : _o.auth) == null ? void 0 : _p.logout;
2171
+ }
2172
+ if ((_t = (_s = (_r = (_q = options.schema) == null ? void 0 : _q.config) == null ? void 0 : _r.admin) == null ? void 0 : _s.auth) == null ? void 0 : _t.getUser) {
2173
+ this.getUser = (_x = (_w = (_v = (_u = options.schema) == null ? void 0 : _u.config) == null ? void 0 : _v.admin) == null ? void 0 : _w.auth) == null ? void 0 : _x.getUser;
2174
+ }
2175
+ if ((_B = (_A = (_z = (_y = options.schema) == null ? void 0 : _y.config) == null ? void 0 : _z.admin) == null ? void 0 : _A.auth) == null ? void 0 : _B.authenticate) {
2176
+ this.authenticate = (_F = (_E = (_D = (_C = options.schema) == null ? void 0 : _C.config) == null ? void 0 : _D.admin) == null ? void 0 : _E.auth) == null ? void 0 : _F.authenticate;
2177
+ }
2170
2178
  if (options.schema) {
2171
2179
  const enrichedSchema = new TinaSchema({
2172
2180
  version: { fullVersion: "", major: "", minor: "", patch: "" },
@@ -2176,6 +2184,9 @@ mutation addPendingDocumentMutation(
2176
2184
  this.schema = enrichedSchema;
2177
2185
  }
2178
2186
  this.options = options;
2187
+ if ((_H = (_G = options.schema) == null ? void 0 : _G.config) == null ? void 0 : _H.contentApiUrlOverride) {
2188
+ this.options.customContentApiUrl = options.schema.config.contentApiUrlOverride;
2189
+ }
2179
2190
  this.setBranch(options.branch);
2180
2191
  this.events.subscribe("branch:change", ({ branchName }) => {
2181
2192
  this.setBranch(branchName);
@@ -2222,6 +2233,9 @@ mutation addPendingDocumentMutation(
2222
2233
  this.getToken = options.getTokenFn;
2223
2234
  break;
2224
2235
  }
2236
+ if ((_L = (_K = (_J = (_I = options.schema) == null ? void 0 : _I.config) == null ? void 0 : _J.admin) == null ? void 0 : _K.auth) == null ? void 0 : _L.getToken) {
2237
+ this.getToken = (_P = (_O = (_N = (_M = options.schema) == null ? void 0 : _M.config) == null ? void 0 : _N.admin) == null ? void 0 : _O.auth) == null ? void 0 : _P.getToken;
2238
+ }
2225
2239
  }
2226
2240
  get isLocalMode() {
2227
2241
  return false;
@@ -2466,10 +2480,7 @@ class LocalClient extends Client {
2466
2480
  localStorage.setItem(LOCAL_CLIENT_KEY, "true");
2467
2481
  return { access_token: "LOCAL", id_token: "LOCAL", refresh_token: "LOCAL" };
2468
2482
  }
2469
- async isAuthorized() {
2470
- return localStorage.getItem(LOCAL_CLIENT_KEY) === "true";
2471
- }
2472
- async isAuthenticated() {
2483
+ async getUser() {
2473
2484
  return localStorage.getItem(LOCAL_CLIENT_KEY) === "true";
2474
2485
  }
2475
2486
  }
@@ -2550,17 +2561,50 @@ class TinaAdminApi {
2550
2561
  }
2551
2562
  }`, { variables: { collection, relativePath } });
2552
2563
  }
2553
- async fetchCollection(collectionName, includeDocuments, after, sortKey, order) {
2564
+ async fetchCollection(collectionName, includeDocuments, after, sortKey, order, filterArgs) {
2565
+ let filter = null;
2566
+ const filterField = filterArgs == null ? void 0 : filterArgs.filterField;
2567
+ if (filterField) {
2568
+ filter = {
2569
+ [collectionName]: {
2570
+ [filterField]: {}
2571
+ }
2572
+ };
2573
+ }
2574
+ if (filterField && (filterArgs == null ? void 0 : filterArgs.startsWith)) {
2575
+ filter[collectionName][filterField] = {
2576
+ ...filter[collectionName][filterField] || {},
2577
+ startsWith: filterArgs.startsWith
2578
+ };
2579
+ }
2580
+ if (filterField && (filterArgs == null ? void 0 : filterArgs.before)) {
2581
+ filter[collectionName][filterField] = {
2582
+ ...filter[collectionName][filterField] || {},
2583
+ before: filterArgs.before
2584
+ };
2585
+ }
2586
+ if (filterField && (filterArgs == null ? void 0 : filterArgs.after)) {
2587
+ filter[collectionName][filterField] = {
2588
+ ...filter[collectionName][filterField] || {},
2589
+ after: filterArgs.after
2590
+ };
2591
+ }
2592
+ if (filterField && (filterArgs == null ? void 0 : filterArgs.booleanEquals) !== null && (filterArgs == null ? void 0 : filterArgs.booleanEquals) !== void 0) {
2593
+ filter[collectionName][filterField] = {
2594
+ ...filter[collectionName][filterField] || {},
2595
+ eq: filterArgs.booleanEquals
2596
+ };
2597
+ }
2554
2598
  if (includeDocuments === true) {
2555
2599
  const sort = sortKey || this.schema.getIsTitleFieldName(collectionName);
2556
2600
  const response = order === "asc" ? await this.api.request(`#graphql
2557
- query($collection: String!, $includeDocuments: Boolean!, $sort: String, $limit: Float, $after: String){
2601
+ query($collection: String!, $includeDocuments: Boolean!, $sort: String, $limit: Float, $after: String, $filter: DocumentFilter){
2558
2602
  collection(collection: $collection){
2559
2603
  name
2560
2604
  label
2561
2605
  format
2562
2606
  templates
2563
- documents(sort: $sort, after: $after, first: $limit) @include(if: $includeDocuments) {
2607
+ documents(sort: $sort, after: $after, first: $limit, filter: $filter) @include(if: $includeDocuments) {
2564
2608
  totalCount
2565
2609
  pageInfo {
2566
2610
  hasPreviousPage
@@ -2592,16 +2636,17 @@ class TinaAdminApi {
2592
2636
  includeDocuments,
2593
2637
  sort,
2594
2638
  limit: 50,
2595
- after
2639
+ after,
2640
+ filter
2596
2641
  }
2597
2642
  }) : await this.api.request(`#graphql
2598
- query($collection: String!, $includeDocuments: Boolean!, $sort: String, $limit: Float, $after: String){
2643
+ query($collection: String!, $includeDocuments: Boolean!, $sort: String, $limit: Float, $after: String, $filter: DocumentFilter){
2599
2644
  collection(collection: $collection){
2600
2645
  name
2601
2646
  label
2602
2647
  format
2603
2648
  templates
2604
- documents(sort: $sort, before: $after, last: $limit) @include(if: $includeDocuments) {
2649
+ documents(sort: $sort, before: $after, last: $limit, filter: $filter) @include(if: $includeDocuments) {
2605
2650
  totalCount
2606
2651
  pageInfo {
2607
2652
  hasPreviousPage
@@ -2633,7 +2678,8 @@ class TinaAdminApi {
2633
2678
  includeDocuments,
2634
2679
  sort,
2635
2680
  limit: 50,
2636
- after
2681
+ after,
2682
+ filter
2637
2683
  }
2638
2684
  });
2639
2685
  return response.collection;
@@ -2702,8 +2748,9 @@ const AuthWallInner = ({
2702
2748
  loginScreen,
2703
2749
  getModalActions
2704
2750
  }) => {
2751
+ var _a, _b, _c, _d, _e;
2705
2752
  const client = cms.api.tina;
2706
- const isLocal = client.isLocalMode;
2753
+ const isTinaCloud = !client.isLocalMode && !((_e = (_d = (_c = (_b = (_a = client.schema) == null ? void 0 : _a.config) == null ? void 0 : _b.config) == null ? void 0 : _c.admin) == null ? void 0 : _d.auth) == null ? void 0 : _e.customAuth);
2707
2754
  const [activeModal, setActiveModal] = useState(null);
2708
2755
  const [showChildren, setShowChildren] = useState(false);
2709
2756
  React.useEffect(() => {
@@ -2732,8 +2779,8 @@ const AuthWallInner = ({
2732
2779
  }
2733
2780
  }) : [];
2734
2781
  return /* @__PURE__ */ React.createElement(React.Fragment, null, activeModal === "authenticate" && /* @__PURE__ */ React.createElement(ModalBuilder, {
2735
- title: isLocal ? "Enter into edit mode" : "Tina Cloud Authorization",
2736
- message: isLocal ? "To save edits, enter into edit mode. On save, changes will saved to the local filesystem." : "To save edits, Tina Cloud authorization is required. On save, changes will get commited using your account.",
2782
+ title: isTinaCloud ? "Tina Cloud Authorization" : "Enter into edit mode",
2783
+ message: isTinaCloud ? "To save edits, Tina Cloud authorization is required. On save, changes will get commited using your account." : "To save edits, enter into edit mode. On save, changes will saved to the local filesystem.",
2737
2784
  close,
2738
2785
  actions: [
2739
2786
  ...otherModalActions,
@@ -2746,7 +2793,7 @@ const AuthWallInner = ({
2746
2793
  primary: false
2747
2794
  },
2748
2795
  {
2749
- name: isLocal ? "Enter Edit Mode" : "Continue to Tina Cloud",
2796
+ name: isTinaCloud ? "Continue to Tina Cloud" : "Enter Edit Mode",
2750
2797
  action: async () => {
2751
2798
  const token = await client.authenticate();
2752
2799
  if (typeof (client == null ? void 0 : client.onLogin) === "function") {
@@ -2820,7 +2867,8 @@ const TinaCloudProvider = (props) => {
2820
2867
  if (branchingEnabled) {
2821
2868
  branchSwitcher = new BranchSwitcherPlugin({
2822
2869
  listBranches: handleListBranches,
2823
- createBranch: handleCreateBranch
2870
+ createBranch: handleCreateBranch,
2871
+ chooseBranch: setCurrentBranch
2824
2872
  });
2825
2873
  cms.plugins.add(branchSwitcher);
2826
2874
  }
@@ -3249,6 +3297,9 @@ var styles = `.tina-tailwind {
3249
3297
  .tina-tailwind .mt-2 {
3250
3298
  margin-top: 8px;
3251
3299
  }
3300
+ .tina-tailwind .ml-1\\.5 {
3301
+ margin-left: 6px;
3302
+ }
3252
3303
  .tina-tailwind .mb-4 {
3253
3304
  margin-bottom: 16px;
3254
3305
  }
@@ -3276,6 +3327,9 @@ var styles = `.tina-tailwind {
3276
3327
  .tina-tailwind .table {
3277
3328
  display: table;
3278
3329
  }
3330
+ .tina-tailwind .grid {
3331
+ display: grid;
3332
+ }
3279
3333
  .tina-tailwind .h-screen {
3280
3334
  height: 100vh;
3281
3335
  }
@@ -3386,9 +3440,18 @@ var styles = `.tina-tailwind {
3386
3440
  .tina-tailwind .cursor-pointer {
3387
3441
  cursor: pointer;
3388
3442
  }
3443
+ .tina-tailwind .grid-flow-col {
3444
+ grid-auto-flow: column;
3445
+ }
3389
3446
  .tina-tailwind .flex-col {
3390
3447
  flex-direction: column;
3391
3448
  }
3449
+ .tina-tailwind .flex-wrap {
3450
+ flex-wrap: wrap;
3451
+ }
3452
+ .tina-tailwind .items-start {
3453
+ align-items: flex-start;
3454
+ }
3392
3455
  .tina-tailwind .items-end {
3393
3456
  align-items: flex-end;
3394
3457
  }
@@ -3431,6 +3494,12 @@ var styles = `.tina-tailwind {
3431
3494
  --tw-divide-opacity: 1;
3432
3495
  border-color: rgb(230 227 239 / var(--tw-divide-opacity));
3433
3496
  }
3497
+ .tina-tailwind .self-end {
3498
+ align-self: flex-end;
3499
+ }
3500
+ .tina-tailwind .justify-self-end {
3501
+ justify-self: end;
3502
+ }
3434
3503
  .tina-tailwind .overflow-hidden {
3435
3504
  overflow: hidden;
3436
3505
  }
@@ -3445,6 +3514,9 @@ var styles = `.tina-tailwind {
3445
3514
  .tina-tailwind .whitespace-normal {
3446
3515
  white-space: normal;
3447
3516
  }
3517
+ .tina-tailwind .whitespace-nowrap {
3518
+ white-space: nowrap;
3519
+ }
3448
3520
  .tina-tailwind .rounded-lg {
3449
3521
  border-radius: 8px;
3450
3522
  }
@@ -3475,6 +3547,10 @@ var styles = `.tina-tailwind {
3475
3547
  --tw-border-opacity: 1;
3476
3548
  border-color: rgb(225 221 236 / var(--tw-border-opacity));
3477
3549
  }
3550
+ .tina-tailwind .border-gray-100 {
3551
+ --tw-border-opacity: 1;
3552
+ border-color: rgb(237 236 243 / var(--tw-border-opacity));
3553
+ }
3478
3554
  .tina-tailwind .bg-white {
3479
3555
  --tw-bg-opacity: 1;
3480
3556
  background-color: rgb(255 255 255 / var(--tw-bg-opacity));
@@ -3498,6 +3574,11 @@ var styles = `.tina-tailwind {
3498
3574
  --tw-gradient-to: rgb(29 44 108 / 0);
3499
3575
  --tw-gradient-stops: var(--tw-gradient-from), var(--tw-gradient-to);
3500
3576
  }
3577
+ .tina-tailwind .from-gray-50\\/50 {
3578
+ --tw-gradient-from: rgb(246 246 249 / .5);
3579
+ --tw-gradient-to: rgb(246 246 249 / 0);
3580
+ --tw-gradient-stops: var(--tw-gradient-from), var(--tw-gradient-to);
3581
+ }
3501
3582
  .tina-tailwind .from-gray-800 {
3502
3583
  --tw-gradient-from: #363145;
3503
3584
  --tw-gradient-to: rgb(54 49 69 / 0);
@@ -3510,6 +3591,9 @@ var styles = `.tina-tailwind {
3510
3591
  .tina-tailwind .to-gray-900 {
3511
3592
  --tw-gradient-to: #252336;
3512
3593
  }
3594
+ .tina-tailwind .to-gray-50 {
3595
+ --tw-gradient-to: #F6F6F9;
3596
+ }
3513
3597
  .tina-tailwind .to-black {
3514
3598
  --tw-gradient-to: #000;
3515
3599
  }
@@ -3533,6 +3617,10 @@ var styles = `.tina-tailwind {
3533
3617
  padding-left: 48px;
3534
3618
  padding-right: 48px;
3535
3619
  }
3620
+ .tina-tailwind .py-8 {
3621
+ padding-top: 32px;
3622
+ padding-bottom: 32px;
3623
+ }
3536
3624
  .tina-tailwind .py-10 {
3537
3625
  padding-top: 40px;
3538
3626
  padding-bottom: 40px;
@@ -3557,6 +3645,10 @@ var styles = `.tina-tailwind {
3557
3645
  padding-left: 12px;
3558
3646
  padding-right: 12px;
3559
3647
  }
3648
+ .tina-tailwind .py-3 {
3649
+ padding-top: 12px;
3650
+ padding-bottom: 12px;
3651
+ }
3560
3652
  .tina-tailwind .py-5 {
3561
3653
  padding-top: 20px;
3562
3654
  padding-bottom: 20px;
@@ -3564,11 +3656,8 @@ var styles = `.tina-tailwind {
3564
3656
  .tina-tailwind .pt-4 {
3565
3657
  padding-top: 16px;
3566
3658
  }
3567
- .tina-tailwind .pb-4 {
3568
- padding-bottom: 16px;
3569
- }
3570
- .tina-tailwind .pt-16 {
3571
- padding-top: 64px;
3659
+ .tina-tailwind .pt-12 {
3660
+ padding-top: 48px;
3572
3661
  }
3573
3662
  .tina-tailwind .pr-3 {
3574
3663
  padding-right: 12px;
@@ -3582,9 +3671,6 @@ var styles = `.tina-tailwind {
3582
3671
  .tina-tailwind .pl-5 {
3583
3672
  padding-left: 20px;
3584
3673
  }
3585
- .tina-tailwind .pt-3 {
3586
- padding-top: 12px;
3587
- }
3588
3674
  .tina-tailwind .pl-18 {
3589
3675
  padding-left: 72px;
3590
3676
  }
@@ -4076,26 +4162,6 @@ function useTina({
4076
4162
  isLoading
4077
4163
  };
4078
4164
  }
4079
- const parseURL = (url) => {
4080
- if (url.includes("localhost")) {
4081
- return { branch: null, isLocalClient: true, clientId: null };
4082
- }
4083
- const params = new URL(url);
4084
- const pattern = new UrlPattern("/content/:clientId/github/*", {
4085
- escapeChar: " "
4086
- });
4087
- const result = pattern.match(params.pathname);
4088
- const branch = result == null ? void 0 : result._;
4089
- const clientId = result == null ? void 0 : result.clientId;
4090
- if (!branch || !clientId) {
4091
- throw new Error(`Invalid URL format provided. Expected: https://content.tinajs.io/content/<ClientID>/github/<Branch> but but received ${url}`);
4092
- }
4093
- return {
4094
- branch,
4095
- clientId,
4096
- isLocalClient: false
4097
- };
4098
- };
4099
4165
  const errorButtonStyles = {
4100
4166
  background: "#eb6337",
4101
4167
  padding: "12px 18px",
@@ -4182,7 +4248,7 @@ const TinaCMSProvider2 = ({
4182
4248
  schema,
4183
4249
  ...props
4184
4250
  }) => {
4185
- var _a;
4251
+ var _a, _b, _c, _d, _e;
4186
4252
  React.useEffect(() => {
4187
4253
  console.warn(`
4188
4254
  * Tina no longer requires wrapping your site in the TinaProvider
@@ -4193,12 +4259,13 @@ const TinaCMSProvider2 = ({
4193
4259
  console.warn("The apiURL prop is deprecated. Please see https://tina.io/blog/tina-v-0.68.14 for information on how to upgrade to the new API");
4194
4260
  }
4195
4261
  const apiURL = ((_a = props == null ? void 0 : props.client) == null ? void 0 : _a.apiUrl) || (props == null ? void 0 : props.apiURL);
4262
+ const isLocalOverride = (_d = (_c = (_b = schema == null ? void 0 : schema.config) == null ? void 0 : _b.admin) == null ? void 0 : _c.auth) == null ? void 0 : _d.useLocalAuth;
4196
4263
  const { branch, clientId, isLocalClient } = apiURL ? parseURL(apiURL) : {
4197
4264
  branch: props.branch,
4198
4265
  clientId: props.clientId,
4199
4266
  isLocalClient: props == null ? void 0 : props.isLocalClient
4200
4267
  };
4201
- if (typeof isLocalClient === "undefined" || !isLocalClient && (!branch || !clientId)) {
4268
+ if (typeof isLocalClient === "undefined" || !isLocalClient && (!branch || !clientId) && !schema.config.contentApiUrlOverride) {
4202
4269
  throw new Error("Invalid setup. See https://tina.io/docs/tina-cloud/connecting-site/ for more information.");
4203
4270
  }
4204
4271
  if (!schema) {
@@ -4206,9 +4273,9 @@ const TinaCMSProvider2 = ({
4206
4273
  }
4207
4274
  return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(TinaCloudProvider, {
4208
4275
  branch,
4209
- clientId,
4276
+ clientId: clientId || ((_e = schema == null ? void 0 : schema.config) == null ? void 0 : _e.clientId),
4210
4277
  tinaioConfig: props.tinaioConfig,
4211
- isLocalClient,
4278
+ isLocalClient: isLocalOverride || isLocalClient,
4212
4279
  cmsCallback: props.cmsCallback,
4213
4280
  mediaStore: props.mediaStore,
4214
4281
  apiUrl: apiURL,
@@ -4552,9 +4619,15 @@ function BiPlus(props) {
4552
4619
  function BiRename(props) {
4553
4620
  return GenIcon({ "tag": "svg", "attr": { "viewBox": "0 0 24 24" }, "child": [{ "tag": "path", "attr": { "d": "M20.005 5.995h-1v2h1v8h-1v2h1c1.103 0 2-.897 2-2v-8c0-1.102-.898-2-2-2zm-14 4H15v4H6.005z" } }, { "tag": "path", "attr": { "d": "M17.005 17.995V4H20V2h-8v2h3.005v1.995h-11c-1.103 0-2 .897-2 2v8c0 1.103.897 2 2 2h11V20H12v2h8v-2h-2.995v-2.005zm-13-2v-8h11v8h-11z" } }] })(props);
4554
4621
  }
4622
+ function BiSearch(props) {
4623
+ return GenIcon({ "tag": "svg", "attr": { "viewBox": "0 0 24 24" }, "child": [{ "tag": "path", "attr": { "d": "M10 18a7.952 7.952 0 0 0 4.897-1.688l4.396 4.396 1.414-1.414-4.396-4.396A7.952 7.952 0 0 0 18 10c0-4.411-3.589-8-8-8s-8 3.589-8 8 3.589 8 8 8zm0-14c3.309 0 6 2.691 6 6s-2.691 6-6 6-6-2.691-6-6 2.691-6 6-6z" } }] })(props);
4624
+ }
4555
4625
  function BiTrash(props) {
4556
4626
  return GenIcon({ "tag": "svg", "attr": { "viewBox": "0 0 24 24" }, "child": [{ "tag": "path", "attr": { "d": "M5 20a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V8h2V6h-4V4a2 2 0 0 0-2-2H9a2 2 0 0 0-2 2v2H3v2h2zM9 4h6v2H9zM8 8h9v12H7V8z" } }, { "tag": "path", "attr": { "d": "M9 10h2v8H9zm4 0h2v8h-2z" } }] })(props);
4557
4627
  }
4628
+ function BiX(props) {
4629
+ return GenIcon({ "tag": "svg", "attr": { "viewBox": "0 0 24 24" }, "child": [{ "tag": "path", "attr": { "d": "m16.192 6.344-4.243 4.242-4.242-4.242-1.414 1.414L10.535 12l-4.242 4.242 1.414 1.414 4.242-4.242 4.243 4.242 1.414-1.414L13.364 12l4.242-4.242z" } }] })(props);
4630
+ }
4558
4631
  const slugify = (text) => {
4559
4632
  return text.toString().toLowerCase().trim().replace(/[^\w\s-]/g, "").replace(/[\s_-]+/g, "_").replace(/^-+|-+$/g, "");
4560
4633
  };
@@ -4812,24 +4885,37 @@ const LogoutPage = () => {
4812
4885
  const PageWrapper = ({
4813
4886
  children
4814
4887
  }) => {
4888
+ var _a, _b;
4889
+ const cms = useCMS();
4890
+ const isLocalMode = (_b = (_a = cms.api) == null ? void 0 : _a.tina) == null ? void 0 : _b.isLocalMode;
4891
+ const [branchingEnabled, setBranchingEnabled] = React.useState(() => cms.flags.get("branch-switcher"));
4892
+ React.useEffect(() => {
4893
+ cms.events.subscribe("flag:set", ({ key, value }) => {
4894
+ if (key === "branch-switcher") {
4895
+ setBranchingEnabled(value);
4896
+ }
4897
+ });
4898
+ }, [cms.events]);
4815
4899
  return /* @__PURE__ */ React.createElement("div", {
4816
- 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"
4817
- }, children);
4900
+ className: "relative left-0 w-full h-full bg-gradient-to-b from-gray-50/50 to-gray-50 shadow-2xl overflow-y-auto transition-opacity duration-300 ease-out flex flex-col opacity-100"
4901
+ }, branchingEnabled && !isLocalMode && /* @__PURE__ */ React.createElement(BranchBanner, null), children);
4818
4902
  };
4819
4903
  const PageHeader = ({
4820
4904
  isLocalMode,
4821
4905
  children
4822
- }) => /* @__PURE__ */ React.createElement(React.Fragment, null, isLocalMode && /* @__PURE__ */ React.createElement(LocalWarning, null), !isLocalMode && /* @__PURE__ */ React.createElement(BillingWarning, null), /* @__PURE__ */ React.createElement("div", {
4823
- className: "bg-white pb-4 pt-16 border-b border-gray-200 px-12"
4824
- }, /* @__PURE__ */ React.createElement("div", {
4825
- className: "w-full mx-auto max-w-screen-xl"
4826
- }, /* @__PURE__ */ React.createElement("div", {
4827
- className: "w-full flex justify-between items-end"
4828
- }, children))));
4906
+ }) => {
4907
+ return /* @__PURE__ */ React.createElement(React.Fragment, null, isLocalMode && /* @__PURE__ */ React.createElement(LocalWarning, null), !isLocalMode && /* @__PURE__ */ React.createElement(BillingWarning, null), /* @__PURE__ */ React.createElement("div", {
4908
+ className: "pt-12 px-12"
4909
+ }, /* @__PURE__ */ React.createElement("div", {
4910
+ className: "w-full mx-auto max-w-screen-xl"
4911
+ }, /* @__PURE__ */ React.createElement("div", {
4912
+ className: "w-full flex justify-between items-end"
4913
+ }, children))));
4914
+ };
4829
4915
  const PageBody = ({
4830
4916
  children
4831
4917
  }) => /* @__PURE__ */ React.createElement("div", {
4832
- className: "py-10 px-12"
4918
+ className: "py-8 px-12"
4833
4919
  }, children);
4834
4920
  const PageBodyNarrow = ({
4835
4921
  children
@@ -4947,7 +5033,7 @@ const LoadingPage = () => /* @__PURE__ */ React.createElement(React.Fragment, nu
4947
5033
  fontWeight: "normal"
4948
5034
  }
4949
5035
  }, "Please wait, Tina is loading data..."))));
4950
- const useGetCollection = (cms, collectionName, includeDocuments = true, after = "", sortKey) => {
5036
+ const useGetCollection = (cms, collectionName, includeDocuments = true, after = "", sortKey, filterArgs) => {
4951
5037
  const api = new TinaAdminApi(cms);
4952
5038
  const schema = cms.api.tina.schema;
4953
5039
  const collectionExtra = schema.getCollection(collectionName);
@@ -4962,7 +5048,7 @@ const useGetCollection = (cms, collectionName, includeDocuments = true, after =
4962
5048
  const { name, order } = JSON.parse(sortKey || "{}");
4963
5049
  const validSortKey = ((_a = collectionExtra.fields) == null ? void 0 : _a.map((x) => x.name).includes(name)) ? name : void 0;
4964
5050
  try {
4965
- const collection2 = await api.fetchCollection(collectionName, includeDocuments, after, validSortKey, order);
5051
+ const collection2 = await api.fetchCollection(collectionName, includeDocuments, after, validSortKey, order, filterArgs);
4966
5052
  setCollection(collection2);
4967
5053
  } catch (error2) {
4968
5054
  cms.alerts.error(`[${error2.name}] GetCollection failed: ${error2.message}`);
@@ -4985,9 +5071,10 @@ const GetCollection = ({
4985
5071
  includeDocuments = true,
4986
5072
  startCursor,
4987
5073
  sortKey,
4988
- children
5074
+ children,
5075
+ filterArgs
4989
5076
  }) => {
4990
- const { collection, loading, error, reFetchCollection, collectionExtra } = useGetCollection(cms, collectionName, includeDocuments, startCursor || "", sortKey) || {};
5077
+ const { collection, loading, error, reFetchCollection, collectionExtra } = useGetCollection(cms, collectionName, includeDocuments, startCursor || "", sortKey, filterArgs) || {};
4991
5078
  if (error) {
4992
5079
  return null;
4993
5080
  }
@@ -5052,7 +5139,13 @@ const CollectionListPage = () => {
5052
5139
  const [vars, setVars] = React.useState({
5053
5140
  collection: collectionName,
5054
5141
  relativePath: "",
5055
- newRelativePath: ""
5142
+ newRelativePath: "",
5143
+ filterField: "",
5144
+ startsWith: "",
5145
+ endsWith: "",
5146
+ before: "",
5147
+ after: "",
5148
+ booleanEquals: null
5056
5149
  });
5057
5150
  const [endCursor, setEndCursor] = useState("");
5058
5151
  const [prevCursors, setPrevCursors] = useState([]);
@@ -5070,23 +5163,55 @@ const CollectionListPage = () => {
5070
5163
  setEndCursor("");
5071
5164
  setPrevCursors([]);
5072
5165
  }, [loc]);
5166
+ useEffect(() => {
5167
+ setVars((old) => ({
5168
+ ...old,
5169
+ collection: collectionName,
5170
+ relativePath: "",
5171
+ newRelativePath: "",
5172
+ filterField: "",
5173
+ startsWith: "",
5174
+ endsWith: "",
5175
+ before: "",
5176
+ after: "",
5177
+ booleanEquals: null
5178
+ }));
5179
+ }, [collectionName]);
5073
5180
  return /* @__PURE__ */ React.createElement(GetCMS, null, (cms) => {
5074
5181
  return /* @__PURE__ */ React.createElement(GetCollection, {
5075
5182
  cms,
5076
5183
  collectionName,
5077
5184
  includeDocuments: true,
5078
5185
  startCursor: endCursor,
5079
- sortKey
5186
+ sortKey,
5187
+ filterArgs: collectionName === vars.collection ? vars : {
5188
+ collection: collectionName,
5189
+ relativePath: "",
5190
+ newRelativePath: "",
5191
+ filterField: "",
5192
+ startsWith: "",
5193
+ endsWith: "",
5194
+ before: "",
5195
+ after: "",
5196
+ booleanEquals: null
5197
+ }
5080
5198
  }, (collection, _loading, reFetchCollection, collectionExtra) => {
5081
- var _a, _b, _c, _d, _e, _f, _g, _h, _i;
5082
- const totalCount = collection.documents.totalCount;
5199
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
5200
+ collection.documents.totalCount;
5083
5201
  const documents = collection.documents.edges;
5084
5202
  const admin = cms.api.admin;
5085
5203
  const pageInfo = collection.documents.pageInfo;
5086
5204
  const fields = (_a = collectionExtra.fields) == null ? void 0 : _a.filter((x) => ["string", "number", "datetime", "boolean"].includes(x.type));
5205
+ const filterFields = (_b = collectionExtra.fields) == null ? void 0 : _b.filter((x) => {
5206
+ return ["string", "datetime", "boolean"].includes(x.type) && !x.list;
5207
+ });
5208
+ const filterField = filterFields == null ? void 0 : filterFields.find((x) => x.name === vars.filterField);
5209
+ const showStartsWith = (filterField == null ? void 0 : filterField.type) === "string" && !filterField.list;
5210
+ const showDateFilter = (filterField == null ? void 0 : filterField.type) === "datetime";
5211
+ const showBooleanToggle = (filterField == null ? void 0 : filterField.type) === "boolean" && !filterField.list;
5087
5212
  const collectionDefinition = cms.api.tina.schema.getCollection(collection.name);
5088
- const allowCreate = (_d = (_c = (_b = collectionDefinition == null ? void 0 : collectionDefinition.ui) == null ? void 0 : _b.allowedActions) == null ? void 0 : _c.create) != null ? _d : true;
5089
- const allowDelete = (_g = (_f = (_e = collectionDefinition == null ? void 0 : collectionDefinition.ui) == null ? void 0 : _e.allowedActions) == null ? void 0 : _f.delete) != null ? _g : true;
5213
+ const allowCreate = (_e = (_d = (_c = collectionDefinition == null ? void 0 : collectionDefinition.ui) == null ? void 0 : _c.allowedActions) == null ? void 0 : _d.create) != null ? _e : true;
5214
+ const allowDelete = (_h = (_g = (_f = collectionDefinition == null ? void 0 : collectionDefinition.ui) == null ? void 0 : _f.allowedActions) == null ? void 0 : _g.delete) != null ? _h : true;
5090
5215
  return /* @__PURE__ */ React.createElement(PageWrapper, null, /* @__PURE__ */ React.createElement(React.Fragment, null, deleteModalOpen && /* @__PURE__ */ React.createElement(DeleteModal, {
5091
5216
  filename: vars.relativePath,
5092
5217
  deleteFunc: async () => {
@@ -5127,13 +5252,17 @@ const CollectionListPage = () => {
5127
5252
  },
5128
5253
  close: () => setRenameModalOpen(false)
5129
5254
  }), /* @__PURE__ */ React.createElement(PageHeader, {
5130
- isLocalMode: (_i = (_h = cms == null ? void 0 : cms.api) == null ? void 0 : _h.tina) == null ? void 0 : _i.isLocalMode
5131
- }, /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("div", {
5255
+ isLocalMode: (_j = (_i = cms == null ? void 0 : cms.api) == null ? void 0 : _i.tina) == null ? void 0 : _j.isLocalMode
5256
+ }, /* @__PURE__ */ React.createElement("div", {
5257
+ className: "w-full grid grid-flow-col items-end gap-4"
5258
+ }, /* @__PURE__ */ React.createElement("div", {
5132
5259
  className: "flex flex-col gap-4"
5133
5260
  }, /* @__PURE__ */ React.createElement("h3", {
5134
5261
  className: "font-sans text-2xl text-gray-700"
5135
5262
  }, collection.label ? collection.label : collection.name), (fields == null ? void 0 : fields.length) > 0 && /* @__PURE__ */ React.createElement("div", {
5136
- className: "flex gap-2 items-center"
5263
+ className: "flex gap-4 items-end flex-wrap"
5264
+ }, /* @__PURE__ */ React.createElement("div", {
5265
+ className: "flex flex-col gap-2 items-start"
5137
5266
  }, /* @__PURE__ */ React.createElement("label", {
5138
5267
  htmlFor: "sort",
5139
5268
  className: "block font-sans text-xs font-semibold text-gray-500 whitespace-normal"
@@ -5149,14 +5278,14 @@ const CollectionListPage = () => {
5149
5278
  },
5150
5279
  ...fields.map((x) => [
5151
5280
  {
5152
- label: (x.label || x.name) + " (Ascending)",
5281
+ label: (x.label || x.name) + (x.type === "datetime" ? " (Oldest First)" : " (Ascending)"),
5153
5282
  value: JSON.stringify({
5154
5283
  name: x.name,
5155
5284
  order: "asc"
5156
5285
  })
5157
5286
  },
5158
5287
  {
5159
- label: (x.label || x.name) + " (Descending)",
5288
+ label: (x.label || x.name) + (x.type === "datetime" ? " (Newest First)" : " (Descending)"),
5160
5289
  value: JSON.stringify({
5161
5290
  name: x.name,
5162
5291
  order: "desc"
@@ -5177,16 +5306,160 @@ const CollectionListPage = () => {
5177
5306
  setSortOrder(val.order);
5178
5307
  }
5179
5308
  }
5180
- }))), !collection.templates && allowCreate && /* @__PURE__ */ React.createElement(Link, {
5309
+ })), /* @__PURE__ */ React.createElement("form", {
5310
+ className: "flex flex-wrap gap-4 items-end"
5311
+ }, /* @__PURE__ */ React.createElement("div", {
5312
+ className: "flex flex-shrink-0 flex-col gap-2 items-start"
5313
+ }, /* @__PURE__ */ React.createElement("label", {
5314
+ htmlFor: "filter",
5315
+ className: "block font-sans text-xs font-semibold text-gray-500 whitespace-normal"
5316
+ }, "Filter by"), /* @__PURE__ */ React.createElement(Select, {
5317
+ name: "filter",
5318
+ options: [
5319
+ {
5320
+ label: "None",
5321
+ value: ""
5322
+ },
5323
+ ...filterFields.map((x) => ({
5324
+ label: x.label || x.name,
5325
+ value: x.name
5326
+ }))
5327
+ ],
5328
+ input: {
5329
+ id: "filter",
5330
+ name: "filter",
5331
+ value: vars.filterField,
5332
+ onChange: (e) => {
5333
+ const val = e.target.value;
5334
+ setEndCursor("");
5335
+ setPrevCursors([]);
5336
+ setVars((old) => ({
5337
+ ...old,
5338
+ filterField: val
5339
+ }));
5340
+ if (!val) {
5341
+ reFetchCollection();
5342
+ }
5343
+ }
5344
+ }
5345
+ })), showStartsWith && /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("div", {
5346
+ className: "flex flex-shrink-0 flex-col gap-2 items-start"
5347
+ }, /* @__PURE__ */ React.createElement("label", {
5348
+ htmlFor: "startsWith",
5349
+ className: "block font-sans text-xs font-semibold text-gray-500 whitespace-normal"
5350
+ }, "Starts with"), /* @__PURE__ */ React.createElement(Input, {
5351
+ name: "startsWith",
5352
+ id: "startsWith",
5353
+ value: vars.startsWith,
5354
+ onChange: (e) => {
5355
+ const val = e.target.value;
5356
+ setVars((old) => ({
5357
+ ...old,
5358
+ startsWith: val,
5359
+ after: "",
5360
+ before: "",
5361
+ booleanEquals: null
5362
+ }));
5363
+ }
5364
+ }))), showDateFilter && /* @__PURE__ */ React.createElement("div", {
5365
+ className: "flex flex-shrink-0 gap-4"
5366
+ }, /* @__PURE__ */ React.createElement("div", {
5367
+ className: "flex flex-col gap-2 items-start"
5368
+ }, /* @__PURE__ */ React.createElement("label", {
5369
+ htmlFor: "dateAfter",
5370
+ className: "block font-sans text-xs font-semibold text-gray-500 whitespace-normal"
5371
+ }, "After"), /* @__PURE__ */ React.createElement(ReactDateTimeWithStyles, {
5372
+ inputProps: {
5373
+ className: textFieldClasses
5374
+ },
5375
+ value: vars.after,
5376
+ onChange: (e) => {
5377
+ setVars((old) => ({
5378
+ ...old,
5379
+ after: e.format(),
5380
+ booleanEquals: null,
5381
+ startsWith: ""
5382
+ }));
5383
+ }
5384
+ })), /* @__PURE__ */ React.createElement("div", {
5385
+ className: "flex flex-col gap-2 items-start"
5386
+ }, /* @__PURE__ */ React.createElement("label", {
5387
+ htmlFor: "dateBefore",
5388
+ className: "block font-sans text-xs font-semibold text-gray-500 whitespace-normal"
5389
+ }, "Before"), /* @__PURE__ */ React.createElement(ReactDateTimeWithStyles, {
5390
+ inputProps: {
5391
+ className: textFieldClasses
5392
+ },
5393
+ value: vars.before,
5394
+ onChange: (e) => {
5395
+ setVars((old) => ({
5396
+ ...old,
5397
+ before: e.format(),
5398
+ booleanEquals: null,
5399
+ startsWith: ""
5400
+ }));
5401
+ }
5402
+ }))), showBooleanToggle && /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("div", {
5403
+ className: "flex flex-col gap-2 items-start"
5404
+ }, /* @__PURE__ */ React.createElement("label", {
5405
+ htmlFor: "toggle",
5406
+ className: "block font-sans text-xs font-semibold text-gray-500 whitespace-normal"
5407
+ }, filterField.label || filterField.name), /* @__PURE__ */ React.createElement(Toggle, {
5408
+ field: filterField,
5409
+ input: {
5410
+ name: "toggle",
5411
+ value: (_k = vars.booleanEquals) != null ? _k : false,
5412
+ onChange: () => {
5413
+ setVars((old) => ({
5414
+ ...old,
5415
+ booleanEquals: !old.booleanEquals,
5416
+ after: "",
5417
+ before: "",
5418
+ startsWith: ""
5419
+ }));
5420
+ }
5421
+ },
5422
+ name: "toggle"
5423
+ }))), (showStartsWith || showDateFilter || showBooleanToggle) && /* @__PURE__ */ React.createElement("div", {
5424
+ className: "flex gap-3"
5425
+ }, /* @__PURE__ */ React.createElement(Button, {
5426
+ onClick: () => {
5427
+ setEndCursor("");
5428
+ setPrevCursors([]);
5429
+ reFetchCollection();
5430
+ },
5431
+ variant: "primary",
5432
+ type: "submit"
5433
+ }, "Search", " ", /* @__PURE__ */ React.createElement(BiSearch, {
5434
+ className: "w-5 h-full ml-1.5 opacity-70"
5435
+ })), (vars.startsWith || vars.after || vars.before || vars.booleanEquals) && /* @__PURE__ */ React.createElement(Button, {
5436
+ onClick: () => {
5437
+ setVars((old) => ({
5438
+ ...old,
5439
+ startsWith: "",
5440
+ after: "",
5441
+ before: "",
5442
+ booleanEquals: null
5443
+ }));
5444
+ setEndCursor("");
5445
+ setPrevCursors([]);
5446
+ reFetchCollection();
5447
+ },
5448
+ variant: "white"
5449
+ }, "Clear", " ", /* @__PURE__ */ React.createElement(BiX, {
5450
+ className: "w-5 h-full ml-1 opacity-70"
5451
+ })))))), /* @__PURE__ */ React.createElement("div", {
5452
+ className: "flex self-end justify-self-end"
5453
+ }, !collection.templates && allowCreate && /* @__PURE__ */ React.createElement(Link, {
5181
5454
  to: `new`,
5182
- 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"
5455
+ 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 whitespace-nowrap shadow text-white bg-blue-500 hover:bg-blue-600 focus:ring-blue-500 text-sm h-10 px-6"
5183
5456
  }, "Create New", " ", /* @__PURE__ */ React.createElement(BiPlus, {
5184
5457
  className: "w-5 h-full ml-1 opacity-70"
5185
5458
  })), collection.templates && allowCreate && /* @__PURE__ */ React.createElement(TemplateMenu, {
5186
5459
  templates: collection.templates
5187
- }))), /* @__PURE__ */ React.createElement(PageBody, null, /* @__PURE__ */ React.createElement("div", {
5460
+ })))), /* @__PURE__ */ React.createElement(PageBody, null, /* @__PURE__ */ React.createElement("div", {
5188
5461
  className: "w-full mx-auto max-w-screen-xl"
5189
- }, totalCount > 0 && /* @__PURE__ */ React.createElement("table", {
5462
+ }, documents.length > 0 ? /* @__PURE__ */ React.createElement("table", {
5190
5463
  className: "table-auto shadow bg-white border-b border-gray-200 w-full max-w-full rounded-lg"
5191
5464
  }, /* @__PURE__ */ React.createElement("tbody", {
5192
5465
  className: "divide-y divide-gray-150"
@@ -5256,11 +5529,12 @@ const CollectionListPage = () => {
5256
5529
  className: "text-red-500"
5257
5530
  }),
5258
5531
  onMouseDown: () => {
5259
- setVars({
5532
+ setVars((old) => ({
5533
+ ...old,
5260
5534
  collection: collectionName,
5261
5535
  relativePath: document.node._sys.breadcrumbs.join("/") + document.node._sys.extension,
5262
5536
  newRelativePath: ""
5263
- });
5537
+ }));
5264
5538
  setDeleteModalOpen(true);
5265
5539
  }
5266
5540
  },
@@ -5272,18 +5546,19 @@ const CollectionListPage = () => {
5272
5546
  className: "text-red-500"
5273
5547
  }),
5274
5548
  onMouseDown: () => {
5275
- setVars({
5549
+ setVars((old) => ({
5550
+ ...old,
5276
5551
  collection: collectionName,
5277
5552
  relativePath: document.node._sys.breadcrumbs.join("/") + document.node._sys.extension,
5278
5553
  newRelativePath: ""
5279
- });
5554
+ }));
5280
5555
  setRenameModalOpen(true);
5281
5556
  }
5282
5557
  }
5283
5558
  ].filter(Boolean)
5284
5559
  })));
5285
- }))), /* @__PURE__ */ React.createElement("div", {
5286
- className: "pt-3"
5560
+ }))) : /* @__PURE__ */ React.createElement(NoDocumentsPlaceholder, null), /* @__PURE__ */ React.createElement("div", {
5561
+ className: "pt-4"
5287
5562
  }, /* @__PURE__ */ React.createElement(CursorPaginator, {
5288
5563
  variant: "white",
5289
5564
  hasNext: sortOrder === "asc" ? pageInfo == null ? void 0 : pageInfo.hasNextPage : pageInfo.hasPreviousPage,
@@ -5305,6 +5580,13 @@ const CollectionListPage = () => {
5305
5580
  });
5306
5581
  });
5307
5582
  };
5583
+ const NoDocumentsPlaceholder = () => {
5584
+ return /* @__PURE__ */ React.createElement("div", {
5585
+ className: "text-center px-5 py-3 flex flex-col items-center justify-center shadow border border-gray-100 bg-gray-50 border-b border-gray-200 w-full max-w-full rounded-lg"
5586
+ }, /* @__PURE__ */ React.createElement("p", {
5587
+ className: "text-base italic font-medium text-gray-300"
5588
+ }, "No documents found."));
5589
+ };
5308
5590
  const DeleteModal = ({ close: close2, deleteFunc, filename }) => {
5309
5591
  return /* @__PURE__ */ React.createElement(Modal, null, /* @__PURE__ */ React.createElement(PopupModal, null, /* @__PURE__ */ React.createElement(ModalHeader, {
5310
5592
  close: close2