tinacms 0.0.0-9ffcade-20251202022528 → 0.0.0-a23fec8-20251217045135

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -7,7 +7,7 @@ var __publicField = (obj, key, value) => {
7
7
  var _a;
8
8
  import { z } from "zod";
9
9
  import * as React from "react";
10
- import React__default, { useState, useCallback, useContext, createContext, forwardRef, useRef, useReducer, useMemo, useEffect, useLayoutEffect, Component, memo as memo$1, useDebugValue, useId, startTransition, useImperativeHandle } from "react";
10
+ import React__default, { useState, useCallback, useContext, createContext, forwardRef, useRef, useReducer, useMemo, useEffect, useLayoutEffect, Component, memo, useDebugValue, useId, startTransition, useImperativeHandle } from "react";
11
11
  import ReactDOM, { createPortal } from "react-dom";
12
12
  import { withRef as withRef$1, cn as cn$2, withCn, createPrimitiveElement, withVariants, withProps, useComposedRef as useComposedRef$1, PortalBody } from "@udecode/cn";
13
13
  import { HEADING_KEYS as HEADING_KEYS$1, HEADING_LEVELS as HEADING_LEVELS$1 } from "@udecode/plate-heading";
@@ -15,7 +15,7 @@ import { isHotkey } from "is-hotkey";
15
15
  import clsx$1, { clsx } from "clsx";
16
16
  import { Slot } from "@radix-ui/react-slot";
17
17
  import { isLangSupported, formatCodeBlock, insertEmptyCodeBlock, unwrapCodeBlock, isCodeBlockEmpty, isSelectionAtCodeBlockStart } from "@udecode/plate-code-block";
18
- import { X, Search, ChevronDown, Check, AlertTriangle, BracesIcon, Plus, AlignCenter as AlignCenter$1, AlignJustify, AlignLeft as AlignLeft$1, AlignRight as AlignRight$1, PaintBucket, Quote, ChevronRight, ChevronsUpDown, FileCode, Baseline, RectangleVertical, Combine, Ungroup, MessageSquare, MessageSquarePlus, Trash, GripVertical, Edit2, Smile, ExternalLink, Heading1, Heading2, Heading3, Heading4, Heading5, Heading6, Indent, Keyboard, WrapText, Minus, MoreHorizontal, Outdent, Pilcrow, RotateCcw, RectangleHorizontal, Settings, Strikethrough, Subscript, Superscript, Table, Text as Text$2, Underline, Link2Off, Eye, SeparatorHorizontal, Moon, SunMedium, Twitter, PaintBucketIcon, CombineIcon, SquareSplitHorizontalIcon, Grid2X2Icon, Trash2Icon, ArrowUp, ArrowDown, XIcon, ArrowLeft, ArrowRight, EraserIcon, ChevronDownIcon as ChevronDownIcon$1, ChevronUp, Clock, CalendarCheck, Calendar as Calendar$1, CalendarDays, RotateCw, ChevronLeft, LoaderCircle, TriangleAlert, EllipsisVertical, GitBranchIcon, List as List$1, ListOrdered, Grid3x3Icon, Link, Unlink } from "lucide-react";
18
+ import { X, Search, ChevronDown, Check, AlertTriangle, BracesIcon, Plus, AlignCenter as AlignCenter$1, AlignJustify, AlignLeft as AlignLeft$1, AlignRight as AlignRight$1, PaintBucket, Quote, ChevronRight, ChevronsUpDown, FileCode, Baseline, RectangleVertical, Combine, Ungroup, MessageSquare, MessageSquarePlus, Trash, GripVertical, Edit2, Smile, ExternalLink, Heading1, Heading2, Heading3, Heading4, Heading5, Heading6, Indent, Keyboard, WrapText, Minus, MoreHorizontal, Outdent, Pilcrow, RotateCcw, RectangleHorizontal, Settings, Strikethrough, Subscript, Superscript, Table, Text as Text$2, Underline, Link2Off, Eye, SeparatorHorizontal, Moon, SunMedium, Twitter, PaintBucketIcon, CombineIcon, SquareSplitHorizontalIcon, Grid2X2Icon, Trash2Icon, ArrowUp, ArrowDown, XIcon, ArrowLeft, ArrowRight, EraserIcon, ChevronDownIcon as ChevronDownIcon$1, ChevronUp, Clock, CalendarCheck, Calendar as Calendar$1, CalendarDays, RotateCw, ChevronLeft, LoaderCircle, TriangleAlert, History, EllipsisVertical, GitBranchIcon, List as List$1, ListOrdered, Grid3x3Icon, CircleX, Link, Unlink } from "lucide-react";
19
19
  import mermaid from "mermaid";
20
20
  import { cva } from "class-variance-authority";
21
21
  import { Command as Command$2 } from "cmdk";
@@ -43,10 +43,10 @@ import { twMerge } from "tailwind-merge";
43
43
  import { useSensors, useSensor, PointerSensor, KeyboardSensor, DndContext, closestCenter } from "@dnd-kit/core";
44
44
  import { sortableKeyboardCoordinates, useSortable, SortableContext, verticalListSortingStrategy, defaultAnimateLayoutChanges } from "@dnd-kit/sortable";
45
45
  import { CSS } from "@dnd-kit/utilities";
46
- import * as pkg$1 from "react-color";
47
- import * as pkg from "color-string";
48
46
  import { buildSchema, print, getIntrospectionQuery, buildClientSchema, parse as parse$4 } from "graphql";
49
47
  import { diff as diff$1 } from "@graphql-inspector/core";
48
+ import { get as get$6, to as to$1 } from "color-string";
49
+ import { HexColorPicker } from "react-colorful";
50
50
  import * as dropzone from "react-dropzone";
51
51
  import { Command as Command$3 } from "@udecode/cmdk";
52
52
  import { Popover as Popover$4, PopoverButton, Transition, PopoverPanel, TransitionChild, Disclosure, DisclosureButton, DisclosurePanel, Menu, MenuButton, MenuItems, MenuItem } from "@headlessui/react";
@@ -1414,21 +1414,29 @@ function isDraftable$1(value) {
1414
1414
  return isPlainObject$4(value) || Array.isArray(value) || !!value[DRAFTABLE] || !!((_a2 = value.constructor) == null ? void 0 : _a2[DRAFTABLE]) || isMap$2(value) || isSet$2(value);
1415
1415
  }
1416
1416
  var objectCtorString$1 = Object.prototype.constructor.toString();
1417
+ var cachedCtorStrings = /* @__PURE__ */ new WeakMap();
1417
1418
  function isPlainObject$4(value) {
1418
1419
  if (!value || typeof value !== "object")
1419
1420
  return false;
1420
- const proto = getPrototypeOf(value);
1421
- if (proto === null) {
1421
+ const proto = Object.getPrototypeOf(value);
1422
+ if (proto === null || proto === Object.prototype)
1422
1423
  return true;
1423
- }
1424
1424
  const Ctor = Object.hasOwnProperty.call(proto, "constructor") && proto.constructor;
1425
1425
  if (Ctor === Object)
1426
1426
  return true;
1427
- return typeof Ctor == "function" && Function.toString.call(Ctor) === objectCtorString$1;
1427
+ if (typeof Ctor !== "function")
1428
+ return false;
1429
+ let ctorString = cachedCtorStrings.get(Ctor);
1430
+ if (ctorString === void 0) {
1431
+ ctorString = Function.toString.call(Ctor);
1432
+ cachedCtorStrings.set(Ctor, ctorString);
1433
+ }
1434
+ return ctorString === objectCtorString$1;
1428
1435
  }
1429
- function each(obj, iter) {
1436
+ function each(obj, iter, strict = true) {
1430
1437
  if (getArchtype(obj) === 0) {
1431
- Reflect.ownKeys(obj).forEach((key) => {
1438
+ const keys2 = strict ? Reflect.ownKeys(obj) : Object.keys(obj);
1439
+ keys2.forEach((key) => {
1432
1440
  iter(key, obj[key], obj);
1433
1441
  });
1434
1442
  } else {
@@ -1511,17 +1519,27 @@ function freeze$1(obj, deep = false) {
1511
1519
  if (isFrozen(obj) || isDraft$1(obj) || !isDraftable$1(obj))
1512
1520
  return obj;
1513
1521
  if (getArchtype(obj) > 1) {
1514
- obj.set = obj.add = obj.clear = obj.delete = dontMutateFrozenCollections;
1522
+ Object.defineProperties(obj, {
1523
+ set: dontMutateMethodOverride,
1524
+ add: dontMutateMethodOverride,
1525
+ clear: dontMutateMethodOverride,
1526
+ delete: dontMutateMethodOverride
1527
+ });
1515
1528
  }
1516
1529
  Object.freeze(obj);
1517
1530
  if (deep)
1518
- Object.entries(obj).forEach(([key, value]) => freeze$1(value, true));
1531
+ Object.values(obj).forEach((value) => freeze$1(value, true));
1519
1532
  return obj;
1520
1533
  }
1521
1534
  function dontMutateFrozenCollections() {
1522
1535
  die(2);
1523
1536
  }
1537
+ var dontMutateMethodOverride = {
1538
+ value: dontMutateFrozenCollections
1539
+ };
1524
1540
  function isFrozen(obj) {
1541
+ if (obj === null || typeof obj !== "object")
1542
+ return true;
1525
1543
  return Object.isFrozen(obj);
1526
1544
  }
1527
1545
  var plugins = {};
@@ -1609,11 +1627,13 @@ function processResult(result, scope) {
1609
1627
  function finalize(rootScope, value, path3) {
1610
1628
  if (isFrozen(value))
1611
1629
  return value;
1630
+ const useStrictIteration = rootScope.immer_.shouldUseStrictIteration();
1612
1631
  const state = value[DRAFT_STATE];
1613
1632
  if (!state) {
1614
1633
  each(
1615
1634
  value,
1616
- (key, childValue) => finalizeProperty(rootScope, state, value, key, childValue, path3)
1635
+ (key, childValue) => finalizeProperty(rootScope, state, value, key, childValue, path3),
1636
+ useStrictIteration
1617
1637
  );
1618
1638
  return value;
1619
1639
  }
@@ -1636,7 +1656,16 @@ function finalize(rootScope, value, path3) {
1636
1656
  }
1637
1657
  each(
1638
1658
  resultEach,
1639
- (key, childValue) => finalizeProperty(rootScope, state, result, key, childValue, path3, isSet2)
1659
+ (key, childValue) => finalizeProperty(
1660
+ rootScope,
1661
+ state,
1662
+ result,
1663
+ key,
1664
+ childValue,
1665
+ path3,
1666
+ isSet2
1667
+ ),
1668
+ useStrictIteration
1640
1669
  );
1641
1670
  maybeFreeze(rootScope, result, false);
1642
1671
  if (path3 && rootScope.patches_) {
@@ -1651,6 +1680,16 @@ function finalize(rootScope, value, path3) {
1651
1680
  return state.copy_;
1652
1681
  }
1653
1682
  function finalizeProperty(rootScope, parentState, targetObject, prop2, childValue, rootPath, targetIsSet) {
1683
+ if (childValue == null) {
1684
+ return;
1685
+ }
1686
+ if (typeof childValue !== "object" && !targetIsSet) {
1687
+ return;
1688
+ }
1689
+ const childIsFrozen = isFrozen(childValue);
1690
+ if (childIsFrozen && !targetIsSet) {
1691
+ return;
1692
+ }
1654
1693
  if (process.env.NODE_ENV !== "production" && childValue === targetObject)
1655
1694
  die(5);
1656
1695
  if (isDraft$1(childValue)) {
@@ -1665,12 +1704,15 @@ function finalizeProperty(rootScope, parentState, targetObject, prop2, childValu
1665
1704
  } else if (targetIsSet) {
1666
1705
  targetObject.add(childValue);
1667
1706
  }
1668
- if (isDraftable$1(childValue) && !isFrozen(childValue)) {
1707
+ if (isDraftable$1(childValue) && !childIsFrozen) {
1669
1708
  if (!rootScope.immer_.autoFreeze_ && rootScope.unfinalizedDrafts_ < 1) {
1670
1709
  return;
1671
1710
  }
1711
+ if (parentState && parentState.base_ && parentState.base_[prop2] === childValue && childIsFrozen) {
1712
+ return;
1713
+ }
1672
1714
  finalize(rootScope, childValue);
1673
- if ((!parentState || !parentState.scope_.parent_) && typeof prop2 !== "symbol" && Object.prototype.propertyIsEnumerable.call(targetObject, prop2))
1715
+ if ((!parentState || !parentState.scope_.parent_) && typeof prop2 !== "symbol" && (isMap$2(targetObject) ? targetObject.has(prop2) : Object.prototype.propertyIsEnumerable.call(targetObject, prop2)))
1674
1716
  maybeFreeze(rootScope, childValue);
1675
1717
  }
1676
1718
  }
@@ -1866,6 +1908,7 @@ var Immer2 = class {
1866
1908
  constructor(config) {
1867
1909
  this.autoFreeze_ = true;
1868
1910
  this.useStrictShallowCopy_ = false;
1911
+ this.useStrictIteration_ = true;
1869
1912
  this.produce = (base, recipe, patchListener) => {
1870
1913
  if (typeof base === "function" && typeof recipe !== "function") {
1871
1914
  const defaultBase = recipe;
@@ -1928,6 +1971,8 @@ var Immer2 = class {
1928
1971
  this.setAutoFreeze(config.autoFreeze);
1929
1972
  if (typeof (config == null ? void 0 : config.useStrictShallowCopy) === "boolean")
1930
1973
  this.setUseStrictShallowCopy(config.useStrictShallowCopy);
1974
+ if (typeof (config == null ? void 0 : config.useStrictIteration) === "boolean")
1975
+ this.setUseStrictIteration(config.useStrictIteration);
1931
1976
  }
1932
1977
  createDraft(base) {
1933
1978
  if (!isDraftable$1(base))
@@ -1964,6 +2009,18 @@ var Immer2 = class {
1964
2009
  setUseStrictShallowCopy(value) {
1965
2010
  this.useStrictShallowCopy_ = value;
1966
2011
  }
2012
+ /**
2013
+ * Pass false to use faster iteration that skips non-enumerable properties
2014
+ * but still handles symbols for compatibility.
2015
+ *
2016
+ * By default, strict iteration is enabled (includes all own properties).
2017
+ */
2018
+ setUseStrictIteration(value) {
2019
+ this.useStrictIteration_ = value;
2020
+ }
2021
+ shouldUseStrictIteration() {
2022
+ return this.useStrictIteration_;
2023
+ }
1967
2024
  applyPatches(base, patches) {
1968
2025
  let i2;
1969
2026
  for (i2 = patches.length - 1; i2 >= 0; i2--) {
@@ -2002,17 +2059,23 @@ function currentImpl(value) {
2002
2059
  return value;
2003
2060
  const state = value[DRAFT_STATE];
2004
2061
  let copy2;
2062
+ let strict = true;
2005
2063
  if (state) {
2006
2064
  if (!state.modified_)
2007
2065
  return state.base_;
2008
2066
  state.finalized_ = true;
2009
2067
  copy2 = shallowCopy$1(value, state.scope_.immer_.useStrictShallowCopy_);
2068
+ strict = state.scope_.immer_.shouldUseStrictIteration();
2010
2069
  } else {
2011
2070
  copy2 = shallowCopy$1(value, true);
2012
2071
  }
2013
- each(copy2, (key, childValue) => {
2014
- set$3(copy2, key, currentImpl(childValue));
2015
- });
2072
+ each(
2073
+ copy2,
2074
+ (key, childValue) => {
2075
+ set$3(copy2, key, currentImpl(childValue));
2076
+ },
2077
+ strict
2078
+ );
2016
2079
  if (state) {
2017
2080
  state.finalized_ = false;
2018
2081
  }
@@ -2020,14 +2083,8 @@ function currentImpl(value) {
2020
2083
  }
2021
2084
  var immer = new Immer2();
2022
2085
  var produce = immer.produce;
2023
- immer.produceWithPatches.bind(
2024
- immer
2025
- );
2026
- immer.setAutoFreeze.bind(immer);
2027
- immer.setUseStrictShallowCopy.bind(immer);
2028
- immer.applyPatches.bind(immer);
2029
- var createDraft$1 = immer.createDraft.bind(immer);
2030
- var finishDraft = immer.finishDraft.bind(immer);
2086
+ var createDraft$1 = /* @__PURE__ */ immer.createDraft.bind(immer);
2087
+ var finishDraft = /* @__PURE__ */ immer.finishDraft.bind(immer);
2031
2088
  var PathRef = {
2032
2089
  transform(ref, op) {
2033
2090
  var {
@@ -10411,7 +10468,7 @@ var TextString = (props) => {
10411
10468
  ref
10412
10469
  }, initialText);
10413
10470
  };
10414
- var MemoizedText$1 = /* @__PURE__ */ memo$1(/* @__PURE__ */ forwardRef((props, ref) => {
10471
+ var MemoizedText$1 = /* @__PURE__ */ memo(/* @__PURE__ */ forwardRef((props, ref) => {
10415
10472
  return /* @__PURE__ */ React__default.createElement("span", {
10416
10473
  "data-slate-string": true,
10417
10474
  ref
@@ -15023,8 +15080,9 @@ const devtoolsImpl = (fn, devtoolsOptions = {}) => (set2, get2, api) => {
15023
15080
  const r2 = set2(state, replace);
15024
15081
  if (!isRecording)
15025
15082
  return r2;
15026
- const inferredActionType = findCallerName(new Error().stack);
15027
- const action = nameOrAction === void 0 ? { type: anonymousActionType || inferredActionType || "anonymous" } : typeof nameOrAction === "string" ? { type: nameOrAction } : nameOrAction;
15083
+ const action = nameOrAction === void 0 ? {
15084
+ type: anonymousActionType || findCallerName(new Error().stack) || "anonymous"
15085
+ } : typeof nameOrAction === "string" ? { type: nameOrAction } : nameOrAction;
15028
15086
  if (store === void 0) {
15029
15087
  connection == null ? void 0 : connection.send(action, get2());
15030
15088
  return r2;
@@ -15312,12 +15370,12 @@ const persistImpl = (config, baseOptions) => (set2, get2, api) => {
15312
15370
  const savedSetState = api.setState;
15313
15371
  api.setState = (state, replace) => {
15314
15372
  savedSetState(state, replace);
15315
- void setItem();
15373
+ return setItem();
15316
15374
  };
15317
15375
  const configResult = config(
15318
15376
  (...args) => {
15319
15377
  set2(...args);
15320
- void setItem();
15378
+ return setItem();
15321
15379
  },
15322
15380
  get2,
15323
15381
  api
@@ -33524,7 +33582,8 @@ const buttonVariants$2 = cva(
33524
33582
  inlineLink: "text-base text-primary underline underline-offset-4",
33525
33583
  link: "text-primary underline-offset-4 hover:underline",
33526
33584
  outline: "border border-input bg-background hover:bg-accent hover:text-accent-foreground",
33527
- secondary: "bg-secondary text-secondary-foreground hover:bg-secondary/80"
33585
+ secondary: "bg-secondary text-secondary-foreground hover:bg-secondary/80",
33586
+ tinaPrimary: "bg-tina-orange-dark text-white hover:bg-tina-orange-dark/90 disabled:bg-tina-orange-dark/50"
33528
33587
  }
33529
33588
  }
33530
33589
  }
@@ -38720,9 +38779,6 @@ function BiListUl(props) {
38720
38779
  function BiLockAlt(props) {
38721
38780
  return GenIcon({ "tag": "svg", "attr": { "viewBox": "0 0 24 24" }, "child": [{ "tag": "path", "attr": { "d": "M12 2C9.243 2 7 4.243 7 7v3H6c-1.103 0-2 .897-2 2v8c0 1.103.897 2 2 2h12c1.103 0 2-.897 2-2v-8c0-1.103-.897-2-2-2h-1V7c0-2.757-2.243-5-5-5zm6 10 .002 8H6v-8h12zm-9-2V7c0-1.654 1.346-3 3-3s3 1.346 3 3v3H9z" }, "child": [] }] })(props);
38722
38781
  }
38723
- function BiLock(props) {
38724
- return GenIcon({ "tag": "svg", "attr": { "viewBox": "0 0 24 24" }, "child": [{ "tag": "path", "attr": { "d": "M12 2C9.243 2 7 4.243 7 7v2H6c-1.103 0-2 .897-2 2v9c0 1.103.897 2 2 2h12c1.103 0 2-.897 2-2v-9c0-1.103-.897-2-2-2h-1V7c0-2.757-2.243-5-5-5zM9 7c0-1.654 1.346-3 3-3s3 1.346 3 3v2H9V7zm9.002 13H13v-2.278c.595-.347 1-.985 1-1.722 0-1.103-.897-2-2-2s-2 .897-2 2c0 .736.405 1.375 1 1.722V20H6v-9h12l.002 9z" }, "child": [] }] })(props);
38725
- }
38726
38782
  function BiMenu(props) {
38727
38783
  return GenIcon({ "tag": "svg", "attr": { "viewBox": "0 0 24 24" }, "child": [{ "tag": "path", "attr": { "d": "M4 6h16v2H4zm0 5h16v2H4zm0 5h16v2H4z" }, "child": [] }] })(props);
38728
38784
  }
@@ -39367,20 +39423,183 @@ const TextArea = React.forwardRef(({ ...props }, ref) => {
39367
39423
  }
39368
39424
  );
39369
39425
  });
39370
- const { get: getColor, to: toColor } = pkg;
39426
+ const TRANSPARENT = "transparent";
39427
+ const isValidHex = (value) => /^#([0-9A-Fa-f]{3}|[0-9A-Fa-f]{6})$/.test(value);
39428
+ const expandHex = (hex) => {
39429
+ const h = hex.replace("#", "");
39430
+ if (h.length === 3) {
39431
+ return `#${h[0]}${h[0]}${h[1]}${h[1]}${h[2]}${h[2]}`.toUpperCase();
39432
+ }
39433
+ return `#${h.toUpperCase()}`;
39434
+ };
39435
+ const hexToRgb = (hex) => {
39436
+ if (!hex || !isValidHex(hex))
39437
+ return null;
39438
+ const expanded = expandHex(hex).replace("#", "");
39439
+ return {
39440
+ r: parseInt(expanded.substring(0, 2), 16),
39441
+ g: parseInt(expanded.substring(2, 4), 16),
39442
+ b: parseInt(expanded.substring(4, 6), 16)
39443
+ };
39444
+ };
39445
+ const rgbToHex = (r2, g, b) => `#${((1 << 24) + (r2 << 16) + (g << 8) + b).toString(16).slice(1).toUpperCase()}`;
39446
+ const checkerboardStyle$1 = (size2 = 8) => ({
39447
+ backgroundImage: "linear-gradient(45deg, #ccc 25%, transparent 25%), linear-gradient(-45deg, #ccc 25%, transparent 25%), linear-gradient(45deg, transparent 75%, #ccc 75%), linear-gradient(-45deg, transparent 75%, #ccc 75%)",
39448
+ backgroundSize: `${size2}px ${size2}px`,
39449
+ backgroundPosition: `0 0, 0 ${size2 / 2}px, ${size2 / 2}px -${size2 / 2}px, -${size2 / 2}px 0px`
39450
+ });
39451
+ const normalizeColorValue = (value) => {
39452
+ if (isValidHex(value)) {
39453
+ return expandHex(value);
39454
+ }
39455
+ const parsed = get$6(value.toLowerCase());
39456
+ if (parsed)
39457
+ return rgbToHex(parsed.value[0], parsed.value[1], parsed.value[2]);
39458
+ return null;
39459
+ };
39460
+ const useHexInput = (color, onChange) => {
39461
+ const [inputValue, setInputValue] = React.useState(color);
39462
+ const [isFocused2, setIsFocused] = React.useState(false);
39463
+ React.useEffect(() => {
39464
+ if (!isFocused2) {
39465
+ setInputValue(color);
39466
+ }
39467
+ }, [color, isFocused2]);
39468
+ const handleChange = (e3) => {
39469
+ const value = e3.target.value;
39470
+ setInputValue(value);
39471
+ const normalized = normalizeColorValue(value);
39472
+ if (normalized)
39473
+ onChange(normalized);
39474
+ };
39475
+ const handleFocus = () => {
39476
+ setIsFocused(true);
39477
+ };
39478
+ const handleBlur = () => {
39479
+ setIsFocused(false);
39480
+ const normalized = normalizeColorValue(inputValue);
39481
+ if (normalized) {
39482
+ setInputValue(normalized);
39483
+ onChange(normalized);
39484
+ } else {
39485
+ setInputValue(color);
39486
+ }
39487
+ };
39488
+ const handleSwatchClick = React.useCallback(
39489
+ (c2) => {
39490
+ if (c2 === TRANSPARENT) {
39491
+ onChange(null);
39492
+ } else {
39493
+ const normalized = normalizeColorValue(c2);
39494
+ onChange(normalized || c2);
39495
+ }
39496
+ },
39497
+ [onChange]
39498
+ );
39499
+ return {
39500
+ inputValue,
39501
+ handleChange,
39502
+ handleFocus,
39503
+ handleBlur,
39504
+ handleSwatchClick
39505
+ };
39506
+ };
39507
+ const SwatchButton = ({ color, isSelected: isSelected2, onClick }) => /* @__PURE__ */ React.createElement("div", { className: "relative w-full pb-[100%]" }, /* @__PURE__ */ React.createElement(
39508
+ "button",
39509
+ {
39510
+ type: "button",
39511
+ onClick,
39512
+ className: `absolute inset-0 rounded-sm border cursor-pointer transition-all ${isSelected2 ? "border-blue-500 border-2 scale-110" : "border-gray-200 hover:scale-105"}`,
39513
+ style: {
39514
+ backgroundColor: color === TRANSPARENT ? "#FFF" : color,
39515
+ ...color === TRANSPARENT ? checkerboardStyle$1() : {}
39516
+ },
39517
+ "aria-label": color === TRANSPARENT ? "Clear color" : `Select color ${color}`
39518
+ }
39519
+ ));
39520
+ const ColorPreview = ({
39521
+ color,
39522
+ size: size2 = "sm"
39523
+ }) => /* @__PURE__ */ React.createElement(
39524
+ "div",
39525
+ {
39526
+ className: size2 === "lg" ? "h-16 w-full rounded border border-gray-200 mb-2" : "w-8 h-8 rounded border border-gray-200 flex-shrink-0",
39527
+ style: {
39528
+ backgroundColor: color || TRANSPARENT,
39529
+ ...!color ? checkerboardStyle$1(size2 === "lg" ? 16 : 8) : {}
39530
+ },
39531
+ "aria-label": "Current color preview"
39532
+ }
39533
+ );
39534
+ const HexInput = ({ value, onChange, onFocus, onBlur, fullWidth }) => /* @__PURE__ */ React.createElement(
39535
+ "input",
39536
+ {
39537
+ type: "text",
39538
+ value: value || "",
39539
+ onChange,
39540
+ onFocus,
39541
+ onBlur,
39542
+ placeholder: "#000000 or color name",
39543
+ className: `shadow-inner px-2 py-1 text-sm border border-gray-200 rounded focus:shadow-outline focus:border-blue-500 focus:outline-none ${fullWidth ? "w-full" : "flex-1 min-w-0"}`
39544
+ }
39545
+ );
39546
+ const SwatchGrid = ({ colors, selectedColor, onSelect }) => /* @__PURE__ */ React.createElement("div", { className: "mt-2 grid grid-cols-8 gap-1.5" }, colors.map((c2) => /* @__PURE__ */ React.createElement(
39547
+ SwatchButton,
39548
+ {
39549
+ key: c2,
39550
+ color: c2,
39551
+ isSelected: (selectedColor == null ? void 0 : selectedColor.toLowerCase()) === c2.toLowerCase(),
39552
+ onClick: () => onSelect(c2)
39553
+ }
39554
+ )));
39555
+ const BlockWidget = ({
39556
+ presetColors: presetColors2,
39557
+ color,
39558
+ onChange,
39559
+ width
39560
+ }) => {
39561
+ const {
39562
+ inputValue,
39563
+ handleChange,
39564
+ handleFocus,
39565
+ handleBlur,
39566
+ handleSwatchClick
39567
+ } = useHexInput(color, onChange);
39568
+ return /* @__PURE__ */ React.createElement(
39569
+ "div",
39570
+ {
39571
+ className: "bg-white rounded-lg shadow-lg overflow-hidden",
39572
+ style: { width }
39573
+ },
39574
+ /* @__PURE__ */ React.createElement("div", { className: "p-3" }, /* @__PURE__ */ React.createElement(ColorPreview, { color, size: "lg" }), /* @__PURE__ */ React.createElement(
39575
+ HexInput,
39576
+ {
39577
+ value: inputValue,
39578
+ onChange: handleChange,
39579
+ onFocus: handleFocus,
39580
+ onBlur: handleBlur,
39581
+ fullWidth: true
39582
+ }
39583
+ ), /* @__PURE__ */ React.createElement(
39584
+ SwatchGrid,
39585
+ {
39586
+ colors: presetColors2,
39587
+ selectedColor: color,
39588
+ onSelect: handleSwatchClick
39589
+ }
39590
+ ))
39591
+ );
39592
+ };
39371
39593
  var ColorFormat = /* @__PURE__ */ ((ColorFormat2) => {
39372
39594
  ColorFormat2["Hex"] = "hex";
39373
39595
  ColorFormat2["RGB"] = "rgb";
39374
39596
  return ColorFormat2;
39375
39597
  })(ColorFormat || {});
39376
- const rgbToHex = function(color) {
39377
- return "#" + ((1 << 24) + (color.r << 16) + (color.g << 8) + color.b).toString(16).slice(1);
39378
- };
39379
39598
  function ParseColorStr(color) {
39380
39599
  if (!color) {
39381
39600
  return null;
39382
39601
  }
39383
- const colorDescriptor = getColor(color);
39602
+ const colorDescriptor = get$6(color);
39384
39603
  if (!colorDescriptor)
39385
39604
  return null;
39386
39605
  const colorVals = colorDescriptor.value;
@@ -39396,7 +39615,7 @@ const ColorFormatter = {
39396
39615
  },
39397
39616
  getValue(color) {
39398
39617
  const colorVals = [color.r, color.g, color.b, color.a];
39399
- return toColor.rgb(colorVals);
39618
+ return to$1.rgb(colorVals);
39400
39619
  },
39401
39620
  parse: ParseColorStr
39402
39621
  },
@@ -39405,37 +39624,88 @@ const ColorFormatter = {
39405
39624
  /* Hex */
39406
39625
  ]: {
39407
39626
  getLabel(color) {
39408
- return rgbToHex(color);
39627
+ return rgbToHex(color.r, color.g, color.b);
39409
39628
  },
39410
39629
  getValue(color) {
39411
39630
  const colorVals = [color.r, color.g, color.b, color.a];
39412
- return toColor.hex(colorVals);
39631
+ return to$1.hex(colorVals).toUpperCase();
39413
39632
  },
39414
39633
  parse: ParseColorStr
39415
39634
  }
39416
39635
  };
39417
- const { SketchPicker, BlockPicker } = pkg$1;
39418
- const GetTextColorForBackground = function(backgroundColor) {
39419
- return !backgroundColor || backgroundColor.r * 0.299 + backgroundColor.g * 0.587 + backgroundColor.b * 0.114 > 186 ? "#000000" : "#ffffff";
39636
+ const SketchWidget = ({
39637
+ presetColors: presetColors2,
39638
+ color,
39639
+ onChange,
39640
+ width
39641
+ }) => {
39642
+ const {
39643
+ inputValue,
39644
+ handleChange,
39645
+ handleFocus,
39646
+ handleBlur,
39647
+ handleSwatchClick
39648
+ } = useHexInput(color, onChange);
39649
+ const currentRgb = hexToRgb(color) || { r: 0, g: 0, b: 0 };
39650
+ const handleRgbChange = (channel, value) => {
39651
+ const num = Math.max(0, Math.min(255, parseInt(value, 10) || 0));
39652
+ const updated = { ...currentRgb, [channel]: num };
39653
+ onChange(rgbToHex(updated.r, updated.g, updated.b));
39654
+ };
39655
+ return /* @__PURE__ */ React.createElement("div", { className: "bg-white rounded-lg shadow-lg p-3", style: { width } }, /* @__PURE__ */ React.createElement(
39656
+ HexColorPicker,
39657
+ {
39658
+ color: color || "#000000",
39659
+ onChange,
39660
+ className: "!w-full !h-[150px]"
39661
+ }
39662
+ ), /* @__PURE__ */ React.createElement("div", { className: "mt-2 flex gap-2 items-center" }, /* @__PURE__ */ React.createElement(ColorPreview, { color }), /* @__PURE__ */ React.createElement(
39663
+ HexInput,
39664
+ {
39665
+ value: inputValue,
39666
+ onChange: handleChange,
39667
+ onFocus: handleFocus,
39668
+ onBlur: handleBlur
39669
+ }
39670
+ )), /* @__PURE__ */ React.createElement("div", { className: "mt-2 flex gap-2" }, ["r", "g", "b"].map((channel) => /* @__PURE__ */ React.createElement("div", { key: channel, className: "flex-1" }, /* @__PURE__ */ React.createElement("label", { className: "block text-xs text-gray-500 mb-0.5" }, channel.toUpperCase()), /* @__PURE__ */ React.createElement(
39671
+ "input",
39672
+ {
39673
+ type: "number",
39674
+ min: 0,
39675
+ max: 255,
39676
+ value: currentRgb[channel],
39677
+ onChange: (e3) => handleRgbChange(channel, e3.target.value),
39678
+ className: "shadow-inner w-full px-2 py-1 text-sm border border-gray-200 rounded focus:shadow-outline focus:border-blue-500 focus:outline-none"
39679
+ }
39680
+ )))), /* @__PURE__ */ React.createElement(
39681
+ SwatchGrid,
39682
+ {
39683
+ colors: presetColors2,
39684
+ selectedColor: color,
39685
+ onSelect: handleSwatchClick
39686
+ }
39687
+ ));
39688
+ };
39689
+ const isLightBackground = function(backgroundColor) {
39690
+ return !backgroundColor || backgroundColor.r * 0.299 + backgroundColor.g * 0.587 + backgroundColor.b * 0.114 > 186;
39420
39691
  };
39421
- const Swatch = ({
39422
- colorRGBA,
39423
- colorFormat,
39424
- unselectable,
39425
- ...props
39426
- }) => /* @__PURE__ */ React.createElement(
39692
+ const getTextColorForBackground = function(backgroundColor) {
39693
+ return isLightBackground(backgroundColor) ? "#000000" : "#FFFFFF";
39694
+ };
39695
+ const Swatch = ({ colorRGBA, colorFormat, width, ...props }) => /* @__PURE__ */ React.createElement(
39427
39696
  "div",
39428
39697
  {
39429
- className: "bg-gray-100 rounded-3xl shadow-[0_2px_3px_rgba(0,0,0,0.12)] cursor-pointer w-full m-0",
39698
+ className: "bg-gray-100 rounded shadow-[0_2px_3px_rgba(0,0,0,0.12)] cursor-pointer m-0",
39699
+ style: { width },
39430
39700
  ...props
39431
39701
  },
39432
39702
  /* @__PURE__ */ React.createElement(
39433
39703
  "div",
39434
39704
  {
39435
- className: "swatch-inner flex items-center justify-center text-[13px] font-bold w-full h-10 rounded-3xl hover:opacity-[.6]",
39705
+ className: "swatch-inner flex items-center justify-center text-[13px] font-bold w-full h-10 rounded hover:opacity-[.6]",
39436
39706
  style: {
39437
39707
  background: colorRGBA ? `rgba(${colorRGBA.r}, ${colorRGBA.g}, ${colorRGBA.b}, ${colorRGBA.a})` : `#fff`,
39438
- color: GetTextColorForBackground(colorRGBA),
39708
+ color: getTextColorForBackground(colorRGBA),
39439
39709
  transition: "all var(--tina-timing-short) ease-out"
39440
39710
  }
39441
39711
  },
@@ -39451,7 +39721,7 @@ const Popover$2 = ({
39451
39721
  }) => /* @__PURE__ */ React.createElement(
39452
39722
  "div",
39453
39723
  {
39454
- className: `fixed z-50 before:content-[""] before:absolute before:left-1/2 before:-translate-x-1/2 before:w-[18px] before:h-[14px] before:bg-gray-200 before:z-10 after:content-[""] after:absolute after:left-1/2 after:-translate-x-1/2 after:w-4 after:h-[13px] after:bg-white after:z-20 ${openTop ? "before:bottom-0 before:mt-[1px] before:translate-y-full color-picker-on-top-clip-path after:bottom-0 after:mb-0.5 after:translate-y-full" : "before:top-0 before:mb-[1px] before:-translate-y-full color-picker-clip-path after:top-0 after:mt-0.5 after:-translate-y-full"} ${className}`,
39724
+ className: `fixed z-50 before:content-[""] before:absolute before:left-1/2 before:-translate-x-1/2 before:w-[18px] before:h-[14px] before:bg-white before:z-10 after:content-[""] after:absolute after:left-1/2 after:-translate-x-1/2 after:w-4 after:h-[13px] after:bg-white after:z-20 ${openTop ? "before:bottom-0 before:mt-[1px] before:translate-y-full color-picker-on-top-clip-path after:bottom-0 after:mb-0.5 after:translate-y-full" : "before:top-0 before:mb-[1px] before:-translate-y-full color-picker-clip-path after:top-0 after:mt-0.5 after:-translate-y-full"} ${className}`,
39455
39725
  style: {
39456
39726
  top: triggerBoundingBox ? openTop ? triggerBoundingBox.top : triggerBoundingBox.bottom : 0,
39457
39727
  left: triggerBoundingBox ? triggerBoundingBox.left + triggerBoundingBox.width / 2 : 0,
@@ -39463,7 +39733,6 @@ const Popover$2 = ({
39463
39733
  ...props
39464
39734
  }
39465
39735
  );
39466
- const nullColor = "transparent";
39467
39736
  const presetColors = [
39468
39737
  "#D0021B",
39469
39738
  "#F5A623",
@@ -39481,93 +39750,69 @@ const presetColors = [
39481
39750
  "#9B9B9B",
39482
39751
  "#FFFFFF"
39483
39752
  ];
39484
- const SketchWidget = (props) => /* @__PURE__ */ React.createElement(
39485
- SketchPicker,
39486
- {
39487
- presetColors: props.presetColors,
39488
- color: props.color,
39489
- onChange: props.onChange,
39490
- disableAlpha: props.disableAlpha,
39491
- width: props.width
39492
- }
39493
- );
39494
- const BlockWidget = (props) => /* @__PURE__ */ React.createElement(
39495
- BlockPicker,
39496
- {
39497
- colors: props.presetColors,
39498
- color: props.color,
39499
- onChange: props.onChange,
39500
- width: props.width
39501
- }
39502
- );
39503
39753
  const WIDGETS = { sketch: SketchWidget, block: BlockWidget };
39504
39754
  const ColorPicker = ({
39505
39755
  colorFormat,
39506
39756
  userColors = presetColors,
39507
39757
  widget = "sketch",
39758
+ width,
39508
39759
  input
39509
39760
  }) => {
39510
39761
  const FormPortal = useFormPortal();
39511
39762
  const triggerRef = React.useRef(null);
39512
39763
  const [triggerBoundingBox, setTriggerBoundingBox] = useState(null);
39513
- const [openTop, setOpenTop] = useState(false);
39764
+ const [displayColorPicker, setDisplayColorPicker] = useState(false);
39514
39765
  const updateTriggerBoundingBox = () => {
39515
- if (triggerRef.current) {
39766
+ if (triggerRef.current)
39516
39767
  setTriggerBoundingBox(triggerRef.current.getBoundingClientRect());
39517
- }
39518
39768
  };
39519
- React.useEffect(() => {
39520
- if (triggerBoundingBox) {
39521
- const triggerOffsetTop = triggerBoundingBox.top + triggerBoundingBox.height / 2;
39522
- const windowHeight = window.innerHeight;
39523
- if (triggerOffsetTop > windowHeight / 2) {
39524
- setOpenTop(true);
39525
- } else {
39526
- setOpenTop(false);
39527
- }
39528
- }
39529
- }, [triggerBoundingBox]);
39769
+ const openTop = triggerBoundingBox ? triggerBoundingBox.top + triggerBoundingBox.height / 2 > window.innerHeight / 2 : false;
39530
39770
  React.useEffect(() => {
39531
39771
  const delay = 100;
39532
- let timeout = false;
39533
- setTimeout(() => {
39534
- updateTriggerBoundingBox();
39535
- }, delay);
39772
+ let timeout = null;
39773
+ timeout = setTimeout(updateTriggerBoundingBox, delay);
39536
39774
  const handleResize = () => {
39537
- clearTimeout(timeout);
39775
+ if (timeout)
39776
+ clearTimeout(timeout);
39538
39777
  timeout = setTimeout(updateTriggerBoundingBox, delay);
39539
39778
  };
39540
39779
  window.addEventListener("resize", handleResize);
39541
- return () => {
39542
- window.removeEventListener("resize", handleResize);
39543
- };
39544
- }, [triggerRef.current]);
39545
- const Widget = WIDGETS[widget];
39546
- if (!Widget)
39547
- throw new Error("You must specify a widget type.");
39548
- const [displayColorPicker, setDisplayColorPicker] = useState(false);
39780
+ return () => window.removeEventListener("resize", handleResize);
39781
+ }, []);
39549
39782
  const getColorFormat = (colorFormat || ColorFormat.Hex).toLowerCase();
39550
39783
  const getColorRGBA = input.value ? ColorFormatter[getColorFormat].parse(input.value) : null;
39551
- const handleChange = (pickerColor) => {
39552
- const color = pickerColor.hex === nullColor ? null : { ...pickerColor.rgb, a: 1 };
39553
- input.onChange(
39554
- color ? ColorFormatter[getColorFormat].getValue(color) : null
39555
- );
39556
- };
39784
+ const currentHexColor = getColorRGBA ? rgbToHex(getColorRGBA.r, getColorRGBA.g, getColorRGBA.b) : "";
39785
+ const handleChange = useCallback(
39786
+ (hexColor) => {
39787
+ if (!hexColor) {
39788
+ input.onChange(null);
39789
+ return;
39790
+ }
39791
+ const rgb = hexToRgb(hexColor);
39792
+ if (rgb)
39793
+ input.onChange(
39794
+ ColorFormatter[getColorFormat].getValue({ ...rgb, a: 1 })
39795
+ );
39796
+ },
39797
+ [getColorFormat, input]
39798
+ );
39557
39799
  const toggleColorPicker = (event) => {
39558
39800
  event.stopPropagation();
39559
39801
  const display = !displayColorPicker;
39560
39802
  setDisplayColorPicker(display);
39561
- if (display) {
39803
+ if (display)
39562
39804
  updateTriggerBoundingBox();
39563
- }
39564
39805
  };
39565
- return /* @__PURE__ */ React.createElement("div", { className: "relative", ref: triggerRef }, /* @__PURE__ */ React.createElement(
39806
+ const Widget = WIDGETS[widget];
39807
+ if (!Widget)
39808
+ throw new Error("You must specify a widget type.");
39809
+ return /* @__PURE__ */ React.createElement("div", { className: "relative", ref: triggerRef, style: { width } }, /* @__PURE__ */ React.createElement(
39566
39810
  Swatch,
39567
39811
  {
39568
39812
  onClick: toggleColorPicker,
39569
39813
  colorRGBA: getColorRGBA,
39570
- colorFormat: getColorFormat
39814
+ colorFormat: getColorFormat,
39815
+ width
39571
39816
  }
39572
39817
  ), displayColorPicker && /* @__PURE__ */ React.createElement(FormPortal, null, ({ zIndexShift }) => /* @__PURE__ */ React.createElement(
39573
39818
  Popover$2,
@@ -39587,11 +39832,10 @@ const ColorPicker = ({
39587
39832
  /* @__PURE__ */ React.createElement(
39588
39833
  Widget,
39589
39834
  {
39590
- presetColors: [...userColors, nullColor],
39591
- color: getColorRGBA || { r: 0, g: 0, b: 0, a: 0 },
39835
+ presetColors: [...userColors, TRANSPARENT],
39836
+ color: currentHexColor,
39592
39837
  onChange: handleChange,
39593
- disableAlpha: true,
39594
- width: "240px"
39838
+ width: width || "240px"
39595
39839
  }
39596
39840
  )
39597
39841
  )
@@ -41338,6 +41582,7 @@ const ColorField = wrapFieldsWithMeta(
41338
41582
  colorFormat: field.colorFormat,
41339
41583
  userColors: field.colors,
41340
41584
  widget: field.widget,
41585
+ width: field.width,
41341
41586
  input
41342
41587
  }
41343
41588
  );
@@ -42838,7 +43083,10 @@ const formatCurrentDate = ({
42838
43083
  if (!dateFormat) {
42839
43084
  return format$1(displayDate, timeFormat);
42840
43085
  }
42841
- return `${format$1(displayDate, dateFormat)} ${format$1(displayDate, timeFormat)}`;
43086
+ return `${format$1(displayDate, dateFormat)} ${format$1(
43087
+ displayDate,
43088
+ timeFormat
43089
+ )}`;
42842
43090
  };
42843
43091
  function Calendar({
42844
43092
  className,
@@ -43240,7 +43488,8 @@ const DateTimePicker = React.forwardRef(
43240
43488
  }),
43241
43489
  [displayDate]
43242
43490
  );
43243
- const { options, localize: localize2, formatLong: formatLong2 } = locale2;
43491
+ const localeAny = locale2;
43492
+ const { options, localize: localize2, formatLong: formatLong2 } = localeAny || {};
43244
43493
  if (options && localize2 && formatLong2) {
43245
43494
  ({
43246
43495
  ...enUS,
@@ -43310,7 +43559,7 @@ const format$1 = (date, format2) => {
43310
43559
  return m.format(format2);
43311
43560
  };
43312
43561
  const DateField = wrapFieldsWithMeta(
43313
- ({ input, field: { dateFormat, timeFormat, onChange, ...rest } }) => {
43562
+ ({ input, field: { dateFormat, timeFormat, onChange, locale: locale2, ...rest } }) => {
43314
43563
  const granularity = timeFormat ? "minute" : "day";
43315
43564
  const inputRef = React__default.useRef(null);
43316
43565
  React__default.useEffect(() => {
@@ -43781,7 +44030,7 @@ const Badge = ({
43781
44030
  children
43782
44031
  );
43783
44032
  };
43784
- const tableHeadingStyle = "px-3 py-3 text-left text-xs font-bold text-gray-700 tracking-wider";
44033
+ const tableHeadingStyle = "px-3 py-3 text-left text-xs font-bold text-gray-700 tracking-wider sticky top-0 bg-gray-100 z-20 border-b-2 border-gray-200 ";
43785
44034
  function formatBranchName(str) {
43786
44035
  const pattern = /[^/\w-]+/g;
43787
44036
  const formattedStr = str.replace(pattern, "-");
@@ -44017,6 +44266,9 @@ const BranchSelector = ({
44017
44266
  const [search, setSearch] = React.useState("");
44018
44267
  const [filter2, setFilter] = React.useState("content");
44019
44268
  const [sortValue, setSortValue] = React.useState("default");
44269
+ const [selectedBranch, setSelectedBranch] = React.useState(
44270
+ null
44271
+ );
44020
44272
  const cms = useCMS$1();
44021
44273
  const filteredBranchList = getFilteredBranchList(
44022
44274
  branchList,
@@ -44076,7 +44328,19 @@ const BranchSelector = ({
44076
44328
  }
44077
44329
  ]
44078
44330
  }
44079
- ))), filteredBranchList.length === 0 && /* @__PURE__ */ React.createElement("div", { className: "block relative text-gray-300 italic py-1" }, "No branches to display"), filteredBranchList.length > 0 && /* @__PURE__ */ React.createElement("div", { className: "min-w-[192px] max-h-[24rem] overflow-y-auto w-full h-full rounded-lg shadow-inner bg-white border border-gray-200" }, /* @__PURE__ */ React.createElement("table", { className: "w-full" }, /* @__PURE__ */ React.createElement("thead", { className: "bg-gray-100 border-b-2 border-gray-200" }, /* @__PURE__ */ React.createElement("tr", null, /* @__PURE__ */ React.createElement("th", { className: tableHeadingStyle }, "Branch Name"), /* @__PURE__ */ React.createElement("th", { className: tableHeadingStyle }, "Last Updated"), /* @__PURE__ */ React.createElement("th", null), /* @__PURE__ */ React.createElement("th", null))), /* @__PURE__ */ React.createElement("tbody", null, filteredBranchList.map((branch) => /* @__PURE__ */ React.createElement(
44331
+ ))), filteredBranchList.length === 0 && /* @__PURE__ */ React.createElement("div", { className: "block relative text-gray-300 italic py-1" }, "No branches to display"), filteredBranchList.length > 0 && /* @__PURE__ */ React.createElement(TooltipProvider$1, null, /* @__PURE__ */ React.createElement("div", { className: "rounded-lg border border-gray-200 overflow-hidden" }, /* @__PURE__ */ React.createElement("div", { className: "min-w-[192px] max-h-[24rem] overflow-y-auto w-full h-full shadow-inner bg-white" }, /* @__PURE__ */ React.createElement("table", { className: "w-full table-auto max-h-[24rem]" }, /* @__PURE__ */ React.createElement("thead", { className: "sticky top-0 z-20 bg-gray-100 border-b-2 border-gray-200" }, /* @__PURE__ */ React.createElement("tr", null, /* @__PURE__ */ React.createElement("th", { className: `${tableHeadingStyle} w-auto` }, "Branch Name"), /* @__PURE__ */ React.createElement(
44332
+ "th",
44333
+ {
44334
+ className: `${tableHeadingStyle} w-0 whitespace-nowrap text-left`
44335
+ },
44336
+ "Last Updated"
44337
+ ), /* @__PURE__ */ React.createElement(
44338
+ "th",
44339
+ {
44340
+ className: `${tableHeadingStyle} w-0 whitespace-nowrap text-left`
44341
+ },
44342
+ "Pull Request"
44343
+ ))), /* @__PURE__ */ React.createElement("tbody", null, filteredBranchList.map((branch) => /* @__PURE__ */ React.createElement(
44080
44344
  BranchItem,
44081
44345
  {
44082
44346
  key: branch.name,
@@ -44085,9 +44349,24 @@ const BranchSelector = ({
44085
44349
  onChange,
44086
44350
  refreshBranchList,
44087
44351
  previewFunction,
44088
- cms
44352
+ cms,
44353
+ selectedBranch,
44354
+ onSelectBranch: setSelectedBranch
44089
44355
  }
44090
- ))))));
44356
+ ))))))), /* @__PURE__ */ React.createElement("div", { className: "flex justify-end" }, /* @__PURE__ */ React.createElement(
44357
+ Button$2,
44358
+ {
44359
+ variant: "primary",
44360
+ onClick: () => {
44361
+ onChange(selectedBranch);
44362
+ },
44363
+ disabled: !selectedBranch || selectedBranch === currentBranch
44364
+ },
44365
+ "Open branch in editor"
44366
+ )));
44367
+ };
44368
+ const extractPullRequestId = (url) => {
44369
+ return url.split("/").pop() || "";
44091
44370
  };
44092
44371
  const BranchItem = ({
44093
44372
  branch,
@@ -44095,9 +44374,11 @@ const BranchItem = ({
44095
44374
  onChange,
44096
44375
  refreshBranchList,
44097
44376
  previewFunction,
44098
- cms
44377
+ cms,
44378
+ selectedBranch,
44379
+ onSelectBranch
44099
44380
  }) => {
44100
- var _a2, _b;
44381
+ var _a2;
44101
44382
  const [creatingPR, setCreatingPR] = React.useState(false);
44102
44383
  const handleCreatePullRequest = async () => {
44103
44384
  if (creatingPR)
@@ -44121,62 +44402,63 @@ const BranchItem = ({
44121
44402
  }
44122
44403
  };
44123
44404
  const isCurrentBranch = branch.name === currentBranch;
44405
+ const isSelected2 = selectedBranch === branch.name;
44124
44406
  const indexingStatus = (_a2 = branch == null ? void 0 : branch.indexStatus) == null ? void 0 : _a2.status;
44407
+ const handleRowClick = () => {
44408
+ if (indexingStatus === "complete" && !isCurrentBranch) {
44409
+ onSelectBranch(isSelected2 ? null : branch.name);
44410
+ }
44411
+ };
44125
44412
  return /* @__PURE__ */ React.createElement(
44126
44413
  "tr",
44127
44414
  {
44128
- className: `text-base border-l-0 border-t-0 border-r-0 outline-none transition-all ease-out duration-150 ${indexingStatus !== "complete" ? "bg-gray-50 text-gray-400" : isCurrentBranch ? "bg-blue-50 text-blue-800 border-b-0" : "border-b-2 border-gray-50"}`
44415
+ onClick: handleRowClick,
44416
+ className: `text-base border-l-0 transition-colors border-t-0 border-r-0 outline-none transition-all ease-out duration-150 ${indexingStatus !== "complete" ? "bg-gray-50 text-gray-400" : isCurrentBranch ? "border-b-2 border-gray-50" : isSelected2 ? "bg-blue-100 text-blue-900 border-b-2 border-blue-50 cursor-pointer" : "border-b-2 border-gray-50 hover:bg-gray-50/50 cursor-pointer"}`
44129
44417
  },
44130
- /* @__PURE__ */ React.createElement("td", { className: "pl-3 pr-3 py-1.5 min-w-0" }, /* @__PURE__ */ React.createElement("div", { className: "flex flex-col" }, /* @__PURE__ */ React.createElement("div", { className: "flex items-center gap-1" }, branch.protected && /* @__PURE__ */ React.createElement(BiLock, { className: "w-5 h-auto opacity-70 text-blue-500 flex-shrink-0" }), /* @__PURE__ */ React.createElement("span", { className: "text-sm leading-tight truncate" }, branch.name)), indexingStatus !== "complete" && /* @__PURE__ */ React.createElement("div", { className: "w-fit mt-1" }, /* @__PURE__ */ React.createElement(IndexStatus, { indexingStatus: branch.indexStatus.status })))),
44418
+ /* @__PURE__ */ React.createElement(
44419
+ "td",
44420
+ {
44421
+ className: `pl-3 pr-3 max-w-xs ${isCurrentBranch ? "py-2.5" : "py-1.5"}`
44422
+ },
44423
+ /* @__PURE__ */ React.createElement("div", { className: "flex flex-col" }, /* @__PURE__ */ React.createElement("div", { className: "flex items-center gap-1 min-w-0" }, branch.protected ? /* @__PURE__ */ React.createElement(BiLockAlt, { className: "w-4 h-auto opacity-70 text-blue-500 flex-shrink-0" }) : /* @__PURE__ */ React.createElement(BiGitBranch, { className: "w-4 h-auto opacity-70 text-gray-600 flex-shrink-0" }), /* @__PURE__ */ React.createElement(Tooltip$1, { delayDuration: 300 }, /* @__PURE__ */ React.createElement(TooltipTrigger$1, { asChild: true }, /* @__PURE__ */ React.createElement("span", { className: "text-sm leading-tight truncate block min-w-0 cursor-default" }, branch.name)), /* @__PURE__ */ React.createElement(TooltipPortal, null, /* @__PURE__ */ React.createElement(TooltipContent$1, { side: "top" }, branch.name)))), isCurrentBranch && /* @__PURE__ */ React.createElement("div", { className: "w-fit mt-1" }, /* @__PURE__ */ React.createElement(
44424
+ Badge,
44425
+ {
44426
+ calloutStyle: "info",
44427
+ className: "w-fit flex-shrink-0",
44428
+ displayIcon: false
44429
+ },
44430
+ /* @__PURE__ */ React.createElement(BiPencil, { className: "w-3 h-auto inline-block mr-1" }),
44431
+ "Currently editing"
44432
+ )), indexingStatus !== "complete" && /* @__PURE__ */ React.createElement("div", { className: "w-fit mt-1" }, /* @__PURE__ */ React.createElement(IndexStatus, { indexingStatus: branch.indexStatus.status })))
44433
+ ),
44131
44434
  /* @__PURE__ */ React.createElement("td", { className: "px-3 py-1.5 min-w-0" }, creatingPR ? /* @__PURE__ */ React.createElement("div", { className: "flex items-center gap-2" }, /* @__PURE__ */ React.createElement("div", null, /* @__PURE__ */ React.createElement("div", { className: "text-xs font-bold text-blue-600" }, "Creating PR"), /* @__PURE__ */ React.createElement("span", { className: "text-sm leading-tight text-blue-500" }, "Please wait...")), /* @__PURE__ */ React.createElement(FaSpinner, { className: "w-3 h-auto animate-spin text-blue-500" })) : /* @__PURE__ */ React.createElement("span", { className: "text-sm leading-tight whitespace-nowrap" }, formatDistanceToNow$1(new Date(branch.indexStatus.timestamp), {
44132
44435
  addSuffix: true
44133
44436
  }))),
44134
- /* @__PURE__ */ React.createElement("td", { className: "px-3 py-1.5 text-left" }, indexingStatus === "complete" && !isCurrentBranch && /* @__PURE__ */ React.createElement(
44437
+ /* @__PURE__ */ React.createElement("td", { className: "px-3 py-1.5 flex", onClick: (e3) => e3.stopPropagation() }, branch.githubPullRequestUrl ? /* @__PURE__ */ React.createElement(
44135
44438
  Button$2,
44136
44439
  {
44137
44440
  variant: "white",
44138
44441
  size: "custom",
44139
44442
  onClick: () => {
44140
- onChange(branch.name);
44443
+ window.open(branch.githubPullRequestUrl, "_blank");
44141
44444
  },
44142
- className: "cursor-pointer text-sm h-9 px-4 flex items-center gap-1"
44445
+ className: "cursor-pointer h-9 px-2 flex items-center gap-1",
44446
+ title: "Open Git Pull Request"
44143
44447
  },
44144
- /* @__PURE__ */ React.createElement(BiPencil, { className: "h-4 w-auto text-blue-500 opacity-70 -mt-px" }),
44145
- " ",
44146
- "Select"
44147
- ), indexingStatus === "complete" && isCurrentBranch && /* @__PURE__ */ React.createElement(Badge, { calloutStyle: "info", className: "w-fit", displayIcon: false }, /* @__PURE__ */ React.createElement("span", null, "Selected"))),
44148
- /* @__PURE__ */ React.createElement("td", { className: "px-3 py-1.5 text-right" }, /* @__PURE__ */ React.createElement(
44149
- OverflowMenu$1,
44150
- {
44151
- toolbarItems: [
44152
- branch.githubPullRequestUrl && {
44153
- name: "github-pr",
44154
- label: "View in GitHub",
44155
- Icon: /* @__PURE__ */ React.createElement(BiLinkExternal, { className: "w-5 h-auto text-blue-500 opacity-70" }),
44156
- onMouseDown: () => {
44157
- window.open(branch.githubPullRequestUrl, "_blank");
44158
- }
44159
- },
44160
- !branch.githubPullRequestUrl && !branch.protected && !creatingPR && cms.api.tina.usingProtectedBranch() && {
44161
- name: "create-pr",
44162
- label: "Create Pull Request",
44163
- Icon: /* @__PURE__ */ React.createElement(BiGitBranch, { className: "w-5 h-auto text-blue-500 opacity-70" }),
44164
- onMouseDown: () => handleCreatePullRequest()
44165
- },
44166
- typeof previewFunction === "function" && ((_b = previewFunction({ branch: branch.name })) == null ? void 0 : _b.url) && {
44167
- name: "preview",
44168
- label: "Preview",
44169
- onMouseDown: () => {
44170
- var _a3;
44171
- const previewUrl = (_a3 = previewFunction({
44172
- branch: branch.name
44173
- })) == null ? void 0 : _a3.url;
44174
- window.open(previewUrl, "_blank");
44175
- }
44176
- }
44177
- ].filter(Boolean)
44178
- }
44179
- ))
44448
+ /* @__PURE__ */ React.createElement(BiLinkExternal, { className: "h-3.5 w-auto text-gray-700 flex-shrink-0" }),
44449
+ /* @__PURE__ */ React.createElement("span", { className: "text-sm truncate max-w-[120px]" }, "PR: ", extractPullRequestId(branch.githubPullRequestUrl))
44450
+ ) : !branch.protected && !creatingPR && cms.api.tina.usingProtectedBranch() ? /* @__PURE__ */ React.createElement(
44451
+ Button$2,
44452
+ {
44453
+ variant: "white",
44454
+ size: "custom",
44455
+ onClick: handleCreatePullRequest,
44456
+ className: "cursor-pointer h-9 px-2 flex items-center gap-1",
44457
+ title: "Create Pull Request"
44458
+ },
44459
+ /* @__PURE__ */ React.createElement(BiGitBranch, { className: "h-3.5 w-auto text-gray-700 flex-shrink-0" }),
44460
+ /* @__PURE__ */ React.createElement("span", { className: "text-sm whitespace-nowrap" }, "Create PR")
44461
+ ) : null)
44180
44462
  );
44181
44463
  };
44182
44464
  const IndexStatus = ({ indexingStatus }) => {
@@ -45485,7 +45767,7 @@ function GridMediaItem({ item, active, onClick }) {
45485
45767
  src: thumbnail,
45486
45768
  alt: item.filename
45487
45769
  }
45488
- )) : /* @__PURE__ */ React__default.createElement("div", { className: "p-4 w-full flex flex-col gap-4 items-center justify-center" }, /* @__PURE__ */ React__default.createElement(FileIcon, { className: "w-[30%] h-auto fill-gray-300" }), /* @__PURE__ */ React__default.createElement("span", { className: "block text-base text-gray-600 w-full break-words truncate" }, item.filename)))
45770
+ )) : /* @__PURE__ */ React__default.createElement("div", { className: "p-4 w-full flex flex-col gap-4 items-center justify-center" }, /* @__PURE__ */ React__default.createElement(FileIcon, { className: "w-[40%] h-auto fill-gray-300", size: 40 })))
45489
45771
  ));
45490
45772
  }
45491
45773
  const DeleteModal$1 = ({
@@ -46296,12 +46578,12 @@ const Callout = ({
46296
46578
  className = "",
46297
46579
  ...props
46298
46580
  }) => {
46299
- const commonAlertStyles = "text-sm px-4 py-3 rounded-md border";
46581
+ const commonAlertStyles = "text-sm px-4 py-3 rounded-md border-2 font bg-white text-gray-700 font-medium";
46300
46582
  const styles = {
46301
- warning: `text-amber-700 bg-amber-100 border-amber-700/20`,
46302
- info: `text-blue-600 bg-blue-100/50 border-blue-600/20`,
46303
- success: `text-green-600 bg-green-100/50 border-green-600/20`,
46304
- error: `text-red-600 bg-red-100/50 border-red-600/20`
46583
+ warning: `border-amber-700/20`,
46584
+ info: `border-blue-600/20`,
46585
+ success: `border-green-600/20`,
46586
+ error: `border-red-600/20`
46305
46587
  };
46306
46588
  const icon = {
46307
46589
  warning: /* @__PURE__ */ React.createElement(MdWarning, { className: "w-5 h-auto inline-block mr-1 opacity-70 text-amber-600" }),
@@ -46414,7 +46696,7 @@ const NavProvider = ({
46414
46696
  };
46415
46697
  return /* @__PURE__ */ React__default.createElement(NavContext.Provider, { value }, children);
46416
46698
  };
46417
- const version$1 = "3.0.0";
46699
+ const version$1 = "3.1.0";
46418
46700
  const VersionInfo = () => {
46419
46701
  var _a2, _b, _c, _d, _e, _f;
46420
46702
  const cms = useCMS();
@@ -47100,8 +47382,25 @@ const Emoji$1 = ({ className = "", ...props }) => /* @__PURE__ */ React.createEl
47100
47382
  ...props
47101
47383
  }
47102
47384
  );
47385
+ const TooltipProvider = TooltipPrimitive.Provider;
47386
+ const Tooltip = TooltipPrimitive.Root;
47387
+ const TooltipTrigger = TooltipPrimitive.Trigger;
47388
+ const TooltipContent = React.forwardRef(({ className, sideOffset = 4, ...props }, ref) => /* @__PURE__ */ React.createElement(TooltipPrimitive.Portal, null, /* @__PURE__ */ React.createElement(
47389
+ TooltipPrimitive.Content,
47390
+ {
47391
+ ref,
47392
+ sideOffset,
47393
+ className: cn$1(
47394
+ "z-[10000] overflow-hidden rounded bg-[#FFF] px-3 py-1.5 text-xs text-[#504E5E] shadow-sm animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 origin-[--radix-tooltip-content-transform-origin]",
47395
+ className
47396
+ ),
47397
+ ...props
47398
+ }
47399
+ )));
47400
+ TooltipContent.displayName = TooltipPrimitive.Content.displayName;
47103
47401
  const minimumTimeToShowLoadingIndicator = 1e3;
47104
47402
  const FormsView = ({ loadingPlaceholder } = {}) => {
47403
+ var _a2, _b;
47105
47404
  const cms = useCMS$1();
47106
47405
  const { setFormIsPristine } = React.useContext(SidebarContext);
47107
47406
  const [isShowingLoading, setIsShowingLoading] = React.useState(true);
@@ -47140,7 +47439,15 @@ const FormsView = ({ loadingPlaceholder } = {}) => {
47140
47439
  return /* @__PURE__ */ React.createElement(FormLists, { isEditing });
47141
47440
  }
47142
47441
  const formMetas = cms.plugins.all("form:meta");
47143
- return /* @__PURE__ */ React.createElement(React.Fragment, null, activeForm && /* @__PURE__ */ React.createElement(FormWrapper$1, { isEditing, isMultiform }, /* @__PURE__ */ React.createElement(FormHeader, { activeForm }), formMetas == null ? void 0 : formMetas.map((meta) => /* @__PURE__ */ React.createElement(React.Fragment, { key: meta.name }, /* @__PURE__ */ React.createElement(meta.Component, null))), /* @__PURE__ */ React.createElement(FormBuilder, { form: activeForm, onPristineChange: setFormIsPristine })));
47442
+ return /* @__PURE__ */ React.createElement(React.Fragment, null, activeForm && /* @__PURE__ */ React.createElement(FormWrapper$1, { isEditing, isMultiform }, /* @__PURE__ */ React.createElement(
47443
+ FormHeader,
47444
+ {
47445
+ activeForm,
47446
+ branch: cms.api.admin.api.branch,
47447
+ repoProvider: cms.api.admin.api.schema.config.config.repoProvider,
47448
+ isLocalMode: (_b = (_a2 = cms.api) == null ? void 0 : _a2.tina) == null ? void 0 : _b.isLocalMode
47449
+ }
47450
+ ), formMetas == null ? void 0 : formMetas.map((meta) => /* @__PURE__ */ React.createElement(React.Fragment, { key: meta.name }, /* @__PURE__ */ React.createElement(meta.Component, null))), /* @__PURE__ */ React.createElement(FormBuilder, { form: activeForm, onPristineChange: setFormIsPristine })));
47144
47451
  };
47145
47452
  const FormWrapper$1 = ({ isEditing, children }) => {
47146
47453
  return /* @__PURE__ */ React.createElement(
@@ -47161,9 +47468,54 @@ const FormWrapper$1 = ({ isEditing, children }) => {
47161
47468
  children
47162
47469
  );
47163
47470
  };
47164
- const FormHeader = ({ activeForm }) => {
47471
+ const FormHeader = ({
47472
+ activeForm,
47473
+ repoProvider,
47474
+ branch,
47475
+ isLocalMode
47476
+ }) => {
47165
47477
  const { formIsPristine } = React.useContext(SidebarContext);
47166
- return /* @__PURE__ */ React.createElement("div", { className: "px-4 pt-2 pb-4 flex flex-row flex-nowrap justify-between items-center gap-2 bg-gradient-to-t from-white to-gray-50" }, /* @__PURE__ */ React.createElement(MultiformSelector, { activeForm }), /* @__PURE__ */ React.createElement(FormBreadcrumbs, { className: "w-[calc(100%-3rem)]" }), /* @__PURE__ */ React.createElement(FormStatus, { pristine: formIsPristine }));
47478
+ return /* @__PURE__ */ React.createElement("div", { className: "px-4 pt-2 pb-4 flex flex-row flex-nowrap justify-between items-center gap-2 bg-gradient-to-t from-white to-gray-50" }, /* @__PURE__ */ React.createElement(MultiformSelector, { activeForm }), /* @__PURE__ */ React.createElement(FormBreadcrumbs, { className: "w-[calc(100%-3rem)]" }), /* @__PURE__ */ React.createElement(
47479
+ FileHistoryProvider,
47480
+ {
47481
+ defaultBranchName: repoProvider == null ? void 0 : repoProvider.defaultBranchName,
47482
+ historyUrl: repoProvider == null ? void 0 : repoProvider.historyUrl,
47483
+ contentRelativePath: activeForm.tinaForm.path,
47484
+ tinaBranch: branch,
47485
+ isLocalMode
47486
+ }
47487
+ ), /* @__PURE__ */ React.createElement(FormStatus, { pristine: formIsPristine }));
47488
+ };
47489
+ const FileHistoryProvider = ({
47490
+ contentRelativePath,
47491
+ tinaBranch,
47492
+ defaultBranchName,
47493
+ historyUrl,
47494
+ isLocalMode
47495
+ }) => {
47496
+ if (!historyUrl) {
47497
+ return null;
47498
+ }
47499
+ const branch = isLocalMode ? defaultBranchName || tinaBranch : tinaBranch;
47500
+ if (!branch) {
47501
+ return null;
47502
+ }
47503
+ const { url } = historyUrl({
47504
+ relativePath: contentRelativePath,
47505
+ branch
47506
+ });
47507
+ if (!url) {
47508
+ return null;
47509
+ }
47510
+ return /* @__PURE__ */ React.createElement(TooltipProvider, null, /* @__PURE__ */ React.createElement(Tooltip, null, /* @__PURE__ */ React.createElement(TooltipTrigger, { asChild: true }, /* @__PURE__ */ React.createElement("button", { type: "button" }, /* @__PURE__ */ React.createElement(
47511
+ "a",
47512
+ {
47513
+ href: url,
47514
+ target: "_blank",
47515
+ className: "flex items-center gap-1 border-[0.5px] hover:bg-gray-300/10 transition-all duration-300 border-gray-300 rounded-md p-2"
47516
+ },
47517
+ /* @__PURE__ */ React.createElement(History, { className: "size-4 text-gray-700" })
47518
+ ))), /* @__PURE__ */ React.createElement(TooltipContent, { side: "top", className: "shadow-md" }, "View file history")));
47167
47519
  };
47168
47520
  const FormBreadcrumbs = ({
47169
47521
  rootBreadcrumbName,
@@ -48082,10 +48434,10 @@ function Alerts2({ alerts }) {
48082
48434
  if (!alerts.all.length) {
48083
48435
  return null;
48084
48436
  }
48085
- return /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, /* @__PURE__ */ React__default.createElement("div", { className: "fixed top-0 left-0 p-6 flex flex-col items-center z-[999999]" }, alerts.all.filter((alert) => {
48437
+ return /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, /* @__PURE__ */ React__default.createElement("div", { className: "fixed top-6 left-6 flex flex-col items-center z-[999999]" }, alerts.all.filter((alert) => {
48086
48438
  return alert.level !== "error";
48087
48439
  }).map((alert) => {
48088
- return /* @__PURE__ */ React__default.createElement(Alert, { key: alert.id, level: alert.level }, alert.level === "info" && /* @__PURE__ */ React__default.createElement(MdInfo, { className: "w-5 h-auto opacity-70" }), alert.level === "success" && /* @__PURE__ */ React__default.createElement(MdCheckCircle, { className: "w-5 h-auto opacity-70" }), alert.level === "warn" && /* @__PURE__ */ React__default.createElement(MdWarning, { className: "w-5 h-auto opacity-70" }), /* @__PURE__ */ React__default.createElement("p", { className: "m-0 flex-1 max-w-[680px] text-left" }, parseUrlsInText(alert.message.toString())), /* @__PURE__ */ React__default.createElement(
48440
+ return /* @__PURE__ */ React__default.createElement(Alert, { key: alert.id, level: alert.level }, alert.level === "info" && /* @__PURE__ */ React__default.createElement(MdInfo, { className: "w-5 h-auto text-blue-500" }), alert.level === "success" && /* @__PURE__ */ React__default.createElement(MdCheckCircle, { className: "w-5 h-auto text-green-500" }), alert.level === "warn" && /* @__PURE__ */ React__default.createElement(MdWarning, { className: "w-5 h-auto text-yellow-500" }), /* @__PURE__ */ React__default.createElement("p", { className: "m-0 flex-1 max-w-[680px] text-left" }, parseUrlsInText(alert.message.toString())), /* @__PURE__ */ React__default.createElement(
48089
48441
  CloseAlert,
48090
48442
  {
48091
48443
  onClick: () => {
@@ -48126,21 +48478,21 @@ const Alert = ({
48126
48478
  ...props
48127
48479
  }) => {
48128
48480
  const colorClasses = {
48129
- info: "bg-white border-blue-500 text-blue-600 fill-blue-500",
48130
- success: "bg-white border-green-500 text-green-600 fill-green-500",
48131
- warn: "bg-white border-yellow-500 text-yellow-600 fill-yellow-500",
48132
- error: "bg-white border-red-500 text-red-600 fill-red-500"
48481
+ info: "bg-white",
48482
+ success: "bg-white",
48483
+ warn: "bg-white",
48484
+ error: "bg-white"
48133
48485
  };
48134
48486
  const borderClasses = {
48135
- info: "border-blue-200",
48136
- success: "border-green-200",
48137
- warn: "border-yellow-200",
48138
- error: "border-red-200"
48487
+ info: "border-blue-500",
48488
+ success: "border-green-500",
48489
+ warn: "border-amber-500",
48490
+ error: "border-red-500"
48139
48491
  };
48140
48492
  return /* @__PURE__ */ React__default.createElement(
48141
48493
  "div",
48142
48494
  {
48143
- className: `rounded shadow-lg font-normal cursor-pointer pointer-events-all text-sm transition-all duration-100 ease-out mb-4 max-w-full ${colorClasses[level]}}`,
48495
+ className: `rounded-md shadow-lg font-medium cursor-pointer pointer-events-all text-sm transition-all duration-100 ease-out mb-4 max-w-full text-gray-700 ${colorClasses[level]}`,
48144
48496
  style: {
48145
48497
  animationName: "fly-in-up, fade-in",
48146
48498
  animationTimingFunction: "ease-out",
@@ -48152,7 +48504,7 @@ const Alert = ({
48152
48504
  /* @__PURE__ */ React__default.createElement(
48153
48505
  "div",
48154
48506
  {
48155
- className: `flex items-center gap-1.5 w-[350px] rounded-md border p-2 ${borderClasses[level]}`,
48507
+ className: `flex items-center gap-2 w-[350px] rounded-md border px-4 py-3 ${borderClasses[level]}`,
48156
48508
  ...props
48157
48509
  }
48158
48510
  )
@@ -48416,7 +48768,7 @@ const BranchButton = ({ className = "" }) => {
48416
48768
  variant: "secondary",
48417
48769
  size: "custom",
48418
48770
  className: cn(
48419
- "pointer-events-auto px-3 py-3 flex shrink gap-1 items-center justify-between",
48771
+ "pointer-events-auto px-3 py-3 flex shrink gap-1 items-center justify-between max-w-sm",
48420
48772
  className
48421
48773
  ),
48422
48774
  onClick: () => setOpen(true),
@@ -52072,7 +52424,7 @@ const nld = [
52072
52424
  "in",
52073
52425
  "is",
52074
52426
  "ja",
52075
- "je ",
52427
+ "je",
52076
52428
  "kan",
52077
52429
  "kon",
52078
52430
  "kunnen",
@@ -63362,195 +63714,203 @@ var __publicField2 = (obj, key, value) => {
63362
63714
  __defNormalProp2(obj, typeof key !== "symbol" ? key + "" : key, value);
63363
63715
  return value;
63364
63716
  };
63717
+ const INDEXABLE_NODE_TYPES = ["text", "code_block", "html"];
63365
63718
  class StringBuilder {
63366
63719
  constructor(limit) {
63367
- __publicField2(this, "buffer");
63368
- __publicField2(this, "length", 0);
63720
+ __publicField2(this, "buffer", []);
63369
63721
  __publicField2(this, "limit");
63370
- this.buffer = [];
63722
+ __publicField2(this, "length", 0);
63371
63723
  this.limit = limit;
63372
63724
  }
63373
63725
  append(str) {
63374
- if (this.length + str.length > this.limit) {
63726
+ if (this.length + str.length > this.limit)
63375
63727
  return true;
63376
- } else {
63377
- this.buffer.push(str);
63378
- this.length += str.length;
63379
- if (this.length > this.limit) {
63380
- return true;
63381
- }
63382
- return false;
63383
- }
63728
+ this.buffer.push(str);
63729
+ this.length += str.length;
63730
+ return this.length > this.limit;
63384
63731
  }
63385
63732
  toString() {
63386
63733
  return this.buffer.join(" ");
63387
63734
  }
63388
63735
  }
63389
- const extractText = (data, acc, indexableNodeTypes) => {
63390
- var _a2, _b;
63391
- if (data) {
63392
- if (indexableNodeTypes.indexOf(data.type) !== -1 && (data.text || data.value)) {
63393
- const tokens = tokenizeString(data.text || data.value);
63394
- for (const token of tokens) {
63395
- if (acc.append(token)) {
63396
- return;
63397
- }
63398
- }
63736
+ const tokenizeString = (str) => {
63737
+ return str.split(/[\s\.,]+/).map((s2) => s2.toLowerCase()).filter((s2) => s2);
63738
+ };
63739
+ const extractText = (data, builder, nodeTypes) => {
63740
+ var _a2;
63741
+ if (!data)
63742
+ return;
63743
+ if (nodeTypes.includes(data.type ?? "") && (data.text || data.value)) {
63744
+ const tokens = tokenizeString(data.text || data.value || "");
63745
+ for (const token of tokens) {
63746
+ if (builder.append(token))
63747
+ return;
63399
63748
  }
63400
- (_b = (_a2 = data.children) == null ? void 0 : _a2.forEach) == null ? void 0 : _b.call(
63401
- _a2,
63402
- (child) => extractText(child, acc, indexableNodeTypes)
63403
- );
63404
63749
  }
63750
+ (_a2 = data.children) == null ? void 0 : _a2.forEach((child) => extractText(child, builder, nodeTypes));
63405
63751
  };
63406
- const relativePath = (path3, collection) => {
63752
+ const getRelativePath = (path3, collection) => {
63407
63753
  return path3.replace(/\\/g, "/").replace(collection.path, "").replace(/^\/|\/$/g, "");
63408
63754
  };
63409
- const tokenizeString = (str) => {
63410
- return str.split(/[\s\.,]+/).map((s2) => s2.toLowerCase()).filter((s2) => s2);
63411
- };
63412
- const processTextFieldValue = (value, maxLen) => {
63755
+ const processTextField = (value, maxLength) => {
63413
63756
  const tokens = tokenizeString(value);
63414
- const builder = new StringBuilder(maxLen);
63757
+ const builder = new StringBuilder(maxLength);
63415
63758
  for (const part of tokens) {
63416
- if (builder.append(part)) {
63759
+ if (builder.append(part))
63417
63760
  break;
63418
- }
63419
63761
  }
63420
63762
  return builder.toString();
63421
63763
  };
63764
+ const processRichTextField = (value, maxLength) => {
63765
+ const builder = new StringBuilder(maxLength);
63766
+ extractText(value, builder, INDEXABLE_NODE_TYPES);
63767
+ return builder.toString();
63768
+ };
63769
+ const processObjectField = (data, path3, collection, textIndexLength, field) => {
63770
+ if (field.list) {
63771
+ return data.map(
63772
+ (obj) => processDocumentForIndexing(obj, path3, collection, textIndexLength, field)
63773
+ );
63774
+ }
63775
+ return processDocumentForIndexing(
63776
+ data,
63777
+ path3,
63778
+ collection,
63779
+ textIndexLength,
63780
+ field
63781
+ );
63782
+ };
63783
+ const processStringField = (data, maxLength, isList) => {
63784
+ if (isList) {
63785
+ return data.map(
63786
+ (value) => processTextField(value, maxLength)
63787
+ );
63788
+ }
63789
+ return processTextField(data, maxLength);
63790
+ };
63791
+ const processRichTextFieldData = (data, maxLength, isList) => {
63792
+ if (isList) {
63793
+ return data.map(
63794
+ (value) => processRichTextField(value, maxLength)
63795
+ );
63796
+ }
63797
+ return processRichTextField(data, maxLength);
63798
+ };
63422
63799
  const processDocumentForIndexing = (data, path3, collection, textIndexLength, field) => {
63423
63800
  if (!field) {
63424
- const relPath = relativePath(path3, collection);
63425
- data["_id"] = `${collection.name}:${relPath}`;
63426
- data["_relativePath"] = relPath;
63801
+ const relativePath = getRelativePath(path3, collection);
63802
+ data["_id"] = `${collection.name}:${relativePath}`;
63803
+ data["_relativePath"] = relativePath;
63427
63804
  }
63428
- for (const f2 of (field == null ? void 0 : field.fields) || collection.fields || []) {
63805
+ const fields = (field == null ? void 0 : field.fields) || collection.fields || [];
63806
+ for (const f2 of fields) {
63429
63807
  if (!f2.searchable) {
63430
63808
  delete data[f2.name];
63431
63809
  continue;
63432
63810
  }
63433
- const isList = f2.list;
63434
- if (data[f2.name]) {
63435
- if (f2.type === "object") {
63436
- if (isList) {
63437
- data[f2.name] = data[f2.name].map(
63438
- (obj) => processDocumentForIndexing(
63439
- obj,
63440
- path3,
63441
- collection,
63442
- textIndexLength,
63443
- f2
63444
- )
63445
- );
63446
- } else {
63447
- data[f2.name] = processDocumentForIndexing(
63448
- data[f2.name],
63449
- path3,
63450
- collection,
63451
- textIndexLength,
63452
- f2
63453
- );
63454
- }
63455
- } else if (f2.type === "string") {
63456
- const fieldTextIndexLength = f2.maxSearchIndexFieldLength || textIndexLength;
63457
- if (isList) {
63458
- data[f2.name] = data[f2.name].map(
63459
- (value) => processTextFieldValue(value, fieldTextIndexLength)
63460
- );
63461
- } else {
63462
- data[f2.name] = processTextFieldValue(
63463
- data[f2.name],
63464
- fieldTextIndexLength
63465
- );
63466
- }
63467
- } else if (f2.type === "rich-text") {
63468
- const fieldTextIndexLength = f2.maxSearchIndexFieldLength || textIndexLength;
63469
- if (isList) {
63470
- data[f2.name] = data[f2.name].map((value) => {
63471
- const acc = new StringBuilder(fieldTextIndexLength);
63472
- extractText(value, acc, ["text", "code_block", "html"]);
63473
- return acc.toString();
63474
- });
63475
- } else {
63476
- const acc = new StringBuilder(fieldTextIndexLength);
63477
- extractText(data[f2.name], acc, ["text", "code_block", "html"]);
63478
- data[f2.name] = acc.toString();
63479
- }
63480
- }
63811
+ if (!data[f2.name])
63812
+ continue;
63813
+ const fieldMaxLength = f2.maxSearchIndexFieldLength || textIndexLength;
63814
+ const isList = Boolean(f2.list);
63815
+ switch (f2.type) {
63816
+ case "object":
63817
+ data[f2.name] = processObjectField(
63818
+ data[f2.name],
63819
+ path3,
63820
+ collection,
63821
+ textIndexLength,
63822
+ f2
63823
+ );
63824
+ break;
63825
+ case "string":
63826
+ data[f2.name] = processStringField(
63827
+ data[f2.name],
63828
+ fieldMaxLength,
63829
+ isList
63830
+ );
63831
+ break;
63832
+ case "rich-text":
63833
+ data[f2.name] = processRichTextFieldData(
63834
+ data[f2.name],
63835
+ fieldMaxLength,
63836
+ isList
63837
+ );
63838
+ break;
63481
63839
  }
63482
63840
  }
63483
63841
  return data;
63484
63842
  };
63485
- const memo = {};
63843
+ const stopwordCache = {};
63844
+ const PRESERVED_WORDS = ["about"];
63486
63845
  const lookupStopwords = (keys2, defaultStopWords = eng) => {
63487
63846
  let stopwords = defaultStopWords;
63488
63847
  if (keys2) {
63489
- if (memo[keys2.join(",")]) {
63490
- return memo[keys2.join(",")];
63491
- }
63492
- stopwords = [];
63493
- for (const key of keys2) {
63494
- stopwords.push(...sw[key]);
63848
+ const cacheKey = keys2.join(",");
63849
+ if (stopwordCache[cacheKey]) {
63850
+ return stopwordCache[cacheKey];
63495
63851
  }
63496
- memo[keys2.join(",")] = stopwords;
63852
+ stopwords = keys2.flatMap((key) => sw[key] || []);
63853
+ stopwordCache[cacheKey] = stopwords;
63497
63854
  }
63498
- return stopwords;
63855
+ return stopwords.filter((word) => !PRESERVED_WORDS.includes(word));
63499
63856
  };
63500
63857
  const queryToSearchIndexQuery = (query, stopwordLanguages) => {
63501
- let q2;
63502
63858
  const parts = query.split(" ");
63503
63859
  const stopwords = lookupStopwords(stopwordLanguages);
63504
63860
  if (parts.length === 1) {
63505
- q2 = { AND: [parts[0]] };
63506
- } else {
63507
- q2 = {
63508
- AND: parts.filter(
63509
- (part) => part.toLowerCase() !== "and" && stopwords.indexOf(part.toLowerCase()) === -1
63510
- )
63511
- };
63861
+ return { AND: [parts[0]] };
63512
63862
  }
63513
- return q2;
63863
+ const filteredParts = parts.filter(
63864
+ (part) => part.toLowerCase() !== "and" && !stopwords.includes(part.toLowerCase())
63865
+ );
63866
+ return { AND: filteredParts };
63514
63867
  };
63515
63868
  const optionsToSearchIndexOptions = (options) => {
63516
- const opt = {};
63517
- if (options == null ? void 0 : options.limit) {
63518
- opt["PAGE"] = {
63869
+ if (!(options == null ? void 0 : options.limit))
63870
+ return {};
63871
+ return {
63872
+ PAGE: {
63519
63873
  SIZE: options.limit,
63520
- NUMBER: (options == null ? void 0 : options.cursor) ? parseInt(options.cursor) : 0
63521
- };
63522
- }
63523
- return opt;
63874
+ NUMBER: options.cursor ? parseInt(options.cursor) : 0
63875
+ }
63876
+ };
63524
63877
  };
63525
63878
  const parseSearchIndexResponse = (data, options) => {
63526
- const results = data["RESULT"];
63527
- const total = data["RESULT_LENGTH"];
63528
- if ((options == null ? void 0 : options.cursor) && (options == null ? void 0 : options.limit)) {
63529
- const prevCursor = options.cursor === "0" ? null : (parseInt(options.cursor) - 1).toString();
63530
- const nextCursor = total <= (parseInt(options.cursor) + 1) * options.limit ? null : (parseInt(options.cursor) + 1).toString();
63879
+ const resultArray = (data == null ? void 0 : data.RESULT) ?? (data == null ? void 0 : data.results);
63880
+ if (!data || !Array.isArray(resultArray)) {
63531
63881
  return {
63532
- results,
63533
- total,
63534
- prevCursor,
63535
- nextCursor
63536
- };
63537
- } else if (!(options == null ? void 0 : options.cursor) && (options == null ? void 0 : options.limit)) {
63538
- const prevCursor = null;
63539
- const nextCursor = total <= options.limit ? null : "1";
63540
- return {
63541
- results,
63542
- total,
63543
- prevCursor,
63544
- nextCursor
63882
+ results: [],
63883
+ total: 0,
63884
+ prevCursor: null,
63885
+ nextCursor: null,
63886
+ fuzzyMatches: void 0
63545
63887
  };
63546
- } else {
63888
+ }
63889
+ const results = data.RESULT ?? data.results;
63890
+ const total = data.RESULT_LENGTH ?? data.total ?? 0;
63891
+ const fuzzyMatches = data.FUZZY_MATCHES ?? data.fuzzyMatches;
63892
+ const nextCursor = data.NEXT_CURSOR ?? data.nextCursor;
63893
+ const prevCursor = data.PREV_CURSOR ?? data.prevCursor;
63894
+ if (nextCursor !== void 0 || prevCursor !== void 0) {
63547
63895
  return {
63548
63896
  results,
63549
63897
  total,
63550
- prevCursor: null,
63551
- nextCursor: null
63898
+ prevCursor: prevCursor ?? null,
63899
+ nextCursor: nextCursor ?? null,
63900
+ fuzzyMatches
63552
63901
  };
63553
63902
  }
63903
+ const currentPage = (options == null ? void 0 : options.cursor) ? parseInt(options.cursor) : 0;
63904
+ const pageSize = options == null ? void 0 : options.limit;
63905
+ const hasPreviousPage = currentPage > 0;
63906
+ const hasNextPage = pageSize ? total > (currentPage + 1) * pageSize : false;
63907
+ return {
63908
+ results,
63909
+ total,
63910
+ prevCursor: hasPreviousPage ? (currentPage - 1).toString() : null,
63911
+ nextCursor: hasNextPage ? (currentPage + 1).toString() : null,
63912
+ fuzzyMatches
63913
+ };
63554
63914
  };
63555
63915
  const CREATE_DOCUMENT_GQL = `#graphql
63556
63916
  mutation($collection: String!, $relativePath: String!, $params: DocumentMutation!) {
@@ -63606,7 +63966,7 @@ class TinaAdminApi {
63606
63966
  fetchCollections() {
63607
63967
  return this.schema.getCollections();
63608
63968
  }
63609
- async renameDocument({ collection, relativePath: relativePath2, newRelativePath }) {
63969
+ async renameDocument({ collection, relativePath, newRelativePath }) {
63610
63970
  await this.api.request(
63611
63971
  `#graphql
63612
63972
  mutation RenameDocument($collection: String!, $relativePath: String! $newRelativePath: String!) {
@@ -63615,7 +63975,7 @@ class TinaAdminApi {
63615
63975
  }
63616
63976
  }
63617
63977
  `,
63618
- { variables: { collection, relativePath: relativePath2, newRelativePath } }
63978
+ { variables: { collection, relativePath, newRelativePath } }
63619
63979
  );
63620
63980
  if (this.searchClient) {
63621
63981
  const { document: doc } = await this.fetchDocument(
@@ -63629,18 +63989,18 @@ class TinaAdminApi {
63629
63989
  this.maxSearchIndexFieldLength
63630
63990
  );
63631
63991
  await this.searchClient.put([processed]);
63632
- await this.searchClient.del([`${collection.name}:${relativePath2}`]);
63992
+ await this.searchClient.del([`${collection.name}:${relativePath}`]);
63633
63993
  }
63634
63994
  }
63635
63995
  async deleteDocument({
63636
63996
  collection,
63637
- relativePath: relativePath2
63997
+ relativePath
63638
63998
  }) {
63639
63999
  var _a2;
63640
64000
  await this.api.request(DELETE_DOCUMENT_GQL, {
63641
- variables: { collection, relativePath: relativePath2 }
64001
+ variables: { collection, relativePath }
63642
64002
  });
63643
- await ((_a2 = this.searchClient) == null ? void 0 : _a2.del([`${collection}:${relativePath2}`]));
64003
+ await ((_a2 = this.searchClient) == null ? void 0 : _a2.del([`${collection}:${relativePath}`]));
63644
64004
  }
63645
64005
  async fetchCollection(collectionName, includeDocuments, folder = "", after3, sortKey, order, filterArgs) {
63646
64006
  let filter2 = null;
@@ -63795,7 +64155,7 @@ class TinaAdminApi {
63795
64155
  }
63796
64156
  }
63797
64157
  }
63798
- async fetchDocument(collectionName, relativePath2, values = true) {
64158
+ async fetchDocument(collectionName, relativePath, values = true) {
63799
64159
  let query;
63800
64160
  if (values) {
63801
64161
  query = `#graphql
@@ -63830,26 +64190,26 @@ class TinaAdminApi {
63830
64190
  }`;
63831
64191
  }
63832
64192
  const response = await this.api.request(query, {
63833
- variables: { collection: collectionName, relativePath: relativePath2 }
64193
+ variables: { collection: collectionName, relativePath }
63834
64194
  });
63835
64195
  return response;
63836
64196
  }
63837
- async createDocument(collection, relativePath2, params) {
64197
+ async createDocument(collection, relativePath, params) {
63838
64198
  const response = await this.api.request(CREATE_DOCUMENT_GQL, {
63839
64199
  variables: {
63840
64200
  collection: collection.name,
63841
- relativePath: relativePath2,
64201
+ relativePath,
63842
64202
  params
63843
64203
  }
63844
64204
  });
63845
64205
  if (this.searchClient) {
63846
64206
  const { document: doc } = await this.fetchDocument(
63847
64207
  collection.name,
63848
- relativePath2
64208
+ relativePath
63849
64209
  );
63850
64210
  const processed = processDocumentForIndexing(
63851
64211
  doc["_values"],
63852
- `${collection.path}/${relativePath2}`,
64212
+ `${collection.path}/${relativePath}`,
63853
64213
  collection,
63854
64214
  this.maxSearchIndexFieldLength
63855
64215
  );
@@ -63857,22 +64217,22 @@ class TinaAdminApi {
63857
64217
  }
63858
64218
  return response;
63859
64219
  }
63860
- async updateDocument(collection, relativePath2, params) {
64220
+ async updateDocument(collection, relativePath, params) {
63861
64221
  const response = await this.api.request(UPDATE_DOCUMENT_GQL, {
63862
64222
  variables: {
63863
64223
  collection: collection.name,
63864
- relativePath: relativePath2,
64224
+ relativePath,
63865
64225
  params
63866
64226
  }
63867
64227
  });
63868
64228
  if (this.searchClient) {
63869
64229
  const { document: doc } = await this.fetchDocument(
63870
64230
  collection.name,
63871
- relativePath2
64231
+ relativePath
63872
64232
  );
63873
64233
  const processed = processDocumentForIndexing(
63874
64234
  doc["_values"],
63875
- `${collection.path}/${relativePath2}`,
64235
+ `${collection.path}/${relativePath}`,
63876
64236
  collection,
63877
64237
  this.maxSearchIndexFieldLength
63878
64238
  );
@@ -63995,7 +64355,7 @@ const CreateBranchModal = ({
63995
64355
  }
63996
64356
  const collection = tinaApi.schema.getCollectionByFullPath(path3);
63997
64357
  const params = tinaApi.schema.transformPayload(collection.name, values);
63998
- const relativePath2 = pathRelativeToCollection(collection.path, path3);
64358
+ const relativePath = pathRelativeToCollection(collection.path, path3);
63999
64359
  const result = await tinaApi.executeEditorialWorkflow({
64000
64360
  branchName,
64001
64361
  baseBranch: tinaApi.branch,
@@ -64004,7 +64364,7 @@ const CreateBranchModal = ({
64004
64364
  query: graphql2,
64005
64365
  variables: {
64006
64366
  collection: collection.name,
64007
- relativePath: relativePath2,
64367
+ relativePath,
64008
64368
  params
64009
64369
  }
64010
64370
  },
@@ -64035,7 +64395,8 @@ const CreateBranchModal = ({
64035
64395
  `Branch created successfully - Pull Request at ${result.pullRequestUrl}`
64036
64396
  );
64037
64397
  if (crudType === "create") {
64038
- window.location.hash = `#/collections/${collection.name}`;
64398
+ const folderPath = relativePath.includes("/") ? relativePath.substring(0, relativePath.lastIndexOf("/")) : "";
64399
+ window.location.hash = `#/collections/${collection.name}${folderPath ? `/${folderPath}` : ""}`;
64039
64400
  }
64040
64401
  close2();
64041
64402
  } catch (e3) {
@@ -64400,7 +64761,7 @@ const Emoji = ({ className = "", ...props }) => /* @__PURE__ */ React.createElem
64400
64761
  const CreateBranchModel = ({
64401
64762
  close: close2,
64402
64763
  safeSubmit,
64403
- relativePath: relativePath2,
64764
+ relativePath,
64404
64765
  values,
64405
64766
  crudType
64406
64767
  }) => /* @__PURE__ */ React.createElement(
@@ -64408,7 +64769,7 @@ const CreateBranchModel = ({
64408
64769
  {
64409
64770
  close: close2,
64410
64771
  safeSubmit,
64411
- path: relativePath2,
64772
+ path: relativePath,
64412
64773
  values,
64413
64774
  crudType
64414
64775
  }
@@ -67190,6 +67551,23 @@ function LinkFloatingToolbar({
67190
67551
  }) {
67191
67552
  const activeCommentId = usePluginOption({ key: "comment" }, "activeId");
67192
67553
  const activeSuggestionId = usePluginOption({ key: "suggestion" }, "activeId");
67554
+ const { api, editor } = useEditorPlugin(LinkPlugin);
67555
+ const isUrlValidator = usePluginOption(LinkPlugin, "isUrl");
67556
+ const [currentUrl, setCurrentUrl] = React.useState("");
67557
+ const [isValidUrl, setIsValidUrl] = React.useState(true);
67558
+ const handleUrlInput = React.useCallback(
67559
+ (e3) => {
67560
+ const value = e3.currentTarget.value;
67561
+ setCurrentUrl(value);
67562
+ if (value && isUrlValidator) {
67563
+ const valid = isUrlValidator(value);
67564
+ setIsValidUrl(valid);
67565
+ } else {
67566
+ setIsValidUrl(true);
67567
+ }
67568
+ },
67569
+ [isUrlValidator]
67570
+ );
67193
67571
  const floatingOptions = React.useMemo(() => {
67194
67572
  return {
67195
67573
  middleware: [
@@ -67233,22 +67611,70 @@ function LinkFloatingToolbar({
67233
67611
  });
67234
67612
  if (hidden)
67235
67613
  return null;
67236
- const input = /* @__PURE__ */ React.createElement("div", { className: "z-[999999] flex w-[330px] flex-col", ...inputProps }, /* @__PURE__ */ React.createElement("div", { className: "flex items-center" }, /* @__PURE__ */ React.createElement("div", { className: "flex items-center pr-1 pl-2 text-muted-foreground" }, /* @__PURE__ */ React.createElement(Link, { className: "size-4" })), /* @__PURE__ */ React.createElement(
67237
- FloatingLinkUrlInput,
67238
- {
67239
- className: inputVariants(),
67240
- placeholder: "Paste link",
67241
- "data-plate-focus": true
67242
- }
67243
- )), /* @__PURE__ */ React.createElement(Separator, { className: "my-1" }), /* @__PURE__ */ React.createElement("div", { className: "flex items-center" }, /* @__PURE__ */ React.createElement("div", { className: "flex items-center pr-1 pl-2 text-muted-foreground" }, /* @__PURE__ */ React.createElement(Text$2, { className: "size-4" })), /* @__PURE__ */ React.createElement(
67244
- "input",
67614
+ const input = /* @__PURE__ */ React.createElement(
67615
+ "div",
67245
67616
  {
67246
- className: inputVariants(),
67247
- placeholder: "Text to display",
67248
- "data-plate-focus": true,
67249
- ...textInputProps
67250
- }
67251
- )));
67617
+ className: "z-[999999] flex w-[330px] flex-col relative",
67618
+ ...inputProps
67619
+ },
67620
+ !isValidUrl && currentUrl && /* @__PURE__ */ React.createElement("div", { className: "absolute -top-16 left-0 right-0 z-[1000000] mb-2" }, /* @__PURE__ */ React.createElement(
67621
+ "div",
67622
+ {
67623
+ className: "bg-red-50 border border-red-200 rounded-md p-2 shadow-lg",
67624
+ role: "alert",
67625
+ "aria-live": "polite"
67626
+ },
67627
+ /* @__PURE__ */ React.createElement("div", { className: "flex items-center" }, /* @__PURE__ */ React.createElement(CircleX, { className: "size-4 text-red-500 mr-2 flex-shrink-0" }), /* @__PURE__ */ React.createElement("span", { className: "text-sm text-red-700 text-wrap" }, "Invalid URL. Please prefix link with https:// or use a relative path like /about")),
67628
+ /* @__PURE__ */ React.createElement("div", { className: "absolute -bottom-1 left-4 w-2 h-2 bg-red-50 border-r border-b border-red-200 transform rotate-45" })
67629
+ )),
67630
+ /* @__PURE__ */ React.createElement("div", { className: "flex items-center" }, /* @__PURE__ */ React.createElement("div", { className: "flex items-center pr-1 pl-2 text-muted-foreground" }, /* @__PURE__ */ React.createElement(Link, { className: "size-4" })), /* @__PURE__ */ React.createElement(
67631
+ FloatingLinkUrlInput,
67632
+ {
67633
+ className: inputVariants(),
67634
+ placeholder: "Paste link",
67635
+ "data-plate-focus": true,
67636
+ onInput: handleUrlInput
67637
+ }
67638
+ )),
67639
+ /* @__PURE__ */ React.createElement(Separator, { className: "my-1" }),
67640
+ /* @__PURE__ */ React.createElement("div", { className: "flex items-center" }, /* @__PURE__ */ React.createElement("div", { className: "flex items-center pr-1 pl-2 text-muted-foreground" }, /* @__PURE__ */ React.createElement(Text$2, { className: "size-4" })), /* @__PURE__ */ React.createElement(
67641
+ "input",
67642
+ {
67643
+ className: inputVariants(),
67644
+ placeholder: "Text to display",
67645
+ "data-plate-focus": true,
67646
+ ...textInputProps
67647
+ }
67648
+ )),
67649
+ /* @__PURE__ */ React.createElement(Separator, { className: "my-1" }),
67650
+ /* @__PURE__ */ React.createElement("div", { className: "flex items-center justify-end gap-2 px-2 py-1" }, /* @__PURE__ */ React.createElement(
67651
+ "button",
67652
+ {
67653
+ type: "button",
67654
+ className: buttonVariants$2({ size: "sm", variant: "ghost" }),
67655
+ onClick: () => {
67656
+ api.floatingLink.hide();
67657
+ }
67658
+ },
67659
+ "Cancel"
67660
+ ), /* @__PURE__ */ React.createElement(
67661
+ "button",
67662
+ {
67663
+ type: "button",
67664
+ className: buttonVariants$2({
67665
+ size: "sm",
67666
+ variant: "tinaPrimary"
67667
+ }),
67668
+ onClick: () => {
67669
+ if (isValidUrl && currentUrl) {
67670
+ submitFloatingLink(editor);
67671
+ }
67672
+ },
67673
+ disabled: !isValidUrl && !!currentUrl
67674
+ },
67675
+ "OK"
67676
+ ))
67677
+ );
67252
67678
  const editContent = editState.isEditing ? input : /* @__PURE__ */ React.createElement("div", { className: "box-content flex items-center" }, /* @__PURE__ */ React.createElement(
67253
67679
  "button",
67254
67680
  {
@@ -67269,7 +67695,25 @@ function LinkFloatingToolbar({
67269
67695
  },
67270
67696
  /* @__PURE__ */ React.createElement(Unlink, { width: 18 })
67271
67697
  ));
67272
- return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("div", { ref: insertRef, className: popoverVariants(), ...insertProps }, input), /* @__PURE__ */ React.createElement("div", { ref: editRef, className: popoverVariants(), ...editProps }, editContent));
67698
+ return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(
67699
+ "div",
67700
+ {
67701
+ ref: insertRef,
67702
+ className: popoverVariants(),
67703
+ ...insertProps,
67704
+ style: insertProps.style
67705
+ },
67706
+ input
67707
+ ), /* @__PURE__ */ React.createElement(
67708
+ "div",
67709
+ {
67710
+ ref: editRef,
67711
+ className: popoverVariants(),
67712
+ ...editProps,
67713
+ style: editProps.style
67714
+ },
67715
+ editContent
67716
+ ));
67273
67717
  }
67274
67718
  function LinkOpenButton() {
67275
67719
  const editor = useEditorRef();
@@ -119545,19 +119989,36 @@ class LocalClient extends Client {
119545
119989
  }
119546
119990
  class TinaCMSSearchClient {
119547
119991
  constructor(client, tinaSearchConfig) {
119992
+ __publicField(this, "fuzzyEnabled");
119993
+ __publicField(this, "defaultFuzzyOptions");
119548
119994
  this.client = client;
119549
119995
  this.tinaSearchConfig = tinaSearchConfig;
119996
+ this.fuzzyEnabled = (tinaSearchConfig == null ? void 0 : tinaSearchConfig.fuzzyEnabled) !== false;
119997
+ this.defaultFuzzyOptions = tinaSearchConfig == null ? void 0 : tinaSearchConfig.fuzzyOptions;
119550
119998
  }
119551
119999
  async query(query, options) {
119552
120000
  var _a2;
120001
+ const opt = optionsToSearchIndexOptions(options);
120002
+ const optionsParam = opt["PAGE"] ? `&options=${JSON.stringify(opt)}` : "";
119553
120003
  const q2 = queryToSearchIndexQuery(
119554
120004
  query,
119555
120005
  (_a2 = this.tinaSearchConfig) == null ? void 0 : _a2.stopwordLanguages
119556
120006
  );
119557
- const opt = optionsToSearchIndexOptions(options);
119558
- const optionsParam = opt["PAGE"] ? `&options=${JSON.stringify(opt)}` : "";
120007
+ const useFuzzy = (options == null ? void 0 : options.fuzzy) !== void 0 ? options.fuzzy : this.fuzzyEnabled;
120008
+ let fuzzyParam = "";
120009
+ if (useFuzzy) {
120010
+ const mergedFuzzyOptions = {
120011
+ ...this.defaultFuzzyOptions,
120012
+ ...options == null ? void 0 : options.fuzzyOptions
120013
+ };
120014
+ fuzzyParam = `&fuzzy=true&fuzzyOptions=${JSON.stringify(
120015
+ mergedFuzzyOptions
120016
+ )}`;
120017
+ }
119559
120018
  const res = await this.client.authProvider.fetchWithToken(
119560
- `${this.client.contentApiBase}/searchIndex/${this.client.clientId}/${this.client.getBranch()}?q=${JSON.stringify(q2)}${optionsParam}`
120019
+ `${this.client.contentApiBase}/searchIndex/${this.client.clientId}/${this.client.getBranch()}?q=${JSON.stringify(
120020
+ q2
120021
+ )}${optionsParam}${fuzzyParam}`
119561
120022
  );
119562
120023
  return parseSearchIndexResponse(await res.json(), options);
119563
120024
  }
@@ -119592,15 +120053,33 @@ class TinaCMSSearchClient {
119592
120053
  }
119593
120054
  }
119594
120055
  class LocalSearchClient {
119595
- constructor(client) {
120056
+ constructor(client, tinaSearchConfig) {
120057
+ __publicField(this, "fuzzyEnabled");
120058
+ __publicField(this, "defaultFuzzyOptions");
119596
120059
  this.client = client;
120060
+ this.tinaSearchConfig = tinaSearchConfig;
120061
+ this.fuzzyEnabled = (tinaSearchConfig == null ? void 0 : tinaSearchConfig.fuzzyEnabled) !== false;
120062
+ this.defaultFuzzyOptions = tinaSearchConfig == null ? void 0 : tinaSearchConfig.fuzzyOptions;
119597
120063
  }
119598
120064
  async query(query, options) {
119599
120065
  const q2 = queryToSearchIndexQuery(query);
119600
120066
  const opt = optionsToSearchIndexOptions(options);
119601
120067
  const optionsParam = opt["PAGE"] ? `&options=${JSON.stringify(opt)}` : "";
120068
+ const useFuzzy = (options == null ? void 0 : options.fuzzy) !== void 0 ? options.fuzzy : this.fuzzyEnabled;
120069
+ let fuzzyParam = "";
120070
+ if (useFuzzy) {
120071
+ const mergedFuzzyOptions = {
120072
+ ...this.defaultFuzzyOptions,
120073
+ ...options == null ? void 0 : options.fuzzyOptions
120074
+ };
120075
+ fuzzyParam = `&fuzzy=true&fuzzyOptions=${JSON.stringify(
120076
+ mergedFuzzyOptions
120077
+ )}`;
120078
+ }
119602
120079
  const res = await this.client.authProvider.fetchWithToken(
119603
- `http://localhost:4001/searchIndex?q=${JSON.stringify(q2)}${optionsParam}`
120080
+ `http://localhost:4001/searchIndex?q=${JSON.stringify(
120081
+ q2
120082
+ )}${optionsParam}${fuzzyParam}`
119604
120083
  );
119605
120084
  return parseSearchIndexResponse(await res.json(), options);
119606
120085
  }
@@ -119907,19 +120386,22 @@ const TinaCloudProvider = (props) => {
119907
120386
  cms.api.tina.setBranch(currentBranch);
119908
120387
  }
119909
120388
  useEffect(() => {
119910
- var _a3, _b2, _c2, _d, _e, _f;
120389
+ var _a3, _b2, _c2, _d, _e, _f, _g, _h;
119911
120390
  let searchClient;
119912
120391
  if (props.isLocalClient) {
119913
- searchClient = new LocalSearchClient(cms.api.tina);
120392
+ searchClient = new LocalSearchClient(
120393
+ cms.api.tina,
120394
+ (_b2 = (_a3 = props.schema.config) == null ? void 0 : _a3.search) == null ? void 0 : _b2.tina
120395
+ );
119914
120396
  } else {
119915
- const hasTinaSearch = Boolean((_b2 = (_a3 = props.schema.config) == null ? void 0 : _a3.search) == null ? void 0 : _b2.tina);
120397
+ const hasTinaSearch = Boolean((_d = (_c2 = props.schema.config) == null ? void 0 : _c2.search) == null ? void 0 : _d.tina);
119916
120398
  if (hasTinaSearch) {
119917
120399
  searchClient = new TinaCMSSearchClient(
119918
120400
  cms.api.tina,
119919
- (_d = (_c2 = props.schema.config) == null ? void 0 : _c2.search) == null ? void 0 : _d.tina
120401
+ (_f = (_e = props.schema.config) == null ? void 0 : _e.search) == null ? void 0 : _f.tina
119920
120402
  );
119921
120403
  } else {
119922
- searchClient = (_f = (_e = props.schema.config) == null ? void 0 : _e.search) == null ? void 0 : _f.searchClient;
120404
+ searchClient = (_h = (_g = props.schema.config) == null ? void 0 : _g.search) == null ? void 0 : _h.searchClient;
119923
120405
  }
119924
120406
  }
119925
120407
  if (searchClient) {
@@ -120053,18 +120535,18 @@ class ContentCreatorPlugin {
120053
120535
  this.onChange = options.onChange;
120054
120536
  this.initialValues = options.initialValues;
120055
120537
  }
120056
- async onSubmit({ collection, template, relativePath: relativePath2 }, cms) {
120538
+ async onSubmit({ collection, template, relativePath }, cms) {
120057
120539
  try {
120058
120540
  const selectedCollection = this.collections.find(
120059
120541
  (collectionItem) => collectionItem.slug === collection
120060
120542
  );
120061
120543
  const collectionFormat = selectedCollection.format;
120062
120544
  const extensionLength = -1 * (collectionFormat.length + 1);
120063
- let relativePathWithExt = relativePath2;
120064
- if (relativePath2.slice(extensionLength).toLocaleLowerCase() === `.${collectionFormat}`) {
120065
- relativePathWithExt = `${relativePath2.slice(0, -3)}.${collectionFormat}`;
120545
+ let relativePathWithExt = relativePath;
120546
+ if (relativePath.slice(extensionLength).toLocaleLowerCase() === `.${collectionFormat}`) {
120547
+ relativePathWithExt = `${relativePath.slice(0, -3)}.${collectionFormat}`;
120066
120548
  } else {
120067
- relativePathWithExt = `${relativePath2}.${collectionFormat}`;
120549
+ relativePathWithExt = `${relativePath}.${collectionFormat}`;
120068
120550
  }
120069
120551
  const payload = {
120070
120552
  relativePath: relativePathWithExt,
@@ -120793,22 +121275,6 @@ const PageHeader = ({
120793
121275
  return /* @__PURE__ */ React__default.createElement("div", { className: "pt-4 pb-2 px-6" }, /* @__PURE__ */ React__default.createElement("div", { className: "w-full flex justify-between items-end" }, children));
120794
121276
  };
120795
121277
  const PageBody = ({ children }) => /* @__PURE__ */ React__default.createElement("div", { className: "py-4 px-6" }, children);
120796
- const TooltipProvider = TooltipPrimitive.Provider;
120797
- const Tooltip = TooltipPrimitive.Root;
120798
- const TooltipTrigger = TooltipPrimitive.Trigger;
120799
- const TooltipContent = React.forwardRef(({ className, sideOffset = 4, ...props }, ref) => /* @__PURE__ */ React.createElement(TooltipPrimitive.Portal, null, /* @__PURE__ */ React.createElement(
120800
- TooltipPrimitive.Content,
120801
- {
120802
- ref,
120803
- sideOffset,
120804
- className: cn$1(
120805
- "z-[10000] overflow-hidden rounded bg-[#FFF] px-3 py-1.5 text-xs text-[#504E5E] shadow-sm animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 origin-[--radix-tooltip-content-transform-origin]",
120806
- className
120807
- ),
120808
- ...props
120809
- }
120810
- )));
120811
- TooltipContent.displayName = TooltipPrimitive.Content.displayName;
120812
121278
  const folderRegex = /^.*\/~\/*(.*)$/;
120813
121279
  const parentFolder = (folder) => {
120814
121280
  return {
@@ -120981,6 +121447,10 @@ const CollectionListPage = () => {
120981
121447
  booleanEquals: null
120982
121448
  }));
120983
121449
  }, [collectionName]);
121450
+ useEffect(() => {
121451
+ setEndCursor("");
121452
+ setPrevCursors([]);
121453
+ }, [search]);
120984
121454
  const tableRowStyle = "hover:bg-gray-50/50 border-b-2 border-gray-50 transition-colors duration-300";
120985
121455
  const tableHeadingCellStyle = "px-3 py-3 text-left text-xs font-bold text-gray-700 tracking-wider";
120986
121456
  const tableHeadingStyle2 = "bg-gray-100 border-b-2 border-gray-200";
@@ -121240,6 +121710,8 @@ const CollectionListPage = () => {
121240
121710
  ))), /* @__PURE__ */ React__default.createElement("div", { className: "flex flex-1 flex-row gap-2 items-end w-full" }, searchEnabled ? /* @__PURE__ */ React__default.createElement(
121241
121711
  SearchInput,
121242
121712
  {
121713
+ cms,
121714
+ collectionName,
121243
121715
  loading: _loading,
121244
121716
  search,
121245
121717
  setSearch,
@@ -121572,33 +122044,31 @@ const SearchInput = ({
121572
122044
  setSearchInput
121573
122045
  }) => {
121574
122046
  const [searchLoaded, setSearchLoaded] = useState(false);
122047
+ const inputRef = React__default.useRef(null);
121575
122048
  useEffect(() => {
121576
- if (loading) {
121577
- setSearchLoaded(false);
121578
- } else {
121579
- setSearchLoaded(true);
121580
- }
122049
+ setSearchLoaded(!loading);
121581
122050
  }, [loading]);
121582
- return /* @__PURE__ */ React__default.createElement("form", { className: "flex flex-1 flex-col gap-2 items-start w-full" }, /* @__PURE__ */ React__default.createElement("div", { className: "h-4" }), /* @__PURE__ */ React__default.createElement("div", { className: "flex flex-col md:flex-row items-start md:items-center w-full md:w-auto gap-3" }, /* @__PURE__ */ React__default.createElement("div", { className: "flex-1 min-w-[200px] w-full md:w-auto relative" }, /* @__PURE__ */ React__default.createElement(BiSearch, { className: "absolute left-3 top-1/2 -translate-y-1/2 w-5 h-5 text-gray-400 pointer-events-none" }), /* @__PURE__ */ React__default.createElement(
122051
+ const handleKeyDown = (e3) => {
122052
+ if (e3.key === "Enter") {
122053
+ e3.preventDefault();
122054
+ if (searchInput.trim()) {
122055
+ setSearch(searchInput);
122056
+ setSearchLoaded(false);
122057
+ }
122058
+ }
122059
+ };
122060
+ return /* @__PURE__ */ React__default.createElement("form", { className: "flex flex-1 flex-col gap-2 items-start w-full" }, /* @__PURE__ */ React__default.createElement("div", { className: "h-4" }), /* @__PURE__ */ React__default.createElement("div", { className: "flex flex-col md:flex-row items-start md:items-center w-full md:w-auto gap-3" }, /* @__PURE__ */ React__default.createElement("div", { className: "flex-1 min-w-[200px] w-full md:w-auto relative" }, /* @__PURE__ */ React__default.createElement(BiSearch, { className: "absolute left-3 top-1/2 -translate-y-1/2 w-5 h-5 text-gray-400 pointer-events-none z-10" }), /* @__PURE__ */ React__default.createElement(
121583
122061
  "input",
121584
122062
  {
122063
+ ref: inputRef,
121585
122064
  type: "text",
121586
122065
  name: "search",
121587
122066
  placeholder: "Search...",
121588
122067
  value: searchInput,
121589
- onChange: (e3) => {
121590
- setSearchInput(e3.target.value);
121591
- },
121592
- onKeyDown: (e3) => {
121593
- if (e3.key === "Enter") {
121594
- e3.preventDefault();
121595
- if (searchInput.trim()) {
121596
- setSearch(searchInput);
121597
- setSearchLoaded(false);
121598
- }
121599
- }
121600
- },
121601
- className: "shadow appearance-none bg-white block pl-10 pr-10 py-2 truncate w-full text-base border border-gray-200 focus:outline-none focus:shadow-outline focus:ring-blue-500 focus:border-blue-500 sm:text-sm rounded placeholder:text-gray-300 text-gray-600 focus:text-gray-900"
122068
+ onChange: (e3) => setSearchInput(e3.target.value),
122069
+ onKeyDown: handleKeyDown,
122070
+ className: "shadow appearance-none bg-white block pl-10 pr-10 py-2 truncate w-full text-base border border-gray-200 focus:outline-none focus:shadow-outline focus:ring-blue-500 focus:border-blue-500 sm:text-sm rounded placeholder:text-gray-300 text-gray-600 focus:text-gray-900",
122071
+ autoComplete: "off"
121602
122072
  }
121603
122073
  ), search && searchLoaded && /* @__PURE__ */ React__default.createElement(
121604
122074
  "button",
@@ -121608,7 +122078,7 @@ const SearchInput = ({
121608
122078
  setSearch("");
121609
122079
  setSearchInput("");
121610
122080
  },
121611
- className: "absolute right-3 top-1/2 -translate-y-1/2 text-gray-400 hover:text-gray-600 transition-colors"
122081
+ className: "absolute right-3 top-1/2 -translate-y-1/2 text-gray-400 hover:text-gray-600 transition-colors z-10"
121612
122082
  },
121613
122083
  /* @__PURE__ */ React__default.createElement(BiX, { className: "w-5 h-5" })
121614
122084
  ))));
@@ -121883,13 +122353,15 @@ const useSearchCollection = (cms, collectionName, includeDocuments = true, folde
121883
122353
  `${search} AND _collection:${collectionName}`,
121884
122354
  {
121885
122355
  limit: 15,
121886
- cursor: after3
122356
+ cursor: after3,
122357
+ fuzzy: true
121887
122358
  }
121888
122359
  );
122360
+ const results = (response == null ? void 0 : response.results) ?? [];
121889
122361
  const docs = await Promise.allSettled(
121890
- response.results.map((result) => {
121891
- const [collection2, relativePath2] = result._id.split(":");
121892
- return api.fetchDocument(collection2, relativePath2, false);
122362
+ results.map((result) => {
122363
+ const [collection2, relativePath] = result._id.split(":");
122364
+ return api.fetchDocument(collection2, relativePath, false);
121893
122365
  })
121894
122366
  );
121895
122367
  const edges2 = docs.filter((p2) => {
@@ -121897,21 +122369,22 @@ const useSearchCollection = (cms, collectionName, includeDocuments = true, folde
121897
122369
  return p2.status === "fulfilled" && !!((_a2 = p2.value) == null ? void 0 : _a2.document);
121898
122370
  }).map((result) => ({ node: result.value.document }));
121899
122371
  const c2 = await api.fetchCollection(collectionName, false, "");
121900
- setCollection({
121901
- format: collection.format,
121902
- label: collection.label,
122372
+ const collectionData = {
122373
+ format: c2.format,
122374
+ label: c2.label,
121903
122375
  name: collectionName,
121904
- templates: collection.templates,
122376
+ templates: c2.templates,
121905
122377
  documents: {
121906
122378
  pageInfo: {
121907
- hasNextPage: !!response.nextCursor,
121908
- hasPreviousPage: !!response.prevCursor,
122379
+ hasNextPage: !!(response == null ? void 0 : response.nextCursor),
122380
+ hasPreviousPage: !!(response == null ? void 0 : response.prevCursor),
121909
122381
  startCursor: "",
121910
- endCursor: response.nextCursor || ""
122382
+ endCursor: (response == null ? void 0 : response.nextCursor) || ""
121911
122383
  },
121912
122384
  edges: edges2
121913
122385
  }
121914
- });
122386
+ };
122387
+ setCollection(collectionData);
121915
122388
  } catch (error22) {
121916
122389
  cms.alerts.error(
121917
122390
  `[${error22.name}] GetCollection failed: ${error22.message}`
@@ -122014,14 +122487,14 @@ const createDocument = async (cms, collection, template, mutationInfo, folder, v
122014
122487
  throw new Error("Filename must be a string");
122015
122488
  }
122016
122489
  const appendFolder = folder && !filename.startsWith("/") ? `/${folder}/` : "/";
122017
- const relativePath2 = `${appendFolder}${filename}.${collection.format}`;
122490
+ const relativePath = `${appendFolder}${filename}.${collection.format}`;
122018
122491
  const params = api.schema.transformPayload(collection.name, {
122019
122492
  _collection: collection.name,
122020
122493
  ...template && { _template: template.name },
122021
122494
  ...leftover
122022
122495
  });
122023
122496
  if (await api.isAuthenticated()) {
122024
- await api.createDocument(collection, relativePath2, params);
122497
+ await api.createDocument(collection, relativePath, params);
122025
122498
  } else {
122026
122499
  const authMessage = `CreateDocument failed: User is no longer authenticated; please login and try again.`;
122027
122500
  cms.alerts.error(authMessage);
@@ -122271,7 +122744,7 @@ const RenderForm$1 = ({
122271
122744
  ), /* @__PURE__ */ React__default.createElement(FormStatus, { pristine: formIsPristine }))
122272
122745
  ), activeForm && /* @__PURE__ */ React__default.createElement(FormBuilder, { form: activeForm, onPristineChange: setFormIsPristine })));
122273
122746
  };
122274
- const useGetDocument = (cms, collectionName, relativePath2) => {
122747
+ const useGetDocument = (cms, collectionName, relativePath) => {
122275
122748
  const api = new TinaAdminApi(cms);
122276
122749
  const [document2, setDocument] = useState(void 0);
122277
122750
  const [loading, setLoading] = useState(true);
@@ -122283,7 +122756,7 @@ const useGetDocument = (cms, collectionName, relativePath2) => {
122283
122756
  try {
122284
122757
  const response = await api.fetchDocument(
122285
122758
  collectionName,
122286
- relativePath2
122759
+ relativePath
122287
122760
  );
122288
122761
  if (!isCancelled) {
122289
122762
  setDocument(response.document);
@@ -122308,19 +122781,19 @@ const useGetDocument = (cms, collectionName, relativePath2) => {
122308
122781
  return () => {
122309
122782
  isCancelled = true;
122310
122783
  };
122311
- }, [cms, collectionName, relativePath2]);
122784
+ }, [cms, collectionName, relativePath]);
122312
122785
  return { document: document2, loading, error: error2 };
122313
122786
  };
122314
122787
  const GetDocument = ({
122315
122788
  cms,
122316
122789
  collectionName,
122317
- relativePath: relativePath2,
122790
+ relativePath,
122318
122791
  children
122319
122792
  }) => {
122320
122793
  const { document: document2, loading, error: error2 } = useGetDocument(
122321
122794
  cms,
122322
122795
  collectionName,
122323
- relativePath2
122796
+ relativePath
122324
122797
  );
122325
122798
  if (error2) {
122326
122799
  return /* @__PURE__ */ React__default.createElement(FullscreenError, null);
@@ -122343,7 +122816,7 @@ const CollectionDuplicatePage = () => {
122343
122816
  includeDocuments: false
122344
122817
  },
122345
122818
  (collection) => {
122346
- const relativePath2 = `${filename.startsWith("~/") ? filename.substring(2) : filename}.${collection.format}`;
122819
+ const relativePath = `${filename.startsWith("~/") ? filename.substring(2) : filename}.${collection.format}`;
122347
122820
  const mutationInfo = {
122348
122821
  includeCollection: true,
122349
122822
  includeTemplate: !!collection.templates
@@ -122353,7 +122826,7 @@ const CollectionDuplicatePage = () => {
122353
122826
  {
122354
122827
  cms,
122355
122828
  collectionName: collection.name,
122356
- relativePath: relativePath2
122829
+ relativePath
122357
122830
  },
122358
122831
  (document2) => {
122359
122832
  var _a2;
@@ -122373,11 +122846,11 @@ const CollectionDuplicatePage = () => {
122373
122846
  }
122374
122847
  ));
122375
122848
  };
122376
- const updateDocument = async (cms, relativePath2, collection, mutationInfo, values) => {
122849
+ const updateDocument = async (cms, relativePath, collection, mutationInfo, values) => {
122377
122850
  const api = new TinaAdminApi(cms);
122378
122851
  const params = api.schema.transformPayload(collection.name, values);
122379
122852
  if (await api.isAuthenticated()) {
122380
- await api.updateDocument(collection, relativePath2, params);
122853
+ await api.updateDocument(collection, relativePath, params);
122381
122854
  } else {
122382
122855
  const authMessage = `UpdateDocument failed: User is no longer authenticated; please login and try again.`;
122383
122856
  cms.alerts.error(authMessage);
@@ -122399,7 +122872,7 @@ const CollectionUpdatePage = () => {
122399
122872
  includeDocuments: false
122400
122873
  },
122401
122874
  (collection) => {
122402
- const relativePath2 = `${resolvedFile}.${collection.format}`;
122875
+ const relativePath = `${resolvedFile}.${collection.format}`;
122403
122876
  const mutationInfo = {
122404
122877
  includeCollection: true,
122405
122878
  includeTemplate: !!collection.templates
@@ -122409,7 +122882,7 @@ const CollectionUpdatePage = () => {
122409
122882
  {
122410
122883
  cms,
122411
122884
  collectionName: collection.name,
122412
- relativePath: relativePath2
122885
+ relativePath
122413
122886
  },
122414
122887
  (document2) => /* @__PURE__ */ React__default.createElement(
122415
122888
  RenderForm,
@@ -122417,7 +122890,7 @@ const CollectionUpdatePage = () => {
122417
122890
  cms,
122418
122891
  document: document2,
122419
122892
  filename: resolvedFile,
122420
- relativePath: relativePath2,
122893
+ relativePath,
122421
122894
  collection,
122422
122895
  mutationInfo
122423
122896
  }
@@ -122430,10 +122903,11 @@ const RenderForm = ({
122430
122903
  cms,
122431
122904
  document: document2,
122432
122905
  filename,
122433
- relativePath: relativePath2,
122906
+ relativePath,
122434
122907
  collection,
122435
122908
  mutationInfo
122436
122909
  }) => {
122910
+ var _a2, _b, _c, _d;
122437
122911
  const [formIsPristine, setFormIsPristine] = useState(true);
122438
122912
  const schema = cms.api.tina.schema;
122439
122913
  const schemaCollection = schema.getCollection(collection.name);
@@ -122450,7 +122924,7 @@ const RenderForm = ({
122450
122924
  const form = useMemo(() => {
122451
122925
  return new Form({
122452
122926
  // id is the full document path
122453
- id: canonicalPath(`${schemaCollection.path}/${relativePath2}`),
122927
+ id: canonicalPath(`${schemaCollection.path}/${relativePath}`),
122454
122928
  label: "form",
122455
122929
  fields: formInfo.fields,
122456
122930
  initialValues: document2._values,
@@ -122458,7 +122932,7 @@ const RenderForm = ({
122458
122932
  try {
122459
122933
  await updateDocument(
122460
122934
  cms,
122461
- relativePath2,
122935
+ relativePath,
122462
122936
  collection,
122463
122937
  mutationInfo,
122464
122938
  values
@@ -122479,7 +122953,7 @@ const RenderForm = ({
122479
122953
  }
122480
122954
  }
122481
122955
  });
122482
- }, [cms, document2, relativePath2, collection, mutationInfo]);
122956
+ }, [cms, document2, relativePath, collection, mutationInfo]);
122483
122957
  React__default.useEffect(() => {
122484
122958
  cms.dispatch({ type: "forms:add", value: form });
122485
122959
  cms.dispatch({ type: "forms:set-active-form-id", value: form.id });
@@ -122505,6 +122979,15 @@ const RenderForm = ({
122505
122979
  className: "w-[calc(100%-3rem)]",
122506
122980
  rootBreadcrumbName: `${filename}.${collection.format}`
122507
122981
  }
122982
+ ), /* @__PURE__ */ React__default.createElement(
122983
+ FileHistoryProvider,
122984
+ {
122985
+ defaultBranchName: (_a2 = cms.api.admin.api.schema.config.config.repoProvider) == null ? void 0 : _a2.defaultBranchName,
122986
+ historyUrl: (_b = cms.api.admin.api.schema.config.config.repoProvider) == null ? void 0 : _b.historyUrl,
122987
+ contentRelativePath: relativePath,
122988
+ tinaBranch: cms.api.admin.api.branch,
122989
+ isLocalMode: (_d = (_c = cms.api) == null ? void 0 : _c.tina) == null ? void 0 : _d.isLocalMode
122990
+ }
122508
122991
  ), /* @__PURE__ */ React__default.createElement(FormStatus, { pristine: formIsPristine }))
122509
122992
  ), activeForm && /* @__PURE__ */ React__default.createElement(FormBuilder, { form: activeForm, onPristineChange: setFormIsPristine }));
122510
122993
  };