tinacms 3.1.2 → 3.2.0

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,6 +9,9 @@ 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 as memo$1, 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";
12
15
  import { withRef as withRef$1, cn as cn$2, withCn, createPrimitiveElement, withVariants, withProps, useComposedRef as useComposedRef$1, PortalBody } from "@udecode/cn";
13
16
  import { HEADING_KEYS as HEADING_KEYS$1, HEADING_LEVELS as HEADING_LEVELS$1 } from "@udecode/plate-heading";
14
17
  import { isHotkey } from "is-hotkey";
@@ -22,7 +25,7 @@ import { Command as Command$2 } from "cmdk";
22
25
  import * as DialogPrimitive from "@radix-ui/react-dialog";
23
26
  import * as PopoverPrimitive from "@radix-ui/react-popover";
24
27
  import { PopoverAnchor } from "@radix-ui/react-popover";
25
- import { createSlatePlugin as createSlatePlugin$1, someHtmlElement, findHtmlParentElement, createTSlatePlugin as createTSlatePlugin$1, RangeApi as RangeApi$1, TextApi as TextApi$1, HtmlPlugin as HtmlPlugin$1, NodeApi as NodeApi$1, ElementApi as ElementApi$1, Hotkeys, isHotkey as isHotkey$1, isUrl as isUrl$1, getEditorPlugin as getEditorPlugin$1, bindFirst as bindFirst$1, sanitizeUrl, PathApi as PathApi$1, isDefined as isDefined$1, PointApi as PointApi$1, BaseParagraphPlugin as BaseParagraphPlugin$1, match as match$3, deleteMerge, getPluginTypes, queryNode as queryNode$1, isType, getInjectMatch as getInjectMatch$1, traverseHtmlElements, isHtmlBlockElement as isHtmlBlockElement$1, postCleanHtml, mergeProps } from "@udecode/plate";
28
+ import { createSlatePlugin as createSlatePlugin$1, someHtmlElement, findHtmlParentElement, createTSlatePlugin as createTSlatePlugin$1, RangeApi as RangeApi$1, TextApi as TextApi$1, HtmlPlugin as HtmlPlugin$1, NodeApi as NodeApi$1, ElementApi as ElementApi$1, Hotkeys, isHotkey as isHotkey$1, isUrl as isUrl$1, getEditorPlugin as getEditorPlugin$1, bindFirst as bindFirst$1, sanitizeUrl, PathApi as PathApi$1, isDefined as isDefined$1, PointApi as PointApi$1, BaseParagraphPlugin as BaseParagraphPlugin$1, match as match$2, deleteMerge, getPluginTypes, queryNode as queryNode$1, isType, getInjectMatch as getInjectMatch$1, traverseHtmlElements, isHtmlBlockElement as isHtmlBlockElement$1, postCleanHtml, mergeProps } from "@udecode/plate";
26
29
  import { useComboboxContext, Combobox as Combobox$1, useComboboxStore, ComboboxProvider, Portal, ComboboxPopover, ComboboxItem } from "@ariakit/react";
27
30
  import { withTriggerCombobox, filterWords } from "@udecode/plate-combobox";
28
31
  import { BaseResetNodePlugin as BaseResetNodePlugin$1 } from "@udecode/plate-reset-node";
@@ -34,9 +37,6 @@ import * as DropdownMenuPrimitive from "@radix-ui/react-dropdown-menu";
34
37
  import * as ToolbarPrimitive from "@radix-ui/react-toolbar";
35
38
  import * as SeparatorPrimitive from "@radix-ui/react-separator";
36
39
  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";
@@ -61,7 +61,7 @@ import moment from "moment";
61
61
  import "moment-timezone";
62
62
  import { DayPicker } from "react-day-picker";
63
63
  import * as SelectPrimitive from "@radix-ui/react-select";
64
- import { formatDistanceToNow as formatDistanceToNow$1 } from "date-fns";
64
+ import { formatDistanceToNow } from "date-fns";
65
65
  import { TinaSchema, addNamespaceToSchema, parseURL, resolveForm, normalizePath, canonicalPath, validateSchema } from "@tinacms/schema-tools";
66
66
  import { NAMER, resolveField } from "@tinacms/schema-tools";
67
67
  import gql from "graphql-tag";
@@ -869,788 +869,1369 @@ function useEvent(eventType) {
869
869
  subscribe: (callback) => cms.events.subscribe(eventType, callback)
870
870
  };
871
871
  }
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
- },
884
- /* @__PURE__ */ React.createElement(Field2, { ...props })
885
- );
886
- };
887
- }
888
- function wrapFieldWithNoHeader(Field2) {
889
- return (props) => {
890
- return /* @__PURE__ */ React.createElement(
891
- FieldMeta,
892
- {
893
- name: props.input.name,
894
- label: false,
895
- description: "",
896
- error: props.meta.error,
897
- index: props.index,
898
- tinaForm: props.tinaForm
899
- },
900
- /* @__PURE__ */ React.createElement(Field2, { ...props })
901
- );
902
- };
903
- }
904
- function wrapFieldWithError(Field2) {
905
- return (props) => {
906
- return /* @__PURE__ */ React.createElement(
907
- FieldMeta,
908
- {
909
- name: props.input.name,
910
- label: false,
911
- description: props.field.description,
912
- error: props.meta.error,
913
- index: props.index,
914
- tinaForm: props.tinaForm
915
- },
916
- /* @__PURE__ */ React.createElement(Field2, { ...props })
917
- );
918
- };
919
- }
920
- const FieldMeta = ({
921
- name,
922
- label,
923
- description,
924
- error: error2,
925
- margin = true,
926
- children,
927
- index,
928
- tinaForm,
929
- ...props
930
- }) => {
931
- const { dispatch: setHoveredField } = useEvent("field:hover");
932
- const { dispatch: setFocusedField } = useEvent("field:focus");
933
- return /* @__PURE__ */ React.createElement(
934
- FieldWrapper,
935
- {
936
- margin,
937
- onMouseOver: () => setHoveredField({ id: tinaForm.id, fieldName: name }),
938
- onMouseOut: () => setHoveredField({ id: null, fieldName: null }),
939
- onClick: () => setFocusedField({ id: tinaForm.id, fieldName: name }),
940
- style: { zIndex: index ? 1e3 - index : void 0 },
941
- ...props
942
- },
943
- (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)),
944
- children,
945
- error2 && typeof error2 === "string" && /* @__PURE__ */ React.createElement(FieldError, null, error2)
946
- );
947
- };
948
- const FieldWrapper = ({
949
- margin,
950
- children,
951
- ...props
952
- }) => {
953
- return /* @__PURE__ */ React.createElement("div", { className: `relative ${margin ? `mb-5 last:mb-0` : ``}`, ...props }, children);
954
- };
955
- const FieldLabel = ({
956
- children,
957
- className,
958
- name,
959
- ...props
960
- }) => {
961
- return /* @__PURE__ */ React.createElement(
962
- "label",
963
- {
964
- htmlFor: name,
965
- className: `block font-sans text-xs font-semibold text-gray-700 whitespace-normal mb-2 ${className}`,
966
- ...props
967
- },
968
- children
969
- );
970
- };
971
- const FieldDescription = ({
972
- children,
973
- className,
974
- ...props
975
- }) => {
976
- if (typeof children === "string") {
977
- return /* @__PURE__ */ React.createElement(
978
- "span",
979
- {
980
- className: `block font-sans text-xs italic font-light text-gray-400 pt-0.5 whitespace-normal m-0 ${className}`,
981
- ...props,
982
- dangerouslySetInnerHTML: { __html: children }
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 };
983
930
  }
984
- );
985
- }
986
- return /* @__PURE__ */ React.createElement(
987
- "span",
988
- {
989
- className: `block font-sans text-xs italic font-light text-gray-400 pt-0.5 whitespace-normal m-0 ${className}`,
990
- ...props
991
- },
992
- children
993
- );
994
- };
995
- const FieldError = ({
996
- children,
997
- className,
998
- ...props
999
- }) => {
1000
- return /* @__PURE__ */ React.createElement(
1001
- "span",
1002
- {
1003
- className: `block font-sans text-xs font-normal text-red-500 pt-3 animate-slide-in whitespace-normal m-0 ${className}`,
1004
- ...props
1005
- },
1006
- children
1007
- );
1008
- };
1009
- const EditorContext$1 = React__default.createContext({
1010
- fieldName: "",
1011
- rawMode: false,
1012
- setRawMode: () => {
1013
- },
1014
- templates: []
1015
- });
1016
- const useEditorContext = () => {
1017
- return React__default.useContext(EditorContext$1);
1018
- };
1019
- const useTemplates = () => {
1020
- return React__default.useContext(EditorContext$1);
1021
- };
1022
- var commonjsGlobal = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : {};
1023
- function getDefaultExportFromCjs(x) {
1024
- return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x;
1025
- }
1026
- var direction_1 = direction;
1027
- var RTL = "֑-߿יִ-﷽ﹰ-ﻼ";
1028
- var LTR = "A-Za-zÀ-ÖØ-öø-ʸ̀-֐ࠀ-῿‎Ⰰ-﬜︀-﹯﻽-￿";
1029
- var rtl = new RegExp("^[^" + LTR + "]*[" + RTL + "]");
1030
- var ltr = new RegExp("^[^" + RTL + "]*[" + LTR + "]");
1031
- function direction(value) {
1032
- value = String(value || "");
1033
- if (rtl.test(value)) {
1034
- return "rtl";
1035
- }
1036
- if (ltr.test(value)) {
1037
- return "ltr";
1038
- }
1039
- return "neutral";
1040
- }
1041
- const getDirection = /* @__PURE__ */ getDefaultExportFromCjs(direction_1);
1042
- function isObject$e(value) {
1043
- var type = typeof value;
1044
- return value != null && (type == "object" || type == "function");
1045
- }
1046
- var isObject_1 = isObject$e;
1047
- var freeGlobal$1 = typeof commonjsGlobal == "object" && commonjsGlobal && commonjsGlobal.Object === Object && commonjsGlobal;
1048
- var _freeGlobal = freeGlobal$1;
1049
- var freeGlobal = _freeGlobal;
1050
- var freeSelf = typeof self == "object" && self && self.Object === Object && self;
1051
- var root$9 = freeGlobal || freeSelf || Function("return this")();
1052
- var _root = root$9;
1053
- var root$8 = _root;
1054
- var now$1 = function() {
1055
- return root$8.Date.now();
1056
- };
1057
- var now_1 = now$1;
1058
- var reWhitespace = /\s/;
1059
- function trimmedEndIndex$1(string3) {
1060
- var index = string3.length;
1061
- while (index-- && reWhitespace.test(string3.charAt(index))) {
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
959
+ }
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
+ }
1062
989
  }
1063
- return index;
1064
- }
1065
- var _trimmedEndIndex = trimmedEndIndex$1;
1066
- var trimmedEndIndex = _trimmedEndIndex;
1067
- var reTrimStart = /^\s+/;
1068
- function baseTrim$1(string3) {
1069
- return string3 ? string3.slice(0, trimmedEndIndex(string3) + 1).replace(reTrimStart, "") : string3;
1070
- }
1071
- var _baseTrim = baseTrim$1;
1072
- var root$7 = _root;
1073
- var Symbol$7 = root$7.Symbol;
1074
- var _Symbol = Symbol$7;
1075
- var Symbol$6 = _Symbol;
1076
- var objectProto$f = Object.prototype;
1077
- var hasOwnProperty$c = objectProto$f.hasOwnProperty;
1078
- var nativeObjectToString$1 = objectProto$f.toString;
1079
- var symToStringTag$1 = Symbol$6 ? Symbol$6.toStringTag : void 0;
1080
- function getRawTag$1(value) {
1081
- var isOwn = hasOwnProperty$c.call(value, symToStringTag$1), tag = value[symToStringTag$1];
1082
- try {
1083
- value[symToStringTag$1] = void 0;
1084
- var unmasked = true;
1085
- } catch (e3) {
990
+ /**
991
+ * A unique identifier for Forms.
992
+ *
993
+ * @deprecated use id instead
994
+ */
995
+ get name() {
996
+ return void 0;
1086
997
  }
1087
- var result = nativeObjectToString$1.call(value);
1088
- if (unmasked) {
1089
- if (isOwn) {
1090
- value[symToStringTag$1] = tag;
1091
- } else {
1092
- delete value[symToStringTag$1];
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;
1093
1006
  }
1007
+ return this.finalForm.getState().values || this.initialValues;
1094
1008
  }
1095
- return result;
1096
- }
1097
- var _getRawTag = getRawTag$1;
1098
- var objectProto$e = Object.prototype;
1099
- var nativeObjectToString = objectProto$e.toString;
1100
- function objectToString$1(value) {
1101
- return nativeObjectToString.call(value);
1102
- }
1103
- var _objectToString = objectToString$1;
1104
- var Symbol$5 = _Symbol, getRawTag = _getRawTag, objectToString = _objectToString;
1105
- var nullTag = "[object Null]", undefinedTag = "[object Undefined]";
1106
- var symToStringTag = Symbol$5 ? Symbol$5.toStringTag : void 0;
1107
- function baseGetTag$6(value) {
1108
- if (value == null) {
1109
- return value === void 0 ? undefinedTag : nullTag;
1110
- }
1111
- return symToStringTag && symToStringTag in Object(value) ? getRawTag(value) : objectToString(value);
1112
- }
1113
- var _baseGetTag = baseGetTag$6;
1114
- function isObjectLike$9(value) {
1115
- return value != null && typeof value == "object";
1116
- }
1117
- var isObjectLike_1 = isObjectLike$9;
1118
- var baseGetTag$5 = _baseGetTag, isObjectLike$8 = isObjectLike_1;
1119
- var symbolTag$3 = "[object Symbol]";
1120
- function isSymbol$4(value) {
1121
- return typeof value == "symbol" || isObjectLike$8(value) && baseGetTag$5(value) == symbolTag$3;
1122
- }
1123
- var isSymbol_1 = isSymbol$4;
1124
- var baseTrim = _baseTrim, isObject$d = isObject_1, isSymbol$3 = isSymbol_1;
1125
- var NAN = 0 / 0;
1126
- var reIsBadHex = /^[-+]0x[0-9a-f]+$/i;
1127
- var reIsBinary = /^0b[01]+$/i;
1128
- var reIsOctal = /^0o[0-7]+$/i;
1129
- var freeParseInt = parseInt;
1130
- function toNumber$1(value) {
1131
- if (typeof value == "number") {
1132
- return value;
1009
+ /**
1010
+ * The values the form was initialized with.
1011
+ */
1012
+ get initialValues() {
1013
+ return this.finalForm.getState().initialValues;
1133
1014
  }
1134
- if (isSymbol$3(value)) {
1135
- return NAN;
1015
+ get pristine() {
1016
+ return this.finalForm.getState().pristine;
1136
1017
  }
1137
- if (isObject$d(value)) {
1138
- var other = typeof value.valueOf == "function" ? value.valueOf() : value;
1139
- value = isObject$d(other) ? other + "" : other;
1018
+ get dirty() {
1019
+ return this.finalForm.getState().dirty;
1140
1020
  }
1141
- if (typeof value != "string") {
1142
- return value === 0 ? value : +value;
1021
+ get submitting() {
1022
+ return this.finalForm.getState().submitting;
1143
1023
  }
1144
- value = baseTrim(value);
1145
- var isBinary = reIsBinary.test(value);
1146
- return isBinary || reIsOctal.test(value) ? freeParseInt(value.slice(2), isBinary ? 2 : 8) : reIsBadHex.test(value) ? NAN : +value;
1147
- }
1148
- var toNumber_1 = toNumber$1;
1149
- var isObject$c = isObject_1, now = now_1, toNumber = toNumber_1;
1150
- var FUNC_ERROR_TEXT$3 = "Expected a function";
1151
- var nativeMax$1 = Math.max, nativeMin = Math.min;
1152
- function debounce$1(func, wait, options) {
1153
- var lastArgs, lastThis, maxWait, result, timerId, lastCallTime, lastInvokeTime = 0, leading = false, maxing = false, trailing = true;
1154
- if (typeof func != "function") {
1155
- throw new TypeError(FUNC_ERROR_TEXT$3);
1024
+ get valid() {
1025
+ return this.finalForm.getState().valid;
1156
1026
  }
1157
- wait = toNumber(wait) || 0;
1158
- if (isObject$c(options)) {
1159
- leading = !!options.leading;
1160
- maxing = "maxWait" in options;
1161
- maxWait = maxing ? nativeMax$1(toNumber(options.maxWait) || 0, wait) : maxWait;
1162
- trailing = "trailing" in options ? !!options.trailing : trailing;
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();
1163
1036
  }
1164
- function invokeFunc(time2) {
1165
- var args = lastArgs, thisArg = lastThis;
1166
- lastArgs = lastThis = void 0;
1167
- lastInvokeTime = time2;
1168
- result = func.apply(thisArg, args);
1169
- return result;
1037
+ /**
1038
+ * @deprecated Unnecessary indirection
1039
+ */
1040
+ updateFields(fields) {
1041
+ this.fields = fields;
1170
1042
  }
1171
- function leadingEdge(time2) {
1172
- lastInvokeTime = time2;
1173
- timerId = setTimeout(timerExpired, wait);
1174
- return leading ? invokeFunc(time2) : result;
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
1051
  }
1176
- function remainingWait(time2) {
1177
- var timeSinceLastCall = time2 - lastCallTime, timeSinceLastInvoke = time2 - lastInvokeTime, timeWaiting = wait - timeSinceLastCall;
1178
- return maxing ? nativeMin(timeWaiting, maxWait - timeSinceLastInvoke) : timeWaiting;
1052
+ get mutators() {
1053
+ return this.finalForm.mutators;
1179
1054
  }
1180
- function shouldInvoke(time2) {
1181
- var timeSinceLastCall = time2 - lastCallTime, timeSinceLastInvoke = time2 - lastInvokeTime;
1182
- return lastCallTime === void 0 || timeSinceLastCall >= wait || timeSinceLastCall < 0 || maxing && timeSinceLastInvoke >= maxWait;
1055
+ addQuery(queryId) {
1056
+ this.queries = [...this.queries.filter((id2) => id2 !== queryId), queryId];
1183
1057
  }
1184
- function timerExpired() {
1185
- var time2 = now();
1186
- if (shouldInvoke(time2)) {
1187
- return trailingEdge(time2);
1188
- }
1189
- timerId = setTimeout(timerExpired, remainingWait(time2));
1058
+ removeQuery(queryId) {
1059
+ this.queries = this.queries.filter((id2) => id2 !== queryId);
1190
1060
  }
1191
- function trailingEdge(time2) {
1192
- timerId = void 0;
1193
- if (trailing && lastArgs) {
1194
- return invokeFunc(time2);
1195
- }
1196
- lastArgs = lastThis = void 0;
1197
- return result;
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
+ });
1198
1081
  }
1199
- function cancel() {
1200
- if (timerId !== void 0) {
1201
- clearTimeout(timerId);
1202
- }
1203
- lastInvokeTime = 0;
1204
- lastArgs = lastCallTime = lastThis = timerId = void 0;
1205
- }
1206
- function flush() {
1207
- return timerId === void 0 ? result : trailingEdge(now());
1208
- }
1209
- function debounced() {
1210
- var time2 = now(), isInvoking = shouldInvoke(time2);
1211
- lastArgs = arguments;
1212
- lastThis = this;
1213
- lastCallTime = time2;
1214
- if (isInvoking) {
1215
- if (timerId === void 0) {
1216
- return leadingEdge(lastCallTime);
1217
- }
1218
- if (maxing) {
1219
- clearTimeout(timerId);
1220
- timerId = setTimeout(timerExpired, wait);
1221
- return invokeFunc(lastCallTime);
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);
1222
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;
1223
1116
  }
1224
- if (timerId === void 0) {
1225
- timerId = setTimeout(timerExpired, wait);
1226
- }
1117
+ const result = this.getFieldGroup({
1118
+ formOrObjectField: this,
1119
+ values: this.finalForm.getState().values,
1120
+ namePathIndex: 0,
1121
+ namePath: fieldName.split(".")
1122
+ });
1227
1123
  return result;
1228
1124
  }
1229
- debounced.cancel = cancel;
1230
- debounced.flush = flush;
1231
- return debounced;
1232
- }
1233
- var debounce_1 = debounce$1;
1234
- const debounce$2 = /* @__PURE__ */ getDefaultExportFromCjs(debounce_1);
1235
- var debounce = debounce_1, isObject$b = isObject_1;
1236
- var FUNC_ERROR_TEXT$2 = "Expected a function";
1237
- function throttle(func, wait, options) {
1238
- var leading = true, trailing = true;
1239
- if (typeof func != "function") {
1240
- throw new TypeError(FUNC_ERROR_TEXT$2);
1241
- }
1242
- if (isObject$b(options)) {
1243
- leading = "leading" in options ? !!options.leading : leading;
1244
- trailing = "trailing" in options ? !!options.trailing : trailing;
1245
- }
1246
- return debounce(func, wait, {
1247
- "leading": leading,
1248
- "maxWait": wait,
1249
- "trailing": trailing
1250
- });
1251
- }
1252
- var throttle_1 = throttle;
1253
- const throttle$1 = /* @__PURE__ */ getDefaultExportFromCjs(throttle_1);
1254
- 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) => {
1255
- if (t2.clientHeight < t2.scrollHeight || t2.clientWidth < t2.scrollWidth) {
1256
- const o3 = getComputedStyle(t2, null);
1257
- return e$3(o3.overflowY, n2) || e$3(o3.overflowX, n2) || ((t3) => {
1258
- const e3 = ((t4) => {
1259
- if (!t4.ownerDocument || !t4.ownerDocument.defaultView)
1260
- return null;
1261
- try {
1262
- return t4.ownerDocument.defaultView.frameElement;
1263
- } catch (t5) {
1264
- return null;
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
+ }
1265
1241
  }
1266
- })(t3);
1267
- return !!e3 && (e3.clientHeight < t3.scrollHeight || e3.clientWidth < t3.scrollWidth);
1268
- })(t2);
1269
- }
1270
- return false;
1271
- }, 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) => {
1272
- const e3 = t2.parentElement;
1273
- return null == e3 ? t2.getRootNode().host || null : e3;
1274
- }, r$3 = (e3, r2) => {
1275
- var i2, s2, d2, h;
1276
- if ("undefined" == typeof document)
1277
- return [];
1278
- const { scrollMode: c2, block: f2, inline: u2, boundary: a2, skipOverflowHiddenElements: g } = r2, p2 = "function" == typeof a2 ? a2 : (t2) => t2 !== a2;
1279
- if (!t$2(e3))
1280
- throw new TypeError("Invalid target");
1281
- const m = document.scrollingElement || document.documentElement, w2 = [];
1282
- let W = e3;
1283
- for (; t$2(W) && p2(W); ) {
1284
- if (W = l$2(W), W === m) {
1285
- w2.push(W);
1286
- break;
1287
- }
1288
- null != W && W === document.body && n$3(W) && !n$3(document.documentElement) || null != W && n$3(W, g) && w2.push(W);
1289
- }
1290
- 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) => {
1291
- const e4 = window.getComputedStyle(t2);
1292
- return { top: parseFloat(e4.scrollMarginTop) || 0, right: parseFloat(e4.scrollMarginRight) || 0, bottom: parseFloat(e4.scrollMarginBottom) || 0, left: parseFloat(e4.scrollMarginLeft) || 0 };
1293
- })(e3);
1294
- 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;
1295
- const L = [];
1296
- for (let t2 = 0; t2 < w2.length; t2++) {
1297
- const e4 = w2[t2], { height: l2, width: r3, top: i3, right: s3, bottom: d3, left: h2 } = e4.getBoundingClientRect();
1298
- 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))
1299
- return L;
1300
- const a3 = getComputedStyle(e4), g2 = parseInt(a3.borderLeftWidth, 10), p3 = parseInt(a3.borderTopWidth, 10), W2 = parseInt(a3.borderRightWidth, 10), T2 = parseInt(a3.borderBottomWidth, 10);
1301
- let B2 = 0, F2 = 0;
1302
- 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;
1303
- if (m === e4)
1304
- 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);
1305
- else {
1306
- 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);
1307
- const { scrollLeft: t3, scrollTop: n2 } = e4;
1308
- 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;
1309
- }
1310
- L.push({ el: e4, top: B2, left: F2 });
1311
- }
1312
- return L;
1313
- };
1314
- 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" };
1315
- function e$2(e3, r2) {
1316
- if (!e3.isConnected || !((t2) => {
1317
- let o3 = t2;
1318
- for (; o3 && o3.parentNode; ) {
1319
- if (o3.parentNode === document)
1320
- return true;
1321
- o3 = o3.parentNode instanceof ShadowRoot ? o3.parentNode.host : o3.parentNode;
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
+ }
1322
1338
  }
1323
- return false;
1324
- })(e3))
1325
- return;
1326
- const n2 = ((t2) => {
1327
- const o3 = window.getComputedStyle(t2);
1328
- return { top: parseFloat(o3.scrollMarginTop) || 0, right: parseFloat(o3.scrollMarginRight) || 0, bottom: parseFloat(o3.scrollMarginBottom) || 0, left: parseFloat(o3.scrollMarginLeft) || 0 };
1329
- })(e3);
1330
- if (((t2) => "object" == typeof t2 && "function" == typeof t2.behavior)(r2))
1331
- return r2.behavior(r$3(e3, r2));
1332
- const l2 = "boolean" == typeof r2 || null == r2 ? void 0 : r2.behavior;
1333
- for (const { el: a2, top: i2, left: s2 } of r$3(e3, o$2(r2))) {
1334
- const t2 = i2 - n2.top + n2.bottom, o3 = s2 - n2.left + n2.right;
1335
- a2.scroll({ top: t2, left: o3, behavior: l2 });
1336
1339
  }
1337
1340
  }
1338
- /*!
1339
- * is-plain-object <https://github.com/jonschlinkert/is-plain-object>
1340
- *
1341
- * Copyright (c) 2014-2017, Jon Schlinkert.
1342
- * Released under the MIT License.
1343
- */
1344
- function isObject$a(o3) {
1345
- return Object.prototype.toString.call(o3) === "[object Object]";
1341
+ function updateEverything(form, values) {
1342
+ Object.entries(values).forEach(([path3, value]) => {
1343
+ form.change(path3, value);
1344
+ });
1346
1345
  }
1347
- function isPlainObject$5(o3) {
1348
- var ctor, prot;
1349
- if (isObject$a(o3) === false)
1350
- return false;
1351
- ctor = o3.constructor;
1352
- if (ctor === void 0)
1353
- return true;
1354
- prot = ctor.prototype;
1355
- if (isObject$a(prot) === false)
1356
- return false;
1357
- if (prot.hasOwnProperty("isPrototypeOf") === false) {
1358
- return false;
1359
- }
1360
- return true;
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);
1355
+ }
1356
+ } else if (path3 !== activePath) {
1357
+ form.change(path3, value);
1358
+ }
1359
+ });
1361
1360
  }
1362
- var NOTHING = Symbol.for("immer-nothing");
1363
- var DRAFTABLE = Symbol.for("immer-draftable");
1364
- var DRAFT_STATE = Symbol.for("immer-state");
1365
- var errors = process.env.NODE_ENV !== "production" ? [
1366
- // All error codes, starting by 0:
1367
- function(plugin) {
1368
- return `The plugin for '${plugin}' has not been loaded into Immer. To enable the plugin, import and call \`enable${plugin}()\` when initializing your application.`;
1369
- },
1370
- function(thing) {
1371
- return `produce can only be called on things that are draftable: plain objects, arrays, Map, Set or classes that are marked with '[immerable]: true'. Got '${thing}'`;
1372
- },
1373
- "This object has been frozen and should not be mutated",
1374
- function(data) {
1375
- return "Cannot use a proxy that has been revoked. Did you pass an object from inside an immer function to an async process? " + data;
1376
- },
1377
- "An immer producer returned a new value *and* modified its draft. Either return a new value *or* modify the draft.",
1378
- "Immer forbids circular references",
1379
- "The first or second argument to `produce` must be a function",
1380
- "The third argument to `produce` must be a function or undefined",
1381
- "First argument to `createDraft` must be a plain object, an array, or an immerable object",
1382
- "First argument to `finishDraft` must be a draft returned by `createDraft`",
1383
- function(thing) {
1384
- return `'current' expects a draft, got: ${thing}`;
1385
- },
1386
- "Object.defineProperty() cannot be used on an Immer draft",
1387
- "Object.setPrototypeOf() cannot be used on an Immer draft",
1388
- "Immer only supports deleting array indices",
1389
- "Immer only supports setting array indices and the 'length' property",
1390
- function(thing) {
1391
- return `'original' expects a draft, got: ${thing}`;
1392
- }
1393
- // Note: if more errors are added, the errorOffset in Patches.ts should be increased
1394
- // See Patches.ts for additional errors
1395
- ] : [];
1396
- function die(error2, ...args) {
1397
- if (process.env.NODE_ENV !== "production") {
1398
- const e3 = errors[error2];
1399
- const msg2 = typeof e3 === "function" ? e3.apply(null, args) : e3;
1400
- throw new Error(`[Immer] ${msg2}`);
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];
1401
1368
  }
1402
- throw new Error(
1403
- `[Immer] minified error nr: ${error2}. Full error at: https://bit.ly/3cXEKWf`
1404
- );
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]);
1405
1383
  }
1406
- var getPrototypeOf = Object.getPrototypeOf;
1407
- function isDraft$1(value) {
1408
- return !!value && !!value[DRAFT_STATE];
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
+ });
1392
+ });
1409
1393
  }
1410
- function isDraftable$1(value) {
1411
- var _a2;
1412
- if (!value)
1413
- return false;
1414
- return isPlainObject$4(value) || Array.isArray(value) || !!value[DRAFTABLE] || !!((_a2 = value.constructor) == null ? void 0 : _a2[DRAFTABLE]) || isMap$2(value) || isSet$2(value);
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
+ };
1415
1412
  }
1416
- var objectCtorString$1 = Object.prototype.constructor.toString();
1417
- function isPlainObject$4(value) {
1418
- if (!value || typeof value !== "object")
1419
- return false;
1420
- const proto = getPrototypeOf(value);
1421
- if (proto === null) {
1422
- return true;
1423
- }
1424
- const Ctor = Object.hasOwnProperty.call(proto, "constructor") && proto.constructor;
1425
- if (Ctor === Object)
1426
- return true;
1427
- return typeof Ctor == "function" && Function.toString.call(Ctor) === objectCtorString$1;
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
+ };
1428
1430
  }
1429
- function each(obj, iter) {
1430
- if (getArchtype(obj) === 0) {
1431
- Reflect.ownKeys(obj).forEach((key) => {
1432
- iter(key, obj[key], obj);
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 }
1433
1480
  });
1434
- } else {
1435
- obj.forEach((entry, index) => iter(index, entry, obj));
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");
1519
+ }
1520
+ if (isHovering) {
1521
+ return buildClasses("blue-500");
1522
+ }
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
+ );
1436
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;
1437
1606
  }
1438
- function getArchtype(thing) {
1439
- const state = thing[DRAFT_STATE];
1440
- return state ? state.type_ : Array.isArray(thing) ? 1 : isMap$2(thing) ? 2 : isSet$2(thing) ? 3 : 0;
1441
- }
1442
- function has$2(thing, prop2) {
1443
- return getArchtype(thing) === 2 ? thing.has(prop2) : Object.prototype.hasOwnProperty.call(thing, prop2);
1444
- }
1445
- function set$3(thing, propOrOldValue, value) {
1446
- const t2 = getArchtype(thing);
1447
- if (t2 === 2)
1448
- thing.set(propOrOldValue, value);
1449
- else if (t2 === 3) {
1450
- thing.add(value);
1451
- } else
1452
- thing[propOrOldValue] = value;
1453
- }
1454
- function is(x, y) {
1455
- if (x === y) {
1456
- return x !== 0 || 1 / x === 1 / y;
1457
- } else {
1458
- return x !== x && y !== y;
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";
1459
1619
  }
1620
+ return "neutral";
1460
1621
  }
1461
- function isMap$2(target) {
1462
- return target instanceof Map;
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");
1463
1626
  }
1464
- function isSet$2(target) {
1465
- return target instanceof Set;
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;
1466
1645
  }
1467
- function latest$1(state) {
1468
- return state.copy_ || state.base_;
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;
1469
1651
  }
1470
- function shallowCopy$1(base, strict) {
1471
- if (isMap$2(base)) {
1472
- return new Map(base);
1473
- }
1474
- if (isSet$2(base)) {
1475
- return new Set(base);
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) {
1476
1667
  }
1477
- if (Array.isArray(base))
1478
- return Array.prototype.slice.call(base);
1479
- const isPlain = isPlainObject$4(base);
1480
- if (strict === true || strict === "class_only" && !isPlain) {
1481
- const descriptors = Object.getOwnPropertyDescriptors(base);
1482
- delete descriptors[DRAFT_STATE];
1483
- let keys2 = Reflect.ownKeys(descriptors);
1484
- for (let i2 = 0; i2 < keys2.length; i2++) {
1485
- const key = keys2[i2];
1486
- const desc = descriptors[key];
1487
- if (desc.writable === false) {
1488
- desc.writable = true;
1489
- desc.configurable = true;
1490
- }
1491
- if (desc.get || desc.set)
1492
- descriptors[key] = {
1493
- configurable: true,
1494
- writable: true,
1495
- // could live with !!desc.set as well here...
1496
- enumerable: desc.enumerable,
1497
- value: base[key]
1498
- };
1499
- }
1500
- return Object.create(getPrototypeOf(base), descriptors);
1501
- } else {
1502
- const proto = getPrototypeOf(base);
1503
- if (proto !== null && isPlain) {
1504
- return { ...base };
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];
1505
1674
  }
1506
- const obj = Object.create(proto);
1507
- return Object.assign(obj, base);
1508
- }
1509
- }
1510
- function freeze$1(obj, deep = false) {
1511
- if (isFrozen(obj) || isDraft$1(obj) || !isDraftable$1(obj))
1512
- return obj;
1513
- if (getArchtype(obj) > 1) {
1514
- obj.set = obj.add = obj.clear = obj.delete = dontMutateFrozenCollections;
1515
1675
  }
1516
- Object.freeze(obj);
1517
- if (deep)
1518
- Object.entries(obj).forEach(([key, value]) => freeze$1(value, true));
1519
- return obj;
1520
- }
1521
- function dontMutateFrozenCollections() {
1522
- die(2);
1676
+ return result;
1523
1677
  }
1524
- function isFrozen(obj) {
1525
- return Object.isFrozen(obj);
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);
1526
1683
  }
1527
- var plugins = {};
1528
- function getPlugin(pluginKey) {
1529
- const plugin = plugins[pluginKey];
1530
- if (!plugin) {
1531
- die(0, pluginKey);
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;
1532
1691
  }
1533
- return plugin;
1692
+ return symToStringTag && symToStringTag in Object(value) ? getRawTag(value) : objectToString(value);
1534
1693
  }
1535
- var currentScope;
1536
- function getCurrentScope() {
1537
- return currentScope;
1694
+ var _baseGetTag = baseGetTag$6;
1695
+ function isObjectLike$9(value) {
1696
+ return value != null && typeof value == "object";
1538
1697
  }
1539
- function createScope(parent_, immer_) {
1540
- return {
1541
- drafts_: [],
1542
- parent_,
1543
- immer_,
1544
- // Whenever the modified draft contains a draft from another scope, we
1545
- // need to prevent auto-freezing so the unowned draft can be finalized.
1546
- canAutoFreeze_: true,
1547
- unfinalizedDrafts_: 0
1548
- };
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;
1549
1703
  }
1550
- function usePatchesInScope(scope, patchListener) {
1551
- if (patchListener) {
1552
- getPlugin("Patches");
1553
- scope.patches_ = [];
1554
- scope.inversePatches_ = [];
1555
- scope.patchListener_ = patchListener;
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;
1556
1714
  }
1557
- }
1558
- function revokeScope(scope) {
1559
- leaveScope(scope);
1560
- scope.drafts_.forEach(revokeDraft);
1561
- scope.drafts_ = null;
1562
- }
1563
- function leaveScope(scope) {
1564
- if (scope === currentScope) {
1565
- currentScope = scope.parent_;
1715
+ if (isSymbol$3(value)) {
1716
+ return NAN;
1566
1717
  }
1567
- }
1568
- function enterScope(immer2) {
1569
- return currentScope = createScope(currentScope, immer2);
1570
- }
1571
- function revokeDraft(draft) {
1572
- const state = draft[DRAFT_STATE];
1573
- if (state.type_ === 0 || state.type_ === 1)
1574
- state.revoke_();
1575
- else
1576
- state.revoked_ = true;
1577
- }
1578
- function processResult(result, scope) {
1579
- scope.unfinalizedDrafts_ = scope.drafts_.length;
1580
- const baseDraft = scope.drafts_[0];
1581
- const isReplaced = result !== void 0 && result !== baseDraft;
1582
- if (isReplaced) {
1583
- if (baseDraft[DRAFT_STATE].modified_) {
1584
- revokeScope(scope);
1585
- die(4);
1586
- }
1587
- if (isDraftable$1(result)) {
1588
- result = finalize(scope, result);
1589
- if (!scope.parent_)
1590
- maybeFreeze(scope, result);
1591
- }
1592
- if (scope.patches_) {
1593
- getPlugin("Patches").generateReplacementPatches_(
1594
- baseDraft[DRAFT_STATE].base_,
1595
- result,
1596
- scope.patches_,
1597
- scope.inversePatches_
1598
- );
1599
- }
1600
- } else {
1601
- result = finalize(scope, baseDraft, []);
1718
+ if (isObject$d(value)) {
1719
+ var other = typeof value.valueOf == "function" ? value.valueOf() : value;
1720
+ value = isObject$d(other) ? other + "" : other;
1602
1721
  }
1603
- revokeScope(scope);
1604
- if (scope.patches_) {
1605
- scope.patchListener_(scope.patches_, scope.inversePatches_);
1722
+ if (typeof value != "string") {
1723
+ return value === 0 ? value : +value;
1606
1724
  }
1607
- return result !== NOTHING ? result : void 0;
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;
1608
1728
  }
1609
- function finalize(rootScope, value, path3) {
1610
- if (isFrozen(value))
1611
- return value;
1612
- const state = value[DRAFT_STATE];
1613
- if (!state) {
1614
- each(
1615
- value,
1616
- (key, childValue) => finalizeProperty(rootScope, state, value, key, childValue, path3)
1617
- );
1618
- return value;
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);
1619
1737
  }
1620
- if (state.scope_ !== rootScope)
1621
- return value;
1622
- if (!state.modified_) {
1623
- maybeFreeze(rootScope, state.base_, true);
1624
- return state.base_;
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;
1625
1744
  }
1626
- if (!state.finalized_) {
1627
- state.finalized_ = true;
1628
- state.scope_.unfinalizedDrafts_--;
1629
- const result = state.copy_;
1630
- let resultEach = result;
1631
- let isSet2 = false;
1632
- if (state.type_ === 3) {
1633
- resultEach = new Set(result);
1634
- result.clear();
1635
- isSet2 = true;
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);
1636
1769
  }
1637
- each(
1638
- resultEach,
1639
- (key, childValue) => finalizeProperty(rootScope, state, result, key, childValue, path3, isSet2)
1640
- );
1641
- maybeFreeze(rootScope, result, false);
1642
- if (path3 && rootScope.patches_) {
1643
- getPlugin("Patches").generatePatches_(
1644
- state,
1645
- path3,
1646
- rootScope.patches_,
1647
- rootScope.inversePatches_
1648
- );
1770
+ timerId = setTimeout(timerExpired, remainingWait(time2));
1771
+ }
1772
+ function trailingEdge(time2) {
1773
+ timerId = void 0;
1774
+ if (trailing && lastArgs) {
1775
+ return invokeFunc(time2);
1649
1776
  }
1777
+ lastArgs = lastThis = void 0;
1778
+ return result;
1650
1779
  }
1651
- return state.copy_;
1652
- }
1653
- function finalizeProperty(rootScope, parentState, targetObject, prop2, childValue, rootPath, targetIsSet) {
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;
1894
+ };
1895
+ 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
+ function e$2(e3, r2) {
1897
+ if (!e3.isConnected || !((t2) => {
1898
+ let o3 = t2;
1899
+ for (; o3 && o3.parentNode; ) {
1900
+ if (o3.parentNode === document)
1901
+ return true;
1902
+ o3 = o3.parentNode instanceof ShadowRoot ? o3.parentNode.host : o3.parentNode;
1903
+ }
1904
+ return false;
1905
+ })(e3))
1906
+ return;
1907
+ const n2 = ((t2) => {
1908
+ const o3 = window.getComputedStyle(t2);
1909
+ return { top: parseFloat(o3.scrollMarginTop) || 0, right: parseFloat(o3.scrollMarginRight) || 0, bottom: parseFloat(o3.scrollMarginBottom) || 0, left: parseFloat(o3.scrollMarginLeft) || 0 };
1910
+ })(e3);
1911
+ if (((t2) => "object" == typeof t2 && "function" == typeof t2.behavior)(r2))
1912
+ return r2.behavior(r$3(e3, r2));
1913
+ const l2 = "boolean" == typeof r2 || null == r2 ? void 0 : r2.behavior;
1914
+ for (const { el: a2, top: i2, left: s2 } of r$3(e3, o$2(r2))) {
1915
+ const t2 = i2 - n2.top + n2.bottom, o3 = s2 - n2.left + n2.right;
1916
+ a2.scroll({ top: t2, left: o3, behavior: l2 });
1917
+ }
1918
+ }
1919
+ /*!
1920
+ * is-plain-object <https://github.com/jonschlinkert/is-plain-object>
1921
+ *
1922
+ * Copyright (c) 2014-2017, Jon Schlinkert.
1923
+ * Released under the MIT License.
1924
+ */
1925
+ function isObject$a(o3) {
1926
+ return Object.prototype.toString.call(o3) === "[object Object]";
1927
+ }
1928
+ function isPlainObject$5(o3) {
1929
+ var ctor, prot;
1930
+ if (isObject$a(o3) === false)
1931
+ return false;
1932
+ ctor = o3.constructor;
1933
+ if (ctor === void 0)
1934
+ return true;
1935
+ prot = ctor.prototype;
1936
+ if (isObject$a(prot) === false)
1937
+ return false;
1938
+ if (prot.hasOwnProperty("isPrototypeOf") === false) {
1939
+ return false;
1940
+ }
1941
+ return true;
1942
+ }
1943
+ var NOTHING = Symbol.for("immer-nothing");
1944
+ var DRAFTABLE = Symbol.for("immer-draftable");
1945
+ var DRAFT_STATE = Symbol.for("immer-state");
1946
+ var errors = process.env.NODE_ENV !== "production" ? [
1947
+ // All error codes, starting by 0:
1948
+ function(plugin) {
1949
+ return `The plugin for '${plugin}' has not been loaded into Immer. To enable the plugin, import and call \`enable${plugin}()\` when initializing your application.`;
1950
+ },
1951
+ function(thing) {
1952
+ return `produce can only be called on things that are draftable: plain objects, arrays, Map, Set or classes that are marked with '[immerable]: true'. Got '${thing}'`;
1953
+ },
1954
+ "This object has been frozen and should not be mutated",
1955
+ function(data) {
1956
+ return "Cannot use a proxy that has been revoked. Did you pass an object from inside an immer function to an async process? " + data;
1957
+ },
1958
+ "An immer producer returned a new value *and* modified its draft. Either return a new value *or* modify the draft.",
1959
+ "Immer forbids circular references",
1960
+ "The first or second argument to `produce` must be a function",
1961
+ "The third argument to `produce` must be a function or undefined",
1962
+ "First argument to `createDraft` must be a plain object, an array, or an immerable object",
1963
+ "First argument to `finishDraft` must be a draft returned by `createDraft`",
1964
+ function(thing) {
1965
+ return `'current' expects a draft, got: ${thing}`;
1966
+ },
1967
+ "Object.defineProperty() cannot be used on an Immer draft",
1968
+ "Object.setPrototypeOf() cannot be used on an Immer draft",
1969
+ "Immer only supports deleting array indices",
1970
+ "Immer only supports setting array indices and the 'length' property",
1971
+ function(thing) {
1972
+ return `'original' expects a draft, got: ${thing}`;
1973
+ }
1974
+ // Note: if more errors are added, the errorOffset in Patches.ts should be increased
1975
+ // See Patches.ts for additional errors
1976
+ ] : [];
1977
+ function die(error2, ...args) {
1978
+ if (process.env.NODE_ENV !== "production") {
1979
+ const e3 = errors[error2];
1980
+ const msg2 = typeof e3 === "function" ? e3.apply(null, args) : e3;
1981
+ throw new Error(`[Immer] ${msg2}`);
1982
+ }
1983
+ throw new Error(
1984
+ `[Immer] minified error nr: ${error2}. Full error at: https://bit.ly/3cXEKWf`
1985
+ );
1986
+ }
1987
+ var getPrototypeOf = Object.getPrototypeOf;
1988
+ function isDraft$1(value) {
1989
+ return !!value && !!value[DRAFT_STATE];
1990
+ }
1991
+ function isDraftable$1(value) {
1992
+ var _a2;
1993
+ if (!value)
1994
+ return false;
1995
+ return isPlainObject$4(value) || Array.isArray(value) || !!value[DRAFTABLE] || !!((_a2 = value.constructor) == null ? void 0 : _a2[DRAFTABLE]) || isMap$2(value) || isSet$2(value);
1996
+ }
1997
+ var objectCtorString$1 = Object.prototype.constructor.toString();
1998
+ function isPlainObject$4(value) {
1999
+ if (!value || typeof value !== "object")
2000
+ return false;
2001
+ const proto = getPrototypeOf(value);
2002
+ if (proto === null) {
2003
+ return true;
2004
+ }
2005
+ const Ctor = Object.hasOwnProperty.call(proto, "constructor") && proto.constructor;
2006
+ if (Ctor === Object)
2007
+ return true;
2008
+ return typeof Ctor == "function" && Function.toString.call(Ctor) === objectCtorString$1;
2009
+ }
2010
+ function each(obj, iter) {
2011
+ if (getArchtype(obj) === 0) {
2012
+ Reflect.ownKeys(obj).forEach((key) => {
2013
+ iter(key, obj[key], obj);
2014
+ });
2015
+ } else {
2016
+ obj.forEach((entry, index) => iter(index, entry, obj));
2017
+ }
2018
+ }
2019
+ function getArchtype(thing) {
2020
+ const state = thing[DRAFT_STATE];
2021
+ return state ? state.type_ : Array.isArray(thing) ? 1 : isMap$2(thing) ? 2 : isSet$2(thing) ? 3 : 0;
2022
+ }
2023
+ function has$2(thing, prop2) {
2024
+ return getArchtype(thing) === 2 ? thing.has(prop2) : Object.prototype.hasOwnProperty.call(thing, prop2);
2025
+ }
2026
+ function set$3(thing, propOrOldValue, value) {
2027
+ const t2 = getArchtype(thing);
2028
+ if (t2 === 2)
2029
+ thing.set(propOrOldValue, value);
2030
+ else if (t2 === 3) {
2031
+ thing.add(value);
2032
+ } else
2033
+ thing[propOrOldValue] = value;
2034
+ }
2035
+ function is(x, y) {
2036
+ if (x === y) {
2037
+ return x !== 0 || 1 / x === 1 / y;
2038
+ } else {
2039
+ return x !== x && y !== y;
2040
+ }
2041
+ }
2042
+ function isMap$2(target) {
2043
+ return target instanceof Map;
2044
+ }
2045
+ function isSet$2(target) {
2046
+ return target instanceof Set;
2047
+ }
2048
+ function latest$1(state) {
2049
+ return state.copy_ || state.base_;
2050
+ }
2051
+ function shallowCopy$1(base, strict) {
2052
+ if (isMap$2(base)) {
2053
+ return new Map(base);
2054
+ }
2055
+ if (isSet$2(base)) {
2056
+ return new Set(base);
2057
+ }
2058
+ if (Array.isArray(base))
2059
+ return Array.prototype.slice.call(base);
2060
+ const isPlain = isPlainObject$4(base);
2061
+ if (strict === true || strict === "class_only" && !isPlain) {
2062
+ const descriptors = Object.getOwnPropertyDescriptors(base);
2063
+ delete descriptors[DRAFT_STATE];
2064
+ let keys2 = Reflect.ownKeys(descriptors);
2065
+ for (let i2 = 0; i2 < keys2.length; i2++) {
2066
+ const key = keys2[i2];
2067
+ const desc = descriptors[key];
2068
+ if (desc.writable === false) {
2069
+ desc.writable = true;
2070
+ desc.configurable = true;
2071
+ }
2072
+ if (desc.get || desc.set)
2073
+ descriptors[key] = {
2074
+ configurable: true,
2075
+ writable: true,
2076
+ // could live with !!desc.set as well here...
2077
+ enumerable: desc.enumerable,
2078
+ value: base[key]
2079
+ };
2080
+ }
2081
+ return Object.create(getPrototypeOf(base), descriptors);
2082
+ } else {
2083
+ const proto = getPrototypeOf(base);
2084
+ if (proto !== null && isPlain) {
2085
+ return { ...base };
2086
+ }
2087
+ const obj = Object.create(proto);
2088
+ return Object.assign(obj, base);
2089
+ }
2090
+ }
2091
+ function freeze$1(obj, deep = false) {
2092
+ if (isFrozen(obj) || isDraft$1(obj) || !isDraftable$1(obj))
2093
+ return obj;
2094
+ if (getArchtype(obj) > 1) {
2095
+ obj.set = obj.add = obj.clear = obj.delete = dontMutateFrozenCollections;
2096
+ }
2097
+ Object.freeze(obj);
2098
+ if (deep)
2099
+ Object.entries(obj).forEach(([key, value]) => freeze$1(value, true));
2100
+ return obj;
2101
+ }
2102
+ function dontMutateFrozenCollections() {
2103
+ die(2);
2104
+ }
2105
+ function isFrozen(obj) {
2106
+ return Object.isFrozen(obj);
2107
+ }
2108
+ var plugins = {};
2109
+ function getPlugin(pluginKey) {
2110
+ const plugin = plugins[pluginKey];
2111
+ if (!plugin) {
2112
+ die(0, pluginKey);
2113
+ }
2114
+ return plugin;
2115
+ }
2116
+ var currentScope;
2117
+ function getCurrentScope() {
2118
+ return currentScope;
2119
+ }
2120
+ function createScope(parent_, immer_) {
2121
+ return {
2122
+ drafts_: [],
2123
+ parent_,
2124
+ immer_,
2125
+ // Whenever the modified draft contains a draft from another scope, we
2126
+ // need to prevent auto-freezing so the unowned draft can be finalized.
2127
+ canAutoFreeze_: true,
2128
+ unfinalizedDrafts_: 0
2129
+ };
2130
+ }
2131
+ function usePatchesInScope(scope, patchListener) {
2132
+ if (patchListener) {
2133
+ getPlugin("Patches");
2134
+ scope.patches_ = [];
2135
+ scope.inversePatches_ = [];
2136
+ scope.patchListener_ = patchListener;
2137
+ }
2138
+ }
2139
+ function revokeScope(scope) {
2140
+ leaveScope(scope);
2141
+ scope.drafts_.forEach(revokeDraft);
2142
+ scope.drafts_ = null;
2143
+ }
2144
+ function leaveScope(scope) {
2145
+ if (scope === currentScope) {
2146
+ currentScope = scope.parent_;
2147
+ }
2148
+ }
2149
+ function enterScope(immer2) {
2150
+ return currentScope = createScope(currentScope, immer2);
2151
+ }
2152
+ function revokeDraft(draft) {
2153
+ const state = draft[DRAFT_STATE];
2154
+ if (state.type_ === 0 || state.type_ === 1)
2155
+ state.revoke_();
2156
+ else
2157
+ state.revoked_ = true;
2158
+ }
2159
+ function processResult(result, scope) {
2160
+ scope.unfinalizedDrafts_ = scope.drafts_.length;
2161
+ const baseDraft = scope.drafts_[0];
2162
+ const isReplaced = result !== void 0 && result !== baseDraft;
2163
+ if (isReplaced) {
2164
+ if (baseDraft[DRAFT_STATE].modified_) {
2165
+ revokeScope(scope);
2166
+ die(4);
2167
+ }
2168
+ if (isDraftable$1(result)) {
2169
+ result = finalize(scope, result);
2170
+ if (!scope.parent_)
2171
+ maybeFreeze(scope, result);
2172
+ }
2173
+ if (scope.patches_) {
2174
+ getPlugin("Patches").generateReplacementPatches_(
2175
+ baseDraft[DRAFT_STATE].base_,
2176
+ result,
2177
+ scope.patches_,
2178
+ scope.inversePatches_
2179
+ );
2180
+ }
2181
+ } else {
2182
+ result = finalize(scope, baseDraft, []);
2183
+ }
2184
+ revokeScope(scope);
2185
+ if (scope.patches_) {
2186
+ scope.patchListener_(scope.patches_, scope.inversePatches_);
2187
+ }
2188
+ return result !== NOTHING ? result : void 0;
2189
+ }
2190
+ function finalize(rootScope, value, path3) {
2191
+ if (isFrozen(value))
2192
+ return value;
2193
+ const state = value[DRAFT_STATE];
2194
+ if (!state) {
2195
+ each(
2196
+ value,
2197
+ (key, childValue) => finalizeProperty(rootScope, state, value, key, childValue, path3)
2198
+ );
2199
+ return value;
2200
+ }
2201
+ if (state.scope_ !== rootScope)
2202
+ return value;
2203
+ if (!state.modified_) {
2204
+ maybeFreeze(rootScope, state.base_, true);
2205
+ return state.base_;
2206
+ }
2207
+ if (!state.finalized_) {
2208
+ state.finalized_ = true;
2209
+ state.scope_.unfinalizedDrafts_--;
2210
+ const result = state.copy_;
2211
+ let resultEach = result;
2212
+ let isSet2 = false;
2213
+ if (state.type_ === 3) {
2214
+ resultEach = new Set(result);
2215
+ result.clear();
2216
+ isSet2 = true;
2217
+ }
2218
+ each(
2219
+ resultEach,
2220
+ (key, childValue) => finalizeProperty(rootScope, state, result, key, childValue, path3, isSet2)
2221
+ );
2222
+ maybeFreeze(rootScope, result, false);
2223
+ if (path3 && rootScope.patches_) {
2224
+ getPlugin("Patches").generatePatches_(
2225
+ state,
2226
+ path3,
2227
+ rootScope.patches_,
2228
+ rootScope.inversePatches_
2229
+ );
2230
+ }
2231
+ }
2232
+ return state.copy_;
2233
+ }
2234
+ function finalizeProperty(rootScope, parentState, targetObject, prop2, childValue, rootPath, targetIsSet) {
1654
2235
  if (process.env.NODE_ENV !== "production" && childValue === targetObject)
1655
2236
  die(5);
1656
2237
  if (isDraft$1(childValue)) {
@@ -2345,21 +2926,21 @@ var Path = {
2345
2926
  return p2;
2346
2927
  }
2347
2928
  };
2348
- function _typeof$4(o3) {
2929
+ function _typeof$3(o3) {
2349
2930
  "@babel/helpers - typeof";
2350
- return _typeof$4 = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o4) {
2931
+ return _typeof$3 = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o4) {
2351
2932
  return typeof o4;
2352
2933
  } : function(o4) {
2353
2934
  return o4 && "function" == typeof Symbol && o4.constructor === Symbol && o4 !== Symbol.prototype ? "symbol" : typeof o4;
2354
- }, _typeof$4(o3);
2935
+ }, _typeof$3(o3);
2355
2936
  }
2356
2937
  function _toPrimitive$4(input, hint) {
2357
- if (_typeof$4(input) !== "object" || input === null)
2938
+ if (_typeof$3(input) !== "object" || input === null)
2358
2939
  return input;
2359
2940
  var prim = input[Symbol.toPrimitive];
2360
2941
  if (prim !== void 0) {
2361
2942
  var res = prim.call(input, hint || "default");
2362
- if (_typeof$4(res) !== "object")
2943
+ if (_typeof$3(res) !== "object")
2363
2944
  return res;
2364
2945
  throw new TypeError("@@toPrimitive must return a primitive value.");
2365
2946
  }
@@ -2367,7 +2948,7 @@ function _toPrimitive$4(input, hint) {
2367
2948
  }
2368
2949
  function _toPropertyKey$4(arg) {
2369
2950
  var key = _toPrimitive$4(arg, "string");
2370
- return _typeof$4(key) === "symbol" ? key : String(key);
2951
+ return _typeof$3(key) === "symbol" ? key : String(key);
2371
2952
  }
2372
2953
  function _defineProperty$5(obj, key, value) {
2373
2954
  key = _toPropertyKey$4(key);
@@ -7697,21 +8278,21 @@ typeof navigator !== "undefined" && /Safari/.test(navigator.userAgent) && /Versi
7697
8278
  var HAS_BEFORE_INPUT_SUPPORT = (!IS_CHROME_LEGACY || !IS_ANDROID_CHROME_LEGACY) && !IS_EDGE_LEGACY && // globalThis is undefined in older browsers
7698
8279
  typeof globalThis !== "undefined" && globalThis.InputEvent && // @ts-ignore The `getTargetRanges` property isn't recognized.
7699
8280
  typeof globalThis.InputEvent.prototype.getTargetRanges === "function";
7700
- function _typeof$3(o3) {
8281
+ function _typeof$2(o3) {
7701
8282
  "@babel/helpers - typeof";
7702
- return _typeof$3 = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o4) {
8283
+ return _typeof$2 = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o4) {
7703
8284
  return typeof o4;
7704
8285
  } : function(o4) {
7705
8286
  return o4 && "function" == typeof Symbol && o4.constructor === Symbol && o4 !== Symbol.prototype ? "symbol" : typeof o4;
7706
- }, _typeof$3(o3);
8287
+ }, _typeof$2(o3);
7707
8288
  }
7708
8289
  function _toPrimitive$3(input, hint) {
7709
- if (_typeof$3(input) !== "object" || input === null)
8290
+ if (_typeof$2(input) !== "object" || input === null)
7710
8291
  return input;
7711
8292
  var prim = input[Symbol.toPrimitive];
7712
8293
  if (prim !== void 0) {
7713
8294
  var res = prim.call(input, hint || "default");
7714
- if (_typeof$3(res) !== "object")
8295
+ if (_typeof$2(res) !== "object")
7715
8296
  return res;
7716
8297
  throw new TypeError("@@toPrimitive must return a primitive value.");
7717
8298
  }
@@ -7719,7 +8300,7 @@ function _toPrimitive$3(input, hint) {
7719
8300
  }
7720
8301
  function _toPropertyKey$3(arg) {
7721
8302
  var key = _toPrimitive$3(arg, "string");
7722
- return _typeof$3(key) === "symbol" ? key : String(key);
8303
+ return _typeof$2(key) === "symbol" ? key : String(key);
7723
8304
  }
7724
8305
  function _defineProperty$4(obj, key, value) {
7725
8306
  key = _toPropertyKey$3(key);
@@ -9640,21 +10221,21 @@ function _objectWithoutProperties$1(source2, excluded) {
9640
10221
  }
9641
10222
  return target;
9642
10223
  }
9643
- function _typeof$2(o3) {
10224
+ function _typeof$1(o3) {
9644
10225
  "@babel/helpers - typeof";
9645
- return _typeof$2 = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o4) {
10226
+ return _typeof$1 = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o4) {
9646
10227
  return typeof o4;
9647
10228
  } : function(o4) {
9648
10229
  return o4 && "function" == typeof Symbol && o4.constructor === Symbol && o4 !== Symbol.prototype ? "symbol" : typeof o4;
9649
- }, _typeof$2(o3);
10230
+ }, _typeof$1(o3);
9650
10231
  }
9651
10232
  function _toPrimitive$2(input, hint) {
9652
- if (_typeof$2(input) !== "object" || input === null)
10233
+ if (_typeof$1(input) !== "object" || input === null)
9653
10234
  return input;
9654
10235
  var prim = input[Symbol.toPrimitive];
9655
10236
  if (prim !== void 0) {
9656
10237
  var res = prim.call(input, hint || "default");
9657
- if (_typeof$2(res) !== "object")
10238
+ if (_typeof$1(res) !== "object")
9658
10239
  return res;
9659
10240
  throw new TypeError("@@toPrimitive must return a primitive value.");
9660
10241
  }
@@ -9662,7 +10243,7 @@ function _toPrimitive$2(input, hint) {
9662
10243
  }
9663
10244
  function _toPropertyKey$2(arg) {
9664
10245
  var key = _toPrimitive$2(arg, "string");
9665
- return _typeof$2(key) === "symbol" ? key : String(key);
10246
+ return _typeof$1(key) === "symbol" ? key : String(key);
9666
10247
  }
9667
10248
  function _defineProperty$3(obj, key, value) {
9668
10249
  key = _toPropertyKey$2(key);
@@ -19131,7 +19712,7 @@ var isBlock = (editor, value) => ElementApi.isElement(value) && isBlock$1(editor
19131
19712
  function castArray2(value) {
19132
19713
  return Array.isArray(value) ? value : [value];
19133
19714
  }
19134
- var match$2 = (obj, path22, predicate) => {
19715
+ var match$1 = (obj, path22, predicate) => {
19135
19716
  if (!predicate)
19136
19717
  return true;
19137
19718
  if (typeof predicate === "object") {
@@ -19167,7 +19748,7 @@ var getMatch = (editor, { id: id2, block: block2, empty, match: matchObjOrFn, te
19167
19748
  }
19168
19749
  if (typeof matchObjOrFn === "object") {
19169
19750
  hasMatch = true;
19170
- matchFn = combineMatch(matchFn, (n2, p2) => match$2(n2, p2, matchObjOrFn));
19751
+ matchFn = combineMatch(matchFn, (n2, p2) => match$1(n2, p2, matchObjOrFn));
19171
19752
  } else if (typeof matchObjOrFn === "function") {
19172
19753
  hasMatch = true;
19173
19754
  matchFn = combineMatch(matchFn, matchObjOrFn);
@@ -19384,7 +19965,7 @@ var descendant = (editor, options) => {
19384
19965
  pass: ([n2]) => voids ? false : editor.api.isVoid(n2)
19385
19966
  });
19386
19967
  for (const [node22, path22] of nodeEntries) {
19387
- if (match$2(node22, path22, _match)) {
19968
+ if (match$1(node22, path22, _match)) {
19388
19969
  return [node22, at2.concat(path22)];
19389
19970
  }
19390
19971
  }
@@ -19623,10 +20204,10 @@ function e2(e3, r2) {
19623
20204
  a2.scroll({ top: t2, left: o3, behavior: l2 });
19624
20205
  }
19625
20206
  }
19626
- var defaultOptions$1 = {
20207
+ var defaultOptions = {
19627
20208
  scrollMode: "if-needed"
19628
20209
  };
19629
- function scrollIntoView(editor, target, options = defaultOptions$1) {
20210
+ function scrollIntoView(editor, target, options = defaultOptions) {
19630
20211
  requestAnimationFrame(() => {
19631
20212
  let domRange;
19632
20213
  if (PointApi.isPoint(target)) {
@@ -21686,21 +22267,21 @@ function omitBy(object, predicate) {
21686
22267
  }
21687
22268
  var omitBy_1 = omitBy;
21688
22269
  const omitBy$1 = /* @__PURE__ */ getDefaultExportFromCjs(omitBy_1);
21689
- function _typeof$1(o3) {
22270
+ function _typeof(o3) {
21690
22271
  "@babel/helpers - typeof";
21691
- return _typeof$1 = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o4) {
22272
+ return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o4) {
21692
22273
  return typeof o4;
21693
22274
  } : function(o4) {
21694
22275
  return o4 && "function" == typeof Symbol && o4.constructor === Symbol && o4 !== Symbol.prototype ? "symbol" : typeof o4;
21695
- }, _typeof$1(o3);
22276
+ }, _typeof(o3);
21696
22277
  }
21697
22278
  function _toPrimitive$1(input, hint) {
21698
- if (_typeof$1(input) !== "object" || input === null)
22279
+ if (_typeof(input) !== "object" || input === null)
21699
22280
  return input;
21700
22281
  var prim = input[Symbol.toPrimitive];
21701
22282
  if (prim !== void 0) {
21702
22283
  var res = prim.call(input, hint || "default");
21703
- if (_typeof$1(res) !== "object")
22284
+ if (_typeof(res) !== "object")
21704
22285
  return res;
21705
22286
  throw new TypeError("@@toPrimitive must return a primitive value.");
21706
22287
  }
@@ -21708,7 +22289,7 @@ function _toPrimitive$1(input, hint) {
21708
22289
  }
21709
22290
  function _toPropertyKey$1(arg) {
21710
22291
  var key = _toPrimitive$1(arg, "string");
21711
- return _typeof$1(key) === "symbol" ? key : String(key);
22292
+ return _typeof(key) === "symbol" ? key : String(key);
21712
22293
  }
21713
22294
  function _defineProperty$1(obj, key, value) {
21714
22295
  key = _toPropertyKey$1(key);
@@ -28659,7 +29240,7 @@ var getTodoListItemEntry = (editor, { at: at2 = editor.selection } = {}) => {
28659
29240
  }
28660
29241
  }
28661
29242
  };
28662
- var hasListChild = (editor, node3) => node3.children.some((n2) => match$3(n2, [], { type: getListTypes(editor) }));
29243
+ var hasListChild = (editor, node3) => node3.children.some((n2) => match$2(n2, [], { type: getListTypes(editor) }));
28663
29244
  var isAcrossListItems = (editor, at2 = editor.selection) => {
28664
29245
  if (!at2 || RangeApi$1.isCollapsed(at2)) {
28665
29246
  return false;
@@ -28685,7 +29266,7 @@ var moveListItemDown = (editor, { list, listItem }) => {
28685
29266
  if (previousSiblingItem) {
28686
29267
  const [previousNode, previousPath] = previousSiblingItem;
28687
29268
  const sublist = previousNode.children.find(
28688
- (n2) => match$3(n2, [], { type: getListTypes(editor) })
29269
+ (n2) => match$2(n2, [], { type: getListTypes(editor) })
28689
29270
  );
28690
29271
  const newPath = previousPath.concat(
28691
29272
  sublist ? [1, sublist.children.length] : [1]
@@ -29764,10 +30345,10 @@ var normalizeListItem = (editor, {
29764
30345
  );
29765
30346
  return true;
29766
30347
  }
29767
- if (editor.api.isBlock(firstLiChildNode) && !match$3(firstLiChildNode, [], {
30348
+ if (editor.api.isBlock(firstLiChildNode) && !match$2(firstLiChildNode, [], {
29768
30349
  type: editor.getType(BaseListItemContentPlugin)
29769
30350
  })) {
29770
- if (match$3(firstLiChildNode, [], {
30351
+ if (match$2(firstLiChildNode, [], {
29771
30352
  type: getListTypes(editor)
29772
30353
  })) {
29773
30354
  const parent3 = editor.api.parent(listItem[1]);
@@ -29843,7 +30424,7 @@ var normalizeListItem = (editor, {
29843
30424
  var normalizeNestedList = (editor, { nestedListItem }) => {
29844
30425
  const [, path3] = nestedListItem;
29845
30426
  const parentNode = editor.api.parent(path3);
29846
- const hasParentList = parentNode && match$3(parentNode[0], [], { type: getListTypes(editor) });
30427
+ const hasParentList = parentNode && match$2(parentNode[0], [], { type: getListTypes(editor) });
29847
30428
  if (!hasParentList) {
29848
30429
  return false;
29849
30430
  }
@@ -29887,7 +30468,7 @@ var withNormalizeList = ({
29887
30468
  );
29888
30469
  }
29889
30470
  }
29890
- if (match$3(node3, [], { type: getListTypes(editor) })) {
30471
+ if (match$2(node3, [], { type: getListTypes(editor) })) {
29891
30472
  if (node3.children.length === 0 || !node3.children.some((item) => item.type === liType)) {
29892
30473
  return editor.tf.removeNodes({ at: path3 });
29893
30474
  }
@@ -37355,830 +37936,309 @@ const TableFloatingToolbar = withRef$1(
37355
37936
  ), /* @__PURE__ */ React__default.createElement(
37356
37937
  ToolbarButton,
37357
37938
  {
37358
- onClick: () => {
37359
- tf.remove.tableColumn();
37360
- },
37361
- onMouseDown: (e3) => e3.preventDefault(),
37362
- tooltip: "Delete column"
37363
- },
37364
- /* @__PURE__ */ React__default.createElement(XIcon, null)
37365
- ))
37366
- )
37367
- ));
37368
- }
37369
- );
37370
- const TableBordersDropdownMenuContent = withRef$1((props, ref) => {
37371
- const editor = useEditorRef();
37372
- const {
37373
- getOnSelectTableBorder,
37374
- hasBottomBorder,
37375
- hasLeftBorder,
37376
- hasNoBorders,
37377
- hasOuterBorders,
37378
- hasRightBorder,
37379
- hasTopBorder
37380
- } = useTableBordersDropdownMenuContentState();
37381
- return /* @__PURE__ */ React__default.createElement(
37382
- DropdownMenuContent$1,
37383
- {
37384
- ref,
37385
- className: cn$2("min-w-[220px]"),
37386
- onCloseAutoFocus: (e3) => {
37387
- e3.preventDefault();
37388
- editor.tf.focus();
37389
- },
37390
- align: "start",
37391
- side: "right",
37392
- sideOffset: 0,
37393
- ...props
37394
- },
37395
- /* @__PURE__ */ React__default.createElement(DropdownMenuGroup, null, /* @__PURE__ */ React__default.createElement(
37396
- DropdownMenuCheckboxItem,
37397
- {
37398
- checked: hasTopBorder,
37399
- onCheckedChange: getOnSelectTableBorder("top")
37400
- },
37401
- /* @__PURE__ */ React__default.createElement("div", null, "Top Border")
37402
- ), /* @__PURE__ */ React__default.createElement(
37403
- DropdownMenuCheckboxItem,
37404
- {
37405
- checked: hasRightBorder,
37406
- onCheckedChange: getOnSelectTableBorder("right")
37407
- },
37408
- /* @__PURE__ */ React__default.createElement("div", null, "Right Border")
37409
- ), /* @__PURE__ */ React__default.createElement(
37410
- DropdownMenuCheckboxItem,
37411
- {
37412
- checked: hasBottomBorder,
37413
- onCheckedChange: getOnSelectTableBorder("bottom")
37414
- },
37415
- /* @__PURE__ */ React__default.createElement("div", null, "Bottom Border")
37416
- ), /* @__PURE__ */ React__default.createElement(
37417
- DropdownMenuCheckboxItem,
37418
- {
37419
- checked: hasLeftBorder,
37420
- onCheckedChange: getOnSelectTableBorder("left")
37421
- },
37422
- /* @__PURE__ */ React__default.createElement("div", null, "Left Border")
37423
- )),
37424
- /* @__PURE__ */ React__default.createElement(DropdownMenuGroup, null, /* @__PURE__ */ React__default.createElement(
37425
- DropdownMenuCheckboxItem,
37426
- {
37427
- checked: hasNoBorders,
37428
- onCheckedChange: getOnSelectTableBorder("none")
37429
- },
37430
- /* @__PURE__ */ React__default.createElement("div", null, "No Border")
37431
- ), /* @__PURE__ */ React__default.createElement(
37432
- DropdownMenuCheckboxItem,
37433
- {
37434
- checked: hasOuterBorders,
37435
- onCheckedChange: getOnSelectTableBorder("outer")
37436
- },
37437
- /* @__PURE__ */ React__default.createElement("div", null, "Outside Borders")
37438
- ))
37439
- );
37440
- });
37441
- function ColorDropdownMenu({ children, tooltip }) {
37442
- const [open, setOpen] = useState(false);
37443
- const editor = useEditorRef();
37444
- const selectedCells = usePluginOption(TablePlugin, "selectedCells");
37445
- useCallback(
37446
- (color) => {
37447
- setOpen(false);
37448
- setCellBackground(editor, { color, selectedCells: selectedCells ?? [] });
37449
- },
37450
- [selectedCells, editor]
37451
- );
37452
- const onClearColor = useCallback(() => {
37453
- setOpen(false);
37454
- setCellBackground(editor, {
37455
- color: null,
37456
- selectedCells: selectedCells ?? []
37457
- });
37458
- }, [selectedCells, editor]);
37459
- 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")))));
37460
- }
37461
- const TableRowElement = withRef$1(
37462
- ({ children, className, ...props }, ref) => {
37463
- const selected = useSelected();
37464
- return /* @__PURE__ */ React__default.createElement(
37465
- PlateElement,
37466
- {
37467
- as: "tr",
37468
- className: cn$2(className, "group/row"),
37469
- "data-selected": selected ? "true" : void 0,
37470
- ...props
37471
- },
37472
- children
37473
- );
37474
- }
37475
- );
37476
- function classNames$1(...classes) {
37477
- return classes.filter(Boolean).join(" ");
37478
- }
37479
- const uuid = () => {
37480
- return ([1e7] + -1e3 + -4e3 + -8e3 + -1e11).replace(
37481
- /[018]/g,
37482
- (c2) => (c2 ^ crypto.getRandomValues(new Uint8Array(1))[0] & 15 >> c2 / 4).toString(16)
37483
- );
37484
- };
37485
- const blockClasses = "mt-0.5";
37486
- const headerClasses = "font-normal";
37487
- const Components = () => {
37488
- return {
37489
- [SlashInputPlugin.key]: SlashInputElement,
37490
- [HEADING_KEYS$1.h1]: ({
37491
- attributes,
37492
- editor,
37493
- element,
37494
- className,
37495
- ...props
37496
- }) => /* @__PURE__ */ React__default.createElement(
37497
- "h1",
37498
- {
37499
- ...attributes,
37500
- ...props,
37501
- className: classNames$1(
37502
- headerClasses,
37503
- blockClasses,
37504
- className,
37505
- "text-4xl mb-4 last:mb-0 mt-6 first:mt-0 font-libre-baskerville"
37506
- )
37507
- }
37508
- ),
37509
- [HEADING_KEYS$1.h2]: ({
37510
- attributes,
37511
- editor,
37512
- element,
37513
- className,
37514
- ...props
37515
- }) => /* @__PURE__ */ React__default.createElement(
37516
- "h2",
37517
- {
37518
- ...attributes,
37519
- ...props,
37520
- className: classNames$1(
37521
- headerClasses,
37522
- blockClasses,
37523
- className,
37524
- "text-3xl mb-4 last:mb-0 mt-6 first:mt-0 font-libre-baskerville"
37525
- )
37526
- }
37527
- ),
37528
- [HEADING_KEYS$1.h3]: ({
37529
- attributes,
37530
- editor,
37531
- element,
37532
- className,
37533
- ...props
37534
- }) => /* @__PURE__ */ React__default.createElement(
37535
- "h3",
37536
- {
37537
- ...attributes,
37538
- ...props,
37539
- className: classNames$1(
37540
- headerClasses,
37541
- blockClasses,
37542
- className,
37543
- "text-2xl mb-4 last:mb-0 mt-6 first:mt-0 font-libre-baskerville"
37544
- )
37545
- }
37546
- ),
37547
- [HEADING_KEYS$1.h4]: ({
37548
- attributes,
37549
- editor,
37550
- element,
37551
- className,
37552
- ...props
37553
- }) => /* @__PURE__ */ React__default.createElement(
37554
- "h4",
37555
- {
37556
- ...attributes,
37557
- ...props,
37558
- className: classNames$1(
37559
- headerClasses,
37560
- blockClasses,
37561
- className,
37562
- "text-xl mb-4 last:mb-0 mt-6 first:mt-0 font-libre-baskerville"
37563
- )
37564
- }
37565
- ),
37566
- /** Tailwind prose doesn't style h5 and h6 elements */
37567
- [HEADING_KEYS$1.h5]: ({
37568
- attributes,
37569
- editor,
37570
- element,
37571
- className,
37572
- ...props
37573
- }) => /* @__PURE__ */ React__default.createElement(
37574
- "h5",
37575
- {
37576
- ...attributes,
37577
- ...props,
37578
- className: classNames$1(
37579
- headerClasses,
37580
- blockClasses,
37581
- className,
37582
- "text-lg mb-4 last:mb-0 mt-6 first:mt-0"
37583
- ),
37584
- style: { fontFamily: "'Libre Baskerville', serif", fontWeight: "400" }
37585
- }
37586
- ),
37587
- [HEADING_KEYS$1.h6]: ({
37588
- attributes,
37589
- editor,
37590
- element,
37591
- className,
37592
- ...props
37593
- }) => /* @__PURE__ */ React__default.createElement(
37594
- "h6",
37595
- {
37596
- ...attributes,
37597
- ...props,
37598
- className: classNames$1(
37599
- headerClasses,
37600
- blockClasses,
37601
- className,
37602
- "text-base mb-4 last:mb-0 mt-6 first:mt-0"
37603
- ),
37604
- style: { fontFamily: "'Libre Baskerville', serif", fontWeight: "400" }
37605
- }
37606
- ),
37607
- [ParagraphPlugin.key]: ParagraphElement,
37608
- [BlockquotePlugin.key]: BlockquoteElement,
37609
- [CodeBlockPlugin.key]: CodeBlockElement,
37610
- [CodeLinePlugin.key]: CodeLineElement,
37611
- [CodeSyntaxPlugin.key]: CodeSyntaxLeaf,
37612
- html: ({ attributes, editor, element, children, className }) => {
37613
- return /* @__PURE__ */ React__default.createElement(
37614
- "div",
37615
- {
37616
- ...attributes,
37617
- className: classNames$1(
37618
- "font-mono text-sm bg-green-100 cursor-not-allowed mb-4",
37619
- className
37620
- )
37621
- },
37622
- children,
37623
- element.value
37624
- );
37625
- },
37626
- html_inline: ({ attributes, editor, element, children, className }) => {
37627
- return /* @__PURE__ */ React__default.createElement(
37628
- "span",
37629
- {
37630
- ...attributes,
37631
- className: classNames$1(
37632
- "font-mono bg-green-100 cursor-not-allowed",
37633
- className
37634
- )
37635
- },
37636
- children,
37637
- element.value
37638
- );
37639
- },
37640
- [BulletedListPlugin.key]: withProps(ListElement, { variant: "ul" }),
37641
- [NumberedListPlugin.key]: withProps(ListElement, { variant: "ol" }),
37642
- [ListItemPlugin.key]: withProps(PlateElement, { as: "li" }),
37643
- [LinkPlugin.key]: LinkElement,
37644
- [CodePlugin.key]: CodeLeaf,
37645
- [UnderlinePlugin.key]: withProps(PlateLeaf, { as: "u" }),
37646
- [StrikethroughPlugin.key]: withProps(PlateLeaf, { as: "s" }),
37647
- [ItalicPlugin.key]: withProps(PlateLeaf, { as: "em" }),
37648
- [BoldPlugin.key]: withProps(PlateLeaf, { as: "strong" }),
37649
- [HorizontalRulePlugin.key]: HrElement,
37650
- [TableCellHeaderPlugin.key]: TableCellHeaderElement,
37651
- [TableCellPlugin.key]: TableCellElement,
37652
- [TablePlugin.key]: TableElement,
37653
- [TableRowPlugin.key]: TableRowElement
37654
- };
37655
- };
37656
- class Form {
37657
- constructor({
37658
- id: id2,
37659
- label,
37660
- fields,
37661
- actions,
37662
- buttons,
37663
- global: global2,
37664
- reset: reset2,
37665
- loadInitialValues,
37666
- onChange,
37667
- queries,
37668
- ...options
37669
- }) {
37670
- __publicField(this, "__type");
37671
- __publicField(this, "id");
37672
- __publicField(this, "label");
37673
- __publicField(this, "fields");
37674
- __publicField(this, "finalForm");
37675
- __publicField(this, "actions");
37676
- __publicField(this, "buttons");
37677
- __publicField(this, "queries");
37678
- __publicField(this, "global", null);
37679
- __publicField(this, "loading", false);
37680
- /**
37681
- * @deprecated
37682
- * Misleading name as per https://github.com/tinacms/tinacms/issues/5686#issuecomment-2899840518
37683
- * Use path property instead.
37684
- */
37685
- __publicField(this, "relativePath");
37686
- /**
37687
- * Where to save the form within the content directory on next submission.
37688
- */
37689
- __publicField(this, "path");
37690
- __publicField(this, "crudType");
37691
- __publicField(this, "beforeSubmit");
37692
- /**
37693
- * Subscribes to changes to the form. The subscriber will only be called when
37694
- * values specified in subscription change. A form can have many subscribers.
37695
- */
37696
- __publicField(this, "subscribe", (cb, options) => {
37697
- return this.finalForm.subscribe(cb, options);
37698
- });
37699
- __publicField(this, "onSubmit");
37700
- __publicField(this, "handleSubmit", async (values, form, cb) => {
37701
- var _a2;
37702
- try {
37703
- const valOverride = await ((_a2 = this.beforeSubmit) == null ? void 0 : _a2.call(this, values));
37704
- if (valOverride) {
37705
- for (const [key, value] of Object.entries(valOverride)) {
37706
- form.change(key, value);
37707
- }
37708
- }
37709
- const response = await this.onSubmit(valOverride || values, form, cb);
37710
- form.initialize(values);
37711
- return response;
37712
- } catch (error2) {
37713
- return { [FORM_ERROR]: error2 };
37714
- }
37715
- });
37716
- /**
37717
- * Submits the form if there are currently no validation errors. It may
37718
- * return undefined or a Promise depending on the nature of the onSubmit
37719
- * configuration value given to the form when it was created.
37720
- */
37721
- __publicField(this, "submit", () => {
37722
- return this.finalForm.submit();
37723
- });
37724
- const initialValues = options.initialValues || {};
37725
- this.__type = options.__type || "form";
37726
- this.id = id2;
37727
- this.label = label;
37728
- this.global = global2;
37729
- this.fields = fields || [];
37730
- this.onSubmit = options.onSubmit;
37731
- this.queries = queries || [];
37732
- this.crudType = options.crudType || "update";
37733
- this.relativePath = options.relativePath || id2;
37734
- this.path = options.path || id2;
37735
- this.finalForm = createForm({
37736
- ...options,
37737
- initialValues,
37738
- onSubmit: this.handleSubmit,
37739
- mutators: {
37740
- ...arrayMutators,
37741
- setFieldData,
37742
- ...options.mutators
37743
- }
37744
- });
37745
- this._reset = reset2;
37746
- this.actions = actions || [];
37747
- this.buttons = buttons || {
37748
- save: "Save",
37749
- reset: "Reset"
37750
- };
37751
- this.updateFields(this.fields);
37752
- if (loadInitialValues) {
37753
- this.loading = true;
37754
- loadInitialValues().then((initialValues2) => {
37755
- this.updateInitialValues(initialValues2);
37756
- }).finally(() => {
37757
- this.loading = false;
37758
- });
37759
- }
37760
- if (onChange) {
37761
- let firstUpdate = true;
37762
- this.subscribe(
37763
- (formState) => {
37764
- if (firstUpdate) {
37765
- firstUpdate = false;
37766
- } else {
37767
- onChange(formState);
37768
- }
37769
- },
37770
- { values: true, ...(options == null ? void 0 : options.extraSubscribeValues) || {} }
37771
- );
37772
- }
37773
- }
37774
- /**
37775
- * A unique identifier for Forms.
37776
- *
37777
- * @deprecated use id instead
37778
- */
37779
- get name() {
37780
- return void 0;
37781
- }
37782
- /**
37783
- * Returns the current values of the form.
37784
- *
37785
- * if the form is still loading it returns `undefined`.
37786
- */
37787
- get values() {
37788
- if (this.loading) {
37789
- return void 0;
37790
- }
37791
- return this.finalForm.getState().values || this.initialValues;
37792
- }
37793
- /**
37794
- * The values the form was initialized with.
37795
- */
37796
- get initialValues() {
37797
- return this.finalForm.getState().initialValues;
37798
- }
37799
- get pristine() {
37800
- return this.finalForm.getState().pristine;
37801
- }
37802
- get dirty() {
37803
- return this.finalForm.getState().dirty;
37804
- }
37805
- get submitting() {
37806
- return this.finalForm.getState().submitting;
37807
- }
37808
- get valid() {
37809
- return this.finalForm.getState().valid;
37810
- }
37811
- /**
37812
- * Resets the values back to the initial values the form was initialized with.
37813
- * Or empties all the values if the form was not initialized.
37814
- */
37815
- async reset() {
37816
- if (this._reset) {
37817
- await this._reset();
37818
- }
37819
- this.finalForm.reset();
37820
- }
37821
- /**
37822
- * @deprecated Unnecessary indirection
37823
- */
37824
- updateFields(fields) {
37825
- this.fields = fields;
37826
- }
37827
- /**
37828
- * Changes the value of the given field.
37829
- *
37830
- * @param name
37831
- * @param value
37832
- */
37833
- change(name, value) {
37834
- return this.finalForm.change(name, value);
37835
- }
37836
- get mutators() {
37837
- return this.finalForm.mutators;
37838
- }
37839
- addQuery(queryId) {
37840
- this.queries = [...this.queries.filter((id2) => id2 !== queryId), queryId];
37841
- }
37842
- removeQuery(queryId) {
37843
- this.queries = this.queries.filter((id2) => id2 !== queryId);
37844
- }
37845
- /**
37846
- * Updates multiple fields in the form.
37847
- *
37848
- * The updates are batched so that it only triggers one `onChange` event.
37849
- *
37850
- * In order to prevent disruptions to the user's editing experience this
37851
- * function will _not_ update the value of any field that is currently
37852
- * being edited.
37853
- *
37854
- * @param values
37855
- */
37856
- updateValues(values) {
37857
- this.finalForm.batch(() => {
37858
- const activePath = this.finalForm.getState().active;
37859
- if (!activePath) {
37860
- updateEverything(this.finalForm, values);
37861
- } else {
37862
- updateSelectively(this.finalForm, values);
37863
- }
37864
- });
37865
- }
37866
- /**
37867
- * Replaces the initialValues of the form without deleting the current values.
37868
- *
37869
- * This function is helpful when the initialValues are loaded asynchronously.
37870
- *
37871
- * @param initialValues
37872
- */
37873
- updateInitialValues(initialValues) {
37874
- this.finalForm.batch(() => {
37875
- const values = this.values || {};
37876
- this.finalForm.initialize(initialValues);
37877
- const activePath = this.finalForm.getState().active;
37878
- if (!activePath) {
37879
- updateEverything(this.finalForm, values);
37880
- } else {
37881
- updateSelectively(this.finalForm, values);
37882
- }
37883
- });
37884
- }
37885
- /**
37886
- * Based on field's name this function will
37887
- * return an array of fields for the give form along
37888
- * with the path that it was found at top nearest
37889
- * object-like group
37890
- *
37891
- * So if you have a field named blocks.3.title
37892
- * It will return the fields from the 3rd "block"
37893
- * along with the path it was found at
37894
- * fields: [{type: 'string', name: 'title'}, ... other fields]
37895
- * activePath: ['blocks', '3']
37896
- */
37897
- getActiveField(fieldName) {
37898
- if (!fieldName) {
37899
- return this;
37900
- }
37901
- const result = this.getFieldGroup({
37902
- formOrObjectField: this,
37903
- values: this.finalForm.getState().values,
37904
- namePathIndex: 0,
37905
- namePath: fieldName.split(".")
37906
- });
37907
- return result;
37908
- }
37909
- getFieldGroup({
37910
- formOrObjectField,
37911
- values = {},
37912
- namePathIndex,
37913
- namePath
37914
- }) {
37915
- const name = namePath[namePathIndex];
37916
- const field = formOrObjectField.fields.find((field2) => field2.name === name);
37917
- const value = values[name];
37918
- const isLastItem = namePathIndex === namePath.length - 1;
37919
- if (!field) {
37920
- return {
37921
- ...formOrObjectField,
37922
- fields: formOrObjectField.fields.map((field2) => {
37923
- return {
37924
- ...field2,
37925
- name: [...namePath, field2.name].join(".")
37926
- };
37927
- })
37928
- };
37929
- } else {
37930
- if (field.type === "object") {
37931
- if (field.templates) {
37932
- if (field.list) {
37933
- if (isLastItem) {
37934
- return formOrObjectField;
37935
- } else {
37936
- const namePathIndexForListItem = namePathIndex + 1;
37937
- const index = namePath[namePathIndexForListItem];
37938
- const listItemValue = value[index];
37939
- const template = field.templates[listItemValue._template];
37940
- const templateName = [
37941
- ...namePath.slice(0, namePathIndexForListItem),
37942
- index
37943
- ].join(".");
37944
- const isLastItem2 = namePathIndexForListItem === namePath.length - 1;
37945
- if (!isLastItem2) {
37946
- return this.getFieldGroup({
37947
- formOrObjectField: template,
37948
- values: listItemValue,
37949
- namePath,
37950
- namePathIndex: namePathIndex + 2
37951
- });
37952
- }
37953
- if (!template) {
37954
- console.error({ field, value });
37955
- throw new Error(
37956
- `Expected template value for field ${field.name}`
37957
- );
37958
- }
37959
- return {
37960
- ...template,
37961
- name: templateName,
37962
- fields: template.fields.map((field2) => {
37963
- return {
37964
- ...field2,
37965
- name: [templateName, field2.name].join(".")
37966
- };
37967
- })
37968
- };
37969
- }
37970
- }
37971
- } else {
37972
- if (field.list) {
37973
- const namePathIndexForListItem = namePathIndex + 1;
37974
- const index = namePath[namePathIndexForListItem];
37975
- const listItemValue = value[index];
37976
- const fieldName = [
37977
- ...namePath.slice(0, namePathIndexForListItem),
37978
- index
37979
- ].join(".");
37980
- const isLastItem2 = namePathIndexForListItem === namePath.length - 1;
37981
- if (!isLastItem2) {
37982
- if (field.fields) {
37983
- return this.getFieldGroup({
37984
- formOrObjectField: field,
37985
- values: listItemValue,
37986
- namePath,
37987
- namePathIndex: namePathIndex + 2
37988
- });
37989
- }
37990
- }
37991
- return {
37992
- ...field,
37993
- name: fieldName,
37994
- fields: field.fields.map((field2) => {
37995
- return {
37996
- ...field2,
37997
- name: [fieldName, field2.name].join(".")
37998
- };
37999
- })
38000
- };
38001
- } else {
38002
- const fieldName = [...namePath.slice(0, namePathIndex + 1)].join(
38003
- "."
38004
- );
38005
- const isLastItem2 = namePathIndex === namePath.length - 1;
38006
- if (!isLastItem2) {
38007
- return this.getFieldGroup({
38008
- formOrObjectField: field,
38009
- values: value,
38010
- namePath,
38011
- namePathIndex: namePathIndex + 1
38012
- });
38013
- }
38014
- return {
38015
- ...field,
38016
- name: fieldName,
38017
- fields: field.fields.map((field2) => {
38018
- return {
38019
- ...field2,
38020
- name: [fieldName, field2.name].join(".")
38021
- };
38022
- })
38023
- };
38024
- }
38025
- }
38026
- } else if (field.type === "rich-text") {
38027
- if (isLastItem) {
38028
- return {
38029
- ...formOrObjectField,
38030
- fields: formOrObjectField.fields.map((field2) => {
38031
- return {
38032
- ...field2,
38033
- name: [...namePath.slice(0, namePathIndex), field2.name].join(
38034
- "."
38035
- )
38036
- };
38037
- })
38038
- };
38039
- } else {
38040
- const childrenIndex = namePath.findIndex(
38041
- (value2) => value2 === "children"
38042
- );
38043
- const propsIndex = namePath.slice(childrenIndex).findIndex((value2) => value2 === "props") + childrenIndex;
38044
- const itemName = namePath.slice(childrenIndex, propsIndex).join(".");
38045
- const item = getIn(value, itemName);
38046
- const props = item.props;
38047
- const templateString = item.name;
38048
- const currentPathIndex = namePathIndex + Math.max(propsIndex, 3);
38049
- const isLastItem2 = currentPathIndex + 1 === namePath.length;
38050
- const template = field.templates.find(
38051
- (t2) => t2.name === templateString
38052
- );
38053
- const templateName = namePath.slice(0, currentPathIndex + 2).join(".");
38054
- if ((item == null ? void 0 : item.type) === "img") {
38055
- const imageName = namePath.slice(0, currentPathIndex + 2).join(".");
38056
- return {
38057
- ...formOrObjectField,
38058
- // name: [formOrObjectField.name, 'img'].join('.'),
38059
- name: [imageName].join("."),
38060
- fields: [
38061
- {
38062
- type: "image",
38063
- // label: 'URL',
38064
- name: [templateName, "url"].join("."),
38065
- component: "image"
38066
- },
38067
- {
38068
- type: "string",
38069
- label: "Alt",
38070
- name: [templateName.replace(/\.props$/, ""), "alt"].join("."),
38071
- component: "text"
38072
- },
38073
- {
38074
- type: "string",
38075
- label: "Caption",
38076
- name: [templateName.replace(/\.props$/, ""), "caption"].join(
38077
- "."
38078
- ),
38079
- component: "text"
38080
- }
38081
- ]
38082
- };
38083
- }
38084
- if (!isLastItem2) {
38085
- return this.getFieldGroup({
38086
- formOrObjectField: template,
38087
- values: props,
38088
- namePath,
38089
- namePathIndex: namePathIndex + Math.max(4, childrenIndex + propsIndex)
38090
- });
38091
- }
38092
- if (!template) {
38093
- throw new Error(`Expected template value for field ${item.name}`);
38094
- }
38095
- return {
38096
- ...template,
38097
- name: templateName,
38098
- fields: template.fields.map((field2) => {
38099
- return {
38100
- ...field2,
38101
- name: [templateName, field2.name].join(".")
38102
- };
38103
- })
38104
- };
38105
- }
38106
- } else {
38107
- const fieldName = [...namePath.slice(0, namePathIndex)].join(".");
38108
- if (!fieldName) {
38109
- return formOrObjectField;
38110
- }
38111
- return {
38112
- ...formOrObjectField,
38113
- name: fieldName,
38114
- fields: formOrObjectField.fields.map((field2) => {
38115
- return {
38116
- ...field2,
38117
- name: [fieldName, field2.name].join(".")
38118
- };
38119
- })
38120
- };
38121
- }
38122
- }
37939
+ onClick: () => {
37940
+ tf.remove.tableColumn();
37941
+ },
37942
+ onMouseDown: (e3) => e3.preventDefault(),
37943
+ tooltip: "Delete column"
37944
+ },
37945
+ /* @__PURE__ */ React__default.createElement(XIcon, null)
37946
+ ))
37947
+ )
37948
+ ));
38123
37949
  }
37950
+ );
37951
+ const TableBordersDropdownMenuContent = withRef$1((props, ref) => {
37952
+ const editor = useEditorRef();
37953
+ const {
37954
+ getOnSelectTableBorder,
37955
+ hasBottomBorder,
37956
+ hasLeftBorder,
37957
+ hasNoBorders,
37958
+ hasOuterBorders,
37959
+ hasRightBorder,
37960
+ hasTopBorder
37961
+ } = useTableBordersDropdownMenuContentState();
37962
+ return /* @__PURE__ */ React__default.createElement(
37963
+ DropdownMenuContent$1,
37964
+ {
37965
+ ref,
37966
+ className: cn$2("min-w-[220px]"),
37967
+ onCloseAutoFocus: (e3) => {
37968
+ e3.preventDefault();
37969
+ editor.tf.focus();
37970
+ },
37971
+ align: "start",
37972
+ side: "right",
37973
+ sideOffset: 0,
37974
+ ...props
37975
+ },
37976
+ /* @__PURE__ */ React__default.createElement(DropdownMenuGroup, null, /* @__PURE__ */ React__default.createElement(
37977
+ DropdownMenuCheckboxItem,
37978
+ {
37979
+ checked: hasTopBorder,
37980
+ onCheckedChange: getOnSelectTableBorder("top")
37981
+ },
37982
+ /* @__PURE__ */ React__default.createElement("div", null, "Top Border")
37983
+ ), /* @__PURE__ */ React__default.createElement(
37984
+ DropdownMenuCheckboxItem,
37985
+ {
37986
+ checked: hasRightBorder,
37987
+ onCheckedChange: getOnSelectTableBorder("right")
37988
+ },
37989
+ /* @__PURE__ */ React__default.createElement("div", null, "Right Border")
37990
+ ), /* @__PURE__ */ React__default.createElement(
37991
+ DropdownMenuCheckboxItem,
37992
+ {
37993
+ checked: hasBottomBorder,
37994
+ onCheckedChange: getOnSelectTableBorder("bottom")
37995
+ },
37996
+ /* @__PURE__ */ React__default.createElement("div", null, "Bottom Border")
37997
+ ), /* @__PURE__ */ React__default.createElement(
37998
+ DropdownMenuCheckboxItem,
37999
+ {
38000
+ checked: hasLeftBorder,
38001
+ onCheckedChange: getOnSelectTableBorder("left")
38002
+ },
38003
+ /* @__PURE__ */ React__default.createElement("div", null, "Left Border")
38004
+ )),
38005
+ /* @__PURE__ */ React__default.createElement(DropdownMenuGroup, null, /* @__PURE__ */ React__default.createElement(
38006
+ DropdownMenuCheckboxItem,
38007
+ {
38008
+ checked: hasNoBorders,
38009
+ onCheckedChange: getOnSelectTableBorder("none")
38010
+ },
38011
+ /* @__PURE__ */ React__default.createElement("div", null, "No Border")
38012
+ ), /* @__PURE__ */ React__default.createElement(
38013
+ DropdownMenuCheckboxItem,
38014
+ {
38015
+ checked: hasOuterBorders,
38016
+ onCheckedChange: getOnSelectTableBorder("outer")
38017
+ },
38018
+ /* @__PURE__ */ React__default.createElement("div", null, "Outside Borders")
38019
+ ))
38020
+ );
38021
+ });
38022
+ function ColorDropdownMenu({ children, tooltip }) {
38023
+ const [open, setOpen] = useState(false);
38024
+ const editor = useEditorRef();
38025
+ const selectedCells = usePluginOption(TablePlugin, "selectedCells");
38026
+ useCallback(
38027
+ (color) => {
38028
+ setOpen(false);
38029
+ setCellBackground(editor, { color, selectedCells: selectedCells ?? [] });
38030
+ },
38031
+ [selectedCells, editor]
38032
+ );
38033
+ const onClearColor = useCallback(() => {
38034
+ setOpen(false);
38035
+ setCellBackground(editor, {
38036
+ color: null,
38037
+ selectedCells: selectedCells ?? []
38038
+ });
38039
+ }, [selectedCells, editor]);
38040
+ 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")))));
38124
38041
  }
38125
- function updateEverything(form, values) {
38126
- Object.entries(values).forEach(([path3, value]) => {
38127
- form.change(path3, value);
38128
- });
38042
+ const TableRowElement = withRef$1(
38043
+ ({ children, className, ...props }, ref) => {
38044
+ const selected = useSelected();
38045
+ return /* @__PURE__ */ React__default.createElement(
38046
+ PlateElement,
38047
+ {
38048
+ as: "tr",
38049
+ className: cn$2(className, "group/row"),
38050
+ "data-selected": selected ? "true" : void 0,
38051
+ ...props
38052
+ },
38053
+ children
38054
+ );
38055
+ }
38056
+ );
38057
+ function classNames$1(...classes) {
38058
+ return classes.filter(Boolean).join(" ");
38129
38059
  }
38130
- function updateSelectively(form, values, prefix) {
38131
- const activePath = form.getState().active;
38132
- Object.entries(values).forEach(([name, value]) => {
38133
- const path3 = prefix ? `${prefix}.${name}` : name;
38134
- if (typeof value === "object") {
38135
- if (typeof activePath === "string" && activePath.startsWith(path3)) {
38136
- updateSelectively(form, value, path3);
38137
- } else {
38138
- form.change(path3, value);
38060
+ const uuid = () => {
38061
+ return ([1e7] + -1e3 + -4e3 + -8e3 + -1e11).replace(
38062
+ /[018]/g,
38063
+ (c2) => (c2 ^ crypto.getRandomValues(new Uint8Array(1))[0] & 15 >> c2 / 4).toString(16)
38064
+ );
38065
+ };
38066
+ const blockClasses = "mt-0.5";
38067
+ const headerClasses = "font-normal";
38068
+ const Components = () => {
38069
+ return {
38070
+ [SlashInputPlugin.key]: SlashInputElement,
38071
+ [HEADING_KEYS$1.h1]: ({
38072
+ attributes,
38073
+ editor,
38074
+ element,
38075
+ className,
38076
+ ...props
38077
+ }) => /* @__PURE__ */ React__default.createElement(
38078
+ "h1",
38079
+ {
38080
+ ...attributes,
38081
+ ...props,
38082
+ className: classNames$1(
38083
+ headerClasses,
38084
+ blockClasses,
38085
+ className,
38086
+ "text-4xl mb-4 last:mb-0 mt-6 first:mt-0 font-libre-baskerville"
38087
+ )
38139
38088
  }
38140
- } else if (path3 !== activePath) {
38141
- form.change(path3, value);
38142
- }
38143
- });
38144
- }
38145
- function usePlugins(plugins2) {
38146
- const cms = useCMS$1();
38147
- let pluginArray;
38148
- if (Array.isArray(plugins2)) {
38149
- pluginArray = plugins2;
38150
- } else {
38151
- pluginArray = [plugins2];
38152
- }
38153
- React.useEffect(() => {
38154
- pluginArray.forEach((plugin) => {
38155
- if (plugin) {
38156
- cms.plugins.add(plugin);
38089
+ ),
38090
+ [HEADING_KEYS$1.h2]: ({
38091
+ attributes,
38092
+ editor,
38093
+ element,
38094
+ className,
38095
+ ...props
38096
+ }) => /* @__PURE__ */ React__default.createElement(
38097
+ "h2",
38098
+ {
38099
+ ...attributes,
38100
+ ...props,
38101
+ className: classNames$1(
38102
+ headerClasses,
38103
+ blockClasses,
38104
+ className,
38105
+ "text-3xl mb-4 last:mb-0 mt-6 first:mt-0 font-libre-baskerville"
38106
+ )
38157
38107
  }
38158
- });
38159
- return () => {
38160
- pluginArray.forEach((plugin) => {
38161
- if (plugin) {
38162
- cms.plugins.remove(plugin);
38163
- }
38164
- });
38165
- };
38166
- }, [cms.plugins, ...pluginArray]);
38167
- }
38168
- function useSubscribable(subscribable, cb) {
38169
- const [, s2] = React.useState(0);
38170
- React.useEffect(() => {
38171
- return subscribable.subscribe(() => {
38172
- s2((x) => x + 1);
38173
- if (cb)
38174
- cb();
38175
- });
38176
- });
38177
- }
38108
+ ),
38109
+ [HEADING_KEYS$1.h3]: ({
38110
+ attributes,
38111
+ editor,
38112
+ element,
38113
+ className,
38114
+ ...props
38115
+ }) => /* @__PURE__ */ React__default.createElement(
38116
+ "h3",
38117
+ {
38118
+ ...attributes,
38119
+ ...props,
38120
+ className: classNames$1(
38121
+ headerClasses,
38122
+ blockClasses,
38123
+ className,
38124
+ "text-2xl mb-4 last:mb-0 mt-6 first:mt-0 font-libre-baskerville"
38125
+ )
38126
+ }
38127
+ ),
38128
+ [HEADING_KEYS$1.h4]: ({
38129
+ attributes,
38130
+ editor,
38131
+ element,
38132
+ className,
38133
+ ...props
38134
+ }) => /* @__PURE__ */ React__default.createElement(
38135
+ "h4",
38136
+ {
38137
+ ...attributes,
38138
+ ...props,
38139
+ className: classNames$1(
38140
+ headerClasses,
38141
+ blockClasses,
38142
+ className,
38143
+ "text-xl mb-4 last:mb-0 mt-6 first:mt-0 font-libre-baskerville"
38144
+ )
38145
+ }
38146
+ ),
38147
+ /** Tailwind prose doesn't style h5 and h6 elements */
38148
+ [HEADING_KEYS$1.h5]: ({
38149
+ attributes,
38150
+ editor,
38151
+ element,
38152
+ className,
38153
+ ...props
38154
+ }) => /* @__PURE__ */ React__default.createElement(
38155
+ "h5",
38156
+ {
38157
+ ...attributes,
38158
+ ...props,
38159
+ className: classNames$1(
38160
+ headerClasses,
38161
+ blockClasses,
38162
+ className,
38163
+ "text-lg mb-4 last:mb-0 mt-6 first:mt-0"
38164
+ ),
38165
+ style: { fontFamily: "'Libre Baskerville', serif", fontWeight: "400" }
38166
+ }
38167
+ ),
38168
+ [HEADING_KEYS$1.h6]: ({
38169
+ attributes,
38170
+ editor,
38171
+ element,
38172
+ className,
38173
+ ...props
38174
+ }) => /* @__PURE__ */ React__default.createElement(
38175
+ "h6",
38176
+ {
38177
+ ...attributes,
38178
+ ...props,
38179
+ className: classNames$1(
38180
+ headerClasses,
38181
+ blockClasses,
38182
+ className,
38183
+ "text-base mb-4 last:mb-0 mt-6 first:mt-0"
38184
+ ),
38185
+ style: { fontFamily: "'Libre Baskerville', serif", fontWeight: "400" }
38186
+ }
38187
+ ),
38188
+ [ParagraphPlugin.key]: ParagraphElement,
38189
+ [BlockquotePlugin.key]: BlockquoteElement,
38190
+ [CodeBlockPlugin.key]: CodeBlockElement,
38191
+ [CodeLinePlugin.key]: CodeLineElement,
38192
+ [CodeSyntaxPlugin.key]: CodeSyntaxLeaf,
38193
+ html: ({ attributes, editor, element, children, className }) => {
38194
+ return /* @__PURE__ */ React__default.createElement(
38195
+ "div",
38196
+ {
38197
+ ...attributes,
38198
+ className: classNames$1(
38199
+ "font-mono text-sm bg-green-100 cursor-not-allowed mb-4",
38200
+ className
38201
+ )
38202
+ },
38203
+ children,
38204
+ element.value
38205
+ );
38206
+ },
38207
+ html_inline: ({ attributes, editor, element, children, className }) => {
38208
+ return /* @__PURE__ */ React__default.createElement(
38209
+ "span",
38210
+ {
38211
+ ...attributes,
38212
+ className: classNames$1(
38213
+ "font-mono bg-green-100 cursor-not-allowed",
38214
+ className
38215
+ )
38216
+ },
38217
+ children,
38218
+ element.value
38219
+ );
38220
+ },
38221
+ [BulletedListPlugin.key]: withProps(ListElement, { variant: "ul" }),
38222
+ [NumberedListPlugin.key]: withProps(ListElement, { variant: "ol" }),
38223
+ [ListItemPlugin.key]: withProps(PlateElement, { as: "li" }),
38224
+ [LinkPlugin.key]: LinkElement,
38225
+ [CodePlugin.key]: CodeLeaf,
38226
+ [UnderlinePlugin.key]: withProps(PlateLeaf, { as: "u" }),
38227
+ [StrikethroughPlugin.key]: withProps(PlateLeaf, { as: "s" }),
38228
+ [ItalicPlugin.key]: withProps(PlateLeaf, { as: "em" }),
38229
+ [BoldPlugin.key]: withProps(PlateLeaf, { as: "strong" }),
38230
+ [HorizontalRulePlugin.key]: HrElement,
38231
+ [TableCellHeaderPlugin.key]: TableCellHeaderElement,
38232
+ [TableCellPlugin.key]: TableCellElement,
38233
+ [TablePlugin.key]: TableElement,
38234
+ [TableRowPlugin.key]: TableRowElement
38235
+ };
38236
+ };
38178
38237
  function FieldsBuilder({
38179
38238
  form,
38180
38239
  fields,
38181
38240
  activeFieldName,
38241
+ hoveringFieldName,
38182
38242
  padding = false
38183
38243
  }) {
38184
38244
  const cms = useCMS$1();
@@ -38189,13 +38249,14 @@ function FieldsBuilder({
38189
38249
  }, [setFieldPlugins]);
38190
38250
  React.useEffect(() => updateFieldPlugins(), []);
38191
38251
  useEventSubscription("plugin:add:field", () => updateFieldPlugins(), []);
38192
- return /* @__PURE__ */ React.createElement(FieldsGroup, { padding }, fields.map((field, index) => {
38252
+ return /* @__PURE__ */ React.createElement(FieldsGroup, null, fields.map((field, index) => {
38193
38253
  return /* @__PURE__ */ React.createElement(
38194
38254
  InnerField,
38195
38255
  {
38196
38256
  key: field.name,
38197
38257
  field,
38198
38258
  activeFieldName,
38259
+ hoveringFieldName,
38199
38260
  form,
38200
38261
  fieldPlugins,
38201
38262
  index
@@ -38208,7 +38269,8 @@ const InnerField = ({
38208
38269
  form,
38209
38270
  fieldPlugins,
38210
38271
  index,
38211
- activeFieldName
38272
+ activeFieldName,
38273
+ hoveringFieldName
38212
38274
  }) => {
38213
38275
  React.useEffect(() => {
38214
38276
  form.mutators.setFieldData(field.name, {
@@ -38231,6 +38293,9 @@ const InnerField = ({
38231
38293
  format2 = plugin.format;
38232
38294
  }
38233
38295
  let isActiveField = field.name === activeFieldName;
38296
+ const isHoveringField = field.name === hoveringFieldName;
38297
+ const focusIntent = isActiveField;
38298
+ const hoverIntent = isHoveringField;
38234
38299
  if (field.list && field.type === "string") {
38235
38300
  if (activeFieldName) {
38236
38301
  const activeFieldNameArray = activeFieldName.split(".");
@@ -38245,6 +38310,7 @@ const InnerField = ({
38245
38310
  {
38246
38311
  name: field.name,
38247
38312
  key: field.name,
38313
+ className: "w-full",
38248
38314
  isEqual: (a2, b) => isEqual(field, a2, b),
38249
38315
  type,
38250
38316
  parse: parse2 ? (value, name) => parse2(value, name, field) : void 0,
@@ -38263,7 +38329,11 @@ const InnerField = ({
38263
38329
  ...fieldProps,
38264
38330
  form: form.finalForm,
38265
38331
  tinaForm: form,
38266
- field: { ...field, experimental_focusIntent: isActiveField }
38332
+ field: {
38333
+ ...field,
38334
+ focusIntent,
38335
+ hoverIntent
38336
+ }
38267
38337
  }
38268
38338
  );
38269
38339
  }
@@ -38272,10 +38342,14 @@ const InnerField = ({
38272
38342
  plugin.Component,
38273
38343
  {
38274
38344
  ...fieldProps,
38275
- experimental_focusIntent: isActiveField,
38345
+ focusIntent,
38276
38346
  form: form.finalForm,
38277
38347
  tinaForm: form,
38278
- field: { ...field, experimental_focusIntent: isActiveField },
38348
+ field: {
38349
+ ...field,
38350
+ focusIntent,
38351
+ hoverIntent
38352
+ },
38279
38353
  index
38280
38354
  }
38281
38355
  );
@@ -38285,13 +38359,12 @@ const InnerField = ({
38285
38359
  );
38286
38360
  };
38287
38361
  const FieldsGroup = ({
38288
- padding,
38289
38362
  children
38290
38363
  }) => {
38291
38364
  return /* @__PURE__ */ React.createElement(
38292
38365
  "div",
38293
38366
  {
38294
- className: `relative block w-full h-full whitespace-nowrap overflow-x-visible ${padding ? `pb-5` : ``}`
38367
+ className: `relative flex flex-wrap w-full h-full whitespace-nowrap overflow-x-visible`
38295
38368
  },
38296
38369
  children
38297
38370
  );
@@ -39341,7 +39414,7 @@ function AiFillWarning(props) {
39341
39414
  function AiOutlineLoading(props) {
39342
39415
  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);
39343
39416
  }
39344
- 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";
39417
+ 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";
39345
39418
  const disabledClasses$1 = "opacity-50 pointer-events-none cursor-not-allowed";
39346
39419
  const BaseTextField = React.forwardRef(({ className, disabled, ...rest }, ref) => {
39347
39420
  return /* @__PURE__ */ React.createElement(
@@ -39359,7 +39432,7 @@ const TextArea = React.forwardRef(({ ...props }, ref) => {
39359
39432
  "textarea",
39360
39433
  {
39361
39434
  ...props,
39362
- 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",
39435
+ 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",
39363
39436
  ref,
39364
39437
  style: { minHeight: "160px" }
39365
39438
  }
@@ -39818,7 +39891,7 @@ const Toggle = ({
39818
39891
  /* @__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(
39819
39892
  "span",
39820
39893
  {
39821
- 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"}`,
39894
+ 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"}`,
39822
39895
  style: {
39823
39896
  transform: `translate3d(${checked ? "20px" : "0"}, -50%, 0)`
39824
39897
  }
@@ -39892,7 +39965,7 @@ function MdOutlinePhotoLibrary(props) {
39892
39965
  function MdOutlinePerson(props) {
39893
39966
  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);
39894
39967
  }
39895
- 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";
39968
+ 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";
39896
39969
  const Select$1 = ({
39897
39970
  input,
39898
39971
  field,
@@ -39902,11 +39975,13 @@ const Select$1 = ({
39902
39975
  const selectOptions = options || field.options;
39903
39976
  const ref = React.useRef(null);
39904
39977
  React.useEffect(() => {
39905
- if (ref.current && (field == null ? void 0 : field.experimental_focusIntent)) {
39978
+ const focusIntent = field == null ? void 0 : field.focusIntent;
39979
+ const shouldFocus = !!focusIntent;
39980
+ if (ref.current && shouldFocus) {
39906
39981
  ref.current.focus();
39907
39982
  }
39908
- }, [field == null ? void 0 : field.experimental_focusIntent, ref]);
39909
- return /* @__PURE__ */ React.createElement("div", { className: "relative group w-full h-full md:w-auto" }, /* @__PURE__ */ React.createElement(
39983
+ }, [field == null ? void 0 : field.focusIntent, ref]);
39984
+ return /* @__PURE__ */ React.createElement("div", { className: "relative group w-full h-fit md:w-auto" }, /* @__PURE__ */ React.createElement(
39910
39985
  "select",
39911
39986
  {
39912
39987
  id: input.name,
@@ -39987,7 +40062,7 @@ const RadioOption = ({ checked, htmlFor, children, ...props }) => /* @__PURE__ *
39987
40062
  /* @__PURE__ */ React.createElement(
39988
40063
  "span",
39989
40064
  {
39990
- 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"}`
40065
+ 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"}`
39991
40066
  },
39992
40067
  /* @__PURE__ */ React.createElement(
39993
40068
  BiCheck,
@@ -40048,7 +40123,7 @@ const CheckboxGroup = ({
40048
40123
  /* @__PURE__ */ React.createElement(
40049
40124
  "span",
40050
40125
  {
40051
- 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"}`
40126
+ 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"}`
40052
40127
  },
40053
40128
  /* @__PURE__ */ React.createElement(
40054
40129
  BiCheck,
@@ -40179,7 +40254,7 @@ const ImageUpload = React.forwardRef(({ onDrop, onClear, onClick, value, src, lo
40179
40254
  /* @__PURE__ */ React.createElement(
40180
40255
  "button",
40181
40256
  {
40182
- 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",
40257
+ 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",
40183
40258
  onClick,
40184
40259
  ref
40185
40260
  },
@@ -40680,7 +40755,7 @@ function toProps(option) {
40680
40755
  return option;
40681
40756
  return { value: option, label: option };
40682
40757
  }
40683
- 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";
40758
+ 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";
40684
40759
  const disabledClasses = "opacity-50 pointer-events-none cursor-not-allowed";
40685
40760
  const errorClasses = "border-red-500 focus:border-red-500 focus:shadow-outline-red";
40686
40761
  const BasePasswordField = React.forwardRef(({ className, disabled, error: error2, ...rest }, ref) => {
@@ -41053,7 +41128,7 @@ const Header = ({ onClick, children }) => {
41053
41128
  "button",
41054
41129
  {
41055
41130
  onClick,
41056
- 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"
41131
+ 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"
41057
41132
  },
41058
41133
  /* @__PURE__ */ React.createElement("span", { className: "text-left text-base font-medium overflow-hidden text-ellipsis whitespace-nowrap flex-1" }, children),
41059
41134
  " ",
@@ -41205,7 +41280,7 @@ const BlockSelectorBig = ({
41205
41280
  "input",
41206
41281
  {
41207
41282
  type: "text",
41208
- 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",
41283
+ 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",
41209
41284
  onClick: (event) => {
41210
41285
  event.stopPropagation();
41211
41286
  event.preventDefault();
@@ -41658,10 +41733,12 @@ const ImageField = wrapFieldsWithMeta(
41658
41733
  onClear = () => props.input.onChange("");
41659
41734
  }
41660
41735
  React.useEffect(() => {
41661
- if (ref.current && props.field.experimental_focusIntent) {
41736
+ const focusIntent = props.field.focusIntent;
41737
+ const shouldFocus = !!focusIntent;
41738
+ if (ref.current && shouldFocus) {
41662
41739
  ref.current.focus();
41663
41740
  }
41664
- }, [props.field.experimental_focusIntent, ref]);
41741
+ }, [props.field.focusIntent, ref]);
41665
41742
  async function onChange(media) {
41666
41743
  var _a2, _b;
41667
41744
  if (media) {
@@ -41787,12 +41864,14 @@ const RadioGroupFieldPlugin = {
41787
41864
  const TextareaField = wrapFieldsWithMeta((props) => {
41788
41865
  const ref = React.useRef(null);
41789
41866
  React.useEffect(() => {
41790
- if (ref.current && props.field.experimental_focusIntent) {
41867
+ const focusIntent = props.field.focusIntent;
41868
+ const shouldFocus = !!focusIntent;
41869
+ if (ref.current && shouldFocus) {
41791
41870
  const el = ref.current;
41792
41871
  el.focus();
41793
41872
  el.setSelectionRange(el.value.length, el.value.length);
41794
41873
  }
41795
- }, [props.field.experimental_focusIntent, ref]);
41874
+ }, [props.field.focusIntent, ref]);
41796
41875
  return /* @__PURE__ */ React.createElement(TextArea, { ref, ...props.input });
41797
41876
  });
41798
41877
  const TextareaFieldPlugin = {
@@ -41853,10 +41932,12 @@ const TextField = wrapFieldsWithMeta(
41853
41932
  var _a2;
41854
41933
  const ref = React.useRef(null);
41855
41934
  React.useEffect(() => {
41856
- if (ref.current && props.field.experimental_focusIntent) {
41935
+ const focusIntent = props.field.focusIntent;
41936
+ const shouldFocus = !!focusIntent;
41937
+ if (ref.current && shouldFocus) {
41857
41938
  ref.current.focus();
41858
41939
  }
41859
- }, [props.field.experimental_focusIntent, ref]);
41940
+ }, [props.field.focusIntent, ref]);
41860
41941
  return /* @__PURE__ */ React.createElement(
41861
41942
  BaseTextField,
41862
41943
  {
@@ -41916,10 +41997,12 @@ const TagsField = wrapFieldsWithMeta(({ input, field, form, tinaForm }) => {
41916
41997
  const items2 = input.value || [];
41917
41998
  const ref = React.useRef(null);
41918
41999
  React.useEffect(() => {
41919
- if (ref.current && field.experimental_focusIntent) {
42000
+ const focusIntent = field.focusIntent;
42001
+ const shouldFocus = !!focusIntent;
42002
+ if (ref.current && shouldFocus) {
41920
42003
  ref.current.focus();
41921
42004
  }
41922
- }, [field.experimental_focusIntent, ref]);
42005
+ }, [field.focusIntent, ref]);
41923
42006
  return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("div", { className: "flex items-center gap-3" }, /* @__PURE__ */ React.createElement(
41924
42007
  BaseTextField,
41925
42008
  {
@@ -42070,66 +42153,63 @@ const PopoverContent = React.forwardRef(({ className, align = "center", sideOffs
42070
42153
  )));
42071
42154
  PopoverContent.displayName = PopoverPrimitive.Content.displayName;
42072
42155
  function buildFormatLongFn(args) {
42073
- return function() {
42074
- var options = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
42075
- var width = options.width ? String(options.width) : args.defaultWidth;
42076
- var format2 = args.formats[width] || args.formats[args.defaultWidth];
42156
+ return (options = {}) => {
42157
+ const width = options.width ? String(options.width) : args.defaultWidth;
42158
+ const format2 = args.formats[width] || args.formats[args.defaultWidth];
42077
42159
  return format2;
42078
42160
  };
42079
42161
  }
42080
42162
  function buildLocalizeFn(args) {
42081
- return function(dirtyIndex, options) {
42082
- var context = options !== null && options !== void 0 && options.context ? String(options.context) : "standalone";
42083
- var valuesArray;
42163
+ return (value, options) => {
42164
+ const context = (options == null ? void 0 : options.context) ? String(options.context) : "standalone";
42165
+ let valuesArray;
42084
42166
  if (context === "formatting" && args.formattingValues) {
42085
- var defaultWidth = args.defaultFormattingWidth || args.defaultWidth;
42086
- var width = options !== null && options !== void 0 && options.width ? String(options.width) : defaultWidth;
42167
+ const defaultWidth = args.defaultFormattingWidth || args.defaultWidth;
42168
+ const width = (options == null ? void 0 : options.width) ? String(options.width) : defaultWidth;
42087
42169
  valuesArray = args.formattingValues[width] || args.formattingValues[defaultWidth];
42088
42170
  } else {
42089
- var _defaultWidth = args.defaultWidth;
42090
- var _width = options !== null && options !== void 0 && options.width ? String(options.width) : args.defaultWidth;
42091
- valuesArray = args.values[_width] || args.values[_defaultWidth];
42171
+ const defaultWidth = args.defaultWidth;
42172
+ const width = (options == null ? void 0 : options.width) ? String(options.width) : args.defaultWidth;
42173
+ valuesArray = args.values[width] || args.values[defaultWidth];
42092
42174
  }
42093
- var index = args.argumentCallback ? args.argumentCallback(dirtyIndex) : dirtyIndex;
42175
+ const index = args.argumentCallback ? args.argumentCallback(value) : value;
42094
42176
  return valuesArray[index];
42095
42177
  };
42096
42178
  }
42097
42179
  function buildMatchFn(args) {
42098
- return function(string3) {
42099
- var options = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
42100
- var width = options.width;
42101
- var matchPattern = width && args.matchPatterns[width] || args.matchPatterns[args.defaultMatchWidth];
42102
- var matchResult = string3.match(matchPattern);
42180
+ return (string3, options = {}) => {
42181
+ const width = options.width;
42182
+ const matchPattern = width && args.matchPatterns[width] || args.matchPatterns[args.defaultMatchWidth];
42183
+ const matchResult = string3.match(matchPattern);
42103
42184
  if (!matchResult) {
42104
42185
  return null;
42105
42186
  }
42106
- var matchedString = matchResult[0];
42107
- var parsePatterns = width && args.parsePatterns[width] || args.parsePatterns[args.defaultParseWidth];
42108
- var key = Array.isArray(parsePatterns) ? findIndex(parsePatterns, function(pattern) {
42109
- return pattern.test(matchedString);
42110
- }) : findKey(parsePatterns, function(pattern) {
42111
- return pattern.test(matchedString);
42112
- });
42113
- var value;
42187
+ const matchedString = matchResult[0];
42188
+ const parsePatterns = width && args.parsePatterns[width] || args.parsePatterns[args.defaultParseWidth];
42189
+ const key = Array.isArray(parsePatterns) ? findIndex(parsePatterns, (pattern) => pattern.test(matchedString)) : (
42190
+ // [TODO] -- I challenge you to fix the type
42191
+ findKey(parsePatterns, (pattern) => pattern.test(matchedString))
42192
+ );
42193
+ let value;
42114
42194
  value = args.valueCallback ? args.valueCallback(key) : key;
42115
- value = options.valueCallback ? options.valueCallback(value) : value;
42116
- var rest = string3.slice(matchedString.length);
42117
- return {
42118
- value,
42119
- rest
42120
- };
42195
+ value = options.valueCallback ? (
42196
+ // [TODO] -- I challenge you to fix the type
42197
+ options.valueCallback(value)
42198
+ ) : value;
42199
+ const rest = string3.slice(matchedString.length);
42200
+ return { value, rest };
42121
42201
  };
42122
42202
  }
42123
42203
  function findKey(object, predicate) {
42124
- for (var key in object) {
42125
- if (object.hasOwnProperty(key) && predicate(object[key])) {
42204
+ for (const key in object) {
42205
+ if (Object.prototype.hasOwnProperty.call(object, key) && predicate(object[key])) {
42126
42206
  return key;
42127
42207
  }
42128
42208
  }
42129
42209
  return void 0;
42130
42210
  }
42131
42211
  function findIndex(array, predicate) {
42132
- for (var key = 0; key < array.length; key++) {
42212
+ for (let key = 0; key < array.length; key++) {
42133
42213
  if (predicate(array[key])) {
42134
42214
  return key;
42135
42215
  }
@@ -42137,146 +42217,21 @@ function findIndex(array, predicate) {
42137
42217
  return void 0;
42138
42218
  }
42139
42219
  function buildMatchPatternFn(args) {
42140
- return function(string3) {
42141
- var options = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
42142
- var matchResult = string3.match(args.matchPattern);
42220
+ return (string3, options = {}) => {
42221
+ const matchResult = string3.match(args.matchPattern);
42143
42222
  if (!matchResult)
42144
42223
  return null;
42145
- var matchedString = matchResult[0];
42146
- var parseResult = string3.match(args.parsePattern);
42224
+ const matchedString = matchResult[0];
42225
+ const parseResult = string3.match(args.parsePattern);
42147
42226
  if (!parseResult)
42148
42227
  return null;
42149
- var value = args.valueCallback ? args.valueCallback(parseResult[0]) : parseResult[0];
42228
+ let value = args.valueCallback ? args.valueCallback(parseResult[0]) : parseResult[0];
42150
42229
  value = options.valueCallback ? options.valueCallback(value) : value;
42151
- var rest = string3.slice(matchedString.length);
42152
- return {
42153
- value,
42154
- rest
42155
- };
42230
+ const rest = string3.slice(matchedString.length);
42231
+ return { value, rest };
42156
42232
  };
42157
42233
  }
42158
- function _typeof(o3) {
42159
- "@babel/helpers - typeof";
42160
- return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o4) {
42161
- return typeof o4;
42162
- } : function(o4) {
42163
- return o4 && "function" == typeof Symbol && o4.constructor === Symbol && o4 !== Symbol.prototype ? "symbol" : typeof o4;
42164
- }, _typeof(o3);
42165
- }
42166
- function requiredArgs(required, args) {
42167
- if (args.length < required) {
42168
- throw new TypeError(required + " argument" + (required > 1 ? "s" : "") + " required, but only " + args.length + " present");
42169
- }
42170
- }
42171
- function toDate(argument) {
42172
- requiredArgs(1, arguments);
42173
- var argStr = Object.prototype.toString.call(argument);
42174
- if (argument instanceof Date || _typeof(argument) === "object" && argStr === "[object Date]") {
42175
- return new Date(argument.getTime());
42176
- } else if (typeof argument === "number" || argStr === "[object Number]") {
42177
- return new Date(argument);
42178
- } else {
42179
- if ((typeof argument === "string" || argStr === "[object String]") && typeof console !== "undefined") {
42180
- console.warn("Starting with v2.0.0-beta.1 date-fns doesn't accept strings as date arguments. Please use `parseISO` to parse strings. See: https://github.com/date-fns/date-fns/blob/master/docs/upgradeGuide.md#string-arguments");
42181
- console.warn(new Error().stack);
42182
- }
42183
- return /* @__PURE__ */ new Date(NaN);
42184
- }
42185
- }
42186
- var defaultOptions = {};
42187
- function getDefaultOptions() {
42188
- return defaultOptions;
42189
- }
42190
- function getTimezoneOffsetInMilliseconds(date) {
42191
- var utcDate = new Date(Date.UTC(date.getFullYear(), date.getMonth(), date.getDate(), date.getHours(), date.getMinutes(), date.getSeconds(), date.getMilliseconds()));
42192
- utcDate.setUTCFullYear(date.getFullYear());
42193
- return date.getTime() - utcDate.getTime();
42194
- }
42195
- function compareAsc(dirtyDateLeft, dirtyDateRight) {
42196
- requiredArgs(2, arguments);
42197
- var dateLeft = toDate(dirtyDateLeft);
42198
- var dateRight = toDate(dirtyDateRight);
42199
- var diff2 = dateLeft.getTime() - dateRight.getTime();
42200
- if (diff2 < 0) {
42201
- return -1;
42202
- } else if (diff2 > 0) {
42203
- return 1;
42204
- } else {
42205
- return diff2;
42206
- }
42207
- }
42208
- function differenceInCalendarMonths(dirtyDateLeft, dirtyDateRight) {
42209
- requiredArgs(2, arguments);
42210
- var dateLeft = toDate(dirtyDateLeft);
42211
- var dateRight = toDate(dirtyDateRight);
42212
- var yearDiff = dateLeft.getFullYear() - dateRight.getFullYear();
42213
- var monthDiff = dateLeft.getMonth() - dateRight.getMonth();
42214
- return yearDiff * 12 + monthDiff;
42215
- }
42216
- function differenceInMilliseconds(dateLeft, dateRight) {
42217
- requiredArgs(2, arguments);
42218
- return toDate(dateLeft).getTime() - toDate(dateRight).getTime();
42219
- }
42220
- var roundingMap = {
42221
- ceil: Math.ceil,
42222
- round: Math.round,
42223
- floor: Math.floor,
42224
- trunc: function trunc(value) {
42225
- return value < 0 ? Math.ceil(value) : Math.floor(value);
42226
- }
42227
- // Math.trunc is not supported by IE
42228
- };
42229
- var defaultRoundingMethod = "trunc";
42230
- function getRoundingMethod(method) {
42231
- return method ? roundingMap[method] : roundingMap[defaultRoundingMethod];
42232
- }
42233
- function endOfDay(dirtyDate) {
42234
- requiredArgs(1, arguments);
42235
- var date = toDate(dirtyDate);
42236
- date.setHours(23, 59, 59, 999);
42237
- return date;
42238
- }
42239
- function endOfMonth(dirtyDate) {
42240
- requiredArgs(1, arguments);
42241
- var date = toDate(dirtyDate);
42242
- var month = date.getMonth();
42243
- date.setFullYear(date.getFullYear(), month + 1, 0);
42244
- date.setHours(23, 59, 59, 999);
42245
- return date;
42246
- }
42247
- function isLastDayOfMonth(dirtyDate) {
42248
- requiredArgs(1, arguments);
42249
- var date = toDate(dirtyDate);
42250
- return endOfDay(date).getTime() === endOfMonth(date).getTime();
42251
- }
42252
- function differenceInMonths(dirtyDateLeft, dirtyDateRight) {
42253
- requiredArgs(2, arguments);
42254
- var dateLeft = toDate(dirtyDateLeft);
42255
- var dateRight = toDate(dirtyDateRight);
42256
- var sign = compareAsc(dateLeft, dateRight);
42257
- var difference = Math.abs(differenceInCalendarMonths(dateLeft, dateRight));
42258
- var result;
42259
- if (difference < 1) {
42260
- result = 0;
42261
- } else {
42262
- if (dateLeft.getMonth() === 1 && dateLeft.getDate() > 27) {
42263
- dateLeft.setDate(30);
42264
- }
42265
- dateLeft.setMonth(dateLeft.getMonth() - sign * difference);
42266
- var isLastMonthNotFull = compareAsc(dateLeft, dateRight) === -sign;
42267
- if (isLastDayOfMonth(toDate(dirtyDateLeft)) && difference === 1 && compareAsc(dirtyDateLeft, dateRight) === 1) {
42268
- isLastMonthNotFull = false;
42269
- }
42270
- result = sign * (difference - Number(isLastMonthNotFull));
42271
- }
42272
- return result === 0 ? 0 : result;
42273
- }
42274
- function differenceInSeconds(dateLeft, dateRight, options) {
42275
- requiredArgs(2, arguments);
42276
- var diff2 = differenceInMilliseconds(dateLeft, dateRight) / 1e3;
42277
- return getRoundingMethod(options === null || options === void 0 ? void 0 : options.roundingMethod)(diff2);
42278
- }
42279
- var formatDistanceLocale = {
42234
+ const formatDistanceLocale = {
42280
42235
  lessThanXSeconds: {
42281
42236
  one: "less than a second",
42282
42237
  other: "less than {{count}} seconds"
@@ -42339,9 +42294,9 @@ var formatDistanceLocale = {
42339
42294
  other: "almost {{count}} years"
42340
42295
  }
42341
42296
  };
42342
- var formatDistance$1 = function formatDistance(token, count, options) {
42343
- var result;
42344
- var tokenValue = formatDistanceLocale[token];
42297
+ const formatDistance = (token, count, options) => {
42298
+ let result;
42299
+ const tokenValue = formatDistanceLocale[token];
42345
42300
  if (typeof tokenValue === "string") {
42346
42301
  result = tokenValue;
42347
42302
  } else if (count === 1) {
@@ -42349,7 +42304,7 @@ var formatDistance$1 = function formatDistance(token, count, options) {
42349
42304
  } else {
42350
42305
  result = tokenValue.other.replace("{{count}}", count.toString());
42351
42306
  }
42352
- if (options !== null && options !== void 0 && options.addSuffix) {
42307
+ if (options == null ? void 0 : options.addSuffix) {
42353
42308
  if (options.comparison && options.comparison > 0) {
42354
42309
  return "in " + result;
42355
42310
  } else {
@@ -42358,41 +42313,7 @@ var formatDistance$1 = function formatDistance(token, count, options) {
42358
42313
  }
42359
42314
  return result;
42360
42315
  };
42361
- const formatDistance$2 = formatDistance$1;
42362
- var dateFormats = {
42363
- full: "EEEE, MMMM do, y",
42364
- long: "MMMM do, y",
42365
- medium: "MMM d, y",
42366
- short: "MM/dd/yyyy"
42367
- };
42368
- var timeFormats = {
42369
- full: "h:mm:ss a zzzz",
42370
- long: "h:mm:ss a z",
42371
- medium: "h:mm:ss a",
42372
- short: "h:mm a"
42373
- };
42374
- var dateTimeFormats = {
42375
- full: "{{date}} 'at' {{time}}",
42376
- long: "{{date}} 'at' {{time}}",
42377
- medium: "{{date}}, {{time}}",
42378
- short: "{{date}}, {{time}}"
42379
- };
42380
- var formatLong = {
42381
- date: buildFormatLongFn({
42382
- formats: dateFormats,
42383
- defaultWidth: "full"
42384
- }),
42385
- time: buildFormatLongFn({
42386
- formats: timeFormats,
42387
- defaultWidth: "full"
42388
- }),
42389
- dateTime: buildFormatLongFn({
42390
- formats: dateTimeFormats,
42391
- defaultWidth: "full"
42392
- })
42393
- };
42394
- const formatLong$1 = formatLong;
42395
- var formatRelativeLocale = {
42316
+ const formatRelativeLocale = {
42396
42317
  lastWeek: "'last' eeee 'at' p",
42397
42318
  yesterday: "'yesterday at' p",
42398
42319
  today: "'today at' p",
@@ -42400,32 +42321,63 @@ var formatRelativeLocale = {
42400
42321
  nextWeek: "eeee 'at' p",
42401
42322
  other: "P"
42402
42323
  };
42403
- var formatRelative = function formatRelative2(token, _date, _baseDate, _options) {
42404
- return formatRelativeLocale[token];
42405
- };
42406
- const formatRelative$1 = formatRelative;
42407
- var eraValues = {
42324
+ const formatRelative = (token, _date, _baseDate, _options) => formatRelativeLocale[token];
42325
+ const eraValues = {
42408
42326
  narrow: ["B", "A"],
42409
42327
  abbreviated: ["BC", "AD"],
42410
42328
  wide: ["Before Christ", "Anno Domini"]
42411
42329
  };
42412
- var quarterValues = {
42330
+ const quarterValues = {
42413
42331
  narrow: ["1", "2", "3", "4"],
42414
42332
  abbreviated: ["Q1", "Q2", "Q3", "Q4"],
42415
42333
  wide: ["1st quarter", "2nd quarter", "3rd quarter", "4th quarter"]
42416
42334
  };
42417
- var monthValues = {
42335
+ const monthValues = {
42418
42336
  narrow: ["J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"],
42419
- abbreviated: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"],
42420
- wide: ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]
42337
+ abbreviated: [
42338
+ "Jan",
42339
+ "Feb",
42340
+ "Mar",
42341
+ "Apr",
42342
+ "May",
42343
+ "Jun",
42344
+ "Jul",
42345
+ "Aug",
42346
+ "Sep",
42347
+ "Oct",
42348
+ "Nov",
42349
+ "Dec"
42350
+ ],
42351
+ wide: [
42352
+ "January",
42353
+ "February",
42354
+ "March",
42355
+ "April",
42356
+ "May",
42357
+ "June",
42358
+ "July",
42359
+ "August",
42360
+ "September",
42361
+ "October",
42362
+ "November",
42363
+ "December"
42364
+ ]
42421
42365
  };
42422
- var dayValues = {
42366
+ const dayValues = {
42423
42367
  narrow: ["S", "M", "T", "W", "T", "F", "S"],
42424
42368
  short: ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"],
42425
42369
  abbreviated: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"],
42426
- wide: ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]
42370
+ wide: [
42371
+ "Sunday",
42372
+ "Monday",
42373
+ "Tuesday",
42374
+ "Wednesday",
42375
+ "Thursday",
42376
+ "Friday",
42377
+ "Saturday"
42378
+ ]
42427
42379
  };
42428
- var dayPeriodValues = {
42380
+ const dayPeriodValues = {
42429
42381
  narrow: {
42430
42382
  am: "a",
42431
42383
  pm: "p",
@@ -42457,7 +42409,7 @@ var dayPeriodValues = {
42457
42409
  night: "night"
42458
42410
  }
42459
42411
  };
42460
- var formattingDayPeriodValues = {
42412
+ const formattingDayPeriodValues = {
42461
42413
  narrow: {
42462
42414
  am: "a",
42463
42415
  pm: "p",
@@ -42489,9 +42441,9 @@ var formattingDayPeriodValues = {
42489
42441
  night: "at night"
42490
42442
  }
42491
42443
  };
42492
- var ordinalNumber = function ordinalNumber2(dirtyNumber, _options) {
42493
- var number = Number(dirtyNumber);
42494
- var rem100 = number % 100;
42444
+ const ordinalNumber = (dirtyNumber, _options) => {
42445
+ const number = Number(dirtyNumber);
42446
+ const rem100 = number % 100;
42495
42447
  if (rem100 > 20 || rem100 < 10) {
42496
42448
  switch (rem100 % 10) {
42497
42449
  case 1:
@@ -42504,7 +42456,7 @@ var ordinalNumber = function ordinalNumber2(dirtyNumber, _options) {
42504
42456
  }
42505
42457
  return number + "th";
42506
42458
  };
42507
- var localize = {
42459
+ const localize = {
42508
42460
  ordinalNumber,
42509
42461
  era: buildLocalizeFn({
42510
42462
  values: eraValues,
@@ -42513,9 +42465,7 @@ var localize = {
42513
42465
  quarter: buildLocalizeFn({
42514
42466
  values: quarterValues,
42515
42467
  defaultWidth: "wide",
42516
- argumentCallback: function argumentCallback(quarter) {
42517
- return quarter - 1;
42518
- }
42468
+ argumentCallback: (quarter) => quarter - 1
42519
42469
  }),
42520
42470
  month: buildLocalizeFn({
42521
42471
  values: monthValues,
@@ -42532,49 +42482,74 @@ var localize = {
42532
42482
  defaultFormattingWidth: "wide"
42533
42483
  })
42534
42484
  };
42535
- const localize$1 = localize;
42536
- var matchOrdinalNumberPattern = /^(\d+)(th|st|nd|rd)?/i;
42537
- var parseOrdinalNumberPattern = /\d+/i;
42538
- var matchEraPatterns = {
42485
+ const matchOrdinalNumberPattern = /^(\d+)(th|st|nd|rd)?/i;
42486
+ const parseOrdinalNumberPattern = /\d+/i;
42487
+ const matchEraPatterns = {
42539
42488
  narrow: /^(b|a)/i,
42540
42489
  abbreviated: /^(b\.?\s?c\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?)/i,
42541
42490
  wide: /^(before christ|before common era|anno domini|common era)/i
42542
42491
  };
42543
- var parseEraPatterns = {
42492
+ const parseEraPatterns = {
42544
42493
  any: [/^b/i, /^(a|c)/i]
42545
42494
  };
42546
- var matchQuarterPatterns = {
42495
+ const matchQuarterPatterns = {
42547
42496
  narrow: /^[1234]/i,
42548
42497
  abbreviated: /^q[1234]/i,
42549
42498
  wide: /^[1234](th|st|nd|rd)? quarter/i
42550
42499
  };
42551
- var parseQuarterPatterns = {
42500
+ const parseQuarterPatterns = {
42552
42501
  any: [/1/i, /2/i, /3/i, /4/i]
42553
42502
  };
42554
- var matchMonthPatterns = {
42503
+ const matchMonthPatterns = {
42555
42504
  narrow: /^[jfmasond]/i,
42556
42505
  abbreviated: /^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i,
42557
42506
  wide: /^(january|february|march|april|may|june|july|august|september|october|november|december)/i
42558
42507
  };
42559
- var parseMonthPatterns = {
42560
- narrow: [/^j/i, /^f/i, /^m/i, /^a/i, /^m/i, /^j/i, /^j/i, /^a/i, /^s/i, /^o/i, /^n/i, /^d/i],
42561
- any: [/^ja/i, /^f/i, /^mar/i, /^ap/i, /^may/i, /^jun/i, /^jul/i, /^au/i, /^s/i, /^o/i, /^n/i, /^d/i]
42508
+ const parseMonthPatterns = {
42509
+ narrow: [
42510
+ /^j/i,
42511
+ /^f/i,
42512
+ /^m/i,
42513
+ /^a/i,
42514
+ /^m/i,
42515
+ /^j/i,
42516
+ /^j/i,
42517
+ /^a/i,
42518
+ /^s/i,
42519
+ /^o/i,
42520
+ /^n/i,
42521
+ /^d/i
42522
+ ],
42523
+ any: [
42524
+ /^ja/i,
42525
+ /^f/i,
42526
+ /^mar/i,
42527
+ /^ap/i,
42528
+ /^may/i,
42529
+ /^jun/i,
42530
+ /^jul/i,
42531
+ /^au/i,
42532
+ /^s/i,
42533
+ /^o/i,
42534
+ /^n/i,
42535
+ /^d/i
42536
+ ]
42562
42537
  };
42563
- var matchDayPatterns = {
42538
+ const matchDayPatterns = {
42564
42539
  narrow: /^[smtwf]/i,
42565
42540
  short: /^(su|mo|tu|we|th|fr|sa)/i,
42566
42541
  abbreviated: /^(sun|mon|tue|wed|thu|fri|sat)/i,
42567
42542
  wide: /^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i
42568
42543
  };
42569
- var parseDayPatterns = {
42544
+ const parseDayPatterns = {
42570
42545
  narrow: [/^s/i, /^m/i, /^t/i, /^w/i, /^t/i, /^f/i, /^s/i],
42571
42546
  any: [/^su/i, /^m/i, /^tu/i, /^w/i, /^th/i, /^f/i, /^sa/i]
42572
42547
  };
42573
- var matchDayPeriodPatterns = {
42548
+ const matchDayPeriodPatterns = {
42574
42549
  narrow: /^(a|p|mi|n|(in the|at) (morning|afternoon|evening|night))/i,
42575
42550
  any: /^([ap]\.?\s?m\.?|midnight|noon|(in the|at) (morning|afternoon|evening|night))/i
42576
42551
  };
42577
- var parseDayPeriodPatterns = {
42552
+ const parseDayPeriodPatterns = {
42578
42553
  any: {
42579
42554
  am: /^a/i,
42580
42555
  pm: /^p/i,
@@ -42586,13 +42561,11 @@ var parseDayPeriodPatterns = {
42586
42561
  night: /night/i
42587
42562
  }
42588
42563
  };
42589
- var match = {
42564
+ const match = {
42590
42565
  ordinalNumber: buildMatchPatternFn({
42591
42566
  matchPattern: matchOrdinalNumberPattern,
42592
42567
  parsePattern: parseOrdinalNumberPattern,
42593
- valueCallback: function valueCallback(value) {
42594
- return parseInt(value, 10);
42595
- }
42568
+ valueCallback: (value) => parseInt(value, 10)
42596
42569
  }),
42597
42570
  era: buildMatchFn({
42598
42571
  matchPatterns: matchEraPatterns,
@@ -42605,9 +42578,7 @@ var match = {
42605
42578
  defaultMatchWidth: "wide",
42606
42579
  parsePatterns: parseQuarterPatterns,
42607
42580
  defaultParseWidth: "any",
42608
- valueCallback: function valueCallback2(index) {
42609
- return index + 1;
42610
- }
42581
+ valueCallback: (index) => index + 1
42611
42582
  }),
42612
42583
  month: buildMatchFn({
42613
42584
  matchPatterns: matchMonthPatterns,
@@ -42628,125 +42599,50 @@ var match = {
42628
42599
  defaultParseWidth: "any"
42629
42600
  })
42630
42601
  };
42631
- const match$1 = match;
42632
- var locale = {
42602
+ const dateFormats = {
42603
+ full: "EEEE, MMMM do, y",
42604
+ long: "MMMM do, y",
42605
+ medium: "MMM d, y",
42606
+ short: "MM/dd/yyyy"
42607
+ };
42608
+ const timeFormats = {
42609
+ full: "h:mm:ss a zzzz",
42610
+ long: "h:mm:ss a z",
42611
+ medium: "h:mm:ss a",
42612
+ short: "h:mm a"
42613
+ };
42614
+ const dateTimeFormats = {
42615
+ full: "{{date}} 'at' {{time}}",
42616
+ long: "{{date}} 'at' {{time}}",
42617
+ medium: "{{date}}, {{time}}",
42618
+ short: "{{date}}, {{time}}"
42619
+ };
42620
+ const formatLong = {
42621
+ date: buildFormatLongFn({
42622
+ formats: dateFormats,
42623
+ defaultWidth: "full"
42624
+ }),
42625
+ time: buildFormatLongFn({
42626
+ formats: timeFormats,
42627
+ defaultWidth: "full"
42628
+ }),
42629
+ dateTime: buildFormatLongFn({
42630
+ formats: dateTimeFormats,
42631
+ defaultWidth: "full"
42632
+ })
42633
+ };
42634
+ const enUS = {
42633
42635
  code: "en-US",
42634
- formatDistance: formatDistance$2,
42635
- formatLong: formatLong$1,
42636
- formatRelative: formatRelative$1,
42637
- localize: localize$1,
42638
- match: match$1,
42636
+ formatDistance,
42637
+ formatLong,
42638
+ formatRelative,
42639
+ localize,
42640
+ match,
42639
42641
  options: {
42640
42642
  weekStartsOn: 0,
42641
42643
  firstWeekContainsDate: 1
42642
42644
  }
42643
42645
  };
42644
- const enUS = locale;
42645
- function assign(target, object) {
42646
- if (target == null) {
42647
- throw new TypeError("assign requires that input parameter not be null or undefined");
42648
- }
42649
- for (var property2 in object) {
42650
- if (Object.prototype.hasOwnProperty.call(object, property2)) {
42651
- target[property2] = object[property2];
42652
- }
42653
- }
42654
- return target;
42655
- }
42656
- function cloneObject(object) {
42657
- return assign({}, object);
42658
- }
42659
- var MINUTES_IN_DAY = 1440;
42660
- var MINUTES_IN_ALMOST_TWO_DAYS = 2520;
42661
- var MINUTES_IN_MONTH = 43200;
42662
- var MINUTES_IN_TWO_MONTHS = 86400;
42663
- function formatDistance2(dirtyDate, dirtyBaseDate, options) {
42664
- var _ref, _options$locale;
42665
- requiredArgs(2, arguments);
42666
- var defaultOptions2 = getDefaultOptions();
42667
- var locale2 = (_ref = (_options$locale = options === null || options === void 0 ? void 0 : options.locale) !== null && _options$locale !== void 0 ? _options$locale : defaultOptions2.locale) !== null && _ref !== void 0 ? _ref : enUS;
42668
- if (!locale2.formatDistance) {
42669
- throw new RangeError("locale must contain formatDistance property");
42670
- }
42671
- var comparison = compareAsc(dirtyDate, dirtyBaseDate);
42672
- if (isNaN(comparison)) {
42673
- throw new RangeError("Invalid time value");
42674
- }
42675
- var localizeOptions = assign(cloneObject(options), {
42676
- addSuffix: Boolean(options === null || options === void 0 ? void 0 : options.addSuffix),
42677
- comparison
42678
- });
42679
- var dateLeft;
42680
- var dateRight;
42681
- if (comparison > 0) {
42682
- dateLeft = toDate(dirtyBaseDate);
42683
- dateRight = toDate(dirtyDate);
42684
- } else {
42685
- dateLeft = toDate(dirtyDate);
42686
- dateRight = toDate(dirtyBaseDate);
42687
- }
42688
- var seconds = differenceInSeconds(dateRight, dateLeft);
42689
- var offsetInSeconds = (getTimezoneOffsetInMilliseconds(dateRight) - getTimezoneOffsetInMilliseconds(dateLeft)) / 1e3;
42690
- var minutes = Math.round((seconds - offsetInSeconds) / 60);
42691
- var months;
42692
- if (minutes < 2) {
42693
- if (options !== null && options !== void 0 && options.includeSeconds) {
42694
- if (seconds < 5) {
42695
- return locale2.formatDistance("lessThanXSeconds", 5, localizeOptions);
42696
- } else if (seconds < 10) {
42697
- return locale2.formatDistance("lessThanXSeconds", 10, localizeOptions);
42698
- } else if (seconds < 20) {
42699
- return locale2.formatDistance("lessThanXSeconds", 20, localizeOptions);
42700
- } else if (seconds < 40) {
42701
- return locale2.formatDistance("halfAMinute", 0, localizeOptions);
42702
- } else if (seconds < 60) {
42703
- return locale2.formatDistance("lessThanXMinutes", 1, localizeOptions);
42704
- } else {
42705
- return locale2.formatDistance("xMinutes", 1, localizeOptions);
42706
- }
42707
- } else {
42708
- if (minutes === 0) {
42709
- return locale2.formatDistance("lessThanXMinutes", 1, localizeOptions);
42710
- } else {
42711
- return locale2.formatDistance("xMinutes", minutes, localizeOptions);
42712
- }
42713
- }
42714
- } else if (minutes < 45) {
42715
- return locale2.formatDistance("xMinutes", minutes, localizeOptions);
42716
- } else if (minutes < 90) {
42717
- return locale2.formatDistance("aboutXHours", 1, localizeOptions);
42718
- } else if (minutes < MINUTES_IN_DAY) {
42719
- var hours = Math.round(minutes / 60);
42720
- return locale2.formatDistance("aboutXHours", hours, localizeOptions);
42721
- } else if (minutes < MINUTES_IN_ALMOST_TWO_DAYS) {
42722
- return locale2.formatDistance("xDays", 1, localizeOptions);
42723
- } else if (minutes < MINUTES_IN_MONTH) {
42724
- var days = Math.round(minutes / MINUTES_IN_DAY);
42725
- return locale2.formatDistance("xDays", days, localizeOptions);
42726
- } else if (minutes < MINUTES_IN_TWO_MONTHS) {
42727
- months = Math.round(minutes / MINUTES_IN_MONTH);
42728
- return locale2.formatDistance("aboutXMonths", months, localizeOptions);
42729
- }
42730
- months = differenceInMonths(dateRight, dateLeft);
42731
- if (months < 12) {
42732
- var nearestMonth = Math.round(minutes / MINUTES_IN_MONTH);
42733
- return locale2.formatDistance("xMonths", nearestMonth, localizeOptions);
42734
- } else {
42735
- var monthsSinceStartOfYear = months % 12;
42736
- var years = Math.floor(months / 12);
42737
- if (monthsSinceStartOfYear < 3) {
42738
- return locale2.formatDistance("aboutXYears", years, localizeOptions);
42739
- } else if (monthsSinceStartOfYear < 9) {
42740
- return locale2.formatDistance("overXYears", years, localizeOptions);
42741
- } else {
42742
- return locale2.formatDistance("almostXYears", years + 1, localizeOptions);
42743
- }
42744
- }
42745
- }
42746
- function formatDistanceToNow(dirtyDate, options) {
42747
- requiredArgs(1, arguments);
42748
- return formatDistance2(dirtyDate, Date.now(), options);
42749
- }
42750
42646
  const Select = SelectPrimitive.Root;
42751
42647
  const SelectValue = SelectPrimitive.Value;
42752
42648
  const SelectTrigger = React.forwardRef(({ className, children, ...props }, ref) => /* @__PURE__ */ React.createElement(
@@ -43382,7 +43278,7 @@ const TimePicker = React.forwardRef(
43382
43278
  TimePicker.displayName = "TimePicker";
43383
43279
  const DateTimePicker = React.forwardRef(
43384
43280
  ({
43385
- locale: locale2 = enUS,
43281
+ locale = enUS,
43386
43282
  defaultPopupValue = new Date((/* @__PURE__ */ new Date()).setHours(0, 0, 0, 0)),
43387
43283
  value,
43388
43284
  onChange,
@@ -43427,7 +43323,7 @@ const DateTimePicker = React.forwardRef(
43427
43323
  }),
43428
43324
  [displayDate]
43429
43325
  );
43430
- const { options, localize: localize2, formatLong: formatLong2 } = locale2;
43326
+ const { options, localize: localize2, formatLong: formatLong2 } = locale;
43431
43327
  if (options && localize2 && formatLong2) {
43432
43328
  ({
43433
43329
  ...enUS,
@@ -43473,7 +43369,7 @@ const DateTimePicker = React.forwardRef(
43473
43369
  onSelect: handleDaySelect,
43474
43370
  initialMonth: value ?? defaultPopupValue,
43475
43371
  yearRange,
43476
- locale: locale2,
43372
+ locale,
43477
43373
  ...props
43478
43374
  }
43479
43375
  ), granularity !== "day" && /* @__PURE__ */ React.createElement("div", { className: "border-border border-t p-3" }, /* @__PURE__ */ React.createElement(
@@ -43501,11 +43397,11 @@ const DateField = wrapFieldsWithMeta(
43501
43397
  const granularity = timeFormat ? "minute" : "day";
43502
43398
  const inputRef = React__default.useRef(null);
43503
43399
  React__default.useEffect(() => {
43504
- if (inputRef.current && rest.experimental_focusIntent) {
43400
+ if (inputRef.current && rest.focusIntent) {
43505
43401
  inputRef.current.focus();
43506
43402
  inputRef.current.open();
43507
43403
  }
43508
- }, [rest.experimental_focusIntent]);
43404
+ }, [rest.focusIntent]);
43509
43405
  const getTimeFormat = useCallback(() => {
43510
43406
  if (timeFormat === false) {
43511
43407
  return;
@@ -43521,10 +43417,11 @@ const DateField = wrapFieldsWithMeta(
43521
43417
  }
43522
43418
  return dateFormat;
43523
43419
  }, [dateFormat]);
43524
- const date = input.value ? new Date(input.value) : input.value;
43420
+ const date = input.value ? new Date(input.value) : /* @__PURE__ */ new Date();
43525
43421
  return /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, /* @__PURE__ */ React__default.createElement(
43526
43422
  DateTimePicker,
43527
43423
  {
43424
+ ...rest,
43528
43425
  ref: inputRef,
43529
43426
  granularity,
43530
43427
  onChange: (value) => input.onChange(value ? value.toISOString() : value),
@@ -43532,7 +43429,7 @@ const DateField = wrapFieldsWithMeta(
43532
43429
  hourCycle: 12,
43533
43430
  dateFormat: getDateFormat(),
43534
43431
  value: date,
43535
- ...rest
43432
+ locale: rest.locale ? { code: rest.locale } : void 0
43536
43433
  }
43537
43434
  ));
43538
43435
  }
@@ -44369,7 +44266,7 @@ const BranchItem = ({
44369
44266
  "Currently editing"
44370
44267
  )), indexingStatus !== "complete" && /* @__PURE__ */ React.createElement("div", { className: "w-fit mt-1" }, /* @__PURE__ */ React.createElement(IndexStatus, { indexingStatus: branch.indexStatus.status })))
44371
44268
  ),
44372
- /* @__PURE__ */ React.createElement("td", { className: "px-3 py-1.5 min-w-0" }, creatingPR ? /* @__PURE__ */ React.createElement("div", { className: "flex items-center gap-2" }, /* @__PURE__ */ React.createElement("div", null, /* @__PURE__ */ React.createElement("div", { className: "text-xs font-bold text-blue-600" }, "Creating PR"), /* @__PURE__ */ React.createElement("span", { className: "text-sm leading-tight text-blue-500" }, "Please wait...")), /* @__PURE__ */ React.createElement(FaSpinner, { className: "w-3 h-auto animate-spin text-blue-500" })) : /* @__PURE__ */ React.createElement("span", { className: "text-sm leading-tight whitespace-nowrap" }, formatDistanceToNow$1(new Date(branch.indexStatus.timestamp), {
44269
+ /* @__PURE__ */ React.createElement("td", { className: "px-3 py-1.5 min-w-0" }, creatingPR ? /* @__PURE__ */ React.createElement("div", { className: "flex items-center gap-2" }, /* @__PURE__ */ React.createElement("div", null, /* @__PURE__ */ React.createElement("div", { className: "text-xs font-bold text-blue-600" }, "Creating PR"), /* @__PURE__ */ React.createElement("span", { className: "text-sm leading-tight text-blue-500" }, "Please wait...")), /* @__PURE__ */ React.createElement(FaSpinner, { className: "w-3 h-auto animate-spin text-blue-500" })) : /* @__PURE__ */ React.createElement("span", { className: "text-sm leading-tight whitespace-nowrap" }, formatDistanceToNow(new Date(branch.indexStatus.timestamp), {
44373
44270
  addSuffix: true
44374
44271
  }))),
44375
44272
  /* @__PURE__ */ React.createElement("td", { className: "px-3 py-1.5 flex", onClick: (e3) => e3.stopPropagation() }, branch.githubPullRequestUrl ? /* @__PURE__ */ React.createElement(
@@ -46634,7 +46531,7 @@ const NavProvider = ({
46634
46531
  };
46635
46532
  return /* @__PURE__ */ React__default.createElement(NavContext.Provider, { value }, children);
46636
46533
  };
46637
- const version$1 = "3.1.2";
46534
+ const version$1 = "3.2.0";
46638
46535
  const VersionInfo = () => {
46639
46536
  var _a2, _b, _c, _d, _e, _f;
46640
46537
  const cms = useCMS();
@@ -48094,6 +47991,25 @@ class TinaCMS extends CMS {
48094
47991
  });
48095
47992
  }
48096
47993
  }
47994
+ const ACTION_TYPES = {
47995
+ FORMS_ADD: "forms:add",
47996
+ FORMS_REMOVE: "forms:remove",
47997
+ FORMS_CLEAR: "forms:clear",
47998
+ FORMS_SET_ACTIVE_FORM_ID: "forms:set-active-form-id",
47999
+ FORMS_SET_ACTIVE_FIELD_NAME: "forms:set-active-field-name",
48000
+ FORMS_SET_HOVERED_FIELD_NAME: "forms:set-hovered-field-name",
48001
+ FORM_LISTS_ADD: "form-lists:add",
48002
+ FORM_LISTS_REMOVE: "form-lists:remove",
48003
+ FORM_LISTS_CLEAR: "form-lists:clear",
48004
+ SET_EDIT_MODE: "set-edit-mode",
48005
+ INCREMENT_OPERATION_INDEX: "increment-operation-index",
48006
+ SET_QUICK_EDITING_SUPPORTED: "set-quick-editing-supported",
48007
+ SET_QUICK_EDITING_ENABLED: "set-quick-editing-enabled",
48008
+ TOGGLE_QUICK_EDITING_ENABLED: "toggle-quick-editing-enabled",
48009
+ TOGGLE_EDIT_STATE: "toggle-edit-state",
48010
+ SIDEBAR_SET_DISPLAY_STATE: "sidebar:set-display-state",
48011
+ SIDEBAR_SET_LOADING_STATE: "sidebar:set-loading-state"
48012
+ };
48097
48013
  const initialState = (cms) => {
48098
48014
  var _a2;
48099
48015
  return {
@@ -48109,24 +48025,24 @@ const initialState = (cms) => {
48109
48025
  };
48110
48026
  function tinaReducer(state, action) {
48111
48027
  switch (action.type) {
48112
- case "set-quick-editing-supported":
48028
+ case ACTION_TYPES.SET_QUICK_EDITING_SUPPORTED:
48113
48029
  return {
48114
48030
  ...state,
48115
48031
  quickEditSupported: action.value
48116
48032
  };
48117
- case "set-edit-mode":
48033
+ case ACTION_TYPES.SET_EDIT_MODE:
48118
48034
  return { ...state, editingMode: action.value };
48119
- case "forms:add":
48035
+ case ACTION_TYPES.FORMS_ADD:
48120
48036
  if (state.forms.find((f2) => f2.tinaForm.id === action.value.id)) {
48121
48037
  return state;
48122
48038
  }
48123
48039
  return { ...state, forms: [...state.forms, { tinaForm: action.value }] };
48124
- case "forms:remove":
48040
+ case ACTION_TYPES.FORMS_REMOVE:
48125
48041
  return {
48126
48042
  ...state,
48127
48043
  forms: state.forms.filter((form) => form.tinaForm.id !== action.value)
48128
48044
  };
48129
- case "form-lists:clear": {
48045
+ case ACTION_TYPES.FORM_LISTS_CLEAR: {
48130
48046
  return {
48131
48047
  ...state,
48132
48048
  quickEditSupported: false,
@@ -48136,7 +48052,7 @@ function tinaReducer(state, action) {
48136
48052
  forms: []
48137
48053
  };
48138
48054
  }
48139
- case "form-lists:add": {
48055
+ case ACTION_TYPES.FORM_LISTS_ADD: {
48140
48056
  let formListItemExists = false;
48141
48057
  const nextFormLists = state.formLists.map((formList) => {
48142
48058
  if (formList.id === action.value.id) {
@@ -48175,7 +48091,7 @@ function tinaReducer(state, action) {
48175
48091
  isLoadingContent: false
48176
48092
  };
48177
48093
  }
48178
- case "form-lists:remove": {
48094
+ case ACTION_TYPES.FORM_LISTS_REMOVE: {
48179
48095
  const nextFormLists = state.formLists.filter(
48180
48096
  ({ id: id2 }) => id2 !== action.value
48181
48097
  );
@@ -48199,7 +48115,7 @@ function tinaReducer(state, action) {
48199
48115
  formLists: nextFormLists
48200
48116
  };
48201
48117
  }
48202
- case "forms:set-active-form-id":
48118
+ case ACTION_TYPES.FORMS_SET_ACTIVE_FORM_ID:
48203
48119
  if (action.value !== state.activeFormId) {
48204
48120
  const newActiveForm = state.forms.find(
48205
48121
  (form) => form.tinaForm.id === action.value
@@ -48216,7 +48132,7 @@ function tinaReducer(state, action) {
48216
48132
  };
48217
48133
  }
48218
48134
  return state;
48219
- case "forms:set-active-field-name":
48135
+ case ACTION_TYPES.FORMS_SET_ACTIVE_FIELD_NAME:
48220
48136
  if (state.activeFormId === action.value.formId) {
48221
48137
  const existingForm = state.forms.find(
48222
48138
  (form) => form.tinaForm.id === action.value.formId
@@ -48229,7 +48145,8 @@ function tinaReducer(state, action) {
48229
48145
  if (form.tinaForm.id === action.value.formId) {
48230
48146
  return {
48231
48147
  tinaForm: form.tinaForm,
48232
- activeFieldName: action.value.fieldName
48148
+ activeFieldName: action.value.fieldName,
48149
+ hoveringFieldName: null
48233
48150
  };
48234
48151
  }
48235
48152
  return form;
@@ -48245,13 +48162,49 @@ function tinaReducer(state, action) {
48245
48162
  forms,
48246
48163
  activeFormId: action.value.formId
48247
48164
  };
48248
- case "toggle-edit-state": {
48165
+ case ACTION_TYPES.FORMS_SET_HOVERED_FIELD_NAME:
48166
+ const hoveredForms = state.forms.map((form) => {
48167
+ if (form.tinaForm.id === action.value.formId) {
48168
+ const activeFieldName = form.activeFieldName;
48169
+ const hoveredFieldName = action.value.fieldName;
48170
+ if (activeFieldName && hoveredFieldName) {
48171
+ if (activeFieldName === hoveredFieldName) {
48172
+ return {
48173
+ ...form,
48174
+ hoveringFieldName: null
48175
+ };
48176
+ }
48177
+ const isChildOfActive = hoveredFieldName.startsWith(
48178
+ activeFieldName + "."
48179
+ );
48180
+ const activePathParts = activeFieldName.split(".");
48181
+ const hoveredPathParts = hoveredFieldName.split(".");
48182
+ const isSibling = activePathParts.length === hoveredPathParts.length && activePathParts.slice(0, -1).join(".") === hoveredPathParts.slice(0, -1).join(".");
48183
+ if (!isChildOfActive && !isSibling) {
48184
+ return {
48185
+ ...form,
48186
+ hoveringFieldName: null
48187
+ };
48188
+ }
48189
+ }
48190
+ return {
48191
+ ...form,
48192
+ hoveringFieldName: hoveredFieldName
48193
+ };
48194
+ }
48195
+ return form;
48196
+ });
48197
+ return {
48198
+ ...state,
48199
+ forms: hoveredForms
48200
+ };
48201
+ case ACTION_TYPES.TOGGLE_EDIT_STATE: {
48249
48202
  return state.sidebarDisplayState === "closed" ? { ...state, sidebarDisplayState: "open" } : {
48250
48203
  ...state,
48251
48204
  sidebarDisplayState: "closed"
48252
48205
  };
48253
48206
  }
48254
- case "sidebar:set-display-state": {
48207
+ case ACTION_TYPES.SIDEBAR_SET_DISPLAY_STATE: {
48255
48208
  if (action.value === "openOrFull") {
48256
48209
  if (state.sidebarDisplayState === "closed") {
48257
48210
  return {
@@ -48269,7 +48222,7 @@ function tinaReducer(state, action) {
48269
48222
  }
48270
48223
  return { ...state, sidebarDisplayState: action.value };
48271
48224
  }
48272
- case "sidebar:set-loading-state": {
48225
+ case ACTION_TYPES.SIDEBAR_SET_LOADING_STATE: {
48273
48226
  return { ...state, isLoadingContent: action.value };
48274
48227
  }
48275
48228
  default:
@@ -48538,10 +48491,12 @@ const AboveViewportIndicator = () => {
48538
48491
  const BelowViewportIndicator = () => {
48539
48492
  return /* @__PURE__ */ React.createElement(IndicatorWrap, { position: "bottom" }, /* @__PURE__ */ React.createElement(ArrowWrap, null, /* @__PURE__ */ React.createElement(ChevronDownIcon, { className: "w-8 h-auto" })));
48540
48493
  };
48541
- const useScrollToFocusedField = () => {
48494
+ const useScrollToFocusedField = (enabled) => {
48542
48495
  const { subscribe } = useEvent("field:focus");
48543
- React.useEffect(
48544
- () => subscribe(({ fieldName }) => {
48496
+ React.useEffect(() => {
48497
+ if (!enabled)
48498
+ return;
48499
+ return subscribe(({ fieldName }) => {
48545
48500
  const ele = document.querySelector(
48546
48501
  `[data-tinafield="${fieldName}"]`
48547
48502
  );
@@ -48577,17 +48532,41 @@ const useScrollToFocusedField = () => {
48577
48532
  });
48578
48533
  }
48579
48534
  }
48580
- })
48581
- );
48535
+ });
48536
+ }, [enabled, subscribe]);
48582
48537
  };
48583
- const ActiveFieldIndicator = () => {
48584
- const [activeFieldName, setActiveFieldName] = React.useState(
48585
- null
48586
- );
48538
+ const FieldIndicator = ({
48539
+ eventType,
48540
+ checkFocusedAttribute = false,
48541
+ scrollToField = false
48542
+ }) => {
48543
+ const [fieldName, setFieldName] = React.useState(null);
48587
48544
  const [display, setDisplay] = React.useState(false);
48588
48545
  const [position, setPosition] = React.useState(false);
48589
48546
  const [iframePosition, setIframePosition] = React.useState({ left: 0 });
48590
- const activeEle = useFieldReference(activeFieldName);
48547
+ const [isFocused2, setIsFocused] = React.useState(false);
48548
+ const activeEle = useFieldReference(fieldName);
48549
+ const { subscribe: subscribeFocus } = useEvent("field:focus");
48550
+ const { subscribe: subscribeHover } = useEvent("field:hover");
48551
+ React.useEffect(() => {
48552
+ const subscribe = eventType === "field:focus" ? subscribeFocus : subscribeHover;
48553
+ return subscribe(({ fieldName: eventFieldName, id: id2 }) => {
48554
+ setFieldName(`${id2}#${eventFieldName}`);
48555
+ if (eventType === "field:focus" && checkFocusedAttribute) {
48556
+ setIsFocused(true);
48557
+ }
48558
+ });
48559
+ }, [eventType, subscribeFocus, subscribeHover, checkFocusedAttribute]);
48560
+ React.useEffect(() => {
48561
+ if (!checkFocusedAttribute)
48562
+ return;
48563
+ if (activeEle) {
48564
+ const hasFocusedAttr = activeEle.hasAttribute("data-tina-field-focused");
48565
+ setIsFocused(hasFocusedAttr);
48566
+ } else {
48567
+ setIsFocused(false);
48568
+ }
48569
+ }, [activeEle, fieldName, checkFocusedAttribute]);
48591
48570
  React.useEffect(() => {
48592
48571
  let displayTimeout;
48593
48572
  if (activeEle) {
@@ -48616,13 +48595,7 @@ const ActiveFieldIndicator = () => {
48616
48595
  window.removeEventListener("scroll", rerender);
48617
48596
  };
48618
48597
  }, []);
48619
- const { subscribe } = useEvent("field:hover");
48620
- React.useEffect(
48621
- () => subscribe(({ fieldName, id: id2 }) => {
48622
- setActiveFieldName(`${id2}#${fieldName}`);
48623
- })
48624
- );
48625
- useScrollToFocusedField();
48598
+ useScrollToFocusedField(scrollToField);
48626
48599
  if (!display)
48627
48600
  return null;
48628
48601
  const eleTopY = position.top + window.scrollY;
@@ -48635,6 +48608,7 @@ const ActiveFieldIndicator = () => {
48635
48608
  if (eleBottomY < viewportTopY) {
48636
48609
  return /* @__PURE__ */ React.createElement(AboveViewportIndicator, null);
48637
48610
  }
48611
+ const outlineColor = checkFocusedAttribute && isFocused2 ? "2px dashed #C2410C" : "2px dashed var(--tina-color-indicator)";
48638
48612
  return /* @__PURE__ */ React.createElement(
48639
48613
  "div",
48640
48614
  {
@@ -48645,7 +48619,7 @@ const ActiveFieldIndicator = () => {
48645
48619
  left: position.left + window.scrollX + iframePosition.left,
48646
48620
  width: position.width,
48647
48621
  height: position.height,
48648
- outline: "2px dashed var(--tina-color-indicator)",
48622
+ outline: outlineColor,
48649
48623
  borderRadius: "var(--tina-radius-small)",
48650
48624
  transition: display ? activeEle ? `opacity 300ms ease-out` : `opacity 150ms ease-in` : `none`,
48651
48625
  opacity: activeEle && display ? 0.8 : 0
@@ -48653,6 +48627,15 @@ const ActiveFieldIndicator = () => {
48653
48627
  }
48654
48628
  );
48655
48629
  };
48630
+ const ActiveFieldIndicator = () => /* @__PURE__ */ React.createElement(
48631
+ FieldIndicator,
48632
+ {
48633
+ eventType: "field:focus",
48634
+ checkFocusedAttribute: true,
48635
+ scrollToField: true
48636
+ }
48637
+ );
48638
+ const HoveredFieldIndicator = () => /* @__PURE__ */ React.createElement(FieldIndicator, { eventType: "field:hover" });
48656
48639
  const TinaUI = ({ children, position }) => {
48657
48640
  const cms = useCMS();
48658
48641
  const [resizingSidebar, setResizingSidebar] = React.useState(false);
@@ -48664,7 +48647,7 @@ const TinaUI = ({ children, position }) => {
48664
48647
  position,
48665
48648
  sidebar: cms.sidebar
48666
48649
  }
48667
- ), /* @__PURE__ */ React.createElement(ActiveFieldIndicator, null), /* @__PURE__ */ React.createElement("div", { className: `${resizingSidebar ? "pointer-events-none" : ""}` }, children)));
48650
+ ), /* @__PURE__ */ React.createElement(ActiveFieldIndicator, null), /* @__PURE__ */ React.createElement(HoveredFieldIndicator, null), /* @__PURE__ */ React.createElement("div", { className: `${resizingSidebar ? "pointer-events-none" : ""}` }, children)));
48668
48651
  };
48669
48652
  const TinaProvider = ({
48670
48653
  cms,
@@ -64633,6 +64616,7 @@ const FormBuilder = ({
64633
64616
  {
64634
64617
  form: tinaForm,
64635
64618
  activeFieldName: form.activeFieldName,
64619
+ hoveringFieldName: form.hoveringFieldName,
64636
64620
  fields: fieldGroup.fields
64637
64621
  }
64638
64622
  ) : /* @__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(
@@ -64677,9 +64661,9 @@ const FormWrapper = ({
64677
64661
  "div",
64678
64662
  {
64679
64663
  "data-test": `form:${id2 == null ? void 0 : id2.replace(/\\/g, "/")}`,
64680
- className: "h-full overflow-y-auto max-h-full bg-gray-50"
64664
+ className: "h-full overflow-y-auto max-h-full bg-gray-50 @container"
64681
64665
  },
64682
- /* @__PURE__ */ React.createElement("div", { className: "py-5 px-6" }, children)
64666
+ /* @__PURE__ */ React.createElement("div", { className: "py-5 px-4" }, children)
64683
64667
  );
64684
64668
  };
64685
64669
  const Emoji = ({ className = "", ...props }) => /* @__PURE__ */ React.createElement(
@@ -64805,7 +64789,7 @@ const ImgEmbed = ({
64805
64789
  "button",
64806
64790
  {
64807
64791
  type: "button",
64808
- 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" : ""}`,
64792
+ 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" : ""}`,
64809
64793
  onClick: handleSelect
64810
64794
  },
64811
64795
  isImage(element.url) ? /* @__PURE__ */ React__default.createElement(StyledImage, { src: element.url }) : /* @__PURE__ */ React__default.createElement(StyledFile, { src: element.url })
@@ -65061,7 +65045,7 @@ const DotMenu = ({ onOpen, onRemove }) => {
65061
65045
  PopoverButton,
65062
65046
  {
65063
65047
  as: "span",
65064
- 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"
65048
+ 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"
65065
65049
  },
65066
65050
  /* @__PURE__ */ React__default.createElement(EllipsisIcon, { title: "Open options" })
65067
65051
  ), /* @__PURE__ */ React__default.createElement(
@@ -66039,7 +66023,7 @@ const editorVariants = cva(
66039
66023
  ai: "w-full px-0 text-base md:text-sm",
66040
66024
  aiChat: "max-h-[min(70vh,320px)] w-full max-w-[700px] overflow-y-auto px-3 py-2 text-base md:text-sm",
66041
66025
  comment: cn$2("rounded-none border-none bg-transparent text-sm"),
66042
- default: "size-full px-2 sm:px-4 pt-2 text-base",
66026
+ default: "size-full px-2 sm:px-4 pt-2 text-base min-h-[100px]",
66043
66027
  demo: "size-full px-2 sm:px-4 pt-2 text-base h-[650px]",
66044
66028
  fullWidth: "size-full px-2 sm:px-4 pt-4 pb-72 text-base",
66045
66029
  none: "",
@@ -118983,13 +118967,13 @@ const RichEditor = ({ input, tinaForm, field }) => {
118983
118967
  const plateElement = (_a3 = ref.current) == null ? void 0 : _a3.querySelector(
118984
118968
  '[role="textbox"]'
118985
118969
  );
118986
- if (field.experimental_focusIntent && plateElement) {
118970
+ if (field.focusIntent && plateElement) {
118987
118971
  if (plateElement)
118988
118972
  plateElement.focus();
118989
118973
  }
118990
118974
  }, 100);
118991
118975
  }
118992
- }, [field.experimental_focusIntent, ref]);
118976
+ }, [field.focusIntent, ref]);
118993
118977
  return /* @__PURE__ */ React__default.createElement("div", { ref }, /* @__PURE__ */ React__default.createElement(
118994
118978
  Plate,
118995
118979
  {
@@ -119080,7 +119064,7 @@ const MdxFieldPluginExtendible = {
119080
119064
  /* @__PURE__ */ React__default.createElement(
119081
119065
  "div",
119082
119066
  {
119083
- 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"
119067
+ 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"
119084
119068
  },
119085
119069
  props.rawMode ? props.rawEditor : /* @__PURE__ */ React__default.createElement(RichEditor, { ...props })
119086
119070
  )