@paraboly/pwc-multi-filter
Version:
A wrapper over pwc-tabview and pwc-filter. Provides means of dynamically managing multiple filters via a single component.
33 lines (29 loc) • 1.24 kB
JavaScript
const linq = require('./linq-23ba6bed.js');
function resolveJson(input) {
// TODO: returning [] when no input only works because of our limited usage in this component.
// We should return an instance of TReturnType instead.
return input ? (typeof input === "string" ? JSON.parse(input) : input) : [];
}
function getVanillaHtmlInputs(rootElement, skipButtonElements) {
return linq.Enumerable.from(rootElement.querySelectorAll("input"))
.where(inputElement => {
const inputElementParents = getAllParentElements(inputElement);
const isChoices = linq.Enumerable.from(inputElementParents).any(p => p.tagName.includes("PWC-CHOICES"));
const isButton = inputElement.type === "button";
const isPwcColorPicker = linq.Enumerable.from(inputElementParents).any(p => p.tagName.includes("PWC-COLOR-PICKER"));
return (false ===
(isChoices || (skipButtonElements && isButton) || isPwcColorPicker));
})
.toArray();
}
function getAllParentElements(node) {
let a = node;
const els = [];
while (a) {
els.unshift(a);
a = a.parentElement;
}
return els;
}
exports.resolveJson = resolveJson;
;