tinacms 0.0.0-d80714b-20241205222511 → 0.0.0-de1bef5-20250124020627

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 = {};
@@ -4935,7 +4935,28 @@ flowchart TD
4935
4935
  onChange,
4936
4936
  value,
4937
4937
  step
4938
- }) => /* @__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
+ );
4939
4960
  function useCMS() {
4940
4961
  return useCMS$1();
4941
4962
  }
@@ -7188,244 +7209,65 @@ flowchart TD
7188
7209
  str = "0" + str;
7189
7210
  return str;
7190
7211
  }
7191
- function _inheritsLoose(subClass, superClass) {
7192
- subClass.prototype = Object.create(superClass.prototype);
7193
- subClass.prototype.constructor = subClass;
7194
- _setPrototypeOf(subClass, superClass);
7195
- }
7196
- function _setPrototypeOf(o, p) {
7197
- _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf2(o2, p2) {
7198
- o2.__proto__ = p2;
7199
- return o2;
7200
- };
7201
- return _setPrototypeOf(o, p);
7202
- }
7203
- function _objectWithoutPropertiesLoose(source, excluded) {
7204
- if (source == null)
7205
- return {};
7206
- var target = {};
7207
- var sourceKeys = Object.keys(source);
7208
- var key, i;
7209
- for (i = 0; i < sourceKeys.length; i++) {
7210
- key = sourceKeys[i];
7211
- if (excluded.indexOf(key) >= 0)
7212
- continue;
7213
- target[key] = source[key];
7214
- }
7215
- return target;
7216
- }
7217
- function _assertThisInitialized(self2) {
7218
- if (self2 === void 0) {
7219
- throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
7220
- }
7221
- return self2;
7222
- }
7223
- function isNodeFound(current, componentNode, ignoreClass) {
7224
- if (current === componentNode) {
7225
- return true;
7226
- }
7227
- if (current.correspondingElement) {
7228
- return current.correspondingElement.classList.contains(ignoreClass);
7229
- }
7230
- return current.classList.contains(ignoreClass);
7231
- }
7232
- function findHighest(current, componentNode, ignoreClass) {
7233
- if (current === componentNode) {
7234
- 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];
7235
7223
  }
7236
- while (current.parentNode || current.host) {
7237
- if (current.parentNode && isNodeFound(current, componentNode, ignoreClass)) {
7238
- return true;
7239
- }
7240
- current = current.parentNode || current.host;
7224
+ if (obj && obj.addEventListener) {
7225
+ obj.addEventListener.apply(obj, args);
7241
7226
  }
7242
- return current;
7243
- }
7244
- function clickedScrollbar(evt) {
7245
- return document.documentElement.clientWidth <= evt.clientX || document.documentElement.clientHeight <= evt.clientY;
7246
7227
  }
7247
- var testPassiveEventSupport = function testPassiveEventSupport2() {
7248
- if (typeof window === "undefined" || typeof window.addEventListener !== "function") {
7249
- 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];
7250
7233
  }
7251
- var passive = false;
7252
- var options = Object.defineProperty({}, "passive", {
7253
- get: function get2() {
7254
- passive = true;
7255
- }
7256
- });
7257
- var noop = function noop2() {
7258
- };
7259
- window.addEventListener("testPassiveEventSupport", noop, options);
7260
- window.removeEventListener("testPassiveEventSupport", noop, options);
7261
- return passive;
7262
- };
7263
- function autoInc(seed) {
7264
- if (seed === void 0) {
7265
- seed = 0;
7234
+ if (obj && obj.removeEventListener) {
7235
+ obj.removeEventListener.apply(obj, args);
7266
7236
  }
7267
- return function() {
7268
- return ++seed;
7269
- };
7270
- }
7271
- var uid = autoInc();
7272
- var passiveEventSupport;
7273
- var handlersMap = {};
7274
- var enabledInstances = {};
7275
- var touchEvents = ["touchstart", "touchmove"];
7276
- var IGNORE_CLASS_NAME = "ignore-react-onclickoutside";
7277
- function getEventHandlerOptions(instance, eventName) {
7278
- var handlerOptions = {};
7279
- var isTouchEvent = touchEvents.indexOf(eventName) !== -1;
7280
- if (isTouchEvent && passiveEventSupport) {
7281
- handlerOptions.passive = !instance.props.preventDefault;
7282
- }
7283
- return handlerOptions;
7284
7237
  }
7285
- function onClickOutsideHOC(WrappedComponent, config) {
7286
- var _class, _temp;
7287
- var componentName = WrappedComponent.displayName || WrappedComponent.name || "Component";
7288
- return _temp = _class = /* @__PURE__ */ function(_Component) {
7289
- _inheritsLoose(onClickOutside, _Component);
7290
- function onClickOutside(props) {
7291
- var _this;
7292
- _this = _Component.call(this, props) || this;
7293
- _this.__outsideClickHandler = function(event) {
7294
- if (typeof _this.__clickOutsideHandlerProp === "function") {
7295
- _this.__clickOutsideHandlerProp(event);
7296
- return;
7297
- }
7298
- var instance = _this.getInstance();
7299
- if (typeof instance.props.handleClickOutside === "function") {
7300
- instance.props.handleClickOutside(event);
7301
- return;
7302
- }
7303
- if (typeof instance.handleClickOutside === "function") {
7304
- instance.handleClickOutside(event);
7305
- return;
7306
- }
7307
- throw new Error("WrappedComponent: " + componentName + " lacks a handleClickOutside(event) function for processing outside click events.");
7308
- };
7309
- _this.__getComponentNode = function() {
7310
- var instance = _this.getInstance();
7311
- if (config && typeof config.setClickOutsideRef === "function") {
7312
- return config.setClickOutsideRef()(instance);
7313
- }
7314
- if (typeof instance.setClickOutsideRef === "function") {
7315
- return instance.setClickOutsideRef();
7316
- }
7317
- return reactDom.findDOMNode(instance);
7318
- };
7319
- _this.enableOnClickOutside = function() {
7320
- if (typeof document === "undefined" || enabledInstances[_this._uid]) {
7321
- return;
7322
- }
7323
- if (typeof passiveEventSupport === "undefined") {
7324
- passiveEventSupport = testPassiveEventSupport();
7325
- }
7326
- enabledInstances[_this._uid] = true;
7327
- var events = _this.props.eventTypes;
7328
- if (!events.forEach) {
7329
- events = [events];
7330
- }
7331
- handlersMap[_this._uid] = function(event) {
7332
- if (_this.componentNode === null)
7333
- return;
7334
- if (_this.initTimeStamp > event.timeStamp)
7335
- return;
7336
- if (_this.props.preventDefault) {
7337
- event.preventDefault();
7338
- }
7339
- if (_this.props.stopPropagation) {
7340
- event.stopPropagation();
7341
- }
7342
- if (_this.props.excludeScrollbar && clickedScrollbar(event))
7343
- return;
7344
- var current = event.composed && event.composedPath && event.composedPath().shift() || event.target;
7345
- if (findHighest(current, _this.componentNode, _this.props.outsideClickIgnoreClass) !== document) {
7346
- return;
7347
- }
7348
- _this.__outsideClickHandler(event);
7349
- };
7350
- events.forEach(function(eventName) {
7351
- document.addEventListener(eventName, handlersMap[_this._uid], getEventHandlerOptions(_assertThisInitialized(_this), eventName));
7352
- });
7353
- };
7354
- _this.disableOnClickOutside = function() {
7355
- delete enabledInstances[_this._uid];
7356
- var fn = handlersMap[_this._uid];
7357
- if (fn && typeof document !== "undefined") {
7358
- var events = _this.props.eventTypes;
7359
- if (!events.forEach) {
7360
- events = [events];
7361
- }
7362
- events.forEach(function(eventName) {
7363
- return document.removeEventListener(eventName, fn, getEventHandlerOptions(_assertThisInitialized(_this), eventName));
7364
- });
7365
- delete handlersMap[_this._uid];
7366
- }
7367
- };
7368
- _this.getRef = function(ref) {
7369
- return _this.instanceRef = ref;
7370
- };
7371
- _this._uid = uid();
7372
- _this.initTimeStamp = performance.now();
7373
- return _this;
7374
- }
7375
- var _proto = onClickOutside.prototype;
7376
- _proto.getInstance = function getInstance() {
7377
- if (WrappedComponent.prototype && !WrappedComponent.prototype.isReactComponent) {
7378
- return this;
7379
- }
7380
- var ref = this.instanceRef;
7381
- return ref.getInstance ? ref.getInstance() : ref;
7382
- };
7383
- _proto.componentDidMount = function componentDidMount() {
7384
- if (typeof document === "undefined" || !document.createElement) {
7385
- return;
7386
- }
7387
- var instance = this.getInstance();
7388
- if (config && typeof config.handleClickOutside === "function") {
7389
- this.__clickOutsideHandlerProp = config.handleClickOutside(instance);
7390
- if (typeof this.__clickOutsideHandlerProp !== "function") {
7391
- throw new Error("WrappedComponent: " + componentName + " lacks a function for processing outside click events specified by the handleClickOutside config option.");
7392
- }
7393
- }
7394
- this.componentNode = this.__getComponentNode();
7395
- if (this.props.disableOnClickOutside)
7396
- return;
7397
- this.enableOnClickOutside();
7398
- };
7399
- _proto.componentDidUpdate = function componentDidUpdate() {
7400
- this.componentNode = this.__getComponentNode();
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);
7401
7257
  };
7402
- _proto.componentWillUnmount = function componentWillUnmount() {
7403
- this.disableOnClickOutside();
7404
- };
7405
- _proto.render = function render() {
7406
- var _this$props = this.props;
7407
- _this$props.excludeScrollbar;
7408
- var props = _objectWithoutPropertiesLoose(_this$props, ["excludeScrollbar"]);
7409
- if (WrappedComponent.prototype && WrappedComponent.prototype.isReactComponent) {
7410
- props.ref = this.getRef;
7411
- } else {
7412
- 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);
7413
7266
  }
7414
- props.disableOnClickOutside = this.disableOnClickOutside;
7415
- props.enableOnClickOutside = this.enableOnClickOutside;
7416
- return React.createElement(WrappedComponent, props);
7417
7267
  };
7418
- return onClickOutside;
7419
- }(React.Component), _class.displayName = "OnClickOutside(" + componentName + ")", _class.defaultProps = {
7420
- eventTypes: ["mousedown", "touchstart"],
7421
- excludeScrollbar: config && config.excludeScrollbar || false,
7422
- outsideClickIgnoreClass: IGNORE_CLASS_NAME,
7423
- preventDefault: false,
7424
- stopPropagation: false
7425
- }, _class.getClass = function() {
7426
- return WrappedComponent.getClass ? WrappedComponent.getClass() : WrappedComponent;
7427
- }, _temp;
7428
- }
7268
+ }, [events, ref]);
7269
+ };
7270
+ var _default = useClickAway$1.default = useClickAway;
7429
7271
  const viewModes = {
7430
7272
  YEARS: "years",
7431
7273
  MONTHS: "months",
@@ -7954,22 +7796,13 @@ flowchart TD
7954
7796
  }
7955
7797
  con[method]("***react-datetime:" + message);
7956
7798
  }
7957
- class ClickOutBase extends React.Component {
7958
- constructor() {
7959
- super(...arguments);
7960
- __publicField(this, "container", React.createRef());
7961
- }
7962
- render() {
7963
- return /* @__PURE__ */ React.createElement("div", { className: this.props.className, ref: this.container }, this.props.children);
7964
- }
7965
- handleClickOutside(e) {
7966
- this.props.onClickOut(e);
7967
- }
7968
- setClickOutsideRef() {
7969
- return this.container.current;
7970
- }
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);
7971
7805
  }
7972
- const ClickableWrapper = onClickOutsideHOC(ClickOutBase);
7973
7806
  const DEFAULT_DATE_DISPLAY_FORMAT = "MMM DD, YYYY";
7974
7807
  const DEFAULT_TIME_DISPLAY_FORMAT = "h:mm A";
7975
7808
  const format$1 = (val, _name, field) => {
@@ -8012,7 +7845,10 @@ flowchart TD
8012
7845
  ReactDateTimeWithStyles,
8013
7846
  {
8014
7847
  value: input.value,
8015
- onChange: input.onChange,
7848
+ onChange: (value) => {
7849
+ const newValue = value === "" ? void 0 : value;
7850
+ input.onChange(newValue);
7851
+ },
8016
7852
  dateFormat: dateFormat || DEFAULT_DATE_DISPLAY_FORMAT,
8017
7853
  timeFormat: timeFormat || false,
8018
7854
  inputProps: { className: textFieldClasses },
@@ -9464,6 +9300,20 @@ flowchart TD
9464
9300
  }
9465
9301
  }
9466
9302
  }
9303
+ const encodeUrlIfNeeded = (url) => {
9304
+ if (url) {
9305
+ try {
9306
+ const parsed = new URL(url);
9307
+ parsed.pathname = parsed.pathname.split("/").filter((part) => part !== "").map(encodeURIComponent).join("/");
9308
+ return parsed.toString();
9309
+ } catch (e) {
9310
+ console.error("Failed to parse URL:", e);
9311
+ return url;
9312
+ }
9313
+ } else {
9314
+ return url;
9315
+ }
9316
+ };
9467
9317
  let MediaManager$1 = class MediaManager {
9468
9318
  constructor(store, events) {
9469
9319
  this.store = store;
@@ -9536,6 +9386,20 @@ flowchart TD
9536
9386
  try {
9537
9387
  this.events.dispatch({ type: "media:list:start", ...options });
9538
9388
  const media = await this.store.list(options);
9389
+ media.items = media.items.map((item) => {
9390
+ if (item.type === "dir") {
9391
+ return item;
9392
+ }
9393
+ if (item.thumbnails) {
9394
+ for (const [size, src] of Object.entries(item.thumbnails)) {
9395
+ item.thumbnails[size] = encodeUrlIfNeeded(src);
9396
+ }
9397
+ }
9398
+ return {
9399
+ ...item,
9400
+ src: encodeUrlIfNeeded(item.src)
9401
+ };
9402
+ });
9539
9403
  this.events.dispatch({ type: "media:list:success", ...options, media });
9540
9404
  return media;
9541
9405
  } catch (error) {
@@ -10343,7 +10207,7 @@ flowchart TD
10343
10207
  "Event Log"
10344
10208
  ));
10345
10209
  };
10346
- const version = "2.5.0";
10210
+ const version = "2.6.1";
10347
10211
  const Nav = ({
10348
10212
  isLocalMode,
10349
10213
  className = "",
@@ -14749,7 +14613,12 @@ flowchart TD
14749
14613
  const [itemsShown, setItemsShown] = React.useState(11);
14750
14614
  const { overrides, templates } = useToolbarContext();
14751
14615
  const showEmbedButton = templates.length > 0;
14752
- let items2 = overrides === void 0 ? Object.values(toolbarItems) : overrides.map((item) => toolbarItems[item]).filter((item) => item !== void 0);
14616
+ let items2 = [];
14617
+ if (Array.isArray(overrides)) {
14618
+ items2 = overrides === void 0 ? Object.values(toolbarItems) : overrides.map((item) => toolbarItems[item]).filter((item) => item !== void 0);
14619
+ } else {
14620
+ items2 = (overrides == null ? void 0 : overrides.toolbar) === void 0 ? Object.values(toolbarItems) : overrides.toolbar.map((item) => toolbarItems[item]).filter((item) => item !== void 0);
14621
+ }
14753
14622
  if (!showEmbedButton) {
14754
14623
  items2 = items2.filter((item) => item.label !== toolbarItems.embed.label);
14755
14624
  }
@@ -15077,6 +14946,9 @@ flowchart TD
15077
14946
  if (typeof string !== "string") {
15078
14947
  return false;
15079
14948
  }
14949
+ if (string.startsWith("#")) {
14950
+ return true;
14951
+ }
15080
14952
  const generalMatch = string.match(protocolAndDomainRE);
15081
14953
  const emailLinkMatch = string.match(emailLintRE);
15082
14954
  const localUrlMatch = string.match(localUrlRE);
@@ -15098,12 +14970,12 @@ flowchart TD
15098
14970
  }
15099
14971
  return localhostDomainRE.test(everythingAfterProtocol) || nonLocalhostDomainRE.test(everythingAfterProtocol);
15100
14972
  };
15101
- const RichEditor = (props) => {
14973
+ const RichEditor = ({ input, tinaForm, field }) => {
15102
14974
  var _a;
15103
14975
  const initialValue = React.useMemo(
15104
14976
  () => {
15105
14977
  var _a2, _b;
15106
- 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: "" }] }];
14978
+ 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: "" }] }];
15107
14979
  },
15108
14980
  []
15109
14981
  );
@@ -15131,7 +15003,7 @@ flowchart TD
15131
15003
  ),
15132
15004
  []
15133
15005
  );
15134
- const tempId = [props.tinaForm.id, props.input.name].join(".");
15006
+ const tempId = [tinaForm.id, input.name].join(".");
15135
15007
  const id = React.useMemo(() => uuid() + tempId, [tempId]);
15136
15008
  const ref = React.useRef(null);
15137
15009
  React.useEffect(() => {
@@ -15141,13 +15013,13 @@ flowchart TD
15141
15013
  const plateElement = (_a2 = ref.current) == null ? void 0 : _a2.querySelector(
15142
15014
  '[role="textbox"]'
15143
15015
  );
15144
- if (props.field.experimental_focusIntent && plateElement) {
15016
+ if (field.experimental_focusIntent && plateElement) {
15145
15017
  if (plateElement)
15146
15018
  plateElement.focus();
15147
15019
  }
15148
15020
  }, 100);
15149
15021
  }
15150
- }, [props.field.experimental_focusIntent, ref]);
15022
+ }, [field.experimental_focusIntent, ref]);
15151
15023
  return /* @__PURE__ */ React.createElement("div", { ref }, /* @__PURE__ */ React.createElement(
15152
15024
  plateCommon.Plate,
15153
15025
  {
@@ -15155,7 +15027,7 @@ flowchart TD
15155
15027
  initialValue,
15156
15028
  plugins: plugins$2,
15157
15029
  onChange: (value) => {
15158
- props.input.onChange({
15030
+ input.onChange({
15159
15031
  type: "root",
15160
15032
  children: value
15161
15033
  });
@@ -15164,12 +15036,12 @@ flowchart TD
15164
15036
  /* @__PURE__ */ React.createElement(TooltipProvider, null, /* @__PURE__ */ React.createElement(
15165
15037
  ToolbarProvider,
15166
15038
  {
15167
- tinaForm: props.tinaForm,
15168
- templates: props.field.templates,
15169
- overrides: (_a = props.field) == null ? void 0 : _a.toolbarOverride
15039
+ tinaForm,
15040
+ templates: field.templates,
15041
+ overrides: (field == null ? void 0 : field.toolbarOverride) ? field.toolbarOverride : field.overrides
15170
15042
  },
15171
15043
  /* @__PURE__ */ React.createElement(FixedToolbar, null, /* @__PURE__ */ React.createElement(FixedToolbarButtons, null)),
15172
- /* @__PURE__ */ React.createElement(FloatingToolbar, null, /* @__PURE__ */ React.createElement(FloatingToolbarButtons, null))
15044
+ ((_a = field == null ? void 0 : field.overrides) == null ? void 0 : _a.showFloatingToolbar) !== false ? /* @__PURE__ */ React.createElement(FloatingToolbar, null, /* @__PURE__ */ React.createElement(FloatingToolbarButtons, null)) : null
15173
15045
  ), /* @__PURE__ */ React.createElement(Editor, null))
15174
15046
  ));
15175
15047
  };