tinacms 3.3.0 → 3.3.2

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
@@ -9,9 +9,6 @@ import { z } from "zod";
9
9
  import * as React from "react";
10
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
- import { createForm, FORM_ERROR, getIn } from "final-form";
13
- import arrayMutators from "final-form-arrays";
14
- import setFieldData from "final-form-set-field-data";
15
12
  import { withRef as withRef$1, cn as cn$2, withCn, createPrimitiveElement, withVariants, withProps, useComposedRef as useComposedRef$1, PortalBody } from "@udecode/cn";
16
13
  import { HEADING_KEYS as HEADING_KEYS$1, HEADING_LEVELS as HEADING_LEVELS$1 } from "@udecode/plate-heading";
17
14
  import { isHotkey } from "is-hotkey";
@@ -37,6 +34,9 @@ import * as DropdownMenuPrimitive from "@radix-ui/react-dropdown-menu";
37
34
  import * as ToolbarPrimitive from "@radix-ui/react-toolbar";
38
35
  import * as SeparatorPrimitive from "@radix-ui/react-separator";
39
36
  import * as TooltipPrimitive from "@radix-ui/react-tooltip";
37
+ import { createForm, FORM_ERROR, getIn } from "final-form";
38
+ import arrayMutators from "final-form-arrays";
39
+ import setFieldData from "final-form-set-field-data";
40
40
  import { Field, Form as Form$1 } from "react-final-form";
41
41
  import PropTypes from "prop-types";
42
42
  import { twMerge } from "tailwind-merge";
@@ -869,1028 +869,458 @@ function useEvent(eventType) {
869
869
  subscribe: (callback) => cms.events.subscribe(eventType, callback)
870
870
  };
871
871
  }
872
- class Form {
873
- constructor({
874
- id: id2,
875
- label,
876
- fields,
877
- actions,
878
- buttons,
879
- global: global2,
880
- reset: reset2,
881
- loadInitialValues,
882
- onChange,
883
- queries,
884
- ...options
885
- }) {
886
- __publicField(this, "__type");
887
- __publicField(this, "id");
888
- __publicField(this, "label");
889
- __publicField(this, "fields");
890
- __publicField(this, "finalForm");
891
- __publicField(this, "actions");
892
- __publicField(this, "buttons");
893
- __publicField(this, "queries");
894
- __publicField(this, "global", null);
895
- __publicField(this, "loading", false);
896
- /**
897
- * @deprecated
898
- * Misleading name as per https://github.com/tinacms/tinacms/issues/5686#issuecomment-2899840518
899
- * Use path property instead.
900
- */
901
- __publicField(this, "relativePath");
902
- /**
903
- * Where to save the form within the content directory on next submission.
904
- */
905
- __publicField(this, "path");
906
- __publicField(this, "crudType");
907
- __publicField(this, "beforeSubmit");
908
- /**
909
- * Subscribes to changes to the form. The subscriber will only be called when
910
- * values specified in subscription change. A form can have many subscribers.
911
- */
912
- __publicField(this, "subscribe", (cb, options) => {
913
- return this.finalForm.subscribe(cb, options);
914
- });
915
- __publicField(this, "onSubmit");
916
- __publicField(this, "handleSubmit", async (values, form, cb) => {
917
- var _a2;
918
- try {
919
- const valOverride = await ((_a2 = this.beforeSubmit) == null ? void 0 : _a2.call(this, values));
920
- if (valOverride) {
921
- for (const [key, value] of Object.entries(valOverride)) {
922
- form.change(key, value);
923
- }
924
- }
925
- const response = await this.onSubmit(valOverride || values, form, cb);
926
- form.initialize(values);
927
- return response;
928
- } catch (error2) {
929
- return { [FORM_ERROR]: error2 };
930
- }
931
- });
932
- /**
933
- * Submits the form if there are currently no validation errors. It may
934
- * return undefined or a Promise depending on the nature of the onSubmit
935
- * configuration value given to the form when it was created.
936
- */
937
- __publicField(this, "submit", () => {
938
- return this.finalForm.submit();
939
- });
940
- const initialValues = options.initialValues || {};
941
- this.__type = options.__type || "form";
942
- this.id = id2;
943
- this.label = label;
944
- this.global = global2;
945
- this.fields = fields || [];
946
- this.onSubmit = options.onSubmit;
947
- this.queries = queries || [];
948
- this.crudType = options.crudType || "update";
949
- this.relativePath = options.relativePath || id2;
950
- this.path = options.path || id2;
951
- this.finalForm = createForm({
952
- ...options,
953
- initialValues,
954
- onSubmit: this.handleSubmit,
955
- mutators: {
956
- ...arrayMutators,
957
- setFieldData,
958
- ...options.mutators
872
+ function wrapFieldsWithMeta(Field2) {
873
+ return (props) => {
874
+ return /* @__PURE__ */ React.createElement(
875
+ FieldMeta,
876
+ {
877
+ name: props.input.name,
878
+ label: props.field.label,
879
+ description: props.field.description,
880
+ error: props.meta.error,
881
+ index: props.index,
882
+ tinaForm: props.tinaForm,
883
+ field: props.field
884
+ },
885
+ /* @__PURE__ */ React.createElement(Field2, { ...props })
886
+ );
887
+ };
888
+ }
889
+ function wrapFieldWithNoHeader(Field2) {
890
+ return (props) => {
891
+ return /* @__PURE__ */ React.createElement(
892
+ FieldMeta,
893
+ {
894
+ name: props.input.name,
895
+ label: false,
896
+ description: "",
897
+ error: props.meta.error,
898
+ index: props.index,
899
+ tinaForm: props.tinaForm
900
+ },
901
+ /* @__PURE__ */ React.createElement(Field2, { ...props })
902
+ );
903
+ };
904
+ }
905
+ function wrapFieldWithError(Field2) {
906
+ return (props) => {
907
+ return /* @__PURE__ */ React.createElement(
908
+ FieldMeta,
909
+ {
910
+ name: props.input.name,
911
+ label: false,
912
+ description: props.field.description,
913
+ error: props.meta.error,
914
+ index: props.index,
915
+ tinaForm: props.tinaForm
916
+ },
917
+ /* @__PURE__ */ React.createElement(Field2, { ...props })
918
+ );
919
+ };
920
+ }
921
+ const FieldMeta = ({
922
+ name,
923
+ label,
924
+ description,
925
+ error: error2,
926
+ margin = true,
927
+ children,
928
+ index,
929
+ tinaForm,
930
+ field,
931
+ ...props
932
+ }) => {
933
+ const { dispatch: setHoveredField } = useEvent("field:hover");
934
+ const { dispatch: setFocusedField } = useEvent("field:focus");
935
+ return /* @__PURE__ */ React.createElement(
936
+ FieldWrapper,
937
+ {
938
+ margin,
939
+ field,
940
+ onMouseOver: () => setHoveredField({ id: tinaForm.id, fieldName: name }),
941
+ onMouseOut: () => setHoveredField({ id: null, fieldName: null }),
942
+ onClick: () => setFocusedField({ id: tinaForm.id, fieldName: name }),
943
+ style: { zIndex: index ? 1e3 - index : void 0 },
944
+ ...props
945
+ },
946
+ (label !== false || description) && /* @__PURE__ */ React.createElement(FieldLabel, { name }, label !== false && /* @__PURE__ */ React.createElement(React.Fragment, null, label || name), description && /* @__PURE__ */ React.createElement(FieldDescription, null, description)),
947
+ children,
948
+ error2 && typeof error2 === "string" && /* @__PURE__ */ React.createElement(FieldError, null, error2)
949
+ );
950
+ };
951
+ const FieldWrapper = ({
952
+ margin,
953
+ children,
954
+ field,
955
+ ...props
956
+ }) => {
957
+ return /* @__PURE__ */ React.createElement(
958
+ "div",
959
+ {
960
+ className: `relative w-full px-2 ${margin ? "mb-5 last:mb-0" : ""} ${(field == null ? void 0 : field.width) === "half" ? "@sm:w-1/2" : ""}`,
961
+ ...props
962
+ },
963
+ children
964
+ );
965
+ };
966
+ const FieldLabel = ({
967
+ children,
968
+ className,
969
+ name,
970
+ ...props
971
+ }) => {
972
+ return /* @__PURE__ */ React.createElement(
973
+ "label",
974
+ {
975
+ htmlFor: name,
976
+ className: `block font-sans text-xs font-semibold text-gray-700 whitespace-normal mb-2 ${className}`,
977
+ ...props
978
+ },
979
+ children
980
+ );
981
+ };
982
+ const FieldDescription = ({
983
+ children,
984
+ className,
985
+ ...props
986
+ }) => {
987
+ if (typeof children === "string") {
988
+ return /* @__PURE__ */ React.createElement(
989
+ "span",
990
+ {
991
+ className: `block font-sans text-xs italic font-light text-gray-400 pt-0.5 whitespace-normal m-0 ${className}`,
992
+ ...props,
993
+ dangerouslySetInnerHTML: { __html: children }
959
994
  }
960
- });
961
- this._reset = reset2;
962
- this.actions = actions || [];
963
- this.buttons = buttons || {
964
- save: "Save",
965
- reset: "Reset"
966
- };
967
- this.updateFields(this.fields);
968
- if (loadInitialValues) {
969
- this.loading = true;
970
- loadInitialValues().then((initialValues2) => {
971
- this.updateInitialValues(initialValues2);
972
- }).finally(() => {
973
- this.loading = false;
974
- });
975
- }
976
- if (onChange) {
977
- let firstUpdate = true;
978
- this.subscribe(
979
- (formState) => {
980
- if (firstUpdate) {
981
- firstUpdate = false;
982
- } else {
983
- onChange(formState);
984
- }
985
- },
986
- { values: true, ...(options == null ? void 0 : options.extraSubscribeValues) || {} }
987
- );
988
- }
995
+ );
989
996
  }
990
- /**
991
- * A unique identifier for Forms.
992
- *
993
- * @deprecated use id instead
994
- */
995
- get name() {
996
- return void 0;
997
+ return /* @__PURE__ */ React.createElement(
998
+ "span",
999
+ {
1000
+ className: `block font-sans text-xs italic font-light text-gray-400 pt-0.5 whitespace-normal m-0 ${className}`,
1001
+ ...props
1002
+ },
1003
+ children
1004
+ );
1005
+ };
1006
+ const FieldError = ({
1007
+ children,
1008
+ className,
1009
+ ...props
1010
+ }) => {
1011
+ return /* @__PURE__ */ React.createElement(
1012
+ "span",
1013
+ {
1014
+ className: `block font-sans text-xs font-normal text-red-500 pt-3 animate-slide-in whitespace-normal m-0 ${className}`,
1015
+ ...props
1016
+ },
1017
+ children
1018
+ );
1019
+ };
1020
+ const EditorContext$1 = React__default.createContext({
1021
+ fieldName: "",
1022
+ rawMode: false,
1023
+ setRawMode: () => {
1024
+ },
1025
+ templates: []
1026
+ });
1027
+ const useEditorContext = () => {
1028
+ return React__default.useContext(EditorContext$1);
1029
+ };
1030
+ const useTemplates = () => {
1031
+ return React__default.useContext(EditorContext$1);
1032
+ };
1033
+ var commonjsGlobal = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : {};
1034
+ function getDefaultExportFromCjs(x) {
1035
+ return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x;
1036
+ }
1037
+ var direction_1 = direction;
1038
+ var RTL = "֑-߿יִ-﷽ﹰ-ﻼ";
1039
+ var LTR = "A-Za-zÀ-ÖØ-öø-ʸ̀-֐ࠀ-῿‎Ⰰ-﬜︀-﹯﻽-￿";
1040
+ var rtl = new RegExp("^[^" + LTR + "]*[" + RTL + "]");
1041
+ var ltr = new RegExp("^[^" + RTL + "]*[" + LTR + "]");
1042
+ function direction(value) {
1043
+ value = String(value || "");
1044
+ if (rtl.test(value)) {
1045
+ return "rtl";
997
1046
  }
998
- /**
999
- * Returns the current values of the form.
1000
- *
1001
- * if the form is still loading it returns `undefined`.
1002
- */
1003
- get values() {
1004
- if (this.loading) {
1005
- return void 0;
1047
+ if (ltr.test(value)) {
1048
+ return "ltr";
1049
+ }
1050
+ return "neutral";
1051
+ }
1052
+ const getDirection = /* @__PURE__ */ getDefaultExportFromCjs(direction_1);
1053
+ function isObject$e(value) {
1054
+ var type = typeof value;
1055
+ return value != null && (type == "object" || type == "function");
1056
+ }
1057
+ var isObject_1 = isObject$e;
1058
+ var freeGlobal$1 = typeof commonjsGlobal == "object" && commonjsGlobal && commonjsGlobal.Object === Object && commonjsGlobal;
1059
+ var _freeGlobal = freeGlobal$1;
1060
+ var freeGlobal = _freeGlobal;
1061
+ var freeSelf = typeof self == "object" && self && self.Object === Object && self;
1062
+ var root$9 = freeGlobal || freeSelf || Function("return this")();
1063
+ var _root = root$9;
1064
+ var root$8 = _root;
1065
+ var now$1 = function() {
1066
+ return root$8.Date.now();
1067
+ };
1068
+ var now_1 = now$1;
1069
+ var reWhitespace = /\s/;
1070
+ function trimmedEndIndex$1(string3) {
1071
+ var index = string3.length;
1072
+ while (index-- && reWhitespace.test(string3.charAt(index))) {
1073
+ }
1074
+ return index;
1075
+ }
1076
+ var _trimmedEndIndex = trimmedEndIndex$1;
1077
+ var trimmedEndIndex = _trimmedEndIndex;
1078
+ var reTrimStart = /^\s+/;
1079
+ function baseTrim$1(string3) {
1080
+ return string3 ? string3.slice(0, trimmedEndIndex(string3) + 1).replace(reTrimStart, "") : string3;
1081
+ }
1082
+ var _baseTrim = baseTrim$1;
1083
+ var root$7 = _root;
1084
+ var Symbol$7 = root$7.Symbol;
1085
+ var _Symbol = Symbol$7;
1086
+ var Symbol$6 = _Symbol;
1087
+ var objectProto$f = Object.prototype;
1088
+ var hasOwnProperty$c = objectProto$f.hasOwnProperty;
1089
+ var nativeObjectToString$1 = objectProto$f.toString;
1090
+ var symToStringTag$1 = Symbol$6 ? Symbol$6.toStringTag : void 0;
1091
+ function getRawTag$1(value) {
1092
+ var isOwn = hasOwnProperty$c.call(value, symToStringTag$1), tag = value[symToStringTag$1];
1093
+ try {
1094
+ value[symToStringTag$1] = void 0;
1095
+ var unmasked = true;
1096
+ } catch (e3) {
1097
+ }
1098
+ var result = nativeObjectToString$1.call(value);
1099
+ if (unmasked) {
1100
+ if (isOwn) {
1101
+ value[symToStringTag$1] = tag;
1102
+ } else {
1103
+ delete value[symToStringTag$1];
1006
1104
  }
1007
- return this.finalForm.getState().values || this.initialValues;
1008
1105
  }
1009
- /**
1010
- * The values the form was initialized with.
1011
- */
1012
- get initialValues() {
1013
- return this.finalForm.getState().initialValues;
1106
+ return result;
1107
+ }
1108
+ var _getRawTag = getRawTag$1;
1109
+ var objectProto$e = Object.prototype;
1110
+ var nativeObjectToString = objectProto$e.toString;
1111
+ function objectToString$1(value) {
1112
+ return nativeObjectToString.call(value);
1113
+ }
1114
+ var _objectToString = objectToString$1;
1115
+ var Symbol$5 = _Symbol, getRawTag = _getRawTag, objectToString = _objectToString;
1116
+ var nullTag = "[object Null]", undefinedTag = "[object Undefined]";
1117
+ var symToStringTag = Symbol$5 ? Symbol$5.toStringTag : void 0;
1118
+ function baseGetTag$6(value) {
1119
+ if (value == null) {
1120
+ return value === void 0 ? undefinedTag : nullTag;
1014
1121
  }
1015
- get pristine() {
1016
- return this.finalForm.getState().pristine;
1122
+ return symToStringTag && symToStringTag in Object(value) ? getRawTag(value) : objectToString(value);
1123
+ }
1124
+ var _baseGetTag = baseGetTag$6;
1125
+ function isObjectLike$9(value) {
1126
+ return value != null && typeof value == "object";
1127
+ }
1128
+ var isObjectLike_1 = isObjectLike$9;
1129
+ var baseGetTag$5 = _baseGetTag, isObjectLike$8 = isObjectLike_1;
1130
+ var symbolTag$3 = "[object Symbol]";
1131
+ function isSymbol$4(value) {
1132
+ return typeof value == "symbol" || isObjectLike$8(value) && baseGetTag$5(value) == symbolTag$3;
1133
+ }
1134
+ var isSymbol_1 = isSymbol$4;
1135
+ var baseTrim = _baseTrim, isObject$d = isObject_1, isSymbol$3 = isSymbol_1;
1136
+ var NAN = 0 / 0;
1137
+ var reIsBadHex = /^[-+]0x[0-9a-f]+$/i;
1138
+ var reIsBinary = /^0b[01]+$/i;
1139
+ var reIsOctal = /^0o[0-7]+$/i;
1140
+ var freeParseInt = parseInt;
1141
+ function toNumber$1(value) {
1142
+ if (typeof value == "number") {
1143
+ return value;
1017
1144
  }
1018
- get dirty() {
1019
- return this.finalForm.getState().dirty;
1145
+ if (isSymbol$3(value)) {
1146
+ return NAN;
1020
1147
  }
1021
- get submitting() {
1022
- return this.finalForm.getState().submitting;
1148
+ if (isObject$d(value)) {
1149
+ var other = typeof value.valueOf == "function" ? value.valueOf() : value;
1150
+ value = isObject$d(other) ? other + "" : other;
1023
1151
  }
1024
- get valid() {
1025
- return this.finalForm.getState().valid;
1152
+ if (typeof value != "string") {
1153
+ return value === 0 ? value : +value;
1026
1154
  }
1027
- /**
1028
- * Resets the values back to the initial values the form was initialized with.
1029
- * Or empties all the values if the form was not initialized.
1030
- */
1031
- async reset() {
1032
- if (this._reset) {
1033
- await this._reset();
1034
- }
1035
- this.finalForm.reset();
1155
+ value = baseTrim(value);
1156
+ var isBinary = reIsBinary.test(value);
1157
+ return isBinary || reIsOctal.test(value) ? freeParseInt(value.slice(2), isBinary ? 2 : 8) : reIsBadHex.test(value) ? NAN : +value;
1158
+ }
1159
+ var toNumber_1 = toNumber$1;
1160
+ var isObject$c = isObject_1, now = now_1, toNumber = toNumber_1;
1161
+ var FUNC_ERROR_TEXT$3 = "Expected a function";
1162
+ var nativeMax$1 = Math.max, nativeMin = Math.min;
1163
+ function debounce$1(func, wait, options) {
1164
+ var lastArgs, lastThis, maxWait, result, timerId, lastCallTime, lastInvokeTime = 0, leading = false, maxing = false, trailing = true;
1165
+ if (typeof func != "function") {
1166
+ throw new TypeError(FUNC_ERROR_TEXT$3);
1036
1167
  }
1037
- /**
1038
- * @deprecated Unnecessary indirection
1039
- */
1040
- updateFields(fields) {
1041
- this.fields = fields;
1168
+ wait = toNumber(wait) || 0;
1169
+ if (isObject$c(options)) {
1170
+ leading = !!options.leading;
1171
+ maxing = "maxWait" in options;
1172
+ maxWait = maxing ? nativeMax$1(toNumber(options.maxWait) || 0, wait) : maxWait;
1173
+ trailing = "trailing" in options ? !!options.trailing : trailing;
1042
1174
  }
1043
- /**
1044
- * Changes the value of the given field.
1045
- *
1046
- * @param name
1047
- * @param value
1048
- */
1049
- change(name, value) {
1050
- return this.finalForm.change(name, value);
1175
+ function invokeFunc(time2) {
1176
+ var args = lastArgs, thisArg = lastThis;
1177
+ lastArgs = lastThis = void 0;
1178
+ lastInvokeTime = time2;
1179
+ result = func.apply(thisArg, args);
1180
+ return result;
1051
1181
  }
1052
- get mutators() {
1053
- return this.finalForm.mutators;
1182
+ function leadingEdge(time2) {
1183
+ lastInvokeTime = time2;
1184
+ timerId = setTimeout(timerExpired, wait);
1185
+ return leading ? invokeFunc(time2) : result;
1054
1186
  }
1055
- addQuery(queryId) {
1056
- this.queries = [...this.queries.filter((id2) => id2 !== queryId), queryId];
1187
+ function remainingWait(time2) {
1188
+ var timeSinceLastCall = time2 - lastCallTime, timeSinceLastInvoke = time2 - lastInvokeTime, timeWaiting = wait - timeSinceLastCall;
1189
+ return maxing ? nativeMin(timeWaiting, maxWait - timeSinceLastInvoke) : timeWaiting;
1057
1190
  }
1058
- removeQuery(queryId) {
1059
- this.queries = this.queries.filter((id2) => id2 !== queryId);
1191
+ function shouldInvoke(time2) {
1192
+ var timeSinceLastCall = time2 - lastCallTime, timeSinceLastInvoke = time2 - lastInvokeTime;
1193
+ return lastCallTime === void 0 || timeSinceLastCall >= wait || timeSinceLastCall < 0 || maxing && timeSinceLastInvoke >= maxWait;
1060
1194
  }
1061
- /**
1062
- * Updates multiple fields in the form.
1063
- *
1064
- * The updates are batched so that it only triggers one `onChange` event.
1065
- *
1066
- * In order to prevent disruptions to the user's editing experience this
1067
- * function will _not_ update the value of any field that is currently
1068
- * being edited.
1069
- *
1070
- * @param values
1071
- */
1072
- updateValues(values) {
1073
- this.finalForm.batch(() => {
1074
- const activePath = this.finalForm.getState().active;
1075
- if (!activePath) {
1076
- updateEverything(this.finalForm, values);
1077
- } else {
1078
- updateSelectively(this.finalForm, values);
1079
- }
1080
- });
1195
+ function timerExpired() {
1196
+ var time2 = now();
1197
+ if (shouldInvoke(time2)) {
1198
+ return trailingEdge(time2);
1199
+ }
1200
+ timerId = setTimeout(timerExpired, remainingWait(time2));
1081
1201
  }
1082
- /**
1083
- * Replaces the initialValues of the form without deleting the current values.
1084
- *
1085
- * This function is helpful when the initialValues are loaded asynchronously.
1086
- *
1087
- * @param initialValues
1088
- */
1089
- updateInitialValues(initialValues) {
1090
- this.finalForm.batch(() => {
1091
- const values = this.values || {};
1092
- this.finalForm.initialize(initialValues);
1093
- const activePath = this.finalForm.getState().active;
1094
- if (!activePath) {
1095
- updateEverything(this.finalForm, values);
1096
- } else {
1097
- updateSelectively(this.finalForm, values);
1098
- }
1099
- });
1100
- }
1101
- /**
1102
- * Based on field's name this function will
1103
- * return an array of fields for the give form along
1104
- * with the path that it was found at top nearest
1105
- * object-like group
1106
- *
1107
- * So if you have a field named blocks.3.title
1108
- * It will return the fields from the 3rd "block"
1109
- * along with the path it was found at
1110
- * fields: [{type: 'string', name: 'title'}, ... other fields]
1111
- * activePath: ['blocks', '3']
1112
- */
1113
- getActiveField(fieldName) {
1114
- if (!fieldName) {
1115
- return this;
1202
+ function trailingEdge(time2) {
1203
+ timerId = void 0;
1204
+ if (trailing && lastArgs) {
1205
+ return invokeFunc(time2);
1116
1206
  }
1117
- const result = this.getFieldGroup({
1118
- formOrObjectField: this,
1119
- values: this.finalForm.getState().values,
1120
- namePathIndex: 0,
1121
- namePath: fieldName.split(".")
1122
- });
1207
+ lastArgs = lastThis = void 0;
1123
1208
  return result;
1124
1209
  }
1125
- getFieldGroup({
1126
- formOrObjectField,
1127
- values = {},
1128
- namePathIndex,
1129
- namePath
1130
- }) {
1131
- const name = namePath[namePathIndex];
1132
- const field = formOrObjectField.fields.find((field2) => field2.name === name);
1133
- const value = values[name];
1134
- const isLastItem = namePathIndex === namePath.length - 1;
1135
- if (!field) {
1136
- return {
1137
- ...formOrObjectField,
1138
- fields: formOrObjectField.fields.map((field2) => {
1139
- return {
1140
- ...field2,
1141
- name: [...namePath, field2.name].join(".")
1142
- };
1143
- })
1144
- };
1145
- } else {
1146
- if (field.type === "object") {
1147
- if (field.templates) {
1148
- if (field.list) {
1149
- if (isLastItem) {
1150
- return formOrObjectField;
1151
- } else {
1152
- const namePathIndexForListItem = namePathIndex + 1;
1153
- const index = namePath[namePathIndexForListItem];
1154
- const listItemValue = value[index];
1155
- const template = field.templates[listItemValue._template];
1156
- const templateName = [
1157
- ...namePath.slice(0, namePathIndexForListItem),
1158
- index
1159
- ].join(".");
1160
- const isLastItem2 = namePathIndexForListItem === namePath.length - 1;
1161
- if (!isLastItem2) {
1162
- return this.getFieldGroup({
1163
- formOrObjectField: template,
1164
- values: listItemValue,
1165
- namePath,
1166
- namePathIndex: namePathIndex + 2
1167
- });
1168
- }
1169
- if (!template) {
1170
- console.error({ field, value });
1171
- throw new Error(
1172
- `Expected template value for field ${field.name}`
1173
- );
1174
- }
1175
- return {
1176
- ...template,
1177
- name: templateName,
1178
- fields: template.fields.map((field2) => {
1179
- return {
1180
- ...field2,
1181
- name: [templateName, field2.name].join(".")
1182
- };
1183
- })
1184
- };
1185
- }
1186
- }
1187
- } else {
1188
- if (field.list) {
1189
- const namePathIndexForListItem = namePathIndex + 1;
1190
- const index = namePath[namePathIndexForListItem];
1191
- const listItemValue = value[index];
1192
- const fieldName = [
1193
- ...namePath.slice(0, namePathIndexForListItem),
1194
- index
1195
- ].join(".");
1196
- const isLastItem2 = namePathIndexForListItem === namePath.length - 1;
1197
- if (!isLastItem2) {
1198
- if (field.fields) {
1199
- return this.getFieldGroup({
1200
- formOrObjectField: field,
1201
- values: listItemValue,
1202
- namePath,
1203
- namePathIndex: namePathIndex + 2
1204
- });
1205
- }
1206
- }
1207
- return {
1208
- ...field,
1209
- name: fieldName,
1210
- fields: field.fields.map((field2) => {
1211
- return {
1212
- ...field2,
1213
- name: [fieldName, field2.name].join(".")
1214
- };
1215
- })
1216
- };
1217
- } else {
1218
- const fieldName = [...namePath.slice(0, namePathIndex + 1)].join(
1219
- "."
1220
- );
1221
- const isLastItem2 = namePathIndex === namePath.length - 1;
1222
- if (!isLastItem2) {
1223
- return this.getFieldGroup({
1224
- formOrObjectField: field,
1225
- values: value,
1226
- namePath,
1227
- namePathIndex: namePathIndex + 1
1228
- });
1229
- }
1230
- return {
1231
- ...field,
1232
- name: fieldName,
1233
- fields: field.fields.map((field2) => {
1234
- return {
1235
- ...field2,
1236
- name: [fieldName, field2.name].join(".")
1237
- };
1238
- })
1239
- };
1240
- }
1241
- }
1242
- } else if (field.type === "rich-text") {
1243
- if (isLastItem) {
1244
- return {
1245
- ...formOrObjectField,
1246
- fields: formOrObjectField.fields.map((field2) => {
1247
- return {
1248
- ...field2,
1249
- name: [...namePath.slice(0, namePathIndex), field2.name].join(
1250
- "."
1251
- )
1252
- };
1253
- })
1254
- };
1255
- } else {
1256
- const childrenIndex = namePath.findIndex(
1257
- (value2) => value2 === "children"
1258
- );
1259
- const propsIndex = namePath.slice(childrenIndex).findIndex((value2) => value2 === "props") + childrenIndex;
1260
- const itemName = namePath.slice(childrenIndex, propsIndex).join(".");
1261
- const item = getIn(value, itemName);
1262
- const props = item.props;
1263
- const templateString = item.name;
1264
- const currentPathIndex = namePathIndex + Math.max(propsIndex, 3);
1265
- const isLastItem2 = currentPathIndex + 1 === namePath.length;
1266
- const template = field.templates.find(
1267
- (t2) => t2.name === templateString
1268
- );
1269
- const templateName = namePath.slice(0, currentPathIndex + 2).join(".");
1270
- if ((item == null ? void 0 : item.type) === "img") {
1271
- const imageName = namePath.slice(0, currentPathIndex + 2).join(".");
1272
- return {
1273
- ...formOrObjectField,
1274
- // name: [formOrObjectField.name, 'img'].join('.'),
1275
- name: [imageName].join("."),
1276
- fields: [
1277
- {
1278
- type: "image",
1279
- // label: 'URL',
1280
- name: [templateName, "url"].join("."),
1281
- component: "image"
1282
- },
1283
- {
1284
- type: "string",
1285
- label: "Alt",
1286
- name: [templateName.replace(/\.props$/, ""), "alt"].join("."),
1287
- component: "text"
1288
- },
1289
- {
1290
- type: "string",
1291
- label: "Caption",
1292
- name: [templateName.replace(/\.props$/, ""), "caption"].join(
1293
- "."
1294
- ),
1295
- component: "text"
1296
- }
1297
- ]
1298
- };
1299
- }
1300
- if (!isLastItem2) {
1301
- return this.getFieldGroup({
1302
- formOrObjectField: template,
1303
- values: props,
1304
- namePath,
1305
- namePathIndex: namePathIndex + Math.max(4, childrenIndex + propsIndex)
1306
- });
1307
- }
1308
- if (!template) {
1309
- throw new Error(`Expected template value for field ${item.name}`);
1310
- }
1311
- return {
1312
- ...template,
1313
- name: templateName,
1314
- fields: template.fields.map((field2) => {
1315
- return {
1316
- ...field2,
1317
- name: [templateName, field2.name].join(".")
1318
- };
1319
- })
1320
- };
1321
- }
1322
- } else {
1323
- const fieldName = [...namePath.slice(0, namePathIndex)].join(".");
1324
- if (!fieldName) {
1325
- return formOrObjectField;
1326
- }
1327
- return {
1328
- ...formOrObjectField,
1329
- name: fieldName,
1330
- fields: formOrObjectField.fields.map((field2) => {
1331
- return {
1332
- ...field2,
1333
- name: [fieldName, field2.name].join(".")
1334
- };
1335
- })
1336
- };
1337
- }
1210
+ function cancel() {
1211
+ if (timerId !== void 0) {
1212
+ clearTimeout(timerId);
1338
1213
  }
1214
+ lastInvokeTime = 0;
1215
+ lastArgs = lastCallTime = lastThis = timerId = void 0;
1339
1216
  }
1340
- }
1341
- function updateEverything(form, values) {
1342
- Object.entries(values).forEach(([path3, value]) => {
1343
- form.change(path3, value);
1344
- });
1345
- }
1346
- function updateSelectively(form, values, prefix) {
1347
- const activePath = form.getState().active;
1348
- Object.entries(values).forEach(([name, value]) => {
1349
- const path3 = prefix ? `${prefix}.${name}` : name;
1350
- if (typeof value === "object") {
1351
- if (typeof activePath === "string" && activePath.startsWith(path3)) {
1352
- updateSelectively(form, value, path3);
1353
- } else {
1354
- form.change(path3, value);
1217
+ function flush() {
1218
+ return timerId === void 0 ? result : trailingEdge(now());
1219
+ }
1220
+ function debounced() {
1221
+ var time2 = now(), isInvoking = shouldInvoke(time2);
1222
+ lastArgs = arguments;
1223
+ lastThis = this;
1224
+ lastCallTime = time2;
1225
+ if (isInvoking) {
1226
+ if (timerId === void 0) {
1227
+ return leadingEdge(lastCallTime);
1228
+ }
1229
+ if (maxing) {
1230
+ clearTimeout(timerId);
1231
+ timerId = setTimeout(timerExpired, wait);
1232
+ return invokeFunc(lastCallTime);
1355
1233
  }
1356
- } else if (path3 !== activePath) {
1357
- form.change(path3, value);
1358
1234
  }
1359
- });
1360
- }
1361
- function usePlugins(plugins2) {
1362
- const cms = useCMS$1();
1363
- let pluginArray;
1364
- if (Array.isArray(plugins2)) {
1365
- pluginArray = plugins2;
1366
- } else {
1367
- pluginArray = [plugins2];
1235
+ if (timerId === void 0) {
1236
+ timerId = setTimeout(timerExpired, wait);
1237
+ }
1238
+ return result;
1368
1239
  }
1369
- React.useEffect(() => {
1370
- pluginArray.forEach((plugin) => {
1371
- if (plugin) {
1372
- cms.plugins.add(plugin);
1373
- }
1374
- });
1375
- return () => {
1376
- pluginArray.forEach((plugin) => {
1377
- if (plugin) {
1378
- cms.plugins.remove(plugin);
1379
- }
1380
- });
1381
- };
1382
- }, [cms.plugins, ...pluginArray]);
1240
+ debounced.cancel = cancel;
1241
+ debounced.flush = flush;
1242
+ return debounced;
1383
1243
  }
1384
- function useSubscribable(subscribable, cb) {
1385
- const [, s2] = React.useState(0);
1386
- React.useEffect(() => {
1387
- return subscribable.subscribe(() => {
1388
- s2((x) => x + 1);
1389
- if (cb)
1390
- cb();
1391
- });
1244
+ var debounce_1 = debounce$1;
1245
+ const debounce$2 = /* @__PURE__ */ getDefaultExportFromCjs(debounce_1);
1246
+ var debounce = debounce_1, isObject$b = isObject_1;
1247
+ var FUNC_ERROR_TEXT$2 = "Expected a function";
1248
+ function throttle(func, wait, options) {
1249
+ var leading = true, trailing = true;
1250
+ if (typeof func != "function") {
1251
+ throw new TypeError(FUNC_ERROR_TEXT$2);
1252
+ }
1253
+ if (isObject$b(options)) {
1254
+ leading = "leading" in options ? !!options.leading : leading;
1255
+ trailing = "trailing" in options ? !!options.trailing : trailing;
1256
+ }
1257
+ return debounce(func, wait, {
1258
+ "leading": leading,
1259
+ "maxWait": wait,
1260
+ "trailing": trailing
1392
1261
  });
1393
1262
  }
1394
- function wrapFieldsWithMeta(Field2) {
1395
- return (props) => {
1396
- return /* @__PURE__ */ React.createElement(
1397
- FieldMeta,
1398
- {
1399
- name: props.input.name,
1400
- label: props.field.label,
1401
- description: props.field.description,
1402
- error: props.meta.error,
1403
- index: props.index,
1404
- tinaForm: props.tinaForm,
1405
- field: props.field,
1406
- focusIntent: props.field.focusIntent,
1407
- hoverIntent: props.field.hoverIntent
1408
- },
1409
- /* @__PURE__ */ React.createElement(Field2, { ...props })
1410
- );
1411
- };
1412
- }
1413
- function wrapFieldWithNoHeader(Field2) {
1414
- return (props) => {
1415
- return /* @__PURE__ */ React.createElement(
1416
- FieldMeta,
1417
- {
1418
- name: props.input.name,
1419
- label: false,
1420
- description: "",
1421
- error: props.meta.error,
1422
- index: props.index,
1423
- tinaForm: props.tinaForm,
1424
- focusIntent: props.field.focusIntent,
1425
- hoverIntent: props.field.hoverIntent
1426
- },
1427
- /* @__PURE__ */ React.createElement(Field2, { ...props })
1428
- );
1429
- };
1430
- }
1431
- function wrapFieldWithError(Field2) {
1432
- return (props) => {
1433
- return /* @__PURE__ */ React.createElement(
1434
- FieldMeta,
1435
- {
1436
- name: props.input.name,
1437
- label: false,
1438
- description: props.field.description,
1439
- error: props.meta.error,
1440
- index: props.index,
1441
- tinaForm: props.tinaForm,
1442
- focusIntent: props.field.focusIntent,
1443
- hoverIntent: props.field.hoverIntent
1444
- },
1445
- /* @__PURE__ */ React.createElement(Field2, { ...props })
1446
- );
1447
- };
1448
- }
1449
- const FieldMeta = ({
1450
- name,
1451
- label,
1452
- description,
1453
- error: error2,
1454
- margin = true,
1455
- children,
1456
- index,
1457
- tinaForm,
1458
- field,
1459
- focusIntent,
1460
- hoverIntent,
1461
- ...props
1462
- }) => {
1463
- const cms = useCMS$1();
1464
- const { dispatch: setHoveredField } = useEvent("field:hover");
1465
- const { dispatch: setFocusedField } = useEvent("field:focus");
1466
- const isActive = !!focusIntent;
1467
- const isHovering = !!hoverIntent;
1468
- const handleClick = () => {
1469
- const existingForm = cms.state.forms.find(
1470
- (form) => form.tinaForm.id === tinaForm.id
1471
- );
1472
- const isAlreadyActive = (existingForm == null ? void 0 : existingForm.activeFieldName) === name;
1473
- if (isAlreadyActive) {
1474
- return;
1475
- }
1476
- setFocusedField({ id: tinaForm.id, fieldName: name });
1477
- cms.dispatch({
1478
- type: "forms:set-active-field-name",
1479
- value: { formId: tinaForm.id, fieldName: name }
1480
- });
1481
- };
1482
- return /* @__PURE__ */ React.createElement(
1483
- FieldWrapper,
1484
- {
1485
- margin,
1486
- field,
1487
- onMouseOver: () => setHoveredField({ id: tinaForm.id, fieldName: name }),
1488
- onMouseOut: () => setHoveredField({ id: null, fieldName: null }),
1489
- onClick: handleClick,
1490
- style: { zIndex: index ? 1e3 - index : void 0 },
1491
- "data-tina-field-active": isActive ? "true" : void 0,
1492
- "data-tina-field-hovering": isHovering ? "true" : void 0,
1493
- ...props
1494
- },
1495
- (label !== false || description) && /* @__PURE__ */ React.createElement(FieldLabel, { name }, label !== false && /* @__PURE__ */ React.createElement(React.Fragment, null, label || name), description && /* @__PURE__ */ React.createElement(FieldDescription, null, description)),
1496
- children,
1497
- error2 && typeof error2 === "string" && /* @__PURE__ */ React.createElement(FieldError, null, error2)
1498
- );
1499
- };
1500
- const FieldWrapper = ({
1501
- margin,
1502
- children,
1503
- field,
1504
- "data-tina-field-active": dataActive,
1505
- "data-tina-field-hovering": dataHovering,
1506
- ...props
1507
- }) => {
1508
- const isActive = dataActive === "true";
1509
- const isHovering = dataHovering === "true";
1510
- const getFieldStateClasses = () => {
1511
- const elements = ["input", "textarea", "select", ".ProseMirror"];
1512
- const buildClasses = (color) => {
1513
- return elements.map(
1514
- (el) => `[&_${el}]:!border-${color} [&_${el}]:!ring-2 [&_${el}]:!ring-${color}/20`
1515
- ).join(" ");
1516
- };
1517
- if (isActive) {
1518
- return buildClasses("tina-orange-dark");
1263
+ var throttle_1 = throttle;
1264
+ const throttle$1 = /* @__PURE__ */ getDefaultExportFromCjs(throttle_1);
1265
+ const t$2 = (t2) => "object" == typeof t2 && null != t2 && 1 === t2.nodeType, e$3 = (t2, e3) => (!e3 || "hidden" !== t2) && ("visible" !== t2 && "clip" !== t2), n$3 = (t2, n2) => {
1266
+ if (t2.clientHeight < t2.scrollHeight || t2.clientWidth < t2.scrollWidth) {
1267
+ const o3 = getComputedStyle(t2, null);
1268
+ return e$3(o3.overflowY, n2) || e$3(o3.overflowX, n2) || ((t3) => {
1269
+ const e3 = ((t4) => {
1270
+ if (!t4.ownerDocument || !t4.ownerDocument.defaultView)
1271
+ return null;
1272
+ try {
1273
+ return t4.ownerDocument.defaultView.frameElement;
1274
+ } catch (t5) {
1275
+ return null;
1276
+ }
1277
+ })(t3);
1278
+ return !!e3 && (e3.clientHeight < t3.scrollHeight || e3.clientWidth < t3.scrollWidth);
1279
+ })(t2);
1280
+ }
1281
+ return false;
1282
+ }, o$3 = (t2, e3, n2, o3, l2, r2, i2, s2) => r2 < t2 && i2 > e3 || r2 > t2 && i2 < e3 ? 0 : r2 <= t2 && s2 <= n2 || i2 >= e3 && s2 >= n2 ? r2 - t2 - o3 : i2 > e3 && s2 < n2 || r2 < t2 && s2 > n2 ? i2 - e3 + l2 : 0, l$2 = (t2) => {
1283
+ const e3 = t2.parentElement;
1284
+ return null == e3 ? t2.getRootNode().host || null : e3;
1285
+ }, r$3 = (e3, r2) => {
1286
+ var i2, s2, d2, h;
1287
+ if ("undefined" == typeof document)
1288
+ return [];
1289
+ const { scrollMode: c2, block: f2, inline: u2, boundary: a2, skipOverflowHiddenElements: g } = r2, p2 = "function" == typeof a2 ? a2 : (t2) => t2 !== a2;
1290
+ if (!t$2(e3))
1291
+ throw new TypeError("Invalid target");
1292
+ const m = document.scrollingElement || document.documentElement, w2 = [];
1293
+ let W = e3;
1294
+ for (; t$2(W) && p2(W); ) {
1295
+ if (W = l$2(W), W === m) {
1296
+ w2.push(W);
1297
+ break;
1519
1298
  }
1520
- if (isHovering) {
1521
- return buildClasses("blue-500");
1299
+ null != W && W === document.body && n$3(W) && !n$3(document.documentElement) || null != W && n$3(W, g) && w2.push(W);
1300
+ }
1301
+ const b = null != (s2 = null == (i2 = window.visualViewport) ? void 0 : i2.width) ? s2 : innerWidth, H = null != (h = null == (d2 = window.visualViewport) ? void 0 : d2.height) ? h : innerHeight, { scrollX: y, scrollY: M } = window, { height: v, width: E, top: x, right: C, bottom: I, left: R } = e3.getBoundingClientRect(), { top: T, right: B, bottom: F, left: V } = ((t2) => {
1302
+ const e4 = window.getComputedStyle(t2);
1303
+ return { top: parseFloat(e4.scrollMarginTop) || 0, right: parseFloat(e4.scrollMarginRight) || 0, bottom: parseFloat(e4.scrollMarginBottom) || 0, left: parseFloat(e4.scrollMarginLeft) || 0 };
1304
+ })(e3);
1305
+ let k = "start" === f2 || "nearest" === f2 ? x - T : "end" === f2 ? I + F : x + v / 2 - T + F, D = "center" === u2 ? R + E / 2 - V + B : "end" === u2 ? C + B : R - V;
1306
+ const L = [];
1307
+ for (let t2 = 0; t2 < w2.length; t2++) {
1308
+ const e4 = w2[t2], { height: l2, width: r3, top: i3, right: s3, bottom: d3, left: h2 } = e4.getBoundingClientRect();
1309
+ if ("if-needed" === c2 && x >= 0 && R >= 0 && I <= H && C <= b && (e4 === m && !n$3(e4) || x >= i3 && I <= d3 && R >= h2 && C <= s3))
1310
+ return L;
1311
+ const a3 = getComputedStyle(e4), g2 = parseInt(a3.borderLeftWidth, 10), p3 = parseInt(a3.borderTopWidth, 10), W2 = parseInt(a3.borderRightWidth, 10), T2 = parseInt(a3.borderBottomWidth, 10);
1312
+ let B2 = 0, F2 = 0;
1313
+ const V2 = "offsetWidth" in e4 ? e4.offsetWidth - e4.clientWidth - g2 - W2 : 0, S = "offsetHeight" in e4 ? e4.offsetHeight - e4.clientHeight - p3 - T2 : 0, X2 = "offsetWidth" in e4 ? 0 === e4.offsetWidth ? 0 : r3 / e4.offsetWidth : 0, Y = "offsetHeight" in e4 ? 0 === e4.offsetHeight ? 0 : l2 / e4.offsetHeight : 0;
1314
+ if (m === e4)
1315
+ B2 = "start" === f2 ? k : "end" === f2 ? k - H : "nearest" === f2 ? o$3(M, M + H, H, p3, T2, M + k, M + k + v, v) : k - H / 2, F2 = "start" === u2 ? D : "center" === u2 ? D - b / 2 : "end" === u2 ? D - b : o$3(y, y + b, b, g2, W2, y + D, y + D + E, E), B2 = Math.max(0, B2 + M), F2 = Math.max(0, F2 + y);
1316
+ else {
1317
+ B2 = "start" === f2 ? k - i3 - p3 : "end" === f2 ? k - d3 + T2 + S : "nearest" === f2 ? o$3(i3, d3, l2, p3, T2 + S, k, k + v, v) : k - (i3 + l2 / 2) + S / 2, F2 = "start" === u2 ? D - h2 - g2 : "center" === u2 ? D - (h2 + r3 / 2) + V2 / 2 : "end" === u2 ? D - s3 + W2 + V2 : o$3(h2, s3, r3, g2, W2 + V2, D, D + E, E);
1318
+ const { scrollLeft: t3, scrollTop: n2 } = e4;
1319
+ B2 = 0 === Y ? 0 : Math.max(0, Math.min(n2 + B2 / Y, e4.scrollHeight - l2 / Y + S)), F2 = 0 === X2 ? 0 : Math.max(0, Math.min(t3 + F2 / X2, e4.scrollWidth - r3 / X2 + V2)), k += n2 - B2, D += t3 - F2;
1522
1320
  }
1523
- return "";
1524
- };
1525
- return /* @__PURE__ */ React.createElement(
1526
- "div",
1527
- {
1528
- className: `relative w-full px-2 ${margin ? "mb-5 last:mb-0" : ""} ${(field == null ? void 0 : field.width) === "half" ? "@sm:w-1/2" : ""} ${getFieldStateClasses()}`,
1529
- "data-tina-field-active": dataActive,
1530
- "data-tina-field-hovering": dataHovering,
1531
- ...props
1532
- },
1533
- children
1534
- );
1535
- };
1536
- const FieldLabel = ({
1537
- children,
1538
- className,
1539
- name,
1540
- ...props
1541
- }) => {
1542
- return /* @__PURE__ */ React.createElement(
1543
- "label",
1544
- {
1545
- htmlFor: name,
1546
- className: `block font-sans text-xs font-semibold text-gray-700 whitespace-normal mb-2 ${className}`,
1547
- ...props
1548
- },
1549
- children
1550
- );
1551
- };
1552
- const FieldDescription = ({
1553
- children,
1554
- className,
1555
- ...props
1556
- }) => {
1557
- if (typeof children === "string") {
1558
- return /* @__PURE__ */ React.createElement(
1559
- "span",
1560
- {
1561
- className: `block font-sans text-xs italic font-light text-gray-400 pt-0.5 whitespace-normal m-0 ${className}`,
1562
- ...props,
1563
- dangerouslySetInnerHTML: { __html: children }
1564
- }
1565
- );
1566
- }
1567
- return /* @__PURE__ */ React.createElement(
1568
- "span",
1569
- {
1570
- className: `block font-sans text-xs italic font-light text-gray-400 pt-0.5 whitespace-normal m-0 ${className}`,
1571
- ...props
1572
- },
1573
- children
1574
- );
1575
- };
1576
- const FieldError = ({
1577
- children,
1578
- className,
1579
- ...props
1580
- }) => {
1581
- return /* @__PURE__ */ React.createElement(
1582
- "span",
1583
- {
1584
- className: `block font-sans text-xs font-normal text-red-500 pt-3 animate-slide-in whitespace-normal m-0 ${className}`,
1585
- ...props
1586
- },
1587
- children
1588
- );
1589
- };
1590
- const EditorContext$1 = React__default.createContext({
1591
- fieldName: "",
1592
- rawMode: false,
1593
- setRawMode: () => {
1594
- },
1595
- templates: []
1596
- });
1597
- const useEditorContext = () => {
1598
- return React__default.useContext(EditorContext$1);
1599
- };
1600
- const useTemplates = () => {
1601
- return React__default.useContext(EditorContext$1);
1602
- };
1603
- var commonjsGlobal = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : {};
1604
- function getDefaultExportFromCjs(x) {
1605
- return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x;
1606
- }
1607
- var direction_1 = direction;
1608
- var RTL = "֑-߿יִ-﷽ﹰ-ﻼ";
1609
- var LTR = "A-Za-zÀ-ÖØ-öø-ʸ̀-֐ࠀ-῿‎Ⰰ-﬜︀-﹯﻽-￿";
1610
- var rtl = new RegExp("^[^" + LTR + "]*[" + RTL + "]");
1611
- var ltr = new RegExp("^[^" + RTL + "]*[" + LTR + "]");
1612
- function direction(value) {
1613
- value = String(value || "");
1614
- if (rtl.test(value)) {
1615
- return "rtl";
1616
- }
1617
- if (ltr.test(value)) {
1618
- return "ltr";
1619
- }
1620
- return "neutral";
1621
- }
1622
- const getDirection = /* @__PURE__ */ getDefaultExportFromCjs(direction_1);
1623
- function isObject$e(value) {
1624
- var type = typeof value;
1625
- return value != null && (type == "object" || type == "function");
1626
- }
1627
- var isObject_1 = isObject$e;
1628
- var freeGlobal$1 = typeof commonjsGlobal == "object" && commonjsGlobal && commonjsGlobal.Object === Object && commonjsGlobal;
1629
- var _freeGlobal = freeGlobal$1;
1630
- var freeGlobal = _freeGlobal;
1631
- var freeSelf = typeof self == "object" && self && self.Object === Object && self;
1632
- var root$9 = freeGlobal || freeSelf || Function("return this")();
1633
- var _root = root$9;
1634
- var root$8 = _root;
1635
- var now$1 = function() {
1636
- return root$8.Date.now();
1637
- };
1638
- var now_1 = now$1;
1639
- var reWhitespace = /\s/;
1640
- function trimmedEndIndex$1(string3) {
1641
- var index = string3.length;
1642
- while (index-- && reWhitespace.test(string3.charAt(index))) {
1643
- }
1644
- return index;
1645
- }
1646
- var _trimmedEndIndex = trimmedEndIndex$1;
1647
- var trimmedEndIndex = _trimmedEndIndex;
1648
- var reTrimStart = /^\s+/;
1649
- function baseTrim$1(string3) {
1650
- return string3 ? string3.slice(0, trimmedEndIndex(string3) + 1).replace(reTrimStart, "") : string3;
1651
- }
1652
- var _baseTrim = baseTrim$1;
1653
- var root$7 = _root;
1654
- var Symbol$7 = root$7.Symbol;
1655
- var _Symbol = Symbol$7;
1656
- var Symbol$6 = _Symbol;
1657
- var objectProto$f = Object.prototype;
1658
- var hasOwnProperty$c = objectProto$f.hasOwnProperty;
1659
- var nativeObjectToString$1 = objectProto$f.toString;
1660
- var symToStringTag$1 = Symbol$6 ? Symbol$6.toStringTag : void 0;
1661
- function getRawTag$1(value) {
1662
- var isOwn = hasOwnProperty$c.call(value, symToStringTag$1), tag = value[symToStringTag$1];
1663
- try {
1664
- value[symToStringTag$1] = void 0;
1665
- var unmasked = true;
1666
- } catch (e3) {
1667
- }
1668
- var result = nativeObjectToString$1.call(value);
1669
- if (unmasked) {
1670
- if (isOwn) {
1671
- value[symToStringTag$1] = tag;
1672
- } else {
1673
- delete value[symToStringTag$1];
1674
- }
1675
- }
1676
- return result;
1677
- }
1678
- var _getRawTag = getRawTag$1;
1679
- var objectProto$e = Object.prototype;
1680
- var nativeObjectToString = objectProto$e.toString;
1681
- function objectToString$1(value) {
1682
- return nativeObjectToString.call(value);
1683
- }
1684
- var _objectToString = objectToString$1;
1685
- var Symbol$5 = _Symbol, getRawTag = _getRawTag, objectToString = _objectToString;
1686
- var nullTag = "[object Null]", undefinedTag = "[object Undefined]";
1687
- var symToStringTag = Symbol$5 ? Symbol$5.toStringTag : void 0;
1688
- function baseGetTag$6(value) {
1689
- if (value == null) {
1690
- return value === void 0 ? undefinedTag : nullTag;
1691
- }
1692
- return symToStringTag && symToStringTag in Object(value) ? getRawTag(value) : objectToString(value);
1693
- }
1694
- var _baseGetTag = baseGetTag$6;
1695
- function isObjectLike$9(value) {
1696
- return value != null && typeof value == "object";
1697
- }
1698
- var isObjectLike_1 = isObjectLike$9;
1699
- var baseGetTag$5 = _baseGetTag, isObjectLike$8 = isObjectLike_1;
1700
- var symbolTag$3 = "[object Symbol]";
1701
- function isSymbol$4(value) {
1702
- return typeof value == "symbol" || isObjectLike$8(value) && baseGetTag$5(value) == symbolTag$3;
1703
- }
1704
- var isSymbol_1 = isSymbol$4;
1705
- var baseTrim = _baseTrim, isObject$d = isObject_1, isSymbol$3 = isSymbol_1;
1706
- var NAN = 0 / 0;
1707
- var reIsBadHex = /^[-+]0x[0-9a-f]+$/i;
1708
- var reIsBinary = /^0b[01]+$/i;
1709
- var reIsOctal = /^0o[0-7]+$/i;
1710
- var freeParseInt = parseInt;
1711
- function toNumber$1(value) {
1712
- if (typeof value == "number") {
1713
- return value;
1714
- }
1715
- if (isSymbol$3(value)) {
1716
- return NAN;
1717
- }
1718
- if (isObject$d(value)) {
1719
- var other = typeof value.valueOf == "function" ? value.valueOf() : value;
1720
- value = isObject$d(other) ? other + "" : other;
1721
- }
1722
- if (typeof value != "string") {
1723
- return value === 0 ? value : +value;
1724
- }
1725
- value = baseTrim(value);
1726
- var isBinary = reIsBinary.test(value);
1727
- return isBinary || reIsOctal.test(value) ? freeParseInt(value.slice(2), isBinary ? 2 : 8) : reIsBadHex.test(value) ? NAN : +value;
1728
- }
1729
- var toNumber_1 = toNumber$1;
1730
- var isObject$c = isObject_1, now = now_1, toNumber = toNumber_1;
1731
- var FUNC_ERROR_TEXT$3 = "Expected a function";
1732
- var nativeMax$1 = Math.max, nativeMin = Math.min;
1733
- function debounce$1(func, wait, options) {
1734
- var lastArgs, lastThis, maxWait, result, timerId, lastCallTime, lastInvokeTime = 0, leading = false, maxing = false, trailing = true;
1735
- if (typeof func != "function") {
1736
- throw new TypeError(FUNC_ERROR_TEXT$3);
1737
- }
1738
- wait = toNumber(wait) || 0;
1739
- if (isObject$c(options)) {
1740
- leading = !!options.leading;
1741
- maxing = "maxWait" in options;
1742
- maxWait = maxing ? nativeMax$1(toNumber(options.maxWait) || 0, wait) : maxWait;
1743
- trailing = "trailing" in options ? !!options.trailing : trailing;
1744
- }
1745
- function invokeFunc(time2) {
1746
- var args = lastArgs, thisArg = lastThis;
1747
- lastArgs = lastThis = void 0;
1748
- lastInvokeTime = time2;
1749
- result = func.apply(thisArg, args);
1750
- return result;
1751
- }
1752
- function leadingEdge(time2) {
1753
- lastInvokeTime = time2;
1754
- timerId = setTimeout(timerExpired, wait);
1755
- return leading ? invokeFunc(time2) : result;
1756
- }
1757
- function remainingWait(time2) {
1758
- var timeSinceLastCall = time2 - lastCallTime, timeSinceLastInvoke = time2 - lastInvokeTime, timeWaiting = wait - timeSinceLastCall;
1759
- return maxing ? nativeMin(timeWaiting, maxWait - timeSinceLastInvoke) : timeWaiting;
1760
- }
1761
- function shouldInvoke(time2) {
1762
- var timeSinceLastCall = time2 - lastCallTime, timeSinceLastInvoke = time2 - lastInvokeTime;
1763
- return lastCallTime === void 0 || timeSinceLastCall >= wait || timeSinceLastCall < 0 || maxing && timeSinceLastInvoke >= maxWait;
1764
- }
1765
- function timerExpired() {
1766
- var time2 = now();
1767
- if (shouldInvoke(time2)) {
1768
- return trailingEdge(time2);
1769
- }
1770
- timerId = setTimeout(timerExpired, remainingWait(time2));
1771
- }
1772
- function trailingEdge(time2) {
1773
- timerId = void 0;
1774
- if (trailing && lastArgs) {
1775
- return invokeFunc(time2);
1776
- }
1777
- lastArgs = lastThis = void 0;
1778
- return result;
1779
- }
1780
- function cancel() {
1781
- if (timerId !== void 0) {
1782
- clearTimeout(timerId);
1783
- }
1784
- lastInvokeTime = 0;
1785
- lastArgs = lastCallTime = lastThis = timerId = void 0;
1786
- }
1787
- function flush() {
1788
- return timerId === void 0 ? result : trailingEdge(now());
1789
- }
1790
- function debounced() {
1791
- var time2 = now(), isInvoking = shouldInvoke(time2);
1792
- lastArgs = arguments;
1793
- lastThis = this;
1794
- lastCallTime = time2;
1795
- if (isInvoking) {
1796
- if (timerId === void 0) {
1797
- return leadingEdge(lastCallTime);
1798
- }
1799
- if (maxing) {
1800
- clearTimeout(timerId);
1801
- timerId = setTimeout(timerExpired, wait);
1802
- return invokeFunc(lastCallTime);
1803
- }
1804
- }
1805
- if (timerId === void 0) {
1806
- timerId = setTimeout(timerExpired, wait);
1807
- }
1808
- return result;
1809
- }
1810
- debounced.cancel = cancel;
1811
- debounced.flush = flush;
1812
- return debounced;
1813
- }
1814
- var debounce_1 = debounce$1;
1815
- const debounce$2 = /* @__PURE__ */ getDefaultExportFromCjs(debounce_1);
1816
- var debounce = debounce_1, isObject$b = isObject_1;
1817
- var FUNC_ERROR_TEXT$2 = "Expected a function";
1818
- function throttle(func, wait, options) {
1819
- var leading = true, trailing = true;
1820
- if (typeof func != "function") {
1821
- throw new TypeError(FUNC_ERROR_TEXT$2);
1822
- }
1823
- if (isObject$b(options)) {
1824
- leading = "leading" in options ? !!options.leading : leading;
1825
- trailing = "trailing" in options ? !!options.trailing : trailing;
1826
- }
1827
- return debounce(func, wait, {
1828
- "leading": leading,
1829
- "maxWait": wait,
1830
- "trailing": trailing
1831
- });
1832
- }
1833
- var throttle_1 = throttle;
1834
- const throttle$1 = /* @__PURE__ */ getDefaultExportFromCjs(throttle_1);
1835
- const t$2 = (t2) => "object" == typeof t2 && null != t2 && 1 === t2.nodeType, e$3 = (t2, e3) => (!e3 || "hidden" !== t2) && ("visible" !== t2 && "clip" !== t2), n$3 = (t2, n2) => {
1836
- if (t2.clientHeight < t2.scrollHeight || t2.clientWidth < t2.scrollWidth) {
1837
- const o3 = getComputedStyle(t2, null);
1838
- return e$3(o3.overflowY, n2) || e$3(o3.overflowX, n2) || ((t3) => {
1839
- const e3 = ((t4) => {
1840
- if (!t4.ownerDocument || !t4.ownerDocument.defaultView)
1841
- return null;
1842
- try {
1843
- return t4.ownerDocument.defaultView.frameElement;
1844
- } catch (t5) {
1845
- return null;
1846
- }
1847
- })(t3);
1848
- return !!e3 && (e3.clientHeight < t3.scrollHeight || e3.clientWidth < t3.scrollWidth);
1849
- })(t2);
1850
- }
1851
- return false;
1852
- }, o$3 = (t2, e3, n2, o3, l2, r2, i2, s2) => r2 < t2 && i2 > e3 || r2 > t2 && i2 < e3 ? 0 : r2 <= t2 && s2 <= n2 || i2 >= e3 && s2 >= n2 ? r2 - t2 - o3 : i2 > e3 && s2 < n2 || r2 < t2 && s2 > n2 ? i2 - e3 + l2 : 0, l$2 = (t2) => {
1853
- const e3 = t2.parentElement;
1854
- return null == e3 ? t2.getRootNode().host || null : e3;
1855
- }, r$3 = (e3, r2) => {
1856
- var i2, s2, d2, h;
1857
- if ("undefined" == typeof document)
1858
- return [];
1859
- const { scrollMode: c2, block: f2, inline: u2, boundary: a2, skipOverflowHiddenElements: g } = r2, p2 = "function" == typeof a2 ? a2 : (t2) => t2 !== a2;
1860
- if (!t$2(e3))
1861
- throw new TypeError("Invalid target");
1862
- const m = document.scrollingElement || document.documentElement, w2 = [];
1863
- let W = e3;
1864
- for (; t$2(W) && p2(W); ) {
1865
- if (W = l$2(W), W === m) {
1866
- w2.push(W);
1867
- break;
1868
- }
1869
- null != W && W === document.body && n$3(W) && !n$3(document.documentElement) || null != W && n$3(W, g) && w2.push(W);
1870
- }
1871
- const b = null != (s2 = null == (i2 = window.visualViewport) ? void 0 : i2.width) ? s2 : innerWidth, H = null != (h = null == (d2 = window.visualViewport) ? void 0 : d2.height) ? h : innerHeight, { scrollX: y, scrollY: M } = window, { height: v, width: E, top: x, right: C, bottom: I, left: R } = e3.getBoundingClientRect(), { top: T, right: B, bottom: F, left: V } = ((t2) => {
1872
- const e4 = window.getComputedStyle(t2);
1873
- return { top: parseFloat(e4.scrollMarginTop) || 0, right: parseFloat(e4.scrollMarginRight) || 0, bottom: parseFloat(e4.scrollMarginBottom) || 0, left: parseFloat(e4.scrollMarginLeft) || 0 };
1874
- })(e3);
1875
- let k = "start" === f2 || "nearest" === f2 ? x - T : "end" === f2 ? I + F : x + v / 2 - T + F, D = "center" === u2 ? R + E / 2 - V + B : "end" === u2 ? C + B : R - V;
1876
- const L = [];
1877
- for (let t2 = 0; t2 < w2.length; t2++) {
1878
- const e4 = w2[t2], { height: l2, width: r3, top: i3, right: s3, bottom: d3, left: h2 } = e4.getBoundingClientRect();
1879
- if ("if-needed" === c2 && x >= 0 && R >= 0 && I <= H && C <= b && (e4 === m && !n$3(e4) || x >= i3 && I <= d3 && R >= h2 && C <= s3))
1880
- return L;
1881
- const a3 = getComputedStyle(e4), g2 = parseInt(a3.borderLeftWidth, 10), p3 = parseInt(a3.borderTopWidth, 10), W2 = parseInt(a3.borderRightWidth, 10), T2 = parseInt(a3.borderBottomWidth, 10);
1882
- let B2 = 0, F2 = 0;
1883
- const V2 = "offsetWidth" in e4 ? e4.offsetWidth - e4.clientWidth - g2 - W2 : 0, S = "offsetHeight" in e4 ? e4.offsetHeight - e4.clientHeight - p3 - T2 : 0, X2 = "offsetWidth" in e4 ? 0 === e4.offsetWidth ? 0 : r3 / e4.offsetWidth : 0, Y = "offsetHeight" in e4 ? 0 === e4.offsetHeight ? 0 : l2 / e4.offsetHeight : 0;
1884
- if (m === e4)
1885
- B2 = "start" === f2 ? k : "end" === f2 ? k - H : "nearest" === f2 ? o$3(M, M + H, H, p3, T2, M + k, M + k + v, v) : k - H / 2, F2 = "start" === u2 ? D : "center" === u2 ? D - b / 2 : "end" === u2 ? D - b : o$3(y, y + b, b, g2, W2, y + D, y + D + E, E), B2 = Math.max(0, B2 + M), F2 = Math.max(0, F2 + y);
1886
- else {
1887
- B2 = "start" === f2 ? k - i3 - p3 : "end" === f2 ? k - d3 + T2 + S : "nearest" === f2 ? o$3(i3, d3, l2, p3, T2 + S, k, k + v, v) : k - (i3 + l2 / 2) + S / 2, F2 = "start" === u2 ? D - h2 - g2 : "center" === u2 ? D - (h2 + r3 / 2) + V2 / 2 : "end" === u2 ? D - s3 + W2 + V2 : o$3(h2, s3, r3, g2, W2 + V2, D, D + E, E);
1888
- const { scrollLeft: t3, scrollTop: n2 } = e4;
1889
- B2 = 0 === Y ? 0 : Math.max(0, Math.min(n2 + B2 / Y, e4.scrollHeight - l2 / Y + S)), F2 = 0 === X2 ? 0 : Math.max(0, Math.min(t3 + F2 / X2, e4.scrollWidth - r3 / X2 + V2)), k += n2 - B2, D += t3 - F2;
1890
- }
1891
- L.push({ el: e4, top: B2, left: F2 });
1892
- }
1893
- return L;
1321
+ L.push({ el: e4, top: B2, left: F2 });
1322
+ }
1323
+ return L;
1894
1324
  };
1895
1325
  const o$2 = (t2) => false === t2 ? { block: "end", inline: "nearest" } : ((t3) => t3 === Object(t3) && 0 !== Object.keys(t3).length)(t2) ? t2 : { block: "start", inline: "nearest" };
1896
1326
  function e$2(e3, r2) {
@@ -37895,408 +37325,929 @@ const TableElement = withHOC(
37895
37325
  if (readOnly || !selected) {
37896
37326
  return content;
37897
37327
  }
37898
- return /* @__PURE__ */ React__default.createElement(TableFloatingToolbar, null, content);
37899
- })
37900
- );
37901
- const TableFloatingToolbar = withRef$1(
37902
- ({ children, ...props }, ref) => {
37903
- const { tf } = useEditorPlugin(TablePlugin);
37904
- const element = useElement();
37905
- const { props: buttonProps } = useRemoveNodeButton({ element });
37906
- const collapsed = useEditorSelector(
37907
- (editor) => !editor.api.isExpanded(),
37908
- []
37909
- );
37910
- const { canMerge, canSplit } = useTableMergeState();
37911
- return /* @__PURE__ */ React__default.createElement(Popover$3, { open: canMerge || canSplit || collapsed, modal: false }, /* @__PURE__ */ React__default.createElement(PopoverAnchor, { asChild: true }, children), /* @__PURE__ */ React__default.createElement(
37912
- PopoverContent$2,
37913
- {
37914
- ref,
37915
- asChild: true,
37916
- onOpenAutoFocus: (e3) => e3.preventDefault(),
37917
- contentEditable: false,
37918
- ...props
37919
- },
37920
- /* @__PURE__ */ React__default.createElement(
37921
- Toolbar,
37922
- {
37923
- className: "scrollbar-hide flex w-auto max-w-[80vw] flex-row overflow-x-auto rounded-md border bg-popover p-1 shadow-md print:hidden",
37924
- contentEditable: false
37925
- },
37926
- /* @__PURE__ */ React__default.createElement(ToolbarGroup, null, /* @__PURE__ */ React__default.createElement(ColorDropdownMenu, { tooltip: "Background color" }, /* @__PURE__ */ React__default.createElement(PaintBucketIcon, null)), canMerge && /* @__PURE__ */ React__default.createElement(
37927
- ToolbarButton,
37928
- {
37929
- onClick: () => tf.table.merge(),
37930
- onMouseDown: (e3) => e3.preventDefault(),
37931
- tooltip: "Merge cells"
37932
- },
37933
- /* @__PURE__ */ React__default.createElement(CombineIcon, null)
37934
- ), canSplit && /* @__PURE__ */ React__default.createElement(
37935
- ToolbarButton,
37936
- {
37937
- onClick: () => tf.table.split(),
37938
- onMouseDown: (e3) => e3.preventDefault(),
37939
- tooltip: "Split cell"
37940
- },
37941
- /* @__PURE__ */ React__default.createElement(SquareSplitHorizontalIcon, null)
37942
- ), /* @__PURE__ */ React__default.createElement(DropdownMenu$1, { modal: false }, /* @__PURE__ */ React__default.createElement(DropdownMenuTrigger$1, { asChild: true }, /* @__PURE__ */ React__default.createElement(ToolbarButton, { tooltip: "Cell borders" }, /* @__PURE__ */ React__default.createElement(Grid2X2Icon, null))), /* @__PURE__ */ React__default.createElement(DropdownMenuPortal, null, /* @__PURE__ */ React__default.createElement(TableBordersDropdownMenuContent, null))), collapsed && /* @__PURE__ */ React__default.createElement(ToolbarGroup, null, /* @__PURE__ */ React__default.createElement(ToolbarButton, { tooltip: "Delete table", ...buttonProps }, /* @__PURE__ */ React__default.createElement(Trash2Icon, null)))),
37943
- collapsed && /* @__PURE__ */ React__default.createElement(ToolbarGroup, null, /* @__PURE__ */ React__default.createElement(
37944
- ToolbarButton,
37945
- {
37946
- onClick: () => {
37947
- tf.insert.tableRow({ before: true });
37948
- },
37949
- onMouseDown: (e3) => e3.preventDefault(),
37950
- tooltip: "Insert row before"
37951
- },
37952
- /* @__PURE__ */ React__default.createElement(ArrowUp, null)
37953
- ), /* @__PURE__ */ React__default.createElement(
37954
- ToolbarButton,
37955
- {
37956
- onClick: () => {
37957
- tf.insert.tableRow();
37958
- },
37959
- onMouseDown: (e3) => e3.preventDefault(),
37960
- tooltip: "Insert row after"
37961
- },
37962
- /* @__PURE__ */ React__default.createElement(ArrowDown, null)
37963
- ), /* @__PURE__ */ React__default.createElement(
37964
- ToolbarButton,
37965
- {
37966
- onClick: () => {
37967
- tf.remove.tableRow();
37968
- },
37969
- onMouseDown: (e3) => e3.preventDefault(),
37970
- tooltip: "Delete row"
37971
- },
37972
- /* @__PURE__ */ React__default.createElement(XIcon, null)
37973
- )),
37974
- collapsed && /* @__PURE__ */ React__default.createElement(ToolbarGroup, null, /* @__PURE__ */ React__default.createElement(
37975
- ToolbarButton,
37976
- {
37977
- onClick: () => {
37978
- tf.insert.tableColumn({ before: true });
37979
- },
37980
- onMouseDown: (e3) => e3.preventDefault(),
37981
- tooltip: "Insert column before"
37982
- },
37983
- /* @__PURE__ */ React__default.createElement(ArrowLeft, null)
37984
- ), /* @__PURE__ */ React__default.createElement(
37985
- ToolbarButton,
37986
- {
37987
- onClick: () => {
37988
- tf.insert.tableColumn();
37989
- },
37990
- onMouseDown: (e3) => e3.preventDefault(),
37991
- tooltip: "Insert column after"
37992
- },
37993
- /* @__PURE__ */ React__default.createElement(ArrowRight, null)
37994
- ), /* @__PURE__ */ React__default.createElement(
37995
- ToolbarButton,
37996
- {
37997
- onClick: () => {
37998
- tf.remove.tableColumn();
37999
- },
38000
- onMouseDown: (e3) => e3.preventDefault(),
38001
- tooltip: "Delete column"
38002
- },
38003
- /* @__PURE__ */ React__default.createElement(XIcon, null)
38004
- ))
38005
- )
38006
- ));
37328
+ return /* @__PURE__ */ React__default.createElement(TableFloatingToolbar, null, content);
37329
+ })
37330
+ );
37331
+ const TableFloatingToolbar = withRef$1(
37332
+ ({ children, ...props }, ref) => {
37333
+ const { tf } = useEditorPlugin(TablePlugin);
37334
+ const element = useElement();
37335
+ const { props: buttonProps } = useRemoveNodeButton({ element });
37336
+ const collapsed = useEditorSelector(
37337
+ (editor) => !editor.api.isExpanded(),
37338
+ []
37339
+ );
37340
+ const { canMerge, canSplit } = useTableMergeState();
37341
+ return /* @__PURE__ */ React__default.createElement(Popover$3, { open: canMerge || canSplit || collapsed, modal: false }, /* @__PURE__ */ React__default.createElement(PopoverAnchor, { asChild: true }, children), /* @__PURE__ */ React__default.createElement(
37342
+ PopoverContent$2,
37343
+ {
37344
+ ref,
37345
+ asChild: true,
37346
+ onOpenAutoFocus: (e3) => e3.preventDefault(),
37347
+ contentEditable: false,
37348
+ ...props
37349
+ },
37350
+ /* @__PURE__ */ React__default.createElement(
37351
+ Toolbar,
37352
+ {
37353
+ className: "scrollbar-hide flex w-auto max-w-[80vw] flex-row overflow-x-auto rounded-md border bg-popover p-1 shadow-md print:hidden",
37354
+ contentEditable: false
37355
+ },
37356
+ /* @__PURE__ */ React__default.createElement(ToolbarGroup, null, /* @__PURE__ */ React__default.createElement(ColorDropdownMenu, { tooltip: "Background color" }, /* @__PURE__ */ React__default.createElement(PaintBucketIcon, null)), canMerge && /* @__PURE__ */ React__default.createElement(
37357
+ ToolbarButton,
37358
+ {
37359
+ onClick: () => tf.table.merge(),
37360
+ onMouseDown: (e3) => e3.preventDefault(),
37361
+ tooltip: "Merge cells"
37362
+ },
37363
+ /* @__PURE__ */ React__default.createElement(CombineIcon, null)
37364
+ ), canSplit && /* @__PURE__ */ React__default.createElement(
37365
+ ToolbarButton,
37366
+ {
37367
+ onClick: () => tf.table.split(),
37368
+ onMouseDown: (e3) => e3.preventDefault(),
37369
+ tooltip: "Split cell"
37370
+ },
37371
+ /* @__PURE__ */ React__default.createElement(SquareSplitHorizontalIcon, null)
37372
+ ), /* @__PURE__ */ React__default.createElement(DropdownMenu$1, { modal: false }, /* @__PURE__ */ React__default.createElement(DropdownMenuTrigger$1, { asChild: true }, /* @__PURE__ */ React__default.createElement(ToolbarButton, { tooltip: "Cell borders" }, /* @__PURE__ */ React__default.createElement(Grid2X2Icon, null))), /* @__PURE__ */ React__default.createElement(DropdownMenuPortal, null, /* @__PURE__ */ React__default.createElement(TableBordersDropdownMenuContent, null))), collapsed && /* @__PURE__ */ React__default.createElement(ToolbarGroup, null, /* @__PURE__ */ React__default.createElement(ToolbarButton, { tooltip: "Delete table", ...buttonProps }, /* @__PURE__ */ React__default.createElement(Trash2Icon, null)))),
37373
+ collapsed && /* @__PURE__ */ React__default.createElement(ToolbarGroup, null, /* @__PURE__ */ React__default.createElement(
37374
+ ToolbarButton,
37375
+ {
37376
+ onClick: () => {
37377
+ tf.insert.tableRow({ before: true });
37378
+ },
37379
+ onMouseDown: (e3) => e3.preventDefault(),
37380
+ tooltip: "Insert row before"
37381
+ },
37382
+ /* @__PURE__ */ React__default.createElement(ArrowUp, null)
37383
+ ), /* @__PURE__ */ React__default.createElement(
37384
+ ToolbarButton,
37385
+ {
37386
+ onClick: () => {
37387
+ tf.insert.tableRow();
37388
+ },
37389
+ onMouseDown: (e3) => e3.preventDefault(),
37390
+ tooltip: "Insert row after"
37391
+ },
37392
+ /* @__PURE__ */ React__default.createElement(ArrowDown, null)
37393
+ ), /* @__PURE__ */ React__default.createElement(
37394
+ ToolbarButton,
37395
+ {
37396
+ onClick: () => {
37397
+ tf.remove.tableRow();
37398
+ },
37399
+ onMouseDown: (e3) => e3.preventDefault(),
37400
+ tooltip: "Delete row"
37401
+ },
37402
+ /* @__PURE__ */ React__default.createElement(XIcon, null)
37403
+ )),
37404
+ collapsed && /* @__PURE__ */ React__default.createElement(ToolbarGroup, null, /* @__PURE__ */ React__default.createElement(
37405
+ ToolbarButton,
37406
+ {
37407
+ onClick: () => {
37408
+ tf.insert.tableColumn({ before: true });
37409
+ },
37410
+ onMouseDown: (e3) => e3.preventDefault(),
37411
+ tooltip: "Insert column before"
37412
+ },
37413
+ /* @__PURE__ */ React__default.createElement(ArrowLeft, null)
37414
+ ), /* @__PURE__ */ React__default.createElement(
37415
+ ToolbarButton,
37416
+ {
37417
+ onClick: () => {
37418
+ tf.insert.tableColumn();
37419
+ },
37420
+ onMouseDown: (e3) => e3.preventDefault(),
37421
+ tooltip: "Insert column after"
37422
+ },
37423
+ /* @__PURE__ */ React__default.createElement(ArrowRight, null)
37424
+ ), /* @__PURE__ */ React__default.createElement(
37425
+ ToolbarButton,
37426
+ {
37427
+ onClick: () => {
37428
+ tf.remove.tableColumn();
37429
+ },
37430
+ onMouseDown: (e3) => e3.preventDefault(),
37431
+ tooltip: "Delete column"
37432
+ },
37433
+ /* @__PURE__ */ React__default.createElement(XIcon, null)
37434
+ ))
37435
+ )
37436
+ ));
37437
+ }
37438
+ );
37439
+ const TableBordersDropdownMenuContent = withRef$1((props, ref) => {
37440
+ const editor = useEditorRef();
37441
+ const {
37442
+ getOnSelectTableBorder,
37443
+ hasBottomBorder,
37444
+ hasLeftBorder,
37445
+ hasNoBorders,
37446
+ hasOuterBorders,
37447
+ hasRightBorder,
37448
+ hasTopBorder
37449
+ } = useTableBordersDropdownMenuContentState();
37450
+ return /* @__PURE__ */ React__default.createElement(
37451
+ DropdownMenuContent$1,
37452
+ {
37453
+ ref,
37454
+ className: cn$2("min-w-[220px]"),
37455
+ onCloseAutoFocus: (e3) => {
37456
+ e3.preventDefault();
37457
+ editor.tf.focus();
37458
+ },
37459
+ align: "start",
37460
+ side: "right",
37461
+ sideOffset: 0,
37462
+ ...props
37463
+ },
37464
+ /* @__PURE__ */ React__default.createElement(DropdownMenuGroup, null, /* @__PURE__ */ React__default.createElement(
37465
+ DropdownMenuCheckboxItem,
37466
+ {
37467
+ checked: hasTopBorder,
37468
+ onCheckedChange: getOnSelectTableBorder("top")
37469
+ },
37470
+ /* @__PURE__ */ React__default.createElement("div", null, "Top Border")
37471
+ ), /* @__PURE__ */ React__default.createElement(
37472
+ DropdownMenuCheckboxItem,
37473
+ {
37474
+ checked: hasRightBorder,
37475
+ onCheckedChange: getOnSelectTableBorder("right")
37476
+ },
37477
+ /* @__PURE__ */ React__default.createElement("div", null, "Right Border")
37478
+ ), /* @__PURE__ */ React__default.createElement(
37479
+ DropdownMenuCheckboxItem,
37480
+ {
37481
+ checked: hasBottomBorder,
37482
+ onCheckedChange: getOnSelectTableBorder("bottom")
37483
+ },
37484
+ /* @__PURE__ */ React__default.createElement("div", null, "Bottom Border")
37485
+ ), /* @__PURE__ */ React__default.createElement(
37486
+ DropdownMenuCheckboxItem,
37487
+ {
37488
+ checked: hasLeftBorder,
37489
+ onCheckedChange: getOnSelectTableBorder("left")
37490
+ },
37491
+ /* @__PURE__ */ React__default.createElement("div", null, "Left Border")
37492
+ )),
37493
+ /* @__PURE__ */ React__default.createElement(DropdownMenuGroup, null, /* @__PURE__ */ React__default.createElement(
37494
+ DropdownMenuCheckboxItem,
37495
+ {
37496
+ checked: hasNoBorders,
37497
+ onCheckedChange: getOnSelectTableBorder("none")
37498
+ },
37499
+ /* @__PURE__ */ React__default.createElement("div", null, "No Border")
37500
+ ), /* @__PURE__ */ React__default.createElement(
37501
+ DropdownMenuCheckboxItem,
37502
+ {
37503
+ checked: hasOuterBorders,
37504
+ onCheckedChange: getOnSelectTableBorder("outer")
37505
+ },
37506
+ /* @__PURE__ */ React__default.createElement("div", null, "Outside Borders")
37507
+ ))
37508
+ );
37509
+ });
37510
+ function ColorDropdownMenu({ children, tooltip }) {
37511
+ const [open, setOpen] = useState(false);
37512
+ const editor = useEditorRef();
37513
+ const selectedCells = usePluginOption(TablePlugin, "selectedCells");
37514
+ useCallback(
37515
+ (color) => {
37516
+ setOpen(false);
37517
+ setCellBackground(editor, { color, selectedCells: selectedCells ?? [] });
37518
+ },
37519
+ [selectedCells, editor]
37520
+ );
37521
+ const onClearColor = useCallback(() => {
37522
+ setOpen(false);
37523
+ setCellBackground(editor, {
37524
+ color: null,
37525
+ selectedCells: selectedCells ?? []
37526
+ });
37527
+ }, [selectedCells, editor]);
37528
+ return /* @__PURE__ */ React__default.createElement(DropdownMenu$1, { open, onOpenChange: setOpen, modal: false }, /* @__PURE__ */ React__default.createElement(DropdownMenuTrigger$1, { asChild: true }, /* @__PURE__ */ React__default.createElement(ToolbarButton, { tooltip }, children)), /* @__PURE__ */ React__default.createElement(DropdownMenuContent$1, { align: "start" }, /* @__PURE__ */ React__default.createElement(DropdownMenuGroup, null, /* @__PURE__ */ React__default.createElement(DropdownMenuItem$1, { className: "p-2", onClick: onClearColor }, /* @__PURE__ */ React__default.createElement(EraserIcon, null), /* @__PURE__ */ React__default.createElement("span", null, "Clear")))));
37529
+ }
37530
+ const TableRowElement = withRef$1(
37531
+ ({ children, className, ...props }, ref) => {
37532
+ const selected = useSelected();
37533
+ return /* @__PURE__ */ React__default.createElement(
37534
+ PlateElement,
37535
+ {
37536
+ as: "tr",
37537
+ className: cn$2(className, "group/row"),
37538
+ "data-selected": selected ? "true" : void 0,
37539
+ ...props
37540
+ },
37541
+ children
37542
+ );
37543
+ }
37544
+ );
37545
+ function classNames$1(...classes) {
37546
+ return classes.filter(Boolean).join(" ");
37547
+ }
37548
+ const uuid = () => {
37549
+ return ([1e7] + -1e3 + -4e3 + -8e3 + -1e11).replace(
37550
+ /[018]/g,
37551
+ (c2) => (c2 ^ crypto.getRandomValues(new Uint8Array(1))[0] & 15 >> c2 / 4).toString(16)
37552
+ );
37553
+ };
37554
+ const blockClasses = "mt-0.5";
37555
+ const headerClasses = "font-normal";
37556
+ const Components = () => {
37557
+ return {
37558
+ [SlashInputPlugin.key]: SlashInputElement,
37559
+ [HEADING_KEYS$1.h1]: ({
37560
+ attributes,
37561
+ editor,
37562
+ element,
37563
+ className,
37564
+ ...props
37565
+ }) => /* @__PURE__ */ React__default.createElement(
37566
+ "h1",
37567
+ {
37568
+ ...attributes,
37569
+ ...props,
37570
+ className: classNames$1(
37571
+ headerClasses,
37572
+ blockClasses,
37573
+ className,
37574
+ "text-4xl mb-4 last:mb-0 mt-6 first:mt-0 font-libre-baskerville"
37575
+ )
37576
+ }
37577
+ ),
37578
+ [HEADING_KEYS$1.h2]: ({
37579
+ attributes,
37580
+ editor,
37581
+ element,
37582
+ className,
37583
+ ...props
37584
+ }) => /* @__PURE__ */ React__default.createElement(
37585
+ "h2",
37586
+ {
37587
+ ...attributes,
37588
+ ...props,
37589
+ className: classNames$1(
37590
+ headerClasses,
37591
+ blockClasses,
37592
+ className,
37593
+ "text-3xl mb-4 last:mb-0 mt-6 first:mt-0 font-libre-baskerville"
37594
+ )
37595
+ }
37596
+ ),
37597
+ [HEADING_KEYS$1.h3]: ({
37598
+ attributes,
37599
+ editor,
37600
+ element,
37601
+ className,
37602
+ ...props
37603
+ }) => /* @__PURE__ */ React__default.createElement(
37604
+ "h3",
37605
+ {
37606
+ ...attributes,
37607
+ ...props,
37608
+ className: classNames$1(
37609
+ headerClasses,
37610
+ blockClasses,
37611
+ className,
37612
+ "text-2xl mb-4 last:mb-0 mt-6 first:mt-0 font-libre-baskerville"
37613
+ )
37614
+ }
37615
+ ),
37616
+ [HEADING_KEYS$1.h4]: ({
37617
+ attributes,
37618
+ editor,
37619
+ element,
37620
+ className,
37621
+ ...props
37622
+ }) => /* @__PURE__ */ React__default.createElement(
37623
+ "h4",
37624
+ {
37625
+ ...attributes,
37626
+ ...props,
37627
+ className: classNames$1(
37628
+ headerClasses,
37629
+ blockClasses,
37630
+ className,
37631
+ "text-xl mb-4 last:mb-0 mt-6 first:mt-0 font-libre-baskerville"
37632
+ )
37633
+ }
37634
+ ),
37635
+ /** Tailwind prose doesn't style h5 and h6 elements */
37636
+ [HEADING_KEYS$1.h5]: ({
37637
+ attributes,
37638
+ editor,
37639
+ element,
37640
+ className,
37641
+ ...props
37642
+ }) => /* @__PURE__ */ React__default.createElement(
37643
+ "h5",
37644
+ {
37645
+ ...attributes,
37646
+ ...props,
37647
+ className: classNames$1(
37648
+ headerClasses,
37649
+ blockClasses,
37650
+ className,
37651
+ "text-lg mb-4 last:mb-0 mt-6 first:mt-0"
37652
+ ),
37653
+ style: { fontFamily: "'Libre Baskerville', serif", fontWeight: "400" }
37654
+ }
37655
+ ),
37656
+ [HEADING_KEYS$1.h6]: ({
37657
+ attributes,
37658
+ editor,
37659
+ element,
37660
+ className,
37661
+ ...props
37662
+ }) => /* @__PURE__ */ React__default.createElement(
37663
+ "h6",
37664
+ {
37665
+ ...attributes,
37666
+ ...props,
37667
+ className: classNames$1(
37668
+ headerClasses,
37669
+ blockClasses,
37670
+ className,
37671
+ "text-base mb-4 last:mb-0 mt-6 first:mt-0"
37672
+ ),
37673
+ style: { fontFamily: "'Libre Baskerville', serif", fontWeight: "400" }
37674
+ }
37675
+ ),
37676
+ [ParagraphPlugin.key]: ParagraphElement,
37677
+ [BlockquotePlugin.key]: BlockquoteElement,
37678
+ [CodeBlockPlugin.key]: CodeBlockElement,
37679
+ [CodeLinePlugin.key]: CodeLineElement,
37680
+ [CodeSyntaxPlugin.key]: CodeSyntaxLeaf,
37681
+ html: ({ attributes, editor, element, children, className }) => {
37682
+ return /* @__PURE__ */ React__default.createElement(
37683
+ "div",
37684
+ {
37685
+ ...attributes,
37686
+ className: classNames$1(
37687
+ "font-mono text-sm bg-green-100 cursor-not-allowed mb-4",
37688
+ className
37689
+ )
37690
+ },
37691
+ children,
37692
+ element.value
37693
+ );
37694
+ },
37695
+ html_inline: ({ attributes, editor, element, children, className }) => {
37696
+ return /* @__PURE__ */ React__default.createElement(
37697
+ "span",
37698
+ {
37699
+ ...attributes,
37700
+ className: classNames$1(
37701
+ "font-mono bg-green-100 cursor-not-allowed",
37702
+ className
37703
+ )
37704
+ },
37705
+ children,
37706
+ element.value
37707
+ );
37708
+ },
37709
+ [BulletedListPlugin.key]: withProps(ListElement, { variant: "ul" }),
37710
+ [NumberedListPlugin.key]: withProps(ListElement, { variant: "ol" }),
37711
+ [ListItemPlugin.key]: withProps(PlateElement, { as: "li" }),
37712
+ [LinkPlugin.key]: LinkElement,
37713
+ [CodePlugin.key]: CodeLeaf,
37714
+ [UnderlinePlugin.key]: withProps(PlateLeaf, { as: "u" }),
37715
+ [StrikethroughPlugin.key]: withProps(PlateLeaf, { as: "s" }),
37716
+ [ItalicPlugin.key]: withProps(PlateLeaf, { as: "em" }),
37717
+ [BoldPlugin.key]: withProps(PlateLeaf, { as: "strong" }),
37718
+ [HorizontalRulePlugin.key]: HrElement,
37719
+ [TableCellHeaderPlugin.key]: TableCellHeaderElement,
37720
+ [TableCellPlugin.key]: TableCellElement,
37721
+ [TablePlugin.key]: TableElement,
37722
+ [TableRowPlugin.key]: TableRowElement
37723
+ };
37724
+ };
37725
+ class Form {
37726
+ constructor({
37727
+ id: id2,
37728
+ label,
37729
+ fields,
37730
+ actions,
37731
+ buttons,
37732
+ global: global2,
37733
+ reset: reset2,
37734
+ loadInitialValues,
37735
+ onChange,
37736
+ queries,
37737
+ ...options
37738
+ }) {
37739
+ __publicField(this, "__type");
37740
+ __publicField(this, "id");
37741
+ __publicField(this, "label");
37742
+ __publicField(this, "fields");
37743
+ __publicField(this, "finalForm");
37744
+ __publicField(this, "actions");
37745
+ __publicField(this, "buttons");
37746
+ __publicField(this, "queries");
37747
+ __publicField(this, "global", null);
37748
+ __publicField(this, "loading", false);
37749
+ /**
37750
+ * @deprecated
37751
+ * Misleading name as per https://github.com/tinacms/tinacms/issues/5686#issuecomment-2899840518
37752
+ * Use path property instead.
37753
+ */
37754
+ __publicField(this, "relativePath");
37755
+ /**
37756
+ * Where to save the form within the content directory on next submission.
37757
+ */
37758
+ __publicField(this, "path");
37759
+ __publicField(this, "crudType");
37760
+ __publicField(this, "beforeSubmit");
37761
+ /**
37762
+ * Subscribes to changes to the form. The subscriber will only be called when
37763
+ * values specified in subscription change. A form can have many subscribers.
37764
+ */
37765
+ __publicField(this, "subscribe", (cb, options) => {
37766
+ return this.finalForm.subscribe(cb, options);
37767
+ });
37768
+ __publicField(this, "onSubmit");
37769
+ __publicField(this, "handleSubmit", async (values, form, cb) => {
37770
+ var _a2;
37771
+ try {
37772
+ const valOverride = await ((_a2 = this.beforeSubmit) == null ? void 0 : _a2.call(this, values));
37773
+ if (valOverride) {
37774
+ for (const [key, value] of Object.entries(valOverride)) {
37775
+ form.change(key, value);
37776
+ }
37777
+ }
37778
+ const response = await this.onSubmit(valOverride || values, form, cb);
37779
+ form.initialize(values);
37780
+ return response;
37781
+ } catch (error2) {
37782
+ return { [FORM_ERROR]: error2 };
37783
+ }
37784
+ });
37785
+ /**
37786
+ * Submits the form if there are currently no validation errors. It may
37787
+ * return undefined or a Promise depending on the nature of the onSubmit
37788
+ * configuration value given to the form when it was created.
37789
+ */
37790
+ __publicField(this, "submit", () => {
37791
+ return this.finalForm.submit();
37792
+ });
37793
+ const initialValues = options.initialValues || {};
37794
+ this.__type = options.__type || "form";
37795
+ this.id = id2;
37796
+ this.label = label;
37797
+ this.global = global2;
37798
+ this.fields = fields || [];
37799
+ this.onSubmit = options.onSubmit;
37800
+ this.queries = queries || [];
37801
+ this.crudType = options.crudType || "update";
37802
+ this.relativePath = options.relativePath || id2;
37803
+ this.path = options.path || id2;
37804
+ this.finalForm = createForm({
37805
+ ...options,
37806
+ initialValues,
37807
+ onSubmit: this.handleSubmit,
37808
+ mutators: {
37809
+ ...arrayMutators,
37810
+ setFieldData,
37811
+ ...options.mutators
37812
+ }
37813
+ });
37814
+ this._reset = reset2;
37815
+ this.actions = actions || [];
37816
+ this.buttons = buttons || {
37817
+ save: "Save",
37818
+ reset: "Reset"
37819
+ };
37820
+ this.updateFields(this.fields);
37821
+ if (loadInitialValues) {
37822
+ this.loading = true;
37823
+ loadInitialValues().then((initialValues2) => {
37824
+ this.updateInitialValues(initialValues2);
37825
+ }).finally(() => {
37826
+ this.loading = false;
37827
+ });
37828
+ }
37829
+ if (onChange) {
37830
+ let firstUpdate = true;
37831
+ this.subscribe(
37832
+ (formState) => {
37833
+ if (firstUpdate) {
37834
+ firstUpdate = false;
37835
+ } else {
37836
+ onChange(formState);
37837
+ }
37838
+ },
37839
+ { values: true, ...(options == null ? void 0 : options.extraSubscribeValues) || {} }
37840
+ );
37841
+ }
37842
+ }
37843
+ /**
37844
+ * A unique identifier for Forms.
37845
+ *
37846
+ * @deprecated use id instead
37847
+ */
37848
+ get name() {
37849
+ return void 0;
37850
+ }
37851
+ /**
37852
+ * Returns the current values of the form.
37853
+ *
37854
+ * if the form is still loading it returns `undefined`.
37855
+ */
37856
+ get values() {
37857
+ if (this.loading) {
37858
+ return void 0;
37859
+ }
37860
+ return this.finalForm.getState().values || this.initialValues;
37861
+ }
37862
+ /**
37863
+ * The values the form was initialized with.
37864
+ */
37865
+ get initialValues() {
37866
+ return this.finalForm.getState().initialValues;
37867
+ }
37868
+ get pristine() {
37869
+ return this.finalForm.getState().pristine;
37870
+ }
37871
+ get dirty() {
37872
+ return this.finalForm.getState().dirty;
37873
+ }
37874
+ get submitting() {
37875
+ return this.finalForm.getState().submitting;
37876
+ }
37877
+ get valid() {
37878
+ return this.finalForm.getState().valid;
37879
+ }
37880
+ /**
37881
+ * Resets the values back to the initial values the form was initialized with.
37882
+ * Or empties all the values if the form was not initialized.
37883
+ */
37884
+ async reset() {
37885
+ if (this._reset) {
37886
+ await this._reset();
37887
+ }
37888
+ this.finalForm.reset();
37889
+ }
37890
+ /**
37891
+ * @deprecated Unnecessary indirection
37892
+ */
37893
+ updateFields(fields) {
37894
+ this.fields = fields;
37895
+ }
37896
+ /**
37897
+ * Changes the value of the given field.
37898
+ *
37899
+ * @param name
37900
+ * @param value
37901
+ */
37902
+ change(name, value) {
37903
+ return this.finalForm.change(name, value);
37904
+ }
37905
+ get mutators() {
37906
+ return this.finalForm.mutators;
37907
+ }
37908
+ addQuery(queryId) {
37909
+ this.queries = [...this.queries.filter((id2) => id2 !== queryId), queryId];
37910
+ }
37911
+ removeQuery(queryId) {
37912
+ this.queries = this.queries.filter((id2) => id2 !== queryId);
37913
+ }
37914
+ /**
37915
+ * Updates multiple fields in the form.
37916
+ *
37917
+ * The updates are batched so that it only triggers one `onChange` event.
37918
+ *
37919
+ * In order to prevent disruptions to the user's editing experience this
37920
+ * function will _not_ update the value of any field that is currently
37921
+ * being edited.
37922
+ *
37923
+ * @param values
37924
+ */
37925
+ updateValues(values) {
37926
+ this.finalForm.batch(() => {
37927
+ const activePath = this.finalForm.getState().active;
37928
+ if (!activePath) {
37929
+ updateEverything(this.finalForm, values);
37930
+ } else {
37931
+ updateSelectively(this.finalForm, values);
37932
+ }
37933
+ });
37934
+ }
37935
+ /**
37936
+ * Replaces the initialValues of the form without deleting the current values.
37937
+ *
37938
+ * This function is helpful when the initialValues are loaded asynchronously.
37939
+ *
37940
+ * @param initialValues
37941
+ */
37942
+ updateInitialValues(initialValues) {
37943
+ this.finalForm.batch(() => {
37944
+ const values = this.values || {};
37945
+ this.finalForm.initialize(initialValues);
37946
+ const activePath = this.finalForm.getState().active;
37947
+ if (!activePath) {
37948
+ updateEverything(this.finalForm, values);
37949
+ } else {
37950
+ updateSelectively(this.finalForm, values);
37951
+ }
37952
+ });
37953
+ }
37954
+ /**
37955
+ * Based on field's name this function will
37956
+ * return an array of fields for the give form along
37957
+ * with the path that it was found at top nearest
37958
+ * object-like group
37959
+ *
37960
+ * So if you have a field named blocks.3.title
37961
+ * It will return the fields from the 3rd "block"
37962
+ * along with the path it was found at
37963
+ * fields: [{type: 'string', name: 'title'}, ... other fields]
37964
+ * activePath: ['blocks', '3']
37965
+ */
37966
+ getActiveField(fieldName) {
37967
+ if (!fieldName) {
37968
+ return this;
37969
+ }
37970
+ const result = this.getFieldGroup({
37971
+ formOrObjectField: this,
37972
+ values: this.finalForm.getState().values,
37973
+ namePathIndex: 0,
37974
+ namePath: fieldName.split(".")
37975
+ });
37976
+ return result;
37977
+ }
37978
+ getFieldGroup({
37979
+ formOrObjectField,
37980
+ values = {},
37981
+ namePathIndex,
37982
+ namePath
37983
+ }) {
37984
+ const name = namePath[namePathIndex];
37985
+ const field = formOrObjectField.fields.find((field2) => field2.name === name);
37986
+ const value = values[name];
37987
+ const isLastItem = namePathIndex === namePath.length - 1;
37988
+ if (!field) {
37989
+ return {
37990
+ ...formOrObjectField,
37991
+ fields: formOrObjectField.fields.map((field2) => {
37992
+ return {
37993
+ ...field2,
37994
+ name: [...namePath, field2.name].join(".")
37995
+ };
37996
+ })
37997
+ };
37998
+ } else {
37999
+ if (field.type === "object") {
38000
+ if (field.templates) {
38001
+ if (field.list) {
38002
+ if (isLastItem) {
38003
+ return formOrObjectField;
38004
+ } else {
38005
+ const namePathIndexForListItem = namePathIndex + 1;
38006
+ const index = namePath[namePathIndexForListItem];
38007
+ const listItemValue = value[index];
38008
+ const template = field.templates[listItemValue._template];
38009
+ const templateName = [
38010
+ ...namePath.slice(0, namePathIndexForListItem),
38011
+ index
38012
+ ].join(".");
38013
+ const isLastItem2 = namePathIndexForListItem === namePath.length - 1;
38014
+ if (!isLastItem2) {
38015
+ return this.getFieldGroup({
38016
+ formOrObjectField: template,
38017
+ values: listItemValue,
38018
+ namePath,
38019
+ namePathIndex: namePathIndex + 2
38020
+ });
38021
+ }
38022
+ if (!template) {
38023
+ console.error({ field, value });
38024
+ throw new Error(
38025
+ `Expected template value for field ${field.name}`
38026
+ );
38027
+ }
38028
+ return {
38029
+ ...template,
38030
+ name: templateName,
38031
+ fields: template.fields.map((field2) => {
38032
+ return {
38033
+ ...field2,
38034
+ name: [templateName, field2.name].join(".")
38035
+ };
38036
+ })
38037
+ };
38038
+ }
38039
+ }
38040
+ } else {
38041
+ if (field.list) {
38042
+ const namePathIndexForListItem = namePathIndex + 1;
38043
+ const index = namePath[namePathIndexForListItem];
38044
+ const listItemValue = value[index];
38045
+ const fieldName = [
38046
+ ...namePath.slice(0, namePathIndexForListItem),
38047
+ index
38048
+ ].join(".");
38049
+ const isLastItem2 = namePathIndexForListItem === namePath.length - 1;
38050
+ if (!isLastItem2) {
38051
+ if (field.fields) {
38052
+ return this.getFieldGroup({
38053
+ formOrObjectField: field,
38054
+ values: listItemValue,
38055
+ namePath,
38056
+ namePathIndex: namePathIndex + 2
38057
+ });
38058
+ }
38059
+ }
38060
+ return {
38061
+ ...field,
38062
+ name: fieldName,
38063
+ fields: field.fields.map((field2) => {
38064
+ return {
38065
+ ...field2,
38066
+ name: [fieldName, field2.name].join(".")
38067
+ };
38068
+ })
38069
+ };
38070
+ } else {
38071
+ const fieldName = [...namePath.slice(0, namePathIndex + 1)].join(
38072
+ "."
38073
+ );
38074
+ const isLastItem2 = namePathIndex === namePath.length - 1;
38075
+ if (!isLastItem2) {
38076
+ return this.getFieldGroup({
38077
+ formOrObjectField: field,
38078
+ values: value,
38079
+ namePath,
38080
+ namePathIndex: namePathIndex + 1
38081
+ });
38082
+ }
38083
+ return {
38084
+ ...field,
38085
+ name: fieldName,
38086
+ fields: field.fields.map((field2) => {
38087
+ return {
38088
+ ...field2,
38089
+ name: [fieldName, field2.name].join(".")
38090
+ };
38091
+ })
38092
+ };
38093
+ }
38094
+ }
38095
+ } else if (field.type === "rich-text") {
38096
+ if (isLastItem) {
38097
+ return {
38098
+ ...formOrObjectField,
38099
+ fields: formOrObjectField.fields.map((field2) => {
38100
+ return {
38101
+ ...field2,
38102
+ name: [...namePath.slice(0, namePathIndex), field2.name].join(
38103
+ "."
38104
+ )
38105
+ };
38106
+ })
38107
+ };
38108
+ } else {
38109
+ const childrenIndex = namePath.findIndex(
38110
+ (value2) => value2 === "children"
38111
+ );
38112
+ const propsIndex = namePath.slice(childrenIndex).findIndex((value2) => value2 === "props") + childrenIndex;
38113
+ const itemName = namePath.slice(childrenIndex, propsIndex).join(".");
38114
+ const item = getIn(value, itemName);
38115
+ const props = item.props;
38116
+ const templateString = item.name;
38117
+ const currentPathIndex = namePathIndex + Math.max(propsIndex, 3);
38118
+ const isLastItem2 = currentPathIndex + 1 === namePath.length;
38119
+ const template = field.templates.find(
38120
+ (t2) => t2.name === templateString
38121
+ );
38122
+ const templateName = namePath.slice(0, currentPathIndex + 2).join(".");
38123
+ if ((item == null ? void 0 : item.type) === "img") {
38124
+ const imageName = namePath.slice(0, currentPathIndex + 2).join(".");
38125
+ return {
38126
+ ...formOrObjectField,
38127
+ // name: [formOrObjectField.name, 'img'].join('.'),
38128
+ name: [imageName].join("."),
38129
+ fields: [
38130
+ {
38131
+ type: "image",
38132
+ // label: 'URL',
38133
+ name: [templateName, "url"].join("."),
38134
+ component: "image"
38135
+ },
38136
+ {
38137
+ type: "string",
38138
+ label: "Alt",
38139
+ name: [templateName.replace(/\.props$/, ""), "alt"].join("."),
38140
+ component: "text"
38141
+ },
38142
+ {
38143
+ type: "string",
38144
+ label: "Caption",
38145
+ name: [templateName.replace(/\.props$/, ""), "caption"].join(
38146
+ "."
38147
+ ),
38148
+ component: "text"
38149
+ }
38150
+ ]
38151
+ };
38152
+ }
38153
+ if (!isLastItem2) {
38154
+ return this.getFieldGroup({
38155
+ formOrObjectField: template,
38156
+ values: props,
38157
+ namePath,
38158
+ namePathIndex: namePathIndex + Math.max(4, childrenIndex + propsIndex)
38159
+ });
38160
+ }
38161
+ if (!template) {
38162
+ throw new Error(`Expected template value for field ${item.name}`);
38163
+ }
38164
+ return {
38165
+ ...template,
38166
+ name: templateName,
38167
+ fields: template.fields.map((field2) => {
38168
+ return {
38169
+ ...field2,
38170
+ name: [templateName, field2.name].join(".")
38171
+ };
38172
+ })
38173
+ };
38174
+ }
38175
+ } else {
38176
+ const fieldName = [...namePath.slice(0, namePathIndex)].join(".");
38177
+ if (!fieldName) {
38178
+ return formOrObjectField;
38179
+ }
38180
+ return {
38181
+ ...formOrObjectField,
38182
+ name: fieldName,
38183
+ fields: formOrObjectField.fields.map((field2) => {
38184
+ return {
38185
+ ...field2,
38186
+ name: [fieldName, field2.name].join(".")
38187
+ };
38188
+ })
38189
+ };
38190
+ }
38191
+ }
38007
38192
  }
38008
- );
38009
- const TableBordersDropdownMenuContent = withRef$1((props, ref) => {
38010
- const editor = useEditorRef();
38011
- const {
38012
- getOnSelectTableBorder,
38013
- hasBottomBorder,
38014
- hasLeftBorder,
38015
- hasNoBorders,
38016
- hasOuterBorders,
38017
- hasRightBorder,
38018
- hasTopBorder
38019
- } = useTableBordersDropdownMenuContentState();
38020
- return /* @__PURE__ */ React__default.createElement(
38021
- DropdownMenuContent$1,
38022
- {
38023
- ref,
38024
- className: cn$2("min-w-[220px]"),
38025
- onCloseAutoFocus: (e3) => {
38026
- e3.preventDefault();
38027
- editor.tf.focus();
38028
- },
38029
- align: "start",
38030
- side: "right",
38031
- sideOffset: 0,
38032
- ...props
38033
- },
38034
- /* @__PURE__ */ React__default.createElement(DropdownMenuGroup, null, /* @__PURE__ */ React__default.createElement(
38035
- DropdownMenuCheckboxItem,
38036
- {
38037
- checked: hasTopBorder,
38038
- onCheckedChange: getOnSelectTableBorder("top")
38039
- },
38040
- /* @__PURE__ */ React__default.createElement("div", null, "Top Border")
38041
- ), /* @__PURE__ */ React__default.createElement(
38042
- DropdownMenuCheckboxItem,
38043
- {
38044
- checked: hasRightBorder,
38045
- onCheckedChange: getOnSelectTableBorder("right")
38046
- },
38047
- /* @__PURE__ */ React__default.createElement("div", null, "Right Border")
38048
- ), /* @__PURE__ */ React__default.createElement(
38049
- DropdownMenuCheckboxItem,
38050
- {
38051
- checked: hasBottomBorder,
38052
- onCheckedChange: getOnSelectTableBorder("bottom")
38053
- },
38054
- /* @__PURE__ */ React__default.createElement("div", null, "Bottom Border")
38055
- ), /* @__PURE__ */ React__default.createElement(
38056
- DropdownMenuCheckboxItem,
38057
- {
38058
- checked: hasLeftBorder,
38059
- onCheckedChange: getOnSelectTableBorder("left")
38060
- },
38061
- /* @__PURE__ */ React__default.createElement("div", null, "Left Border")
38062
- )),
38063
- /* @__PURE__ */ React__default.createElement(DropdownMenuGroup, null, /* @__PURE__ */ React__default.createElement(
38064
- DropdownMenuCheckboxItem,
38065
- {
38066
- checked: hasNoBorders,
38067
- onCheckedChange: getOnSelectTableBorder("none")
38068
- },
38069
- /* @__PURE__ */ React__default.createElement("div", null, "No Border")
38070
- ), /* @__PURE__ */ React__default.createElement(
38071
- DropdownMenuCheckboxItem,
38072
- {
38073
- checked: hasOuterBorders,
38074
- onCheckedChange: getOnSelectTableBorder("outer")
38075
- },
38076
- /* @__PURE__ */ React__default.createElement("div", null, "Outside Borders")
38077
- ))
38078
- );
38079
- });
38080
- function ColorDropdownMenu({ children, tooltip }) {
38081
- const [open, setOpen] = useState(false);
38082
- const editor = useEditorRef();
38083
- const selectedCells = usePluginOption(TablePlugin, "selectedCells");
38084
- useCallback(
38085
- (color) => {
38086
- setOpen(false);
38087
- setCellBackground(editor, { color, selectedCells: selectedCells ?? [] });
38088
- },
38089
- [selectedCells, editor]
38090
- );
38091
- const onClearColor = useCallback(() => {
38092
- setOpen(false);
38093
- setCellBackground(editor, {
38094
- color: null,
38095
- selectedCells: selectedCells ?? []
38096
- });
38097
- }, [selectedCells, editor]);
38098
- return /* @__PURE__ */ React__default.createElement(DropdownMenu$1, { open, onOpenChange: setOpen, modal: false }, /* @__PURE__ */ React__default.createElement(DropdownMenuTrigger$1, { asChild: true }, /* @__PURE__ */ React__default.createElement(ToolbarButton, { tooltip }, children)), /* @__PURE__ */ React__default.createElement(DropdownMenuContent$1, { align: "start" }, /* @__PURE__ */ React__default.createElement(DropdownMenuGroup, null, /* @__PURE__ */ React__default.createElement(DropdownMenuItem$1, { className: "p-2", onClick: onClearColor }, /* @__PURE__ */ React__default.createElement(EraserIcon, null), /* @__PURE__ */ React__default.createElement("span", null, "Clear")))));
38099
38193
  }
38100
- const TableRowElement = withRef$1(
38101
- ({ children, className, ...props }, ref) => {
38102
- const selected = useSelected();
38103
- return /* @__PURE__ */ React__default.createElement(
38104
- PlateElement,
38105
- {
38106
- as: "tr",
38107
- className: cn$2(className, "group/row"),
38108
- "data-selected": selected ? "true" : void 0,
38109
- ...props
38110
- },
38111
- children
38112
- );
38113
- }
38114
- );
38115
- function classNames$1(...classes) {
38116
- return classes.filter(Boolean).join(" ");
38194
+ function updateEverything(form, values) {
38195
+ Object.entries(values).forEach(([path3, value]) => {
38196
+ form.change(path3, value);
38197
+ });
38117
38198
  }
38118
- const uuid = () => {
38119
- return ([1e7] + -1e3 + -4e3 + -8e3 + -1e11).replace(
38120
- /[018]/g,
38121
- (c2) => (c2 ^ crypto.getRandomValues(new Uint8Array(1))[0] & 15 >> c2 / 4).toString(16)
38122
- );
38123
- };
38124
- const blockClasses = "mt-0.5";
38125
- const headerClasses = "font-normal";
38126
- const Components = () => {
38127
- return {
38128
- [SlashInputPlugin.key]: SlashInputElement,
38129
- [HEADING_KEYS$1.h1]: ({
38130
- attributes,
38131
- editor,
38132
- element,
38133
- className,
38134
- ...props
38135
- }) => /* @__PURE__ */ React__default.createElement(
38136
- "h1",
38137
- {
38138
- ...attributes,
38139
- ...props,
38140
- className: classNames$1(
38141
- headerClasses,
38142
- blockClasses,
38143
- className,
38144
- "text-4xl mb-4 last:mb-0 mt-6 first:mt-0 font-libre-baskerville"
38145
- )
38146
- }
38147
- ),
38148
- [HEADING_KEYS$1.h2]: ({
38149
- attributes,
38150
- editor,
38151
- element,
38152
- className,
38153
- ...props
38154
- }) => /* @__PURE__ */ React__default.createElement(
38155
- "h2",
38156
- {
38157
- ...attributes,
38158
- ...props,
38159
- className: classNames$1(
38160
- headerClasses,
38161
- blockClasses,
38162
- className,
38163
- "text-3xl mb-4 last:mb-0 mt-6 first:mt-0 font-libre-baskerville"
38164
- )
38165
- }
38166
- ),
38167
- [HEADING_KEYS$1.h3]: ({
38168
- attributes,
38169
- editor,
38170
- element,
38171
- className,
38172
- ...props
38173
- }) => /* @__PURE__ */ React__default.createElement(
38174
- "h3",
38175
- {
38176
- ...attributes,
38177
- ...props,
38178
- className: classNames$1(
38179
- headerClasses,
38180
- blockClasses,
38181
- className,
38182
- "text-2xl mb-4 last:mb-0 mt-6 first:mt-0 font-libre-baskerville"
38183
- )
38184
- }
38185
- ),
38186
- [HEADING_KEYS$1.h4]: ({
38187
- attributes,
38188
- editor,
38189
- element,
38190
- className,
38191
- ...props
38192
- }) => /* @__PURE__ */ React__default.createElement(
38193
- "h4",
38194
- {
38195
- ...attributes,
38196
- ...props,
38197
- className: classNames$1(
38198
- headerClasses,
38199
- blockClasses,
38200
- className,
38201
- "text-xl mb-4 last:mb-0 mt-6 first:mt-0 font-libre-baskerville"
38202
- )
38203
- }
38204
- ),
38205
- /** Tailwind prose doesn't style h5 and h6 elements */
38206
- [HEADING_KEYS$1.h5]: ({
38207
- attributes,
38208
- editor,
38209
- element,
38210
- className,
38211
- ...props
38212
- }) => /* @__PURE__ */ React__default.createElement(
38213
- "h5",
38214
- {
38215
- ...attributes,
38216
- ...props,
38217
- className: classNames$1(
38218
- headerClasses,
38219
- blockClasses,
38220
- className,
38221
- "text-lg mb-4 last:mb-0 mt-6 first:mt-0"
38222
- ),
38223
- style: { fontFamily: "'Libre Baskerville', serif", fontWeight: "400" }
38199
+ function updateSelectively(form, values, prefix) {
38200
+ const activePath = form.getState().active;
38201
+ Object.entries(values).forEach(([name, value]) => {
38202
+ const path3 = prefix ? `${prefix}.${name}` : name;
38203
+ if (typeof value === "object") {
38204
+ if (typeof activePath === "string" && activePath.startsWith(path3)) {
38205
+ updateSelectively(form, value, path3);
38206
+ } else {
38207
+ form.change(path3, value);
38224
38208
  }
38225
- ),
38226
- [HEADING_KEYS$1.h6]: ({
38227
- attributes,
38228
- editor,
38229
- element,
38230
- className,
38231
- ...props
38232
- }) => /* @__PURE__ */ React__default.createElement(
38233
- "h6",
38234
- {
38235
- ...attributes,
38236
- ...props,
38237
- className: classNames$1(
38238
- headerClasses,
38239
- blockClasses,
38240
- className,
38241
- "text-base mb-4 last:mb-0 mt-6 first:mt-0"
38242
- ),
38243
- style: { fontFamily: "'Libre Baskerville', serif", fontWeight: "400" }
38209
+ } else if (path3 !== activePath) {
38210
+ form.change(path3, value);
38211
+ }
38212
+ });
38213
+ }
38214
+ function usePlugins(plugins2) {
38215
+ const cms = useCMS$1();
38216
+ let pluginArray;
38217
+ if (Array.isArray(plugins2)) {
38218
+ pluginArray = plugins2;
38219
+ } else {
38220
+ pluginArray = [plugins2];
38221
+ }
38222
+ React.useEffect(() => {
38223
+ pluginArray.forEach((plugin) => {
38224
+ if (plugin) {
38225
+ cms.plugins.add(plugin);
38244
38226
  }
38245
- ),
38246
- [ParagraphPlugin.key]: ParagraphElement,
38247
- [BlockquotePlugin.key]: BlockquoteElement,
38248
- [CodeBlockPlugin.key]: CodeBlockElement,
38249
- [CodeLinePlugin.key]: CodeLineElement,
38250
- [CodeSyntaxPlugin.key]: CodeSyntaxLeaf,
38251
- html: ({ attributes, editor, element, children, className }) => {
38252
- return /* @__PURE__ */ React__default.createElement(
38253
- "div",
38254
- {
38255
- ...attributes,
38256
- className: classNames$1(
38257
- "font-mono text-sm bg-green-100 cursor-not-allowed mb-4",
38258
- className
38259
- )
38260
- },
38261
- children,
38262
- element.value
38263
- );
38264
- },
38265
- html_inline: ({ attributes, editor, element, children, className }) => {
38266
- return /* @__PURE__ */ React__default.createElement(
38267
- "span",
38268
- {
38269
- ...attributes,
38270
- className: classNames$1(
38271
- "font-mono bg-green-100 cursor-not-allowed",
38272
- className
38273
- )
38274
- },
38275
- children,
38276
- element.value
38277
- );
38278
- },
38279
- [BulletedListPlugin.key]: withProps(ListElement, { variant: "ul" }),
38280
- [NumberedListPlugin.key]: withProps(ListElement, { variant: "ol" }),
38281
- [ListItemPlugin.key]: withProps(PlateElement, { as: "li" }),
38282
- [LinkPlugin.key]: LinkElement,
38283
- [CodePlugin.key]: CodeLeaf,
38284
- [UnderlinePlugin.key]: withProps(PlateLeaf, { as: "u" }),
38285
- [StrikethroughPlugin.key]: withProps(PlateLeaf, { as: "s" }),
38286
- [ItalicPlugin.key]: withProps(PlateLeaf, { as: "em" }),
38287
- [BoldPlugin.key]: withProps(PlateLeaf, { as: "strong" }),
38288
- [HorizontalRulePlugin.key]: HrElement,
38289
- [TableCellHeaderPlugin.key]: TableCellHeaderElement,
38290
- [TableCellPlugin.key]: TableCellElement,
38291
- [TablePlugin.key]: TableElement,
38292
- [TableRowPlugin.key]: TableRowElement
38293
- };
38294
- };
38227
+ });
38228
+ return () => {
38229
+ pluginArray.forEach((plugin) => {
38230
+ if (plugin) {
38231
+ cms.plugins.remove(plugin);
38232
+ }
38233
+ });
38234
+ };
38235
+ }, [cms.plugins, ...pluginArray]);
38236
+ }
38237
+ function useSubscribable(subscribable, cb) {
38238
+ const [, s2] = React.useState(0);
38239
+ React.useEffect(() => {
38240
+ return subscribable.subscribe(() => {
38241
+ s2((x) => x + 1);
38242
+ if (cb)
38243
+ cb();
38244
+ });
38245
+ });
38246
+ }
38295
38247
  function FieldsBuilder({
38296
38248
  form,
38297
38249
  fields,
38298
38250
  activeFieldName,
38299
- hoveringFieldName,
38300
38251
  padding = false
38301
38252
  }) {
38302
38253
  const cms = useCMS$1();
@@ -38314,7 +38265,6 @@ function FieldsBuilder({
38314
38265
  key: field.name,
38315
38266
  field,
38316
38267
  activeFieldName,
38317
- hoveringFieldName,
38318
38268
  form,
38319
38269
  fieldPlugins,
38320
38270
  index
@@ -38327,8 +38277,7 @@ const InnerField = ({
38327
38277
  form,
38328
38278
  fieldPlugins,
38329
38279
  index,
38330
- activeFieldName,
38331
- hoveringFieldName
38280
+ activeFieldName
38332
38281
  }) => {
38333
38282
  React.useEffect(() => {
38334
38283
  form.mutators.setFieldData(field.name, {
@@ -38351,9 +38300,6 @@ const InnerField = ({
38351
38300
  format2 = plugin.format;
38352
38301
  }
38353
38302
  let isActiveField = field.name === activeFieldName;
38354
- const isHoveringField = field.name === hoveringFieldName;
38355
- const focusIntent = isActiveField;
38356
- const hoverIntent = isHoveringField;
38357
38303
  if (field.list && field.type === "string") {
38358
38304
  if (activeFieldName) {
38359
38305
  const activeFieldNameArray = activeFieldName.split(".");
@@ -38387,11 +38333,7 @@ const InnerField = ({
38387
38333
  ...fieldProps,
38388
38334
  form: form.finalForm,
38389
38335
  tinaForm: form,
38390
- field: {
38391
- ...field,
38392
- focusIntent,
38393
- hoverIntent
38394
- }
38336
+ field: { ...field, experimental_focusIntent: isActiveField }
38395
38337
  }
38396
38338
  );
38397
38339
  }
@@ -38400,14 +38342,10 @@ const InnerField = ({
38400
38342
  plugin.Component,
38401
38343
  {
38402
38344
  ...fieldProps,
38403
- focusIntent,
38345
+ experimental_focusIntent: isActiveField,
38404
38346
  form: form.finalForm,
38405
38347
  tinaForm: form,
38406
- field: {
38407
- ...field,
38408
- focusIntent,
38409
- hoverIntent
38410
- },
38348
+ field: { ...field, experimental_focusIntent: isActiveField },
38411
38349
  index
38412
38350
  }
38413
38351
  );
@@ -39472,7 +39410,7 @@ function AiFillWarning(props) {
39472
39410
  function AiOutlineLoading(props) {
39473
39411
  return GenIcon({ "tag": "svg", "attr": { "viewBox": "0 0 1024 1024" }, "child": [{ "tag": "path", "attr": { "d": "M988 548c-19.9 0-36-16.1-36-36 0-59.4-11.6-117-34.6-171.3a440.45 440.45 0 0 0-94.3-139.9 437.71 437.71 0 0 0-139.9-94.3C629 83.6 571.4 72 512 72c-19.9 0-36-16.1-36-36s16.1-36 36-36c69.1 0 136.2 13.5 199.3 40.3C772.3 66 827 103 874 150c47 47 83.9 101.8 109.7 162.7 26.7 63.1 40.2 130.2 40.2 199.3.1 19.9-16 36-35.9 36z" }, "child": [] }] })(props);
39474
39412
  }
39475
- const textFieldClasses = "shadow-inner focus:shadow-outline focus:border-tina-orange-dark focus-visible:ring-0 focus:outline-none focus:ring-2 block text-base placeholder:text-gray-300 px-3 py-2 text-gray-600 w-full bg-white border border-gray-200 transition-all ease-out duration-150 focus:text-gray-900 rounded";
39413
+ const textFieldClasses = "shadow-inner focus:shadow-outline focus:border-blue-500 focus:outline-none block text-base placeholder:text-gray-300 px-3 py-2 text-gray-600 w-full bg-white border border-gray-200 transition-all ease-out duration-150 focus:text-gray-900 rounded";
39476
39414
  const disabledClasses$1 = "opacity-50 pointer-events-none cursor-not-allowed";
39477
39415
  const BaseTextField = React.forwardRef(({ className, disabled, ...rest }, ref) => {
39478
39416
  return /* @__PURE__ */ React.createElement(
@@ -39490,7 +39428,7 @@ const TextArea = React.forwardRef(({ ...props }, ref) => {
39490
39428
  "textarea",
39491
39429
  {
39492
39430
  ...props,
39493
- className: "shadow-inner text-base px-3 py-2 text-gray-600 resize-y focus:shadow-outline focus:outline-none focus:border-tina-orange-dark block w-full border border-gray-200 focus:text-gray-900 rounded",
39431
+ className: "shadow-inner text-base px-3 py-2 text-gray-600 resize-y focus:shadow-outline focus:border-blue-500 block w-full border border-gray-200 focus:text-gray-900 rounded",
39494
39432
  ref,
39495
39433
  style: { minHeight: "160px" }
39496
39434
  }
@@ -39949,7 +39887,7 @@ const Toggle = ({
39949
39887
  /* @__PURE__ */ React.createElement("div", { className: "relative w-[48px] h-7 rounded-3xl bg-white shadow-inner border border-gray-200 pointer-events-none -ml-0.5" }, /* @__PURE__ */ React.createElement(
39950
39888
  "span",
39951
39889
  {
39952
- className: `absolute rounded-3xl left-0.5 top-1/2 w-[22px] h-[22px] shadow border transition-all ease-out duration-150 ${checked ? "bg-tina-orange border-tina-orange-dark" : "bg-gray-250 border-gray-300"}`,
39890
+ className: `absolute rounded-3xl left-0.5 top-1/2 w-[22px] h-[22px] shadow border transition-all ease-out duration-150 ${checked ? "bg-blue-500 border-blue-600" : "bg-gray-250 border-gray-300"}`,
39953
39891
  style: {
39954
39892
  transform: `translate3d(${checked ? "20px" : "0"}, -50%, 0)`
39955
39893
  }
@@ -40023,7 +39961,7 @@ function MdOutlinePhotoLibrary(props) {
40023
39961
  function MdOutlinePerson(props) {
40024
39962
  return GenIcon({ "tag": "svg", "attr": { "viewBox": "0 0 24 24" }, "child": [{ "tag": "path", "attr": { "fill": "none", "d": "M0 0h24v24H0V0z" }, "child": [] }, { "tag": "path", "attr": { "d": "M12 6c1.1 0 2 .9 2 2s-.9 2-2 2-2-.9-2-2 .9-2 2-2m0 10c2.7 0 5.8 1.29 6 2H6c.23-.72 3.31-2 6-2m0-12C9.79 4 8 5.79 8 8s1.79 4 4 4 4-1.79 4-4-1.79-4-4-4zm0 10c-2.67 0-8 1.34-8 4v2h16v-2c0-2.66-5.33-4-8-4z" }, "child": [] }] })(props);
40025
39963
  }
40026
- const selectFieldClasses = "shadow appearance-none h-full bg-white block pl-3 pr-8 py-2 truncate w-full text-base cursor-pointer border border-gray-200 focus:outline-none focus:shadow-outline focus:ring-tina-orange-dark focus:border-tina-orange-dark sm:text-sm rounded";
39964
+ const selectFieldClasses = "shadow appearance-none h-full bg-white block pl-3 pr-8 py-2 truncate w-full text-base cursor-pointer border border-gray-200 focus:outline-none focus:shadow-outline focus:ring-blue-500 focus:border-blue-500 sm:text-sm rounded";
40027
39965
  const Select$1 = ({
40028
39966
  input,
40029
39967
  field,
@@ -40033,12 +39971,10 @@ const Select$1 = ({
40033
39971
  const selectOptions = options || field.options;
40034
39972
  const ref = React.useRef(null);
40035
39973
  React.useEffect(() => {
40036
- const focusIntent = field == null ? void 0 : field.focusIntent;
40037
- const shouldFocus = !!focusIntent;
40038
- if (ref.current && shouldFocus) {
39974
+ if (ref.current && (field == null ? void 0 : field.experimental_focusIntent)) {
40039
39975
  ref.current.focus();
40040
39976
  }
40041
- }, [field == null ? void 0 : field.focusIntent, ref]);
39977
+ }, [field == null ? void 0 : field.experimental_focusIntent, ref]);
40042
39978
  return /* @__PURE__ */ React.createElement("div", { className: "relative group w-full h-fit md:w-auto" }, /* @__PURE__ */ React.createElement(
40043
39979
  "select",
40044
39980
  {
@@ -40120,7 +40056,7 @@ const RadioOption = ({ checked, htmlFor, children, ...props }) => /* @__PURE__ *
40120
40056
  /* @__PURE__ */ React.createElement(
40121
40057
  "span",
40122
40058
  {
40123
- className: `relative h-[19px] w-[19px] rounded border text-indigo-600 focus:ring-indigo-500 transition ease-out duration-150 ${checked ? "border-tina-orange-dark bg-tina-orange shadow-sm group-hover:bg-tina-orange group-hover:border-tina-orange-dark" : "border-gray-200 bg-white shadow-inner group-hover:bg-gray-100"}`
40059
+ className: `relative h-[19px] w-[19px] rounded border text-indigo-600 focus:ring-indigo-500 transition ease-out duration-150 ${checked ? "border-blue-500 bg-blue-500 shadow-sm group-hover:bg-blue-400 group-hover:border-blue-400" : "border-gray-200 bg-white shadow-inner group-hover:bg-gray-100"}`
40124
40060
  },
40125
40061
  /* @__PURE__ */ React.createElement(
40126
40062
  BiCheck,
@@ -40181,7 +40117,7 @@ const CheckboxGroup = ({
40181
40117
  /* @__PURE__ */ React.createElement(
40182
40118
  "span",
40183
40119
  {
40184
- className: `relative h-[18px] w-[18px] rounded border text-indigo-600 focus:ring-indigo-500 transition ease-out duration-150 ${checked ? "border-tina-orange-dark bg-tina-orange shadow-sm group-hover:bg-tina-orange group-hover:border-tina-orange-dark" : "border-gray-200 bg-white shadow-inner group-hover:bg-gray-100"}`
40120
+ className: `relative h-[18px] w-[18px] rounded border text-indigo-600 focus:ring-indigo-500 transition ease-out duration-150 ${checked ? "border-blue-500 bg-blue-500 shadow-sm group-hover:bg-blue-400 group-hover:border-blue-400" : "border-gray-200 bg-white shadow-inner group-hover:bg-gray-100"}`
40185
40121
  },
40186
40122
  /* @__PURE__ */ React.createElement(
40187
40123
  BiCheck,
@@ -40312,7 +40248,7 @@ const ImageUpload = React.forwardRef(({ onDrop, onClear, onClick, value, src, lo
40312
40248
  /* @__PURE__ */ React.createElement(
40313
40249
  "button",
40314
40250
  {
40315
- className: "flex-shrink min-w-0 focus-within:shadow-outline focus-within:border-tina-orange-dark rounded outline-none overflow-visible cursor-pointer border-none hover:opacity-60 transition ease-out duration-100",
40251
+ className: "flex-shrink min-w-0 focus-within:shadow-outline focus-within:border-blue-500 rounded outline-none overflow-visible cursor-pointer border-none hover:opacity-60 transition ease-out duration-100",
40316
40252
  onClick,
40317
40253
  ref
40318
40254
  },
@@ -40813,7 +40749,7 @@ function toProps(option) {
40813
40749
  return option;
40814
40750
  return { value: option, label: option };
40815
40751
  }
40816
- const passwordFieldClasses = "shadow-inner focus:shadow-outline focus:border-tina-orange-dark focus:outline-none block text-base placeholder:text-gray-300 px-3 py-2 text-gray-600 w-full bg-white border border-gray-200 transition-all ease-out duration-150 focus:text-gray-900 rounded";
40752
+ const passwordFieldClasses = "shadow-inner focus:shadow-outline focus:border-blue-500 focus:outline-none block text-base placeholder:text-gray-300 px-3 py-2 text-gray-600 w-full bg-white border border-gray-200 transition-all ease-out duration-150 focus:text-gray-900 rounded";
40817
40753
  const disabledClasses = "opacity-50 pointer-events-none cursor-not-allowed";
40818
40754
  const errorClasses = "border-red-500 focus:border-red-500 focus:shadow-outline-red";
40819
40755
  const BasePasswordField = React.forwardRef(({ className, disabled, error: error2, ...rest }, ref) => {
@@ -41186,7 +41122,7 @@ const Header = ({ onClick, children }) => {
41186
41122
  "button",
41187
41123
  {
41188
41124
  onClick,
41189
- className: "group px-4 py-3 bg-white hover:bg-gray-50 shadow focus:shadow-outline focus:border-tina-orange-dark w-full border border-gray-100 hover:border-gray-200 text-gray-500 hover:text-tina-orange-dark focus:text-tina-orange-dark rounded flex justify-between items-center gap-2"
41125
+ className: "group px-4 py-3 bg-white hover:bg-gray-50 shadow focus:shadow-outline focus:border-blue-500 w-full border border-gray-100 hover:border-gray-200 text-gray-500 hover:text-blue-400 focus:text-blue-500 rounded flex justify-between items-center gap-2"
41190
41126
  },
41191
41127
  /* @__PURE__ */ React.createElement("span", { className: "text-left text-base font-medium overflow-hidden text-ellipsis whitespace-nowrap flex-1" }, children),
41192
41128
  " ",
@@ -41338,7 +41274,7 @@ const BlockSelectorBig = ({
41338
41274
  "input",
41339
41275
  {
41340
41276
  type: "text",
41341
- className: "shadow-inner focus:shadow-outline focus:border-tina-orange-dark focus:outline-none block text-sm pl-2.5 pr-8 py-1.5 text-gray-600 w-full bg-white border border-gray-200 focus:text-gray-900 rounded placeholder-gray-400 hover:placeholder-gray-600 transition-all ease-out duration-150",
41277
+ className: "shadow-inner focus:shadow-outline focus:border-blue-400 focus:outline-none block text-sm pl-2.5 pr-8 py-1.5 text-gray-600 w-full bg-white border border-gray-200 focus:text-gray-900 rounded placeholder-gray-400 hover:placeholder-gray-600 transition-all ease-out duration-150",
41342
41278
  onClick: (event) => {
41343
41279
  event.stopPropagation();
41344
41280
  event.preventDefault();
@@ -41791,12 +41727,10 @@ const ImageField = wrapFieldsWithMeta(
41791
41727
  onClear = () => props.input.onChange("");
41792
41728
  }
41793
41729
  React.useEffect(() => {
41794
- const focusIntent = props.field.focusIntent;
41795
- const shouldFocus = !!focusIntent;
41796
- if (ref.current && shouldFocus) {
41730
+ if (ref.current && props.field.experimental_focusIntent) {
41797
41731
  ref.current.focus();
41798
41732
  }
41799
- }, [props.field.focusIntent, ref]);
41733
+ }, [props.field.experimental_focusIntent, ref]);
41800
41734
  async function onChange(media) {
41801
41735
  var _a2, _b;
41802
41736
  if (media) {
@@ -41922,14 +41856,12 @@ const RadioGroupFieldPlugin = {
41922
41856
  const TextareaField = wrapFieldsWithMeta((props) => {
41923
41857
  const ref = React.useRef(null);
41924
41858
  React.useEffect(() => {
41925
- const focusIntent = props.field.focusIntent;
41926
- const shouldFocus = !!focusIntent;
41927
- if (ref.current && shouldFocus) {
41859
+ if (ref.current && props.field.experimental_focusIntent) {
41928
41860
  const el = ref.current;
41929
41861
  el.focus();
41930
41862
  el.setSelectionRange(el.value.length, el.value.length);
41931
41863
  }
41932
- }, [props.field.focusIntent, ref]);
41864
+ }, [props.field.experimental_focusIntent, ref]);
41933
41865
  return /* @__PURE__ */ React.createElement(TextArea, { ref, ...props.input });
41934
41866
  });
41935
41867
  const TextareaFieldPlugin = {
@@ -41990,12 +41922,10 @@ const TextField = wrapFieldsWithMeta(
41990
41922
  var _a2;
41991
41923
  const ref = React.useRef(null);
41992
41924
  React.useEffect(() => {
41993
- const focusIntent = props.field.focusIntent;
41994
- const shouldFocus = !!focusIntent;
41995
- if (ref.current && shouldFocus) {
41925
+ if (ref.current && props.field.experimental_focusIntent) {
41996
41926
  ref.current.focus();
41997
41927
  }
41998
- }, [props.field.focusIntent, ref]);
41928
+ }, [props.field.experimental_focusIntent, ref]);
41999
41929
  return /* @__PURE__ */ React.createElement(
42000
41930
  BaseTextField,
42001
41931
  {
@@ -42055,12 +41985,10 @@ const TagsField = wrapFieldsWithMeta(({ input, field, form, tinaForm }) => {
42055
41985
  const items2 = input.value || [];
42056
41986
  const ref = React.useRef(null);
42057
41987
  React.useEffect(() => {
42058
- const focusIntent = field.focusIntent;
42059
- const shouldFocus = !!focusIntent;
42060
- if (ref.current && shouldFocus) {
41988
+ if (ref.current && field.experimental_focusIntent) {
42061
41989
  ref.current.focus();
42062
41990
  }
42063
- }, [field.focusIntent, ref]);
41991
+ }, [field.experimental_focusIntent, ref]);
42064
41992
  return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("div", { className: "flex items-center gap-3" }, /* @__PURE__ */ React.createElement(
42065
41993
  BaseTextField,
42066
41994
  {
@@ -43459,11 +43387,11 @@ const DateField = wrapFieldsWithMeta(
43459
43387
  const granularity = timeFormat ? "minute" : "day";
43460
43388
  const inputRef = React__default.useRef(null);
43461
43389
  React__default.useEffect(() => {
43462
- if (inputRef.current && rest.focusIntent) {
43390
+ if (inputRef.current && rest.experimental_focusIntent) {
43463
43391
  inputRef.current.focus();
43464
43392
  inputRef.current.open();
43465
43393
  }
43466
- }, [rest.focusIntent]);
43394
+ }, [rest.experimental_focusIntent]);
43467
43395
  const getTimeFormat = useCallback(() => {
43468
43396
  if (timeFormat === false) {
43469
43397
  return;
@@ -44078,9 +44006,20 @@ const EditoralBranchSwitcher = ({
44078
44006
  ) : /* @__PURE__ */ React.createElement("div", { className: "px-6 py-8 w-full h-full flex flex-col items-center justify-center" }, /* @__PURE__ */ React.createElement("p", { className: "text-base mb-4 text-center" }, "An error occurred while retrieving the branch list."), /* @__PURE__ */ React.createElement(Button$2, { className: "mb-4", onClick: refreshBranchList }, "Try again ", /* @__PURE__ */ React.createElement(BiRefresh, { className: "w-6 h-full ml-1 opacity-70" }))))));
44079
44007
  };
44080
44008
  const getFilteredBranchList = (branchList, search, currentBranchName, filter2 = "all") => {
44081
- const filteredBranchList = branchList.filter(
44082
- (branch) => !search || branch.name.includes(search) || branch.name === currentBranchName
44083
- ).filter((branch) => {
44009
+ const filteredBranchList = branchList.filter((branch) => {
44010
+ if (!search)
44011
+ return true;
44012
+ if (branch.name === currentBranchName)
44013
+ return true;
44014
+ const searchLower = search.toLowerCase();
44015
+ const nameMatch = branch.name.toLowerCase().includes(searchLower);
44016
+ let prMatch = false;
44017
+ if (branch.githubPullRequestUrl) {
44018
+ const prId = extractPullRequestId(branch.githubPullRequestUrl);
44019
+ prMatch = prId.toLowerCase().includes(searchLower);
44020
+ }
44021
+ return nameMatch || prMatch;
44022
+ }).filter((branch) => {
44084
44023
  if (branch.protected)
44085
44024
  return true;
44086
44025
  if (filter2 === "all")
@@ -44184,7 +44123,7 @@ const BranchSelector = ({
44184
44123
  ), /* @__PURE__ */ React.createElement("div", { className: "block relative group h-fit mb-auto" }, /* @__PURE__ */ React.createElement(
44185
44124
  BaseTextField,
44186
44125
  {
44187
- placeholder: "Search",
44126
+ placeholder: "Branch name or PR #",
44188
44127
  value: search,
44189
44128
  onChange: (e3) => setSearch(e3.target.value)
44190
44129
  }
@@ -46593,7 +46532,7 @@ const NavProvider = ({
46593
46532
  };
46594
46533
  return /* @__PURE__ */ React__default.createElement(NavContext.Provider, { value }, children);
46595
46534
  };
46596
- const version$1 = "3.3.0";
46535
+ const version$1 = "3.3.2";
46597
46536
  const VersionInfo = () => {
46598
46537
  var _a2, _b, _c, _d, _e, _f;
46599
46538
  const cms = useCMS();
@@ -48053,25 +47992,6 @@ class TinaCMS extends CMS {
48053
47992
  });
48054
47993
  }
48055
47994
  }
48056
- const ACTION_TYPES = {
48057
- FORMS_ADD: "forms:add",
48058
- FORMS_REMOVE: "forms:remove",
48059
- FORMS_CLEAR: "forms:clear",
48060
- FORMS_SET_ACTIVE_FORM_ID: "forms:set-active-form-id",
48061
- FORMS_SET_ACTIVE_FIELD_NAME: "forms:set-active-field-name",
48062
- FORMS_SET_HOVERED_FIELD_NAME: "forms:set-hovered-field-name",
48063
- FORM_LISTS_ADD: "form-lists:add",
48064
- FORM_LISTS_REMOVE: "form-lists:remove",
48065
- FORM_LISTS_CLEAR: "form-lists:clear",
48066
- SET_EDIT_MODE: "set-edit-mode",
48067
- INCREMENT_OPERATION_INDEX: "increment-operation-index",
48068
- SET_QUICK_EDITING_SUPPORTED: "set-quick-editing-supported",
48069
- SET_QUICK_EDITING_ENABLED: "set-quick-editing-enabled",
48070
- TOGGLE_QUICK_EDITING_ENABLED: "toggle-quick-editing-enabled",
48071
- TOGGLE_EDIT_STATE: "toggle-edit-state",
48072
- SIDEBAR_SET_DISPLAY_STATE: "sidebar:set-display-state",
48073
- SIDEBAR_SET_LOADING_STATE: "sidebar:set-loading-state"
48074
- };
48075
47995
  const initialState = (cms) => {
48076
47996
  var _a2;
48077
47997
  return {
@@ -48087,24 +48007,24 @@ const initialState = (cms) => {
48087
48007
  };
48088
48008
  function tinaReducer(state, action) {
48089
48009
  switch (action.type) {
48090
- case ACTION_TYPES.SET_QUICK_EDITING_SUPPORTED:
48010
+ case "set-quick-editing-supported":
48091
48011
  return {
48092
48012
  ...state,
48093
48013
  quickEditSupported: action.value
48094
48014
  };
48095
- case ACTION_TYPES.SET_EDIT_MODE:
48015
+ case "set-edit-mode":
48096
48016
  return { ...state, editingMode: action.value };
48097
- case ACTION_TYPES.FORMS_ADD:
48017
+ case "forms:add":
48098
48018
  if (state.forms.find((f2) => f2.tinaForm.id === action.value.id)) {
48099
48019
  return state;
48100
48020
  }
48101
48021
  return { ...state, forms: [...state.forms, { tinaForm: action.value }] };
48102
- case ACTION_TYPES.FORMS_REMOVE:
48022
+ case "forms:remove":
48103
48023
  return {
48104
48024
  ...state,
48105
48025
  forms: state.forms.filter((form) => form.tinaForm.id !== action.value)
48106
48026
  };
48107
- case ACTION_TYPES.FORM_LISTS_CLEAR: {
48027
+ case "form-lists:clear": {
48108
48028
  return {
48109
48029
  ...state,
48110
48030
  quickEditSupported: false,
@@ -48114,7 +48034,7 @@ function tinaReducer(state, action) {
48114
48034
  forms: []
48115
48035
  };
48116
48036
  }
48117
- case ACTION_TYPES.FORM_LISTS_ADD: {
48037
+ case "form-lists:add": {
48118
48038
  let formListItemExists = false;
48119
48039
  const nextFormLists = state.formLists.map((formList) => {
48120
48040
  if (formList.id === action.value.id) {
@@ -48153,7 +48073,7 @@ function tinaReducer(state, action) {
48153
48073
  isLoadingContent: false
48154
48074
  };
48155
48075
  }
48156
- case ACTION_TYPES.FORM_LISTS_REMOVE: {
48076
+ case "form-lists:remove": {
48157
48077
  const nextFormLists = state.formLists.filter(
48158
48078
  ({ id: id2 }) => id2 !== action.value
48159
48079
  );
@@ -48177,7 +48097,7 @@ function tinaReducer(state, action) {
48177
48097
  formLists: nextFormLists
48178
48098
  };
48179
48099
  }
48180
- case ACTION_TYPES.FORMS_SET_ACTIVE_FORM_ID:
48100
+ case "forms:set-active-form-id":
48181
48101
  if (action.value !== state.activeFormId) {
48182
48102
  const newActiveForm = state.forms.find(
48183
48103
  (form) => form.tinaForm.id === action.value
@@ -48194,7 +48114,7 @@ function tinaReducer(state, action) {
48194
48114
  };
48195
48115
  }
48196
48116
  return state;
48197
- case ACTION_TYPES.FORMS_SET_ACTIVE_FIELD_NAME:
48117
+ case "forms:set-active-field-name":
48198
48118
  if (state.activeFormId === action.value.formId) {
48199
48119
  const existingForm = state.forms.find(
48200
48120
  (form) => form.tinaForm.id === action.value.formId
@@ -48207,8 +48127,7 @@ function tinaReducer(state, action) {
48207
48127
  if (form.tinaForm.id === action.value.formId) {
48208
48128
  return {
48209
48129
  tinaForm: form.tinaForm,
48210
- activeFieldName: action.value.fieldName,
48211
- hoveringFieldName: null
48130
+ activeFieldName: action.value.fieldName
48212
48131
  };
48213
48132
  }
48214
48133
  return form;
@@ -48224,49 +48143,13 @@ function tinaReducer(state, action) {
48224
48143
  forms,
48225
48144
  activeFormId: action.value.formId
48226
48145
  };
48227
- case ACTION_TYPES.FORMS_SET_HOVERED_FIELD_NAME:
48228
- const hoveredForms = state.forms.map((form) => {
48229
- if (form.tinaForm.id === action.value.formId) {
48230
- const activeFieldName = form.activeFieldName;
48231
- const hoveredFieldName = action.value.fieldName;
48232
- if (activeFieldName && hoveredFieldName) {
48233
- if (activeFieldName === hoveredFieldName) {
48234
- return {
48235
- ...form,
48236
- hoveringFieldName: null
48237
- };
48238
- }
48239
- const isChildOfActive = hoveredFieldName.startsWith(
48240
- activeFieldName + "."
48241
- );
48242
- const activePathParts = activeFieldName.split(".");
48243
- const hoveredPathParts = hoveredFieldName.split(".");
48244
- const isSibling = activePathParts.length === hoveredPathParts.length && activePathParts.slice(0, -1).join(".") === hoveredPathParts.slice(0, -1).join(".");
48245
- if (!isChildOfActive && !isSibling) {
48246
- return {
48247
- ...form,
48248
- hoveringFieldName: null
48249
- };
48250
- }
48251
- }
48252
- return {
48253
- ...form,
48254
- hoveringFieldName: hoveredFieldName
48255
- };
48256
- }
48257
- return form;
48258
- });
48259
- return {
48260
- ...state,
48261
- forms: hoveredForms
48262
- };
48263
- case ACTION_TYPES.TOGGLE_EDIT_STATE: {
48146
+ case "toggle-edit-state": {
48264
48147
  return state.sidebarDisplayState === "closed" ? { ...state, sidebarDisplayState: "open" } : {
48265
48148
  ...state,
48266
48149
  sidebarDisplayState: "closed"
48267
48150
  };
48268
48151
  }
48269
- case ACTION_TYPES.SIDEBAR_SET_DISPLAY_STATE: {
48152
+ case "sidebar:set-display-state": {
48270
48153
  if (action.value === "openOrFull") {
48271
48154
  if (state.sidebarDisplayState === "closed") {
48272
48155
  return {
@@ -48284,7 +48167,7 @@ function tinaReducer(state, action) {
48284
48167
  }
48285
48168
  return { ...state, sidebarDisplayState: action.value };
48286
48169
  }
48287
- case ACTION_TYPES.SIDEBAR_SET_LOADING_STATE: {
48170
+ case "sidebar:set-loading-state": {
48288
48171
  return { ...state, isLoadingContent: action.value };
48289
48172
  }
48290
48173
  default:
@@ -48553,12 +48436,10 @@ const AboveViewportIndicator = () => {
48553
48436
  const BelowViewportIndicator = () => {
48554
48437
  return /* @__PURE__ */ React.createElement(IndicatorWrap, { position: "bottom" }, /* @__PURE__ */ React.createElement(ArrowWrap, null, /* @__PURE__ */ React.createElement(ChevronDownIcon, { className: "w-8 h-auto" })));
48555
48438
  };
48556
- const useScrollToFocusedField = (enabled) => {
48439
+ const useScrollToFocusedField = () => {
48557
48440
  const { subscribe } = useEvent("field:focus");
48558
- React.useEffect(() => {
48559
- if (!enabled)
48560
- return;
48561
- return subscribe(({ fieldName }) => {
48441
+ React.useEffect(
48442
+ () => subscribe(({ fieldName }) => {
48562
48443
  const ele = document.querySelector(
48563
48444
  `[data-tinafield="${fieldName}"]`
48564
48445
  );
@@ -48594,41 +48475,17 @@ const useScrollToFocusedField = (enabled) => {
48594
48475
  });
48595
48476
  }
48596
48477
  }
48597
- });
48598
- }, [enabled, subscribe]);
48478
+ })
48479
+ );
48599
48480
  };
48600
- const FieldIndicator = ({
48601
- eventType,
48602
- checkFocusedAttribute = false,
48603
- scrollToField = false
48604
- }) => {
48605
- const [fieldName, setFieldName] = React.useState(null);
48481
+ const ActiveFieldIndicator = () => {
48482
+ const [activeFieldName, setActiveFieldName] = React.useState(
48483
+ null
48484
+ );
48606
48485
  const [display, setDisplay] = React.useState(false);
48607
48486
  const [position, setPosition] = React.useState(false);
48608
48487
  const [iframePosition, setIframePosition] = React.useState({ left: 0 });
48609
- const [isFocused2, setIsFocused] = React.useState(false);
48610
- const activeEle = useFieldReference(fieldName);
48611
- const { subscribe: subscribeFocus } = useEvent("field:focus");
48612
- const { subscribe: subscribeHover } = useEvent("field:hover");
48613
- React.useEffect(() => {
48614
- const subscribe = eventType === "field:focus" ? subscribeFocus : subscribeHover;
48615
- return subscribe(({ fieldName: eventFieldName, id: id2 }) => {
48616
- setFieldName(`${id2}#${eventFieldName}`);
48617
- if (eventType === "field:focus" && checkFocusedAttribute) {
48618
- setIsFocused(true);
48619
- }
48620
- });
48621
- }, [eventType, subscribeFocus, subscribeHover, checkFocusedAttribute]);
48622
- React.useEffect(() => {
48623
- if (!checkFocusedAttribute)
48624
- return;
48625
- if (activeEle) {
48626
- const hasFocusedAttr = activeEle.hasAttribute("data-tina-field-focused");
48627
- setIsFocused(hasFocusedAttr);
48628
- } else {
48629
- setIsFocused(false);
48630
- }
48631
- }, [activeEle, fieldName, checkFocusedAttribute]);
48488
+ const activeEle = useFieldReference(activeFieldName);
48632
48489
  React.useEffect(() => {
48633
48490
  let displayTimeout;
48634
48491
  if (activeEle) {
@@ -48657,7 +48514,13 @@ const FieldIndicator = ({
48657
48514
  window.removeEventListener("scroll", rerender);
48658
48515
  };
48659
48516
  }, []);
48660
- useScrollToFocusedField(scrollToField);
48517
+ const { subscribe } = useEvent("field:hover");
48518
+ React.useEffect(
48519
+ () => subscribe(({ fieldName, id: id2 }) => {
48520
+ setActiveFieldName(`${id2}#${fieldName}`);
48521
+ })
48522
+ );
48523
+ useScrollToFocusedField();
48661
48524
  if (!display)
48662
48525
  return null;
48663
48526
  const eleTopY = position.top + window.scrollY;
@@ -48670,7 +48533,6 @@ const FieldIndicator = ({
48670
48533
  if (eleBottomY < viewportTopY) {
48671
48534
  return /* @__PURE__ */ React.createElement(AboveViewportIndicator, null);
48672
48535
  }
48673
- const outlineColor = checkFocusedAttribute && isFocused2 ? "2px dashed #C2410C" : "2px dashed var(--tina-color-indicator)";
48674
48536
  return /* @__PURE__ */ React.createElement(
48675
48537
  "div",
48676
48538
  {
@@ -48681,7 +48543,7 @@ const FieldIndicator = ({
48681
48543
  left: position.left + window.scrollX + iframePosition.left,
48682
48544
  width: position.width,
48683
48545
  height: position.height,
48684
- outline: outlineColor,
48546
+ outline: "2px dashed var(--tina-color-indicator)",
48685
48547
  borderRadius: "var(--tina-radius-small)",
48686
48548
  transition: display ? activeEle ? `opacity 300ms ease-out` : `opacity 150ms ease-in` : `none`,
48687
48549
  opacity: activeEle && display ? 0.8 : 0
@@ -48689,15 +48551,6 @@ const FieldIndicator = ({
48689
48551
  }
48690
48552
  );
48691
48553
  };
48692
- const ActiveFieldIndicator = () => /* @__PURE__ */ React.createElement(
48693
- FieldIndicator,
48694
- {
48695
- eventType: "field:focus",
48696
- checkFocusedAttribute: true,
48697
- scrollToField: true
48698
- }
48699
- );
48700
- const HoveredFieldIndicator = () => /* @__PURE__ */ React.createElement(FieldIndicator, { eventType: "field:hover" });
48701
48554
  const TinaUI = ({ children, position }) => {
48702
48555
  const cms = useCMS();
48703
48556
  const [resizingSidebar, setResizingSidebar] = React.useState(false);
@@ -48709,7 +48562,7 @@ const TinaUI = ({ children, position }) => {
48709
48562
  position,
48710
48563
  sidebar: cms.sidebar
48711
48564
  }
48712
- ), /* @__PURE__ */ React.createElement(ActiveFieldIndicator, null), /* @__PURE__ */ React.createElement(HoveredFieldIndicator, null), /* @__PURE__ */ React.createElement("div", { className: `${resizingSidebar ? "pointer-events-none" : ""}` }, children)));
48565
+ ), /* @__PURE__ */ React.createElement(ActiveFieldIndicator, null), /* @__PURE__ */ React.createElement("div", { className: `${resizingSidebar ? "pointer-events-none" : ""}` }, children)));
48713
48566
  };
48714
48567
  const TinaProvider = ({
48715
48568
  cms,
@@ -64685,7 +64538,6 @@ const FormBuilder = ({
64685
64538
  {
64686
64539
  form: tinaForm,
64687
64540
  activeFieldName: form.activeFieldName,
64688
- hoveringFieldName: form.hoveringFieldName,
64689
64541
  fields: fieldGroup.fields
64690
64542
  }
64691
64543
  ) : /* @__PURE__ */ React.createElement(NoFieldsPlaceholder, null))), !hideFooter && /* @__PURE__ */ React.createElement("div", { className: "relative flex-none w-full h-16 px-6 bg-white border-t border-gray-100 flex items-center justify-end" }, /* @__PURE__ */ React.createElement("div", { className: "flex-1 w-full justify-end gap-2 flex items-center max-w-form" }, tinaForm.reset && /* @__PURE__ */ React.createElement(
@@ -64858,7 +64710,7 @@ const ImgEmbed = ({
64858
64710
  "button",
64859
64711
  {
64860
64712
  type: "button",
64861
- className: `flex-shrink min-w-0 focus-within:shadow-outline focus-within:border-tina-orange-dark rounded outline-none overflow-visible cursor-pointer border-none hover:opacity-60 transition ease-out duration-100 ${selected ? "shadow-outline border-tina-orange-dark" : ""}`,
64713
+ className: `flex-shrink min-w-0 focus-within:shadow-outline focus-within:border-blue-500 rounded outline-none overflow-visible cursor-pointer border-none hover:opacity-60 transition ease-out duration-100 ${selected ? "shadow-outline border-blue-500" : ""}`,
64862
64714
  onClick: handleSelect
64863
64715
  },
64864
64716
  isImage(element.url) ? /* @__PURE__ */ React__default.createElement(StyledImage, { src: element.url }) : /* @__PURE__ */ React__default.createElement(StyledFile, { src: element.url })
@@ -65114,7 +64966,7 @@ const DotMenu = ({ onOpen, onRemove }) => {
65114
64966
  PopoverButton,
65115
64967
  {
65116
64968
  as: "span",
65117
- className: "cursor-pointer h-full relative inline-flex items-center px-1 py-0.5 rounded-r border border-gray-200 bg-white text-gray-500 hover:bg-gray-50 focus:outline-none focus:ring-1 focus:ring-tina-orange-dark focus:border-tina-orange-dark"
64969
+ className: "cursor-pointer h-full relative inline-flex items-center px-1 py-0.5 rounded-r border border-gray-200 bg-white text-gray-500 hover:bg-gray-50 focus:outline-none focus:ring-1 focus:ring-blue-500 focus:border-blue-500"
65118
64970
  },
65119
64971
  /* @__PURE__ */ React__default.createElement(EllipsisIcon, { title: "Open options" })
65120
64972
  ), /* @__PURE__ */ React__default.createElement(
@@ -119036,13 +118888,13 @@ const RichEditor = ({ input, tinaForm, field }) => {
119036
118888
  const plateElement = (_a3 = ref.current) == null ? void 0 : _a3.querySelector(
119037
118889
  '[role="textbox"]'
119038
118890
  );
119039
- if (field.focusIntent && plateElement) {
118891
+ if (field.experimental_focusIntent && plateElement) {
119040
118892
  if (plateElement)
119041
118893
  plateElement.focus();
119042
118894
  }
119043
118895
  }, 100);
119044
118896
  }
119045
- }, [field.focusIntent, ref]);
118897
+ }, [field.experimental_focusIntent, ref]);
119046
118898
  return /* @__PURE__ */ React__default.createElement("div", { ref }, /* @__PURE__ */ React__default.createElement(
119047
118899
  Plate,
119048
118900
  {
@@ -119133,7 +118985,7 @@ const MdxFieldPluginExtendible = {
119133
118985
  /* @__PURE__ */ React__default.createElement(
119134
118986
  "div",
119135
118987
  {
119136
- className: "min-h-[100px] max-w-full tina-prose relative shadow-inner focus-within:shadow-outline focus-within:border-tina-orange-dark block w-full bg-white border border-gray-200 text-gray-600 focus-within:text-gray-900 rounded pt-0 py-2"
118988
+ className: "min-h-[100px] max-w-full tina-prose relative shadow-inner focus-within:shadow-outline focus-within:border-blue-500 block w-full bg-white border border-gray-200 text-gray-600 focus-within:text-gray-900 rounded pt-0 py-2"
119137
118989
  },
119138
118990
  props.rawMode ? props.rawEditor : /* @__PURE__ */ React__default.createElement(RichEditor, { ...props })
119139
118991
  )
@@ -122598,7 +122450,7 @@ const RenderForm$1 = ({
122598
122450
  mutationInfo,
122599
122451
  customDefaults
122600
122452
  }) => {
122601
- var _a2, _b, _c, _d, _e, _f, _g, _h;
122453
+ var _a2, _b, _c, _d, _e, _f, _g, _h, _i, _j;
122602
122454
  const navigate = useNavigate();
122603
122455
  const [formIsPristine, setFormIsPristine] = useState(true);
122604
122456
  const schema = cms.api.tina.schema;
@@ -122628,10 +122480,11 @@ const RenderForm$1 = ({
122628
122480
  const defaultItem2 = customDefaults || // @ts-ignore internal types aren't up to date
122629
122481
  ((_d = template.ui) == null ? void 0 : _d.defaultItem) || // @ts-ignore
122630
122482
  (template == null ? void 0 : template.defaultItem) || {};
122483
+ const fileReadOnly = (_f = (_e = schemaCollection == null ? void 0 : schemaCollection.ui) == null ? void 0 : _e.filename) == null ? void 0 : _f.readonly;
122631
122484
  const filenameField = {
122632
122485
  name: "filename",
122633
122486
  label: "Filename",
122634
- component: slugFunction ? wrapFieldsWithMeta(({ field, input, meta }) => {
122487
+ component: slugFunction && !fileReadOnly ? wrapFieldsWithMeta(({ field, input, meta }) => {
122635
122488
  var _a3, _b2;
122636
122489
  return /* @__PURE__ */ React__default.createElement(
122637
122490
  FilenameInput,
@@ -122641,8 +122494,8 @@ const RenderForm$1 = ({
122641
122494
  }
122642
122495
  );
122643
122496
  }) : "text",
122644
- disabled: (_f = (_e = schemaCollection == null ? void 0 : schemaCollection.ui) == null ? void 0 : _e.filename) == null ? void 0 : _f.readonly,
122645
- description: ((_h = (_g = collection.ui) == null ? void 0 : _g.filename) == null ? void 0 : _h.description) ? /* @__PURE__ */ React__default.createElement(
122497
+ disabled: (_h = (_g = schemaCollection == null ? void 0 : schemaCollection.ui) == null ? void 0 : _g.filename) == null ? void 0 : _h.readonly,
122498
+ description: ((_j = (_i = collection.ui) == null ? void 0 : _i.filename) == null ? void 0 : _j.description) ? /* @__PURE__ */ React__default.createElement(
122646
122499
  "span",
122647
122500
  {
122648
122501
  dangerouslySetInnerHTML: { __html: collection.ui.filename.description }