tinacms 2.5.2 → 2.6.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -3830,7 +3830,7 @@ flowchart TD
3830
3830
  function _objectWithoutProperties(source, excluded) {
3831
3831
  if (source == null)
3832
3832
  return {};
3833
- var target = _objectWithoutPropertiesLoose$1(source, excluded);
3833
+ var target = _objectWithoutPropertiesLoose(source, excluded);
3834
3834
  var key, i;
3835
3835
  if (Object.getOwnPropertySymbols) {
3836
3836
  var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
@@ -3845,7 +3845,7 @@ flowchart TD
3845
3845
  }
3846
3846
  return target;
3847
3847
  }
3848
- function _objectWithoutPropertiesLoose$1(source, excluded) {
3848
+ function _objectWithoutPropertiesLoose(source, excluded) {
3849
3849
  if (source == null)
3850
3850
  return {};
3851
3851
  var target = {};
@@ -7209,244 +7209,65 @@ flowchart TD
7209
7209
  str = "0" + str;
7210
7210
  return str;
7211
7211
  }
7212
- function _inheritsLoose(subClass, superClass) {
7213
- subClass.prototype = Object.create(superClass.prototype);
7214
- subClass.prototype.constructor = subClass;
7215
- _setPrototypeOf(subClass, superClass);
7216
- }
7217
- function _setPrototypeOf(o, p) {
7218
- _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf2(o2, p2) {
7219
- o2.__proto__ = p2;
7220
- return o2;
7221
- };
7222
- return _setPrototypeOf(o, p);
7223
- }
7224
- function _objectWithoutPropertiesLoose(source, excluded) {
7225
- if (source == null)
7226
- return {};
7227
- var target = {};
7228
- var sourceKeys = Object.keys(source);
7229
- var key, i;
7230
- for (i = 0; i < sourceKeys.length; i++) {
7231
- key = sourceKeys[i];
7232
- if (excluded.indexOf(key) >= 0)
7233
- continue;
7234
- target[key] = source[key];
7235
- }
7236
- return target;
7237
- }
7238
- function _assertThisInitialized(self2) {
7239
- if (self2 === void 0) {
7240
- throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
7241
- }
7242
- return self2;
7243
- }
7244
- function isNodeFound(current, componentNode, ignoreClass) {
7245
- if (current === componentNode) {
7246
- return true;
7247
- }
7248
- if (current.correspondingElement) {
7249
- return current.correspondingElement.classList.contains(ignoreClass);
7250
- }
7251
- return current.classList.contains(ignoreClass);
7252
- }
7253
- function findHighest(current, componentNode, ignoreClass) {
7254
- if (current === componentNode) {
7255
- return true;
7212
+ var useClickAway$1 = {};
7213
+ var util = {};
7214
+ Object.defineProperty(util, "__esModule", { value: true });
7215
+ util.isNavigator = util.isBrowser = util.off = util.on = util.noop = void 0;
7216
+ var noop = function() {
7217
+ };
7218
+ util.noop = noop;
7219
+ function on(obj) {
7220
+ var args = [];
7221
+ for (var _i = 1; _i < arguments.length; _i++) {
7222
+ args[_i - 1] = arguments[_i];
7256
7223
  }
7257
- while (current.parentNode || current.host) {
7258
- if (current.parentNode && isNodeFound(current, componentNode, ignoreClass)) {
7259
- return true;
7260
- }
7261
- current = current.parentNode || current.host;
7224
+ if (obj && obj.addEventListener) {
7225
+ obj.addEventListener.apply(obj, args);
7262
7226
  }
7263
- return current;
7264
7227
  }
7265
- function clickedScrollbar(evt) {
7266
- return document.documentElement.clientWidth <= evt.clientX || document.documentElement.clientHeight <= evt.clientY;
7267
- }
7268
- var testPassiveEventSupport = function testPassiveEventSupport2() {
7269
- if (typeof window === "undefined" || typeof window.addEventListener !== "function") {
7270
- return;
7228
+ util.on = on;
7229
+ function off(obj) {
7230
+ var args = [];
7231
+ for (var _i = 1; _i < arguments.length; _i++) {
7232
+ args[_i - 1] = arguments[_i];
7271
7233
  }
7272
- var passive = false;
7273
- var options = Object.defineProperty({}, "passive", {
7274
- get: function get2() {
7275
- passive = true;
7276
- }
7277
- });
7278
- var noop = function noop2() {
7279
- };
7280
- window.addEventListener("testPassiveEventSupport", noop, options);
7281
- window.removeEventListener("testPassiveEventSupport", noop, options);
7282
- return passive;
7283
- };
7284
- function autoInc(seed) {
7285
- if (seed === void 0) {
7286
- seed = 0;
7234
+ if (obj && obj.removeEventListener) {
7235
+ obj.removeEventListener.apply(obj, args);
7287
7236
  }
7288
- return function() {
7289
- return ++seed;
7290
- };
7291
- }
7292
- var uid = autoInc();
7293
- var passiveEventSupport;
7294
- var handlersMap = {};
7295
- var enabledInstances = {};
7296
- var touchEvents = ["touchstart", "touchmove"];
7297
- var IGNORE_CLASS_NAME = "ignore-react-onclickoutside";
7298
- function getEventHandlerOptions(instance, eventName) {
7299
- var handlerOptions = {};
7300
- var isTouchEvent = touchEvents.indexOf(eventName) !== -1;
7301
- if (isTouchEvent && passiveEventSupport) {
7302
- handlerOptions.passive = !instance.props.preventDefault;
7303
- }
7304
- return handlerOptions;
7305
7237
  }
7306
- function onClickOutsideHOC(WrappedComponent, config) {
7307
- var _class, _temp;
7308
- var componentName = WrappedComponent.displayName || WrappedComponent.name || "Component";
7309
- return _temp = _class = /* @__PURE__ */ function(_Component) {
7310
- _inheritsLoose(onClickOutside, _Component);
7311
- function onClickOutside(props) {
7312
- var _this;
7313
- _this = _Component.call(this, props) || this;
7314
- _this.__outsideClickHandler = function(event) {
7315
- if (typeof _this.__clickOutsideHandlerProp === "function") {
7316
- _this.__clickOutsideHandlerProp(event);
7317
- return;
7318
- }
7319
- var instance = _this.getInstance();
7320
- if (typeof instance.props.handleClickOutside === "function") {
7321
- instance.props.handleClickOutside(event);
7322
- return;
7323
- }
7324
- if (typeof instance.handleClickOutside === "function") {
7325
- instance.handleClickOutside(event);
7326
- return;
7327
- }
7328
- throw new Error("WrappedComponent: " + componentName + " lacks a handleClickOutside(event) function for processing outside click events.");
7329
- };
7330
- _this.__getComponentNode = function() {
7331
- var instance = _this.getInstance();
7332
- if (config && typeof config.setClickOutsideRef === "function") {
7333
- return config.setClickOutsideRef()(instance);
7334
- }
7335
- if (typeof instance.setClickOutsideRef === "function") {
7336
- return instance.setClickOutsideRef();
7337
- }
7338
- return reactDom.findDOMNode(instance);
7339
- };
7340
- _this.enableOnClickOutside = function() {
7341
- if (typeof document === "undefined" || enabledInstances[_this._uid]) {
7342
- return;
7343
- }
7344
- if (typeof passiveEventSupport === "undefined") {
7345
- passiveEventSupport = testPassiveEventSupport();
7346
- }
7347
- enabledInstances[_this._uid] = true;
7348
- var events = _this.props.eventTypes;
7349
- if (!events.forEach) {
7350
- events = [events];
7351
- }
7352
- handlersMap[_this._uid] = function(event) {
7353
- if (_this.componentNode === null)
7354
- return;
7355
- if (_this.initTimeStamp > event.timeStamp)
7356
- return;
7357
- if (_this.props.preventDefault) {
7358
- event.preventDefault();
7359
- }
7360
- if (_this.props.stopPropagation) {
7361
- event.stopPropagation();
7362
- }
7363
- if (_this.props.excludeScrollbar && clickedScrollbar(event))
7364
- return;
7365
- var current = event.composed && event.composedPath && event.composedPath().shift() || event.target;
7366
- if (findHighest(current, _this.componentNode, _this.props.outsideClickIgnoreClass) !== document) {
7367
- return;
7368
- }
7369
- _this.__outsideClickHandler(event);
7370
- };
7371
- events.forEach(function(eventName) {
7372
- document.addEventListener(eventName, handlersMap[_this._uid], getEventHandlerOptions(_assertThisInitialized(_this), eventName));
7373
- });
7374
- };
7375
- _this.disableOnClickOutside = function() {
7376
- delete enabledInstances[_this._uid];
7377
- var fn = handlersMap[_this._uid];
7378
- if (fn && typeof document !== "undefined") {
7379
- var events = _this.props.eventTypes;
7380
- if (!events.forEach) {
7381
- events = [events];
7382
- }
7383
- events.forEach(function(eventName) {
7384
- return document.removeEventListener(eventName, fn, getEventHandlerOptions(_assertThisInitialized(_this), eventName));
7385
- });
7386
- delete handlersMap[_this._uid];
7387
- }
7388
- };
7389
- _this.getRef = function(ref) {
7390
- return _this.instanceRef = ref;
7391
- };
7392
- _this._uid = uid();
7393
- _this.initTimeStamp = performance.now();
7394
- return _this;
7395
- }
7396
- var _proto = onClickOutside.prototype;
7397
- _proto.getInstance = function getInstance() {
7398
- if (WrappedComponent.prototype && !WrappedComponent.prototype.isReactComponent) {
7399
- return this;
7400
- }
7401
- var ref = this.instanceRef;
7402
- return ref.getInstance ? ref.getInstance() : ref;
7238
+ util.off = off;
7239
+ util.isBrowser = typeof window !== "undefined";
7240
+ util.isNavigator = typeof navigator !== "undefined";
7241
+ Object.defineProperty(useClickAway$1, "__esModule", { value: true });
7242
+ var react_1 = React;
7243
+ var util_1 = util;
7244
+ var defaultEvents = ["mousedown", "touchstart"];
7245
+ var useClickAway = function(ref, onClickAway, events) {
7246
+ if (events === void 0) {
7247
+ events = defaultEvents;
7248
+ }
7249
+ var savedCallback = react_1.useRef(onClickAway);
7250
+ react_1.useEffect(function() {
7251
+ savedCallback.current = onClickAway;
7252
+ }, [onClickAway]);
7253
+ react_1.useEffect(function() {
7254
+ var handler = function(event) {
7255
+ var el = ref.current;
7256
+ el && !el.contains(event.target) && savedCallback.current(event);
7403
7257
  };
7404
- _proto.componentDidMount = function componentDidMount() {
7405
- if (typeof document === "undefined" || !document.createElement) {
7406
- return;
7407
- }
7408
- var instance = this.getInstance();
7409
- if (config && typeof config.handleClickOutside === "function") {
7410
- this.__clickOutsideHandlerProp = config.handleClickOutside(instance);
7411
- if (typeof this.__clickOutsideHandlerProp !== "function") {
7412
- throw new Error("WrappedComponent: " + componentName + " lacks a function for processing outside click events specified by the handleClickOutside config option.");
7413
- }
7414
- }
7415
- this.componentNode = this.__getComponentNode();
7416
- if (this.props.disableOnClickOutside)
7417
- return;
7418
- this.enableOnClickOutside();
7419
- };
7420
- _proto.componentDidUpdate = function componentDidUpdate() {
7421
- this.componentNode = this.__getComponentNode();
7422
- };
7423
- _proto.componentWillUnmount = function componentWillUnmount() {
7424
- this.disableOnClickOutside();
7425
- };
7426
- _proto.render = function render() {
7427
- var _this$props = this.props;
7428
- _this$props.excludeScrollbar;
7429
- var props = _objectWithoutPropertiesLoose(_this$props, ["excludeScrollbar"]);
7430
- if (WrappedComponent.prototype && WrappedComponent.prototype.isReactComponent) {
7431
- props.ref = this.getRef;
7432
- } else {
7433
- props.wrappedRef = this.getRef;
7258
+ for (var _i = 0, events_1 = events; _i < events_1.length; _i++) {
7259
+ var eventName = events_1[_i];
7260
+ util_1.on(document, eventName, handler);
7261
+ }
7262
+ return function() {
7263
+ for (var _i2 = 0, events_2 = events; _i2 < events_2.length; _i2++) {
7264
+ var eventName2 = events_2[_i2];
7265
+ util_1.off(document, eventName2, handler);
7434
7266
  }
7435
- props.disableOnClickOutside = this.disableOnClickOutside;
7436
- props.enableOnClickOutside = this.enableOnClickOutside;
7437
- return React.createElement(WrappedComponent, props);
7438
7267
  };
7439
- return onClickOutside;
7440
- }(React.Component), _class.displayName = "OnClickOutside(" + componentName + ")", _class.defaultProps = {
7441
- eventTypes: ["mousedown", "touchstart"],
7442
- excludeScrollbar: config && config.excludeScrollbar || false,
7443
- outsideClickIgnoreClass: IGNORE_CLASS_NAME,
7444
- preventDefault: false,
7445
- stopPropagation: false
7446
- }, _class.getClass = function() {
7447
- return WrappedComponent.getClass ? WrappedComponent.getClass() : WrappedComponent;
7448
- }, _temp;
7449
- }
7268
+ }, [events, ref]);
7269
+ };
7270
+ var _default = useClickAway$1.default = useClickAway;
7450
7271
  const viewModes = {
7451
7272
  YEARS: "years",
7452
7273
  MONTHS: "months",
@@ -7975,22 +7796,13 @@ flowchart TD
7975
7796
  }
7976
7797
  con[method]("***react-datetime:" + message);
7977
7798
  }
7978
- class ClickOutBase extends React.Component {
7979
- constructor() {
7980
- super(...arguments);
7981
- __publicField(this, "container", React.createRef());
7982
- }
7983
- render() {
7984
- return /* @__PURE__ */ React.createElement("div", { className: this.props.className, ref: this.container }, this.props.children);
7985
- }
7986
- handleClickOutside(e) {
7987
- this.props.onClickOut(e);
7988
- }
7989
- setClickOutsideRef() {
7990
- return this.container.current;
7991
- }
7799
+ function ClickableWrapper({ className, onClickOut, children }) {
7800
+ const containerRef = React.useRef(null);
7801
+ _default(containerRef, (event) => {
7802
+ onClickOut(event);
7803
+ });
7804
+ return /* @__PURE__ */ React.createElement("div", { className, ref: containerRef }, children);
7992
7805
  }
7993
- const ClickableWrapper = onClickOutsideHOC(ClickOutBase);
7994
7806
  const DEFAULT_DATE_DISPLAY_FORMAT = "MMM DD, YYYY";
7995
7807
  const DEFAULT_TIME_DISPLAY_FORMAT = "h:mm A";
7996
7808
  const format$1 = (val, _name, field) => {
@@ -10367,7 +10179,7 @@ flowchart TD
10367
10179
  "Event Log"
10368
10180
  ));
10369
10181
  };
10370
- const version = "2.5.2";
10182
+ const version = "2.6.1";
10371
10183
  const Nav = ({
10372
10184
  isLocalMode,
10373
10185
  className = "",
@@ -14773,7 +14585,12 @@ flowchart TD
14773
14585
  const [itemsShown, setItemsShown] = React.useState(11);
14774
14586
  const { overrides, templates } = useToolbarContext();
14775
14587
  const showEmbedButton = templates.length > 0;
14776
- let items2 = overrides === void 0 ? Object.values(toolbarItems) : overrides.map((item) => toolbarItems[item]).filter((item) => item !== void 0);
14588
+ let items2 = [];
14589
+ if (Array.isArray(overrides)) {
14590
+ items2 = overrides === void 0 ? Object.values(toolbarItems) : overrides.map((item) => toolbarItems[item]).filter((item) => item !== void 0);
14591
+ } else {
14592
+ items2 = (overrides == null ? void 0 : overrides.toolbar) === void 0 ? Object.values(toolbarItems) : overrides.toolbar.map((item) => toolbarItems[item]).filter((item) => item !== void 0);
14593
+ }
14777
14594
  if (!showEmbedButton) {
14778
14595
  items2 = items2.filter((item) => item.label !== toolbarItems.embed.label);
14779
14596
  }
@@ -15101,6 +14918,9 @@ flowchart TD
15101
14918
  if (typeof string !== "string") {
15102
14919
  return false;
15103
14920
  }
14921
+ if (string.startsWith("#")) {
14922
+ return true;
14923
+ }
15104
14924
  const generalMatch = string.match(protocolAndDomainRE);
15105
14925
  const emailLinkMatch = string.match(emailLintRE);
15106
14926
  const localUrlMatch = string.match(localUrlRE);
@@ -15122,12 +14942,12 @@ flowchart TD
15122
14942
  }
15123
14943
  return localhostDomainRE.test(everythingAfterProtocol) || nonLocalhostDomainRE.test(everythingAfterProtocol);
15124
14944
  };
15125
- const RichEditor = (props) => {
14945
+ const RichEditor = ({ input, tinaForm, field }) => {
15126
14946
  var _a;
15127
14947
  const initialValue = React.useMemo(
15128
14948
  () => {
15129
14949
  var _a2, _b;
15130
- 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: "" }] }];
14950
+ 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: "" }] }];
15131
14951
  },
15132
14952
  []
15133
14953
  );
@@ -15155,7 +14975,7 @@ flowchart TD
15155
14975
  ),
15156
14976
  []
15157
14977
  );
15158
- const tempId = [props.tinaForm.id, props.input.name].join(".");
14978
+ const tempId = [tinaForm.id, input.name].join(".");
15159
14979
  const id = React.useMemo(() => uuid() + tempId, [tempId]);
15160
14980
  const ref = React.useRef(null);
15161
14981
  React.useEffect(() => {
@@ -15165,13 +14985,13 @@ flowchart TD
15165
14985
  const plateElement = (_a2 = ref.current) == null ? void 0 : _a2.querySelector(
15166
14986
  '[role="textbox"]'
15167
14987
  );
15168
- if (props.field.experimental_focusIntent && plateElement) {
14988
+ if (field.experimental_focusIntent && plateElement) {
15169
14989
  if (plateElement)
15170
14990
  plateElement.focus();
15171
14991
  }
15172
14992
  }, 100);
15173
14993
  }
15174
- }, [props.field.experimental_focusIntent, ref]);
14994
+ }, [field.experimental_focusIntent, ref]);
15175
14995
  return /* @__PURE__ */ React.createElement("div", { ref }, /* @__PURE__ */ React.createElement(
15176
14996
  plateCommon.Plate,
15177
14997
  {
@@ -15179,7 +14999,7 @@ flowchart TD
15179
14999
  initialValue,
15180
15000
  plugins: plugins$2,
15181
15001
  onChange: (value) => {
15182
- props.input.onChange({
15002
+ input.onChange({
15183
15003
  type: "root",
15184
15004
  children: value
15185
15005
  });
@@ -15188,12 +15008,12 @@ flowchart TD
15188
15008
  /* @__PURE__ */ React.createElement(TooltipProvider, null, /* @__PURE__ */ React.createElement(
15189
15009
  ToolbarProvider,
15190
15010
  {
15191
- tinaForm: props.tinaForm,
15192
- templates: props.field.templates,
15193
- overrides: (_a = props.field) == null ? void 0 : _a.toolbarOverride
15011
+ tinaForm,
15012
+ templates: field.templates,
15013
+ overrides: (field == null ? void 0 : field.toolbarOverride) ? field.toolbarOverride : field.overrides
15194
15014
  },
15195
15015
  /* @__PURE__ */ React.createElement(FixedToolbar, null, /* @__PURE__ */ React.createElement(FixedToolbarButtons, null)),
15196
- /* @__PURE__ */ React.createElement(FloatingToolbar, null, /* @__PURE__ */ React.createElement(FloatingToolbarButtons, null))
15016
+ ((_a = field == null ? void 0 : field.overrides) == null ? void 0 : _a.showFloatingToolbar) !== false ? /* @__PURE__ */ React.createElement(FloatingToolbar, null, /* @__PURE__ */ React.createElement(FloatingToolbarButtons, null)) : null
15197
15017
  ), /* @__PURE__ */ React.createElement(Editor, null))
15198
15018
  ));
15199
15019
  };