UNPKG

@react-querybuilder/core

Version:

React Query Builder component for constructing queries and filters, with utilities for executing them in various database and evaluation contexts

40 lines (37 loc) 1.61 kB
import { numericRegex } from "numeric-quantity"; //#region src/utils/misc.ts /** * Converts a value to lowercase if it's a string, otherwise returns the value as is. */ // istanbul ignore next const lc = (v) => typeof v === "string" ? v.toLowerCase() : v; /** * Regex matching numeric strings. Passes for positive/negative integers, decimals, * and E notation, with optional surrounding whitespace. */ const numericRegex$1 = new RegExp(numericRegex.source.replace(/^\^/, String.raw`^\s*`).replace(/\$$/, String.raw`\s*$`)); /** * Determines if a variable is a plain old JavaScript object, aka POJO. */ const isPojo = (obj) => obj === null || typeof obj !== "object" ? false : Object.getPrototypeOf(obj) === Object.prototype; /** * Simple helper to determine whether a value is null, undefined, or an empty string. */ const nullOrUndefinedOrEmpty = (value) => value === null || value === void 0 || value === ""; //#endregion //#region src/utils/isRuleGroup.ts /** * Determines if an object is a {@link RuleGroupType} or {@link RuleGroupTypeIC}. */ const isRuleGroup = (rg) => isPojo(rg) && Array.isArray(rg.rules); /** * Determines if an object is a {@link RuleGroupType}. */ const isRuleGroupType = (rg) => isRuleGroup(rg) && typeof rg.combinator === "string"; /** * Determines if an object is a {@link RuleGroupTypeIC}. */ const isRuleGroupTypeIC = (rg) => isRuleGroup(rg) && rg.combinator === void 0; //#endregion export { lc as a, isPojo as i, isRuleGroupType as n, nullOrUndefinedOrEmpty as o, isRuleGroupTypeIC as r, numericRegex$1 as s, isRuleGroup as t }; //# sourceMappingURL=isRuleGroup-CYcfPgbg.mjs.map