tinacms 3.2.0 → 3.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +1659 -1651
- package/dist/internalClient/index.d.ts +27 -30
- package/dist/react.js +0 -94
- package/dist/toolkit/components/active-field-indicator.d.ts +0 -1
- package/dist/toolkit/components/ui/date-time-picker.d.ts +1 -1
- package/dist/toolkit/fields/components/password-field.d.ts +1 -1
- package/dist/toolkit/fields/components/select.d.ts +1 -1
- package/dist/toolkit/fields/components/text-field.d.ts +1 -1
- package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/plugins/ui/components.d.ts +2 -1
- package/dist/toolkit/fields/plugins/wrap-field-with-meta.d.ts +2 -6
- package/dist/toolkit/form-builder/fields-builder.d.ts +1 -2
- package/dist/toolkit/form-builder/form-builder.d.ts +0 -1
- package/dist/toolkit/forms/field.d.ts +2 -3
- package/dist/toolkit/tina-state.d.ts +16 -42
- package/package.json +4 -4
package/dist/index.js
CHANGED
|
@@ -7,11 +7,8 @@ var __publicField = (obj, key, value) => {
|
|
|
7
7
|
var _a;
|
|
8
8
|
import { z } from "zod";
|
|
9
9
|
import * as React from "react";
|
|
10
|
-
import React__default, { useState, useCallback, useContext, createContext, forwardRef, useRef, useReducer, useMemo, useEffect, useLayoutEffect, Component, memo
|
|
10
|
+
import React__default, { useState, useCallback, useContext, createContext, forwardRef, useRef, useReducer, useMemo, useEffect, useLayoutEffect, Component, memo, useDebugValue, useId, startTransition, useImperativeHandle } from "react";
|
|
11
11
|
import ReactDOM, { createPortal } from "react-dom";
|
|
12
|
-
import { createForm, FORM_ERROR, getIn } from "final-form";
|
|
13
|
-
import arrayMutators from "final-form-arrays";
|
|
14
|
-
import setFieldData from "final-form-set-field-data";
|
|
15
12
|
import { withRef as withRef$1, cn as cn$2, withCn, createPrimitiveElement, withVariants, withProps, useComposedRef as useComposedRef$1, PortalBody } from "@udecode/cn";
|
|
16
13
|
import { HEADING_KEYS as HEADING_KEYS$1, HEADING_LEVELS as HEADING_LEVELS$1 } from "@udecode/plate-heading";
|
|
17
14
|
import { isHotkey } from "is-hotkey";
|
|
@@ -37,6 +34,9 @@ import * as DropdownMenuPrimitive from "@radix-ui/react-dropdown-menu";
|
|
|
37
34
|
import * as ToolbarPrimitive from "@radix-ui/react-toolbar";
|
|
38
35
|
import * as SeparatorPrimitive from "@radix-ui/react-separator";
|
|
39
36
|
import * as TooltipPrimitive from "@radix-ui/react-tooltip";
|
|
37
|
+
import { createForm, FORM_ERROR, getIn } from "final-form";
|
|
38
|
+
import arrayMutators from "final-form-arrays";
|
|
39
|
+
import setFieldData from "final-form-set-field-data";
|
|
40
40
|
import { Field, Form as Form$1 } from "react-final-form";
|
|
41
41
|
import PropTypes from "prop-types";
|
|
42
42
|
import { twMerge } from "tailwind-merge";
|
|
@@ -869,1028 +869,458 @@ function useEvent(eventType) {
|
|
|
869
869
|
subscribe: (callback) => cms.events.subscribe(eventType, callback)
|
|
870
870
|
};
|
|
871
871
|
}
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
872
|
+
function wrapFieldsWithMeta(Field2) {
|
|
873
|
+
return (props) => {
|
|
874
|
+
return /* @__PURE__ */ React.createElement(
|
|
875
|
+
FieldMeta,
|
|
876
|
+
{
|
|
877
|
+
name: props.input.name,
|
|
878
|
+
label: props.field.label,
|
|
879
|
+
description: props.field.description,
|
|
880
|
+
error: props.meta.error,
|
|
881
|
+
index: props.index,
|
|
882
|
+
tinaForm: props.tinaForm,
|
|
883
|
+
field: props.field
|
|
884
|
+
},
|
|
885
|
+
/* @__PURE__ */ React.createElement(Field2, { ...props })
|
|
886
|
+
);
|
|
887
|
+
};
|
|
888
|
+
}
|
|
889
|
+
function wrapFieldWithNoHeader(Field2) {
|
|
890
|
+
return (props) => {
|
|
891
|
+
return /* @__PURE__ */ React.createElement(
|
|
892
|
+
FieldMeta,
|
|
893
|
+
{
|
|
894
|
+
name: props.input.name,
|
|
895
|
+
label: false,
|
|
896
|
+
description: "",
|
|
897
|
+
error: props.meta.error,
|
|
898
|
+
index: props.index,
|
|
899
|
+
tinaForm: props.tinaForm
|
|
900
|
+
},
|
|
901
|
+
/* @__PURE__ */ React.createElement(Field2, { ...props })
|
|
902
|
+
);
|
|
903
|
+
};
|
|
904
|
+
}
|
|
905
|
+
function wrapFieldWithError(Field2) {
|
|
906
|
+
return (props) => {
|
|
907
|
+
return /* @__PURE__ */ React.createElement(
|
|
908
|
+
FieldMeta,
|
|
909
|
+
{
|
|
910
|
+
name: props.input.name,
|
|
911
|
+
label: false,
|
|
912
|
+
description: props.field.description,
|
|
913
|
+
error: props.meta.error,
|
|
914
|
+
index: props.index,
|
|
915
|
+
tinaForm: props.tinaForm
|
|
916
|
+
},
|
|
917
|
+
/* @__PURE__ */ React.createElement(Field2, { ...props })
|
|
918
|
+
);
|
|
919
|
+
};
|
|
920
|
+
}
|
|
921
|
+
const FieldMeta = ({
|
|
922
|
+
name,
|
|
923
|
+
label,
|
|
924
|
+
description,
|
|
925
|
+
error: error2,
|
|
926
|
+
margin = true,
|
|
927
|
+
children,
|
|
928
|
+
index,
|
|
929
|
+
tinaForm,
|
|
930
|
+
field,
|
|
931
|
+
...props
|
|
932
|
+
}) => {
|
|
933
|
+
const { dispatch: setHoveredField } = useEvent("field:hover");
|
|
934
|
+
const { dispatch: setFocusedField } = useEvent("field:focus");
|
|
935
|
+
return /* @__PURE__ */ React.createElement(
|
|
936
|
+
FieldWrapper,
|
|
937
|
+
{
|
|
938
|
+
margin,
|
|
939
|
+
field,
|
|
940
|
+
onMouseOver: () => setHoveredField({ id: tinaForm.id, fieldName: name }),
|
|
941
|
+
onMouseOut: () => setHoveredField({ id: null, fieldName: null }),
|
|
942
|
+
onClick: () => setFocusedField({ id: tinaForm.id, fieldName: name }),
|
|
943
|
+
style: { zIndex: index ? 1e3 - index : void 0 },
|
|
944
|
+
...props
|
|
945
|
+
},
|
|
946
|
+
(label !== false || description) && /* @__PURE__ */ React.createElement(FieldLabel, { name }, label !== false && /* @__PURE__ */ React.createElement(React.Fragment, null, label || name), description && /* @__PURE__ */ React.createElement(FieldDescription, null, description)),
|
|
947
|
+
children,
|
|
948
|
+
error2 && typeof error2 === "string" && /* @__PURE__ */ React.createElement(FieldError, null, error2)
|
|
949
|
+
);
|
|
950
|
+
};
|
|
951
|
+
const FieldWrapper = ({
|
|
952
|
+
margin,
|
|
953
|
+
children,
|
|
954
|
+
field,
|
|
955
|
+
...props
|
|
956
|
+
}) => {
|
|
957
|
+
return /* @__PURE__ */ React.createElement(
|
|
958
|
+
"div",
|
|
959
|
+
{
|
|
960
|
+
className: `relative w-full px-2 ${margin ? "mb-5 last:mb-0" : ""} ${(field == null ? void 0 : field.width) === "half" ? "@sm:w-1/2" : ""}`,
|
|
961
|
+
...props
|
|
962
|
+
},
|
|
963
|
+
children
|
|
964
|
+
);
|
|
965
|
+
};
|
|
966
|
+
const FieldLabel = ({
|
|
967
|
+
children,
|
|
968
|
+
className,
|
|
969
|
+
name,
|
|
970
|
+
...props
|
|
971
|
+
}) => {
|
|
972
|
+
return /* @__PURE__ */ React.createElement(
|
|
973
|
+
"label",
|
|
974
|
+
{
|
|
975
|
+
htmlFor: name,
|
|
976
|
+
className: `block font-sans text-xs font-semibold text-gray-700 whitespace-normal mb-2 ${className}`,
|
|
977
|
+
...props
|
|
978
|
+
},
|
|
979
|
+
children
|
|
980
|
+
);
|
|
981
|
+
};
|
|
982
|
+
const FieldDescription = ({
|
|
983
|
+
children,
|
|
984
|
+
className,
|
|
985
|
+
...props
|
|
986
|
+
}) => {
|
|
987
|
+
if (typeof children === "string") {
|
|
988
|
+
return /* @__PURE__ */ React.createElement(
|
|
989
|
+
"span",
|
|
990
|
+
{
|
|
991
|
+
className: `block font-sans text-xs italic font-light text-gray-400 pt-0.5 whitespace-normal m-0 ${className}`,
|
|
992
|
+
...props,
|
|
993
|
+
dangerouslySetInnerHTML: { __html: children }
|
|
959
994
|
}
|
|
960
|
-
|
|
961
|
-
this._reset = reset2;
|
|
962
|
-
this.actions = actions || [];
|
|
963
|
-
this.buttons = buttons || {
|
|
964
|
-
save: "Save",
|
|
965
|
-
reset: "Reset"
|
|
966
|
-
};
|
|
967
|
-
this.updateFields(this.fields);
|
|
968
|
-
if (loadInitialValues) {
|
|
969
|
-
this.loading = true;
|
|
970
|
-
loadInitialValues().then((initialValues2) => {
|
|
971
|
-
this.updateInitialValues(initialValues2);
|
|
972
|
-
}).finally(() => {
|
|
973
|
-
this.loading = false;
|
|
974
|
-
});
|
|
975
|
-
}
|
|
976
|
-
if (onChange) {
|
|
977
|
-
let firstUpdate = true;
|
|
978
|
-
this.subscribe(
|
|
979
|
-
(formState) => {
|
|
980
|
-
if (firstUpdate) {
|
|
981
|
-
firstUpdate = false;
|
|
982
|
-
} else {
|
|
983
|
-
onChange(formState);
|
|
984
|
-
}
|
|
985
|
-
},
|
|
986
|
-
{ values: true, ...(options == null ? void 0 : options.extraSubscribeValues) || {} }
|
|
987
|
-
);
|
|
988
|
-
}
|
|
995
|
+
);
|
|
989
996
|
}
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
+
return /* @__PURE__ */ React.createElement(
|
|
998
|
+
"span",
|
|
999
|
+
{
|
|
1000
|
+
className: `block font-sans text-xs italic font-light text-gray-400 pt-0.5 whitespace-normal m-0 ${className}`,
|
|
1001
|
+
...props
|
|
1002
|
+
},
|
|
1003
|
+
children
|
|
1004
|
+
);
|
|
1005
|
+
};
|
|
1006
|
+
const FieldError = ({
|
|
1007
|
+
children,
|
|
1008
|
+
className,
|
|
1009
|
+
...props
|
|
1010
|
+
}) => {
|
|
1011
|
+
return /* @__PURE__ */ React.createElement(
|
|
1012
|
+
"span",
|
|
1013
|
+
{
|
|
1014
|
+
className: `block font-sans text-xs font-normal text-red-500 pt-3 animate-slide-in whitespace-normal m-0 ${className}`,
|
|
1015
|
+
...props
|
|
1016
|
+
},
|
|
1017
|
+
children
|
|
1018
|
+
);
|
|
1019
|
+
};
|
|
1020
|
+
const EditorContext$1 = React__default.createContext({
|
|
1021
|
+
fieldName: "",
|
|
1022
|
+
rawMode: false,
|
|
1023
|
+
setRawMode: () => {
|
|
1024
|
+
},
|
|
1025
|
+
templates: []
|
|
1026
|
+
});
|
|
1027
|
+
const useEditorContext = () => {
|
|
1028
|
+
return React__default.useContext(EditorContext$1);
|
|
1029
|
+
};
|
|
1030
|
+
const useTemplates = () => {
|
|
1031
|
+
return React__default.useContext(EditorContext$1);
|
|
1032
|
+
};
|
|
1033
|
+
var commonjsGlobal = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : {};
|
|
1034
|
+
function getDefaultExportFromCjs(x) {
|
|
1035
|
+
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x;
|
|
1036
|
+
}
|
|
1037
|
+
var direction_1 = direction;
|
|
1038
|
+
var RTL = "֑-߿יִ-﷽ﹰ-ﻼ";
|
|
1039
|
+
var LTR = "A-Za-zÀ-ÖØ-öø-ʸ̀-ࠀ-Ⰰ-︀--";
|
|
1040
|
+
var rtl = new RegExp("^[^" + LTR + "]*[" + RTL + "]");
|
|
1041
|
+
var ltr = new RegExp("^[^" + RTL + "]*[" + LTR + "]");
|
|
1042
|
+
function direction(value) {
|
|
1043
|
+
value = String(value || "");
|
|
1044
|
+
if (rtl.test(value)) {
|
|
1045
|
+
return "rtl";
|
|
997
1046
|
}
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1047
|
+
if (ltr.test(value)) {
|
|
1048
|
+
return "ltr";
|
|
1049
|
+
}
|
|
1050
|
+
return "neutral";
|
|
1051
|
+
}
|
|
1052
|
+
const getDirection = /* @__PURE__ */ getDefaultExportFromCjs(direction_1);
|
|
1053
|
+
function isObject$e(value) {
|
|
1054
|
+
var type = typeof value;
|
|
1055
|
+
return value != null && (type == "object" || type == "function");
|
|
1056
|
+
}
|
|
1057
|
+
var isObject_1 = isObject$e;
|
|
1058
|
+
var freeGlobal$1 = typeof commonjsGlobal == "object" && commonjsGlobal && commonjsGlobal.Object === Object && commonjsGlobal;
|
|
1059
|
+
var _freeGlobal = freeGlobal$1;
|
|
1060
|
+
var freeGlobal = _freeGlobal;
|
|
1061
|
+
var freeSelf = typeof self == "object" && self && self.Object === Object && self;
|
|
1062
|
+
var root$9 = freeGlobal || freeSelf || Function("return this")();
|
|
1063
|
+
var _root = root$9;
|
|
1064
|
+
var root$8 = _root;
|
|
1065
|
+
var now$1 = function() {
|
|
1066
|
+
return root$8.Date.now();
|
|
1067
|
+
};
|
|
1068
|
+
var now_1 = now$1;
|
|
1069
|
+
var reWhitespace = /\s/;
|
|
1070
|
+
function trimmedEndIndex$1(string3) {
|
|
1071
|
+
var index = string3.length;
|
|
1072
|
+
while (index-- && reWhitespace.test(string3.charAt(index))) {
|
|
1073
|
+
}
|
|
1074
|
+
return index;
|
|
1075
|
+
}
|
|
1076
|
+
var _trimmedEndIndex = trimmedEndIndex$1;
|
|
1077
|
+
var trimmedEndIndex = _trimmedEndIndex;
|
|
1078
|
+
var reTrimStart = /^\s+/;
|
|
1079
|
+
function baseTrim$1(string3) {
|
|
1080
|
+
return string3 ? string3.slice(0, trimmedEndIndex(string3) + 1).replace(reTrimStart, "") : string3;
|
|
1081
|
+
}
|
|
1082
|
+
var _baseTrim = baseTrim$1;
|
|
1083
|
+
var root$7 = _root;
|
|
1084
|
+
var Symbol$7 = root$7.Symbol;
|
|
1085
|
+
var _Symbol = Symbol$7;
|
|
1086
|
+
var Symbol$6 = _Symbol;
|
|
1087
|
+
var objectProto$f = Object.prototype;
|
|
1088
|
+
var hasOwnProperty$c = objectProto$f.hasOwnProperty;
|
|
1089
|
+
var nativeObjectToString$1 = objectProto$f.toString;
|
|
1090
|
+
var symToStringTag$1 = Symbol$6 ? Symbol$6.toStringTag : void 0;
|
|
1091
|
+
function getRawTag$1(value) {
|
|
1092
|
+
var isOwn = hasOwnProperty$c.call(value, symToStringTag$1), tag = value[symToStringTag$1];
|
|
1093
|
+
try {
|
|
1094
|
+
value[symToStringTag$1] = void 0;
|
|
1095
|
+
var unmasked = true;
|
|
1096
|
+
} catch (e3) {
|
|
1097
|
+
}
|
|
1098
|
+
var result = nativeObjectToString$1.call(value);
|
|
1099
|
+
if (unmasked) {
|
|
1100
|
+
if (isOwn) {
|
|
1101
|
+
value[symToStringTag$1] = tag;
|
|
1102
|
+
} else {
|
|
1103
|
+
delete value[symToStringTag$1];
|
|
1006
1104
|
}
|
|
1007
|
-
return this.finalForm.getState().values || this.initialValues;
|
|
1008
1105
|
}
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1106
|
+
return result;
|
|
1107
|
+
}
|
|
1108
|
+
var _getRawTag = getRawTag$1;
|
|
1109
|
+
var objectProto$e = Object.prototype;
|
|
1110
|
+
var nativeObjectToString = objectProto$e.toString;
|
|
1111
|
+
function objectToString$1(value) {
|
|
1112
|
+
return nativeObjectToString.call(value);
|
|
1113
|
+
}
|
|
1114
|
+
var _objectToString = objectToString$1;
|
|
1115
|
+
var Symbol$5 = _Symbol, getRawTag = _getRawTag, objectToString = _objectToString;
|
|
1116
|
+
var nullTag = "[object Null]", undefinedTag = "[object Undefined]";
|
|
1117
|
+
var symToStringTag = Symbol$5 ? Symbol$5.toStringTag : void 0;
|
|
1118
|
+
function baseGetTag$6(value) {
|
|
1119
|
+
if (value == null) {
|
|
1120
|
+
return value === void 0 ? undefinedTag : nullTag;
|
|
1014
1121
|
}
|
|
1015
|
-
|
|
1016
|
-
|
|
1122
|
+
return symToStringTag && symToStringTag in Object(value) ? getRawTag(value) : objectToString(value);
|
|
1123
|
+
}
|
|
1124
|
+
var _baseGetTag = baseGetTag$6;
|
|
1125
|
+
function isObjectLike$9(value) {
|
|
1126
|
+
return value != null && typeof value == "object";
|
|
1127
|
+
}
|
|
1128
|
+
var isObjectLike_1 = isObjectLike$9;
|
|
1129
|
+
var baseGetTag$5 = _baseGetTag, isObjectLike$8 = isObjectLike_1;
|
|
1130
|
+
var symbolTag$3 = "[object Symbol]";
|
|
1131
|
+
function isSymbol$4(value) {
|
|
1132
|
+
return typeof value == "symbol" || isObjectLike$8(value) && baseGetTag$5(value) == symbolTag$3;
|
|
1133
|
+
}
|
|
1134
|
+
var isSymbol_1 = isSymbol$4;
|
|
1135
|
+
var baseTrim = _baseTrim, isObject$d = isObject_1, isSymbol$3 = isSymbol_1;
|
|
1136
|
+
var NAN = 0 / 0;
|
|
1137
|
+
var reIsBadHex = /^[-+]0x[0-9a-f]+$/i;
|
|
1138
|
+
var reIsBinary = /^0b[01]+$/i;
|
|
1139
|
+
var reIsOctal = /^0o[0-7]+$/i;
|
|
1140
|
+
var freeParseInt = parseInt;
|
|
1141
|
+
function toNumber$1(value) {
|
|
1142
|
+
if (typeof value == "number") {
|
|
1143
|
+
return value;
|
|
1017
1144
|
}
|
|
1018
|
-
|
|
1019
|
-
return
|
|
1145
|
+
if (isSymbol$3(value)) {
|
|
1146
|
+
return NAN;
|
|
1020
1147
|
}
|
|
1021
|
-
|
|
1022
|
-
|
|
1148
|
+
if (isObject$d(value)) {
|
|
1149
|
+
var other = typeof value.valueOf == "function" ? value.valueOf() : value;
|
|
1150
|
+
value = isObject$d(other) ? other + "" : other;
|
|
1023
1151
|
}
|
|
1024
|
-
|
|
1025
|
-
return
|
|
1152
|
+
if (typeof value != "string") {
|
|
1153
|
+
return value === 0 ? value : +value;
|
|
1026
1154
|
}
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1155
|
+
value = baseTrim(value);
|
|
1156
|
+
var isBinary = reIsBinary.test(value);
|
|
1157
|
+
return isBinary || reIsOctal.test(value) ? freeParseInt(value.slice(2), isBinary ? 2 : 8) : reIsBadHex.test(value) ? NAN : +value;
|
|
1158
|
+
}
|
|
1159
|
+
var toNumber_1 = toNumber$1;
|
|
1160
|
+
var isObject$c = isObject_1, now = now_1, toNumber = toNumber_1;
|
|
1161
|
+
var FUNC_ERROR_TEXT$3 = "Expected a function";
|
|
1162
|
+
var nativeMax$1 = Math.max, nativeMin = Math.min;
|
|
1163
|
+
function debounce$1(func, wait, options) {
|
|
1164
|
+
var lastArgs, lastThis, maxWait, result, timerId, lastCallTime, lastInvokeTime = 0, leading = false, maxing = false, trailing = true;
|
|
1165
|
+
if (typeof func != "function") {
|
|
1166
|
+
throw new TypeError(FUNC_ERROR_TEXT$3);
|
|
1036
1167
|
}
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1168
|
+
wait = toNumber(wait) || 0;
|
|
1169
|
+
if (isObject$c(options)) {
|
|
1170
|
+
leading = !!options.leading;
|
|
1171
|
+
maxing = "maxWait" in options;
|
|
1172
|
+
maxWait = maxing ? nativeMax$1(toNumber(options.maxWait) || 0, wait) : maxWait;
|
|
1173
|
+
trailing = "trailing" in options ? !!options.trailing : trailing;
|
|
1042
1174
|
}
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
change(name, value) {
|
|
1050
|
-
return this.finalForm.change(name, value);
|
|
1175
|
+
function invokeFunc(time2) {
|
|
1176
|
+
var args = lastArgs, thisArg = lastThis;
|
|
1177
|
+
lastArgs = lastThis = void 0;
|
|
1178
|
+
lastInvokeTime = time2;
|
|
1179
|
+
result = func.apply(thisArg, args);
|
|
1180
|
+
return result;
|
|
1051
1181
|
}
|
|
1052
|
-
|
|
1053
|
-
|
|
1182
|
+
function leadingEdge(time2) {
|
|
1183
|
+
lastInvokeTime = time2;
|
|
1184
|
+
timerId = setTimeout(timerExpired, wait);
|
|
1185
|
+
return leading ? invokeFunc(time2) : result;
|
|
1054
1186
|
}
|
|
1055
|
-
|
|
1056
|
-
|
|
1187
|
+
function remainingWait(time2) {
|
|
1188
|
+
var timeSinceLastCall = time2 - lastCallTime, timeSinceLastInvoke = time2 - lastInvokeTime, timeWaiting = wait - timeSinceLastCall;
|
|
1189
|
+
return maxing ? nativeMin(timeWaiting, maxWait - timeSinceLastInvoke) : timeWaiting;
|
|
1057
1190
|
}
|
|
1058
|
-
|
|
1059
|
-
|
|
1191
|
+
function shouldInvoke(time2) {
|
|
1192
|
+
var timeSinceLastCall = time2 - lastCallTime, timeSinceLastInvoke = time2 - lastInvokeTime;
|
|
1193
|
+
return lastCallTime === void 0 || timeSinceLastCall >= wait || timeSinceLastCall < 0 || maxing && timeSinceLastInvoke >= maxWait;
|
|
1060
1194
|
}
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
* function will _not_ update the value of any field that is currently
|
|
1068
|
-
* being edited.
|
|
1069
|
-
*
|
|
1070
|
-
* @param values
|
|
1071
|
-
*/
|
|
1072
|
-
updateValues(values) {
|
|
1073
|
-
this.finalForm.batch(() => {
|
|
1074
|
-
const activePath = this.finalForm.getState().active;
|
|
1075
|
-
if (!activePath) {
|
|
1076
|
-
updateEverything(this.finalForm, values);
|
|
1077
|
-
} else {
|
|
1078
|
-
updateSelectively(this.finalForm, values);
|
|
1079
|
-
}
|
|
1080
|
-
});
|
|
1195
|
+
function timerExpired() {
|
|
1196
|
+
var time2 = now();
|
|
1197
|
+
if (shouldInvoke(time2)) {
|
|
1198
|
+
return trailingEdge(time2);
|
|
1199
|
+
}
|
|
1200
|
+
timerId = setTimeout(timerExpired, remainingWait(time2));
|
|
1081
1201
|
}
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
*
|
|
1087
|
-
* @param initialValues
|
|
1088
|
-
*/
|
|
1089
|
-
updateInitialValues(initialValues) {
|
|
1090
|
-
this.finalForm.batch(() => {
|
|
1091
|
-
const values = this.values || {};
|
|
1092
|
-
this.finalForm.initialize(initialValues);
|
|
1093
|
-
const activePath = this.finalForm.getState().active;
|
|
1094
|
-
if (!activePath) {
|
|
1095
|
-
updateEverything(this.finalForm, values);
|
|
1096
|
-
} else {
|
|
1097
|
-
updateSelectively(this.finalForm, values);
|
|
1098
|
-
}
|
|
1099
|
-
});
|
|
1100
|
-
}
|
|
1101
|
-
/**
|
|
1102
|
-
* Based on field's name this function will
|
|
1103
|
-
* return an array of fields for the give form along
|
|
1104
|
-
* with the path that it was found at top nearest
|
|
1105
|
-
* object-like group
|
|
1106
|
-
*
|
|
1107
|
-
* So if you have a field named blocks.3.title
|
|
1108
|
-
* It will return the fields from the 3rd "block"
|
|
1109
|
-
* along with the path it was found at
|
|
1110
|
-
* fields: [{type: 'string', name: 'title'}, ... other fields]
|
|
1111
|
-
* activePath: ['blocks', '3']
|
|
1112
|
-
*/
|
|
1113
|
-
getActiveField(fieldName) {
|
|
1114
|
-
if (!fieldName) {
|
|
1115
|
-
return this;
|
|
1202
|
+
function trailingEdge(time2) {
|
|
1203
|
+
timerId = void 0;
|
|
1204
|
+
if (trailing && lastArgs) {
|
|
1205
|
+
return invokeFunc(time2);
|
|
1116
1206
|
}
|
|
1117
|
-
|
|
1118
|
-
formOrObjectField: this,
|
|
1119
|
-
values: this.finalForm.getState().values,
|
|
1120
|
-
namePathIndex: 0,
|
|
1121
|
-
namePath: fieldName.split(".")
|
|
1122
|
-
});
|
|
1207
|
+
lastArgs = lastThis = void 0;
|
|
1123
1208
|
return result;
|
|
1124
1209
|
}
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
namePathIndex,
|
|
1129
|
-
namePath
|
|
1130
|
-
}) {
|
|
1131
|
-
const name = namePath[namePathIndex];
|
|
1132
|
-
const field = formOrObjectField.fields.find((field2) => field2.name === name);
|
|
1133
|
-
const value = values[name];
|
|
1134
|
-
const isLastItem = namePathIndex === namePath.length - 1;
|
|
1135
|
-
if (!field) {
|
|
1136
|
-
return {
|
|
1137
|
-
...formOrObjectField,
|
|
1138
|
-
fields: formOrObjectField.fields.map((field2) => {
|
|
1139
|
-
return {
|
|
1140
|
-
...field2,
|
|
1141
|
-
name: [...namePath, field2.name].join(".")
|
|
1142
|
-
};
|
|
1143
|
-
})
|
|
1144
|
-
};
|
|
1145
|
-
} else {
|
|
1146
|
-
if (field.type === "object") {
|
|
1147
|
-
if (field.templates) {
|
|
1148
|
-
if (field.list) {
|
|
1149
|
-
if (isLastItem) {
|
|
1150
|
-
return formOrObjectField;
|
|
1151
|
-
} else {
|
|
1152
|
-
const namePathIndexForListItem = namePathIndex + 1;
|
|
1153
|
-
const index = namePath[namePathIndexForListItem];
|
|
1154
|
-
const listItemValue = value[index];
|
|
1155
|
-
const template = field.templates[listItemValue._template];
|
|
1156
|
-
const templateName = [
|
|
1157
|
-
...namePath.slice(0, namePathIndexForListItem),
|
|
1158
|
-
index
|
|
1159
|
-
].join(".");
|
|
1160
|
-
const isLastItem2 = namePathIndexForListItem === namePath.length - 1;
|
|
1161
|
-
if (!isLastItem2) {
|
|
1162
|
-
return this.getFieldGroup({
|
|
1163
|
-
formOrObjectField: template,
|
|
1164
|
-
values: listItemValue,
|
|
1165
|
-
namePath,
|
|
1166
|
-
namePathIndex: namePathIndex + 2
|
|
1167
|
-
});
|
|
1168
|
-
}
|
|
1169
|
-
if (!template) {
|
|
1170
|
-
console.error({ field, value });
|
|
1171
|
-
throw new Error(
|
|
1172
|
-
`Expected template value for field ${field.name}`
|
|
1173
|
-
);
|
|
1174
|
-
}
|
|
1175
|
-
return {
|
|
1176
|
-
...template,
|
|
1177
|
-
name: templateName,
|
|
1178
|
-
fields: template.fields.map((field2) => {
|
|
1179
|
-
return {
|
|
1180
|
-
...field2,
|
|
1181
|
-
name: [templateName, field2.name].join(".")
|
|
1182
|
-
};
|
|
1183
|
-
})
|
|
1184
|
-
};
|
|
1185
|
-
}
|
|
1186
|
-
}
|
|
1187
|
-
} else {
|
|
1188
|
-
if (field.list) {
|
|
1189
|
-
const namePathIndexForListItem = namePathIndex + 1;
|
|
1190
|
-
const index = namePath[namePathIndexForListItem];
|
|
1191
|
-
const listItemValue = value[index];
|
|
1192
|
-
const fieldName = [
|
|
1193
|
-
...namePath.slice(0, namePathIndexForListItem),
|
|
1194
|
-
index
|
|
1195
|
-
].join(".");
|
|
1196
|
-
const isLastItem2 = namePathIndexForListItem === namePath.length - 1;
|
|
1197
|
-
if (!isLastItem2) {
|
|
1198
|
-
if (field.fields) {
|
|
1199
|
-
return this.getFieldGroup({
|
|
1200
|
-
formOrObjectField: field,
|
|
1201
|
-
values: listItemValue,
|
|
1202
|
-
namePath,
|
|
1203
|
-
namePathIndex: namePathIndex + 2
|
|
1204
|
-
});
|
|
1205
|
-
}
|
|
1206
|
-
}
|
|
1207
|
-
return {
|
|
1208
|
-
...field,
|
|
1209
|
-
name: fieldName,
|
|
1210
|
-
fields: field.fields.map((field2) => {
|
|
1211
|
-
return {
|
|
1212
|
-
...field2,
|
|
1213
|
-
name: [fieldName, field2.name].join(".")
|
|
1214
|
-
};
|
|
1215
|
-
})
|
|
1216
|
-
};
|
|
1217
|
-
} else {
|
|
1218
|
-
const fieldName = [...namePath.slice(0, namePathIndex + 1)].join(
|
|
1219
|
-
"."
|
|
1220
|
-
);
|
|
1221
|
-
const isLastItem2 = namePathIndex === namePath.length - 1;
|
|
1222
|
-
if (!isLastItem2) {
|
|
1223
|
-
return this.getFieldGroup({
|
|
1224
|
-
formOrObjectField: field,
|
|
1225
|
-
values: value,
|
|
1226
|
-
namePath,
|
|
1227
|
-
namePathIndex: namePathIndex + 1
|
|
1228
|
-
});
|
|
1229
|
-
}
|
|
1230
|
-
return {
|
|
1231
|
-
...field,
|
|
1232
|
-
name: fieldName,
|
|
1233
|
-
fields: field.fields.map((field2) => {
|
|
1234
|
-
return {
|
|
1235
|
-
...field2,
|
|
1236
|
-
name: [fieldName, field2.name].join(".")
|
|
1237
|
-
};
|
|
1238
|
-
})
|
|
1239
|
-
};
|
|
1240
|
-
}
|
|
1241
|
-
}
|
|
1242
|
-
} else if (field.type === "rich-text") {
|
|
1243
|
-
if (isLastItem) {
|
|
1244
|
-
return {
|
|
1245
|
-
...formOrObjectField,
|
|
1246
|
-
fields: formOrObjectField.fields.map((field2) => {
|
|
1247
|
-
return {
|
|
1248
|
-
...field2,
|
|
1249
|
-
name: [...namePath.slice(0, namePathIndex), field2.name].join(
|
|
1250
|
-
"."
|
|
1251
|
-
)
|
|
1252
|
-
};
|
|
1253
|
-
})
|
|
1254
|
-
};
|
|
1255
|
-
} else {
|
|
1256
|
-
const childrenIndex = namePath.findIndex(
|
|
1257
|
-
(value2) => value2 === "children"
|
|
1258
|
-
);
|
|
1259
|
-
const propsIndex = namePath.slice(childrenIndex).findIndex((value2) => value2 === "props") + childrenIndex;
|
|
1260
|
-
const itemName = namePath.slice(childrenIndex, propsIndex).join(".");
|
|
1261
|
-
const item = getIn(value, itemName);
|
|
1262
|
-
const props = item.props;
|
|
1263
|
-
const templateString = item.name;
|
|
1264
|
-
const currentPathIndex = namePathIndex + Math.max(propsIndex, 3);
|
|
1265
|
-
const isLastItem2 = currentPathIndex + 1 === namePath.length;
|
|
1266
|
-
const template = field.templates.find(
|
|
1267
|
-
(t2) => t2.name === templateString
|
|
1268
|
-
);
|
|
1269
|
-
const templateName = namePath.slice(0, currentPathIndex + 2).join(".");
|
|
1270
|
-
if ((item == null ? void 0 : item.type) === "img") {
|
|
1271
|
-
const imageName = namePath.slice(0, currentPathIndex + 2).join(".");
|
|
1272
|
-
return {
|
|
1273
|
-
...formOrObjectField,
|
|
1274
|
-
// name: [formOrObjectField.name, 'img'].join('.'),
|
|
1275
|
-
name: [imageName].join("."),
|
|
1276
|
-
fields: [
|
|
1277
|
-
{
|
|
1278
|
-
type: "image",
|
|
1279
|
-
// label: 'URL',
|
|
1280
|
-
name: [templateName, "url"].join("."),
|
|
1281
|
-
component: "image"
|
|
1282
|
-
},
|
|
1283
|
-
{
|
|
1284
|
-
type: "string",
|
|
1285
|
-
label: "Alt",
|
|
1286
|
-
name: [templateName.replace(/\.props$/, ""), "alt"].join("."),
|
|
1287
|
-
component: "text"
|
|
1288
|
-
},
|
|
1289
|
-
{
|
|
1290
|
-
type: "string",
|
|
1291
|
-
label: "Caption",
|
|
1292
|
-
name: [templateName.replace(/\.props$/, ""), "caption"].join(
|
|
1293
|
-
"."
|
|
1294
|
-
),
|
|
1295
|
-
component: "text"
|
|
1296
|
-
}
|
|
1297
|
-
]
|
|
1298
|
-
};
|
|
1299
|
-
}
|
|
1300
|
-
if (!isLastItem2) {
|
|
1301
|
-
return this.getFieldGroup({
|
|
1302
|
-
formOrObjectField: template,
|
|
1303
|
-
values: props,
|
|
1304
|
-
namePath,
|
|
1305
|
-
namePathIndex: namePathIndex + Math.max(4, childrenIndex + propsIndex)
|
|
1306
|
-
});
|
|
1307
|
-
}
|
|
1308
|
-
if (!template) {
|
|
1309
|
-
throw new Error(`Expected template value for field ${item.name}`);
|
|
1310
|
-
}
|
|
1311
|
-
return {
|
|
1312
|
-
...template,
|
|
1313
|
-
name: templateName,
|
|
1314
|
-
fields: template.fields.map((field2) => {
|
|
1315
|
-
return {
|
|
1316
|
-
...field2,
|
|
1317
|
-
name: [templateName, field2.name].join(".")
|
|
1318
|
-
};
|
|
1319
|
-
})
|
|
1320
|
-
};
|
|
1321
|
-
}
|
|
1322
|
-
} else {
|
|
1323
|
-
const fieldName = [...namePath.slice(0, namePathIndex)].join(".");
|
|
1324
|
-
if (!fieldName) {
|
|
1325
|
-
return formOrObjectField;
|
|
1326
|
-
}
|
|
1327
|
-
return {
|
|
1328
|
-
...formOrObjectField,
|
|
1329
|
-
name: fieldName,
|
|
1330
|
-
fields: formOrObjectField.fields.map((field2) => {
|
|
1331
|
-
return {
|
|
1332
|
-
...field2,
|
|
1333
|
-
name: [fieldName, field2.name].join(".")
|
|
1334
|
-
};
|
|
1335
|
-
})
|
|
1336
|
-
};
|
|
1337
|
-
}
|
|
1210
|
+
function cancel() {
|
|
1211
|
+
if (timerId !== void 0) {
|
|
1212
|
+
clearTimeout(timerId);
|
|
1338
1213
|
}
|
|
1214
|
+
lastInvokeTime = 0;
|
|
1215
|
+
lastArgs = lastCallTime = lastThis = timerId = void 0;
|
|
1339
1216
|
}
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1217
|
+
function flush() {
|
|
1218
|
+
return timerId === void 0 ? result : trailingEdge(now());
|
|
1219
|
+
}
|
|
1220
|
+
function debounced() {
|
|
1221
|
+
var time2 = now(), isInvoking = shouldInvoke(time2);
|
|
1222
|
+
lastArgs = arguments;
|
|
1223
|
+
lastThis = this;
|
|
1224
|
+
lastCallTime = time2;
|
|
1225
|
+
if (isInvoking) {
|
|
1226
|
+
if (timerId === void 0) {
|
|
1227
|
+
return leadingEdge(lastCallTime);
|
|
1228
|
+
}
|
|
1229
|
+
if (maxing) {
|
|
1230
|
+
clearTimeout(timerId);
|
|
1231
|
+
timerId = setTimeout(timerExpired, wait);
|
|
1232
|
+
return invokeFunc(lastCallTime);
|
|
1355
1233
|
}
|
|
1356
|
-
} else if (path3 !== activePath) {
|
|
1357
|
-
form.change(path3, value);
|
|
1358
1234
|
}
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
let pluginArray;
|
|
1364
|
-
if (Array.isArray(plugins2)) {
|
|
1365
|
-
pluginArray = plugins2;
|
|
1366
|
-
} else {
|
|
1367
|
-
pluginArray = [plugins2];
|
|
1235
|
+
if (timerId === void 0) {
|
|
1236
|
+
timerId = setTimeout(timerExpired, wait);
|
|
1237
|
+
}
|
|
1238
|
+
return result;
|
|
1368
1239
|
}
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
cms.plugins.add(plugin);
|
|
1373
|
-
}
|
|
1374
|
-
});
|
|
1375
|
-
return () => {
|
|
1376
|
-
pluginArray.forEach((plugin) => {
|
|
1377
|
-
if (plugin) {
|
|
1378
|
-
cms.plugins.remove(plugin);
|
|
1379
|
-
}
|
|
1380
|
-
});
|
|
1381
|
-
};
|
|
1382
|
-
}, [cms.plugins, ...pluginArray]);
|
|
1240
|
+
debounced.cancel = cancel;
|
|
1241
|
+
debounced.flush = flush;
|
|
1242
|
+
return debounced;
|
|
1383
1243
|
}
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1244
|
+
var debounce_1 = debounce$1;
|
|
1245
|
+
const debounce$2 = /* @__PURE__ */ getDefaultExportFromCjs(debounce_1);
|
|
1246
|
+
var debounce = debounce_1, isObject$b = isObject_1;
|
|
1247
|
+
var FUNC_ERROR_TEXT$2 = "Expected a function";
|
|
1248
|
+
function throttle(func, wait, options) {
|
|
1249
|
+
var leading = true, trailing = true;
|
|
1250
|
+
if (typeof func != "function") {
|
|
1251
|
+
throw new TypeError(FUNC_ERROR_TEXT$2);
|
|
1252
|
+
}
|
|
1253
|
+
if (isObject$b(options)) {
|
|
1254
|
+
leading = "leading" in options ? !!options.leading : leading;
|
|
1255
|
+
trailing = "trailing" in options ? !!options.trailing : trailing;
|
|
1256
|
+
}
|
|
1257
|
+
return debounce(func, wait, {
|
|
1258
|
+
"leading": leading,
|
|
1259
|
+
"maxWait": wait,
|
|
1260
|
+
"trailing": trailing
|
|
1392
1261
|
});
|
|
1393
1262
|
}
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
}
|
|
1409
|
-
|
|
1410
|
-
);
|
|
1411
|
-
}
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
};
|
|
1430
|
-
}
|
|
1431
|
-
function wrapFieldWithError(Field2) {
|
|
1432
|
-
return (props) => {
|
|
1433
|
-
return /* @__PURE__ */ React.createElement(
|
|
1434
|
-
FieldMeta,
|
|
1435
|
-
{
|
|
1436
|
-
name: props.input.name,
|
|
1437
|
-
label: false,
|
|
1438
|
-
description: props.field.description,
|
|
1439
|
-
error: props.meta.error,
|
|
1440
|
-
index: props.index,
|
|
1441
|
-
tinaForm: props.tinaForm,
|
|
1442
|
-
focusIntent: props.field.focusIntent,
|
|
1443
|
-
hoverIntent: props.field.hoverIntent
|
|
1444
|
-
},
|
|
1445
|
-
/* @__PURE__ */ React.createElement(Field2, { ...props })
|
|
1446
|
-
);
|
|
1447
|
-
};
|
|
1448
|
-
}
|
|
1449
|
-
const FieldMeta = ({
|
|
1450
|
-
name,
|
|
1451
|
-
label,
|
|
1452
|
-
description,
|
|
1453
|
-
error: error2,
|
|
1454
|
-
margin = true,
|
|
1455
|
-
children,
|
|
1456
|
-
index,
|
|
1457
|
-
tinaForm,
|
|
1458
|
-
field,
|
|
1459
|
-
focusIntent,
|
|
1460
|
-
hoverIntent,
|
|
1461
|
-
...props
|
|
1462
|
-
}) => {
|
|
1463
|
-
const cms = useCMS$1();
|
|
1464
|
-
const { dispatch: setHoveredField } = useEvent("field:hover");
|
|
1465
|
-
const { dispatch: setFocusedField } = useEvent("field:focus");
|
|
1466
|
-
const isActive = !!focusIntent;
|
|
1467
|
-
const isHovering = !!hoverIntent;
|
|
1468
|
-
const handleClick = () => {
|
|
1469
|
-
const existingForm = cms.state.forms.find(
|
|
1470
|
-
(form) => form.tinaForm.id === tinaForm.id
|
|
1471
|
-
);
|
|
1472
|
-
const isAlreadyActive = (existingForm == null ? void 0 : existingForm.activeFieldName) === name;
|
|
1473
|
-
if (isAlreadyActive) {
|
|
1474
|
-
return;
|
|
1475
|
-
}
|
|
1476
|
-
setFocusedField({ id: tinaForm.id, fieldName: name });
|
|
1477
|
-
cms.dispatch({
|
|
1478
|
-
type: "forms:set-active-field-name",
|
|
1479
|
-
value: { formId: tinaForm.id, fieldName: name }
|
|
1480
|
-
});
|
|
1481
|
-
};
|
|
1482
|
-
return /* @__PURE__ */ React.createElement(
|
|
1483
|
-
FieldWrapper,
|
|
1484
|
-
{
|
|
1485
|
-
margin,
|
|
1486
|
-
field,
|
|
1487
|
-
onMouseOver: () => setHoveredField({ id: tinaForm.id, fieldName: name }),
|
|
1488
|
-
onMouseOut: () => setHoveredField({ id: null, fieldName: null }),
|
|
1489
|
-
onClick: handleClick,
|
|
1490
|
-
style: { zIndex: index ? 1e3 - index : void 0 },
|
|
1491
|
-
"data-tina-field-active": isActive ? "true" : void 0,
|
|
1492
|
-
"data-tina-field-hovering": isHovering ? "true" : void 0,
|
|
1493
|
-
...props
|
|
1494
|
-
},
|
|
1495
|
-
(label !== false || description) && /* @__PURE__ */ React.createElement(FieldLabel, { name }, label !== false && /* @__PURE__ */ React.createElement(React.Fragment, null, label || name), description && /* @__PURE__ */ React.createElement(FieldDescription, null, description)),
|
|
1496
|
-
children,
|
|
1497
|
-
error2 && typeof error2 === "string" && /* @__PURE__ */ React.createElement(FieldError, null, error2)
|
|
1498
|
-
);
|
|
1499
|
-
};
|
|
1500
|
-
const FieldWrapper = ({
|
|
1501
|
-
margin,
|
|
1502
|
-
children,
|
|
1503
|
-
field,
|
|
1504
|
-
"data-tina-field-active": dataActive,
|
|
1505
|
-
"data-tina-field-hovering": dataHovering,
|
|
1506
|
-
...props
|
|
1507
|
-
}) => {
|
|
1508
|
-
const isActive = dataActive === "true";
|
|
1509
|
-
const isHovering = dataHovering === "true";
|
|
1510
|
-
const getFieldStateClasses = () => {
|
|
1511
|
-
const elements = ["input", "textarea", "select", ".ProseMirror"];
|
|
1512
|
-
const buildClasses = (color) => {
|
|
1513
|
-
return elements.map(
|
|
1514
|
-
(el) => `[&_${el}]:!border-${color} [&_${el}]:!ring-2 [&_${el}]:!ring-${color}/20`
|
|
1515
|
-
).join(" ");
|
|
1516
|
-
};
|
|
1517
|
-
if (isActive) {
|
|
1518
|
-
return buildClasses("tina-orange-dark");
|
|
1263
|
+
var throttle_1 = throttle;
|
|
1264
|
+
const throttle$1 = /* @__PURE__ */ getDefaultExportFromCjs(throttle_1);
|
|
1265
|
+
const t$2 = (t2) => "object" == typeof t2 && null != t2 && 1 === t2.nodeType, e$3 = (t2, e3) => (!e3 || "hidden" !== t2) && ("visible" !== t2 && "clip" !== t2), n$3 = (t2, n2) => {
|
|
1266
|
+
if (t2.clientHeight < t2.scrollHeight || t2.clientWidth < t2.scrollWidth) {
|
|
1267
|
+
const o3 = getComputedStyle(t2, null);
|
|
1268
|
+
return e$3(o3.overflowY, n2) || e$3(o3.overflowX, n2) || ((t3) => {
|
|
1269
|
+
const e3 = ((t4) => {
|
|
1270
|
+
if (!t4.ownerDocument || !t4.ownerDocument.defaultView)
|
|
1271
|
+
return null;
|
|
1272
|
+
try {
|
|
1273
|
+
return t4.ownerDocument.defaultView.frameElement;
|
|
1274
|
+
} catch (t5) {
|
|
1275
|
+
return null;
|
|
1276
|
+
}
|
|
1277
|
+
})(t3);
|
|
1278
|
+
return !!e3 && (e3.clientHeight < t3.scrollHeight || e3.clientWidth < t3.scrollWidth);
|
|
1279
|
+
})(t2);
|
|
1280
|
+
}
|
|
1281
|
+
return false;
|
|
1282
|
+
}, o$3 = (t2, e3, n2, o3, l2, r2, i2, s2) => r2 < t2 && i2 > e3 || r2 > t2 && i2 < e3 ? 0 : r2 <= t2 && s2 <= n2 || i2 >= e3 && s2 >= n2 ? r2 - t2 - o3 : i2 > e3 && s2 < n2 || r2 < t2 && s2 > n2 ? i2 - e3 + l2 : 0, l$2 = (t2) => {
|
|
1283
|
+
const e3 = t2.parentElement;
|
|
1284
|
+
return null == e3 ? t2.getRootNode().host || null : e3;
|
|
1285
|
+
}, r$3 = (e3, r2) => {
|
|
1286
|
+
var i2, s2, d2, h;
|
|
1287
|
+
if ("undefined" == typeof document)
|
|
1288
|
+
return [];
|
|
1289
|
+
const { scrollMode: c2, block: f2, inline: u2, boundary: a2, skipOverflowHiddenElements: g } = r2, p2 = "function" == typeof a2 ? a2 : (t2) => t2 !== a2;
|
|
1290
|
+
if (!t$2(e3))
|
|
1291
|
+
throw new TypeError("Invalid target");
|
|
1292
|
+
const m = document.scrollingElement || document.documentElement, w2 = [];
|
|
1293
|
+
let W = e3;
|
|
1294
|
+
for (; t$2(W) && p2(W); ) {
|
|
1295
|
+
if (W = l$2(W), W === m) {
|
|
1296
|
+
w2.push(W);
|
|
1297
|
+
break;
|
|
1519
1298
|
}
|
|
1520
|
-
|
|
1521
|
-
|
|
1299
|
+
null != W && W === document.body && n$3(W) && !n$3(document.documentElement) || null != W && n$3(W, g) && w2.push(W);
|
|
1300
|
+
}
|
|
1301
|
+
const b = null != (s2 = null == (i2 = window.visualViewport) ? void 0 : i2.width) ? s2 : innerWidth, H = null != (h = null == (d2 = window.visualViewport) ? void 0 : d2.height) ? h : innerHeight, { scrollX: y, scrollY: M } = window, { height: v, width: E, top: x, right: C, bottom: I, left: R } = e3.getBoundingClientRect(), { top: T, right: B, bottom: F, left: V } = ((t2) => {
|
|
1302
|
+
const e4 = window.getComputedStyle(t2);
|
|
1303
|
+
return { top: parseFloat(e4.scrollMarginTop) || 0, right: parseFloat(e4.scrollMarginRight) || 0, bottom: parseFloat(e4.scrollMarginBottom) || 0, left: parseFloat(e4.scrollMarginLeft) || 0 };
|
|
1304
|
+
})(e3);
|
|
1305
|
+
let k = "start" === f2 || "nearest" === f2 ? x - T : "end" === f2 ? I + F : x + v / 2 - T + F, D = "center" === u2 ? R + E / 2 - V + B : "end" === u2 ? C + B : R - V;
|
|
1306
|
+
const L = [];
|
|
1307
|
+
for (let t2 = 0; t2 < w2.length; t2++) {
|
|
1308
|
+
const e4 = w2[t2], { height: l2, width: r3, top: i3, right: s3, bottom: d3, left: h2 } = e4.getBoundingClientRect();
|
|
1309
|
+
if ("if-needed" === c2 && x >= 0 && R >= 0 && I <= H && C <= b && (e4 === m && !n$3(e4) || x >= i3 && I <= d3 && R >= h2 && C <= s3))
|
|
1310
|
+
return L;
|
|
1311
|
+
const a3 = getComputedStyle(e4), g2 = parseInt(a3.borderLeftWidth, 10), p3 = parseInt(a3.borderTopWidth, 10), W2 = parseInt(a3.borderRightWidth, 10), T2 = parseInt(a3.borderBottomWidth, 10);
|
|
1312
|
+
let B2 = 0, F2 = 0;
|
|
1313
|
+
const V2 = "offsetWidth" in e4 ? e4.offsetWidth - e4.clientWidth - g2 - W2 : 0, S = "offsetHeight" in e4 ? e4.offsetHeight - e4.clientHeight - p3 - T2 : 0, X2 = "offsetWidth" in e4 ? 0 === e4.offsetWidth ? 0 : r3 / e4.offsetWidth : 0, Y = "offsetHeight" in e4 ? 0 === e4.offsetHeight ? 0 : l2 / e4.offsetHeight : 0;
|
|
1314
|
+
if (m === e4)
|
|
1315
|
+
B2 = "start" === f2 ? k : "end" === f2 ? k - H : "nearest" === f2 ? o$3(M, M + H, H, p3, T2, M + k, M + k + v, v) : k - H / 2, F2 = "start" === u2 ? D : "center" === u2 ? D - b / 2 : "end" === u2 ? D - b : o$3(y, y + b, b, g2, W2, y + D, y + D + E, E), B2 = Math.max(0, B2 + M), F2 = Math.max(0, F2 + y);
|
|
1316
|
+
else {
|
|
1317
|
+
B2 = "start" === f2 ? k - i3 - p3 : "end" === f2 ? k - d3 + T2 + S : "nearest" === f2 ? o$3(i3, d3, l2, p3, T2 + S, k, k + v, v) : k - (i3 + l2 / 2) + S / 2, F2 = "start" === u2 ? D - h2 - g2 : "center" === u2 ? D - (h2 + r3 / 2) + V2 / 2 : "end" === u2 ? D - s3 + W2 + V2 : o$3(h2, s3, r3, g2, W2 + V2, D, D + E, E);
|
|
1318
|
+
const { scrollLeft: t3, scrollTop: n2 } = e4;
|
|
1319
|
+
B2 = 0 === Y ? 0 : Math.max(0, Math.min(n2 + B2 / Y, e4.scrollHeight - l2 / Y + S)), F2 = 0 === X2 ? 0 : Math.max(0, Math.min(t3 + F2 / X2, e4.scrollWidth - r3 / X2 + V2)), k += n2 - B2, D += t3 - F2;
|
|
1522
1320
|
}
|
|
1523
|
-
|
|
1524
|
-
}
|
|
1525
|
-
return
|
|
1526
|
-
"div",
|
|
1527
|
-
{
|
|
1528
|
-
className: `relative w-full px-2 ${margin ? "mb-5 last:mb-0" : ""} ${(field == null ? void 0 : field.width) === "half" ? "@sm:w-1/2" : ""} ${getFieldStateClasses()}`,
|
|
1529
|
-
"data-tina-field-active": dataActive,
|
|
1530
|
-
"data-tina-field-hovering": dataHovering,
|
|
1531
|
-
...props
|
|
1532
|
-
},
|
|
1533
|
-
children
|
|
1534
|
-
);
|
|
1535
|
-
};
|
|
1536
|
-
const FieldLabel = ({
|
|
1537
|
-
children,
|
|
1538
|
-
className,
|
|
1539
|
-
name,
|
|
1540
|
-
...props
|
|
1541
|
-
}) => {
|
|
1542
|
-
return /* @__PURE__ */ React.createElement(
|
|
1543
|
-
"label",
|
|
1544
|
-
{
|
|
1545
|
-
htmlFor: name,
|
|
1546
|
-
className: `block font-sans text-xs font-semibold text-gray-700 whitespace-normal mb-2 ${className}`,
|
|
1547
|
-
...props
|
|
1548
|
-
},
|
|
1549
|
-
children
|
|
1550
|
-
);
|
|
1551
|
-
};
|
|
1552
|
-
const FieldDescription = ({
|
|
1553
|
-
children,
|
|
1554
|
-
className,
|
|
1555
|
-
...props
|
|
1556
|
-
}) => {
|
|
1557
|
-
if (typeof children === "string") {
|
|
1558
|
-
return /* @__PURE__ */ React.createElement(
|
|
1559
|
-
"span",
|
|
1560
|
-
{
|
|
1561
|
-
className: `block font-sans text-xs italic font-light text-gray-400 pt-0.5 whitespace-normal m-0 ${className}`,
|
|
1562
|
-
...props,
|
|
1563
|
-
dangerouslySetInnerHTML: { __html: children }
|
|
1564
|
-
}
|
|
1565
|
-
);
|
|
1566
|
-
}
|
|
1567
|
-
return /* @__PURE__ */ React.createElement(
|
|
1568
|
-
"span",
|
|
1569
|
-
{
|
|
1570
|
-
className: `block font-sans text-xs italic font-light text-gray-400 pt-0.5 whitespace-normal m-0 ${className}`,
|
|
1571
|
-
...props
|
|
1572
|
-
},
|
|
1573
|
-
children
|
|
1574
|
-
);
|
|
1575
|
-
};
|
|
1576
|
-
const FieldError = ({
|
|
1577
|
-
children,
|
|
1578
|
-
className,
|
|
1579
|
-
...props
|
|
1580
|
-
}) => {
|
|
1581
|
-
return /* @__PURE__ */ React.createElement(
|
|
1582
|
-
"span",
|
|
1583
|
-
{
|
|
1584
|
-
className: `block font-sans text-xs font-normal text-red-500 pt-3 animate-slide-in whitespace-normal m-0 ${className}`,
|
|
1585
|
-
...props
|
|
1586
|
-
},
|
|
1587
|
-
children
|
|
1588
|
-
);
|
|
1589
|
-
};
|
|
1590
|
-
const EditorContext$1 = React__default.createContext({
|
|
1591
|
-
fieldName: "",
|
|
1592
|
-
rawMode: false,
|
|
1593
|
-
setRawMode: () => {
|
|
1594
|
-
},
|
|
1595
|
-
templates: []
|
|
1596
|
-
});
|
|
1597
|
-
const useEditorContext = () => {
|
|
1598
|
-
return React__default.useContext(EditorContext$1);
|
|
1599
|
-
};
|
|
1600
|
-
const useTemplates = () => {
|
|
1601
|
-
return React__default.useContext(EditorContext$1);
|
|
1602
|
-
};
|
|
1603
|
-
var commonjsGlobal = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : {};
|
|
1604
|
-
function getDefaultExportFromCjs(x) {
|
|
1605
|
-
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x;
|
|
1606
|
-
}
|
|
1607
|
-
var direction_1 = direction;
|
|
1608
|
-
var RTL = "֑-߿יִ-﷽ﹰ-ﻼ";
|
|
1609
|
-
var LTR = "A-Za-zÀ-ÖØ-öø-ʸ̀-ࠀ-Ⰰ-︀--";
|
|
1610
|
-
var rtl = new RegExp("^[^" + LTR + "]*[" + RTL + "]");
|
|
1611
|
-
var ltr = new RegExp("^[^" + RTL + "]*[" + LTR + "]");
|
|
1612
|
-
function direction(value) {
|
|
1613
|
-
value = String(value || "");
|
|
1614
|
-
if (rtl.test(value)) {
|
|
1615
|
-
return "rtl";
|
|
1616
|
-
}
|
|
1617
|
-
if (ltr.test(value)) {
|
|
1618
|
-
return "ltr";
|
|
1619
|
-
}
|
|
1620
|
-
return "neutral";
|
|
1621
|
-
}
|
|
1622
|
-
const getDirection = /* @__PURE__ */ getDefaultExportFromCjs(direction_1);
|
|
1623
|
-
function isObject$e(value) {
|
|
1624
|
-
var type = typeof value;
|
|
1625
|
-
return value != null && (type == "object" || type == "function");
|
|
1626
|
-
}
|
|
1627
|
-
var isObject_1 = isObject$e;
|
|
1628
|
-
var freeGlobal$1 = typeof commonjsGlobal == "object" && commonjsGlobal && commonjsGlobal.Object === Object && commonjsGlobal;
|
|
1629
|
-
var _freeGlobal = freeGlobal$1;
|
|
1630
|
-
var freeGlobal = _freeGlobal;
|
|
1631
|
-
var freeSelf = typeof self == "object" && self && self.Object === Object && self;
|
|
1632
|
-
var root$9 = freeGlobal || freeSelf || Function("return this")();
|
|
1633
|
-
var _root = root$9;
|
|
1634
|
-
var root$8 = _root;
|
|
1635
|
-
var now$1 = function() {
|
|
1636
|
-
return root$8.Date.now();
|
|
1637
|
-
};
|
|
1638
|
-
var now_1 = now$1;
|
|
1639
|
-
var reWhitespace = /\s/;
|
|
1640
|
-
function trimmedEndIndex$1(string3) {
|
|
1641
|
-
var index = string3.length;
|
|
1642
|
-
while (index-- && reWhitespace.test(string3.charAt(index))) {
|
|
1643
|
-
}
|
|
1644
|
-
return index;
|
|
1645
|
-
}
|
|
1646
|
-
var _trimmedEndIndex = trimmedEndIndex$1;
|
|
1647
|
-
var trimmedEndIndex = _trimmedEndIndex;
|
|
1648
|
-
var reTrimStart = /^\s+/;
|
|
1649
|
-
function baseTrim$1(string3) {
|
|
1650
|
-
return string3 ? string3.slice(0, trimmedEndIndex(string3) + 1).replace(reTrimStart, "") : string3;
|
|
1651
|
-
}
|
|
1652
|
-
var _baseTrim = baseTrim$1;
|
|
1653
|
-
var root$7 = _root;
|
|
1654
|
-
var Symbol$7 = root$7.Symbol;
|
|
1655
|
-
var _Symbol = Symbol$7;
|
|
1656
|
-
var Symbol$6 = _Symbol;
|
|
1657
|
-
var objectProto$f = Object.prototype;
|
|
1658
|
-
var hasOwnProperty$c = objectProto$f.hasOwnProperty;
|
|
1659
|
-
var nativeObjectToString$1 = objectProto$f.toString;
|
|
1660
|
-
var symToStringTag$1 = Symbol$6 ? Symbol$6.toStringTag : void 0;
|
|
1661
|
-
function getRawTag$1(value) {
|
|
1662
|
-
var isOwn = hasOwnProperty$c.call(value, symToStringTag$1), tag = value[symToStringTag$1];
|
|
1663
|
-
try {
|
|
1664
|
-
value[symToStringTag$1] = void 0;
|
|
1665
|
-
var unmasked = true;
|
|
1666
|
-
} catch (e3) {
|
|
1667
|
-
}
|
|
1668
|
-
var result = nativeObjectToString$1.call(value);
|
|
1669
|
-
if (unmasked) {
|
|
1670
|
-
if (isOwn) {
|
|
1671
|
-
value[symToStringTag$1] = tag;
|
|
1672
|
-
} else {
|
|
1673
|
-
delete value[symToStringTag$1];
|
|
1674
|
-
}
|
|
1675
|
-
}
|
|
1676
|
-
return result;
|
|
1677
|
-
}
|
|
1678
|
-
var _getRawTag = getRawTag$1;
|
|
1679
|
-
var objectProto$e = Object.prototype;
|
|
1680
|
-
var nativeObjectToString = objectProto$e.toString;
|
|
1681
|
-
function objectToString$1(value) {
|
|
1682
|
-
return nativeObjectToString.call(value);
|
|
1683
|
-
}
|
|
1684
|
-
var _objectToString = objectToString$1;
|
|
1685
|
-
var Symbol$5 = _Symbol, getRawTag = _getRawTag, objectToString = _objectToString;
|
|
1686
|
-
var nullTag = "[object Null]", undefinedTag = "[object Undefined]";
|
|
1687
|
-
var symToStringTag = Symbol$5 ? Symbol$5.toStringTag : void 0;
|
|
1688
|
-
function baseGetTag$6(value) {
|
|
1689
|
-
if (value == null) {
|
|
1690
|
-
return value === void 0 ? undefinedTag : nullTag;
|
|
1691
|
-
}
|
|
1692
|
-
return symToStringTag && symToStringTag in Object(value) ? getRawTag(value) : objectToString(value);
|
|
1693
|
-
}
|
|
1694
|
-
var _baseGetTag = baseGetTag$6;
|
|
1695
|
-
function isObjectLike$9(value) {
|
|
1696
|
-
return value != null && typeof value == "object";
|
|
1697
|
-
}
|
|
1698
|
-
var isObjectLike_1 = isObjectLike$9;
|
|
1699
|
-
var baseGetTag$5 = _baseGetTag, isObjectLike$8 = isObjectLike_1;
|
|
1700
|
-
var symbolTag$3 = "[object Symbol]";
|
|
1701
|
-
function isSymbol$4(value) {
|
|
1702
|
-
return typeof value == "symbol" || isObjectLike$8(value) && baseGetTag$5(value) == symbolTag$3;
|
|
1703
|
-
}
|
|
1704
|
-
var isSymbol_1 = isSymbol$4;
|
|
1705
|
-
var baseTrim = _baseTrim, isObject$d = isObject_1, isSymbol$3 = isSymbol_1;
|
|
1706
|
-
var NAN = 0 / 0;
|
|
1707
|
-
var reIsBadHex = /^[-+]0x[0-9a-f]+$/i;
|
|
1708
|
-
var reIsBinary = /^0b[01]+$/i;
|
|
1709
|
-
var reIsOctal = /^0o[0-7]+$/i;
|
|
1710
|
-
var freeParseInt = parseInt;
|
|
1711
|
-
function toNumber$1(value) {
|
|
1712
|
-
if (typeof value == "number") {
|
|
1713
|
-
return value;
|
|
1714
|
-
}
|
|
1715
|
-
if (isSymbol$3(value)) {
|
|
1716
|
-
return NAN;
|
|
1717
|
-
}
|
|
1718
|
-
if (isObject$d(value)) {
|
|
1719
|
-
var other = typeof value.valueOf == "function" ? value.valueOf() : value;
|
|
1720
|
-
value = isObject$d(other) ? other + "" : other;
|
|
1721
|
-
}
|
|
1722
|
-
if (typeof value != "string") {
|
|
1723
|
-
return value === 0 ? value : +value;
|
|
1724
|
-
}
|
|
1725
|
-
value = baseTrim(value);
|
|
1726
|
-
var isBinary = reIsBinary.test(value);
|
|
1727
|
-
return isBinary || reIsOctal.test(value) ? freeParseInt(value.slice(2), isBinary ? 2 : 8) : reIsBadHex.test(value) ? NAN : +value;
|
|
1728
|
-
}
|
|
1729
|
-
var toNumber_1 = toNumber$1;
|
|
1730
|
-
var isObject$c = isObject_1, now = now_1, toNumber = toNumber_1;
|
|
1731
|
-
var FUNC_ERROR_TEXT$3 = "Expected a function";
|
|
1732
|
-
var nativeMax$1 = Math.max, nativeMin = Math.min;
|
|
1733
|
-
function debounce$1(func, wait, options) {
|
|
1734
|
-
var lastArgs, lastThis, maxWait, result, timerId, lastCallTime, lastInvokeTime = 0, leading = false, maxing = false, trailing = true;
|
|
1735
|
-
if (typeof func != "function") {
|
|
1736
|
-
throw new TypeError(FUNC_ERROR_TEXT$3);
|
|
1737
|
-
}
|
|
1738
|
-
wait = toNumber(wait) || 0;
|
|
1739
|
-
if (isObject$c(options)) {
|
|
1740
|
-
leading = !!options.leading;
|
|
1741
|
-
maxing = "maxWait" in options;
|
|
1742
|
-
maxWait = maxing ? nativeMax$1(toNumber(options.maxWait) || 0, wait) : maxWait;
|
|
1743
|
-
trailing = "trailing" in options ? !!options.trailing : trailing;
|
|
1744
|
-
}
|
|
1745
|
-
function invokeFunc(time2) {
|
|
1746
|
-
var args = lastArgs, thisArg = lastThis;
|
|
1747
|
-
lastArgs = lastThis = void 0;
|
|
1748
|
-
lastInvokeTime = time2;
|
|
1749
|
-
result = func.apply(thisArg, args);
|
|
1750
|
-
return result;
|
|
1751
|
-
}
|
|
1752
|
-
function leadingEdge(time2) {
|
|
1753
|
-
lastInvokeTime = time2;
|
|
1754
|
-
timerId = setTimeout(timerExpired, wait);
|
|
1755
|
-
return leading ? invokeFunc(time2) : result;
|
|
1756
|
-
}
|
|
1757
|
-
function remainingWait(time2) {
|
|
1758
|
-
var timeSinceLastCall = time2 - lastCallTime, timeSinceLastInvoke = time2 - lastInvokeTime, timeWaiting = wait - timeSinceLastCall;
|
|
1759
|
-
return maxing ? nativeMin(timeWaiting, maxWait - timeSinceLastInvoke) : timeWaiting;
|
|
1760
|
-
}
|
|
1761
|
-
function shouldInvoke(time2) {
|
|
1762
|
-
var timeSinceLastCall = time2 - lastCallTime, timeSinceLastInvoke = time2 - lastInvokeTime;
|
|
1763
|
-
return lastCallTime === void 0 || timeSinceLastCall >= wait || timeSinceLastCall < 0 || maxing && timeSinceLastInvoke >= maxWait;
|
|
1764
|
-
}
|
|
1765
|
-
function timerExpired() {
|
|
1766
|
-
var time2 = now();
|
|
1767
|
-
if (shouldInvoke(time2)) {
|
|
1768
|
-
return trailingEdge(time2);
|
|
1769
|
-
}
|
|
1770
|
-
timerId = setTimeout(timerExpired, remainingWait(time2));
|
|
1771
|
-
}
|
|
1772
|
-
function trailingEdge(time2) {
|
|
1773
|
-
timerId = void 0;
|
|
1774
|
-
if (trailing && lastArgs) {
|
|
1775
|
-
return invokeFunc(time2);
|
|
1776
|
-
}
|
|
1777
|
-
lastArgs = lastThis = void 0;
|
|
1778
|
-
return result;
|
|
1779
|
-
}
|
|
1780
|
-
function cancel() {
|
|
1781
|
-
if (timerId !== void 0) {
|
|
1782
|
-
clearTimeout(timerId);
|
|
1783
|
-
}
|
|
1784
|
-
lastInvokeTime = 0;
|
|
1785
|
-
lastArgs = lastCallTime = lastThis = timerId = void 0;
|
|
1786
|
-
}
|
|
1787
|
-
function flush() {
|
|
1788
|
-
return timerId === void 0 ? result : trailingEdge(now());
|
|
1789
|
-
}
|
|
1790
|
-
function debounced() {
|
|
1791
|
-
var time2 = now(), isInvoking = shouldInvoke(time2);
|
|
1792
|
-
lastArgs = arguments;
|
|
1793
|
-
lastThis = this;
|
|
1794
|
-
lastCallTime = time2;
|
|
1795
|
-
if (isInvoking) {
|
|
1796
|
-
if (timerId === void 0) {
|
|
1797
|
-
return leadingEdge(lastCallTime);
|
|
1798
|
-
}
|
|
1799
|
-
if (maxing) {
|
|
1800
|
-
clearTimeout(timerId);
|
|
1801
|
-
timerId = setTimeout(timerExpired, wait);
|
|
1802
|
-
return invokeFunc(lastCallTime);
|
|
1803
|
-
}
|
|
1804
|
-
}
|
|
1805
|
-
if (timerId === void 0) {
|
|
1806
|
-
timerId = setTimeout(timerExpired, wait);
|
|
1807
|
-
}
|
|
1808
|
-
return result;
|
|
1809
|
-
}
|
|
1810
|
-
debounced.cancel = cancel;
|
|
1811
|
-
debounced.flush = flush;
|
|
1812
|
-
return debounced;
|
|
1813
|
-
}
|
|
1814
|
-
var debounce_1 = debounce$1;
|
|
1815
|
-
const debounce$2 = /* @__PURE__ */ getDefaultExportFromCjs(debounce_1);
|
|
1816
|
-
var debounce = debounce_1, isObject$b = isObject_1;
|
|
1817
|
-
var FUNC_ERROR_TEXT$2 = "Expected a function";
|
|
1818
|
-
function throttle(func, wait, options) {
|
|
1819
|
-
var leading = true, trailing = true;
|
|
1820
|
-
if (typeof func != "function") {
|
|
1821
|
-
throw new TypeError(FUNC_ERROR_TEXT$2);
|
|
1822
|
-
}
|
|
1823
|
-
if (isObject$b(options)) {
|
|
1824
|
-
leading = "leading" in options ? !!options.leading : leading;
|
|
1825
|
-
trailing = "trailing" in options ? !!options.trailing : trailing;
|
|
1826
|
-
}
|
|
1827
|
-
return debounce(func, wait, {
|
|
1828
|
-
"leading": leading,
|
|
1829
|
-
"maxWait": wait,
|
|
1830
|
-
"trailing": trailing
|
|
1831
|
-
});
|
|
1832
|
-
}
|
|
1833
|
-
var throttle_1 = throttle;
|
|
1834
|
-
const throttle$1 = /* @__PURE__ */ getDefaultExportFromCjs(throttle_1);
|
|
1835
|
-
const t$2 = (t2) => "object" == typeof t2 && null != t2 && 1 === t2.nodeType, e$3 = (t2, e3) => (!e3 || "hidden" !== t2) && ("visible" !== t2 && "clip" !== t2), n$3 = (t2, n2) => {
|
|
1836
|
-
if (t2.clientHeight < t2.scrollHeight || t2.clientWidth < t2.scrollWidth) {
|
|
1837
|
-
const o3 = getComputedStyle(t2, null);
|
|
1838
|
-
return e$3(o3.overflowY, n2) || e$3(o3.overflowX, n2) || ((t3) => {
|
|
1839
|
-
const e3 = ((t4) => {
|
|
1840
|
-
if (!t4.ownerDocument || !t4.ownerDocument.defaultView)
|
|
1841
|
-
return null;
|
|
1842
|
-
try {
|
|
1843
|
-
return t4.ownerDocument.defaultView.frameElement;
|
|
1844
|
-
} catch (t5) {
|
|
1845
|
-
return null;
|
|
1846
|
-
}
|
|
1847
|
-
})(t3);
|
|
1848
|
-
return !!e3 && (e3.clientHeight < t3.scrollHeight || e3.clientWidth < t3.scrollWidth);
|
|
1849
|
-
})(t2);
|
|
1850
|
-
}
|
|
1851
|
-
return false;
|
|
1852
|
-
}, o$3 = (t2, e3, n2, o3, l2, r2, i2, s2) => r2 < t2 && i2 > e3 || r2 > t2 && i2 < e3 ? 0 : r2 <= t2 && s2 <= n2 || i2 >= e3 && s2 >= n2 ? r2 - t2 - o3 : i2 > e3 && s2 < n2 || r2 < t2 && s2 > n2 ? i2 - e3 + l2 : 0, l$2 = (t2) => {
|
|
1853
|
-
const e3 = t2.parentElement;
|
|
1854
|
-
return null == e3 ? t2.getRootNode().host || null : e3;
|
|
1855
|
-
}, r$3 = (e3, r2) => {
|
|
1856
|
-
var i2, s2, d2, h;
|
|
1857
|
-
if ("undefined" == typeof document)
|
|
1858
|
-
return [];
|
|
1859
|
-
const { scrollMode: c2, block: f2, inline: u2, boundary: a2, skipOverflowHiddenElements: g } = r2, p2 = "function" == typeof a2 ? a2 : (t2) => t2 !== a2;
|
|
1860
|
-
if (!t$2(e3))
|
|
1861
|
-
throw new TypeError("Invalid target");
|
|
1862
|
-
const m = document.scrollingElement || document.documentElement, w2 = [];
|
|
1863
|
-
let W = e3;
|
|
1864
|
-
for (; t$2(W) && p2(W); ) {
|
|
1865
|
-
if (W = l$2(W), W === m) {
|
|
1866
|
-
w2.push(W);
|
|
1867
|
-
break;
|
|
1868
|
-
}
|
|
1869
|
-
null != W && W === document.body && n$3(W) && !n$3(document.documentElement) || null != W && n$3(W, g) && w2.push(W);
|
|
1870
|
-
}
|
|
1871
|
-
const b = null != (s2 = null == (i2 = window.visualViewport) ? void 0 : i2.width) ? s2 : innerWidth, H = null != (h = null == (d2 = window.visualViewport) ? void 0 : d2.height) ? h : innerHeight, { scrollX: y, scrollY: M } = window, { height: v, width: E, top: x, right: C, bottom: I, left: R } = e3.getBoundingClientRect(), { top: T, right: B, bottom: F, left: V } = ((t2) => {
|
|
1872
|
-
const e4 = window.getComputedStyle(t2);
|
|
1873
|
-
return { top: parseFloat(e4.scrollMarginTop) || 0, right: parseFloat(e4.scrollMarginRight) || 0, bottom: parseFloat(e4.scrollMarginBottom) || 0, left: parseFloat(e4.scrollMarginLeft) || 0 };
|
|
1874
|
-
})(e3);
|
|
1875
|
-
let k = "start" === f2 || "nearest" === f2 ? x - T : "end" === f2 ? I + F : x + v / 2 - T + F, D = "center" === u2 ? R + E / 2 - V + B : "end" === u2 ? C + B : R - V;
|
|
1876
|
-
const L = [];
|
|
1877
|
-
for (let t2 = 0; t2 < w2.length; t2++) {
|
|
1878
|
-
const e4 = w2[t2], { height: l2, width: r3, top: i3, right: s3, bottom: d3, left: h2 } = e4.getBoundingClientRect();
|
|
1879
|
-
if ("if-needed" === c2 && x >= 0 && R >= 0 && I <= H && C <= b && (e4 === m && !n$3(e4) || x >= i3 && I <= d3 && R >= h2 && C <= s3))
|
|
1880
|
-
return L;
|
|
1881
|
-
const a3 = getComputedStyle(e4), g2 = parseInt(a3.borderLeftWidth, 10), p3 = parseInt(a3.borderTopWidth, 10), W2 = parseInt(a3.borderRightWidth, 10), T2 = parseInt(a3.borderBottomWidth, 10);
|
|
1882
|
-
let B2 = 0, F2 = 0;
|
|
1883
|
-
const V2 = "offsetWidth" in e4 ? e4.offsetWidth - e4.clientWidth - g2 - W2 : 0, S = "offsetHeight" in e4 ? e4.offsetHeight - e4.clientHeight - p3 - T2 : 0, X2 = "offsetWidth" in e4 ? 0 === e4.offsetWidth ? 0 : r3 / e4.offsetWidth : 0, Y = "offsetHeight" in e4 ? 0 === e4.offsetHeight ? 0 : l2 / e4.offsetHeight : 0;
|
|
1884
|
-
if (m === e4)
|
|
1885
|
-
B2 = "start" === f2 ? k : "end" === f2 ? k - H : "nearest" === f2 ? o$3(M, M + H, H, p3, T2, M + k, M + k + v, v) : k - H / 2, F2 = "start" === u2 ? D : "center" === u2 ? D - b / 2 : "end" === u2 ? D - b : o$3(y, y + b, b, g2, W2, y + D, y + D + E, E), B2 = Math.max(0, B2 + M), F2 = Math.max(0, F2 + y);
|
|
1886
|
-
else {
|
|
1887
|
-
B2 = "start" === f2 ? k - i3 - p3 : "end" === f2 ? k - d3 + T2 + S : "nearest" === f2 ? o$3(i3, d3, l2, p3, T2 + S, k, k + v, v) : k - (i3 + l2 / 2) + S / 2, F2 = "start" === u2 ? D - h2 - g2 : "center" === u2 ? D - (h2 + r3 / 2) + V2 / 2 : "end" === u2 ? D - s3 + W2 + V2 : o$3(h2, s3, r3, g2, W2 + V2, D, D + E, E);
|
|
1888
|
-
const { scrollLeft: t3, scrollTop: n2 } = e4;
|
|
1889
|
-
B2 = 0 === Y ? 0 : Math.max(0, Math.min(n2 + B2 / Y, e4.scrollHeight - l2 / Y + S)), F2 = 0 === X2 ? 0 : Math.max(0, Math.min(t3 + F2 / X2, e4.scrollWidth - r3 / X2 + V2)), k += n2 - B2, D += t3 - F2;
|
|
1890
|
-
}
|
|
1891
|
-
L.push({ el: e4, top: B2, left: F2 });
|
|
1892
|
-
}
|
|
1893
|
-
return L;
|
|
1321
|
+
L.push({ el: e4, top: B2, left: F2 });
|
|
1322
|
+
}
|
|
1323
|
+
return L;
|
|
1894
1324
|
};
|
|
1895
1325
|
const o$2 = (t2) => false === t2 ? { block: "end", inline: "nearest" } : ((t3) => t3 === Object(t3) && 0 !== Object.keys(t3).length)(t2) ? t2 : { block: "start", inline: "nearest" };
|
|
1896
1326
|
function e$2(e3, r2) {
|
|
@@ -1995,21 +1425,29 @@ function isDraftable$1(value) {
|
|
|
1995
1425
|
return isPlainObject$4(value) || Array.isArray(value) || !!value[DRAFTABLE] || !!((_a2 = value.constructor) == null ? void 0 : _a2[DRAFTABLE]) || isMap$2(value) || isSet$2(value);
|
|
1996
1426
|
}
|
|
1997
1427
|
var objectCtorString$1 = Object.prototype.constructor.toString();
|
|
1428
|
+
var cachedCtorStrings = /* @__PURE__ */ new WeakMap();
|
|
1998
1429
|
function isPlainObject$4(value) {
|
|
1999
1430
|
if (!value || typeof value !== "object")
|
|
2000
1431
|
return false;
|
|
2001
|
-
const proto = getPrototypeOf(value);
|
|
2002
|
-
if (proto === null)
|
|
1432
|
+
const proto = Object.getPrototypeOf(value);
|
|
1433
|
+
if (proto === null || proto === Object.prototype)
|
|
2003
1434
|
return true;
|
|
2004
|
-
}
|
|
2005
1435
|
const Ctor = Object.hasOwnProperty.call(proto, "constructor") && proto.constructor;
|
|
2006
1436
|
if (Ctor === Object)
|
|
2007
1437
|
return true;
|
|
2008
|
-
|
|
1438
|
+
if (typeof Ctor !== "function")
|
|
1439
|
+
return false;
|
|
1440
|
+
let ctorString = cachedCtorStrings.get(Ctor);
|
|
1441
|
+
if (ctorString === void 0) {
|
|
1442
|
+
ctorString = Function.toString.call(Ctor);
|
|
1443
|
+
cachedCtorStrings.set(Ctor, ctorString);
|
|
1444
|
+
}
|
|
1445
|
+
return ctorString === objectCtorString$1;
|
|
2009
1446
|
}
|
|
2010
|
-
function each(obj, iter) {
|
|
1447
|
+
function each(obj, iter, strict = true) {
|
|
2011
1448
|
if (getArchtype(obj) === 0) {
|
|
2012
|
-
Reflect.ownKeys(obj).
|
|
1449
|
+
const keys2 = strict ? Reflect.ownKeys(obj) : Object.keys(obj);
|
|
1450
|
+
keys2.forEach((key) => {
|
|
2013
1451
|
iter(key, obj[key], obj);
|
|
2014
1452
|
});
|
|
2015
1453
|
} else {
|
|
@@ -2092,17 +1530,27 @@ function freeze$1(obj, deep = false) {
|
|
|
2092
1530
|
if (isFrozen(obj) || isDraft$1(obj) || !isDraftable$1(obj))
|
|
2093
1531
|
return obj;
|
|
2094
1532
|
if (getArchtype(obj) > 1) {
|
|
2095
|
-
|
|
1533
|
+
Object.defineProperties(obj, {
|
|
1534
|
+
set: dontMutateMethodOverride,
|
|
1535
|
+
add: dontMutateMethodOverride,
|
|
1536
|
+
clear: dontMutateMethodOverride,
|
|
1537
|
+
delete: dontMutateMethodOverride
|
|
1538
|
+
});
|
|
2096
1539
|
}
|
|
2097
1540
|
Object.freeze(obj);
|
|
2098
1541
|
if (deep)
|
|
2099
|
-
Object.
|
|
1542
|
+
Object.values(obj).forEach((value) => freeze$1(value, true));
|
|
2100
1543
|
return obj;
|
|
2101
1544
|
}
|
|
2102
1545
|
function dontMutateFrozenCollections() {
|
|
2103
1546
|
die(2);
|
|
2104
1547
|
}
|
|
1548
|
+
var dontMutateMethodOverride = {
|
|
1549
|
+
value: dontMutateFrozenCollections
|
|
1550
|
+
};
|
|
2105
1551
|
function isFrozen(obj) {
|
|
1552
|
+
if (obj === null || typeof obj !== "object")
|
|
1553
|
+
return true;
|
|
2106
1554
|
return Object.isFrozen(obj);
|
|
2107
1555
|
}
|
|
2108
1556
|
var plugins = {};
|
|
@@ -2190,11 +1638,13 @@ function processResult(result, scope) {
|
|
|
2190
1638
|
function finalize(rootScope, value, path3) {
|
|
2191
1639
|
if (isFrozen(value))
|
|
2192
1640
|
return value;
|
|
1641
|
+
const useStrictIteration = rootScope.immer_.shouldUseStrictIteration();
|
|
2193
1642
|
const state = value[DRAFT_STATE];
|
|
2194
1643
|
if (!state) {
|
|
2195
1644
|
each(
|
|
2196
1645
|
value,
|
|
2197
|
-
(key, childValue) => finalizeProperty(rootScope, state, value, key, childValue, path3)
|
|
1646
|
+
(key, childValue) => finalizeProperty(rootScope, state, value, key, childValue, path3),
|
|
1647
|
+
useStrictIteration
|
|
2198
1648
|
);
|
|
2199
1649
|
return value;
|
|
2200
1650
|
}
|
|
@@ -2217,7 +1667,16 @@ function finalize(rootScope, value, path3) {
|
|
|
2217
1667
|
}
|
|
2218
1668
|
each(
|
|
2219
1669
|
resultEach,
|
|
2220
|
-
(key, childValue) => finalizeProperty(
|
|
1670
|
+
(key, childValue) => finalizeProperty(
|
|
1671
|
+
rootScope,
|
|
1672
|
+
state,
|
|
1673
|
+
result,
|
|
1674
|
+
key,
|
|
1675
|
+
childValue,
|
|
1676
|
+
path3,
|
|
1677
|
+
isSet2
|
|
1678
|
+
),
|
|
1679
|
+
useStrictIteration
|
|
2221
1680
|
);
|
|
2222
1681
|
maybeFreeze(rootScope, result, false);
|
|
2223
1682
|
if (path3 && rootScope.patches_) {
|
|
@@ -2232,6 +1691,16 @@ function finalize(rootScope, value, path3) {
|
|
|
2232
1691
|
return state.copy_;
|
|
2233
1692
|
}
|
|
2234
1693
|
function finalizeProperty(rootScope, parentState, targetObject, prop2, childValue, rootPath, targetIsSet) {
|
|
1694
|
+
if (childValue == null) {
|
|
1695
|
+
return;
|
|
1696
|
+
}
|
|
1697
|
+
if (typeof childValue !== "object" && !targetIsSet) {
|
|
1698
|
+
return;
|
|
1699
|
+
}
|
|
1700
|
+
const childIsFrozen = isFrozen(childValue);
|
|
1701
|
+
if (childIsFrozen && !targetIsSet) {
|
|
1702
|
+
return;
|
|
1703
|
+
}
|
|
2235
1704
|
if (process.env.NODE_ENV !== "production" && childValue === targetObject)
|
|
2236
1705
|
die(5);
|
|
2237
1706
|
if (isDraft$1(childValue)) {
|
|
@@ -2246,12 +1715,15 @@ function finalizeProperty(rootScope, parentState, targetObject, prop2, childValu
|
|
|
2246
1715
|
} else if (targetIsSet) {
|
|
2247
1716
|
targetObject.add(childValue);
|
|
2248
1717
|
}
|
|
2249
|
-
if (isDraftable$1(childValue) && !
|
|
1718
|
+
if (isDraftable$1(childValue) && !childIsFrozen) {
|
|
2250
1719
|
if (!rootScope.immer_.autoFreeze_ && rootScope.unfinalizedDrafts_ < 1) {
|
|
2251
1720
|
return;
|
|
2252
1721
|
}
|
|
1722
|
+
if (parentState && parentState.base_ && parentState.base_[prop2] === childValue && childIsFrozen) {
|
|
1723
|
+
return;
|
|
1724
|
+
}
|
|
2253
1725
|
finalize(rootScope, childValue);
|
|
2254
|
-
if ((!parentState || !parentState.scope_.parent_) && typeof prop2 !== "symbol" && Object.prototype.propertyIsEnumerable.call(targetObject, prop2))
|
|
1726
|
+
if ((!parentState || !parentState.scope_.parent_) && typeof prop2 !== "symbol" && (isMap$2(targetObject) ? targetObject.has(prop2) : Object.prototype.propertyIsEnumerable.call(targetObject, prop2)))
|
|
2255
1727
|
maybeFreeze(rootScope, childValue);
|
|
2256
1728
|
}
|
|
2257
1729
|
}
|
|
@@ -2447,6 +1919,7 @@ var Immer2 = class {
|
|
|
2447
1919
|
constructor(config) {
|
|
2448
1920
|
this.autoFreeze_ = true;
|
|
2449
1921
|
this.useStrictShallowCopy_ = false;
|
|
1922
|
+
this.useStrictIteration_ = true;
|
|
2450
1923
|
this.produce = (base, recipe, patchListener) => {
|
|
2451
1924
|
if (typeof base === "function" && typeof recipe !== "function") {
|
|
2452
1925
|
const defaultBase = recipe;
|
|
@@ -2509,6 +1982,8 @@ var Immer2 = class {
|
|
|
2509
1982
|
this.setAutoFreeze(config.autoFreeze);
|
|
2510
1983
|
if (typeof (config == null ? void 0 : config.useStrictShallowCopy) === "boolean")
|
|
2511
1984
|
this.setUseStrictShallowCopy(config.useStrictShallowCopy);
|
|
1985
|
+
if (typeof (config == null ? void 0 : config.useStrictIteration) === "boolean")
|
|
1986
|
+
this.setUseStrictIteration(config.useStrictIteration);
|
|
2512
1987
|
}
|
|
2513
1988
|
createDraft(base) {
|
|
2514
1989
|
if (!isDraftable$1(base))
|
|
@@ -2545,6 +2020,18 @@ var Immer2 = class {
|
|
|
2545
2020
|
setUseStrictShallowCopy(value) {
|
|
2546
2021
|
this.useStrictShallowCopy_ = value;
|
|
2547
2022
|
}
|
|
2023
|
+
/**
|
|
2024
|
+
* Pass false to use faster iteration that skips non-enumerable properties
|
|
2025
|
+
* but still handles symbols for compatibility.
|
|
2026
|
+
*
|
|
2027
|
+
* By default, strict iteration is enabled (includes all own properties).
|
|
2028
|
+
*/
|
|
2029
|
+
setUseStrictIteration(value) {
|
|
2030
|
+
this.useStrictIteration_ = value;
|
|
2031
|
+
}
|
|
2032
|
+
shouldUseStrictIteration() {
|
|
2033
|
+
return this.useStrictIteration_;
|
|
2034
|
+
}
|
|
2548
2035
|
applyPatches(base, patches) {
|
|
2549
2036
|
let i2;
|
|
2550
2037
|
for (i2 = patches.length - 1; i2 >= 0; i2--) {
|
|
@@ -2583,17 +2070,23 @@ function currentImpl(value) {
|
|
|
2583
2070
|
return value;
|
|
2584
2071
|
const state = value[DRAFT_STATE];
|
|
2585
2072
|
let copy2;
|
|
2073
|
+
let strict = true;
|
|
2586
2074
|
if (state) {
|
|
2587
2075
|
if (!state.modified_)
|
|
2588
2076
|
return state.base_;
|
|
2589
2077
|
state.finalized_ = true;
|
|
2590
2078
|
copy2 = shallowCopy$1(value, state.scope_.immer_.useStrictShallowCopy_);
|
|
2079
|
+
strict = state.scope_.immer_.shouldUseStrictIteration();
|
|
2591
2080
|
} else {
|
|
2592
2081
|
copy2 = shallowCopy$1(value, true);
|
|
2593
2082
|
}
|
|
2594
|
-
each(
|
|
2595
|
-
|
|
2596
|
-
|
|
2083
|
+
each(
|
|
2084
|
+
copy2,
|
|
2085
|
+
(key, childValue) => {
|
|
2086
|
+
set$3(copy2, key, currentImpl(childValue));
|
|
2087
|
+
},
|
|
2088
|
+
strict
|
|
2089
|
+
);
|
|
2597
2090
|
if (state) {
|
|
2598
2091
|
state.finalized_ = false;
|
|
2599
2092
|
}
|
|
@@ -2601,14 +2094,8 @@ function currentImpl(value) {
|
|
|
2601
2094
|
}
|
|
2602
2095
|
var immer = new Immer2();
|
|
2603
2096
|
var produce = immer.produce;
|
|
2604
|
-
immer.
|
|
2605
|
-
|
|
2606
|
-
);
|
|
2607
|
-
immer.setAutoFreeze.bind(immer);
|
|
2608
|
-
immer.setUseStrictShallowCopy.bind(immer);
|
|
2609
|
-
immer.applyPatches.bind(immer);
|
|
2610
|
-
var createDraft$1 = immer.createDraft.bind(immer);
|
|
2611
|
-
var finishDraft = immer.finishDraft.bind(immer);
|
|
2097
|
+
var createDraft$1 = /* @__PURE__ */ immer.createDraft.bind(immer);
|
|
2098
|
+
var finishDraft = /* @__PURE__ */ immer.finishDraft.bind(immer);
|
|
2612
2099
|
var PathRef = {
|
|
2613
2100
|
transform(ref, op) {
|
|
2614
2101
|
var {
|
|
@@ -10992,7 +10479,7 @@ var TextString = (props) => {
|
|
|
10992
10479
|
ref
|
|
10993
10480
|
}, initialText);
|
|
10994
10481
|
};
|
|
10995
|
-
var MemoizedText$1 = /* @__PURE__ */ memo
|
|
10482
|
+
var MemoizedText$1 = /* @__PURE__ */ memo(/* @__PURE__ */ forwardRef((props, ref) => {
|
|
10996
10483
|
return /* @__PURE__ */ React__default.createElement("span", {
|
|
10997
10484
|
"data-slate-string": true,
|
|
10998
10485
|
ref
|
|
@@ -15604,8 +15091,9 @@ const devtoolsImpl = (fn, devtoolsOptions = {}) => (set2, get2, api) => {
|
|
|
15604
15091
|
const r2 = set2(state, replace);
|
|
15605
15092
|
if (!isRecording)
|
|
15606
15093
|
return r2;
|
|
15607
|
-
const
|
|
15608
|
-
|
|
15094
|
+
const action = nameOrAction === void 0 ? {
|
|
15095
|
+
type: anonymousActionType || findCallerName(new Error().stack) || "anonymous"
|
|
15096
|
+
} : typeof nameOrAction === "string" ? { type: nameOrAction } : nameOrAction;
|
|
15609
15097
|
if (store === void 0) {
|
|
15610
15098
|
connection == null ? void 0 : connection.send(action, get2());
|
|
15611
15099
|
return r2;
|
|
@@ -15893,12 +15381,12 @@ const persistImpl = (config, baseOptions) => (set2, get2, api) => {
|
|
|
15893
15381
|
const savedSetState = api.setState;
|
|
15894
15382
|
api.setState = (state, replace) => {
|
|
15895
15383
|
savedSetState(state, replace);
|
|
15896
|
-
|
|
15384
|
+
return setItem();
|
|
15897
15385
|
};
|
|
15898
15386
|
const configResult = config(
|
|
15899
15387
|
(...args) => {
|
|
15900
15388
|
set2(...args);
|
|
15901
|
-
|
|
15389
|
+
return setItem();
|
|
15902
15390
|
},
|
|
15903
15391
|
get2,
|
|
15904
15392
|
api
|
|
@@ -38053,192 +37541,713 @@ const TableRowElement = withRef$1(
|
|
|
38053
37541
|
children
|
|
38054
37542
|
);
|
|
38055
37543
|
}
|
|
38056
|
-
);
|
|
38057
|
-
function classNames$1(...classes) {
|
|
38058
|
-
return classes.filter(Boolean).join(" ");
|
|
37544
|
+
);
|
|
37545
|
+
function classNames$1(...classes) {
|
|
37546
|
+
return classes.filter(Boolean).join(" ");
|
|
37547
|
+
}
|
|
37548
|
+
const uuid = () => {
|
|
37549
|
+
return ([1e7] + -1e3 + -4e3 + -8e3 + -1e11).replace(
|
|
37550
|
+
/[018]/g,
|
|
37551
|
+
(c2) => (c2 ^ crypto.getRandomValues(new Uint8Array(1))[0] & 15 >> c2 / 4).toString(16)
|
|
37552
|
+
);
|
|
37553
|
+
};
|
|
37554
|
+
const blockClasses = "mt-0.5";
|
|
37555
|
+
const headerClasses = "font-normal";
|
|
37556
|
+
const Components = () => {
|
|
37557
|
+
return {
|
|
37558
|
+
[SlashInputPlugin.key]: SlashInputElement,
|
|
37559
|
+
[HEADING_KEYS$1.h1]: ({
|
|
37560
|
+
attributes,
|
|
37561
|
+
editor,
|
|
37562
|
+
element,
|
|
37563
|
+
className,
|
|
37564
|
+
...props
|
|
37565
|
+
}) => /* @__PURE__ */ React__default.createElement(
|
|
37566
|
+
"h1",
|
|
37567
|
+
{
|
|
37568
|
+
...attributes,
|
|
37569
|
+
...props,
|
|
37570
|
+
className: classNames$1(
|
|
37571
|
+
headerClasses,
|
|
37572
|
+
blockClasses,
|
|
37573
|
+
className,
|
|
37574
|
+
"text-4xl mb-4 last:mb-0 mt-6 first:mt-0 font-libre-baskerville"
|
|
37575
|
+
)
|
|
37576
|
+
}
|
|
37577
|
+
),
|
|
37578
|
+
[HEADING_KEYS$1.h2]: ({
|
|
37579
|
+
attributes,
|
|
37580
|
+
editor,
|
|
37581
|
+
element,
|
|
37582
|
+
className,
|
|
37583
|
+
...props
|
|
37584
|
+
}) => /* @__PURE__ */ React__default.createElement(
|
|
37585
|
+
"h2",
|
|
37586
|
+
{
|
|
37587
|
+
...attributes,
|
|
37588
|
+
...props,
|
|
37589
|
+
className: classNames$1(
|
|
37590
|
+
headerClasses,
|
|
37591
|
+
blockClasses,
|
|
37592
|
+
className,
|
|
37593
|
+
"text-3xl mb-4 last:mb-0 mt-6 first:mt-0 font-libre-baskerville"
|
|
37594
|
+
)
|
|
37595
|
+
}
|
|
37596
|
+
),
|
|
37597
|
+
[HEADING_KEYS$1.h3]: ({
|
|
37598
|
+
attributes,
|
|
37599
|
+
editor,
|
|
37600
|
+
element,
|
|
37601
|
+
className,
|
|
37602
|
+
...props
|
|
37603
|
+
}) => /* @__PURE__ */ React__default.createElement(
|
|
37604
|
+
"h3",
|
|
37605
|
+
{
|
|
37606
|
+
...attributes,
|
|
37607
|
+
...props,
|
|
37608
|
+
className: classNames$1(
|
|
37609
|
+
headerClasses,
|
|
37610
|
+
blockClasses,
|
|
37611
|
+
className,
|
|
37612
|
+
"text-2xl mb-4 last:mb-0 mt-6 first:mt-0 font-libre-baskerville"
|
|
37613
|
+
)
|
|
37614
|
+
}
|
|
37615
|
+
),
|
|
37616
|
+
[HEADING_KEYS$1.h4]: ({
|
|
37617
|
+
attributes,
|
|
37618
|
+
editor,
|
|
37619
|
+
element,
|
|
37620
|
+
className,
|
|
37621
|
+
...props
|
|
37622
|
+
}) => /* @__PURE__ */ React__default.createElement(
|
|
37623
|
+
"h4",
|
|
37624
|
+
{
|
|
37625
|
+
...attributes,
|
|
37626
|
+
...props,
|
|
37627
|
+
className: classNames$1(
|
|
37628
|
+
headerClasses,
|
|
37629
|
+
blockClasses,
|
|
37630
|
+
className,
|
|
37631
|
+
"text-xl mb-4 last:mb-0 mt-6 first:mt-0 font-libre-baskerville"
|
|
37632
|
+
)
|
|
37633
|
+
}
|
|
37634
|
+
),
|
|
37635
|
+
/** Tailwind prose doesn't style h5 and h6 elements */
|
|
37636
|
+
[HEADING_KEYS$1.h5]: ({
|
|
37637
|
+
attributes,
|
|
37638
|
+
editor,
|
|
37639
|
+
element,
|
|
37640
|
+
className,
|
|
37641
|
+
...props
|
|
37642
|
+
}) => /* @__PURE__ */ React__default.createElement(
|
|
37643
|
+
"h5",
|
|
37644
|
+
{
|
|
37645
|
+
...attributes,
|
|
37646
|
+
...props,
|
|
37647
|
+
className: classNames$1(
|
|
37648
|
+
headerClasses,
|
|
37649
|
+
blockClasses,
|
|
37650
|
+
className,
|
|
37651
|
+
"text-lg mb-4 last:mb-0 mt-6 first:mt-0"
|
|
37652
|
+
),
|
|
37653
|
+
style: { fontFamily: "'Libre Baskerville', serif", fontWeight: "400" }
|
|
37654
|
+
}
|
|
37655
|
+
),
|
|
37656
|
+
[HEADING_KEYS$1.h6]: ({
|
|
37657
|
+
attributes,
|
|
37658
|
+
editor,
|
|
37659
|
+
element,
|
|
37660
|
+
className,
|
|
37661
|
+
...props
|
|
37662
|
+
}) => /* @__PURE__ */ React__default.createElement(
|
|
37663
|
+
"h6",
|
|
37664
|
+
{
|
|
37665
|
+
...attributes,
|
|
37666
|
+
...props,
|
|
37667
|
+
className: classNames$1(
|
|
37668
|
+
headerClasses,
|
|
37669
|
+
blockClasses,
|
|
37670
|
+
className,
|
|
37671
|
+
"text-base mb-4 last:mb-0 mt-6 first:mt-0"
|
|
37672
|
+
),
|
|
37673
|
+
style: { fontFamily: "'Libre Baskerville', serif", fontWeight: "400" }
|
|
37674
|
+
}
|
|
37675
|
+
),
|
|
37676
|
+
[ParagraphPlugin.key]: ParagraphElement,
|
|
37677
|
+
[BlockquotePlugin.key]: BlockquoteElement,
|
|
37678
|
+
[CodeBlockPlugin.key]: CodeBlockElement,
|
|
37679
|
+
[CodeLinePlugin.key]: CodeLineElement,
|
|
37680
|
+
[CodeSyntaxPlugin.key]: CodeSyntaxLeaf,
|
|
37681
|
+
html: ({ attributes, editor, element, children, className }) => {
|
|
37682
|
+
return /* @__PURE__ */ React__default.createElement(
|
|
37683
|
+
"div",
|
|
37684
|
+
{
|
|
37685
|
+
...attributes,
|
|
37686
|
+
className: classNames$1(
|
|
37687
|
+
"font-mono text-sm bg-green-100 cursor-not-allowed mb-4",
|
|
37688
|
+
className
|
|
37689
|
+
)
|
|
37690
|
+
},
|
|
37691
|
+
children,
|
|
37692
|
+
element.value
|
|
37693
|
+
);
|
|
37694
|
+
},
|
|
37695
|
+
html_inline: ({ attributes, editor, element, children, className }) => {
|
|
37696
|
+
return /* @__PURE__ */ React__default.createElement(
|
|
37697
|
+
"span",
|
|
37698
|
+
{
|
|
37699
|
+
...attributes,
|
|
37700
|
+
className: classNames$1(
|
|
37701
|
+
"font-mono bg-green-100 cursor-not-allowed",
|
|
37702
|
+
className
|
|
37703
|
+
)
|
|
37704
|
+
},
|
|
37705
|
+
children,
|
|
37706
|
+
element.value
|
|
37707
|
+
);
|
|
37708
|
+
},
|
|
37709
|
+
[BulletedListPlugin.key]: withProps(ListElement, { variant: "ul" }),
|
|
37710
|
+
[NumberedListPlugin.key]: withProps(ListElement, { variant: "ol" }),
|
|
37711
|
+
[ListItemPlugin.key]: withProps(PlateElement, { as: "li" }),
|
|
37712
|
+
[LinkPlugin.key]: LinkElement,
|
|
37713
|
+
[CodePlugin.key]: CodeLeaf,
|
|
37714
|
+
[UnderlinePlugin.key]: withProps(PlateLeaf, { as: "u" }),
|
|
37715
|
+
[StrikethroughPlugin.key]: withProps(PlateLeaf, { as: "s" }),
|
|
37716
|
+
[ItalicPlugin.key]: withProps(PlateLeaf, { as: "em" }),
|
|
37717
|
+
[BoldPlugin.key]: withProps(PlateLeaf, { as: "strong" }),
|
|
37718
|
+
[HorizontalRulePlugin.key]: HrElement,
|
|
37719
|
+
[TableCellHeaderPlugin.key]: TableCellHeaderElement,
|
|
37720
|
+
[TableCellPlugin.key]: TableCellElement,
|
|
37721
|
+
[TablePlugin.key]: TableElement,
|
|
37722
|
+
[TableRowPlugin.key]: TableRowElement
|
|
37723
|
+
};
|
|
37724
|
+
};
|
|
37725
|
+
class Form {
|
|
37726
|
+
constructor({
|
|
37727
|
+
id: id2,
|
|
37728
|
+
label,
|
|
37729
|
+
fields,
|
|
37730
|
+
actions,
|
|
37731
|
+
buttons,
|
|
37732
|
+
global: global2,
|
|
37733
|
+
reset: reset2,
|
|
37734
|
+
loadInitialValues,
|
|
37735
|
+
onChange,
|
|
37736
|
+
queries,
|
|
37737
|
+
...options
|
|
37738
|
+
}) {
|
|
37739
|
+
__publicField(this, "__type");
|
|
37740
|
+
__publicField(this, "id");
|
|
37741
|
+
__publicField(this, "label");
|
|
37742
|
+
__publicField(this, "fields");
|
|
37743
|
+
__publicField(this, "finalForm");
|
|
37744
|
+
__publicField(this, "actions");
|
|
37745
|
+
__publicField(this, "buttons");
|
|
37746
|
+
__publicField(this, "queries");
|
|
37747
|
+
__publicField(this, "global", null);
|
|
37748
|
+
__publicField(this, "loading", false);
|
|
37749
|
+
/**
|
|
37750
|
+
* @deprecated
|
|
37751
|
+
* Misleading name as per https://github.com/tinacms/tinacms/issues/5686#issuecomment-2899840518
|
|
37752
|
+
* Use path property instead.
|
|
37753
|
+
*/
|
|
37754
|
+
__publicField(this, "relativePath");
|
|
37755
|
+
/**
|
|
37756
|
+
* Where to save the form within the content directory on next submission.
|
|
37757
|
+
*/
|
|
37758
|
+
__publicField(this, "path");
|
|
37759
|
+
__publicField(this, "crudType");
|
|
37760
|
+
__publicField(this, "beforeSubmit");
|
|
37761
|
+
/**
|
|
37762
|
+
* Subscribes to changes to the form. The subscriber will only be called when
|
|
37763
|
+
* values specified in subscription change. A form can have many subscribers.
|
|
37764
|
+
*/
|
|
37765
|
+
__publicField(this, "subscribe", (cb, options) => {
|
|
37766
|
+
return this.finalForm.subscribe(cb, options);
|
|
37767
|
+
});
|
|
37768
|
+
__publicField(this, "onSubmit");
|
|
37769
|
+
__publicField(this, "handleSubmit", async (values, form, cb) => {
|
|
37770
|
+
var _a2;
|
|
37771
|
+
try {
|
|
37772
|
+
const valOverride = await ((_a2 = this.beforeSubmit) == null ? void 0 : _a2.call(this, values));
|
|
37773
|
+
if (valOverride) {
|
|
37774
|
+
for (const [key, value] of Object.entries(valOverride)) {
|
|
37775
|
+
form.change(key, value);
|
|
37776
|
+
}
|
|
37777
|
+
}
|
|
37778
|
+
const response = await this.onSubmit(valOverride || values, form, cb);
|
|
37779
|
+
form.initialize(values);
|
|
37780
|
+
return response;
|
|
37781
|
+
} catch (error2) {
|
|
37782
|
+
return { [FORM_ERROR]: error2 };
|
|
37783
|
+
}
|
|
37784
|
+
});
|
|
37785
|
+
/**
|
|
37786
|
+
* Submits the form if there are currently no validation errors. It may
|
|
37787
|
+
* return undefined or a Promise depending on the nature of the onSubmit
|
|
37788
|
+
* configuration value given to the form when it was created.
|
|
37789
|
+
*/
|
|
37790
|
+
__publicField(this, "submit", () => {
|
|
37791
|
+
return this.finalForm.submit();
|
|
37792
|
+
});
|
|
37793
|
+
const initialValues = options.initialValues || {};
|
|
37794
|
+
this.__type = options.__type || "form";
|
|
37795
|
+
this.id = id2;
|
|
37796
|
+
this.label = label;
|
|
37797
|
+
this.global = global2;
|
|
37798
|
+
this.fields = fields || [];
|
|
37799
|
+
this.onSubmit = options.onSubmit;
|
|
37800
|
+
this.queries = queries || [];
|
|
37801
|
+
this.crudType = options.crudType || "update";
|
|
37802
|
+
this.relativePath = options.relativePath || id2;
|
|
37803
|
+
this.path = options.path || id2;
|
|
37804
|
+
this.finalForm = createForm({
|
|
37805
|
+
...options,
|
|
37806
|
+
initialValues,
|
|
37807
|
+
onSubmit: this.handleSubmit,
|
|
37808
|
+
mutators: {
|
|
37809
|
+
...arrayMutators,
|
|
37810
|
+
setFieldData,
|
|
37811
|
+
...options.mutators
|
|
37812
|
+
}
|
|
37813
|
+
});
|
|
37814
|
+
this._reset = reset2;
|
|
37815
|
+
this.actions = actions || [];
|
|
37816
|
+
this.buttons = buttons || {
|
|
37817
|
+
save: "Save",
|
|
37818
|
+
reset: "Reset"
|
|
37819
|
+
};
|
|
37820
|
+
this.updateFields(this.fields);
|
|
37821
|
+
if (loadInitialValues) {
|
|
37822
|
+
this.loading = true;
|
|
37823
|
+
loadInitialValues().then((initialValues2) => {
|
|
37824
|
+
this.updateInitialValues(initialValues2);
|
|
37825
|
+
}).finally(() => {
|
|
37826
|
+
this.loading = false;
|
|
37827
|
+
});
|
|
37828
|
+
}
|
|
37829
|
+
if (onChange) {
|
|
37830
|
+
let firstUpdate = true;
|
|
37831
|
+
this.subscribe(
|
|
37832
|
+
(formState) => {
|
|
37833
|
+
if (firstUpdate) {
|
|
37834
|
+
firstUpdate = false;
|
|
37835
|
+
} else {
|
|
37836
|
+
onChange(formState);
|
|
37837
|
+
}
|
|
37838
|
+
},
|
|
37839
|
+
{ values: true, ...(options == null ? void 0 : options.extraSubscribeValues) || {} }
|
|
37840
|
+
);
|
|
37841
|
+
}
|
|
37842
|
+
}
|
|
37843
|
+
/**
|
|
37844
|
+
* A unique identifier for Forms.
|
|
37845
|
+
*
|
|
37846
|
+
* @deprecated use id instead
|
|
37847
|
+
*/
|
|
37848
|
+
get name() {
|
|
37849
|
+
return void 0;
|
|
37850
|
+
}
|
|
37851
|
+
/**
|
|
37852
|
+
* Returns the current values of the form.
|
|
37853
|
+
*
|
|
37854
|
+
* if the form is still loading it returns `undefined`.
|
|
37855
|
+
*/
|
|
37856
|
+
get values() {
|
|
37857
|
+
if (this.loading) {
|
|
37858
|
+
return void 0;
|
|
37859
|
+
}
|
|
37860
|
+
return this.finalForm.getState().values || this.initialValues;
|
|
37861
|
+
}
|
|
37862
|
+
/**
|
|
37863
|
+
* The values the form was initialized with.
|
|
37864
|
+
*/
|
|
37865
|
+
get initialValues() {
|
|
37866
|
+
return this.finalForm.getState().initialValues;
|
|
37867
|
+
}
|
|
37868
|
+
get pristine() {
|
|
37869
|
+
return this.finalForm.getState().pristine;
|
|
37870
|
+
}
|
|
37871
|
+
get dirty() {
|
|
37872
|
+
return this.finalForm.getState().dirty;
|
|
37873
|
+
}
|
|
37874
|
+
get submitting() {
|
|
37875
|
+
return this.finalForm.getState().submitting;
|
|
37876
|
+
}
|
|
37877
|
+
get valid() {
|
|
37878
|
+
return this.finalForm.getState().valid;
|
|
37879
|
+
}
|
|
37880
|
+
/**
|
|
37881
|
+
* Resets the values back to the initial values the form was initialized with.
|
|
37882
|
+
* Or empties all the values if the form was not initialized.
|
|
37883
|
+
*/
|
|
37884
|
+
async reset() {
|
|
37885
|
+
if (this._reset) {
|
|
37886
|
+
await this._reset();
|
|
37887
|
+
}
|
|
37888
|
+
this.finalForm.reset();
|
|
37889
|
+
}
|
|
37890
|
+
/**
|
|
37891
|
+
* @deprecated Unnecessary indirection
|
|
37892
|
+
*/
|
|
37893
|
+
updateFields(fields) {
|
|
37894
|
+
this.fields = fields;
|
|
37895
|
+
}
|
|
37896
|
+
/**
|
|
37897
|
+
* Changes the value of the given field.
|
|
37898
|
+
*
|
|
37899
|
+
* @param name
|
|
37900
|
+
* @param value
|
|
37901
|
+
*/
|
|
37902
|
+
change(name, value) {
|
|
37903
|
+
return this.finalForm.change(name, value);
|
|
37904
|
+
}
|
|
37905
|
+
get mutators() {
|
|
37906
|
+
return this.finalForm.mutators;
|
|
37907
|
+
}
|
|
37908
|
+
addQuery(queryId) {
|
|
37909
|
+
this.queries = [...this.queries.filter((id2) => id2 !== queryId), queryId];
|
|
37910
|
+
}
|
|
37911
|
+
removeQuery(queryId) {
|
|
37912
|
+
this.queries = this.queries.filter((id2) => id2 !== queryId);
|
|
37913
|
+
}
|
|
37914
|
+
/**
|
|
37915
|
+
* Updates multiple fields in the form.
|
|
37916
|
+
*
|
|
37917
|
+
* The updates are batched so that it only triggers one `onChange` event.
|
|
37918
|
+
*
|
|
37919
|
+
* In order to prevent disruptions to the user's editing experience this
|
|
37920
|
+
* function will _not_ update the value of any field that is currently
|
|
37921
|
+
* being edited.
|
|
37922
|
+
*
|
|
37923
|
+
* @param values
|
|
37924
|
+
*/
|
|
37925
|
+
updateValues(values) {
|
|
37926
|
+
this.finalForm.batch(() => {
|
|
37927
|
+
const activePath = this.finalForm.getState().active;
|
|
37928
|
+
if (!activePath) {
|
|
37929
|
+
updateEverything(this.finalForm, values);
|
|
37930
|
+
} else {
|
|
37931
|
+
updateSelectively(this.finalForm, values);
|
|
37932
|
+
}
|
|
37933
|
+
});
|
|
37934
|
+
}
|
|
37935
|
+
/**
|
|
37936
|
+
* Replaces the initialValues of the form without deleting the current values.
|
|
37937
|
+
*
|
|
37938
|
+
* This function is helpful when the initialValues are loaded asynchronously.
|
|
37939
|
+
*
|
|
37940
|
+
* @param initialValues
|
|
37941
|
+
*/
|
|
37942
|
+
updateInitialValues(initialValues) {
|
|
37943
|
+
this.finalForm.batch(() => {
|
|
37944
|
+
const values = this.values || {};
|
|
37945
|
+
this.finalForm.initialize(initialValues);
|
|
37946
|
+
const activePath = this.finalForm.getState().active;
|
|
37947
|
+
if (!activePath) {
|
|
37948
|
+
updateEverything(this.finalForm, values);
|
|
37949
|
+
} else {
|
|
37950
|
+
updateSelectively(this.finalForm, values);
|
|
37951
|
+
}
|
|
37952
|
+
});
|
|
37953
|
+
}
|
|
37954
|
+
/**
|
|
37955
|
+
* Based on field's name this function will
|
|
37956
|
+
* return an array of fields for the give form along
|
|
37957
|
+
* with the path that it was found at top nearest
|
|
37958
|
+
* object-like group
|
|
37959
|
+
*
|
|
37960
|
+
* So if you have a field named blocks.3.title
|
|
37961
|
+
* It will return the fields from the 3rd "block"
|
|
37962
|
+
* along with the path it was found at
|
|
37963
|
+
* fields: [{type: 'string', name: 'title'}, ... other fields]
|
|
37964
|
+
* activePath: ['blocks', '3']
|
|
37965
|
+
*/
|
|
37966
|
+
getActiveField(fieldName) {
|
|
37967
|
+
if (!fieldName) {
|
|
37968
|
+
return this;
|
|
37969
|
+
}
|
|
37970
|
+
const result = this.getFieldGroup({
|
|
37971
|
+
formOrObjectField: this,
|
|
37972
|
+
values: this.finalForm.getState().values,
|
|
37973
|
+
namePathIndex: 0,
|
|
37974
|
+
namePath: fieldName.split(".")
|
|
37975
|
+
});
|
|
37976
|
+
return result;
|
|
37977
|
+
}
|
|
37978
|
+
getFieldGroup({
|
|
37979
|
+
formOrObjectField,
|
|
37980
|
+
values = {},
|
|
37981
|
+
namePathIndex,
|
|
37982
|
+
namePath
|
|
37983
|
+
}) {
|
|
37984
|
+
const name = namePath[namePathIndex];
|
|
37985
|
+
const field = formOrObjectField.fields.find((field2) => field2.name === name);
|
|
37986
|
+
const value = values[name];
|
|
37987
|
+
const isLastItem = namePathIndex === namePath.length - 1;
|
|
37988
|
+
if (!field) {
|
|
37989
|
+
return {
|
|
37990
|
+
...formOrObjectField,
|
|
37991
|
+
fields: formOrObjectField.fields.map((field2) => {
|
|
37992
|
+
return {
|
|
37993
|
+
...field2,
|
|
37994
|
+
name: [...namePath, field2.name].join(".")
|
|
37995
|
+
};
|
|
37996
|
+
})
|
|
37997
|
+
};
|
|
37998
|
+
} else {
|
|
37999
|
+
if (field.type === "object") {
|
|
38000
|
+
if (field.templates) {
|
|
38001
|
+
if (field.list) {
|
|
38002
|
+
if (isLastItem) {
|
|
38003
|
+
return formOrObjectField;
|
|
38004
|
+
} else {
|
|
38005
|
+
const namePathIndexForListItem = namePathIndex + 1;
|
|
38006
|
+
const index = namePath[namePathIndexForListItem];
|
|
38007
|
+
const listItemValue = value[index];
|
|
38008
|
+
const template = field.templates[listItemValue._template];
|
|
38009
|
+
const templateName = [
|
|
38010
|
+
...namePath.slice(0, namePathIndexForListItem),
|
|
38011
|
+
index
|
|
38012
|
+
].join(".");
|
|
38013
|
+
const isLastItem2 = namePathIndexForListItem === namePath.length - 1;
|
|
38014
|
+
if (!isLastItem2) {
|
|
38015
|
+
return this.getFieldGroup({
|
|
38016
|
+
formOrObjectField: template,
|
|
38017
|
+
values: listItemValue,
|
|
38018
|
+
namePath,
|
|
38019
|
+
namePathIndex: namePathIndex + 2
|
|
38020
|
+
});
|
|
38021
|
+
}
|
|
38022
|
+
if (!template) {
|
|
38023
|
+
console.error({ field, value });
|
|
38024
|
+
throw new Error(
|
|
38025
|
+
`Expected template value for field ${field.name}`
|
|
38026
|
+
);
|
|
38027
|
+
}
|
|
38028
|
+
return {
|
|
38029
|
+
...template,
|
|
38030
|
+
name: templateName,
|
|
38031
|
+
fields: template.fields.map((field2) => {
|
|
38032
|
+
return {
|
|
38033
|
+
...field2,
|
|
38034
|
+
name: [templateName, field2.name].join(".")
|
|
38035
|
+
};
|
|
38036
|
+
})
|
|
38037
|
+
};
|
|
38038
|
+
}
|
|
38039
|
+
}
|
|
38040
|
+
} else {
|
|
38041
|
+
if (field.list) {
|
|
38042
|
+
const namePathIndexForListItem = namePathIndex + 1;
|
|
38043
|
+
const index = namePath[namePathIndexForListItem];
|
|
38044
|
+
const listItemValue = value[index];
|
|
38045
|
+
const fieldName = [
|
|
38046
|
+
...namePath.slice(0, namePathIndexForListItem),
|
|
38047
|
+
index
|
|
38048
|
+
].join(".");
|
|
38049
|
+
const isLastItem2 = namePathIndexForListItem === namePath.length - 1;
|
|
38050
|
+
if (!isLastItem2) {
|
|
38051
|
+
if (field.fields) {
|
|
38052
|
+
return this.getFieldGroup({
|
|
38053
|
+
formOrObjectField: field,
|
|
38054
|
+
values: listItemValue,
|
|
38055
|
+
namePath,
|
|
38056
|
+
namePathIndex: namePathIndex + 2
|
|
38057
|
+
});
|
|
38058
|
+
}
|
|
38059
|
+
}
|
|
38060
|
+
return {
|
|
38061
|
+
...field,
|
|
38062
|
+
name: fieldName,
|
|
38063
|
+
fields: field.fields.map((field2) => {
|
|
38064
|
+
return {
|
|
38065
|
+
...field2,
|
|
38066
|
+
name: [fieldName, field2.name].join(".")
|
|
38067
|
+
};
|
|
38068
|
+
})
|
|
38069
|
+
};
|
|
38070
|
+
} else {
|
|
38071
|
+
const fieldName = [...namePath.slice(0, namePathIndex + 1)].join(
|
|
38072
|
+
"."
|
|
38073
|
+
);
|
|
38074
|
+
const isLastItem2 = namePathIndex === namePath.length - 1;
|
|
38075
|
+
if (!isLastItem2) {
|
|
38076
|
+
return this.getFieldGroup({
|
|
38077
|
+
formOrObjectField: field,
|
|
38078
|
+
values: value,
|
|
38079
|
+
namePath,
|
|
38080
|
+
namePathIndex: namePathIndex + 1
|
|
38081
|
+
});
|
|
38082
|
+
}
|
|
38083
|
+
return {
|
|
38084
|
+
...field,
|
|
38085
|
+
name: fieldName,
|
|
38086
|
+
fields: field.fields.map((field2) => {
|
|
38087
|
+
return {
|
|
38088
|
+
...field2,
|
|
38089
|
+
name: [fieldName, field2.name].join(".")
|
|
38090
|
+
};
|
|
38091
|
+
})
|
|
38092
|
+
};
|
|
38093
|
+
}
|
|
38094
|
+
}
|
|
38095
|
+
} else if (field.type === "rich-text") {
|
|
38096
|
+
if (isLastItem) {
|
|
38097
|
+
return {
|
|
38098
|
+
...formOrObjectField,
|
|
38099
|
+
fields: formOrObjectField.fields.map((field2) => {
|
|
38100
|
+
return {
|
|
38101
|
+
...field2,
|
|
38102
|
+
name: [...namePath.slice(0, namePathIndex), field2.name].join(
|
|
38103
|
+
"."
|
|
38104
|
+
)
|
|
38105
|
+
};
|
|
38106
|
+
})
|
|
38107
|
+
};
|
|
38108
|
+
} else {
|
|
38109
|
+
const childrenIndex = namePath.findIndex(
|
|
38110
|
+
(value2) => value2 === "children"
|
|
38111
|
+
);
|
|
38112
|
+
const propsIndex = namePath.slice(childrenIndex).findIndex((value2) => value2 === "props") + childrenIndex;
|
|
38113
|
+
const itemName = namePath.slice(childrenIndex, propsIndex).join(".");
|
|
38114
|
+
const item = getIn(value, itemName);
|
|
38115
|
+
const props = item.props;
|
|
38116
|
+
const templateString = item.name;
|
|
38117
|
+
const currentPathIndex = namePathIndex + Math.max(propsIndex, 3);
|
|
38118
|
+
const isLastItem2 = currentPathIndex + 1 === namePath.length;
|
|
38119
|
+
const template = field.templates.find(
|
|
38120
|
+
(t2) => t2.name === templateString
|
|
38121
|
+
);
|
|
38122
|
+
const templateName = namePath.slice(0, currentPathIndex + 2).join(".");
|
|
38123
|
+
if ((item == null ? void 0 : item.type) === "img") {
|
|
38124
|
+
const imageName = namePath.slice(0, currentPathIndex + 2).join(".");
|
|
38125
|
+
return {
|
|
38126
|
+
...formOrObjectField,
|
|
38127
|
+
// name: [formOrObjectField.name, 'img'].join('.'),
|
|
38128
|
+
name: [imageName].join("."),
|
|
38129
|
+
fields: [
|
|
38130
|
+
{
|
|
38131
|
+
type: "image",
|
|
38132
|
+
// label: 'URL',
|
|
38133
|
+
name: [templateName, "url"].join("."),
|
|
38134
|
+
component: "image"
|
|
38135
|
+
},
|
|
38136
|
+
{
|
|
38137
|
+
type: "string",
|
|
38138
|
+
label: "Alt",
|
|
38139
|
+
name: [templateName.replace(/\.props$/, ""), "alt"].join("."),
|
|
38140
|
+
component: "text"
|
|
38141
|
+
},
|
|
38142
|
+
{
|
|
38143
|
+
type: "string",
|
|
38144
|
+
label: "Caption",
|
|
38145
|
+
name: [templateName.replace(/\.props$/, ""), "caption"].join(
|
|
38146
|
+
"."
|
|
38147
|
+
),
|
|
38148
|
+
component: "text"
|
|
38149
|
+
}
|
|
38150
|
+
]
|
|
38151
|
+
};
|
|
38152
|
+
}
|
|
38153
|
+
if (!isLastItem2) {
|
|
38154
|
+
return this.getFieldGroup({
|
|
38155
|
+
formOrObjectField: template,
|
|
38156
|
+
values: props,
|
|
38157
|
+
namePath,
|
|
38158
|
+
namePathIndex: namePathIndex + Math.max(4, childrenIndex + propsIndex)
|
|
38159
|
+
});
|
|
38160
|
+
}
|
|
38161
|
+
if (!template) {
|
|
38162
|
+
throw new Error(`Expected template value for field ${item.name}`);
|
|
38163
|
+
}
|
|
38164
|
+
return {
|
|
38165
|
+
...template,
|
|
38166
|
+
name: templateName,
|
|
38167
|
+
fields: template.fields.map((field2) => {
|
|
38168
|
+
return {
|
|
38169
|
+
...field2,
|
|
38170
|
+
name: [templateName, field2.name].join(".")
|
|
38171
|
+
};
|
|
38172
|
+
})
|
|
38173
|
+
};
|
|
38174
|
+
}
|
|
38175
|
+
} else {
|
|
38176
|
+
const fieldName = [...namePath.slice(0, namePathIndex)].join(".");
|
|
38177
|
+
if (!fieldName) {
|
|
38178
|
+
return formOrObjectField;
|
|
38179
|
+
}
|
|
38180
|
+
return {
|
|
38181
|
+
...formOrObjectField,
|
|
38182
|
+
name: fieldName,
|
|
38183
|
+
fields: formOrObjectField.fields.map((field2) => {
|
|
38184
|
+
return {
|
|
38185
|
+
...field2,
|
|
38186
|
+
name: [fieldName, field2.name].join(".")
|
|
38187
|
+
};
|
|
38188
|
+
})
|
|
38189
|
+
};
|
|
38190
|
+
}
|
|
38191
|
+
}
|
|
38192
|
+
}
|
|
38059
38193
|
}
|
|
38060
|
-
|
|
38061
|
-
|
|
38062
|
-
|
|
38063
|
-
|
|
38064
|
-
|
|
38065
|
-
|
|
38066
|
-
const
|
|
38067
|
-
|
|
38068
|
-
const
|
|
38069
|
-
|
|
38070
|
-
|
|
38071
|
-
|
|
38072
|
-
|
|
38073
|
-
|
|
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
|
-
)
|
|
38088
|
-
}
|
|
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
|
-
)
|
|
38107
|
-
}
|
|
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" }
|
|
38194
|
+
function updateEverything(form, values) {
|
|
38195
|
+
Object.entries(values).forEach(([path3, value]) => {
|
|
38196
|
+
form.change(path3, value);
|
|
38197
|
+
});
|
|
38198
|
+
}
|
|
38199
|
+
function updateSelectively(form, values, prefix) {
|
|
38200
|
+
const activePath = form.getState().active;
|
|
38201
|
+
Object.entries(values).forEach(([name, value]) => {
|
|
38202
|
+
const path3 = prefix ? `${prefix}.${name}` : name;
|
|
38203
|
+
if (typeof value === "object") {
|
|
38204
|
+
if (typeof activePath === "string" && activePath.startsWith(path3)) {
|
|
38205
|
+
updateSelectively(form, value, path3);
|
|
38206
|
+
} else {
|
|
38207
|
+
form.change(path3, value);
|
|
38166
38208
|
}
|
|
38167
|
-
)
|
|
38168
|
-
|
|
38169
|
-
|
|
38170
|
-
|
|
38171
|
-
|
|
38172
|
-
|
|
38173
|
-
|
|
38174
|
-
|
|
38175
|
-
|
|
38176
|
-
|
|
38177
|
-
|
|
38178
|
-
|
|
38179
|
-
|
|
38180
|
-
|
|
38181
|
-
|
|
38182
|
-
|
|
38183
|
-
|
|
38184
|
-
),
|
|
38185
|
-
style: { fontFamily: "'Libre Baskerville', serif", fontWeight: "400" }
|
|
38209
|
+
} else if (path3 !== activePath) {
|
|
38210
|
+
form.change(path3, value);
|
|
38211
|
+
}
|
|
38212
|
+
});
|
|
38213
|
+
}
|
|
38214
|
+
function usePlugins(plugins2) {
|
|
38215
|
+
const cms = useCMS$1();
|
|
38216
|
+
let pluginArray;
|
|
38217
|
+
if (Array.isArray(plugins2)) {
|
|
38218
|
+
pluginArray = plugins2;
|
|
38219
|
+
} else {
|
|
38220
|
+
pluginArray = [plugins2];
|
|
38221
|
+
}
|
|
38222
|
+
React.useEffect(() => {
|
|
38223
|
+
pluginArray.forEach((plugin) => {
|
|
38224
|
+
if (plugin) {
|
|
38225
|
+
cms.plugins.add(plugin);
|
|
38186
38226
|
}
|
|
38187
|
-
)
|
|
38188
|
-
|
|
38189
|
-
|
|
38190
|
-
|
|
38191
|
-
|
|
38192
|
-
|
|
38193
|
-
|
|
38194
|
-
|
|
38195
|
-
|
|
38196
|
-
|
|
38197
|
-
|
|
38198
|
-
|
|
38199
|
-
|
|
38200
|
-
|
|
38201
|
-
|
|
38202
|
-
|
|
38203
|
-
|
|
38204
|
-
|
|
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
|
-
};
|
|
38227
|
+
});
|
|
38228
|
+
return () => {
|
|
38229
|
+
pluginArray.forEach((plugin) => {
|
|
38230
|
+
if (plugin) {
|
|
38231
|
+
cms.plugins.remove(plugin);
|
|
38232
|
+
}
|
|
38233
|
+
});
|
|
38234
|
+
};
|
|
38235
|
+
}, [cms.plugins, ...pluginArray]);
|
|
38236
|
+
}
|
|
38237
|
+
function useSubscribable(subscribable, cb) {
|
|
38238
|
+
const [, s2] = React.useState(0);
|
|
38239
|
+
React.useEffect(() => {
|
|
38240
|
+
return subscribable.subscribe(() => {
|
|
38241
|
+
s2((x) => x + 1);
|
|
38242
|
+
if (cb)
|
|
38243
|
+
cb();
|
|
38244
|
+
});
|
|
38245
|
+
});
|
|
38246
|
+
}
|
|
38237
38247
|
function FieldsBuilder({
|
|
38238
38248
|
form,
|
|
38239
38249
|
fields,
|
|
38240
38250
|
activeFieldName,
|
|
38241
|
-
hoveringFieldName,
|
|
38242
38251
|
padding = false
|
|
38243
38252
|
}) {
|
|
38244
38253
|
const cms = useCMS$1();
|
|
@@ -38256,7 +38265,6 @@ function FieldsBuilder({
|
|
|
38256
38265
|
key: field.name,
|
|
38257
38266
|
field,
|
|
38258
38267
|
activeFieldName,
|
|
38259
|
-
hoveringFieldName,
|
|
38260
38268
|
form,
|
|
38261
38269
|
fieldPlugins,
|
|
38262
38270
|
index
|
|
@@ -38269,8 +38277,7 @@ const InnerField = ({
|
|
|
38269
38277
|
form,
|
|
38270
38278
|
fieldPlugins,
|
|
38271
38279
|
index,
|
|
38272
|
-
activeFieldName
|
|
38273
|
-
hoveringFieldName
|
|
38280
|
+
activeFieldName
|
|
38274
38281
|
}) => {
|
|
38275
38282
|
React.useEffect(() => {
|
|
38276
38283
|
form.mutators.setFieldData(field.name, {
|
|
@@ -38293,9 +38300,6 @@ const InnerField = ({
|
|
|
38293
38300
|
format2 = plugin.format;
|
|
38294
38301
|
}
|
|
38295
38302
|
let isActiveField = field.name === activeFieldName;
|
|
38296
|
-
const isHoveringField = field.name === hoveringFieldName;
|
|
38297
|
-
const focusIntent = isActiveField;
|
|
38298
|
-
const hoverIntent = isHoveringField;
|
|
38299
38303
|
if (field.list && field.type === "string") {
|
|
38300
38304
|
if (activeFieldName) {
|
|
38301
38305
|
const activeFieldNameArray = activeFieldName.split(".");
|
|
@@ -38329,11 +38333,7 @@ const InnerField = ({
|
|
|
38329
38333
|
...fieldProps,
|
|
38330
38334
|
form: form.finalForm,
|
|
38331
38335
|
tinaForm: form,
|
|
38332
|
-
field: {
|
|
38333
|
-
...field,
|
|
38334
|
-
focusIntent,
|
|
38335
|
-
hoverIntent
|
|
38336
|
-
}
|
|
38336
|
+
field: { ...field, experimental_focusIntent: isActiveField }
|
|
38337
38337
|
}
|
|
38338
38338
|
);
|
|
38339
38339
|
}
|
|
@@ -38342,14 +38342,10 @@ const InnerField = ({
|
|
|
38342
38342
|
plugin.Component,
|
|
38343
38343
|
{
|
|
38344
38344
|
...fieldProps,
|
|
38345
|
-
|
|
38345
|
+
experimental_focusIntent: isActiveField,
|
|
38346
38346
|
form: form.finalForm,
|
|
38347
38347
|
tinaForm: form,
|
|
38348
|
-
field: {
|
|
38349
|
-
...field,
|
|
38350
|
-
focusIntent,
|
|
38351
|
-
hoverIntent
|
|
38352
|
-
},
|
|
38348
|
+
field: { ...field, experimental_focusIntent: isActiveField },
|
|
38353
38349
|
index
|
|
38354
38350
|
}
|
|
38355
38351
|
);
|
|
@@ -39414,7 +39410,7 @@ function AiFillWarning(props) {
|
|
|
39414
39410
|
function AiOutlineLoading(props) {
|
|
39415
39411
|
return GenIcon({ "tag": "svg", "attr": { "viewBox": "0 0 1024 1024" }, "child": [{ "tag": "path", "attr": { "d": "M988 548c-19.9 0-36-16.1-36-36 0-59.4-11.6-117-34.6-171.3a440.45 440.45 0 0 0-94.3-139.9 437.71 437.71 0 0 0-139.9-94.3C629 83.6 571.4 72 512 72c-19.9 0-36-16.1-36-36s16.1-36 36-36c69.1 0 136.2 13.5 199.3 40.3C772.3 66 827 103 874 150c47 47 83.9 101.8 109.7 162.7 26.7 63.1 40.2 130.2 40.2 199.3.1 19.9-16 36-35.9 36z" }, "child": [] }] })(props);
|
|
39416
39412
|
}
|
|
39417
|
-
const textFieldClasses = "shadow-inner focus:shadow-outline focus:border-
|
|
39413
|
+
const textFieldClasses = "shadow-inner focus:shadow-outline focus:border-blue-500 focus:outline-none block text-base placeholder:text-gray-300 px-3 py-2 text-gray-600 w-full bg-white border border-gray-200 transition-all ease-out duration-150 focus:text-gray-900 rounded";
|
|
39418
39414
|
const disabledClasses$1 = "opacity-50 pointer-events-none cursor-not-allowed";
|
|
39419
39415
|
const BaseTextField = React.forwardRef(({ className, disabled, ...rest }, ref) => {
|
|
39420
39416
|
return /* @__PURE__ */ React.createElement(
|
|
@@ -39432,7 +39428,7 @@ const TextArea = React.forwardRef(({ ...props }, ref) => {
|
|
|
39432
39428
|
"textarea",
|
|
39433
39429
|
{
|
|
39434
39430
|
...props,
|
|
39435
|
-
className: "shadow-inner text-base px-3 py-2 text-gray-600 resize-y focus:shadow-outline focus:
|
|
39431
|
+
className: "shadow-inner text-base px-3 py-2 text-gray-600 resize-y focus:shadow-outline focus:border-blue-500 block w-full border border-gray-200 focus:text-gray-900 rounded",
|
|
39436
39432
|
ref,
|
|
39437
39433
|
style: { minHeight: "160px" }
|
|
39438
39434
|
}
|
|
@@ -39891,7 +39887,7 @@ const Toggle = ({
|
|
|
39891
39887
|
/* @__PURE__ */ React.createElement("div", { className: "relative w-[48px] h-7 rounded-3xl bg-white shadow-inner border border-gray-200 pointer-events-none -ml-0.5" }, /* @__PURE__ */ React.createElement(
|
|
39892
39888
|
"span",
|
|
39893
39889
|
{
|
|
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-
|
|
39890
|
+
className: `absolute rounded-3xl left-0.5 top-1/2 w-[22px] h-[22px] shadow border transition-all ease-out duration-150 ${checked ? "bg-blue-500 border-blue-600" : "bg-gray-250 border-gray-300"}`,
|
|
39895
39891
|
style: {
|
|
39896
39892
|
transform: `translate3d(${checked ? "20px" : "0"}, -50%, 0)`
|
|
39897
39893
|
}
|
|
@@ -39965,7 +39961,7 @@ function MdOutlinePhotoLibrary(props) {
|
|
|
39965
39961
|
function MdOutlinePerson(props) {
|
|
39966
39962
|
return GenIcon({ "tag": "svg", "attr": { "viewBox": "0 0 24 24" }, "child": [{ "tag": "path", "attr": { "fill": "none", "d": "M0 0h24v24H0V0z" }, "child": [] }, { "tag": "path", "attr": { "d": "M12 6c1.1 0 2 .9 2 2s-.9 2-2 2-2-.9-2-2 .9-2 2-2m0 10c2.7 0 5.8 1.29 6 2H6c.23-.72 3.31-2 6-2m0-12C9.79 4 8 5.79 8 8s1.79 4 4 4 4-1.79 4-4-1.79-4-4-4zm0 10c-2.67 0-8 1.34-8 4v2h16v-2c0-2.66-5.33-4-8-4z" }, "child": [] }] })(props);
|
|
39967
39963
|
}
|
|
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-
|
|
39964
|
+
const selectFieldClasses = "shadow appearance-none h-full bg-white block pl-3 pr-8 py-2 truncate w-full text-base cursor-pointer border border-gray-200 focus:outline-none focus:shadow-outline focus:ring-blue-500 focus:border-blue-500 sm:text-sm rounded";
|
|
39969
39965
|
const Select$1 = ({
|
|
39970
39966
|
input,
|
|
39971
39967
|
field,
|
|
@@ -39975,12 +39971,10 @@ const Select$1 = ({
|
|
|
39975
39971
|
const selectOptions = options || field.options;
|
|
39976
39972
|
const ref = React.useRef(null);
|
|
39977
39973
|
React.useEffect(() => {
|
|
39978
|
-
|
|
39979
|
-
const shouldFocus = !!focusIntent;
|
|
39980
|
-
if (ref.current && shouldFocus) {
|
|
39974
|
+
if (ref.current && (field == null ? void 0 : field.experimental_focusIntent)) {
|
|
39981
39975
|
ref.current.focus();
|
|
39982
39976
|
}
|
|
39983
|
-
}, [field == null ? void 0 : field.
|
|
39977
|
+
}, [field == null ? void 0 : field.experimental_focusIntent, ref]);
|
|
39984
39978
|
return /* @__PURE__ */ React.createElement("div", { className: "relative group w-full h-fit md:w-auto" }, /* @__PURE__ */ React.createElement(
|
|
39985
39979
|
"select",
|
|
39986
39980
|
{
|
|
@@ -40062,7 +40056,7 @@ const RadioOption = ({ checked, htmlFor, children, ...props }) => /* @__PURE__ *
|
|
|
40062
40056
|
/* @__PURE__ */ React.createElement(
|
|
40063
40057
|
"span",
|
|
40064
40058
|
{
|
|
40065
|
-
className: `relative h-[19px] w-[19px] rounded border text-indigo-600 focus:ring-indigo-500 transition ease-out duration-150 ${checked ? "border-
|
|
40059
|
+
className: `relative h-[19px] w-[19px] rounded border text-indigo-600 focus:ring-indigo-500 transition ease-out duration-150 ${checked ? "border-blue-500 bg-blue-500 shadow-sm group-hover:bg-blue-400 group-hover:border-blue-400" : "border-gray-200 bg-white shadow-inner group-hover:bg-gray-100"}`
|
|
40066
40060
|
},
|
|
40067
40061
|
/* @__PURE__ */ React.createElement(
|
|
40068
40062
|
BiCheck,
|
|
@@ -40123,7 +40117,7 @@ const CheckboxGroup = ({
|
|
|
40123
40117
|
/* @__PURE__ */ React.createElement(
|
|
40124
40118
|
"span",
|
|
40125
40119
|
{
|
|
40126
|
-
className: `relative h-[18px] w-[18px] rounded border text-indigo-600 focus:ring-indigo-500 transition ease-out duration-150 ${checked ? "border-
|
|
40120
|
+
className: `relative h-[18px] w-[18px] rounded border text-indigo-600 focus:ring-indigo-500 transition ease-out duration-150 ${checked ? "border-blue-500 bg-blue-500 shadow-sm group-hover:bg-blue-400 group-hover:border-blue-400" : "border-gray-200 bg-white shadow-inner group-hover:bg-gray-100"}`
|
|
40127
40121
|
},
|
|
40128
40122
|
/* @__PURE__ */ React.createElement(
|
|
40129
40123
|
BiCheck,
|
|
@@ -40254,7 +40248,7 @@ const ImageUpload = React.forwardRef(({ onDrop, onClear, onClick, value, src, lo
|
|
|
40254
40248
|
/* @__PURE__ */ React.createElement(
|
|
40255
40249
|
"button",
|
|
40256
40250
|
{
|
|
40257
|
-
className: "flex-shrink min-w-0 focus-within:shadow-outline focus-within:border-
|
|
40251
|
+
className: "flex-shrink min-w-0 focus-within:shadow-outline focus-within:border-blue-500 rounded outline-none overflow-visible cursor-pointer border-none hover:opacity-60 transition ease-out duration-100",
|
|
40258
40252
|
onClick,
|
|
40259
40253
|
ref
|
|
40260
40254
|
},
|
|
@@ -40755,7 +40749,7 @@ function toProps(option) {
|
|
|
40755
40749
|
return option;
|
|
40756
40750
|
return { value: option, label: option };
|
|
40757
40751
|
}
|
|
40758
|
-
const passwordFieldClasses = "shadow-inner focus:shadow-outline focus:border-
|
|
40752
|
+
const passwordFieldClasses = "shadow-inner focus:shadow-outline focus:border-blue-500 focus:outline-none block text-base placeholder:text-gray-300 px-3 py-2 text-gray-600 w-full bg-white border border-gray-200 transition-all ease-out duration-150 focus:text-gray-900 rounded";
|
|
40759
40753
|
const disabledClasses = "opacity-50 pointer-events-none cursor-not-allowed";
|
|
40760
40754
|
const errorClasses = "border-red-500 focus:border-red-500 focus:shadow-outline-red";
|
|
40761
40755
|
const BasePasswordField = React.forwardRef(({ className, disabled, error: error2, ...rest }, ref) => {
|
|
@@ -41128,7 +41122,7 @@ const Header = ({ onClick, children }) => {
|
|
|
41128
41122
|
"button",
|
|
41129
41123
|
{
|
|
41130
41124
|
onClick,
|
|
41131
|
-
className: "group px-4 py-3 bg-white hover:bg-gray-50 shadow focus:shadow-outline focus:border-
|
|
41125
|
+
className: "group px-4 py-3 bg-white hover:bg-gray-50 shadow focus:shadow-outline focus:border-blue-500 w-full border border-gray-100 hover:border-gray-200 text-gray-500 hover:text-blue-400 focus:text-blue-500 rounded flex justify-between items-center gap-2"
|
|
41132
41126
|
},
|
|
41133
41127
|
/* @__PURE__ */ React.createElement("span", { className: "text-left text-base font-medium overflow-hidden text-ellipsis whitespace-nowrap flex-1" }, children),
|
|
41134
41128
|
" ",
|
|
@@ -41280,7 +41274,7 @@ const BlockSelectorBig = ({
|
|
|
41280
41274
|
"input",
|
|
41281
41275
|
{
|
|
41282
41276
|
type: "text",
|
|
41283
|
-
className: "shadow-inner focus:shadow-outline focus:border-
|
|
41277
|
+
className: "shadow-inner focus:shadow-outline focus:border-blue-400 focus:outline-none block text-sm pl-2.5 pr-8 py-1.5 text-gray-600 w-full bg-white border border-gray-200 focus:text-gray-900 rounded placeholder-gray-400 hover:placeholder-gray-600 transition-all ease-out duration-150",
|
|
41284
41278
|
onClick: (event) => {
|
|
41285
41279
|
event.stopPropagation();
|
|
41286
41280
|
event.preventDefault();
|
|
@@ -41733,12 +41727,10 @@ const ImageField = wrapFieldsWithMeta(
|
|
|
41733
41727
|
onClear = () => props.input.onChange("");
|
|
41734
41728
|
}
|
|
41735
41729
|
React.useEffect(() => {
|
|
41736
|
-
|
|
41737
|
-
const shouldFocus = !!focusIntent;
|
|
41738
|
-
if (ref.current && shouldFocus) {
|
|
41730
|
+
if (ref.current && props.field.experimental_focusIntent) {
|
|
41739
41731
|
ref.current.focus();
|
|
41740
41732
|
}
|
|
41741
|
-
}, [props.field.
|
|
41733
|
+
}, [props.field.experimental_focusIntent, ref]);
|
|
41742
41734
|
async function onChange(media) {
|
|
41743
41735
|
var _a2, _b;
|
|
41744
41736
|
if (media) {
|
|
@@ -41864,14 +41856,12 @@ const RadioGroupFieldPlugin = {
|
|
|
41864
41856
|
const TextareaField = wrapFieldsWithMeta((props) => {
|
|
41865
41857
|
const ref = React.useRef(null);
|
|
41866
41858
|
React.useEffect(() => {
|
|
41867
|
-
|
|
41868
|
-
const shouldFocus = !!focusIntent;
|
|
41869
|
-
if (ref.current && shouldFocus) {
|
|
41859
|
+
if (ref.current && props.field.experimental_focusIntent) {
|
|
41870
41860
|
const el = ref.current;
|
|
41871
41861
|
el.focus();
|
|
41872
41862
|
el.setSelectionRange(el.value.length, el.value.length);
|
|
41873
41863
|
}
|
|
41874
|
-
}, [props.field.
|
|
41864
|
+
}, [props.field.experimental_focusIntent, ref]);
|
|
41875
41865
|
return /* @__PURE__ */ React.createElement(TextArea, { ref, ...props.input });
|
|
41876
41866
|
});
|
|
41877
41867
|
const TextareaFieldPlugin = {
|
|
@@ -41932,12 +41922,10 @@ const TextField = wrapFieldsWithMeta(
|
|
|
41932
41922
|
var _a2;
|
|
41933
41923
|
const ref = React.useRef(null);
|
|
41934
41924
|
React.useEffect(() => {
|
|
41935
|
-
|
|
41936
|
-
const shouldFocus = !!focusIntent;
|
|
41937
|
-
if (ref.current && shouldFocus) {
|
|
41925
|
+
if (ref.current && props.field.experimental_focusIntent) {
|
|
41938
41926
|
ref.current.focus();
|
|
41939
41927
|
}
|
|
41940
|
-
}, [props.field.
|
|
41928
|
+
}, [props.field.experimental_focusIntent, ref]);
|
|
41941
41929
|
return /* @__PURE__ */ React.createElement(
|
|
41942
41930
|
BaseTextField,
|
|
41943
41931
|
{
|
|
@@ -41997,12 +41985,10 @@ const TagsField = wrapFieldsWithMeta(({ input, field, form, tinaForm }) => {
|
|
|
41997
41985
|
const items2 = input.value || [];
|
|
41998
41986
|
const ref = React.useRef(null);
|
|
41999
41987
|
React.useEffect(() => {
|
|
42000
|
-
|
|
42001
|
-
const shouldFocus = !!focusIntent;
|
|
42002
|
-
if (ref.current && shouldFocus) {
|
|
41988
|
+
if (ref.current && field.experimental_focusIntent) {
|
|
42003
41989
|
ref.current.focus();
|
|
42004
41990
|
}
|
|
42005
|
-
}, [field.
|
|
41991
|
+
}, [field.experimental_focusIntent, ref]);
|
|
42006
41992
|
return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("div", { className: "flex items-center gap-3" }, /* @__PURE__ */ React.createElement(
|
|
42007
41993
|
BaseTextField,
|
|
42008
41994
|
{
|
|
@@ -42921,7 +42907,10 @@ const formatCurrentDate = ({
|
|
|
42921
42907
|
if (!dateFormat) {
|
|
42922
42908
|
return format$1(displayDate, timeFormat);
|
|
42923
42909
|
}
|
|
42924
|
-
return `${format$1(displayDate, dateFormat)} ${format$1(
|
|
42910
|
+
return `${format$1(displayDate, dateFormat)} ${format$1(
|
|
42911
|
+
displayDate,
|
|
42912
|
+
timeFormat
|
|
42913
|
+
)}`;
|
|
42925
42914
|
};
|
|
42926
42915
|
function Calendar({
|
|
42927
42916
|
className,
|
|
@@ -43323,7 +43312,8 @@ const DateTimePicker = React.forwardRef(
|
|
|
43323
43312
|
}),
|
|
43324
43313
|
[displayDate]
|
|
43325
43314
|
);
|
|
43326
|
-
const
|
|
43315
|
+
const localeAny = locale;
|
|
43316
|
+
const { options, localize: localize2, formatLong: formatLong2 } = localeAny || {};
|
|
43327
43317
|
if (options && localize2 && formatLong2) {
|
|
43328
43318
|
({
|
|
43329
43319
|
...enUS,
|
|
@@ -43397,11 +43387,11 @@ const DateField = wrapFieldsWithMeta(
|
|
|
43397
43387
|
const granularity = timeFormat ? "minute" : "day";
|
|
43398
43388
|
const inputRef = React__default.useRef(null);
|
|
43399
43389
|
React__default.useEffect(() => {
|
|
43400
|
-
if (inputRef.current && rest.
|
|
43390
|
+
if (inputRef.current && rest.experimental_focusIntent) {
|
|
43401
43391
|
inputRef.current.focus();
|
|
43402
43392
|
inputRef.current.open();
|
|
43403
43393
|
}
|
|
43404
|
-
}, [rest.
|
|
43394
|
+
}, [rest.experimental_focusIntent]);
|
|
43405
43395
|
const getTimeFormat = useCallback(() => {
|
|
43406
43396
|
if (timeFormat === false) {
|
|
43407
43397
|
return;
|
|
@@ -44016,9 +44006,20 @@ const EditoralBranchSwitcher = ({
|
|
|
44016
44006
|
) : /* @__PURE__ */ React.createElement("div", { className: "px-6 py-8 w-full h-full flex flex-col items-center justify-center" }, /* @__PURE__ */ React.createElement("p", { className: "text-base mb-4 text-center" }, "An error occurred while retrieving the branch list."), /* @__PURE__ */ React.createElement(Button$2, { className: "mb-4", onClick: refreshBranchList }, "Try again ", /* @__PURE__ */ React.createElement(BiRefresh, { className: "w-6 h-full ml-1 opacity-70" }))))));
|
|
44017
44007
|
};
|
|
44018
44008
|
const getFilteredBranchList = (branchList, search, currentBranchName, filter2 = "all") => {
|
|
44019
|
-
const filteredBranchList = branchList.filter(
|
|
44020
|
-
(
|
|
44021
|
-
|
|
44009
|
+
const filteredBranchList = branchList.filter((branch) => {
|
|
44010
|
+
if (!search)
|
|
44011
|
+
return true;
|
|
44012
|
+
if (branch.name === currentBranchName)
|
|
44013
|
+
return true;
|
|
44014
|
+
const searchLower = search.toLowerCase();
|
|
44015
|
+
const nameMatch = branch.name.toLowerCase().includes(searchLower);
|
|
44016
|
+
let prMatch = false;
|
|
44017
|
+
if (branch.githubPullRequestUrl) {
|
|
44018
|
+
const prId = extractPullRequestId(branch.githubPullRequestUrl);
|
|
44019
|
+
prMatch = prId.toLowerCase().includes(searchLower);
|
|
44020
|
+
}
|
|
44021
|
+
return nameMatch || prMatch;
|
|
44022
|
+
}).filter((branch) => {
|
|
44022
44023
|
if (branch.protected)
|
|
44023
44024
|
return true;
|
|
44024
44025
|
if (filter2 === "all")
|
|
@@ -44122,7 +44123,7 @@ const BranchSelector = ({
|
|
|
44122
44123
|
), /* @__PURE__ */ React.createElement("div", { className: "block relative group h-fit mb-auto" }, /* @__PURE__ */ React.createElement(
|
|
44123
44124
|
BaseTextField,
|
|
44124
44125
|
{
|
|
44125
|
-
placeholder: "
|
|
44126
|
+
placeholder: "Branch name or PR #",
|
|
44126
44127
|
value: search,
|
|
44127
44128
|
onChange: (e3) => setSearch(e3.target.value)
|
|
44128
44129
|
}
|
|
@@ -46531,7 +46532,7 @@ const NavProvider = ({
|
|
|
46531
46532
|
};
|
|
46532
46533
|
return /* @__PURE__ */ React__default.createElement(NavContext.Provider, { value }, children);
|
|
46533
46534
|
};
|
|
46534
|
-
const version$1 = "3.
|
|
46535
|
+
const version$1 = "3.3.1";
|
|
46535
46536
|
const VersionInfo = () => {
|
|
46536
46537
|
var _a2, _b, _c, _d, _e, _f;
|
|
46537
46538
|
const cms = useCMS();
|
|
@@ -47991,25 +47992,6 @@ class TinaCMS extends CMS {
|
|
|
47991
47992
|
});
|
|
47992
47993
|
}
|
|
47993
47994
|
}
|
|
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
|
-
};
|
|
48013
47995
|
const initialState = (cms) => {
|
|
48014
47996
|
var _a2;
|
|
48015
47997
|
return {
|
|
@@ -48025,24 +48007,24 @@ const initialState = (cms) => {
|
|
|
48025
48007
|
};
|
|
48026
48008
|
function tinaReducer(state, action) {
|
|
48027
48009
|
switch (action.type) {
|
|
48028
|
-
case
|
|
48010
|
+
case "set-quick-editing-supported":
|
|
48029
48011
|
return {
|
|
48030
48012
|
...state,
|
|
48031
48013
|
quickEditSupported: action.value
|
|
48032
48014
|
};
|
|
48033
|
-
case
|
|
48015
|
+
case "set-edit-mode":
|
|
48034
48016
|
return { ...state, editingMode: action.value };
|
|
48035
|
-
case
|
|
48017
|
+
case "forms:add":
|
|
48036
48018
|
if (state.forms.find((f2) => f2.tinaForm.id === action.value.id)) {
|
|
48037
48019
|
return state;
|
|
48038
48020
|
}
|
|
48039
48021
|
return { ...state, forms: [...state.forms, { tinaForm: action.value }] };
|
|
48040
|
-
case
|
|
48022
|
+
case "forms:remove":
|
|
48041
48023
|
return {
|
|
48042
48024
|
...state,
|
|
48043
48025
|
forms: state.forms.filter((form) => form.tinaForm.id !== action.value)
|
|
48044
48026
|
};
|
|
48045
|
-
case
|
|
48027
|
+
case "form-lists:clear": {
|
|
48046
48028
|
return {
|
|
48047
48029
|
...state,
|
|
48048
48030
|
quickEditSupported: false,
|
|
@@ -48052,7 +48034,7 @@ function tinaReducer(state, action) {
|
|
|
48052
48034
|
forms: []
|
|
48053
48035
|
};
|
|
48054
48036
|
}
|
|
48055
|
-
case
|
|
48037
|
+
case "form-lists:add": {
|
|
48056
48038
|
let formListItemExists = false;
|
|
48057
48039
|
const nextFormLists = state.formLists.map((formList) => {
|
|
48058
48040
|
if (formList.id === action.value.id) {
|
|
@@ -48091,7 +48073,7 @@ function tinaReducer(state, action) {
|
|
|
48091
48073
|
isLoadingContent: false
|
|
48092
48074
|
};
|
|
48093
48075
|
}
|
|
48094
|
-
case
|
|
48076
|
+
case "form-lists:remove": {
|
|
48095
48077
|
const nextFormLists = state.formLists.filter(
|
|
48096
48078
|
({ id: id2 }) => id2 !== action.value
|
|
48097
48079
|
);
|
|
@@ -48115,7 +48097,7 @@ function tinaReducer(state, action) {
|
|
|
48115
48097
|
formLists: nextFormLists
|
|
48116
48098
|
};
|
|
48117
48099
|
}
|
|
48118
|
-
case
|
|
48100
|
+
case "forms:set-active-form-id":
|
|
48119
48101
|
if (action.value !== state.activeFormId) {
|
|
48120
48102
|
const newActiveForm = state.forms.find(
|
|
48121
48103
|
(form) => form.tinaForm.id === action.value
|
|
@@ -48132,7 +48114,7 @@ function tinaReducer(state, action) {
|
|
|
48132
48114
|
};
|
|
48133
48115
|
}
|
|
48134
48116
|
return state;
|
|
48135
|
-
case
|
|
48117
|
+
case "forms:set-active-field-name":
|
|
48136
48118
|
if (state.activeFormId === action.value.formId) {
|
|
48137
48119
|
const existingForm = state.forms.find(
|
|
48138
48120
|
(form) => form.tinaForm.id === action.value.formId
|
|
@@ -48145,8 +48127,7 @@ function tinaReducer(state, action) {
|
|
|
48145
48127
|
if (form.tinaForm.id === action.value.formId) {
|
|
48146
48128
|
return {
|
|
48147
48129
|
tinaForm: form.tinaForm,
|
|
48148
|
-
activeFieldName: action.value.fieldName
|
|
48149
|
-
hoveringFieldName: null
|
|
48130
|
+
activeFieldName: action.value.fieldName
|
|
48150
48131
|
};
|
|
48151
48132
|
}
|
|
48152
48133
|
return form;
|
|
@@ -48162,49 +48143,13 @@ function tinaReducer(state, action) {
|
|
|
48162
48143
|
forms,
|
|
48163
48144
|
activeFormId: action.value.formId
|
|
48164
48145
|
};
|
|
48165
|
-
case
|
|
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: {
|
|
48146
|
+
case "toggle-edit-state": {
|
|
48202
48147
|
return state.sidebarDisplayState === "closed" ? { ...state, sidebarDisplayState: "open" } : {
|
|
48203
48148
|
...state,
|
|
48204
48149
|
sidebarDisplayState: "closed"
|
|
48205
48150
|
};
|
|
48206
48151
|
}
|
|
48207
|
-
case
|
|
48152
|
+
case "sidebar:set-display-state": {
|
|
48208
48153
|
if (action.value === "openOrFull") {
|
|
48209
48154
|
if (state.sidebarDisplayState === "closed") {
|
|
48210
48155
|
return {
|
|
@@ -48222,7 +48167,7 @@ function tinaReducer(state, action) {
|
|
|
48222
48167
|
}
|
|
48223
48168
|
return { ...state, sidebarDisplayState: action.value };
|
|
48224
48169
|
}
|
|
48225
|
-
case
|
|
48170
|
+
case "sidebar:set-loading-state": {
|
|
48226
48171
|
return { ...state, isLoadingContent: action.value };
|
|
48227
48172
|
}
|
|
48228
48173
|
default:
|
|
@@ -48491,12 +48436,10 @@ const AboveViewportIndicator = () => {
|
|
|
48491
48436
|
const BelowViewportIndicator = () => {
|
|
48492
48437
|
return /* @__PURE__ */ React.createElement(IndicatorWrap, { position: "bottom" }, /* @__PURE__ */ React.createElement(ArrowWrap, null, /* @__PURE__ */ React.createElement(ChevronDownIcon, { className: "w-8 h-auto" })));
|
|
48493
48438
|
};
|
|
48494
|
-
const useScrollToFocusedField = (
|
|
48439
|
+
const useScrollToFocusedField = () => {
|
|
48495
48440
|
const { subscribe } = useEvent("field:focus");
|
|
48496
|
-
React.useEffect(
|
|
48497
|
-
|
|
48498
|
-
return;
|
|
48499
|
-
return subscribe(({ fieldName }) => {
|
|
48441
|
+
React.useEffect(
|
|
48442
|
+
() => subscribe(({ fieldName }) => {
|
|
48500
48443
|
const ele = document.querySelector(
|
|
48501
48444
|
`[data-tinafield="${fieldName}"]`
|
|
48502
48445
|
);
|
|
@@ -48532,41 +48475,17 @@ const useScrollToFocusedField = (enabled) => {
|
|
|
48532
48475
|
});
|
|
48533
48476
|
}
|
|
48534
48477
|
}
|
|
48535
|
-
})
|
|
48536
|
-
|
|
48478
|
+
})
|
|
48479
|
+
);
|
|
48537
48480
|
};
|
|
48538
|
-
const
|
|
48539
|
-
|
|
48540
|
-
|
|
48541
|
-
|
|
48542
|
-
}) => {
|
|
48543
|
-
const [fieldName, setFieldName] = React.useState(null);
|
|
48481
|
+
const ActiveFieldIndicator = () => {
|
|
48482
|
+
const [activeFieldName, setActiveFieldName] = React.useState(
|
|
48483
|
+
null
|
|
48484
|
+
);
|
|
48544
48485
|
const [display, setDisplay] = React.useState(false);
|
|
48545
48486
|
const [position, setPosition] = React.useState(false);
|
|
48546
48487
|
const [iframePosition, setIframePosition] = React.useState({ left: 0 });
|
|
48547
|
-
const
|
|
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]);
|
|
48488
|
+
const activeEle = useFieldReference(activeFieldName);
|
|
48570
48489
|
React.useEffect(() => {
|
|
48571
48490
|
let displayTimeout;
|
|
48572
48491
|
if (activeEle) {
|
|
@@ -48595,7 +48514,13 @@ const FieldIndicator = ({
|
|
|
48595
48514
|
window.removeEventListener("scroll", rerender);
|
|
48596
48515
|
};
|
|
48597
48516
|
}, []);
|
|
48598
|
-
|
|
48517
|
+
const { subscribe } = useEvent("field:hover");
|
|
48518
|
+
React.useEffect(
|
|
48519
|
+
() => subscribe(({ fieldName, id: id2 }) => {
|
|
48520
|
+
setActiveFieldName(`${id2}#${fieldName}`);
|
|
48521
|
+
})
|
|
48522
|
+
);
|
|
48523
|
+
useScrollToFocusedField();
|
|
48599
48524
|
if (!display)
|
|
48600
48525
|
return null;
|
|
48601
48526
|
const eleTopY = position.top + window.scrollY;
|
|
@@ -48608,7 +48533,6 @@ const FieldIndicator = ({
|
|
|
48608
48533
|
if (eleBottomY < viewportTopY) {
|
|
48609
48534
|
return /* @__PURE__ */ React.createElement(AboveViewportIndicator, null);
|
|
48610
48535
|
}
|
|
48611
|
-
const outlineColor = checkFocusedAttribute && isFocused2 ? "2px dashed #C2410C" : "2px dashed var(--tina-color-indicator)";
|
|
48612
48536
|
return /* @__PURE__ */ React.createElement(
|
|
48613
48537
|
"div",
|
|
48614
48538
|
{
|
|
@@ -48619,7 +48543,7 @@ const FieldIndicator = ({
|
|
|
48619
48543
|
left: position.left + window.scrollX + iframePosition.left,
|
|
48620
48544
|
width: position.width,
|
|
48621
48545
|
height: position.height,
|
|
48622
|
-
outline:
|
|
48546
|
+
outline: "2px dashed var(--tina-color-indicator)",
|
|
48623
48547
|
borderRadius: "var(--tina-radius-small)",
|
|
48624
48548
|
transition: display ? activeEle ? `opacity 300ms ease-out` : `opacity 150ms ease-in` : `none`,
|
|
48625
48549
|
opacity: activeEle && display ? 0.8 : 0
|
|
@@ -48627,15 +48551,6 @@ const FieldIndicator = ({
|
|
|
48627
48551
|
}
|
|
48628
48552
|
);
|
|
48629
48553
|
};
|
|
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" });
|
|
48639
48554
|
const TinaUI = ({ children, position }) => {
|
|
48640
48555
|
const cms = useCMS();
|
|
48641
48556
|
const [resizingSidebar, setResizingSidebar] = React.useState(false);
|
|
@@ -48647,7 +48562,7 @@ const TinaUI = ({ children, position }) => {
|
|
|
48647
48562
|
position,
|
|
48648
48563
|
sidebar: cms.sidebar
|
|
48649
48564
|
}
|
|
48650
|
-
), /* @__PURE__ */ React.createElement(ActiveFieldIndicator, null), /* @__PURE__ */ React.createElement(
|
|
48565
|
+
), /* @__PURE__ */ React.createElement(ActiveFieldIndicator, null), /* @__PURE__ */ React.createElement("div", { className: `${resizingSidebar ? "pointer-events-none" : ""}` }, children)));
|
|
48651
48566
|
};
|
|
48652
48567
|
const TinaProvider = ({
|
|
48653
48568
|
cms,
|
|
@@ -52345,7 +52260,7 @@ const nld = [
|
|
|
52345
52260
|
"in",
|
|
52346
52261
|
"is",
|
|
52347
52262
|
"ja",
|
|
52348
|
-
"je
|
|
52263
|
+
"je",
|
|
52349
52264
|
"kan",
|
|
52350
52265
|
"kon",
|
|
52351
52266
|
"kunnen",
|
|
@@ -63635,195 +63550,202 @@ var __publicField2 = (obj, key, value) => {
|
|
|
63635
63550
|
__defNormalProp2(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
63636
63551
|
return value;
|
|
63637
63552
|
};
|
|
63553
|
+
const INDEXABLE_NODE_TYPES = ["text", "code_block", "html"];
|
|
63638
63554
|
class StringBuilder {
|
|
63639
63555
|
constructor(limit) {
|
|
63640
|
-
__publicField2(this, "buffer");
|
|
63641
|
-
__publicField2(this, "length", 0);
|
|
63556
|
+
__publicField2(this, "buffer", []);
|
|
63642
63557
|
__publicField2(this, "limit");
|
|
63643
|
-
this
|
|
63558
|
+
__publicField2(this, "length", 0);
|
|
63644
63559
|
this.limit = limit;
|
|
63645
63560
|
}
|
|
63646
63561
|
append(str) {
|
|
63647
|
-
if (this.length + str.length > this.limit)
|
|
63562
|
+
if (this.length + str.length > this.limit)
|
|
63648
63563
|
return true;
|
|
63649
|
-
|
|
63650
|
-
|
|
63651
|
-
|
|
63652
|
-
if (this.length > this.limit) {
|
|
63653
|
-
return true;
|
|
63654
|
-
}
|
|
63655
|
-
return false;
|
|
63656
|
-
}
|
|
63564
|
+
this.buffer.push(str);
|
|
63565
|
+
this.length += str.length;
|
|
63566
|
+
return this.length > this.limit;
|
|
63657
63567
|
}
|
|
63658
63568
|
toString() {
|
|
63659
63569
|
return this.buffer.join(" ");
|
|
63660
63570
|
}
|
|
63661
63571
|
}
|
|
63662
|
-
const
|
|
63663
|
-
|
|
63664
|
-
|
|
63665
|
-
|
|
63666
|
-
|
|
63667
|
-
|
|
63668
|
-
|
|
63669
|
-
|
|
63670
|
-
|
|
63671
|
-
|
|
63572
|
+
const tokenizeString = (str) => {
|
|
63573
|
+
return str.split(/[\s\.,]+/).map((s2) => s2.toLowerCase()).filter((s2) => s2);
|
|
63574
|
+
};
|
|
63575
|
+
const extractText = (data, builder, nodeTypes) => {
|
|
63576
|
+
var _a2;
|
|
63577
|
+
if (!data)
|
|
63578
|
+
return;
|
|
63579
|
+
if (nodeTypes.includes(data.type ?? "") && (data.text || data.value)) {
|
|
63580
|
+
const tokens = tokenizeString(data.text || data.value || "");
|
|
63581
|
+
for (const token of tokens) {
|
|
63582
|
+
if (builder.append(token))
|
|
63583
|
+
return;
|
|
63672
63584
|
}
|
|
63673
|
-
(_b = (_a2 = data.children) == null ? void 0 : _a2.forEach) == null ? void 0 : _b.call(
|
|
63674
|
-
_a2,
|
|
63675
|
-
(child) => extractText(child, acc, indexableNodeTypes)
|
|
63676
|
-
);
|
|
63677
63585
|
}
|
|
63586
|
+
(_a2 = data.children) == null ? void 0 : _a2.forEach((child) => extractText(child, builder, nodeTypes));
|
|
63678
63587
|
};
|
|
63679
|
-
const
|
|
63588
|
+
const getRelativePath = (path3, collection) => {
|
|
63680
63589
|
return path3.replace(/\\/g, "/").replace(collection.path, "").replace(/^\/|\/$/g, "");
|
|
63681
63590
|
};
|
|
63682
|
-
const
|
|
63683
|
-
return str.split(/[\s\.,]+/).map((s2) => s2.toLowerCase()).filter((s2) => s2);
|
|
63684
|
-
};
|
|
63685
|
-
const processTextFieldValue = (value, maxLen) => {
|
|
63591
|
+
const processTextField = (value, maxLength) => {
|
|
63686
63592
|
const tokens = tokenizeString(value);
|
|
63687
|
-
const builder = new StringBuilder(
|
|
63593
|
+
const builder = new StringBuilder(maxLength);
|
|
63688
63594
|
for (const part of tokens) {
|
|
63689
|
-
if (builder.append(part))
|
|
63595
|
+
if (builder.append(part))
|
|
63690
63596
|
break;
|
|
63691
|
-
}
|
|
63692
63597
|
}
|
|
63693
63598
|
return builder.toString();
|
|
63694
63599
|
};
|
|
63600
|
+
const processRichTextField = (value, maxLength) => {
|
|
63601
|
+
const builder = new StringBuilder(maxLength);
|
|
63602
|
+
extractText(value, builder, INDEXABLE_NODE_TYPES);
|
|
63603
|
+
return builder.toString();
|
|
63604
|
+
};
|
|
63605
|
+
const processObjectField = (data, path3, collection, textIndexLength, field) => {
|
|
63606
|
+
if (field.list) {
|
|
63607
|
+
return data.map(
|
|
63608
|
+
(obj) => processDocumentForIndexing(obj, path3, collection, textIndexLength, field)
|
|
63609
|
+
);
|
|
63610
|
+
}
|
|
63611
|
+
return processDocumentForIndexing(
|
|
63612
|
+
data,
|
|
63613
|
+
path3,
|
|
63614
|
+
collection,
|
|
63615
|
+
textIndexLength,
|
|
63616
|
+
field
|
|
63617
|
+
);
|
|
63618
|
+
};
|
|
63619
|
+
const processStringField = (data, maxLength, isList) => {
|
|
63620
|
+
if (isList) {
|
|
63621
|
+
return data.map(
|
|
63622
|
+
(value) => processTextField(value, maxLength)
|
|
63623
|
+
);
|
|
63624
|
+
}
|
|
63625
|
+
return processTextField(data, maxLength);
|
|
63626
|
+
};
|
|
63627
|
+
const processRichTextFieldData = (data, maxLength, isList) => {
|
|
63628
|
+
if (isList) {
|
|
63629
|
+
return data.map(
|
|
63630
|
+
(value) => processRichTextField(value, maxLength)
|
|
63631
|
+
);
|
|
63632
|
+
}
|
|
63633
|
+
return processRichTextField(data, maxLength);
|
|
63634
|
+
};
|
|
63695
63635
|
const processDocumentForIndexing = (data, path3, collection, textIndexLength, field) => {
|
|
63696
63636
|
if (!field) {
|
|
63697
|
-
const
|
|
63698
|
-
data["_id"] = `${collection.name}:${
|
|
63699
|
-
data["_relativePath"] =
|
|
63637
|
+
const relativePath = getRelativePath(path3, collection);
|
|
63638
|
+
data["_id"] = `${collection.name}:${relativePath}`;
|
|
63639
|
+
data["_relativePath"] = relativePath;
|
|
63700
63640
|
}
|
|
63701
|
-
|
|
63641
|
+
const fields = (field == null ? void 0 : field.fields) || collection.fields || [];
|
|
63642
|
+
for (const f2 of fields) {
|
|
63702
63643
|
if (!f2.searchable) {
|
|
63703
63644
|
delete data[f2.name];
|
|
63704
63645
|
continue;
|
|
63705
63646
|
}
|
|
63706
|
-
|
|
63707
|
-
|
|
63708
|
-
|
|
63709
|
-
|
|
63710
|
-
|
|
63711
|
-
|
|
63712
|
-
|
|
63713
|
-
|
|
63714
|
-
|
|
63715
|
-
|
|
63716
|
-
|
|
63717
|
-
|
|
63718
|
-
|
|
63719
|
-
|
|
63720
|
-
|
|
63721
|
-
|
|
63722
|
-
|
|
63723
|
-
|
|
63724
|
-
|
|
63725
|
-
|
|
63726
|
-
|
|
63727
|
-
|
|
63728
|
-
|
|
63729
|
-
|
|
63730
|
-
|
|
63731
|
-
|
|
63732
|
-
|
|
63733
|
-
|
|
63734
|
-
} else {
|
|
63735
|
-
data[f2.name] = processTextFieldValue(
|
|
63736
|
-
data[f2.name],
|
|
63737
|
-
fieldTextIndexLength
|
|
63738
|
-
);
|
|
63739
|
-
}
|
|
63740
|
-
} else if (f2.type === "rich-text") {
|
|
63741
|
-
const fieldTextIndexLength = f2.maxSearchIndexFieldLength || textIndexLength;
|
|
63742
|
-
if (isList) {
|
|
63743
|
-
data[f2.name] = data[f2.name].map((value) => {
|
|
63744
|
-
const acc = new StringBuilder(fieldTextIndexLength);
|
|
63745
|
-
extractText(value, acc, ["text", "code_block", "html"]);
|
|
63746
|
-
return acc.toString();
|
|
63747
|
-
});
|
|
63748
|
-
} else {
|
|
63749
|
-
const acc = new StringBuilder(fieldTextIndexLength);
|
|
63750
|
-
extractText(data[f2.name], acc, ["text", "code_block", "html"]);
|
|
63751
|
-
data[f2.name] = acc.toString();
|
|
63752
|
-
}
|
|
63753
|
-
}
|
|
63647
|
+
if (!data[f2.name])
|
|
63648
|
+
continue;
|
|
63649
|
+
const fieldMaxLength = f2.maxSearchIndexFieldLength || textIndexLength;
|
|
63650
|
+
const isList = Boolean(f2.list);
|
|
63651
|
+
switch (f2.type) {
|
|
63652
|
+
case "object":
|
|
63653
|
+
data[f2.name] = processObjectField(
|
|
63654
|
+
data[f2.name],
|
|
63655
|
+
path3,
|
|
63656
|
+
collection,
|
|
63657
|
+
textIndexLength,
|
|
63658
|
+
f2
|
|
63659
|
+
);
|
|
63660
|
+
break;
|
|
63661
|
+
case "string":
|
|
63662
|
+
data[f2.name] = processStringField(
|
|
63663
|
+
data[f2.name],
|
|
63664
|
+
fieldMaxLength,
|
|
63665
|
+
isList
|
|
63666
|
+
);
|
|
63667
|
+
break;
|
|
63668
|
+
case "rich-text":
|
|
63669
|
+
data[f2.name] = processRichTextFieldData(
|
|
63670
|
+
data[f2.name],
|
|
63671
|
+
fieldMaxLength,
|
|
63672
|
+
isList
|
|
63673
|
+
);
|
|
63674
|
+
break;
|
|
63754
63675
|
}
|
|
63755
63676
|
}
|
|
63756
63677
|
return data;
|
|
63757
63678
|
};
|
|
63758
|
-
const
|
|
63679
|
+
const stopwordCache = {};
|
|
63759
63680
|
const lookupStopwords = (keys2, defaultStopWords = eng) => {
|
|
63760
|
-
|
|
63761
|
-
|
|
63762
|
-
|
|
63763
|
-
|
|
63764
|
-
|
|
63765
|
-
|
|
63766
|
-
for (const key of keys2) {
|
|
63767
|
-
stopwords.push(...sw[key]);
|
|
63768
|
-
}
|
|
63769
|
-
memo[keys2.join(",")] = stopwords;
|
|
63681
|
+
if (!keys2) {
|
|
63682
|
+
return defaultStopWords;
|
|
63683
|
+
}
|
|
63684
|
+
const cacheKey = keys2.join(",");
|
|
63685
|
+
if (stopwordCache[cacheKey]) {
|
|
63686
|
+
return stopwordCache[cacheKey];
|
|
63770
63687
|
}
|
|
63688
|
+
const stopwords = keys2.flatMap((key) => sw[key] || []);
|
|
63689
|
+
stopwordCache[cacheKey] = stopwords;
|
|
63771
63690
|
return stopwords;
|
|
63772
63691
|
};
|
|
63773
63692
|
const queryToSearchIndexQuery = (query, stopwordLanguages) => {
|
|
63774
|
-
let q2;
|
|
63775
63693
|
const parts = query.split(" ");
|
|
63776
63694
|
const stopwords = lookupStopwords(stopwordLanguages);
|
|
63777
63695
|
if (parts.length === 1) {
|
|
63778
|
-
|
|
63779
|
-
} else {
|
|
63780
|
-
q2 = {
|
|
63781
|
-
AND: parts.filter(
|
|
63782
|
-
(part) => part.toLowerCase() !== "and" && stopwords.indexOf(part.toLowerCase()) === -1
|
|
63783
|
-
)
|
|
63784
|
-
};
|
|
63696
|
+
return { AND: [parts[0]] };
|
|
63785
63697
|
}
|
|
63786
|
-
|
|
63698
|
+
const filteredParts = parts.filter(
|
|
63699
|
+
(part) => part.toLowerCase() !== "and" && !stopwords.includes(part.toLowerCase())
|
|
63700
|
+
);
|
|
63701
|
+
return { AND: filteredParts };
|
|
63787
63702
|
};
|
|
63788
63703
|
const optionsToSearchIndexOptions = (options) => {
|
|
63789
|
-
|
|
63790
|
-
|
|
63791
|
-
|
|
63704
|
+
if (!(options == null ? void 0 : options.limit))
|
|
63705
|
+
return {};
|
|
63706
|
+
return {
|
|
63707
|
+
PAGE: {
|
|
63792
63708
|
SIZE: options.limit,
|
|
63793
|
-
NUMBER:
|
|
63794
|
-
}
|
|
63795
|
-
}
|
|
63796
|
-
return opt;
|
|
63709
|
+
NUMBER: options.cursor ? parseInt(options.cursor) : 0
|
|
63710
|
+
}
|
|
63711
|
+
};
|
|
63797
63712
|
};
|
|
63798
63713
|
const parseSearchIndexResponse = (data, options) => {
|
|
63799
|
-
const
|
|
63800
|
-
|
|
63801
|
-
if ((options == null ? void 0 : options.cursor) && (options == null ? void 0 : options.limit)) {
|
|
63802
|
-
const prevCursor = options.cursor === "0" ? null : (parseInt(options.cursor) - 1).toString();
|
|
63803
|
-
const nextCursor = total <= (parseInt(options.cursor) + 1) * options.limit ? null : (parseInt(options.cursor) + 1).toString();
|
|
63804
|
-
return {
|
|
63805
|
-
results,
|
|
63806
|
-
total,
|
|
63807
|
-
prevCursor,
|
|
63808
|
-
nextCursor
|
|
63809
|
-
};
|
|
63810
|
-
} else if (!(options == null ? void 0 : options.cursor) && (options == null ? void 0 : options.limit)) {
|
|
63811
|
-
const prevCursor = null;
|
|
63812
|
-
const nextCursor = total <= options.limit ? null : "1";
|
|
63714
|
+
const resultArray = (data == null ? void 0 : data.RESULT) ?? (data == null ? void 0 : data.results);
|
|
63715
|
+
if (!data || !Array.isArray(resultArray)) {
|
|
63813
63716
|
return {
|
|
63814
|
-
results,
|
|
63815
|
-
total,
|
|
63816
|
-
prevCursor,
|
|
63817
|
-
nextCursor
|
|
63717
|
+
results: [],
|
|
63718
|
+
total: 0,
|
|
63719
|
+
prevCursor: null,
|
|
63720
|
+
nextCursor: null,
|
|
63721
|
+
fuzzyMatches: void 0
|
|
63818
63722
|
};
|
|
63819
|
-
}
|
|
63723
|
+
}
|
|
63724
|
+
const results = data.RESULT ?? data.results;
|
|
63725
|
+
const total = data.RESULT_LENGTH ?? data.total ?? 0;
|
|
63726
|
+
const fuzzyMatches = data.FUZZY_MATCHES ?? data.fuzzyMatches;
|
|
63727
|
+
const nextCursor = data.NEXT_CURSOR ?? data.nextCursor;
|
|
63728
|
+
const prevCursor = data.PREV_CURSOR ?? data.prevCursor;
|
|
63729
|
+
if (nextCursor !== void 0 || prevCursor !== void 0) {
|
|
63820
63730
|
return {
|
|
63821
63731
|
results,
|
|
63822
63732
|
total,
|
|
63823
|
-
prevCursor: null,
|
|
63824
|
-
nextCursor: null
|
|
63733
|
+
prevCursor: prevCursor ?? null,
|
|
63734
|
+
nextCursor: nextCursor ?? null,
|
|
63735
|
+
fuzzyMatches
|
|
63825
63736
|
};
|
|
63826
63737
|
}
|
|
63738
|
+
const currentPage = (options == null ? void 0 : options.cursor) ? parseInt(options.cursor) : 0;
|
|
63739
|
+
const pageSize = options == null ? void 0 : options.limit;
|
|
63740
|
+
const hasPreviousPage = currentPage > 0;
|
|
63741
|
+
const hasNextPage = pageSize ? total > (currentPage + 1) * pageSize : false;
|
|
63742
|
+
return {
|
|
63743
|
+
results,
|
|
63744
|
+
total,
|
|
63745
|
+
prevCursor: hasPreviousPage ? (currentPage - 1).toString() : null,
|
|
63746
|
+
nextCursor: hasNextPage ? (currentPage + 1).toString() : null,
|
|
63747
|
+
fuzzyMatches
|
|
63748
|
+
};
|
|
63827
63749
|
};
|
|
63828
63750
|
const CREATE_DOCUMENT_GQL = `#graphql
|
|
63829
63751
|
mutation($collection: String!, $relativePath: String!, $params: DocumentMutation!) {
|
|
@@ -63879,7 +63801,7 @@ class TinaAdminApi {
|
|
|
63879
63801
|
fetchCollections() {
|
|
63880
63802
|
return this.schema.getCollections();
|
|
63881
63803
|
}
|
|
63882
|
-
async renameDocument({ collection, relativePath
|
|
63804
|
+
async renameDocument({ collection, relativePath, newRelativePath }) {
|
|
63883
63805
|
await this.api.request(
|
|
63884
63806
|
`#graphql
|
|
63885
63807
|
mutation RenameDocument($collection: String!, $relativePath: String! $newRelativePath: String!) {
|
|
@@ -63888,7 +63810,7 @@ class TinaAdminApi {
|
|
|
63888
63810
|
}
|
|
63889
63811
|
}
|
|
63890
63812
|
`,
|
|
63891
|
-
{ variables: { collection, relativePath
|
|
63813
|
+
{ variables: { collection, relativePath, newRelativePath } }
|
|
63892
63814
|
);
|
|
63893
63815
|
if (this.searchClient) {
|
|
63894
63816
|
const { document: doc } = await this.fetchDocument(
|
|
@@ -63902,18 +63824,18 @@ class TinaAdminApi {
|
|
|
63902
63824
|
this.maxSearchIndexFieldLength
|
|
63903
63825
|
);
|
|
63904
63826
|
await this.searchClient.put([processed]);
|
|
63905
|
-
await this.searchClient.del([`${collection.name}:${
|
|
63827
|
+
await this.searchClient.del([`${collection.name}:${relativePath}`]);
|
|
63906
63828
|
}
|
|
63907
63829
|
}
|
|
63908
63830
|
async deleteDocument({
|
|
63909
63831
|
collection,
|
|
63910
|
-
relativePath
|
|
63832
|
+
relativePath
|
|
63911
63833
|
}) {
|
|
63912
63834
|
var _a2;
|
|
63913
63835
|
await this.api.request(DELETE_DOCUMENT_GQL, {
|
|
63914
|
-
variables: { collection, relativePath
|
|
63836
|
+
variables: { collection, relativePath }
|
|
63915
63837
|
});
|
|
63916
|
-
await ((_a2 = this.searchClient) == null ? void 0 : _a2.del([`${collection}:${
|
|
63838
|
+
await ((_a2 = this.searchClient) == null ? void 0 : _a2.del([`${collection}:${relativePath}`]));
|
|
63917
63839
|
}
|
|
63918
63840
|
async fetchCollection(collectionName, includeDocuments, folder = "", after3, sortKey, order, filterArgs) {
|
|
63919
63841
|
let filter2 = null;
|
|
@@ -64068,7 +63990,7 @@ class TinaAdminApi {
|
|
|
64068
63990
|
}
|
|
64069
63991
|
}
|
|
64070
63992
|
}
|
|
64071
|
-
async fetchDocument(collectionName,
|
|
63993
|
+
async fetchDocument(collectionName, relativePath, values = true) {
|
|
64072
63994
|
let query;
|
|
64073
63995
|
if (values) {
|
|
64074
63996
|
query = `#graphql
|
|
@@ -64103,26 +64025,26 @@ class TinaAdminApi {
|
|
|
64103
64025
|
}`;
|
|
64104
64026
|
}
|
|
64105
64027
|
const response = await this.api.request(query, {
|
|
64106
|
-
variables: { collection: collectionName, relativePath
|
|
64028
|
+
variables: { collection: collectionName, relativePath }
|
|
64107
64029
|
});
|
|
64108
64030
|
return response;
|
|
64109
64031
|
}
|
|
64110
|
-
async createDocument(collection,
|
|
64032
|
+
async createDocument(collection, relativePath, params) {
|
|
64111
64033
|
const response = await this.api.request(CREATE_DOCUMENT_GQL, {
|
|
64112
64034
|
variables: {
|
|
64113
64035
|
collection: collection.name,
|
|
64114
|
-
relativePath
|
|
64036
|
+
relativePath,
|
|
64115
64037
|
params
|
|
64116
64038
|
}
|
|
64117
64039
|
});
|
|
64118
64040
|
if (this.searchClient) {
|
|
64119
64041
|
const { document: doc } = await this.fetchDocument(
|
|
64120
64042
|
collection.name,
|
|
64121
|
-
|
|
64043
|
+
relativePath
|
|
64122
64044
|
);
|
|
64123
64045
|
const processed = processDocumentForIndexing(
|
|
64124
64046
|
doc["_values"],
|
|
64125
|
-
`${collection.path}/${
|
|
64047
|
+
`${collection.path}/${relativePath}`,
|
|
64126
64048
|
collection,
|
|
64127
64049
|
this.maxSearchIndexFieldLength
|
|
64128
64050
|
);
|
|
@@ -64130,22 +64052,22 @@ class TinaAdminApi {
|
|
|
64130
64052
|
}
|
|
64131
64053
|
return response;
|
|
64132
64054
|
}
|
|
64133
|
-
async updateDocument(collection,
|
|
64055
|
+
async updateDocument(collection, relativePath, params) {
|
|
64134
64056
|
const response = await this.api.request(UPDATE_DOCUMENT_GQL, {
|
|
64135
64057
|
variables: {
|
|
64136
64058
|
collection: collection.name,
|
|
64137
|
-
relativePath
|
|
64059
|
+
relativePath,
|
|
64138
64060
|
params
|
|
64139
64061
|
}
|
|
64140
64062
|
});
|
|
64141
64063
|
if (this.searchClient) {
|
|
64142
64064
|
const { document: doc } = await this.fetchDocument(
|
|
64143
64065
|
collection.name,
|
|
64144
|
-
|
|
64066
|
+
relativePath
|
|
64145
64067
|
);
|
|
64146
64068
|
const processed = processDocumentForIndexing(
|
|
64147
64069
|
doc["_values"],
|
|
64148
|
-
`${collection.path}/${
|
|
64070
|
+
`${collection.path}/${relativePath}`,
|
|
64149
64071
|
collection,
|
|
64150
64072
|
this.maxSearchIndexFieldLength
|
|
64151
64073
|
);
|
|
@@ -64268,7 +64190,7 @@ const CreateBranchModal = ({
|
|
|
64268
64190
|
}
|
|
64269
64191
|
const collection = tinaApi.schema.getCollectionByFullPath(path3);
|
|
64270
64192
|
const params = tinaApi.schema.transformPayload(collection.name, values);
|
|
64271
|
-
const
|
|
64193
|
+
const relativePath = pathRelativeToCollection(collection.path, path3);
|
|
64272
64194
|
const result = await tinaApi.executeEditorialWorkflow({
|
|
64273
64195
|
branchName,
|
|
64274
64196
|
baseBranch: tinaApi.branch,
|
|
@@ -64277,7 +64199,7 @@ const CreateBranchModal = ({
|
|
|
64277
64199
|
query: graphql2,
|
|
64278
64200
|
variables: {
|
|
64279
64201
|
collection: collection.name,
|
|
64280
|
-
relativePath
|
|
64202
|
+
relativePath,
|
|
64281
64203
|
params
|
|
64282
64204
|
}
|
|
64283
64205
|
},
|
|
@@ -64309,7 +64231,7 @@ const CreateBranchModal = ({
|
|
|
64309
64231
|
0
|
|
64310
64232
|
);
|
|
64311
64233
|
if (crudType === "create") {
|
|
64312
|
-
const folderPath =
|
|
64234
|
+
const folderPath = relativePath.includes("/") ? relativePath.substring(0, relativePath.lastIndexOf("/")) : "";
|
|
64313
64235
|
window.location.hash = `#/collections/${collection.name}${folderPath ? `/${folderPath}` : ""}`;
|
|
64314
64236
|
}
|
|
64315
64237
|
close2();
|
|
@@ -64616,7 +64538,6 @@ const FormBuilder = ({
|
|
|
64616
64538
|
{
|
|
64617
64539
|
form: tinaForm,
|
|
64618
64540
|
activeFieldName: form.activeFieldName,
|
|
64619
|
-
hoveringFieldName: form.hoveringFieldName,
|
|
64620
64541
|
fields: fieldGroup.fields
|
|
64621
64542
|
}
|
|
64622
64543
|
) : /* @__PURE__ */ React.createElement(NoFieldsPlaceholder, null))), !hideFooter && /* @__PURE__ */ React.createElement("div", { className: "relative flex-none w-full h-16 px-6 bg-white border-t border-gray-100 flex items-center justify-end" }, /* @__PURE__ */ React.createElement("div", { className: "flex-1 w-full justify-end gap-2 flex items-center max-w-form" }, tinaForm.reset && /* @__PURE__ */ React.createElement(
|
|
@@ -64676,7 +64597,7 @@ const Emoji = ({ className = "", ...props }) => /* @__PURE__ */ React.createElem
|
|
|
64676
64597
|
const CreateBranchModel = ({
|
|
64677
64598
|
close: close2,
|
|
64678
64599
|
safeSubmit,
|
|
64679
|
-
relativePath
|
|
64600
|
+
relativePath,
|
|
64680
64601
|
values,
|
|
64681
64602
|
crudType
|
|
64682
64603
|
}) => /* @__PURE__ */ React.createElement(
|
|
@@ -64684,7 +64605,7 @@ const CreateBranchModel = ({
|
|
|
64684
64605
|
{
|
|
64685
64606
|
close: close2,
|
|
64686
64607
|
safeSubmit,
|
|
64687
|
-
path:
|
|
64608
|
+
path: relativePath,
|
|
64688
64609
|
values,
|
|
64689
64610
|
crudType
|
|
64690
64611
|
}
|
|
@@ -64789,7 +64710,7 @@ const ImgEmbed = ({
|
|
|
64789
64710
|
"button",
|
|
64790
64711
|
{
|
|
64791
64712
|
type: "button",
|
|
64792
|
-
className: `flex-shrink min-w-0 focus-within:shadow-outline focus-within:border-
|
|
64713
|
+
className: `flex-shrink min-w-0 focus-within:shadow-outline focus-within:border-blue-500 rounded outline-none overflow-visible cursor-pointer border-none hover:opacity-60 transition ease-out duration-100 ${selected ? "shadow-outline border-blue-500" : ""}`,
|
|
64793
64714
|
onClick: handleSelect
|
|
64794
64715
|
},
|
|
64795
64716
|
isImage(element.url) ? /* @__PURE__ */ React__default.createElement(StyledImage, { src: element.url }) : /* @__PURE__ */ React__default.createElement(StyledFile, { src: element.url })
|
|
@@ -65045,7 +64966,7 @@ const DotMenu = ({ onOpen, onRemove }) => {
|
|
|
65045
64966
|
PopoverButton,
|
|
65046
64967
|
{
|
|
65047
64968
|
as: "span",
|
|
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-
|
|
64969
|
+
className: "cursor-pointer h-full relative inline-flex items-center px-1 py-0.5 rounded-r border border-gray-200 bg-white text-gray-500 hover:bg-gray-50 focus:outline-none focus:ring-1 focus:ring-blue-500 focus:border-blue-500"
|
|
65049
64970
|
},
|
|
65050
64971
|
/* @__PURE__ */ React__default.createElement(EllipsisIcon, { title: "Open options" })
|
|
65051
64972
|
), /* @__PURE__ */ React__default.createElement(
|
|
@@ -118967,13 +118888,13 @@ const RichEditor = ({ input, tinaForm, field }) => {
|
|
|
118967
118888
|
const plateElement = (_a3 = ref.current) == null ? void 0 : _a3.querySelector(
|
|
118968
118889
|
'[role="textbox"]'
|
|
118969
118890
|
);
|
|
118970
|
-
if (field.
|
|
118891
|
+
if (field.experimental_focusIntent && plateElement) {
|
|
118971
118892
|
if (plateElement)
|
|
118972
118893
|
plateElement.focus();
|
|
118973
118894
|
}
|
|
118974
118895
|
}, 100);
|
|
118975
118896
|
}
|
|
118976
|
-
}, [field.
|
|
118897
|
+
}, [field.experimental_focusIntent, ref]);
|
|
118977
118898
|
return /* @__PURE__ */ React__default.createElement("div", { ref }, /* @__PURE__ */ React__default.createElement(
|
|
118978
118899
|
Plate,
|
|
118979
118900
|
{
|
|
@@ -119064,7 +118985,7 @@ const MdxFieldPluginExtendible = {
|
|
|
119064
118985
|
/* @__PURE__ */ React__default.createElement(
|
|
119065
118986
|
"div",
|
|
119066
118987
|
{
|
|
119067
|
-
className: "min-h-[100px] max-w-full tina-prose relative shadow-inner focus-within:shadow-outline focus-within:border-
|
|
118988
|
+
className: "min-h-[100px] max-w-full tina-prose relative shadow-inner focus-within:shadow-outline focus-within:border-blue-500 block w-full bg-white border border-gray-200 text-gray-600 focus-within:text-gray-900 rounded pt-0 py-2"
|
|
119068
118989
|
},
|
|
119069
118990
|
props.rawMode ? props.rawEditor : /* @__PURE__ */ React__default.createElement(RichEditor, { ...props })
|
|
119070
118991
|
)
|
|
@@ -119904,44 +119825,68 @@ class LocalClient extends Client {
|
|
|
119904
119825
|
}
|
|
119905
119826
|
class TinaCMSSearchClient {
|
|
119906
119827
|
constructor(client, tinaSearchConfig) {
|
|
119828
|
+
__publicField(this, "client");
|
|
119829
|
+
__publicField(this, "fuzzyEnabled");
|
|
119830
|
+
__publicField(this, "stopwordLanguages");
|
|
119831
|
+
__publicField(this, "defaultFuzzyOptions");
|
|
119907
119832
|
this.client = client;
|
|
119908
|
-
this.
|
|
119833
|
+
this.fuzzyEnabled = (tinaSearchConfig == null ? void 0 : tinaSearchConfig.fuzzyEnabled) ?? true;
|
|
119834
|
+
this.stopwordLanguages = tinaSearchConfig == null ? void 0 : tinaSearchConfig.stopwordLanguages;
|
|
119835
|
+
this.defaultFuzzyOptions = tinaSearchConfig == null ? void 0 : tinaSearchConfig.fuzzyOptions;
|
|
119909
119836
|
}
|
|
119910
|
-
|
|
119911
|
-
|
|
119837
|
+
getSearchBaseUrl(useFuzzy) {
|
|
119838
|
+
const version2 = useFuzzy ? "v2" : "";
|
|
119839
|
+
const searchPath = version2 ? `${version2}/searchIndex` : "searchIndex";
|
|
119840
|
+
return `${this.client.contentApiBase}/${searchPath}/${this.client.clientId}/${this.client.getBranch()}`;
|
|
119841
|
+
}
|
|
119842
|
+
buildSearchUrl(query, options, useFuzzy) {
|
|
119843
|
+
const baseUrl = this.getSearchBaseUrl(useFuzzy);
|
|
119844
|
+
if (useFuzzy) {
|
|
119845
|
+
const params = new URLSearchParams();
|
|
119846
|
+
params.set("query", query);
|
|
119847
|
+
if (options == null ? void 0 : options.collection) {
|
|
119848
|
+
params.set("collection", options.collection);
|
|
119849
|
+
}
|
|
119850
|
+
if (options == null ? void 0 : options.limit) {
|
|
119851
|
+
params.set("limit", options.limit.toString());
|
|
119852
|
+
}
|
|
119853
|
+
if (options == null ? void 0 : options.cursor) {
|
|
119854
|
+
params.set("cursor", options.cursor);
|
|
119855
|
+
}
|
|
119856
|
+
return `${baseUrl}?${params.toString()}`;
|
|
119857
|
+
}
|
|
119858
|
+
const queryWithCollection = (options == null ? void 0 : options.collection) ? `${query} AND _collection:${options.collection}` : query;
|
|
119912
119859
|
const q2 = queryToSearchIndexQuery(
|
|
119913
|
-
|
|
119914
|
-
|
|
119860
|
+
queryWithCollection,
|
|
119861
|
+
this.stopwordLanguages
|
|
119915
119862
|
);
|
|
119916
119863
|
const opt = optionsToSearchIndexOptions(options);
|
|
119917
119864
|
const optionsParam = opt["PAGE"] ? `&options=${JSON.stringify(opt)}` : "";
|
|
119918
|
-
|
|
119919
|
-
|
|
119920
|
-
|
|
119865
|
+
return `${baseUrl}?q=${JSON.stringify(q2)}${optionsParam}`;
|
|
119866
|
+
}
|
|
119867
|
+
async query(query, options) {
|
|
119868
|
+
const useFuzzy = (options == null ? void 0 : options.fuzzy) !== void 0 ? options.fuzzy : this.fuzzyEnabled;
|
|
119869
|
+
const url = this.buildSearchUrl(query, options, useFuzzy);
|
|
119870
|
+
const res = await this.client.authProvider.fetchWithToken(url);
|
|
119921
119871
|
return parseSearchIndexResponse(await res.json(), options);
|
|
119922
119872
|
}
|
|
119923
119873
|
async del(ids) {
|
|
119874
|
+
const baseUrl = this.getSearchBaseUrl(this.fuzzyEnabled);
|
|
119924
119875
|
const res = await this.client.authProvider.fetchWithToken(
|
|
119925
|
-
`${
|
|
119926
|
-
{
|
|
119927
|
-
method: "DELETE"
|
|
119928
|
-
}
|
|
119876
|
+
`${baseUrl}?ids=${ids.join(",")}`,
|
|
119877
|
+
{ method: "DELETE" }
|
|
119929
119878
|
);
|
|
119930
119879
|
if (res.status !== 200) {
|
|
119931
119880
|
throw new Error("Failed to update search index");
|
|
119932
119881
|
}
|
|
119933
119882
|
}
|
|
119934
119883
|
async put(docs) {
|
|
119935
|
-
const
|
|
119936
|
-
|
|
119937
|
-
|
|
119938
|
-
|
|
119939
|
-
|
|
119940
|
-
|
|
119941
|
-
"Content-Type": "application/json"
|
|
119942
|
-
}
|
|
119943
|
-
}
|
|
119944
|
-
);
|
|
119884
|
+
const baseUrl = this.getSearchBaseUrl(this.fuzzyEnabled);
|
|
119885
|
+
const res = await this.client.authProvider.fetchWithToken(baseUrl, {
|
|
119886
|
+
method: "POST",
|
|
119887
|
+
body: JSON.stringify({ docs }),
|
|
119888
|
+
headers: { "Content-Type": "application/json" }
|
|
119889
|
+
});
|
|
119945
119890
|
if (res.status !== 200) {
|
|
119946
119891
|
throw new Error("Failed to update search index");
|
|
119947
119892
|
}
|
|
@@ -119949,29 +119894,62 @@ class TinaCMSSearchClient {
|
|
|
119949
119894
|
supportsClientSideIndexing() {
|
|
119950
119895
|
return true;
|
|
119951
119896
|
}
|
|
119897
|
+
getDefaultLimit() {
|
|
119898
|
+
return 15;
|
|
119899
|
+
}
|
|
119952
119900
|
}
|
|
119953
119901
|
class LocalSearchClient {
|
|
119954
|
-
constructor(client) {
|
|
119902
|
+
constructor(client, tinaSearchConfig) {
|
|
119903
|
+
__publicField(this, "client");
|
|
119904
|
+
__publicField(this, "fuzzyEnabled");
|
|
119905
|
+
__publicField(this, "defaultFuzzyOptions");
|
|
119955
119906
|
this.client = client;
|
|
119907
|
+
this.fuzzyEnabled = (tinaSearchConfig == null ? void 0 : tinaSearchConfig.fuzzyEnabled) ?? true;
|
|
119908
|
+
this.defaultFuzzyOptions = tinaSearchConfig == null ? void 0 : tinaSearchConfig.fuzzyOptions;
|
|
119956
119909
|
}
|
|
119957
|
-
|
|
119958
|
-
|
|
119910
|
+
getSearchBaseUrl(useFuzzy) {
|
|
119911
|
+
return useFuzzy ? "http://localhost:4001/v2/searchIndex" : "http://localhost:4001/searchIndex";
|
|
119912
|
+
}
|
|
119913
|
+
buildSearchUrl(query, options, useFuzzy) {
|
|
119914
|
+
const baseUrl = this.getSearchBaseUrl(!!useFuzzy);
|
|
119915
|
+
if (useFuzzy) {
|
|
119916
|
+
const params = new URLSearchParams();
|
|
119917
|
+
params.set("query", query);
|
|
119918
|
+
if (options == null ? void 0 : options.collection) {
|
|
119919
|
+
params.set("collection", options.collection);
|
|
119920
|
+
}
|
|
119921
|
+
if (options == null ? void 0 : options.limit) {
|
|
119922
|
+
params.set("limit", options.limit.toString());
|
|
119923
|
+
}
|
|
119924
|
+
if (options == null ? void 0 : options.cursor) {
|
|
119925
|
+
params.set("cursor", options.cursor);
|
|
119926
|
+
}
|
|
119927
|
+
return `${baseUrl}?${params.toString()}`;
|
|
119928
|
+
}
|
|
119929
|
+
const queryWithCollection = (options == null ? void 0 : options.collection) ? `${query} AND _collection:${options.collection}` : query;
|
|
119930
|
+
const q2 = queryToSearchIndexQuery(queryWithCollection);
|
|
119959
119931
|
const opt = optionsToSearchIndexOptions(options);
|
|
119960
119932
|
const optionsParam = opt["PAGE"] ? `&options=${JSON.stringify(opt)}` : "";
|
|
119961
|
-
|
|
119962
|
-
|
|
119963
|
-
|
|
119933
|
+
return `${baseUrl}?q=${JSON.stringify(q2)}${optionsParam}`;
|
|
119934
|
+
}
|
|
119935
|
+
async query(query, options) {
|
|
119936
|
+
const useFuzzy = (options == null ? void 0 : options.fuzzy) !== void 0 ? options.fuzzy : this.fuzzyEnabled;
|
|
119937
|
+
const url = this.buildSearchUrl(query, options, useFuzzy);
|
|
119938
|
+
const res = await this.client.authProvider.fetchWithToken(url);
|
|
119964
119939
|
return parseSearchIndexResponse(await res.json(), options);
|
|
119965
119940
|
}
|
|
119966
|
-
del(
|
|
119967
|
-
return Promise.resolve(
|
|
119941
|
+
del(_ids) {
|
|
119942
|
+
return Promise.resolve();
|
|
119968
119943
|
}
|
|
119969
|
-
put(
|
|
119970
|
-
return Promise.resolve(
|
|
119944
|
+
put(_docs) {
|
|
119945
|
+
return Promise.resolve();
|
|
119971
119946
|
}
|
|
119972
119947
|
supportsClientSideIndexing() {
|
|
119973
119948
|
return false;
|
|
119974
119949
|
}
|
|
119950
|
+
getDefaultLimit() {
|
|
119951
|
+
return 15;
|
|
119952
|
+
}
|
|
119975
119953
|
}
|
|
119976
119954
|
function ModalBuilder(modalProps) {
|
|
119977
119955
|
return /* @__PURE__ */ React__default.createElement(Modal, null, /* @__PURE__ */ React__default.createElement(ModalPopup, null, /* @__PURE__ */ React__default.createElement(ModalHeader, null, modalProps.title), /* @__PURE__ */ React__default.createElement(ModalBody, { padded: true }, modalProps.message && (typeof modalProps.message === "string" ? /* @__PURE__ */ React__default.createElement("p", null, modalProps.message) : modalProps.message), modalProps.error && /* @__PURE__ */ React__default.createElement(ErrorLabel, null, modalProps.error), modalProps.children), /* @__PURE__ */ React__default.createElement(ModalActions, null, modalProps.actions.map((action) => /* @__PURE__ */ React__default.createElement(AsyncButton, { key: action.name, ...action })))));
|
|
@@ -120266,19 +120244,22 @@ const TinaCloudProvider = (props) => {
|
|
|
120266
120244
|
cms.api.tina.setBranch(currentBranch);
|
|
120267
120245
|
}
|
|
120268
120246
|
useEffect(() => {
|
|
120269
|
-
var _a3, _b2, _c2, _d, _e, _f;
|
|
120247
|
+
var _a3, _b2, _c2, _d, _e, _f, _g, _h;
|
|
120270
120248
|
let searchClient;
|
|
120271
120249
|
if (props.isLocalClient) {
|
|
120272
|
-
searchClient = new LocalSearchClient(
|
|
120250
|
+
searchClient = new LocalSearchClient(
|
|
120251
|
+
cms.api.tina,
|
|
120252
|
+
(_b2 = (_a3 = props.schema.config) == null ? void 0 : _a3.search) == null ? void 0 : _b2.tina
|
|
120253
|
+
);
|
|
120273
120254
|
} else {
|
|
120274
|
-
const hasTinaSearch = Boolean((
|
|
120255
|
+
const hasTinaSearch = Boolean((_d = (_c2 = props.schema.config) == null ? void 0 : _c2.search) == null ? void 0 : _d.tina);
|
|
120275
120256
|
if (hasTinaSearch) {
|
|
120276
120257
|
searchClient = new TinaCMSSearchClient(
|
|
120277
120258
|
cms.api.tina,
|
|
120278
|
-
(
|
|
120259
|
+
(_f = (_e = props.schema.config) == null ? void 0 : _e.search) == null ? void 0 : _f.tina
|
|
120279
120260
|
);
|
|
120280
120261
|
} else {
|
|
120281
|
-
searchClient = (
|
|
120262
|
+
searchClient = (_h = (_g = props.schema.config) == null ? void 0 : _g.search) == null ? void 0 : _h.searchClient;
|
|
120282
120263
|
}
|
|
120283
120264
|
}
|
|
120284
120265
|
if (searchClient) {
|
|
@@ -120412,18 +120393,18 @@ class ContentCreatorPlugin {
|
|
|
120412
120393
|
this.onChange = options.onChange;
|
|
120413
120394
|
this.initialValues = options.initialValues;
|
|
120414
120395
|
}
|
|
120415
|
-
async onSubmit({ collection, template, relativePath
|
|
120396
|
+
async onSubmit({ collection, template, relativePath }, cms) {
|
|
120416
120397
|
try {
|
|
120417
120398
|
const selectedCollection = this.collections.find(
|
|
120418
120399
|
(collectionItem) => collectionItem.slug === collection
|
|
120419
120400
|
);
|
|
120420
120401
|
const collectionFormat = selectedCollection.format;
|
|
120421
120402
|
const extensionLength = -1 * (collectionFormat.length + 1);
|
|
120422
|
-
let relativePathWithExt =
|
|
120423
|
-
if (
|
|
120424
|
-
relativePathWithExt = `${
|
|
120403
|
+
let relativePathWithExt = relativePath;
|
|
120404
|
+
if (relativePath.slice(extensionLength).toLocaleLowerCase() === `.${collectionFormat}`) {
|
|
120405
|
+
relativePathWithExt = `${relativePath.slice(0, -3)}.${collectionFormat}`;
|
|
120425
120406
|
} else {
|
|
120426
|
-
relativePathWithExt = `${
|
|
120407
|
+
relativePathWithExt = `${relativePath}.${collectionFormat}`;
|
|
120427
120408
|
}
|
|
120428
120409
|
const payload = {
|
|
120429
120410
|
relativePath: relativePathWithExt,
|
|
@@ -121324,6 +121305,10 @@ const CollectionListPage = () => {
|
|
|
121324
121305
|
booleanEquals: null
|
|
121325
121306
|
}));
|
|
121326
121307
|
}, [collectionName]);
|
|
121308
|
+
useEffect(() => {
|
|
121309
|
+
setEndCursor("");
|
|
121310
|
+
setPrevCursors([]);
|
|
121311
|
+
}, [search]);
|
|
121327
121312
|
const tableRowStyle = "hover:bg-gray-50/50 border-b-2 border-gray-50 transition-colors duration-300";
|
|
121328
121313
|
const tableHeadingCellStyle = "px-3 py-3 text-left text-xs font-bold text-gray-700 tracking-wider";
|
|
121329
121314
|
const tableHeadingStyle2 = "bg-gray-100 border-b-2 border-gray-200";
|
|
@@ -121583,6 +121568,8 @@ const CollectionListPage = () => {
|
|
|
121583
121568
|
))), /* @__PURE__ */ React__default.createElement("div", { className: "flex flex-1 flex-row gap-2 items-end w-full" }, searchEnabled ? /* @__PURE__ */ React__default.createElement(
|
|
121584
121569
|
SearchInput,
|
|
121585
121570
|
{
|
|
121571
|
+
cms,
|
|
121572
|
+
collectionName,
|
|
121586
121573
|
loading: _loading,
|
|
121587
121574
|
search,
|
|
121588
121575
|
setSearch,
|
|
@@ -121915,46 +121902,67 @@ const SearchInput = ({
|
|
|
121915
121902
|
setSearchInput
|
|
121916
121903
|
}) => {
|
|
121917
121904
|
const [searchLoaded, setSearchLoaded] = useState(false);
|
|
121905
|
+
const inputRef = React__default.useRef(null);
|
|
121918
121906
|
useEffect(() => {
|
|
121919
|
-
|
|
121907
|
+
setSearchLoaded(!loading);
|
|
121908
|
+
}, [loading]);
|
|
121909
|
+
const handleKeyDown = (e3) => {
|
|
121910
|
+
if (e3.key === "Enter") {
|
|
121911
|
+
e3.preventDefault();
|
|
121912
|
+
if (searchInput.trim()) {
|
|
121913
|
+
setSearch(searchInput);
|
|
121914
|
+
setSearchLoaded(false);
|
|
121915
|
+
}
|
|
121916
|
+
}
|
|
121917
|
+
};
|
|
121918
|
+
const handleSubmit = (e3) => {
|
|
121919
|
+
e3.preventDefault();
|
|
121920
|
+
if (searchInput.trim()) {
|
|
121921
|
+
setSearch(searchInput);
|
|
121920
121922
|
setSearchLoaded(false);
|
|
121921
|
-
} else {
|
|
121922
|
-
setSearchLoaded(true);
|
|
121923
121923
|
}
|
|
121924
|
-
}
|
|
121925
|
-
return /* @__PURE__ */ React__default.createElement(
|
|
121926
|
-
"
|
|
121924
|
+
};
|
|
121925
|
+
return /* @__PURE__ */ React__default.createElement(
|
|
121926
|
+
"form",
|
|
121927
121927
|
{
|
|
121928
|
-
|
|
121929
|
-
|
|
121930
|
-
|
|
121931
|
-
|
|
121932
|
-
|
|
121933
|
-
|
|
121934
|
-
|
|
121935
|
-
|
|
121936
|
-
|
|
121928
|
+
className: "flex flex-1 flex-col gap-2 items-start w-full",
|
|
121929
|
+
onSubmit: handleSubmit
|
|
121930
|
+
},
|
|
121931
|
+
/* @__PURE__ */ React__default.createElement("div", { className: "h-4" }),
|
|
121932
|
+
/* @__PURE__ */ React__default.createElement("div", { className: "flex items-center w-full md:w-auto gap-3" }, /* @__PURE__ */ React__default.createElement("div", { className: "flex-1 min-w-[200px] relative" }, /* @__PURE__ */ React__default.createElement(BiSearch, { className: "absolute left-3 top-1/2 -translate-y-1/2 w-5 h-5 text-gray-400 pointer-events-none z-10" }), /* @__PURE__ */ React__default.createElement(
|
|
121933
|
+
"input",
|
|
121934
|
+
{
|
|
121935
|
+
ref: inputRef,
|
|
121936
|
+
type: "text",
|
|
121937
|
+
name: "search",
|
|
121938
|
+
placeholder: "Search...",
|
|
121939
|
+
value: searchInput,
|
|
121940
|
+
onChange: (e3) => setSearchInput(e3.target.value),
|
|
121941
|
+
onKeyDown: handleKeyDown,
|
|
121942
|
+
className: "shadow appearance-none bg-white block pl-10 pr-10 py-2 truncate w-full text-base border border-gray-200 focus:outline-none focus:shadow-outline focus:ring-blue-500 focus:border-blue-500 sm:text-sm rounded placeholder:text-gray-300 text-gray-600 focus:text-gray-900",
|
|
121943
|
+
autoComplete: "off"
|
|
121944
|
+
}
|
|
121945
|
+
), search && searchLoaded && /* @__PURE__ */ React__default.createElement(
|
|
121946
|
+
"button",
|
|
121947
|
+
{
|
|
121948
|
+
onClick: (e3) => {
|
|
121937
121949
|
e3.preventDefault();
|
|
121938
|
-
|
|
121939
|
-
|
|
121940
|
-
|
|
121941
|
-
|
|
121942
|
-
}
|
|
121950
|
+
setSearch("");
|
|
121951
|
+
setSearchInput("");
|
|
121952
|
+
},
|
|
121953
|
+
className: "absolute right-3 top-1/2 -translate-y-1/2 text-gray-400 hover:text-gray-600 transition-colors z-10"
|
|
121943
121954
|
},
|
|
121944
|
-
|
|
121945
|
-
|
|
121946
|
-
|
|
121947
|
-
|
|
121948
|
-
|
|
121949
|
-
|
|
121950
|
-
|
|
121951
|
-
setSearch("");
|
|
121952
|
-
setSearchInput("");
|
|
121955
|
+
/* @__PURE__ */ React__default.createElement(BiX, { className: "w-5 h-5" })
|
|
121956
|
+
)), /* @__PURE__ */ React__default.createElement(
|
|
121957
|
+
Button$2,
|
|
121958
|
+
{
|
|
121959
|
+
variant: "primary",
|
|
121960
|
+
type: "submit",
|
|
121961
|
+
className: "focus:ring-0 focus:shadow-none"
|
|
121953
121962
|
},
|
|
121954
|
-
|
|
121955
|
-
|
|
121956
|
-
|
|
121957
|
-
))));
|
|
121963
|
+
"Search"
|
|
121964
|
+
))
|
|
121965
|
+
);
|
|
121958
121966
|
};
|
|
121959
121967
|
const Breadcrumb = ({ folder, navigate, collectionName }) => {
|
|
121960
121968
|
const folderArray = folder.name.split("/");
|
|
@@ -122222,17 +122230,16 @@ const useSearchCollection = (cms, collectionName, includeDocuments = true, folde
|
|
|
122222
122230
|
const searchCollection = async () => {
|
|
122223
122231
|
if (await api.isAuthenticated() && !folder.loading && !cancelled) {
|
|
122224
122232
|
try {
|
|
122225
|
-
const response = await cms.api.search.query(
|
|
122226
|
-
|
|
122227
|
-
|
|
122228
|
-
|
|
122229
|
-
|
|
122230
|
-
|
|
122231
|
-
);
|
|
122233
|
+
const response = await cms.api.search.query(search, {
|
|
122234
|
+
limit: 15,
|
|
122235
|
+
cursor: after3,
|
|
122236
|
+
collection: collectionName
|
|
122237
|
+
});
|
|
122238
|
+
const results = (response == null ? void 0 : response.results) ?? [];
|
|
122232
122239
|
const docs = await Promise.allSettled(
|
|
122233
|
-
|
|
122234
|
-
const [collection2,
|
|
122235
|
-
return api.fetchDocument(collection2,
|
|
122240
|
+
results.map((result) => {
|
|
122241
|
+
const [collection2, relativePath] = result._id.split(":");
|
|
122242
|
+
return api.fetchDocument(collection2, relativePath, false);
|
|
122236
122243
|
})
|
|
122237
122244
|
);
|
|
122238
122245
|
const edges2 = docs.filter((p2) => {
|
|
@@ -122240,21 +122247,22 @@ const useSearchCollection = (cms, collectionName, includeDocuments = true, folde
|
|
|
122240
122247
|
return p2.status === "fulfilled" && !!((_a2 = p2.value) == null ? void 0 : _a2.document);
|
|
122241
122248
|
}).map((result) => ({ node: result.value.document }));
|
|
122242
122249
|
const c2 = await api.fetchCollection(collectionName, false, "");
|
|
122243
|
-
|
|
122244
|
-
format:
|
|
122245
|
-
label:
|
|
122250
|
+
const collectionData = {
|
|
122251
|
+
format: c2.format,
|
|
122252
|
+
label: c2.label,
|
|
122246
122253
|
name: collectionName,
|
|
122247
|
-
templates:
|
|
122254
|
+
templates: c2.templates,
|
|
122248
122255
|
documents: {
|
|
122249
122256
|
pageInfo: {
|
|
122250
|
-
hasNextPage: !!response.nextCursor,
|
|
122251
|
-
hasPreviousPage: !!response.prevCursor,
|
|
122257
|
+
hasNextPage: !!(response == null ? void 0 : response.nextCursor),
|
|
122258
|
+
hasPreviousPage: !!(response == null ? void 0 : response.prevCursor),
|
|
122252
122259
|
startCursor: "",
|
|
122253
|
-
endCursor: response.nextCursor || ""
|
|
122260
|
+
endCursor: (response == null ? void 0 : response.nextCursor) || ""
|
|
122254
122261
|
},
|
|
122255
122262
|
edges: edges2
|
|
122256
122263
|
}
|
|
122257
|
-
}
|
|
122264
|
+
};
|
|
122265
|
+
setCollection(collectionData);
|
|
122258
122266
|
} catch (error22) {
|
|
122259
122267
|
cms.alerts.error(
|
|
122260
122268
|
`[${error22.name}] GetCollection failed: ${error22.message}`
|
|
@@ -122357,14 +122365,14 @@ const createDocument = async (cms, collection, template, mutationInfo, folder, v
|
|
|
122357
122365
|
throw new Error("Filename must be a string");
|
|
122358
122366
|
}
|
|
122359
122367
|
const appendFolder = folder && !filename.startsWith("/") ? `/${folder}/` : "/";
|
|
122360
|
-
const
|
|
122368
|
+
const relativePath = `${appendFolder}${filename}.${collection.format}`;
|
|
122361
122369
|
const params = api.schema.transformPayload(collection.name, {
|
|
122362
122370
|
_collection: collection.name,
|
|
122363
122371
|
...template && { _template: template.name },
|
|
122364
122372
|
...leftover
|
|
122365
122373
|
});
|
|
122366
122374
|
if (await api.isAuthenticated()) {
|
|
122367
|
-
await api.createDocument(collection,
|
|
122375
|
+
await api.createDocument(collection, relativePath, params);
|
|
122368
122376
|
} else {
|
|
122369
122377
|
const authMessage = `CreateDocument failed: User is no longer authenticated; please login and try again.`;
|
|
122370
122378
|
cms.alerts.error(authMessage);
|
|
@@ -122614,7 +122622,7 @@ const RenderForm$1 = ({
|
|
|
122614
122622
|
), /* @__PURE__ */ React__default.createElement(FormStatus, { pristine: formIsPristine }))
|
|
122615
122623
|
), activeForm && /* @__PURE__ */ React__default.createElement(FormBuilder, { form: activeForm, onPristineChange: setFormIsPristine })));
|
|
122616
122624
|
};
|
|
122617
|
-
const useGetDocument = (cms, collectionName,
|
|
122625
|
+
const useGetDocument = (cms, collectionName, relativePath) => {
|
|
122618
122626
|
const api = new TinaAdminApi(cms);
|
|
122619
122627
|
const [document2, setDocument] = useState(void 0);
|
|
122620
122628
|
const [loading, setLoading] = useState(true);
|
|
@@ -122626,7 +122634,7 @@ const useGetDocument = (cms, collectionName, relativePath2) => {
|
|
|
122626
122634
|
try {
|
|
122627
122635
|
const response = await api.fetchDocument(
|
|
122628
122636
|
collectionName,
|
|
122629
|
-
|
|
122637
|
+
relativePath
|
|
122630
122638
|
);
|
|
122631
122639
|
if (!isCancelled) {
|
|
122632
122640
|
setDocument(response.document);
|
|
@@ -122651,19 +122659,19 @@ const useGetDocument = (cms, collectionName, relativePath2) => {
|
|
|
122651
122659
|
return () => {
|
|
122652
122660
|
isCancelled = true;
|
|
122653
122661
|
};
|
|
122654
|
-
}, [cms, collectionName,
|
|
122662
|
+
}, [cms, collectionName, relativePath]);
|
|
122655
122663
|
return { document: document2, loading, error: error2 };
|
|
122656
122664
|
};
|
|
122657
122665
|
const GetDocument = ({
|
|
122658
122666
|
cms,
|
|
122659
122667
|
collectionName,
|
|
122660
|
-
relativePath
|
|
122668
|
+
relativePath,
|
|
122661
122669
|
children
|
|
122662
122670
|
}) => {
|
|
122663
122671
|
const { document: document2, loading, error: error2 } = useGetDocument(
|
|
122664
122672
|
cms,
|
|
122665
122673
|
collectionName,
|
|
122666
|
-
|
|
122674
|
+
relativePath
|
|
122667
122675
|
);
|
|
122668
122676
|
if (error2) {
|
|
122669
122677
|
return /* @__PURE__ */ React__default.createElement(FullscreenError, null);
|
|
@@ -122686,7 +122694,7 @@ const CollectionDuplicatePage = () => {
|
|
|
122686
122694
|
includeDocuments: false
|
|
122687
122695
|
},
|
|
122688
122696
|
(collection) => {
|
|
122689
|
-
const
|
|
122697
|
+
const relativePath = `${filename.startsWith("~/") ? filename.substring(2) : filename}.${collection.format}`;
|
|
122690
122698
|
const mutationInfo = {
|
|
122691
122699
|
includeCollection: true,
|
|
122692
122700
|
includeTemplate: !!collection.templates
|
|
@@ -122696,7 +122704,7 @@ const CollectionDuplicatePage = () => {
|
|
|
122696
122704
|
{
|
|
122697
122705
|
cms,
|
|
122698
122706
|
collectionName: collection.name,
|
|
122699
|
-
relativePath
|
|
122707
|
+
relativePath
|
|
122700
122708
|
},
|
|
122701
122709
|
(document2) => {
|
|
122702
122710
|
var _a2;
|
|
@@ -122716,11 +122724,11 @@ const CollectionDuplicatePage = () => {
|
|
|
122716
122724
|
}
|
|
122717
122725
|
));
|
|
122718
122726
|
};
|
|
122719
|
-
const updateDocument = async (cms,
|
|
122727
|
+
const updateDocument = async (cms, relativePath, collection, mutationInfo, values) => {
|
|
122720
122728
|
const api = new TinaAdminApi(cms);
|
|
122721
122729
|
const params = api.schema.transformPayload(collection.name, values);
|
|
122722
122730
|
if (await api.isAuthenticated()) {
|
|
122723
|
-
await api.updateDocument(collection,
|
|
122731
|
+
await api.updateDocument(collection, relativePath, params);
|
|
122724
122732
|
} else {
|
|
122725
122733
|
const authMessage = `UpdateDocument failed: User is no longer authenticated; please login and try again.`;
|
|
122726
122734
|
cms.alerts.error(authMessage);
|
|
@@ -122742,7 +122750,7 @@ const CollectionUpdatePage = () => {
|
|
|
122742
122750
|
includeDocuments: false
|
|
122743
122751
|
},
|
|
122744
122752
|
(collection) => {
|
|
122745
|
-
const
|
|
122753
|
+
const relativePath = `${resolvedFile}.${collection.format}`;
|
|
122746
122754
|
const mutationInfo = {
|
|
122747
122755
|
includeCollection: true,
|
|
122748
122756
|
includeTemplate: !!collection.templates
|
|
@@ -122752,7 +122760,7 @@ const CollectionUpdatePage = () => {
|
|
|
122752
122760
|
{
|
|
122753
122761
|
cms,
|
|
122754
122762
|
collectionName: collection.name,
|
|
122755
|
-
relativePath
|
|
122763
|
+
relativePath
|
|
122756
122764
|
},
|
|
122757
122765
|
(document2) => /* @__PURE__ */ React__default.createElement(
|
|
122758
122766
|
RenderForm,
|
|
@@ -122760,7 +122768,7 @@ const CollectionUpdatePage = () => {
|
|
|
122760
122768
|
cms,
|
|
122761
122769
|
document: document2,
|
|
122762
122770
|
filename: resolvedFile,
|
|
122763
|
-
relativePath
|
|
122771
|
+
relativePath,
|
|
122764
122772
|
collection,
|
|
122765
122773
|
mutationInfo
|
|
122766
122774
|
}
|
|
@@ -122773,7 +122781,7 @@ const RenderForm = ({
|
|
|
122773
122781
|
cms,
|
|
122774
122782
|
document: document2,
|
|
122775
122783
|
filename,
|
|
122776
|
-
relativePath
|
|
122784
|
+
relativePath,
|
|
122777
122785
|
collection,
|
|
122778
122786
|
mutationInfo
|
|
122779
122787
|
}) => {
|
|
@@ -122794,7 +122802,7 @@ const RenderForm = ({
|
|
|
122794
122802
|
const form = useMemo(() => {
|
|
122795
122803
|
return new Form({
|
|
122796
122804
|
// id is the full document path
|
|
122797
|
-
id: canonicalPath(`${schemaCollection.path}/${
|
|
122805
|
+
id: canonicalPath(`${schemaCollection.path}/${relativePath}`),
|
|
122798
122806
|
label: "form",
|
|
122799
122807
|
fields: formInfo.fields,
|
|
122800
122808
|
initialValues: document2._values,
|
|
@@ -122802,7 +122810,7 @@ const RenderForm = ({
|
|
|
122802
122810
|
try {
|
|
122803
122811
|
await updateDocument(
|
|
122804
122812
|
cms,
|
|
122805
|
-
|
|
122813
|
+
relativePath,
|
|
122806
122814
|
collection,
|
|
122807
122815
|
mutationInfo,
|
|
122808
122816
|
values
|
|
@@ -122823,7 +122831,7 @@ const RenderForm = ({
|
|
|
122823
122831
|
}
|
|
122824
122832
|
}
|
|
122825
122833
|
});
|
|
122826
|
-
}, [cms, document2,
|
|
122834
|
+
}, [cms, document2, relativePath, collection, mutationInfo]);
|
|
122827
122835
|
React__default.useEffect(() => {
|
|
122828
122836
|
cms.dispatch({ type: "forms:add", value: form });
|
|
122829
122837
|
cms.dispatch({ type: "forms:set-active-form-id", value: form.id });
|
|
@@ -122854,7 +122862,7 @@ const RenderForm = ({
|
|
|
122854
122862
|
{
|
|
122855
122863
|
defaultBranchName: (_a2 = cms.api.admin.api.schema.config.config.repoProvider) == null ? void 0 : _a2.defaultBranchName,
|
|
122856
122864
|
historyUrl: (_b = cms.api.admin.api.schema.config.config.repoProvider) == null ? void 0 : _b.historyUrl,
|
|
122857
|
-
contentRelativePath:
|
|
122865
|
+
contentRelativePath: relativePath,
|
|
122858
122866
|
tinaBranch: cms.api.admin.api.branch,
|
|
122859
122867
|
isLocalMode: (_d = (_c = cms.api) == null ? void 0 : _c.tina) == null ? void 0 : _d.isLocalMode
|
|
122860
122868
|
}
|