strapi-plugin-field-clearer 1.0.2 → 1.0.5

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.
@@ -27833,43 +27833,6 @@ const ClearFieldModalContent = ({
27833
27833
  )
27834
27834
  );
27835
27835
  };
27836
- const ClearFieldActionWrapper = ({ model, documentId, get: get2 }) => {
27837
- const [allowedTypes, setAllowedTypes] = React.useState(null);
27838
- const [loading, setLoading] = React.useState(true);
27839
- const fetchedRef = React.useRef(false);
27840
- React.useEffect(() => {
27841
- if (fetchedRef.current) return;
27842
- fetchedRef.current = true;
27843
- const fetchConfig = async () => {
27844
- try {
27845
- const { data } = await get2("/field-clearer/config");
27846
- setAllowedTypes(data.allowedContentTypes || []);
27847
- } catch {
27848
- setAllowedTypes([]);
27849
- } finally {
27850
- setLoading(false);
27851
- }
27852
- };
27853
- fetchConfig();
27854
- }, [get2]);
27855
- if (loading || allowedTypes === null) {
27856
- return null;
27857
- }
27858
- if (!allowedTypes.includes(model) || !documentId) {
27859
- return null;
27860
- }
27861
- return {
27862
- label: "Clear Field",
27863
- icon: React.createElement(icons.Trash),
27864
- variant: "danger",
27865
- position: "panel",
27866
- dialog: {
27867
- type: "modal",
27868
- title: "Clear Field Data",
27869
- content: React.createElement(ClearFieldModalContent, { contentType: model, documentId })
27870
- }
27871
- };
27872
- };
27873
27836
  const index = {
27874
27837
  register(app) {
27875
27838
  app.registerPlugin({
@@ -27882,8 +27845,20 @@ const index = {
27882
27845
  bootstrap(app) {
27883
27846
  const contentManagerApis = app.getPlugin("content-manager").apis;
27884
27847
  const ClearFieldAction = ({ model, documentId }) => {
27885
- const { get: get2 } = useFetchClient();
27886
- return ClearFieldActionWrapper({ model, documentId, get: get2 });
27848
+ if (!documentId) {
27849
+ return null;
27850
+ }
27851
+ return {
27852
+ label: "Clear Field",
27853
+ icon: React.createElement(icons.Trash),
27854
+ variant: "danger",
27855
+ position: "panel",
27856
+ dialog: {
27857
+ type: "modal",
27858
+ title: "Clear Field Data",
27859
+ content: React.createElement(ClearFieldModalContent, { contentType: model, documentId })
27860
+ }
27861
+ };
27887
27862
  };
27888
27863
  contentManagerApis.addDocumentAction([ClearFieldAction]);
27889
27864
  },
@@ -10480,7 +10480,7 @@ var objectInspect = function inspect_(obj, options, depth, seen) {
10480
10480
  var ys = arrObjKeys(obj, inspect2);
10481
10481
  var isPlainObject2 = gPO ? gPO(obj) === Object.prototype : obj instanceof Object || obj.constructor === Object;
10482
10482
  var protoTag = obj instanceof Object ? "" : "null prototype";
10483
- var stringTag2 = !isPlainObject2 && toStringTag$1 && Object(obj) === obj && toStringTag$1 in obj ? $slice.call(toStr$1(obj), 8, -1) : protoTag ? "Object" : "";
10483
+ var stringTag2 = !isPlainObject2 && toStringTag$1 && Object(obj) === obj && toStringTag$1 in obj ? $slice.call(toStr(obj), 8, -1) : protoTag ? "Object" : "";
10484
10484
  var constructorTag = isPlainObject2 || typeof obj.constructor !== "function" ? "" : obj.constructor.name ? obj.constructor.name + " " : "";
10485
10485
  var tag = constructorTag + (stringTag2 || protoTag ? "[" + $join.call($concat$1.call([], stringTag2 || [], protoTag || []), ": ") + "] " : "");
10486
10486
  if (ys.length === 0) {
@@ -10505,25 +10505,25 @@ function canTrustToString(obj) {
10505
10505
  return !toStringTag$1 || !(typeof obj === "object" && (toStringTag$1 in obj || typeof obj[toStringTag$1] !== "undefined"));
10506
10506
  }
10507
10507
  function isArray$4(obj) {
10508
- return toStr$1(obj) === "[object Array]" && canTrustToString(obj);
10508
+ return toStr(obj) === "[object Array]" && canTrustToString(obj);
10509
10509
  }
10510
10510
  function isDate$2(obj) {
10511
- return toStr$1(obj) === "[object Date]" && canTrustToString(obj);
10511
+ return toStr(obj) === "[object Date]" && canTrustToString(obj);
10512
10512
  }
10513
10513
  function isRegExp$2(obj) {
10514
- return toStr$1(obj) === "[object RegExp]" && canTrustToString(obj);
10514
+ return toStr(obj) === "[object RegExp]" && canTrustToString(obj);
10515
10515
  }
10516
10516
  function isError(obj) {
10517
- return toStr$1(obj) === "[object Error]" && canTrustToString(obj);
10517
+ return toStr(obj) === "[object Error]" && canTrustToString(obj);
10518
10518
  }
10519
10519
  function isString$1(obj) {
10520
- return toStr$1(obj) === "[object String]" && canTrustToString(obj);
10520
+ return toStr(obj) === "[object String]" && canTrustToString(obj);
10521
10521
  }
10522
10522
  function isNumber$1(obj) {
10523
- return toStr$1(obj) === "[object Number]" && canTrustToString(obj);
10523
+ return toStr(obj) === "[object Number]" && canTrustToString(obj);
10524
10524
  }
10525
10525
  function isBoolean$1(obj) {
10526
- return toStr$1(obj) === "[object Boolean]" && canTrustToString(obj);
10526
+ return toStr(obj) === "[object Boolean]" && canTrustToString(obj);
10527
10527
  }
10528
10528
  function isSymbol(obj) {
10529
10529
  if (hasShammedSymbols) {
@@ -10559,7 +10559,7 @@ var hasOwn$1 = Object.prototype.hasOwnProperty || function(key) {
10559
10559
  function has$5(obj, key) {
10560
10560
  return hasOwn$1.call(obj, key);
10561
10561
  }
10562
- function toStr$1(obj) {
10562
+ function toStr(obj) {
10563
10563
  return objectToString.call(obj);
10564
10564
  }
10565
10565
  function nameOf(f2) {
@@ -10868,7 +10868,7 @@ var syntax = SyntaxError;
10868
10868
  var uri = URIError;
10869
10869
  var abs$2 = Math.abs;
10870
10870
  var floor$1 = Math.floor;
10871
- var max$2 = Math.max;
10871
+ var max$1 = Math.max;
10872
10872
  var min$1 = Math.min;
10873
10873
  var pow$1 = Math.pow;
10874
10874
  var round$1 = Math.round;
@@ -10997,77 +10997,91 @@ function requireObject_getPrototypeOf() {
10997
10997
  Object_getPrototypeOf = $Object2.getPrototypeOf || null;
10998
10998
  return Object_getPrototypeOf;
10999
10999
  }
11000
- var ERROR_MESSAGE = "Function.prototype.bind called on incompatible ";
11001
- var toStr = Object.prototype.toString;
11002
- var max$1 = Math.max;
11003
- var funcType = "[object Function]";
11004
- var concatty = function concatty2(a2, b2) {
11005
- var arr = [];
11006
- for (var i2 = 0; i2 < a2.length; i2 += 1) {
11007
- arr[i2] = a2[i2];
11008
- }
11009
- for (var j2 = 0; j2 < b2.length; j2 += 1) {
11010
- arr[j2 + a2.length] = b2[j2];
11011
- }
11012
- return arr;
11013
- };
11014
- var slicy = function slicy2(arrLike, offset) {
11015
- var arr = [];
11016
- for (var i2 = offset, j2 = 0; i2 < arrLike.length; i2 += 1, j2 += 1) {
11017
- arr[j2] = arrLike[i2];
11018
- }
11019
- return arr;
11020
- };
11021
- var joiny = function(arr, joiner) {
11022
- var str = "";
11023
- for (var i2 = 0; i2 < arr.length; i2 += 1) {
11024
- str += arr[i2];
11025
- if (i2 + 1 < arr.length) {
11026
- str += joiner;
11000
+ var implementation;
11001
+ var hasRequiredImplementation;
11002
+ function requireImplementation() {
11003
+ if (hasRequiredImplementation) return implementation;
11004
+ hasRequiredImplementation = 1;
11005
+ var ERROR_MESSAGE = "Function.prototype.bind called on incompatible ";
11006
+ var toStr2 = Object.prototype.toString;
11007
+ var max2 = Math.max;
11008
+ var funcType = "[object Function]";
11009
+ var concatty = function concatty2(a2, b2) {
11010
+ var arr = [];
11011
+ for (var i2 = 0; i2 < a2.length; i2 += 1) {
11012
+ arr[i2] = a2[i2];
11027
11013
  }
11028
- }
11029
- return str;
11030
- };
11031
- var implementation$1 = function bind(that) {
11032
- var target = this;
11033
- if (typeof target !== "function" || toStr.apply(target) !== funcType) {
11034
- throw new TypeError(ERROR_MESSAGE + target);
11035
- }
11036
- var args = slicy(arguments, 1);
11037
- var bound;
11038
- var binder = function() {
11039
- if (this instanceof bound) {
11040
- var result = target.apply(
11041
- this,
11042
- concatty(args, arguments)
11043
- );
11044
- if (Object(result) === result) {
11045
- return result;
11014
+ for (var j2 = 0; j2 < b2.length; j2 += 1) {
11015
+ arr[j2 + a2.length] = b2[j2];
11016
+ }
11017
+ return arr;
11018
+ };
11019
+ var slicy = function slicy2(arrLike, offset) {
11020
+ var arr = [];
11021
+ for (var i2 = offset, j2 = 0; i2 < arrLike.length; i2 += 1, j2 += 1) {
11022
+ arr[j2] = arrLike[i2];
11023
+ }
11024
+ return arr;
11025
+ };
11026
+ var joiny = function(arr, joiner) {
11027
+ var str = "";
11028
+ for (var i2 = 0; i2 < arr.length; i2 += 1) {
11029
+ str += arr[i2];
11030
+ if (i2 + 1 < arr.length) {
11031
+ str += joiner;
11046
11032
  }
11047
- return this;
11048
11033
  }
11049
- return target.apply(
11050
- that,
11051
- concatty(args, arguments)
11052
- );
11034
+ return str;
11053
11035
  };
11054
- var boundLength = max$1(0, target.length - args.length);
11055
- var boundArgs = [];
11056
- for (var i2 = 0; i2 < boundLength; i2++) {
11057
- boundArgs[i2] = "$" + i2;
11058
- }
11059
- bound = Function("binder", "return function (" + joiny(boundArgs, ",") + "){ return binder.apply(this,arguments); }")(binder);
11060
- if (target.prototype) {
11061
- var Empty = function Empty2() {
11036
+ implementation = function bind2(that) {
11037
+ var target = this;
11038
+ if (typeof target !== "function" || toStr2.apply(target) !== funcType) {
11039
+ throw new TypeError(ERROR_MESSAGE + target);
11040
+ }
11041
+ var args = slicy(arguments, 1);
11042
+ var bound;
11043
+ var binder = function() {
11044
+ if (this instanceof bound) {
11045
+ var result = target.apply(
11046
+ this,
11047
+ concatty(args, arguments)
11048
+ );
11049
+ if (Object(result) === result) {
11050
+ return result;
11051
+ }
11052
+ return this;
11053
+ }
11054
+ return target.apply(
11055
+ that,
11056
+ concatty(args, arguments)
11057
+ );
11062
11058
  };
11063
- Empty.prototype = target.prototype;
11064
- bound.prototype = new Empty();
11065
- Empty.prototype = null;
11066
- }
11067
- return bound;
11068
- };
11069
- var implementation = implementation$1;
11070
- var functionBind = Function.prototype.bind || implementation;
11059
+ var boundLength = max2(0, target.length - args.length);
11060
+ var boundArgs = [];
11061
+ for (var i2 = 0; i2 < boundLength; i2++) {
11062
+ boundArgs[i2] = "$" + i2;
11063
+ }
11064
+ bound = Function("binder", "return function (" + joiny(boundArgs, ",") + "){ return binder.apply(this,arguments); }")(binder);
11065
+ if (target.prototype) {
11066
+ var Empty = function Empty2() {
11067
+ };
11068
+ Empty.prototype = target.prototype;
11069
+ bound.prototype = new Empty();
11070
+ Empty.prototype = null;
11071
+ }
11072
+ return bound;
11073
+ };
11074
+ return implementation;
11075
+ }
11076
+ var functionBind;
11077
+ var hasRequiredFunctionBind;
11078
+ function requireFunctionBind() {
11079
+ if (hasRequiredFunctionBind) return functionBind;
11080
+ hasRequiredFunctionBind = 1;
11081
+ var implementation2 = requireImplementation();
11082
+ functionBind = Function.prototype.bind || implementation2;
11083
+ return functionBind;
11084
+ }
11071
11085
  var functionCall;
11072
11086
  var hasRequiredFunctionCall;
11073
11087
  function requireFunctionCall() {
@@ -11085,12 +11099,12 @@ function requireFunctionApply() {
11085
11099
  return functionApply;
11086
11100
  }
11087
11101
  var reflectApply = typeof Reflect !== "undefined" && Reflect && Reflect.apply;
11088
- var bind$3 = functionBind;
11102
+ var bind$3 = requireFunctionBind();
11089
11103
  var $apply$1 = requireFunctionApply();
11090
11104
  var $call$2 = requireFunctionCall();
11091
11105
  var $reflectApply = reflectApply;
11092
11106
  var actualApply = $reflectApply || bind$3.call($call$2, $apply$1);
11093
- var bind$2 = functionBind;
11107
+ var bind$2 = requireFunctionBind();
11094
11108
  var $TypeError$4 = type;
11095
11109
  var $call$1 = requireFunctionCall();
11096
11110
  var $actualApply = actualApply;
@@ -11158,8 +11172,8 @@ function requireHasown() {
11158
11172
  hasRequiredHasown = 1;
11159
11173
  var call = Function.prototype.call;
11160
11174
  var $hasOwn = Object.prototype.hasOwnProperty;
11161
- var bind3 = functionBind;
11162
- hasown = bind3.call(call, $hasOwn);
11175
+ var bind2 = requireFunctionBind();
11176
+ hasown = bind2.call(call, $hasOwn);
11163
11177
  return hasown;
11164
11178
  }
11165
11179
  var undefined$1;
@@ -11173,7 +11187,7 @@ var $TypeError$3 = type;
11173
11187
  var $URIError = uri;
11174
11188
  var abs$1 = abs$2;
11175
11189
  var floor = floor$1;
11176
- var max = max$2;
11190
+ var max = max$1;
11177
11191
  var min = min$1;
11178
11192
  var pow = pow$1;
11179
11193
  var round = round$1;
@@ -11378,7 +11392,7 @@ var LEGACY_ALIASES = {
11378
11392
  "%WeakMapPrototype%": ["WeakMap", "prototype"],
11379
11393
  "%WeakSetPrototype%": ["WeakSet", "prototype"]
11380
11394
  };
11381
- var bind$1 = functionBind;
11395
+ var bind$1 = requireFunctionBind();
11382
11396
  var hasOwn = requireHasown();
11383
11397
  var $concat = bind$1.call($call, Array.prototype.concat);
11384
11398
  var $spliceApply = bind$1.call($apply, Array.prototype.splice);
@@ -15709,7 +15723,7 @@ const admin = adminApi.enhanceEndpoints({
15709
15723
  overrideExisting: false
15710
15724
  });
15711
15725
  const { useInitQuery, useTelemetryPropertiesQuery, useInformationQuery, useProjectSettingsQuery, useUpdateProjectSettingsMutation, useGetPluginsQuery, useGetLicenseLimitsQuery, useGetLicenseTrialTimeLeftQuery, useGetGuidedTourMetaQuery } = admin;
15712
- function bind2(fn2, thisArg) {
15726
+ function bind(fn2, thisArg) {
15713
15727
  return function wrap() {
15714
15728
  return fn2.apply(thisArg, arguments);
15715
15729
  };
@@ -15846,7 +15860,7 @@ function merge2() {
15846
15860
  const extend = (a2, b2, thisArg, { allOwnKeys } = {}) => {
15847
15861
  forEach$1(b2, (val, key) => {
15848
15862
  if (thisArg && isFunction$1(val)) {
15849
- a2[key] = bind2(val, thisArg);
15863
+ a2[key] = bind(val, thisArg);
15850
15864
  } else {
15851
15865
  a2[key] = val;
15852
15866
  }
@@ -18126,7 +18140,7 @@ Object.entries(HttpStatusCode$1).forEach(([key, value]) => {
18126
18140
  });
18127
18141
  function createInstance(defaultConfig) {
18128
18142
  const context = new Axios$1(defaultConfig);
18129
- const instance = bind2(Axios$1.prototype.request, context);
18143
+ const instance = bind(Axios$1.prototype.request, context);
18130
18144
  utils$1.extend(instance, Axios$1.prototype, context, { allOwnKeys: true });
18131
18145
  utils$1.extend(instance, context, null, { allOwnKeys: true });
18132
18146
  instance.create = function create2(instanceConfig) {
@@ -27820,43 +27834,6 @@ const ClearFieldModalContent = ({
27820
27834
  )
27821
27835
  );
27822
27836
  };
27823
- const ClearFieldActionWrapper = ({ model, documentId, get: get2 }) => {
27824
- const [allowedTypes, setAllowedTypes] = useState(null);
27825
- const [loading, setLoading] = useState(true);
27826
- const fetchedRef = useRef(false);
27827
- useEffect(() => {
27828
- if (fetchedRef.current) return;
27829
- fetchedRef.current = true;
27830
- const fetchConfig = async () => {
27831
- try {
27832
- const { data } = await get2("/field-clearer/config");
27833
- setAllowedTypes(data.allowedContentTypes || []);
27834
- } catch {
27835
- setAllowedTypes([]);
27836
- } finally {
27837
- setLoading(false);
27838
- }
27839
- };
27840
- fetchConfig();
27841
- }, [get2]);
27842
- if (loading || allowedTypes === null) {
27843
- return null;
27844
- }
27845
- if (!allowedTypes.includes(model) || !documentId) {
27846
- return null;
27847
- }
27848
- return {
27849
- label: "Clear Field",
27850
- icon: createElement(Trash),
27851
- variant: "danger",
27852
- position: "panel",
27853
- dialog: {
27854
- type: "modal",
27855
- title: "Clear Field Data",
27856
- content: createElement(ClearFieldModalContent, { contentType: model, documentId })
27857
- }
27858
- };
27859
- };
27860
27837
  const index = {
27861
27838
  register(app) {
27862
27839
  app.registerPlugin({
@@ -27869,8 +27846,20 @@ const index = {
27869
27846
  bootstrap(app) {
27870
27847
  const contentManagerApis = app.getPlugin("content-manager").apis;
27871
27848
  const ClearFieldAction = ({ model, documentId }) => {
27872
- const { get: get2 } = useFetchClient();
27873
- return ClearFieldActionWrapper({ model, documentId, get: get2 });
27849
+ if (!documentId) {
27850
+ return null;
27851
+ }
27852
+ return {
27853
+ label: "Clear Field",
27854
+ icon: createElement(Trash),
27855
+ variant: "danger",
27856
+ position: "panel",
27857
+ dialog: {
27858
+ type: "modal",
27859
+ title: "Clear Field Data",
27860
+ content: createElement(ClearFieldModalContent, { contentType: model, documentId })
27861
+ }
27862
+ };
27874
27863
  };
27875
27864
  contentManagerApis.addDocumentAction([ClearFieldAction]);
27876
27865
  },
@@ -235,7 +235,6 @@ const service = ({ strapi }) => ({
235
235
  try {
236
236
  document = await strapi.documents(contentType).findOne({
237
237
  documentId,
238
- status: "draft",
239
238
  populate: "*"
240
239
  });
241
240
  } catch (error) {
@@ -270,7 +269,6 @@ const service = ({ strapi }) => ({
270
269
  try {
271
270
  document = await strapi.documents(contentType).findOne({
272
271
  documentId,
273
- status: "draft",
274
272
  populate: {
275
273
  [componentField]: {
276
274
  populate: "*"
@@ -474,7 +472,6 @@ const service = ({ strapi }) => ({
474
472
  try {
475
473
  document = await strapi.documents(contentType).findOne({
476
474
  documentId,
477
- status: "draft",
478
475
  populate: "*"
479
476
  });
480
477
  } catch (error) {
@@ -530,7 +527,6 @@ const service = ({ strapi }) => ({
530
527
  try {
531
528
  document = await strapi.documents(contentType).findOne({
532
529
  documentId,
533
- status: "draft",
534
530
  populate: {
535
531
  [componentField]: {
536
532
  populate: "*"
@@ -234,7 +234,6 @@ const service = ({ strapi }) => ({
234
234
  try {
235
235
  document = await strapi.documents(contentType).findOne({
236
236
  documentId,
237
- status: "draft",
238
237
  populate: "*"
239
238
  });
240
239
  } catch (error) {
@@ -269,7 +268,6 @@ const service = ({ strapi }) => ({
269
268
  try {
270
269
  document = await strapi.documents(contentType).findOne({
271
270
  documentId,
272
- status: "draft",
273
271
  populate: {
274
272
  [componentField]: {
275
273
  populate: "*"
@@ -473,7 +471,6 @@ const service = ({ strapi }) => ({
473
471
  try {
474
472
  document = await strapi.documents(contentType).findOne({
475
473
  documentId,
476
- status: "draft",
477
474
  populate: "*"
478
475
  });
479
476
  } catch (error) {
@@ -529,7 +526,6 @@ const service = ({ strapi }) => ({
529
526
  try {
530
527
  document = await strapi.documents(contentType).findOne({
531
528
  documentId,
532
- status: "draft",
533
529
  populate: {
534
530
  [componentField]: {
535
531
  populate: "*"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "strapi-plugin-field-clearer",
3
- "version": "1.0.2",
3
+ "version": "1.0.5",
4
4
  "description": "A Strapi v5 plugin to clear/delete field data from content types. Supports nested fields, component arrays, relations, and more.",
5
5
  "keywords": [
6
6
  "strapi",