@react-awesome-query-builder/core
Advanced tools
Comparing version 6.6.1 to 6.6.2
@@ -30,2 +30,3 @@ "use strict"; | ||
shouldCreateEmptyGroup: false, | ||
exportPreserveGroups: false, | ||
removeEmptyGroupsOnLoad: true, | ||
@@ -32,0 +33,0 @@ removeEmptyRulesOnLoad: true, |
@@ -166,2 +166,5 @@ "use strict"; | ||
}); | ||
// allows for unnecessary (ie. empty or only one rule) groups to be exported | ||
var shouldPreserveGroups = !!config.settings.exportPreserveGroups; | ||
if (isRuleGroupArray && !isGroup0) { | ||
@@ -171,6 +174,6 @@ // "count" rule can have no "having" children, but should have number value | ||
} else { | ||
if (!list.size) return undefined; | ||
if (!list.size && !shouldPreserveGroups) return undefined; | ||
} | ||
var resultQuery = {}; | ||
if (list.size == 1 && !isRoot) resultQuery = list.first();else resultQuery[conj] = list.toList().toJS(); | ||
if (list.size == 1 && !isRoot && !shouldPreserveGroups) resultQuery = list.first();else resultQuery[conj] = list.toList().toJS(); | ||
@@ -177,0 +180,0 @@ // reverse filter |
@@ -165,2 +165,3 @@ /* eslint-disable no-extra-semi */ | ||
export type FieldValueI = FieldPath | FuncValueI; | ||
export type AnyFieldValue = FieldValue | FieldValueI; | ||
@@ -541,7 +542,7 @@ export type ValueSource = "value" | "field" | "func" | "const"; | ||
extendConfig(config: Config): Config; | ||
getFieldConfig(config: Config, field: FieldValue | FieldValueI): Field | Func | null; | ||
getFieldConfig(config: Config, field: AnyFieldValue): FieldConfig; | ||
getFuncConfig(config: Config, func: string): Func | null; | ||
getFuncArgConfig(config: Config, func: string, arg: string): FuncArg | null; | ||
getOperatorConfig(config: Config, operator: string, field?: FieldValue | FieldValueI): Operator | null; | ||
getFieldWidgetConfig(config: Config, field: FieldValue | FieldValueI, operator: string, widget?: string, valueStr?: ValueSource): Widget | null; | ||
getOperatorConfig(config: Config, operator: string, field?: AnyFieldValue): Operator | null; | ||
getFieldWidgetConfig(config: Config, field: AnyFieldValue, operator: string, widget?: string, valueStr?: ValueSource): Widget | null; | ||
isJSX(jsx: any): boolean; | ||
@@ -552,2 +553,19 @@ isDirtyJSX(jsx: any): boolean; | ||
} | ||
interface DefaultUtils { | ||
getDefaultField(config: Config, canGetFirst?: boolean, parentRuleGroupPath?: IdPath): FieldValueI | null; | ||
getDefaultSubField(config: Config, parentRuleGroupPath?: IdPath): FieldValueI | null; | ||
getDefaultFieldSrc(config: Config, canGetFirst?: boolean): string; | ||
getDefaultOperator(config: Config, field: Field, canGetFirst?: boolean): string; | ||
defaultRule(id: string, config: Config): Record<string, ImmutableRule>; | ||
defaultRoot(config: Config, canAddDefaultRule?: boolean): ImmutableGroup; | ||
defaultItemProperties(config: Config, item: JsonItem): ImmutableItemProperties; | ||
defaultGroupProperties(config: Config, fieldConfig?: FieldValueOrConfig): ImmutableGroupProperties; | ||
defaultRuleProperties(config: Config, parentRuleGroupPath?: IdPath, 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; | ||
// createListWithOneElement<TItem>(el: TItem): ImmutableList<TItem>; | ||
// createListFromArray<TItem>(array: TItem[]): ImmutableList<TItem>; | ||
} | ||
interface ExportUtils { | ||
@@ -622,2 +640,3 @@ wrapWithBrackets(val: string): string; | ||
ConfigUtils: ConfigUtils; | ||
DefaultUtils: DefaultUtils; | ||
ExportUtils: ExportUtils; | ||
@@ -708,3 +727,3 @@ ListUtils: ListUtils; | ||
setValue(path: IdPath, delta: number, value: RuleValueI, valueType: string): undefined; // todo: try to support RuleValue | ||
setFuncValue(path: IdPath, delta: number, parentFuncs: string[], argKey: string | null, value: SimpleValue, valueType: string | "!valueSrc"): undefined; | ||
setFuncValue(path: IdPath, delta: number, parentFuncs: Array<[string, string]>, argKey: string | null, value: SimpleValue, valueType: string | "!valueSrc"): undefined; | ||
setValueSrc(path: IdPath, delta: number, valueSrc: ValueSource): undefined; | ||
@@ -746,3 +765,3 @@ setOperatorOption(path: IdPath, name: string, value: SimpleValue): undefined; | ||
setOperatorOption(config: Config, path: IdPath, name: string, value: SimpleValue): InputAction; | ||
setFuncValue(config: Config, path: IdPath, delta: number, parentFuncs: string[], argKey: string | null, value: SimpleValue, valueType: string | "!valueSrc"): InputAction; | ||
setFuncValue(config: Config, path: IdPath, delta: number, parentFuncs: Array<[string, string]>, argKey: string | null, value: SimpleValue, valueType: string | "!valueSrc"): InputAction; | ||
}; | ||
@@ -942,3 +961,3 @@ } | ||
// tip: use generic WidgetProps here, TS can't determine correct factory | ||
export type TypedWidget<C = Config> = | ||
export type TypedWidget<C = Config> = | ||
TextWidget<C, WidgetProps<C>> | ||
@@ -955,3 +974,3 @@ | DateTimeWidget<C, WidgetProps<C>> | ||
export type Widget<C = Config> = | ||
export type Widget<C = Config> = | ||
FieldWidget<C> | ||
@@ -1272,2 +1291,5 @@ | FuncWidget<C> | ||
export type FieldConfig = Field | Func | null; | ||
export type FieldValueOrConfig = FieldConfig | AnyFieldValue; | ||
export type NumberField = SimpleField<NumberFieldSettings>; | ||
@@ -1354,3 +1376,3 @@ export type DateTimeField = SimpleField<DateTimeFieldSettings>; | ||
canShortMongoQuery?: boolean; | ||
defaultField?: FieldValue | FieldValueI; | ||
defaultField?: AnyFieldValue; | ||
defaultOperator?: string; | ||
@@ -1382,2 +1404,3 @@ fieldSources?: Array<FieldSource>; | ||
convertableWidgets?: TypedMap<Array<string>>; | ||
exportPreserveGroups?: boolean; | ||
removeEmptyGroupsOnLoad?: boolean; | ||
@@ -1384,0 +1407,0 @@ removeEmptyRulesOnLoad?: boolean; |
@@ -156,7 +156,7 @@ "use strict"; | ||
var createListWithOneElement = exports.createListWithOneElement = function createListWithOneElement(el) { | ||
if ((0, _stuff.isImmutable)(el)) return el; // already Immutable | ||
if ((0, _stuff.isImmutableList)(el)) return el; // already Immutable list | ||
return createListFromArray([el]); | ||
}; | ||
var createListFromArray = exports.createListFromArray = function createListFromArray(arr) { | ||
if ((0, _stuff.isImmutable)(arr)) return arr; // already Immutable | ||
if ((0, _stuff.isImmutableList)(arr)) return arr; // already Immutable list | ||
return new _immutable["default"].List(arr); | ||
@@ -163,0 +163,0 @@ }; |
@@ -9,3 +9,3 @@ "use strict"; | ||
exports.applyToJS = applyToJS; | ||
exports.logger = exports.isObject = exports.isJsonLogic = exports.isJsonCompatible = exports.isJSX = exports.isImmutable = exports.isDirtyJSX = exports.getOpCardinality = exports.getLogger = exports.getFirstDefined = exports.escapeRegExp = exports.deepFreeze = exports.deepEqual = exports.cleanJSX = void 0; | ||
exports.logger = exports.isObject = exports.isJsonLogic = exports.isJsonCompatible = exports.isJSX = exports.isImmutableList = exports.isImmutable = exports.isDirtyJSX = exports.getOpCardinality = exports.getLogger = exports.getFirstDefined = exports.escapeRegExp = exports.deepFreeze = exports.deepEqual = exports.cleanJSX = void 0; | ||
exports.mergeArraysSmart = mergeArraysSmart; | ||
@@ -146,4 +146,7 @@ exports.shallowEqual = exports.shallowCopy = exports.opDefKeysToOmit = exports.omit = exports.mergeCustomizerNoArrays = void 0; | ||
}; | ||
var isImmutableList = exports.isImmutableList = function isImmutableList(v) { | ||
return isImmutable(v) && _immutable["default"].isList(v); // Immutable.isIndexed(v) | ||
}; | ||
function toImmutableList(v) { | ||
return isImmutable(v) ? v : new _immutable["default"].List(v); | ||
return isImmutableList(v) ? v : new _immutable["default"].List(v); | ||
} | ||
@@ -150,0 +153,0 @@ function applyToJS(v) { |
@@ -24,2 +24,3 @@ export var settings = { | ||
shouldCreateEmptyGroup: false, | ||
exportPreserveGroups: false, | ||
removeEmptyGroupsOnLoad: true, | ||
@@ -26,0 +27,0 @@ removeEmptyRulesOnLoad: true, |
@@ -160,2 +160,5 @@ import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray"; | ||
}); | ||
// allows for unnecessary (ie. empty or only one rule) groups to be exported | ||
var shouldPreserveGroups = !!config.settings.exportPreserveGroups; | ||
if (isRuleGroupArray && !isGroup0) { | ||
@@ -165,6 +168,6 @@ // "count" rule can have no "having" children, but should have number value | ||
} else { | ||
if (!list.size) return undefined; | ||
if (!list.size && !shouldPreserveGroups) return undefined; | ||
} | ||
var resultQuery = {}; | ||
if (list.size == 1 && !isRoot) resultQuery = list.first();else resultQuery[conj] = list.toList().toJS(); | ||
if (list.size == 1 && !isRoot && !shouldPreserveGroups) resultQuery = list.first();else resultQuery[conj] = list.toList().toJS(); | ||
@@ -171,0 +174,0 @@ // reverse filter |
@@ -165,2 +165,3 @@ /* eslint-disable no-extra-semi */ | ||
export type FieldValueI = FieldPath | FuncValueI; | ||
export type AnyFieldValue = FieldValue | FieldValueI; | ||
@@ -541,7 +542,7 @@ export type ValueSource = "value" | "field" | "func" | "const"; | ||
extendConfig(config: Config): Config; | ||
getFieldConfig(config: Config, field: FieldValue | FieldValueI): Field | Func | null; | ||
getFieldConfig(config: Config, field: AnyFieldValue): FieldConfig; | ||
getFuncConfig(config: Config, func: string): Func | null; | ||
getFuncArgConfig(config: Config, func: string, arg: string): FuncArg | null; | ||
getOperatorConfig(config: Config, operator: string, field?: FieldValue | FieldValueI): Operator | null; | ||
getFieldWidgetConfig(config: Config, field: FieldValue | FieldValueI, operator: string, widget?: string, valueStr?: ValueSource): Widget | null; | ||
getOperatorConfig(config: Config, operator: string, field?: AnyFieldValue): Operator | null; | ||
getFieldWidgetConfig(config: Config, field: AnyFieldValue, operator: string, widget?: string, valueStr?: ValueSource): Widget | null; | ||
isJSX(jsx: any): boolean; | ||
@@ -552,2 +553,19 @@ isDirtyJSX(jsx: any): boolean; | ||
} | ||
interface DefaultUtils { | ||
getDefaultField(config: Config, canGetFirst?: boolean, parentRuleGroupPath?: IdPath): FieldValueI | null; | ||
getDefaultSubField(config: Config, parentRuleGroupPath?: IdPath): FieldValueI | null; | ||
getDefaultFieldSrc(config: Config, canGetFirst?: boolean): string; | ||
getDefaultOperator(config: Config, field: Field, canGetFirst?: boolean): string; | ||
defaultRule(id: string, config: Config): Record<string, ImmutableRule>; | ||
defaultRoot(config: Config, canAddDefaultRule?: boolean): ImmutableGroup; | ||
defaultItemProperties(config: Config, item: JsonItem): ImmutableItemProperties; | ||
defaultGroupProperties(config: Config, fieldConfig?: FieldValueOrConfig): ImmutableGroupProperties; | ||
defaultRuleProperties(config: Config, parentRuleGroupPath?: IdPath, 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; | ||
// createListWithOneElement<TItem>(el: TItem): ImmutableList<TItem>; | ||
// createListFromArray<TItem>(array: TItem[]): ImmutableList<TItem>; | ||
} | ||
interface ExportUtils { | ||
@@ -622,2 +640,3 @@ wrapWithBrackets(val: string): string; | ||
ConfigUtils: ConfigUtils; | ||
DefaultUtils: DefaultUtils; | ||
ExportUtils: ExportUtils; | ||
@@ -708,3 +727,3 @@ ListUtils: ListUtils; | ||
setValue(path: IdPath, delta: number, value: RuleValueI, valueType: string): undefined; // todo: try to support RuleValue | ||
setFuncValue(path: IdPath, delta: number, parentFuncs: string[], argKey: string | null, value: SimpleValue, valueType: string | "!valueSrc"): undefined; | ||
setFuncValue(path: IdPath, delta: number, parentFuncs: Array<[string, string]>, argKey: string | null, value: SimpleValue, valueType: string | "!valueSrc"): undefined; | ||
setValueSrc(path: IdPath, delta: number, valueSrc: ValueSource): undefined; | ||
@@ -746,3 +765,3 @@ setOperatorOption(path: IdPath, name: string, value: SimpleValue): undefined; | ||
setOperatorOption(config: Config, path: IdPath, name: string, value: SimpleValue): InputAction; | ||
setFuncValue(config: Config, path: IdPath, delta: number, parentFuncs: string[], argKey: string | null, value: SimpleValue, valueType: string | "!valueSrc"): InputAction; | ||
setFuncValue(config: Config, path: IdPath, delta: number, parentFuncs: Array<[string, string]>, argKey: string | null, value: SimpleValue, valueType: string | "!valueSrc"): InputAction; | ||
}; | ||
@@ -942,3 +961,3 @@ } | ||
// tip: use generic WidgetProps here, TS can't determine correct factory | ||
export type TypedWidget<C = Config> = | ||
export type TypedWidget<C = Config> = | ||
TextWidget<C, WidgetProps<C>> | ||
@@ -955,3 +974,3 @@ | DateTimeWidget<C, WidgetProps<C>> | ||
export type Widget<C = Config> = | ||
export type Widget<C = Config> = | ||
FieldWidget<C> | ||
@@ -1272,2 +1291,5 @@ | FuncWidget<C> | ||
export type FieldConfig = Field | Func | null; | ||
export type FieldValueOrConfig = FieldConfig | AnyFieldValue; | ||
export type NumberField = SimpleField<NumberFieldSettings>; | ||
@@ -1354,3 +1376,3 @@ export type DateTimeField = SimpleField<DateTimeFieldSettings>; | ||
canShortMongoQuery?: boolean; | ||
defaultField?: FieldValue | FieldValueI; | ||
defaultField?: AnyFieldValue; | ||
defaultOperator?: string; | ||
@@ -1382,2 +1404,3 @@ fieldSources?: Array<FieldSource>; | ||
convertableWidgets?: TypedMap<Array<string>>; | ||
exportPreserveGroups?: boolean; | ||
removeEmptyGroupsOnLoad?: boolean; | ||
@@ -1384,0 +1407,0 @@ removeEmptyRulesOnLoad?: boolean; |
@@ -10,3 +10,3 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty"; | ||
import { getNewValueForFieldOp } from "../utils/validation"; | ||
import { isImmutable } from "./stuff"; | ||
import { isImmutable, isImmutableList } from "./stuff"; | ||
import { jsToImmutable } from "../import"; | ||
@@ -150,7 +150,7 @@ export var getDefaultField = function getDefaultField(config) { | ||
export var createListWithOneElement = function createListWithOneElement(el) { | ||
if (isImmutable(el)) return el; // already Immutable | ||
if (isImmutableList(el)) return el; // already Immutable list | ||
return createListFromArray([el]); | ||
}; | ||
export var createListFromArray = function createListFromArray(arr) { | ||
if (isImmutable(arr)) return arr; // already Immutable | ||
if (isImmutableList(arr)) return arr; // already Immutable list | ||
return new Immutable.List(arr); | ||
@@ -157,0 +157,0 @@ }; |
@@ -124,4 +124,7 @@ import _slicedToArray from "@babel/runtime/helpers/slicedToArray"; | ||
}; | ||
export var isImmutableList = function isImmutableList(v) { | ||
return isImmutable(v) && Immutable.isList(v); // Immutable.isIndexed(v) | ||
}; | ||
export function toImmutableList(v) { | ||
return isImmutable(v) ? v : new Immutable.List(v); | ||
return isImmutableList(v) ? v : new Immutable.List(v); | ||
} | ||
@@ -128,0 +131,0 @@ export function applyToJS(v) { |
@@ -27,2 +27,3 @@ export const settings = { | ||
shouldCreateEmptyGroup: false, | ||
exportPreserveGroups: false, | ||
removeEmptyGroupsOnLoad: true, | ||
@@ -29,0 +30,0 @@ removeEmptyRulesOnLoad: true, |
@@ -146,2 +146,4 @@ import {getOpCardinality, widgetDefKeysToOmit, opDefKeysToOmit, omit} from "../utils/stuff"; | ||
// allows for unnecessary (ie. empty or only one rule) groups to be exported | ||
const shouldPreserveGroups = !!config.settings.exportPreserveGroups; | ||
if (isRuleGroupArray && !isGroup0) { | ||
@@ -152,3 +154,3 @@ // "count" rule can have no "having" children, but should have number value | ||
} else { | ||
if (!list.size) | ||
if (!list.size && !shouldPreserveGroups) | ||
return undefined; | ||
@@ -158,3 +160,3 @@ } | ||
let resultQuery = {}; | ||
if (list.size == 1 && !isRoot) | ||
if (list.size == 1 && !isRoot && !shouldPreserveGroups) | ||
resultQuery = list.first(); | ||
@@ -161,0 +163,0 @@ else |
@@ -165,2 +165,3 @@ /* eslint-disable no-extra-semi */ | ||
export type FieldValueI = FieldPath | FuncValueI; | ||
export type AnyFieldValue = FieldValue | FieldValueI; | ||
@@ -541,7 +542,7 @@ export type ValueSource = "value" | "field" | "func" | "const"; | ||
extendConfig(config: Config): Config; | ||
getFieldConfig(config: Config, field: FieldValue | FieldValueI): Field | Func | null; | ||
getFieldConfig(config: Config, field: AnyFieldValue): FieldConfig; | ||
getFuncConfig(config: Config, func: string): Func | null; | ||
getFuncArgConfig(config: Config, func: string, arg: string): FuncArg | null; | ||
getOperatorConfig(config: Config, operator: string, field?: FieldValue | FieldValueI): Operator | null; | ||
getFieldWidgetConfig(config: Config, field: FieldValue | FieldValueI, operator: string, widget?: string, valueStr?: ValueSource): Widget | null; | ||
getOperatorConfig(config: Config, operator: string, field?: AnyFieldValue): Operator | null; | ||
getFieldWidgetConfig(config: Config, field: AnyFieldValue, operator: string, widget?: string, valueStr?: ValueSource): Widget | null; | ||
isJSX(jsx: any): boolean; | ||
@@ -552,2 +553,19 @@ isDirtyJSX(jsx: any): boolean; | ||
} | ||
interface DefaultUtils { | ||
getDefaultField(config: Config, canGetFirst?: boolean, parentRuleGroupPath?: IdPath): FieldValueI | null; | ||
getDefaultSubField(config: Config, parentRuleGroupPath?: IdPath): FieldValueI | null; | ||
getDefaultFieldSrc(config: Config, canGetFirst?: boolean): string; | ||
getDefaultOperator(config: Config, field: Field, canGetFirst?: boolean): string; | ||
defaultRule(id: string, config: Config): Record<string, ImmutableRule>; | ||
defaultRoot(config: Config, canAddDefaultRule?: boolean): ImmutableGroup; | ||
defaultItemProperties(config: Config, item: JsonItem): ImmutableItemProperties; | ||
defaultGroupProperties(config: Config, fieldConfig?: FieldValueOrConfig): ImmutableGroupProperties; | ||
defaultRuleProperties(config: Config, parentRuleGroupPath?: IdPath, 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; | ||
// createListWithOneElement<TItem>(el: TItem): ImmutableList<TItem>; | ||
// createListFromArray<TItem>(array: TItem[]): ImmutableList<TItem>; | ||
} | ||
interface ExportUtils { | ||
@@ -622,2 +640,3 @@ wrapWithBrackets(val: string): string; | ||
ConfigUtils: ConfigUtils; | ||
DefaultUtils: DefaultUtils; | ||
ExportUtils: ExportUtils; | ||
@@ -708,3 +727,3 @@ ListUtils: ListUtils; | ||
setValue(path: IdPath, delta: number, value: RuleValueI, valueType: string): undefined; // todo: try to support RuleValue | ||
setFuncValue(path: IdPath, delta: number, parentFuncs: string[], argKey: string | null, value: SimpleValue, valueType: string | "!valueSrc"): undefined; | ||
setFuncValue(path: IdPath, delta: number, parentFuncs: Array<[string, string]>, argKey: string | null, value: SimpleValue, valueType: string | "!valueSrc"): undefined; | ||
setValueSrc(path: IdPath, delta: number, valueSrc: ValueSource): undefined; | ||
@@ -746,3 +765,3 @@ setOperatorOption(path: IdPath, name: string, value: SimpleValue): undefined; | ||
setOperatorOption(config: Config, path: IdPath, name: string, value: SimpleValue): InputAction; | ||
setFuncValue(config: Config, path: IdPath, delta: number, parentFuncs: string[], argKey: string | null, value: SimpleValue, valueType: string | "!valueSrc"): InputAction; | ||
setFuncValue(config: Config, path: IdPath, delta: number, parentFuncs: Array<[string, string]>, argKey: string | null, value: SimpleValue, valueType: string | "!valueSrc"): InputAction; | ||
}; | ||
@@ -942,3 +961,3 @@ } | ||
// tip: use generic WidgetProps here, TS can't determine correct factory | ||
export type TypedWidget<C = Config> = | ||
export type TypedWidget<C = Config> = | ||
TextWidget<C, WidgetProps<C>> | ||
@@ -955,3 +974,3 @@ | DateTimeWidget<C, WidgetProps<C>> | ||
export type Widget<C = Config> = | ||
export type Widget<C = Config> = | ||
FieldWidget<C> | ||
@@ -1272,2 +1291,5 @@ | FuncWidget<C> | ||
export type FieldConfig = Field | Func | null; | ||
export type FieldValueOrConfig = FieldConfig | AnyFieldValue; | ||
export type NumberField = SimpleField<NumberFieldSettings>; | ||
@@ -1354,3 +1376,3 @@ export type DateTimeField = SimpleField<DateTimeFieldSettings>; | ||
canShortMongoQuery?: boolean; | ||
defaultField?: FieldValue | FieldValueI; | ||
defaultField?: AnyFieldValue; | ||
defaultOperator?: string; | ||
@@ -1382,2 +1404,3 @@ fieldSources?: Array<FieldSource>; | ||
convertableWidgets?: TypedMap<Array<string>>; | ||
exportPreserveGroups?: boolean; | ||
removeEmptyGroupsOnLoad?: boolean; | ||
@@ -1384,0 +1407,0 @@ removeEmptyRulesOnLoad?: boolean; |
@@ -6,3 +6,3 @@ import Immutable from "immutable"; | ||
import {getNewValueForFieldOp} from "../utils/validation"; | ||
import { isImmutable } from "./stuff"; | ||
import { isImmutable, isImmutableList } from "./stuff"; | ||
import { jsToImmutable } from "../import"; | ||
@@ -153,4 +153,4 @@ | ||
export const createListWithOneElement = (el) => { | ||
if (isImmutable(el)) | ||
return el; // already Immutable | ||
if (isImmutableList(el)) | ||
return el; // already Immutable list | ||
return createListFromArray([el]); | ||
@@ -160,4 +160,4 @@ }; | ||
export const createListFromArray = (arr) => { | ||
if (isImmutable(arr)) | ||
return arr; // already Immutable | ||
if (isImmutableList(arr)) | ||
return arr; // already Immutable list | ||
return new Immutable.List(arr); | ||
@@ -164,0 +164,0 @@ }; |
@@ -142,4 +142,8 @@ import Immutable, { Map } from "immutable"; | ||
export const isImmutableList = (v) => { | ||
return isImmutable(v) && Immutable.isList(v); // Immutable.isIndexed(v) | ||
}; | ||
export function toImmutableList(v) { | ||
return (isImmutable(v) ? v : new Immutable.List(v)); | ||
return (isImmutableList(v) ? v : new Immutable.List(v)); | ||
} | ||
@@ -146,0 +150,0 @@ |
@@ -404,3 +404,3 @@ import omit from "lodash/omit"; | ||
// tip: default case should contain only value | ||
const childrenAreRequired = isCase ? !isDefaultCase : (isGroupExt ? cardinality == 0 : true); | ||
const childrenAreRequired = isCase ? !isDefaultCase : (isGroupExt ? cardinality == 0 : removeEmptyGroups); | ||
const canHaveValue = isGroupExt || isCase; | ||
@@ -407,0 +407,0 @@ |
{ | ||
"name": "@react-awesome-query-builder/core", | ||
"version": "6.6.1", | ||
"version": "6.6.2", | ||
"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
1904967
46399