tinacms 0.0.0-ac2003f-20241101002635 → 0.0.0-ad9a889-20250218035304

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
@@ -862,13 +862,23 @@ var __publicField = (obj, key, value) => {
862
862
  className,
863
863
  ...props
864
864
  }) => {
865
+ if (typeof children === "string") {
866
+ return /* @__PURE__ */ React__namespace.createElement(
867
+ "span",
868
+ {
869
+ className: `block font-sans text-xs italic font-light text-gray-400 pt-0.5 whitespace-normal m-0 ${className}`,
870
+ ...props,
871
+ dangerouslySetInnerHTML: { __html: children }
872
+ }
873
+ );
874
+ }
865
875
  return /* @__PURE__ */ React__namespace.createElement(
866
876
  "span",
867
877
  {
868
878
  className: `block font-sans text-xs italic font-light text-gray-400 pt-0.5 whitespace-normal m-0 ${className}`,
869
- ...props,
870
- dangerouslySetInnerHTML: { __html: children }
871
- }
879
+ ...props
880
+ },
881
+ children
872
882
  );
873
883
  };
874
884
  const FieldError = ({
@@ -3820,7 +3830,7 @@ flowchart TD
3820
3830
  function _objectWithoutProperties(source, excluded) {
3821
3831
  if (source == null)
3822
3832
  return {};
3823
- var target = _objectWithoutPropertiesLoose$1(source, excluded);
3833
+ var target = _objectWithoutPropertiesLoose(source, excluded);
3824
3834
  var key, i;
3825
3835
  if (Object.getOwnPropertySymbols) {
3826
3836
  var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
@@ -3835,7 +3845,7 @@ flowchart TD
3835
3845
  }
3836
3846
  return target;
3837
3847
  }
3838
- function _objectWithoutPropertiesLoose$1(source, excluded) {
3848
+ function _objectWithoutPropertiesLoose(source, excluded) {
3839
3849
  if (source == null)
3840
3850
  return {};
3841
3851
  var target = {};
@@ -4925,7 +4935,28 @@ flowchart TD
4925
4935
  onChange,
4926
4936
  value,
4927
4937
  step
4928
- }) => /* @__PURE__ */ React__namespace.createElement(Input, { type: "number", step, value, onChange });
4938
+ }) => /* @__PURE__ */ React__namespace.createElement(
4939
+ Input,
4940
+ {
4941
+ type: "number",
4942
+ step,
4943
+ value,
4944
+ onChange: (event) => {
4945
+ const inputValue = event.target.value;
4946
+ const newValue = inputValue === "" ? void 0 : inputValue;
4947
+ if (onChange) {
4948
+ const syntheticEvent = {
4949
+ ...event,
4950
+ target: {
4951
+ ...event.target,
4952
+ value: newValue
4953
+ }
4954
+ };
4955
+ onChange(syntheticEvent);
4956
+ }
4957
+ }
4958
+ }
4959
+ );
4929
4960
  function useCMS() {
4930
4961
  return useCMS$1();
4931
4962
  }
@@ -5166,7 +5197,7 @@ flowchart TD
5166
5197
  side: "bottom",
5167
5198
  className: cn(
5168
5199
  "rounded-md border bg-white p-4 text-popover-foreground shadow-md outline-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-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",
5169
- "max-h-[30vh] max-w-[30vh] overflow-y-auto",
5200
+ "max-h-[30vh] max-w-[30vw] overflow-y-auto",
5170
5201
  className
5171
5202
  ),
5172
5203
  ...props
@@ -5258,11 +5289,7 @@ flowchart TD
5258
5289
  const node = nodes.find((node2) => node2.id === value);
5259
5290
  return node ? node._internalSys.filename : null;
5260
5291
  };
5261
- const ComboboxDemo = ({
5262
- cms,
5263
- input,
5264
- field
5265
- }) => {
5292
+ const Combobox = ({ cms, input, field }) => {
5266
5293
  const [open2, setOpen] = React__namespace.useState(false);
5267
5294
  const [value, setValue] = React__namespace.useState(input.value);
5268
5295
  const [displayText, setDisplayText] = React__namespace.useState(null);
@@ -5286,17 +5313,17 @@ flowchart TD
5286
5313
  if (loading === true) {
5287
5314
  return /* @__PURE__ */ React__namespace.createElement(LoadingDots, { color: "var(--tina-color-primary)" });
5288
5315
  }
5289
- return /* @__PURE__ */ React__namespace.createElement(React__namespace.Fragment, null, /* @__PURE__ */ React__namespace.createElement(Popover, { open: open2, onOpenChange: setOpen }, /* @__PURE__ */ React__namespace.createElement(PopoverTrigger, { asChild: true }, /* @__PURE__ */ React__namespace.createElement(
5316
+ return /* @__PURE__ */ React__namespace.createElement(Popover, { open: open2, onOpenChange: setOpen }, /* @__PURE__ */ React__namespace.createElement(PopoverTrigger, { asChild: true }, /* @__PURE__ */ React__namespace.createElement(
5290
5317
  Button,
5291
5318
  {
5292
5319
  variant: "outline",
5293
5320
  role: "combobox",
5294
5321
  "aria-expanded": open2,
5295
- className: "w-52 justify-between"
5322
+ className: "w-full justify-between"
5296
5323
  },
5297
5324
  /* @__PURE__ */ React__namespace.createElement("p", { className: "truncate" }, displayText ?? "Choose an option..."),
5298
5325
  open2 ? /* @__PURE__ */ React__namespace.createElement(IoMdArrowDropup, { size: 20 }) : /* @__PURE__ */ React__namespace.createElement(IoMdArrowDropdown, { size: 20 })
5299
- )), /* @__PURE__ */ React__namespace.createElement(PopoverContent, { className: "p-0 relative" }, /* @__PURE__ */ React__namespace.createElement(
5326
+ )), /* @__PURE__ */ React__namespace.createElement(PopoverContent, { className: "p-0 relative min-w-[var(--radix-popover-trigger-width)]" }, /* @__PURE__ */ React__namespace.createElement(
5300
5327
  Command,
5301
5328
  {
5302
5329
  shouldFilter: !field.experimental___filter,
@@ -5320,32 +5347,25 @@ flowchart TD
5320
5347
  }
5321
5348
  ),
5322
5349
  /* @__PURE__ */ React__namespace.createElement(CommandEmpty, null, "No reference found"),
5323
- /* @__PURE__ */ React__namespace.createElement(CommandList, null, filteredOptionsList.length > 0 && (filteredOptionsList == null ? void 0 : filteredOptionsList.map(({ collection, edges }) => /* @__PURE__ */ React__namespace.createElement(
5324
- CommandGroup,
5325
- {
5326
- key: `${collection}-group`,
5327
- heading: collection
5328
- },
5329
- /* @__PURE__ */ React__namespace.createElement(CommandList, null, edges == null ? void 0 : edges.map(({ node }) => {
5330
- const { id, _values } = node;
5331
- return /* @__PURE__ */ React__namespace.createElement(
5332
- OptionComponent,
5333
- {
5334
- id,
5335
- key: id,
5336
- value,
5337
- field,
5338
- _values,
5339
- node,
5340
- onSelect: (currentValue) => {
5341
- setValue(currentValue);
5342
- setOpen(false);
5343
- }
5350
+ /* @__PURE__ */ React__namespace.createElement(CommandList, null, filteredOptionsList.length > 0 && (filteredOptionsList == null ? void 0 : filteredOptionsList.map(({ collection, edges }) => /* @__PURE__ */ React__namespace.createElement(CommandGroup, { key: `${collection}-group`, heading: collection }, /* @__PURE__ */ React__namespace.createElement(CommandList, null, edges == null ? void 0 : edges.map(({ node }) => {
5351
+ const { id, _values } = node;
5352
+ return /* @__PURE__ */ React__namespace.createElement(
5353
+ OptionComponent,
5354
+ {
5355
+ id,
5356
+ key: id,
5357
+ value,
5358
+ field,
5359
+ _values,
5360
+ node,
5361
+ onSelect: (currentValue) => {
5362
+ setValue(currentValue);
5363
+ setOpen(false);
5344
5364
  }
5345
- );
5346
- }))
5347
- ))))
5348
- ))));
5365
+ }
5366
+ );
5367
+ }))))))
5368
+ )));
5349
5369
  };
5350
5370
  const useGetNode = (cms, id) => {
5351
5371
  const [document2, setDocument] = React__namespace.useState(
@@ -5418,7 +5438,7 @@ flowchart TD
5418
5438
  };
5419
5439
  const Reference = ({ input, field }) => {
5420
5440
  const cms = useCMS();
5421
- return /* @__PURE__ */ React__namespace.createElement("div", null, /* @__PURE__ */ React__namespace.createElement("div", { className: "relative group" }, /* @__PURE__ */ React__namespace.createElement(ComboboxDemo, { cms, input, field })), /* @__PURE__ */ React__namespace.createElement(ReferenceLink, { cms, input }));
5441
+ return /* @__PURE__ */ React__namespace.createElement(React__namespace.Fragment, null, /* @__PURE__ */ React__namespace.createElement("div", { className: "relative group" }, /* @__PURE__ */ React__namespace.createElement(Combobox, { cms, input, field })), /* @__PURE__ */ React__namespace.createElement(ReferenceLink, { cms, input }));
5422
5442
  };
5423
5443
  const ButtonToggle = ({
5424
5444
  input,
@@ -5726,10 +5746,11 @@ flowchart TD
5726
5746
  return /* @__PURE__ */ React.createElement(
5727
5747
  "button",
5728
5748
  {
5729
- className: `w-8 px-1 py-2.5 flex items-center justify-center hover:bg-gray-50 text-gray-200 hover:text-red-500 ${disabled && "pointer-events-none opacity-30 cursor-not-allowed"}`,
5749
+ type: "button",
5750
+ className: `w-8 px-1 py-2.5 flex items-center justify-center text-gray-200 hover:opacity-100 opacity-30 hover:bg-gray-50 ${disabled && "pointer-events-none opacity-30 cursor-not-allowed"}`,
5730
5751
  onClick
5731
5752
  },
5732
- /* @__PURE__ */ React.createElement(TrashIcon, { className: "fill-current transition-colors ease-out duration-100" })
5753
+ /* @__PURE__ */ React.createElement(TrashIcon, { className: "h-5 w-auto fill-current text-red-500 transition-colors duration-150 ease-out" })
5733
5754
  );
5734
5755
  };
5735
5756
  const DragHandle = ({ isDragging }) => {
@@ -7177,244 +7198,65 @@ flowchart TD
7177
7198
  str = "0" + str;
7178
7199
  return str;
7179
7200
  }
7180
- function _inheritsLoose(subClass, superClass) {
7181
- subClass.prototype = Object.create(superClass.prototype);
7182
- subClass.prototype.constructor = subClass;
7183
- _setPrototypeOf(subClass, superClass);
7184
- }
7185
- function _setPrototypeOf(o, p) {
7186
- _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf2(o2, p2) {
7187
- o2.__proto__ = p2;
7188
- return o2;
7189
- };
7190
- return _setPrototypeOf(o, p);
7191
- }
7192
- function _objectWithoutPropertiesLoose(source, excluded) {
7193
- if (source == null)
7194
- return {};
7195
- var target = {};
7196
- var sourceKeys = Object.keys(source);
7197
- var key, i;
7198
- for (i = 0; i < sourceKeys.length; i++) {
7199
- key = sourceKeys[i];
7200
- if (excluded.indexOf(key) >= 0)
7201
- continue;
7202
- target[key] = source[key];
7203
- }
7204
- return target;
7205
- }
7206
- function _assertThisInitialized(self2) {
7207
- if (self2 === void 0) {
7208
- throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
7209
- }
7210
- return self2;
7211
- }
7212
- function isNodeFound(current, componentNode, ignoreClass) {
7213
- if (current === componentNode) {
7214
- return true;
7201
+ var useClickAway$1 = {};
7202
+ var util = {};
7203
+ Object.defineProperty(util, "__esModule", { value: true });
7204
+ util.isNavigator = util.isBrowser = util.off = util.on = util.noop = void 0;
7205
+ var noop = function() {
7206
+ };
7207
+ util.noop = noop;
7208
+ function on(obj) {
7209
+ var args = [];
7210
+ for (var _i = 1; _i < arguments.length; _i++) {
7211
+ args[_i - 1] = arguments[_i];
7215
7212
  }
7216
- if (current.correspondingElement) {
7217
- return current.correspondingElement.classList.contains(ignoreClass);
7213
+ if (obj && obj.addEventListener) {
7214
+ obj.addEventListener.apply(obj, args);
7218
7215
  }
7219
- return current.classList.contains(ignoreClass);
7220
7216
  }
7221
- function findHighest(current, componentNode, ignoreClass) {
7222
- if (current === componentNode) {
7223
- return true;
7224
- }
7225
- while (current.parentNode || current.host) {
7226
- if (current.parentNode && isNodeFound(current, componentNode, ignoreClass)) {
7227
- return true;
7228
- }
7229
- current = current.parentNode || current.host;
7217
+ util.on = on;
7218
+ function off(obj) {
7219
+ var args = [];
7220
+ for (var _i = 1; _i < arguments.length; _i++) {
7221
+ args[_i - 1] = arguments[_i];
7230
7222
  }
7231
- return current;
7232
- }
7233
- function clickedScrollbar(evt) {
7234
- return document.documentElement.clientWidth <= evt.clientX || document.documentElement.clientHeight <= evt.clientY;
7235
- }
7236
- var testPassiveEventSupport = function testPassiveEventSupport2() {
7237
- if (typeof window === "undefined" || typeof window.addEventListener !== "function") {
7238
- return;
7239
- }
7240
- var passive = false;
7241
- var options = Object.defineProperty({}, "passive", {
7242
- get: function get2() {
7243
- passive = true;
7244
- }
7245
- });
7246
- var noop = function noop2() {
7247
- };
7248
- window.addEventListener("testPassiveEventSupport", noop, options);
7249
- window.removeEventListener("testPassiveEventSupport", noop, options);
7250
- return passive;
7251
- };
7252
- function autoInc(seed) {
7253
- if (seed === void 0) {
7254
- seed = 0;
7223
+ if (obj && obj.removeEventListener) {
7224
+ obj.removeEventListener.apply(obj, args);
7255
7225
  }
7256
- return function() {
7257
- return ++seed;
7258
- };
7259
- }
7260
- var uid = autoInc();
7261
- var passiveEventSupport;
7262
- var handlersMap = {};
7263
- var enabledInstances = {};
7264
- var touchEvents = ["touchstart", "touchmove"];
7265
- var IGNORE_CLASS_NAME = "ignore-react-onclickoutside";
7266
- function getEventHandlerOptions(instance, eventName) {
7267
- var handlerOptions = {};
7268
- var isTouchEvent = touchEvents.indexOf(eventName) !== -1;
7269
- if (isTouchEvent && passiveEventSupport) {
7270
- handlerOptions.passive = !instance.props.preventDefault;
7271
- }
7272
- return handlerOptions;
7273
7226
  }
7274
- function onClickOutsideHOC(WrappedComponent, config) {
7275
- var _class, _temp;
7276
- var componentName = WrappedComponent.displayName || WrappedComponent.name || "Component";
7277
- return _temp = _class = /* @__PURE__ */ function(_Component) {
7278
- _inheritsLoose(onClickOutside, _Component);
7279
- function onClickOutside(props) {
7280
- var _this;
7281
- _this = _Component.call(this, props) || this;
7282
- _this.__outsideClickHandler = function(event) {
7283
- if (typeof _this.__clickOutsideHandlerProp === "function") {
7284
- _this.__clickOutsideHandlerProp(event);
7285
- return;
7286
- }
7287
- var instance = _this.getInstance();
7288
- if (typeof instance.props.handleClickOutside === "function") {
7289
- instance.props.handleClickOutside(event);
7290
- return;
7291
- }
7292
- if (typeof instance.handleClickOutside === "function") {
7293
- instance.handleClickOutside(event);
7294
- return;
7295
- }
7296
- throw new Error("WrappedComponent: " + componentName + " lacks a handleClickOutside(event) function for processing outside click events.");
7297
- };
7298
- _this.__getComponentNode = function() {
7299
- var instance = _this.getInstance();
7300
- if (config && typeof config.setClickOutsideRef === "function") {
7301
- return config.setClickOutsideRef()(instance);
7302
- }
7303
- if (typeof instance.setClickOutsideRef === "function") {
7304
- return instance.setClickOutsideRef();
7305
- }
7306
- return reactDom.findDOMNode(instance);
7307
- };
7308
- _this.enableOnClickOutside = function() {
7309
- if (typeof document === "undefined" || enabledInstances[_this._uid]) {
7310
- return;
7311
- }
7312
- if (typeof passiveEventSupport === "undefined") {
7313
- passiveEventSupport = testPassiveEventSupport();
7314
- }
7315
- enabledInstances[_this._uid] = true;
7316
- var events = _this.props.eventTypes;
7317
- if (!events.forEach) {
7318
- events = [events];
7319
- }
7320
- handlersMap[_this._uid] = function(event) {
7321
- if (_this.componentNode === null)
7322
- return;
7323
- if (_this.initTimeStamp > event.timeStamp)
7324
- return;
7325
- if (_this.props.preventDefault) {
7326
- event.preventDefault();
7327
- }
7328
- if (_this.props.stopPropagation) {
7329
- event.stopPropagation();
7330
- }
7331
- if (_this.props.excludeScrollbar && clickedScrollbar(event))
7332
- return;
7333
- var current = event.composed && event.composedPath && event.composedPath().shift() || event.target;
7334
- if (findHighest(current, _this.componentNode, _this.props.outsideClickIgnoreClass) !== document) {
7335
- return;
7336
- }
7337
- _this.__outsideClickHandler(event);
7338
- };
7339
- events.forEach(function(eventName) {
7340
- document.addEventListener(eventName, handlersMap[_this._uid], getEventHandlerOptions(_assertThisInitialized(_this), eventName));
7341
- });
7342
- };
7343
- _this.disableOnClickOutside = function() {
7344
- delete enabledInstances[_this._uid];
7345
- var fn = handlersMap[_this._uid];
7346
- if (fn && typeof document !== "undefined") {
7347
- var events = _this.props.eventTypes;
7348
- if (!events.forEach) {
7349
- events = [events];
7350
- }
7351
- events.forEach(function(eventName) {
7352
- return document.removeEventListener(eventName, fn, getEventHandlerOptions(_assertThisInitialized(_this), eventName));
7353
- });
7354
- delete handlersMap[_this._uid];
7355
- }
7356
- };
7357
- _this.getRef = function(ref) {
7358
- return _this.instanceRef = ref;
7359
- };
7360
- _this._uid = uid();
7361
- _this.initTimeStamp = performance.now();
7362
- return _this;
7363
- }
7364
- var _proto = onClickOutside.prototype;
7365
- _proto.getInstance = function getInstance() {
7366
- if (WrappedComponent.prototype && !WrappedComponent.prototype.isReactComponent) {
7367
- return this;
7368
- }
7369
- var ref = this.instanceRef;
7370
- return ref.getInstance ? ref.getInstance() : ref;
7371
- };
7372
- _proto.componentDidMount = function componentDidMount() {
7373
- if (typeof document === "undefined" || !document.createElement) {
7374
- return;
7375
- }
7376
- var instance = this.getInstance();
7377
- if (config && typeof config.handleClickOutside === "function") {
7378
- this.__clickOutsideHandlerProp = config.handleClickOutside(instance);
7379
- if (typeof this.__clickOutsideHandlerProp !== "function") {
7380
- throw new Error("WrappedComponent: " + componentName + " lacks a function for processing outside click events specified by the handleClickOutside config option.");
7381
- }
7382
- }
7383
- this.componentNode = this.__getComponentNode();
7384
- if (this.props.disableOnClickOutside)
7385
- return;
7386
- this.enableOnClickOutside();
7227
+ util.off = off;
7228
+ util.isBrowser = typeof window !== "undefined";
7229
+ util.isNavigator = typeof navigator !== "undefined";
7230
+ Object.defineProperty(useClickAway$1, "__esModule", { value: true });
7231
+ var react_1 = React;
7232
+ var util_1 = util;
7233
+ var defaultEvents = ["mousedown", "touchstart"];
7234
+ var useClickAway = function(ref, onClickAway, events) {
7235
+ if (events === void 0) {
7236
+ events = defaultEvents;
7237
+ }
7238
+ var savedCallback = react_1.useRef(onClickAway);
7239
+ react_1.useEffect(function() {
7240
+ savedCallback.current = onClickAway;
7241
+ }, [onClickAway]);
7242
+ react_1.useEffect(function() {
7243
+ var handler = function(event) {
7244
+ var el = ref.current;
7245
+ el && !el.contains(event.target) && savedCallback.current(event);
7387
7246
  };
7388
- _proto.componentDidUpdate = function componentDidUpdate() {
7389
- this.componentNode = this.__getComponentNode();
7390
- };
7391
- _proto.componentWillUnmount = function componentWillUnmount() {
7392
- this.disableOnClickOutside();
7393
- };
7394
- _proto.render = function render() {
7395
- var _this$props = this.props;
7396
- _this$props.excludeScrollbar;
7397
- var props = _objectWithoutPropertiesLoose(_this$props, ["excludeScrollbar"]);
7398
- if (WrappedComponent.prototype && WrappedComponent.prototype.isReactComponent) {
7399
- props.ref = this.getRef;
7400
- } else {
7401
- props.wrappedRef = this.getRef;
7247
+ for (var _i = 0, events_1 = events; _i < events_1.length; _i++) {
7248
+ var eventName = events_1[_i];
7249
+ util_1.on(document, eventName, handler);
7250
+ }
7251
+ return function() {
7252
+ for (var _i2 = 0, events_2 = events; _i2 < events_2.length; _i2++) {
7253
+ var eventName2 = events_2[_i2];
7254
+ util_1.off(document, eventName2, handler);
7402
7255
  }
7403
- props.disableOnClickOutside = this.disableOnClickOutside;
7404
- props.enableOnClickOutside = this.enableOnClickOutside;
7405
- return React.createElement(WrappedComponent, props);
7406
7256
  };
7407
- return onClickOutside;
7408
- }(React.Component), _class.displayName = "OnClickOutside(" + componentName + ")", _class.defaultProps = {
7409
- eventTypes: ["mousedown", "touchstart"],
7410
- excludeScrollbar: config && config.excludeScrollbar || false,
7411
- outsideClickIgnoreClass: IGNORE_CLASS_NAME,
7412
- preventDefault: false,
7413
- stopPropagation: false
7414
- }, _class.getClass = function() {
7415
- return WrappedComponent.getClass ? WrappedComponent.getClass() : WrappedComponent;
7416
- }, _temp;
7417
- }
7257
+ }, [events, ref]);
7258
+ };
7259
+ var _default = useClickAway$1.default = useClickAway;
7418
7260
  const viewModes = {
7419
7261
  YEARS: "years",
7420
7262
  MONTHS: "months",
@@ -7943,22 +7785,13 @@ flowchart TD
7943
7785
  }
7944
7786
  con[method]("***react-datetime:" + message);
7945
7787
  }
7946
- class ClickOutBase extends React.Component {
7947
- constructor() {
7948
- super(...arguments);
7949
- __publicField(this, "container", React.createRef());
7950
- }
7951
- render() {
7952
- return /* @__PURE__ */ React.createElement("div", { className: this.props.className, ref: this.container }, this.props.children);
7953
- }
7954
- handleClickOutside(e) {
7955
- this.props.onClickOut(e);
7956
- }
7957
- setClickOutsideRef() {
7958
- return this.container.current;
7959
- }
7788
+ function ClickableWrapper({ className, onClickOut, children }) {
7789
+ const containerRef = React.useRef(null);
7790
+ _default(containerRef, (event) => {
7791
+ onClickOut(event);
7792
+ });
7793
+ return /* @__PURE__ */ React.createElement("div", { className, ref: containerRef }, children);
7960
7794
  }
7961
- const ClickableWrapper = onClickOutsideHOC(ClickOutBase);
7962
7795
  const DEFAULT_DATE_DISPLAY_FORMAT = "MMM DD, YYYY";
7963
7796
  const DEFAULT_TIME_DISPLAY_FORMAT = "h:mm A";
7964
7797
  const format$1 = (val, _name, field) => {
@@ -8001,7 +7834,10 @@ flowchart TD
8001
7834
  ReactDateTimeWithStyles,
8002
7835
  {
8003
7836
  value: input.value,
8004
- onChange: input.onChange,
7837
+ onChange: (value) => {
7838
+ const newValue = value === "" ? void 0 : value;
7839
+ input.onChange(newValue);
7840
+ },
8005
7841
  dateFormat: dateFormat || DEFAULT_DATE_DISPLAY_FORMAT,
8006
7842
  timeFormat: timeFormat || false,
8007
7843
  inputProps: { className: textFieldClasses },
@@ -9453,6 +9289,19 @@ flowchart TD
9453
9289
  }
9454
9290
  }
9455
9291
  }
9292
+ const encodeUrlIfNeeded = (url) => {
9293
+ if (url) {
9294
+ try {
9295
+ const parsed = new URL(url);
9296
+ parsed.pathname = parsed.pathname.split("/").filter((part) => part !== "").map(encodeURIComponent).join("/");
9297
+ return parsed.toString();
9298
+ } catch (e) {
9299
+ return url;
9300
+ }
9301
+ } else {
9302
+ return url;
9303
+ }
9304
+ };
9456
9305
  let MediaManager$1 = class MediaManager {
9457
9306
  constructor(store, events) {
9458
9307
  this.store = store;
@@ -9525,6 +9374,20 @@ flowchart TD
9525
9374
  try {
9526
9375
  this.events.dispatch({ type: "media:list:start", ...options });
9527
9376
  const media = await this.store.list(options);
9377
+ media.items = media.items.map((item) => {
9378
+ if (item.type === "dir") {
9379
+ return item;
9380
+ }
9381
+ if (item.thumbnails) {
9382
+ for (const [size, src] of Object.entries(item.thumbnails)) {
9383
+ item.thumbnails[size] = encodeUrlIfNeeded(src);
9384
+ }
9385
+ }
9386
+ return {
9387
+ ...item,
9388
+ src: encodeUrlIfNeeded(item.src)
9389
+ };
9390
+ });
9528
9391
  this.events.dispatch({ type: "media:list:success", ...options, media });
9529
9392
  return media;
9530
9393
  } catch (error) {
@@ -10332,7 +10195,7 @@ flowchart TD
10332
10195
  "Event Log"
10333
10196
  ));
10334
10197
  };
10335
- const version = "2.4.0";
10198
+ const version = "2.6.4";
10336
10199
  const Nav = ({
10337
10200
  isLocalMode,
10338
10201
  className = "",
@@ -14652,7 +14515,7 @@ flowchart TD
14652
14515
  key: template.name,
14653
14516
  onMouseDown: (e) => {
14654
14517
  e.preventDefault();
14655
- close();
14518
+ setOpen(false);
14656
14519
  insertMDX(editor, template);
14657
14520
  },
14658
14521
  className: ""
@@ -14738,7 +14601,12 @@ flowchart TD
14738
14601
  const [itemsShown, setItemsShown] = React.useState(11);
14739
14602
  const { overrides, templates } = useToolbarContext();
14740
14603
  const showEmbedButton = templates.length > 0;
14741
- let items2 = overrides === void 0 ? Object.values(toolbarItems) : overrides.map((item) => toolbarItems[item]).filter((item) => item !== void 0);
14604
+ let items2 = [];
14605
+ if (Array.isArray(overrides)) {
14606
+ items2 = overrides === void 0 ? Object.values(toolbarItems) : overrides.map((item) => toolbarItems[item]).filter((item) => item !== void 0);
14607
+ } else {
14608
+ items2 = (overrides == null ? void 0 : overrides.toolbar) === void 0 ? Object.values(toolbarItems) : overrides.toolbar.map((item) => toolbarItems[item]).filter((item) => item !== void 0);
14609
+ }
14742
14610
  if (!showEmbedButton) {
14743
14611
  items2 = items2.filter((item) => item.label !== toolbarItems.embed.label);
14744
14612
  }
@@ -15066,6 +14934,9 @@ flowchart TD
15066
14934
  if (typeof string !== "string") {
15067
14935
  return false;
15068
14936
  }
14937
+ if (string.startsWith("#")) {
14938
+ return true;
14939
+ }
15069
14940
  const generalMatch = string.match(protocolAndDomainRE);
15070
14941
  const emailLinkMatch = string.match(emailLintRE);
15071
14942
  const localUrlMatch = string.match(localUrlRE);
@@ -15087,12 +14958,12 @@ flowchart TD
15087
14958
  }
15088
14959
  return localhostDomainRE.test(everythingAfterProtocol) || nonLocalhostDomainRE.test(everythingAfterProtocol);
15089
14960
  };
15090
- const RichEditor = (props) => {
14961
+ const RichEditor = ({ input, tinaForm, field }) => {
15091
14962
  var _a;
15092
14963
  const initialValue = React.useMemo(
15093
14964
  () => {
15094
14965
  var _a2, _b;
15095
- return ((_b = (_a2 = props.input.value) == null ? void 0 : _a2.children) == null ? void 0 : _b.length) ? props.input.value.children.map(helpers.normalize) : [{ type: "p", children: [{ type: "text", text: "" }] }];
14966
+ return ((_b = (_a2 = input.value) == null ? void 0 : _a2.children) == null ? void 0 : _b.length) ? input.value.children.map(helpers.normalize) : [{ type: "p", children: [{ type: "text", text: "" }] }];
15096
14967
  },
15097
14968
  []
15098
14969
  );
@@ -15120,7 +14991,7 @@ flowchart TD
15120
14991
  ),
15121
14992
  []
15122
14993
  );
15123
- const tempId = [props.tinaForm.id, props.input.name].join(".");
14994
+ const tempId = [tinaForm.id, input.name].join(".");
15124
14995
  const id = React.useMemo(() => uuid() + tempId, [tempId]);
15125
14996
  const ref = React.useRef(null);
15126
14997
  React.useEffect(() => {
@@ -15130,13 +15001,13 @@ flowchart TD
15130
15001
  const plateElement = (_a2 = ref.current) == null ? void 0 : _a2.querySelector(
15131
15002
  '[role="textbox"]'
15132
15003
  );
15133
- if (props.field.experimental_focusIntent && plateElement) {
15004
+ if (field.experimental_focusIntent && plateElement) {
15134
15005
  if (plateElement)
15135
15006
  plateElement.focus();
15136
15007
  }
15137
15008
  }, 100);
15138
15009
  }
15139
- }, [props.field.experimental_focusIntent, ref]);
15010
+ }, [field.experimental_focusIntent, ref]);
15140
15011
  return /* @__PURE__ */ React.createElement("div", { ref }, /* @__PURE__ */ React.createElement(
15141
15012
  plateCommon.Plate,
15142
15013
  {
@@ -15144,7 +15015,7 @@ flowchart TD
15144
15015
  initialValue,
15145
15016
  plugins: plugins$2,
15146
15017
  onChange: (value) => {
15147
- props.input.onChange({
15018
+ input.onChange({
15148
15019
  type: "root",
15149
15020
  children: value
15150
15021
  });
@@ -15153,12 +15024,12 @@ flowchart TD
15153
15024
  /* @__PURE__ */ React.createElement(TooltipProvider, null, /* @__PURE__ */ React.createElement(
15154
15025
  ToolbarProvider,
15155
15026
  {
15156
- tinaForm: props.tinaForm,
15157
- templates: props.field.templates,
15158
- overrides: (_a = props.field) == null ? void 0 : _a.toolbarOverride
15027
+ tinaForm,
15028
+ templates: field.templates,
15029
+ overrides: (field == null ? void 0 : field.toolbarOverride) ? field.toolbarOverride : field.overrides
15159
15030
  },
15160
15031
  /* @__PURE__ */ React.createElement(FixedToolbar, null, /* @__PURE__ */ React.createElement(FixedToolbarButtons, null)),
15161
- /* @__PURE__ */ React.createElement(FloatingToolbar, null, /* @__PURE__ */ React.createElement(FloatingToolbarButtons, null))
15032
+ ((_a = field == null ? void 0 : field.overrides) == null ? void 0 : _a.showFloatingToolbar) !== false ? /* @__PURE__ */ React.createElement(FloatingToolbar, null, /* @__PURE__ */ React.createElement(FloatingToolbarButtons, null)) : null
15162
15033
  ), /* @__PURE__ */ React.createElement(Editor, null))
15163
15034
  ));
15164
15035
  };
@@ -30112,6 +29983,7 @@ mutation addPendingDocumentMutation(
30112
29983
  relativePath
30113
29984
  filename
30114
29985
  extension
29986
+ hasReferences
30115
29987
  }
30116
29988
  }
30117
29989
  }
@@ -30203,6 +30075,9 @@ mutation addPendingDocumentMutation(
30203
30075
  document(collection:$collection, relativePath:$relativePath) {
30204
30076
  ... on Document {
30205
30077
  _values
30078
+ _sys {
30079
+ hasReferences
30080
+ }
30206
30081
  }
30207
30082
  }
30208
30083
  }`;
@@ -31929,6 +31804,23 @@ This will work when developing locally but NOT when deployed to production.
31929
31804
  DeleteModal,
31930
31805
  {
31931
31806
  filename: vars.relativePath,
31807
+ checkRefsFunc: async () => {
31808
+ var _a2, _b2;
31809
+ try {
31810
+ const doc = await admin.fetchDocument(
31811
+ collection.name,
31812
+ vars.relativePath,
31813
+ true
31814
+ );
31815
+ return (_b2 = (_a2 = doc == null ? void 0 : doc.document) == null ? void 0 : _a2._sys) == null ? void 0 : _b2.hasReferences;
31816
+ } catch (error) {
31817
+ cms.alerts.error(
31818
+ "Document was not found, ask a developer for help or check the console for an error message"
31819
+ );
31820
+ console.error(error);
31821
+ throw error;
31822
+ }
31823
+ },
31932
31824
  deleteFunc: async () => {
31933
31825
  try {
31934
31826
  await admin.deleteDocument(vars);
@@ -31937,6 +31829,12 @@ This will work when developing locally but NOT when deployed to production.
31937
31829
  );
31938
31830
  reFetchCollection();
31939
31831
  } catch (error) {
31832
+ if (error.message.indexOf("has references")) {
31833
+ cms.alerts.error(
31834
+ error.message.split("\n ").filter(Boolean)[1]
31835
+ );
31836
+ return;
31837
+ }
31940
31838
  cms.alerts.warn(
31941
31839
  "Document was not deleted, ask a developer for help or check the console for an error message"
31942
31840
  );
@@ -31988,6 +31886,12 @@ This will work when developing locally but NOT when deployed to production.
31988
31886
  cms.alerts.info("Document was successfully renamed");
31989
31887
  reFetchCollection();
31990
31888
  } catch (error) {
31889
+ if (error.message.indexOf("has references")) {
31890
+ cms.alerts.error(
31891
+ error.message.split("\n ").filter(Boolean)[1]
31892
+ );
31893
+ return;
31894
+ }
31991
31895
  cms.alerts.warn(
31992
31896
  "Document was not renamed, ask a developer for help or check the console for an error message"
31993
31897
  );
@@ -32461,8 +32365,19 @@ This will work when developing locally but NOT when deployed to production.
32461
32365
  const NoDocumentsPlaceholder = () => {
32462
32366
  return /* @__PURE__ */ React.createElement("div", { className: "text-center px-5 py-3 flex flex-col items-center justify-center shadow border border-gray-100 bg-gray-50 border-b border-gray-200 w-full max-w-full rounded-lg" }, /* @__PURE__ */ React.createElement("p", { className: "text-base italic font-medium text-gray-300" }, "No documents found."));
32463
32367
  };
32464
- const DeleteModal = ({ close: close2, deleteFunc, filename }) => {
32465
- return /* @__PURE__ */ React.createElement(Modal, null, /* @__PURE__ */ React.createElement(PopupModal, null, /* @__PURE__ */ React.createElement(ModalHeader, { close: close2 }, "Delete ", filename), /* @__PURE__ */ React.createElement(ModalBody, { padded: true }, /* @__PURE__ */ React.createElement("p", null, `Are you sure you want to delete ${filename}?`)), /* @__PURE__ */ React.createElement(ModalActions, null, /* @__PURE__ */ React.createElement(Button$1, { style: { flexGrow: 2 }, onClick: close2 }, "Cancel"), /* @__PURE__ */ React.createElement(
32368
+ const DeleteModal = ({
32369
+ close: close2,
32370
+ deleteFunc,
32371
+ checkRefsFunc,
32372
+ filename
32373
+ }) => {
32374
+ const [hasRefs, setHasRefs] = React.useState();
32375
+ React.useEffect(() => {
32376
+ checkRefsFunc().then((result) => {
32377
+ setHasRefs(result);
32378
+ });
32379
+ }, [filename, checkRefsFunc]);
32380
+ return /* @__PURE__ */ React.createElement(Modal, null, /* @__PURE__ */ React.createElement(PopupModal, null, /* @__PURE__ */ React.createElement(ModalHeader, { close: close2 }, "Delete ", filename), /* @__PURE__ */ React.createElement(ModalBody, { padded: true }, /* @__PURE__ */ React.createElement("p", null, `Are you sure you want to delete ${filename}?${hasRefs ? " References to this document will also be deleted." : ""}`)), /* @__PURE__ */ React.createElement(ModalActions, null, /* @__PURE__ */ React.createElement(Button$1, { style: { flexGrow: 2 }, onClick: close2 }, "Cancel"), /* @__PURE__ */ React.createElement(
32466
32381
  Button$1,
32467
32382
  {
32468
32383
  style: { flexGrow: 3 },
@@ -33194,15 +33109,24 @@ This will work when developing locally but NOT when deployed to production.
33194
33109
  }
33195
33110
  }
33196
33111
  if (state === "creatingPR") {
33197
- const foo = await tinaApi.createPullRequest({
33198
- baseBranch,
33199
- branch,
33200
- title: `${branch.replace("tina/", "").replace("-", " ")} (PR from TinaCMS)`
33201
- });
33202
- console.log("PR created", foo);
33203
- cms.alerts.success("Pull request created.");
33204
- localStorage.setItem("tina.createBranchState", "done");
33205
- setState("done");
33112
+ try {
33113
+ const foo = await tinaApi.createPullRequest({
33114
+ baseBranch,
33115
+ branch,
33116
+ title: `${branch.replace("tina/", "").replace("-", " ")} (PR from TinaCMS)`
33117
+ });
33118
+ console.log("PR created", foo);
33119
+ cms.alerts.success("Pull request created.");
33120
+ localStorage.setItem("tina.createBranchState", "done");
33121
+ setState("done");
33122
+ } catch (e) {
33123
+ console.error(e);
33124
+ cms.alerts.error("Failed to create PR");
33125
+ setErrorMessage(
33126
+ "Failed to create PR, please try again. If the problem persists please contact support."
33127
+ );
33128
+ setState("error");
33129
+ }
33206
33130
  }
33207
33131
  if (state === "done") {
33208
33132
  window.location.href = back;