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.6.3 to 6.6.4-alpha.0

16

cjs/actions/tree.js

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

var children = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : null;
var parentRuleGroupPath = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : null;
var parentRuleGroupField = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : null;
return {

@@ -44,4 +44,7 @@ type: constants.ADD_RULE,

id: (0, _uuid["default"])(),
properties: (0, _defaultUtils.defaultRuleProperties)(config, parentRuleGroupPath).merge((0, _immutable.fromJS)(properties) || {}),
config: config
properties: (0, _defaultUtils.defaultRuleProperties)(config, parentRuleGroupField).merge((0, _immutable.fromJS)(properties) || {}),
config: config,
meta: {
parentRuleGroupField: parentRuleGroupField
}
};

@@ -106,2 +109,3 @@ };

var children = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null;
var parentRuleGroupField = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : null;
return {

@@ -112,4 +116,8 @@ type: constants.ADD_GROUP,

id: (0, _uuid["default"])(),
// todo: use parentRuleGroupField in defaultGroupProperties (for default conj)
properties: (0, _defaultUtils.defaultGroupProperties)(config).merge((0, _immutable.fromJS)(properties) || {}),
config: config
config: config,
meta: {
parentRuleGroupField: parentRuleGroupField
}
};

@@ -116,0 +124,0 @@ };

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

addSubRuleLabel: "Add sub rule",
addSubGroupLabel: "Add sub group",
delGroupLabel: "Delete",

@@ -63,0 +64,0 @@ notLabel: "Not",

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

var wrapInDefaultConjRuleGroup = function wrapInDefaultConjRuleGroup(rule, parentField, parentFieldConfig, config) {
var wrapInDefaultConjRuleGroup = function wrapInDefaultConjRuleGroup(rule, groupField, groupFieldConfig, config) {
var conj = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : undefined;

@@ -729,5 +729,5 @@ var not = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : false;

properties: {
conjunction: conj || (0, _defaultUtils.defaultGroupConjunction)(config, parentFieldConfig),
conjunction: conj || (0, _defaultUtils.defaultGroupConjunction)(config, groupFieldConfig),
not: not,
field: parentField
field: groupField
}

@@ -734,0 +734,0 @@ };

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

// const wrapInDefaultConjRuleGroup = (rule, parentField, parentFieldConfig, config, conj) => {
// const wrapInDefaultConjRuleGroup = (rule, groupField, groupFieldConfig, config, conj) => {
// if (!rule) return undefined;

@@ -1511,5 +1511,5 @@ // return {

// properties: {
// conjunction: conj || defaultGroupConjunction(config, parentFieldConfig),
// conjunction: conj || defaultGroupConjunction(config, groupFieldConfig),
// not: false,
// field: parentField,
// field: groupField,
// }

@@ -1516,0 +1516,0 @@ // };

@@ -549,4 +549,4 @@ /* eslint-disable no-extra-semi */

interface DefaultUtils {
getDefaultField(config: Config, canGetFirst?: boolean, parentRuleGroupPath?: IdPath): FieldValueI | null;
getDefaultSubField(config: Config, parentRuleGroupPath?: IdPath): FieldValueI | null;
getDefaultField(config: Config, canGetFirst?: boolean, parentRuleGroupField?: string): FieldValueI | null;
getDefaultSubField(config: Config, parentRuleGroupField?: string): FieldValueI | null;
getDefaultFieldSrc(config: Config, canGetFirst?: boolean): string;

@@ -557,7 +557,7 @@ getDefaultOperator(config: Config, field: Field, canGetFirst?: boolean): string;

defaultItemProperties(config: Config, item: JsonItem): ImmutableItemProperties;
defaultGroupProperties(config: Config, fieldConfig?: FieldValueOrConfig): ImmutableGroupProperties;
defaultRuleProperties(config: Config, parentRuleGroupPath?: IdPath, item?: JsonItem, canUseDefaultFieldAndOp?: boolean, canGetFirst?: boolean): ImmutableRuleProperties;
defaultGroupProperties(config: Config, groupFieldConfig?: FieldValueOrConfig): ImmutableGroupProperties;
defaultRuleProperties(config: Config, parentRuleGroupField?: string, item?: JsonItem, canUseDefaultFieldAndOp?: boolean, canGetFirst?: boolean): ImmutableRuleProperties;
defaultConjunction(config: Config): string;
defaultOperatorOptions(config: Config, operator: string, field: Field): OperatorOptionsI | null;
defaultGroupConjunction(config: Config, fieldConfig?: FieldValueOrConfig): string;
defaultGroupConjunction(config: Config, groupFieldConfig?: FieldValueOrConfig): string;

@@ -1261,2 +1261,3 @@ // createListWithOneElement<TItem>(el: TItem): ImmutableList<TItem>;

fieldSettings?: FS;
maxNesting?: number;
}

@@ -1344,2 +1345,3 @@ interface FieldGroupExt<FS = NumberFieldSettings<number>> extends BaseField {

addSubRuleLabel?: string;
addSubGroupLabel?: string;
delGroupLabel?: string;

@@ -1346,0 +1348,0 @@ notLabel?: string;

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

if (canAddNewRule) {
state = addItem(state, groupPath, "rule", (0, _uuid["default"])(), (0, _defaultUtils.defaultRuleProperties)(config), config);
state = addItem(state, groupPath, "rule", (0, _uuid["default"])(), (0, _defaultUtils.defaultRuleProperties)(config, meta.parentRuleGroupField), config);
}

@@ -221,2 +221,3 @@ }

} else if ((targetItem === null || targetItem === void 0 ? void 0 : targetItem.get("type")) === "rule_group") {
// todo
// don't restrict

@@ -584,3 +585,3 @@ } else {

operatorCardinality = _getNewValueForFieldO.operatorCardinality;
var groupProperties = (0, _defaultUtils.defaultGroupProperties)(config, newFieldConfig).merge({
var groupProperties = (0, _defaultUtils.defaultGroupProperties)(config, newFieldConfig, newField).merge({
field: newField,

@@ -587,0 +588,0 @@ fieldSrc: "field",

@@ -435,6 +435,6 @@ "use strict";

var getFirstField = exports.getFirstField = function getFirstField(config) {
var parentRuleGroupPath = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
var parentRuleGroupField = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
var fieldSeparator = config.settings.fieldSeparator;
var parentPathArr = getFieldParts(parentRuleGroupPath, config);
var parentField = parentRuleGroupPath ? getFieldRawConfig(config, parentRuleGroupPath) : config;
var parentPathArr = getFieldParts(parentRuleGroupField, config);
var parentField = parentRuleGroupField ? getFieldRawConfig(config, parentRuleGroupField) : config;
var firstField = parentField,

@@ -441,0 +441,0 @@ key = null,

@@ -21,5 +21,5 @@ "use strict";

var canGetFirst = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
var parentRuleGroupPath = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
var parentRuleGroupField = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
var defaultField = config.settings.defaultField;
var f = (!parentRuleGroupPath ? defaultField : getDefaultSubField(config, parentRuleGroupPath)) || canGetFirst && (0, _configUtils.getFirstField)(config, parentRuleGroupPath) || null;
var f = (!parentRuleGroupField ? defaultField : getDefaultSubField(config, parentRuleGroupField)) || canGetFirst && (0, _configUtils.getFirstField)(config, parentRuleGroupField) || null;
// if default LHS is func, convert to Immutable

@@ -33,9 +33,9 @@ if (f != null && typeof f !== "string" && !(0, _stuff.isImmutable)(f)) {

var _config$settings;
var parentRuleGroupPath = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
if (!parentRuleGroupPath) return null;
var parentRuleGroupField = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
if (!parentRuleGroupField) return null;
var fieldSeparator = (config === null || config === void 0 || (_config$settings = config.settings) === null || _config$settings === void 0 ? void 0 : _config$settings.fieldSeparator) || ".";
var parentRuleGroupConfig = (0, _configUtils.getFieldConfig)(config, parentRuleGroupPath);
var parentRuleGroupConfig = (0, _configUtils.getFieldConfig)(config, parentRuleGroupField);
var f = parentRuleGroupConfig === null || parentRuleGroupConfig === void 0 ? void 0 : parentRuleGroupConfig.defaultField;
if (f) {
f = [].concat((0, _toConsumableArray2["default"])((0, _configUtils.getFieldParts)(parentRuleGroupPath)), [f]).join(fieldSeparator);
f = [].concat((0, _toConsumableArray2["default"])((0, _configUtils.getFieldParts)(parentRuleGroupField)), [f]).join(fieldSeparator);
}

@@ -69,3 +69,3 @@ return f;

var defaultRuleProperties = exports.defaultRuleProperties = function defaultRuleProperties(config) {
var parentRuleGroupPath = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
var parentRuleGroupField = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
var item = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;

@@ -84,3 +84,3 @@ var canUseDefaultFieldAndOp = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : true;

} else if (canUseDefaultFieldAndOp) {
field = getDefaultField(config, canGetFirst, parentRuleGroupPath);
field = getDefaultField(config, canGetFirst, parentRuleGroupField);
if (field) {

@@ -120,8 +120,13 @@ fieldSrc = (0, _stuff.isImmutable)(field) ? "func" : "field";

}
var fieldConfig = (0, _configUtils.getFieldConfig)(config, field);
if ((fieldConfig === null || fieldConfig === void 0 ? void 0 : fieldConfig.type) === "!group") {
var conjunction = defaultGroupConjunction(config, fieldConfig);
current = current.set("conjunction", conjunction);
}
return current;
};
var defaultGroupConjunction = exports.defaultGroupConjunction = function defaultGroupConjunction(config) {
var fieldConfig = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
fieldConfig = (0, _configUtils.getFieldConfig)(config, fieldConfig); // if `fieldConfig` is field name, not config
var conjs = fieldConfig && fieldConfig.conjunctions || Object.keys(config.conjunctions);
var groupFieldConfig = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
groupFieldConfig = (0, _configUtils.getFieldConfig)(config, groupFieldConfig); // if `groupFieldConfig` is field name, not config
var conjs = groupFieldConfig && groupFieldConfig.conjunctions || Object.keys(config.conjunctions);
if (conjs.length == 1) return conjs[0];

@@ -134,5 +139,5 @@ return config.settings.defaultGroupConjunction || config.settings.defaultConjunction || conjs[0];

var defaultGroupProperties = exports.defaultGroupProperties = function defaultGroupProperties(config) {
var fieldConfig = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
var groupFieldConfig = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
return new _immutable["default"].Map({
conjunction: defaultGroupConjunction(config, fieldConfig),
conjunction: defaultGroupConjunction(config, groupFieldConfig),
not: false

@@ -142,4 +147,3 @@ });

var defaultItemProperties = exports.defaultItemProperties = function defaultItemProperties(config, item) {
var _item$properties4;
return item && item.type == "group" ? defaultGroupProperties(config, item === null || item === void 0 || (_item$properties4 = item.properties) === null || _item$properties4 === void 0 ? void 0 : _item$properties4.field) : defaultRuleProperties(config, null, item);
return (item === null || item === void 0 ? void 0 : item.type) == "group" ? defaultGroupProperties(config) : defaultRuleProperties(config, null, item);
};

@@ -146,0 +150,0 @@ var defaultRule = exports.defaultRule = function defaultRule(id, config) {

@@ -27,3 +27,3 @@ import Immutable, { fromJS } from "immutable";

var children = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : null;
var parentRuleGroupPath = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : null;
var parentRuleGroupField = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : null;
return {

@@ -35,4 +35,7 @@ type: constants.ADD_RULE,

id: uuid(),
properties: defaultRuleProperties(config, parentRuleGroupPath).merge(fromJS(properties) || {}),
config: config
properties: defaultRuleProperties(config, parentRuleGroupField).merge(fromJS(properties) || {}),
config: config,
meta: {
parentRuleGroupField: parentRuleGroupField
}
};

@@ -97,2 +100,3 @@ };

var children = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null;
var parentRuleGroupField = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : null;
return {

@@ -103,4 +107,8 @@ type: constants.ADD_GROUP,

id: uuid(),
// todo: use parentRuleGroupField in defaultGroupProperties (for default conj)
properties: defaultGroupProperties(config).merge(fromJS(properties) || {}),
config: config
config: config,
meta: {
parentRuleGroupField: parentRuleGroupField
}
};

@@ -107,0 +115,0 @@ };

@@ -55,2 +55,3 @@ export var settings = {

addSubRuleLabel: "Add sub rule",
addSubGroupLabel: "Add sub group",
delGroupLabel: "Delete",

@@ -57,0 +58,0 @@ notLabel: "Not",

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

var wrapInDefaultConjRuleGroup = function wrapInDefaultConjRuleGroup(rule, parentField, parentFieldConfig, config) {
var wrapInDefaultConjRuleGroup = function wrapInDefaultConjRuleGroup(rule, groupField, groupFieldConfig, config) {
var conj = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : undefined;

@@ -723,5 +723,5 @@ var not = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : false;

properties: {
conjunction: conj || defaultGroupConjunction(config, parentFieldConfig),
conjunction: conj || defaultGroupConjunction(config, groupFieldConfig),
not: not,
field: parentField
field: groupField
}

@@ -728,0 +728,0 @@ };

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

// const wrapInDefaultConjRuleGroup = (rule, parentField, parentFieldConfig, config, conj) => {
// const wrapInDefaultConjRuleGroup = (rule, groupField, groupFieldConfig, config, conj) => {
// if (!rule) return undefined;

@@ -1505,5 +1505,5 @@ // return {

// properties: {
// conjunction: conj || defaultGroupConjunction(config, parentFieldConfig),
// conjunction: conj || defaultGroupConjunction(config, groupFieldConfig),
// not: false,
// field: parentField,
// field: groupField,
// }

@@ -1510,0 +1510,0 @@ // };

@@ -549,4 +549,4 @@ /* eslint-disable no-extra-semi */

interface DefaultUtils {
getDefaultField(config: Config, canGetFirst?: boolean, parentRuleGroupPath?: IdPath): FieldValueI | null;
getDefaultSubField(config: Config, parentRuleGroupPath?: IdPath): FieldValueI | null;
getDefaultField(config: Config, canGetFirst?: boolean, parentRuleGroupField?: string): FieldValueI | null;
getDefaultSubField(config: Config, parentRuleGroupField?: string): FieldValueI | null;
getDefaultFieldSrc(config: Config, canGetFirst?: boolean): string;

@@ -557,7 +557,7 @@ getDefaultOperator(config: Config, field: Field, canGetFirst?: boolean): string;

defaultItemProperties(config: Config, item: JsonItem): ImmutableItemProperties;
defaultGroupProperties(config: Config, fieldConfig?: FieldValueOrConfig): ImmutableGroupProperties;
defaultRuleProperties(config: Config, parentRuleGroupPath?: IdPath, item?: JsonItem, canUseDefaultFieldAndOp?: boolean, canGetFirst?: boolean): ImmutableRuleProperties;
defaultGroupProperties(config: Config, groupFieldConfig?: FieldValueOrConfig): ImmutableGroupProperties;
defaultRuleProperties(config: Config, parentRuleGroupField?: string, item?: JsonItem, canUseDefaultFieldAndOp?: boolean, canGetFirst?: boolean): ImmutableRuleProperties;
defaultConjunction(config: Config): string;
defaultOperatorOptions(config: Config, operator: string, field: Field): OperatorOptionsI | null;
defaultGroupConjunction(config: Config, fieldConfig?: FieldValueOrConfig): string;
defaultGroupConjunction(config: Config, groupFieldConfig?: FieldValueOrConfig): string;

@@ -1261,2 +1261,3 @@ // createListWithOneElement<TItem>(el: TItem): ImmutableList<TItem>;

fieldSettings?: FS;
maxNesting?: number;
}

@@ -1344,2 +1345,3 @@ interface FieldGroupExt<FS = NumberFieldSettings<number>> extends BaseField {

addSubRuleLabel?: string;
addSubGroupLabel?: string;
delGroupLabel?: string;

@@ -1346,0 +1348,0 @@ notLabel?: string;

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

if (canAddNewRule) {
state = addItem(state, groupPath, "rule", uuid(), defaultRuleProperties(config), config);
state = addItem(state, groupPath, "rule", uuid(), defaultRuleProperties(config, meta.parentRuleGroupField), config);
}

@@ -212,2 +212,3 @@ }

} else if ((targetItem === null || targetItem === void 0 ? void 0 : targetItem.get("type")) === "rule_group") {
// todo
// don't restrict

@@ -575,3 +576,3 @@ } else {

operatorCardinality = _getNewValueForFieldO.operatorCardinality;
var groupProperties = defaultGroupProperties(config, newFieldConfig).merge({
var groupProperties = defaultGroupProperties(config, newFieldConfig, newField).merge({
field: newField,

@@ -578,0 +579,0 @@ fieldSrc: "field",

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

export var getFirstField = function getFirstField(config) {
var parentRuleGroupPath = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
var parentRuleGroupField = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
var fieldSeparator = config.settings.fieldSeparator;
var parentPathArr = getFieldParts(parentRuleGroupPath, config);
var parentField = parentRuleGroupPath ? getFieldRawConfig(config, parentRuleGroupPath) : config;
var parentPathArr = getFieldParts(parentRuleGroupField, config);
var parentField = parentRuleGroupField ? getFieldRawConfig(config, parentRuleGroupField) : config;
var firstField = parentField,

@@ -376,0 +376,0 @@ key = null,

@@ -14,5 +14,5 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";

var canGetFirst = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
var parentRuleGroupPath = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
var parentRuleGroupField = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
var defaultField = config.settings.defaultField;
var f = (!parentRuleGroupPath ? defaultField : getDefaultSubField(config, parentRuleGroupPath)) || canGetFirst && getFirstField(config, parentRuleGroupPath) || null;
var f = (!parentRuleGroupField ? defaultField : getDefaultSubField(config, parentRuleGroupField)) || canGetFirst && getFirstField(config, parentRuleGroupField) || null;
// if default LHS is func, convert to Immutable

@@ -26,9 +26,9 @@ if (f != null && typeof f !== "string" && !isImmutable(f)) {

var _config$settings;
var parentRuleGroupPath = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
if (!parentRuleGroupPath) return null;
var parentRuleGroupField = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
if (!parentRuleGroupField) return null;
var fieldSeparator = (config === null || config === void 0 || (_config$settings = config.settings) === null || _config$settings === void 0 ? void 0 : _config$settings.fieldSeparator) || ".";
var parentRuleGroupConfig = getFieldConfig(config, parentRuleGroupPath);
var parentRuleGroupConfig = getFieldConfig(config, parentRuleGroupField);
var f = parentRuleGroupConfig === null || parentRuleGroupConfig === void 0 ? void 0 : parentRuleGroupConfig.defaultField;
if (f) {
f = [].concat(_toConsumableArray(getFieldParts(parentRuleGroupPath)), [f]).join(fieldSeparator);
f = [].concat(_toConsumableArray(getFieldParts(parentRuleGroupField)), [f]).join(fieldSeparator);
}

@@ -62,3 +62,3 @@ return f;

export var defaultRuleProperties = function defaultRuleProperties(config) {
var parentRuleGroupPath = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
var parentRuleGroupField = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
var item = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;

@@ -77,3 +77,3 @@ var canUseDefaultFieldAndOp = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : true;

} else if (canUseDefaultFieldAndOp) {
field = getDefaultField(config, canGetFirst, parentRuleGroupPath);
field = getDefaultField(config, canGetFirst, parentRuleGroupField);
if (field) {

@@ -113,8 +113,13 @@ fieldSrc = isImmutable(field) ? "func" : "field";

}
var fieldConfig = getFieldConfig(config, field);
if ((fieldConfig === null || fieldConfig === void 0 ? void 0 : fieldConfig.type) === "!group") {
var conjunction = defaultGroupConjunction(config, fieldConfig);
current = current.set("conjunction", conjunction);
}
return current;
};
export var defaultGroupConjunction = function defaultGroupConjunction(config) {
var fieldConfig = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
fieldConfig = getFieldConfig(config, fieldConfig); // if `fieldConfig` is field name, not config
var conjs = fieldConfig && fieldConfig.conjunctions || Object.keys(config.conjunctions);
var groupFieldConfig = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
groupFieldConfig = getFieldConfig(config, groupFieldConfig); // if `groupFieldConfig` is field name, not config
var conjs = groupFieldConfig && groupFieldConfig.conjunctions || Object.keys(config.conjunctions);
if (conjs.length == 1) return conjs[0];

@@ -127,5 +132,5 @@ return config.settings.defaultGroupConjunction || config.settings.defaultConjunction || conjs[0];

export var defaultGroupProperties = function defaultGroupProperties(config) {
var fieldConfig = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
var groupFieldConfig = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
return new Immutable.Map({
conjunction: defaultGroupConjunction(config, fieldConfig),
conjunction: defaultGroupConjunction(config, groupFieldConfig),
not: false

@@ -135,4 +140,3 @@ });

export var defaultItemProperties = function defaultItemProperties(config, item) {
var _item$properties4;
return item && item.type == "group" ? defaultGroupProperties(config, item === null || item === void 0 || (_item$properties4 = item.properties) === null || _item$properties4 === void 0 ? void 0 : _item$properties4.field) : defaultRuleProperties(config, null, item);
return (item === null || item === void 0 ? void 0 : item.type) == "group" ? defaultGroupProperties(config) : defaultRuleProperties(config, null, item);
};

@@ -139,0 +143,0 @@ export var defaultRule = function defaultRule(id, config) {

@@ -23,3 +23,3 @@ import Immutable, {fromJS} from "immutable";

*/
export const addRule = (config, path, properties, ruleType = "rule", children = null, parentRuleGroupPath = null) => ({
export const addRule = (config, path, properties, ruleType = "rule", children = null, parentRuleGroupField = null) => ({
type: constants.ADD_RULE,

@@ -30,4 +30,7 @@ ruleType: ruleType,

id: uuid(),
properties: defaultRuleProperties(config, parentRuleGroupPath).merge(fromJS(properties) || {}),
config: config
properties: defaultRuleProperties(config, parentRuleGroupField).merge(fromJS(properties) || {}),
config: config,
meta: {
parentRuleGroupField,
},
});

@@ -81,3 +84,3 @@

*/
export const addGroup = (config, path, properties, children = null) => ({
export const addGroup = (config, path, properties, children = null, parentRuleGroupField = null) => ({
type: constants.ADD_GROUP,

@@ -87,4 +90,8 @@ path: toImmutableList(path),

id: uuid(),
// todo: use parentRuleGroupField in defaultGroupProperties (for default conj)
properties: defaultGroupProperties(config).merge(fromJS(properties) || {}),
config: config
config: config,
meta: {
parentRuleGroupField,
},
});

@@ -91,0 +98,0 @@

@@ -59,2 +59,3 @@ export const settings = {

addSubRuleLabel: "Add sub rule",
addSubGroupLabel: "Add sub group",
delGroupLabel: "Delete",

@@ -61,0 +62,0 @@ notLabel: "Not",

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

const wrapInDefaultConjRuleGroup = (rule, parentField, parentFieldConfig, config, conj = undefined, not = false) => {
const wrapInDefaultConjRuleGroup = (rule, groupField, groupFieldConfig, config, conj = undefined, not = false) => {
if (!rule) return undefined;

@@ -680,5 +680,5 @@ return {

properties: {
conjunction: conj || defaultGroupConjunction(config, parentFieldConfig),
conjunction: conj || defaultGroupConjunction(config, groupFieldConfig),
not: not,
field: parentField,
field: groupField,
}

@@ -685,0 +685,0 @@ };

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

// const wrapInDefaultConjRuleGroup = (rule, parentField, parentFieldConfig, config, conj) => {
// const wrapInDefaultConjRuleGroup = (rule, groupField, groupFieldConfig, config, conj) => {
// if (!rule) return undefined;

@@ -1313,5 +1313,5 @@ // return {

// properties: {
// conjunction: conj || defaultGroupConjunction(config, parentFieldConfig),
// conjunction: conj || defaultGroupConjunction(config, groupFieldConfig),
// not: false,
// field: parentField,
// field: groupField,
// }

@@ -1318,0 +1318,0 @@ // };

@@ -549,4 +549,4 @@ /* eslint-disable no-extra-semi */

interface DefaultUtils {
getDefaultField(config: Config, canGetFirst?: boolean, parentRuleGroupPath?: IdPath): FieldValueI | null;
getDefaultSubField(config: Config, parentRuleGroupPath?: IdPath): FieldValueI | null;
getDefaultField(config: Config, canGetFirst?: boolean, parentRuleGroupField?: string): FieldValueI | null;
getDefaultSubField(config: Config, parentRuleGroupField?: string): FieldValueI | null;
getDefaultFieldSrc(config: Config, canGetFirst?: boolean): string;

@@ -557,7 +557,7 @@ getDefaultOperator(config: Config, field: Field, canGetFirst?: boolean): string;

defaultItemProperties(config: Config, item: JsonItem): ImmutableItemProperties;
defaultGroupProperties(config: Config, fieldConfig?: FieldValueOrConfig): ImmutableGroupProperties;
defaultRuleProperties(config: Config, parentRuleGroupPath?: IdPath, item?: JsonItem, canUseDefaultFieldAndOp?: boolean, canGetFirst?: boolean): ImmutableRuleProperties;
defaultGroupProperties(config: Config, groupFieldConfig?: FieldValueOrConfig): ImmutableGroupProperties;
defaultRuleProperties(config: Config, parentRuleGroupField?: string, item?: JsonItem, canUseDefaultFieldAndOp?: boolean, canGetFirst?: boolean): ImmutableRuleProperties;
defaultConjunction(config: Config): string;
defaultOperatorOptions(config: Config, operator: string, field: Field): OperatorOptionsI | null;
defaultGroupConjunction(config: Config, fieldConfig?: FieldValueOrConfig): string;
defaultGroupConjunction(config: Config, groupFieldConfig?: FieldValueOrConfig): string;

@@ -1261,2 +1261,3 @@ // createListWithOneElement<TItem>(el: TItem): ImmutableList<TItem>;

fieldSettings?: FS;
maxNesting?: number;
}

@@ -1344,2 +1345,3 @@ interface FieldGroupExt<FS = NumberFieldSettings<number>> extends BaseField {

addSubRuleLabel?: string;
addSubGroupLabel?: string;
delGroupLabel?: string;

@@ -1346,0 +1348,0 @@ notLabel?: string;

import Immutable, { fromJS } from "immutable";
import {
expandTreePath, expandTreeSubpath, getItemByPath, fixPathsInTree,
expandTreePath, expandTreeSubpath, getItemByPath, fixPathsInTree,
getTotalRulesCountInTree, fixEmptyGroupsInTree, isEmptyTree, hasChildren, removeIsLockedInTree

@@ -53,3 +53,3 @@ } from "../utils/treeUtils";

if (canAddNewRule) {
state = addItem(state, groupPath, "rule", uuid(), defaultRuleProperties(config), config);
state = addItem(state, groupPath, "rule", uuid(), defaultRuleProperties(config, meta.parentRuleGroupField), config);
}

@@ -233,2 +233,3 @@ }

} else if (targetItem?.get("type") === "rule_group") {
// todo
// don't restrict

@@ -578,3 +579,3 @@ } else {

);
let groupProperties = defaultGroupProperties(config, newFieldConfig).merge({
let groupProperties = defaultGroupProperties(config, newFieldConfig, newField).merge({
field: newField,

@@ -581,0 +582,0 @@ fieldSrc: "field",

@@ -352,6 +352,6 @@ import pick from "lodash/pick";

export const getFirstField = (config, parentRuleGroupPath = null) => {
export const getFirstField = (config, parentRuleGroupField = null) => {
const fieldSeparator = config.settings.fieldSeparator;
const parentPathArr = getFieldParts(parentRuleGroupPath, config);
const parentField = parentRuleGroupPath ? getFieldRawConfig(config, parentRuleGroupPath) : config;
const parentPathArr = getFieldParts(parentRuleGroupField, config);
const parentField = parentRuleGroupField ? getFieldRawConfig(config, parentRuleGroupField) : config;

@@ -358,0 +358,0 @@ let firstField = parentField, key = null, keysPath = [];

@@ -10,6 +10,6 @@ import Immutable from "immutable";

export const getDefaultField = (config, canGetFirst = true, parentRuleGroupPath = null) => {
export const getDefaultField = (config, canGetFirst = true, parentRuleGroupField = null) => {
const {defaultField} = config.settings;
let f = (!parentRuleGroupPath ? defaultField : getDefaultSubField(config, parentRuleGroupPath))
|| canGetFirst && getFirstField(config, parentRuleGroupPath)
let f = (!parentRuleGroupField ? defaultField : getDefaultSubField(config, parentRuleGroupField))
|| canGetFirst && getFirstField(config, parentRuleGroupField)
|| null;

@@ -23,10 +23,10 @@ // if default LHS is func, convert to Immutable

export const getDefaultSubField = (config, parentRuleGroupPath = null) => {
if (!parentRuleGroupPath)
export const getDefaultSubField = (config, parentRuleGroupField = null) => {
if (!parentRuleGroupField)
return null;
const fieldSeparator = config?.settings?.fieldSeparator || ".";
const parentRuleGroupConfig = getFieldConfig(config, parentRuleGroupPath);
const parentRuleGroupConfig = getFieldConfig(config, parentRuleGroupField);
let f = parentRuleGroupConfig?.defaultField;
if (f) {
f = [...getFieldParts(parentRuleGroupPath), f].join(fieldSeparator);
f = [...getFieldParts(parentRuleGroupField), f].join(fieldSeparator);
}

@@ -64,3 +64,3 @@ return f;

export const defaultRuleProperties = (config, parentRuleGroupPath = null, item = null, canUseDefaultFieldAndOp = true, canGetFirst = false) => {
export const defaultRuleProperties = (config, parentRuleGroupField = null, item = null, canUseDefaultFieldAndOp = true, canGetFirst = false) => {
let field = null, operator = null, fieldSrc = null;

@@ -73,3 +73,3 @@ const {showErrorMessage} = config.settings;

} else if (canUseDefaultFieldAndOp) {
field = getDefaultField(config, canGetFirst, parentRuleGroupPath);
field = getDefaultField(config, canGetFirst, parentRuleGroupField);
if (field) {

@@ -112,2 +112,9 @@ fieldSrc = isImmutable(field) ? "func" : "field";

}
const fieldConfig = getFieldConfig(config, field);
if (fieldConfig?.type === "!group") {
const conjunction = defaultGroupConjunction(config, fieldConfig);
current = current.set("conjunction", conjunction);
}
return current;

@@ -117,5 +124,5 @@ };

export const defaultGroupConjunction = (config, fieldConfig = null) => {
fieldConfig = getFieldConfig(config, fieldConfig); // if `fieldConfig` is field name, not config
const conjs = fieldConfig && fieldConfig.conjunctions || Object.keys(config.conjunctions);
export const defaultGroupConjunction = (config, groupFieldConfig = null) => {
groupFieldConfig = getFieldConfig(config, groupFieldConfig); // if `groupFieldConfig` is field name, not config
const conjs = groupFieldConfig && groupFieldConfig.conjunctions || Object.keys(config.conjunctions);
if (conjs.length == 1)

@@ -129,10 +136,12 @@ return conjs[0];

export const defaultGroupProperties = (config, fieldConfig = null) => new Immutable.Map({
conjunction: defaultGroupConjunction(config, fieldConfig),
not: false
});
export const defaultGroupProperties = (config, groupFieldConfig = null) => {
return new Immutable.Map({
conjunction: defaultGroupConjunction(config, groupFieldConfig),
not: false
});
};
export const defaultItemProperties = (config, item) => {
return item && item.type == "group"
? defaultGroupProperties(config, item?.properties?.field)
return item?.type == "group"
? defaultGroupProperties(config)
: defaultRuleProperties(config, null, item);

@@ -139,0 +148,0 @@ };

{
"name": "@react-awesome-query-builder/core",
"version": "6.6.3",
"version": "6.6.4-alpha.0",
"description": "User-friendly query builder for React. Core",

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

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