react-querybuilder
Version:
React Query Builder component for constructing queries and filters, with utilities for executing them in various database and evaluation contexts
119 lines (115 loc) • 3.71 kB
JavaScript
//#region rolldown:runtime
var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __commonJS = (cb, mod) => function() {
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
key = keys[i];
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
get: ((k) => from[k]).bind(null, key),
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
});
}
return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
value: mod,
enumerable: true
}) : target, mod));
//#endregion
const numeric_quantity = __toESM(require("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 = new RegExp(numeric_quantity.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
Object.defineProperty(exports, '__commonJS', {
enumerable: true,
get: function () {
return __commonJS;
}
});
Object.defineProperty(exports, '__toESM', {
enumerable: true,
get: function () {
return __toESM;
}
});
Object.defineProperty(exports, 'isPojo', {
enumerable: true,
get: function () {
return isPojo;
}
});
Object.defineProperty(exports, 'isRuleGroup', {
enumerable: true,
get: function () {
return isRuleGroup;
}
});
Object.defineProperty(exports, 'isRuleGroupType', {
enumerable: true,
get: function () {
return isRuleGroupType;
}
});
Object.defineProperty(exports, 'isRuleGroupTypeIC', {
enumerable: true,
get: function () {
return isRuleGroupTypeIC;
}
});
Object.defineProperty(exports, 'lc', {
enumerable: true,
get: function () {
return lc;
}
});
Object.defineProperty(exports, 'nullOrUndefinedOrEmpty', {
enumerable: true,
get: function () {
return nullOrUndefinedOrEmpty;
}
});
Object.defineProperty(exports, 'numericRegex', {
enumerable: true,
get: function () {
return numericRegex;
}
});
//# sourceMappingURL=isRuleGroup-Bf2BUwdE.js.map