New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@react-awesome-query-builder/core

Package Overview
Dependencies
Maintainers
1
Versions
33
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@react-awesome-query-builder/core - npm Package Compare versions

Comparing version 6.4.0 to 6.4.1

4

cjs/export/jsonLogic.js

@@ -105,6 +105,2 @@ "use strict";

var not = properties.get("not");
if (conj != "and" && conj != "or") {
meta.errors.push("Conjunction ".concat(conj, " is not supported"));
return undefined;
}
var isRuleGroup = type === "rule_group" && !isRoot;

@@ -111,0 +107,0 @@ var groupField = isRuleGroup && mode != "struct" ? field : parentField;

7

cjs/export/mongoDb.js

@@ -70,3 +70,6 @@ "use strict";

var children = item.get("children1") || new _immutable.List();
var canShortMongoQuery = config.settings.canShortMongoQuery;
var _config$settings = config.settings,
canShortMongoQuery = _config$settings.canShortMongoQuery,
fieldSeparator = _config$settings.fieldSeparator;
var sep = fieldSeparator;
var hasParentRuleGroup = parents.filter(function (it) {

@@ -89,3 +92,3 @@ return it.get("type") == "rule_group";

return formatItem([].concat((0, _toConsumableArray2["default"])(parents), [item]), currentChild, config, meta, not, mode != "array", mode == "array" ? function (f) {
return "$$el.".concat(f);
return "$$el".concat(sep).concat(f);
} : undefined);

@@ -92,0 +95,0 @@ }).filter(function (currentChild) {

@@ -143,2 +143,3 @@ "use strict";

var isSpelArray = groupFieldDef.isSpelArray;
var fieldSeparator = config.settings.fieldSeparator;

@@ -181,3 +182,4 @@ // check op for reverse

var formattedField = formatField(meta, config, field, parentField);
var getSize = isSpelArray ? ".length" : ".size()";
var sep = fieldSeparator || ".";
var getSize = sep + (isSpelArray ? "length" : "size()");
var fullSize = "".concat(formattedField).concat(getSize);

@@ -409,3 +411,4 @@ // https://docs.spring.io/spring-framework/docs/3.2.x/spring-framework-reference/html/expressions.html#expressions-collection-selection

parent: parent,
isSpelVariable: isSpelVariable
isSpelVariable: isSpelVariable,
fieldSeparator: fieldSeparator
};

@@ -412,0 +415,0 @@ });

@@ -472,3 +472,3 @@ "use strict";

fc = _ref4[1];
return fc.type == "!group";
return (fc === null || fc === void 0 ? void 0 : fc.type) == "!group";
}));

@@ -495,3 +495,3 @@ return [f, Object.keys(ancs)];

v = _ref6[1];
if (v.type == "group" || v.type == "rule_group") {
if ((v === null || v === void 0 ? void 0 : v.type) == "group" || (v === null || v === void 0 ? void 0 : v.type) == "rule_group") {
// put as-is

@@ -506,3 +506,5 @@ children1[k] = v;

// not in rule_group (can be simple field or in struct) - put as-is
children1[k] = v;
if (v) {
children1[k] = v;
}
} else {

@@ -564,17 +566,17 @@ // wrap field in rule_group (with creating hierarchy if need)

};
var topLevelFieldsFilter = function topLevelFieldsFilter(fields) {
var arr = (0, _toConsumableArray2["default"])(fields).sort(function (a, b) {
return a.length - b.length;
});
for (var i = 0; i < arr.length; i++) {
for (var j = i + 1; j < arr.length; j++) {
if (arr[j].indexOf(arr[i]) == 0) {
// arr[j] is inside arr[i] (eg. "a.b" inside "a")
arr.splice(j, 1);
j--;
}
}
}
return arr;
};
// const topLevelFieldsFilter = (fields) => {
// let arr = [...fields].sort((a, b) => (a.length - b.length));
// for (let i = 0 ; i < arr.length ; i++) {
// for (let j = i + 1 ; j < arr.length ; j++) {
// if (arr[j].indexOf(arr[i]) == 0) {
// // arr[j] is inside arr[i] (eg. "a.b" inside "a")
// arr.splice(j, 1);
// j--;
// }
// }
// }
// return arr;
// };
var wrapInDefaultConjRuleGroup = function wrapInDefaultConjRuleGroup(rule, parentField, parentFieldConfig, config, conj) {

@@ -581,0 +583,0 @@ if (!rule) return undefined;

@@ -1311,8 +1311,27 @@ "use strict";

var mode = fieldConfig === null || fieldConfig === void 0 ? void 0 : fieldConfig.mode;
var res = _objectSpread(_objectSpread({}, groupFilter || {}), {}, {
type: "rule_group",
properties: _objectSpread(_objectSpread(_objectSpread({}, groupOpRule.properties), (groupFilter === null || groupFilter === void 0 ? void 0 : groupFilter.properties) || {}), {}, {
mode: mode
})
});
var res;
if ((groupFilter === null || groupFilter === void 0 ? void 0 : groupFilter.type) === "group") {
res = _objectSpread(_objectSpread({}, groupFilter || {}), {}, {
type: "rule_group",
properties: _objectSpread(_objectSpread(_objectSpread({}, groupOpRule.properties), (groupFilter === null || groupFilter === void 0 ? void 0 : groupFilter.properties) || {}), {}, {
mode: mode
})
});
} else if (groupFilter) {
// rule_group in rule_group
res = _objectSpread(_objectSpread({}, groupOpRule || {}), {}, {
type: "rule_group",
children1: [groupFilter],
properties: _objectSpread(_objectSpread({}, groupOpRule.properties), {}, {
mode: mode
})
});
} else {
res = _objectSpread(_objectSpread({}, groupOpRule || {}), {}, {
type: "rule_group",
properties: _objectSpread(_objectSpread({}, groupOpRule.properties), {}, {
mode: mode
})
});
}
if (!res.id) res.id = (0, _uuid["default"])();

@@ -1319,0 +1338,0 @@ return res;

@@ -134,3 +134,3 @@ /* eslint-disable no-extra-semi */

interface RuleProperties extends BasicItemProperties {
export interface RuleProperties extends BasicItemProperties {
field: FieldValue | Empty,

@@ -146,7 +146,7 @@ fieldSrc?: FieldSource,

interface RuleGroupExtProperties extends RuleProperties {
export interface RuleGroupExtProperties extends RuleProperties {
mode: RuleGroupMode,
}
interface RuleGroupProperties extends BasicItemProperties {
export interface RuleGroupProperties extends BasicItemProperties {
field: FieldPath | Empty,

@@ -156,3 +156,3 @@ mode?: RuleGroupMode,

interface GroupProperties extends BasicItemProperties {
export interface GroupProperties extends BasicItemProperties {
conjunction: string,

@@ -162,27 +162,56 @@ not?: boolean,

interface SwitchGroupProperties extends BasicItemProperties {
export interface SwitchGroupProperties extends BasicItemProperties {
}
interface CaseGroupProperties extends BasicItemProperties {
export interface CaseGroupProperties extends BasicItemProperties {
}
type JsonAnyRule = JsonRule|JsonRuleGroup|JsonRuleGroupExt;
type JsonItem = JsonGroup|JsonAnyRule;
type JsonSwitchGroup = {
//////
interface _RulePropertiesI extends RuleProperties {
value: ImmutableList<RuleValue>,
valueSrc?: ImmutableList<ValueSource>,
valueType?: ImmutableList<string>,
valueError?: ImmutableList<string>,
operatorOptions?: ImmMap,
}
interface _RuleGroupExtProperties extends _RulePropertiesI, RuleGroupExtProperties {}
interface ObjectToImmOMap<P> extends ImmutableOMap<keyof P, any> {
get<K extends keyof P>(name: K): P[K];
}
export interface BasicItemPropertiesI<P = BasicItemProperties> extends ObjectToImmOMap<P> {}
export interface ImmutableRuleProperties<P = _RulePropertiesI> extends BasicItemPropertiesI<P> {}
export interface ImmutableRuleGroupExtProperties<P = _RuleGroupExtProperties> extends ImmutableRuleProperties<P> {}
export interface ImmutableRuleGroupProperties<P = RuleGroupProperties> extends BasicItemPropertiesI<P> {}
export interface ImmutableGroupProperties<P = GroupProperties> extends BasicItemPropertiesI<P> {}
export interface ImmutableSwitchGroupProperties<P = SwitchGroupProperties> extends BasicItemPropertiesI<P> {}
export interface ImmutableCaseGroupProperties<P = CaseGroupProperties> extends BasicItemPropertiesI<P> {}
export type ImmutableItemProperties = ImmutableRuleProperties | ImmutableRuleGroupProperties | ImmutableRuleGroupExtProperties | ImmutableGroupProperties;
//////
export type JsonAnyRule = JsonRule|JsonRuleGroup|JsonRuleGroupExt;
export type JsonItem = JsonGroup|JsonAnyRule;
export interface JsonBasicItem {
type: ItemType,
id?: string,
}
export interface JsonSwitchGroup extends JsonBasicItem {
type: "switch_group",
id?: string,
children1?: {[id: string]: JsonCaseGroup} | JsonCaseGroup[],
properties?: SwitchGroupProperties
};
type JsonCaseGroup = {
}
export interface JsonCaseGroup extends JsonBasicItem {
type: "case_group",
id?: string,
children1?: {[id: string]: JsonGroup} | JsonGroup[],
properties?: CaseGroupProperties
};
type JsonGroup = {
}
export interface JsonGroup extends JsonBasicItem {
type: "group",
id?: string,
// tip: if got array, it will be converted to immutable ordered map in `_addChildren1`

@@ -192,17 +221,14 @@ children1?: {[id: string]: JsonItem} | JsonItem[],

}
type JsonRuleGroup = {
export interface JsonRuleGroup extends JsonBasicItem {
type: "rule_group",
id?: string,
children1?: {[id: string]: JsonRule} | JsonRule[],
properties?: RuleGroupProperties
}
type JsonRuleGroupExt = {
export interface JsonRuleGroupExt extends JsonBasicItem {
type: "rule_group",
id?: string,
children1?: {[id: string]: JsonRule} | JsonRule[],
properties?: RuleGroupExtProperties
}
type JsonRule = {
export interface JsonRule extends JsonBasicItem {
type: "rule",
id?: string,
properties: RuleProperties,

@@ -212,5 +238,49 @@ }

export type ImmutableTree = ImmutableOMap<string, any>;
export type ImmutableItem = ImmutableOMap<string, any>;
////
interface _BasicItemI {
type: ItemType,
id: string,
}
interface _RuleI extends _BasicItemI {
type: "rule",
properties: ImmutableRuleProperties,
}
interface _GroupI extends _BasicItemI {
type: "group",
children1?: ImmOMap<string, ImmutableItem>,
properties: ImmutableGroupProperties,
}
interface _RuleGroupI extends _BasicItemI {
type: "rule_group",
children1?: ImmOMap<string, ImmutableRule>,
properties: ImmutableRuleGroupProperties,
}
interface _RuleGroupExtI extends _BasicItemI {
type: "rule_group",
children1?: ImmOMap<string, ImmutableRule>,
properties: ImmutableRuleGroupExtProperties,
}
interface _SwitchGroupI extends _BasicItemI {
type: "switch_group",
children1?: ImmOMap<string, ImmutableSwitchGroup>,
properties: ImmutableSwitchGroupProperties,
}
interface _CaseGroupI extends _BasicItemI {
type: "case_group",
children1?: ImmOMap<string, ImmutableGroup>,
properties: ImmutableCaseGroupProperties,
}
export interface ImmutableBasicItem<P = _BasicItemI> extends ObjectToImmOMap<P> {}
export interface ImmutableRule<P = _RuleI> extends ImmutableBasicItem<P> {}
export interface ImmutableGroup<P = _GroupI> extends ImmutableBasicItem<P> {}
export interface ImmutableRuleGroup<P = _RuleGroupI> extends ImmutableBasicItem<P> {}
export interface ImmutableRuleGroupExt<P = _RuleGroupExtI> extends ImmutableBasicItem<P> {}
export interface ImmutableSwitchGroup<P = _SwitchGroupI> extends ImmutableBasicItem<P> {}
export interface ImmutableCaseGroup<P = _CaseGroupI> extends ImmutableBasicItem<P> {}
export type ImmutableAnyRule = ImmutableRule|ImmutableRuleGroup|ImmutableRuleGroupExt;
export type ImmutableItem = ImmutableGroup|ImmutableAnyRule;
export type ImmutableTree = ImmutableGroup|ImmutableSwitchGroup;
////////////////

@@ -217,0 +287,0 @@ // Utils

@@ -758,4 +758,3 @@ "use strict";

var _default = function _default(config, tree, getMemoizedTree, setLastTree) {
var emptyTree = (0, _defaultUtils.defaultRoot)(config);
var initTree = tree || emptyTree;
var initTree = tree;
var emptyState = _objectSpread({

@@ -762,0 +761,0 @@ tree: initTree

@@ -156,6 +156,7 @@ "use strict";

var defaultRoot = function defaultRoot(config) {
var canAddDefaultRule = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
return new _immutable["default"].Map({
type: "group",
id: (0, _uuid["default"])(),
children1: new _immutable["default"].OrderedMap(_objectSpread({}, defaultRule((0, _uuid["default"])(), config))),
children1: new _immutable["default"].OrderedMap(canAddDefaultRule ? _objectSpread({}, defaultRule((0, _uuid["default"])(), config)) : {}),
properties: defaultGroupProperties(config)

@@ -162,0 +163,0 @@ });

@@ -216,6 +216,7 @@ "use strict";

return childId;
}) : null;
}).toArray() : null;
var isRuleGroup = type == "rule_group";
// tip: count rule_group as 1 rule
var isLeaf = !insideRuleGroup && (!children || isRuleGroup);
var hasChildren = (childrenIds === null || childrenIds === void 0 ? void 0 : childrenIds.length) > 0;
var itemsBefore = flat.length;

@@ -248,2 +249,3 @@ var top = realHeight;

};
var depth;
if (children) {

@@ -256,2 +258,6 @@ var subinfo = {};

info.height = (info.height || 0) + (subinfo.height || 0);
if (hasChildren && !isRuleGroup) {
// tip: don't count children of rule_group
depth = (subinfo.depth || 0) + 1;
}
}

@@ -270,2 +276,8 @@ }

});
if (depth != undefined) {
Object.assign(items[id], {
depth: depth
});
info.depth = Math.max(info.depth || 0, depth);
}
}

@@ -272,0 +284,0 @@ _flatizeTree(tree, [], false, false, false, 0, {}, null, null);

@@ -98,6 +98,2 @@ import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";

var not = properties.get("not");
if (conj != "and" && conj != "or") {
meta.errors.push("Conjunction ".concat(conj, " is not supported"));
return undefined;
}
var isRuleGroup = type === "rule_group" && !isRoot;

@@ -104,0 +100,0 @@ var groupField = isRuleGroup && mode != "struct" ? field : parentField;

@@ -62,3 +62,6 @@ import _slicedToArray from "@babel/runtime/helpers/slicedToArray";

var children = item.get("children1") || new List();
var canShortMongoQuery = config.settings.canShortMongoQuery;
var _config$settings = config.settings,
canShortMongoQuery = _config$settings.canShortMongoQuery,
fieldSeparator = _config$settings.fieldSeparator;
var sep = fieldSeparator;
var hasParentRuleGroup = parents.filter(function (it) {

@@ -81,3 +84,3 @@ return it.get("type") == "rule_group";

return formatItem([].concat(_toConsumableArray(parents), [item]), currentChild, config, meta, not, mode != "array", mode == "array" ? function (f) {
return "$$el.".concat(f);
return "$$el".concat(sep).concat(f);
} : undefined);

@@ -84,0 +87,0 @@ }).filter(function (currentChild) {

@@ -134,2 +134,3 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";

var isSpelArray = groupFieldDef.isSpelArray;
var fieldSeparator = config.settings.fieldSeparator;

@@ -172,3 +173,4 @@ // check op for reverse

var formattedField = formatField(meta, config, field, parentField);
var getSize = isSpelArray ? ".length" : ".size()";
var sep = fieldSeparator || ".";
var getSize = sep + (isSpelArray ? "length" : "size()");
var fullSize = "".concat(formattedField).concat(getSize);

@@ -400,3 +402,4 @@ // https://docs.spring.io/spring-framework/docs/3.2.x/spring-framework-reference/html/expressions.html#expressions-collection-selection

parent: parent,
isSpelVariable: isSpelVariable
isSpelVariable: isSpelVariable,
fieldSeparator: fieldSeparator
};

@@ -403,0 +406,0 @@ });

@@ -465,3 +465,3 @@ import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";

fc = _ref4[1];
return fc.type == "!group";
return (fc === null || fc === void 0 ? void 0 : fc.type) == "!group";
}));

@@ -488,3 +488,3 @@ return [f, Object.keys(ancs)];

v = _ref6[1];
if (v.type == "group" || v.type == "rule_group") {
if ((v === null || v === void 0 ? void 0 : v.type) == "group" || (v === null || v === void 0 ? void 0 : v.type) == "rule_group") {
// put as-is

@@ -499,3 +499,5 @@ children1[k] = v;

// not in rule_group (can be simple field or in struct) - put as-is
children1[k] = v;
if (v) {
children1[k] = v;
}
} else {

@@ -557,17 +559,17 @@ // wrap field in rule_group (with creating hierarchy if need)

};
var topLevelFieldsFilter = function topLevelFieldsFilter(fields) {
var arr = _toConsumableArray(fields).sort(function (a, b) {
return a.length - b.length;
});
for (var i = 0; i < arr.length; i++) {
for (var j = i + 1; j < arr.length; j++) {
if (arr[j].indexOf(arr[i]) == 0) {
// arr[j] is inside arr[i] (eg. "a.b" inside "a")
arr.splice(j, 1);
j--;
}
}
}
return arr;
};
// const topLevelFieldsFilter = (fields) => {
// let arr = [...fields].sort((a, b) => (a.length - b.length));
// for (let i = 0 ; i < arr.length ; i++) {
// for (let j = i + 1 ; j < arr.length ; j++) {
// if (arr[j].indexOf(arr[i]) == 0) {
// // arr[j] is inside arr[i] (eg. "a.b" inside "a")
// arr.splice(j, 1);
// j--;
// }
// }
// }
// return arr;
// };
var wrapInDefaultConjRuleGroup = function wrapInDefaultConjRuleGroup(rule, parentField, parentFieldConfig, config, conj) {

@@ -574,0 +576,0 @@ if (!rule) return undefined;

@@ -1304,8 +1304,27 @@ import _slicedToArray from "@babel/runtime/helpers/slicedToArray";

var mode = fieldConfig === null || fieldConfig === void 0 ? void 0 : fieldConfig.mode;
var res = _objectSpread(_objectSpread({}, groupFilter || {}), {}, {
type: "rule_group",
properties: _objectSpread(_objectSpread(_objectSpread({}, groupOpRule.properties), (groupFilter === null || groupFilter === void 0 ? void 0 : groupFilter.properties) || {}), {}, {
mode: mode
})
});
var res;
if ((groupFilter === null || groupFilter === void 0 ? void 0 : groupFilter.type) === "group") {
res = _objectSpread(_objectSpread({}, groupFilter || {}), {}, {
type: "rule_group",
properties: _objectSpread(_objectSpread(_objectSpread({}, groupOpRule.properties), (groupFilter === null || groupFilter === void 0 ? void 0 : groupFilter.properties) || {}), {}, {
mode: mode
})
});
} else if (groupFilter) {
// rule_group in rule_group
res = _objectSpread(_objectSpread({}, groupOpRule || {}), {}, {
type: "rule_group",
children1: [groupFilter],
properties: _objectSpread(_objectSpread({}, groupOpRule.properties), {}, {
mode: mode
})
});
} else {
res = _objectSpread(_objectSpread({}, groupOpRule || {}), {}, {
type: "rule_group",
properties: _objectSpread(_objectSpread({}, groupOpRule.properties), {}, {
mode: mode
})
});
}
if (!res.id) res.id = uuid();

@@ -1312,0 +1331,0 @@ return res;

@@ -134,3 +134,3 @@ /* eslint-disable no-extra-semi */

interface RuleProperties extends BasicItemProperties {
export interface RuleProperties extends BasicItemProperties {
field: FieldValue | Empty,

@@ -146,7 +146,7 @@ fieldSrc?: FieldSource,

interface RuleGroupExtProperties extends RuleProperties {
export interface RuleGroupExtProperties extends RuleProperties {
mode: RuleGroupMode,
}
interface RuleGroupProperties extends BasicItemProperties {
export interface RuleGroupProperties extends BasicItemProperties {
field: FieldPath | Empty,

@@ -156,3 +156,3 @@ mode?: RuleGroupMode,

interface GroupProperties extends BasicItemProperties {
export interface GroupProperties extends BasicItemProperties {
conjunction: string,

@@ -162,27 +162,56 @@ not?: boolean,

interface SwitchGroupProperties extends BasicItemProperties {
export interface SwitchGroupProperties extends BasicItemProperties {
}
interface CaseGroupProperties extends BasicItemProperties {
export interface CaseGroupProperties extends BasicItemProperties {
}
type JsonAnyRule = JsonRule|JsonRuleGroup|JsonRuleGroupExt;
type JsonItem = JsonGroup|JsonAnyRule;
type JsonSwitchGroup = {
//////
interface _RulePropertiesI extends RuleProperties {
value: ImmutableList<RuleValue>,
valueSrc?: ImmutableList<ValueSource>,
valueType?: ImmutableList<string>,
valueError?: ImmutableList<string>,
operatorOptions?: ImmMap,
}
interface _RuleGroupExtProperties extends _RulePropertiesI, RuleGroupExtProperties {}
interface ObjectToImmOMap<P> extends ImmutableOMap<keyof P, any> {
get<K extends keyof P>(name: K): P[K];
}
export interface BasicItemPropertiesI<P = BasicItemProperties> extends ObjectToImmOMap<P> {}
export interface ImmutableRuleProperties<P = _RulePropertiesI> extends BasicItemPropertiesI<P> {}
export interface ImmutableRuleGroupExtProperties<P = _RuleGroupExtProperties> extends ImmutableRuleProperties<P> {}
export interface ImmutableRuleGroupProperties<P = RuleGroupProperties> extends BasicItemPropertiesI<P> {}
export interface ImmutableGroupProperties<P = GroupProperties> extends BasicItemPropertiesI<P> {}
export interface ImmutableSwitchGroupProperties<P = SwitchGroupProperties> extends BasicItemPropertiesI<P> {}
export interface ImmutableCaseGroupProperties<P = CaseGroupProperties> extends BasicItemPropertiesI<P> {}
export type ImmutableItemProperties = ImmutableRuleProperties | ImmutableRuleGroupProperties | ImmutableRuleGroupExtProperties | ImmutableGroupProperties;
//////
export type JsonAnyRule = JsonRule|JsonRuleGroup|JsonRuleGroupExt;
export type JsonItem = JsonGroup|JsonAnyRule;
export interface JsonBasicItem {
type: ItemType,
id?: string,
}
export interface JsonSwitchGroup extends JsonBasicItem {
type: "switch_group",
id?: string,
children1?: {[id: string]: JsonCaseGroup} | JsonCaseGroup[],
properties?: SwitchGroupProperties
};
type JsonCaseGroup = {
}
export interface JsonCaseGroup extends JsonBasicItem {
type: "case_group",
id?: string,
children1?: {[id: string]: JsonGroup} | JsonGroup[],
properties?: CaseGroupProperties
};
type JsonGroup = {
}
export interface JsonGroup extends JsonBasicItem {
type: "group",
id?: string,
// tip: if got array, it will be converted to immutable ordered map in `_addChildren1`

@@ -192,17 +221,14 @@ children1?: {[id: string]: JsonItem} | JsonItem[],

}
type JsonRuleGroup = {
export interface JsonRuleGroup extends JsonBasicItem {
type: "rule_group",
id?: string,
children1?: {[id: string]: JsonRule} | JsonRule[],
properties?: RuleGroupProperties
}
type JsonRuleGroupExt = {
export interface JsonRuleGroupExt extends JsonBasicItem {
type: "rule_group",
id?: string,
children1?: {[id: string]: JsonRule} | JsonRule[],
properties?: RuleGroupExtProperties
}
type JsonRule = {
export interface JsonRule extends JsonBasicItem {
type: "rule",
id?: string,
properties: RuleProperties,

@@ -212,5 +238,49 @@ }

export type ImmutableTree = ImmutableOMap<string, any>;
export type ImmutableItem = ImmutableOMap<string, any>;
////
interface _BasicItemI {
type: ItemType,
id: string,
}
interface _RuleI extends _BasicItemI {
type: "rule",
properties: ImmutableRuleProperties,
}
interface _GroupI extends _BasicItemI {
type: "group",
children1?: ImmOMap<string, ImmutableItem>,
properties: ImmutableGroupProperties,
}
interface _RuleGroupI extends _BasicItemI {
type: "rule_group",
children1?: ImmOMap<string, ImmutableRule>,
properties: ImmutableRuleGroupProperties,
}
interface _RuleGroupExtI extends _BasicItemI {
type: "rule_group",
children1?: ImmOMap<string, ImmutableRule>,
properties: ImmutableRuleGroupExtProperties,
}
interface _SwitchGroupI extends _BasicItemI {
type: "switch_group",
children1?: ImmOMap<string, ImmutableSwitchGroup>,
properties: ImmutableSwitchGroupProperties,
}
interface _CaseGroupI extends _BasicItemI {
type: "case_group",
children1?: ImmOMap<string, ImmutableGroup>,
properties: ImmutableCaseGroupProperties,
}
export interface ImmutableBasicItem<P = _BasicItemI> extends ObjectToImmOMap<P> {}
export interface ImmutableRule<P = _RuleI> extends ImmutableBasicItem<P> {}
export interface ImmutableGroup<P = _GroupI> extends ImmutableBasicItem<P> {}
export interface ImmutableRuleGroup<P = _RuleGroupI> extends ImmutableBasicItem<P> {}
export interface ImmutableRuleGroupExt<P = _RuleGroupExtI> extends ImmutableBasicItem<P> {}
export interface ImmutableSwitchGroup<P = _SwitchGroupI> extends ImmutableBasicItem<P> {}
export interface ImmutableCaseGroup<P = _CaseGroupI> extends ImmutableBasicItem<P> {}
export type ImmutableAnyRule = ImmutableRule|ImmutableRuleGroup|ImmutableRuleGroupExt;
export type ImmutableItem = ImmutableGroup|ImmutableAnyRule;
export type ImmutableTree = ImmutableGroup|ImmutableSwitchGroup;
////////////////

@@ -217,0 +287,0 @@ // Utils

@@ -10,3 +10,3 @@ import _slicedToArray from "@babel/runtime/helpers/slicedToArray";

import { expandTreePath, expandTreeSubpath, getItemByPath, fixPathsInTree, getTotalRulesCountInTree, fixEmptyGroupsInTree, isEmptyTree, hasChildren, removeIsLockedInTree } from "../utils/treeUtils";
import { defaultRuleProperties, defaultGroupProperties, getDefaultOperator, defaultOperatorOptions, defaultRoot, defaultItemProperties } from "../utils/defaultUtils";
import { defaultRuleProperties, defaultGroupProperties, getDefaultOperator, defaultOperatorOptions, defaultItemProperties } from "../utils/defaultUtils";
import * as constants from "./constants";

@@ -750,4 +750,3 @@ import uuid from "../utils/uuid";

export default (function (config, tree, getMemoizedTree, setLastTree) {
var emptyTree = defaultRoot(config);
var initTree = tree || emptyTree;
var initTree = tree;
var emptyState = _objectSpread({

@@ -754,0 +753,0 @@ tree: initTree

@@ -138,6 +138,7 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";

export var defaultRoot = function defaultRoot(config) {
var canAddDefaultRule = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
return new Immutable.Map({
type: "group",
id: uuid(),
children1: new Immutable.OrderedMap(_objectSpread({}, defaultRule(uuid(), config))),
children1: new Immutable.OrderedMap(canAddDefaultRule ? _objectSpread({}, defaultRule(uuid(), config)) : {}),
properties: defaultGroupProperties(config)

@@ -144,0 +145,0 @@ });

@@ -179,6 +179,7 @@ import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";

return childId;
}) : null;
}).toArray() : null;
var isRuleGroup = type == "rule_group";
// tip: count rule_group as 1 rule
var isLeaf = !insideRuleGroup && (!children || isRuleGroup);
var hasChildren = (childrenIds === null || childrenIds === void 0 ? void 0 : childrenIds.length) > 0;
var itemsBefore = flat.length;

@@ -211,2 +212,3 @@ var top = realHeight;

};
var depth;
if (children) {

@@ -219,2 +221,6 @@ var subinfo = {};

info.height = (info.height || 0) + (subinfo.height || 0);
if (hasChildren && !isRuleGroup) {
// tip: don't count children of rule_group
depth = (subinfo.depth || 0) + 1;
}
}

@@ -233,2 +239,8 @@ }

});
if (depth != undefined) {
Object.assign(items[id], {
depth: depth
});
info.depth = Math.max(info.depth || 0, depth);
}
}

@@ -235,0 +247,0 @@ _flatizeTree(tree, [], false, false, false, 0, {}, null, null);

@@ -1239,3 +1239,3 @@ import {settings as defaultSettings} from "./default";

formatSpelField: function (field, parentField, parts, partsExt, fieldDefinition, config) {
let fieldName = partsExt.map(({key, parent}, ind) => {
let fieldName = partsExt.map(({key, parent, fieldSeparator: sep}, ind) => {
if (ind == 0) {

@@ -1252,5 +1252,5 @@ if (parent == "[map]")

else if (parent == "class" || parent == "[class]")
return `.${key}`;
return `${sep}${key}`;
else
return `.${key}`;
return `${sep}${key}`;
}

@@ -1257,0 +1257,0 @@ }).join("");

@@ -93,6 +93,2 @@ import {defaultValue, widgetDefKeysToOmit, opDefKeysToOmit} from "../utils/stuff";

const not = properties.get("not");
if (conj != "and" && conj != "or") {
meta.errors.push(`Conjunction ${conj} is not supported`);
return undefined;
}

@@ -99,0 +95,0 @@ const isRuleGroup = (type === "rule_group" && !isRoot);

@@ -56,3 +56,4 @@ import {defaultValue, widgetDefKeysToOmit, opDefKeysToOmit} from "../utils/stuff";

const children = item.get("children1") || new List();
const {canShortMongoQuery} = config.settings;
const {canShortMongoQuery, fieldSeparator} = config.settings;
const sep = fieldSeparator;

@@ -75,3 +76,3 @@ const hasParentRuleGroup = parents.filter(it => it.get("type") == "rule_group").length > 0;

.map((currentChild) => formatItem(
[...parents, item], currentChild, config, meta, not, mode != "array", mode == "array" ? (f => `$$el.${f}`) : undefined)
[...parents, item], currentChild, config, meta, not, mode != "array", mode == "array" ? (f => `$$el${sep}${f}`) : undefined)
)

@@ -78,0 +79,0 @@ .filter((currentChild) => typeof currentChild !== "undefined");

@@ -143,2 +143,3 @@ import {

const isSpelArray = groupFieldDef.isSpelArray;
const {fieldSeparator} = config.settings;

@@ -181,3 +182,4 @@ // check op for reverse

const formattedField = formatField(meta, config, field, parentField);
const getSize = isSpelArray ? ".length" : ".size()";
const sep = fieldSeparator || ".";
const getSize = sep + (isSpelArray ? "length" : "size()");
const fullSize = `${formattedField}${getSize}`;

@@ -436,3 +438,4 @@ // https://docs.spring.io/spring-framework/docs/3.2.x/spring-framework-reference/html/expressions.html#expressions-collection-selection

parent,
isSpelVariable
isSpelVariable,
fieldSeparator
};

@@ -439,0 +442,0 @@ });

@@ -433,3 +433,3 @@ import uuid from "../utils/uuid";

.map(fp => [fp.join(fieldSeparator), getFieldConfig(config, fp)])
.filter(([_f, fc]) => fc.type == "!group")
.filter(([_f, fc]) => fc?.type == "!group")
);

@@ -455,3 +455,3 @@ return [f, Object.keys(ancs)];

Object.entries(children).map(([k, v]) => {
if (v.type == "group" || v.type == "rule_group") {
if (v?.type == "group" || v?.type == "rule_group") {
// put as-is

@@ -465,3 +465,5 @@ children1[k] = v;

// not in rule_group (can be simple field or in struct) - put as-is
children1[k] = v;
if (v) {
children1[k] = v;
}
} else {

@@ -520,15 +522,15 @@ // wrap field in rule_group (with creating hierarchy if need)

const topLevelFieldsFilter = (fields) => {
let arr = [...fields].sort((a, b) => (a.length - b.length));
for (let i = 0 ; i < arr.length ; i++) {
for (let j = i + 1 ; j < arr.length ; j++) {
if (arr[j].indexOf(arr[i]) == 0) {
// arr[j] is inside arr[i] (eg. "a.b" inside "a")
arr.splice(j, 1);
j--;
}
}
}
return arr;
};
// const topLevelFieldsFilter = (fields) => {
// let arr = [...fields].sort((a, b) => (a.length - b.length));
// for (let i = 0 ; i < arr.length ; i++) {
// for (let j = i + 1 ; j < arr.length ; j++) {
// if (arr[j].indexOf(arr[i]) == 0) {
// // arr[j] is inside arr[i] (eg. "a.b" inside "a")
// arr.splice(j, 1);
// j--;
// }
// }
// }
// return arr;
// };

@@ -535,0 +537,0 @@ const wrapInDefaultConjRuleGroup = (rule, parentField, parentFieldConfig, config, conj) => {

@@ -520,3 +520,3 @@ import { SpelExpressionEvaluator } from "spel2js";

const convertChildren = () => {
let newChildren = spel.children.map(child =>
let newChildren = spel.children.map(child =>
convertToTree(child, conv, config, meta, {

@@ -1117,11 +1117,36 @@ ...spel,

const mode = fieldConfig?.mode;
let res = {
...(groupFilter || {}),
type: "rule_group",
properties: {
...groupOpRule.properties,
...(groupFilter?.properties || {}),
mode
}
};
let res;
if (groupFilter?.type === "group") {
res = {
...(groupFilter || {}),
type: "rule_group",
properties: {
...groupOpRule.properties,
...(groupFilter?.properties || {}),
mode
}
};
} else if (groupFilter) {
// rule_group in rule_group
res = {
...(groupOpRule || {}),
type: "rule_group",
children1: [ groupFilter ],
properties: {
...groupOpRule.properties,
mode
}
};
} else {
res = {
...(groupOpRule || {}),
type: "rule_group",
properties: {
...groupOpRule.properties,
mode
}
};
}
if (!res.id)

@@ -1128,0 +1153,0 @@ res.id = uuid();

@@ -134,3 +134,3 @@ /* eslint-disable no-extra-semi */

interface RuleProperties extends BasicItemProperties {
export interface RuleProperties extends BasicItemProperties {
field: FieldValue | Empty,

@@ -146,7 +146,7 @@ fieldSrc?: FieldSource,

interface RuleGroupExtProperties extends RuleProperties {
export interface RuleGroupExtProperties extends RuleProperties {
mode: RuleGroupMode,
}
interface RuleGroupProperties extends BasicItemProperties {
export interface RuleGroupProperties extends BasicItemProperties {
field: FieldPath | Empty,

@@ -156,3 +156,3 @@ mode?: RuleGroupMode,

interface GroupProperties extends BasicItemProperties {
export interface GroupProperties extends BasicItemProperties {
conjunction: string,

@@ -162,27 +162,56 @@ not?: boolean,

interface SwitchGroupProperties extends BasicItemProperties {
export interface SwitchGroupProperties extends BasicItemProperties {
}
interface CaseGroupProperties extends BasicItemProperties {
export interface CaseGroupProperties extends BasicItemProperties {
}
type JsonAnyRule = JsonRule|JsonRuleGroup|JsonRuleGroupExt;
type JsonItem = JsonGroup|JsonAnyRule;
type JsonSwitchGroup = {
//////
interface _RulePropertiesI extends RuleProperties {
value: ImmutableList<RuleValue>,
valueSrc?: ImmutableList<ValueSource>,
valueType?: ImmutableList<string>,
valueError?: ImmutableList<string>,
operatorOptions?: ImmMap,
}
interface _RuleGroupExtProperties extends _RulePropertiesI, RuleGroupExtProperties {}
interface ObjectToImmOMap<P> extends ImmutableOMap<keyof P, any> {
get<K extends keyof P>(name: K): P[K];
}
export interface BasicItemPropertiesI<P = BasicItemProperties> extends ObjectToImmOMap<P> {}
export interface ImmutableRuleProperties<P = _RulePropertiesI> extends BasicItemPropertiesI<P> {}
export interface ImmutableRuleGroupExtProperties<P = _RuleGroupExtProperties> extends ImmutableRuleProperties<P> {}
export interface ImmutableRuleGroupProperties<P = RuleGroupProperties> extends BasicItemPropertiesI<P> {}
export interface ImmutableGroupProperties<P = GroupProperties> extends BasicItemPropertiesI<P> {}
export interface ImmutableSwitchGroupProperties<P = SwitchGroupProperties> extends BasicItemPropertiesI<P> {}
export interface ImmutableCaseGroupProperties<P = CaseGroupProperties> extends BasicItemPropertiesI<P> {}
export type ImmutableItemProperties = ImmutableRuleProperties | ImmutableRuleGroupProperties | ImmutableRuleGroupExtProperties | ImmutableGroupProperties;
//////
export type JsonAnyRule = JsonRule|JsonRuleGroup|JsonRuleGroupExt;
export type JsonItem = JsonGroup|JsonAnyRule;
export interface JsonBasicItem {
type: ItemType,
id?: string,
}
export interface JsonSwitchGroup extends JsonBasicItem {
type: "switch_group",
id?: string,
children1?: {[id: string]: JsonCaseGroup} | JsonCaseGroup[],
properties?: SwitchGroupProperties
};
type JsonCaseGroup = {
}
export interface JsonCaseGroup extends JsonBasicItem {
type: "case_group",
id?: string,
children1?: {[id: string]: JsonGroup} | JsonGroup[],
properties?: CaseGroupProperties
};
type JsonGroup = {
}
export interface JsonGroup extends JsonBasicItem {
type: "group",
id?: string,
// tip: if got array, it will be converted to immutable ordered map in `_addChildren1`

@@ -192,17 +221,14 @@ children1?: {[id: string]: JsonItem} | JsonItem[],

}
type JsonRuleGroup = {
export interface JsonRuleGroup extends JsonBasicItem {
type: "rule_group",
id?: string,
children1?: {[id: string]: JsonRule} | JsonRule[],
properties?: RuleGroupProperties
}
type JsonRuleGroupExt = {
export interface JsonRuleGroupExt extends JsonBasicItem {
type: "rule_group",
id?: string,
children1?: {[id: string]: JsonRule} | JsonRule[],
properties?: RuleGroupExtProperties
}
type JsonRule = {
export interface JsonRule extends JsonBasicItem {
type: "rule",
id?: string,
properties: RuleProperties,

@@ -212,5 +238,49 @@ }

export type ImmutableTree = ImmutableOMap<string, any>;
export type ImmutableItem = ImmutableOMap<string, any>;
////
interface _BasicItemI {
type: ItemType,
id: string,
}
interface _RuleI extends _BasicItemI {
type: "rule",
properties: ImmutableRuleProperties,
}
interface _GroupI extends _BasicItemI {
type: "group",
children1?: ImmOMap<string, ImmutableItem>,
properties: ImmutableGroupProperties,
}
interface _RuleGroupI extends _BasicItemI {
type: "rule_group",
children1?: ImmOMap<string, ImmutableRule>,
properties: ImmutableRuleGroupProperties,
}
interface _RuleGroupExtI extends _BasicItemI {
type: "rule_group",
children1?: ImmOMap<string, ImmutableRule>,
properties: ImmutableRuleGroupExtProperties,
}
interface _SwitchGroupI extends _BasicItemI {
type: "switch_group",
children1?: ImmOMap<string, ImmutableSwitchGroup>,
properties: ImmutableSwitchGroupProperties,
}
interface _CaseGroupI extends _BasicItemI {
type: "case_group",
children1?: ImmOMap<string, ImmutableGroup>,
properties: ImmutableCaseGroupProperties,
}
export interface ImmutableBasicItem<P = _BasicItemI> extends ObjectToImmOMap<P> {}
export interface ImmutableRule<P = _RuleI> extends ImmutableBasicItem<P> {}
export interface ImmutableGroup<P = _GroupI> extends ImmutableBasicItem<P> {}
export interface ImmutableRuleGroup<P = _RuleGroupI> extends ImmutableBasicItem<P> {}
export interface ImmutableRuleGroupExt<P = _RuleGroupExtI> extends ImmutableBasicItem<P> {}
export interface ImmutableSwitchGroup<P = _SwitchGroupI> extends ImmutableBasicItem<P> {}
export interface ImmutableCaseGroup<P = _CaseGroupI> extends ImmutableBasicItem<P> {}
export type ImmutableAnyRule = ImmutableRule|ImmutableRuleGroup|ImmutableRuleGroupExt;
export type ImmutableItem = ImmutableGroup|ImmutableAnyRule;
export type ImmutableTree = ImmutableGroup|ImmutableSwitchGroup;
////////////////

@@ -217,0 +287,0 @@ // Utils

@@ -8,3 +8,3 @@ import Immutable from "immutable";

defaultRuleProperties, defaultGroupProperties, getDefaultOperator,
defaultOperatorOptions, defaultRoot, defaultItemProperties
defaultOperatorOptions, defaultItemProperties
} from "../utils/defaultUtils";

@@ -789,4 +789,3 @@ import * as constants from "./constants";

export default (config, tree, getMemoizedTree, setLastTree) => {
const emptyTree = defaultRoot(config);
const initTree = tree || emptyTree;
const initTree = tree;
const emptyState = {

@@ -793,0 +792,0 @@ tree: initTree,

@@ -142,7 +142,7 @@ import Immutable from "immutable";

export const defaultRoot = (config) => {
export const defaultRoot = (config, canAddDefaultRule = true) => {
return new Immutable.Map({
type: "group",
id: uuid(),
children1: new Immutable.OrderedMap({ ...defaultRule(uuid(), config) }),
children1: new Immutable.OrderedMap(canAddDefaultRule ? { ...defaultRule(uuid(), config) } : {}),
properties: defaultGroupProperties(config)

@@ -149,0 +149,0 @@ });

@@ -189,6 +189,7 @@ import Immutable from "immutable";

const isLocked = item.getIn(["properties", "isLocked"]);
const childrenIds = children ? children.map((_child, childId) => childId) : null;
const childrenIds = children ? children.map((_child, childId) => childId).toArray() : null;
const isRuleGroup = type == "rule_group";
// tip: count rule_group as 1 rule
const isLeaf = !insideRuleGroup && (!children || isRuleGroup);
const hasChildren = childrenIds?.length > 0;

@@ -225,2 +226,3 @@ const itemsBefore = flat.length;

let depth;
if (children) {

@@ -237,2 +239,5 @@ let subinfo = {};

info.height = (info.height || 0) + (subinfo.height || 0);
if (hasChildren && !isRuleGroup) { // tip: don't count children of rule_group
depth = (subinfo.depth || 0) + 1;
}
}

@@ -254,2 +259,8 @@ }

});
if (depth != undefined) {
Object.assign(items[id], {
depth: depth,
});
info.depth = Math.max(info.depth || 0, depth);
}
}

@@ -256,0 +267,0 @@

{
"name": "@react-awesome-query-builder/core",
"version": "6.4.0",
"version": "6.4.1",
"description": "User-friendly query builder for React. Core",

@@ -5,0 +5,0 @@ "keywords": [

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc