@pnp/spfx-controls-react
Version:
Reusable React controls for SharePoint Framework solutions
35 lines • 1.8 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.Pill = void 0;
var tslib_1 = require("tslib");
var react_1 = require("@fluentui/react");
var FilterBar_module_scss_1 = tslib_1.__importDefault(require("./FilterBar.module.scss"));
var strings = tslib_1.__importStar(require("ControlStrings"));
var react_2 = tslib_1.__importDefault(require("react"));
var Pill = function (props) {
var onClick = function (event) {
if (props.onClick) {
props.onClick(props.field, props.value);
}
};
// eslint-disable-next-line @typescript-eslint/no-explicit-any
var buttonProps = {
title: props.clearAll ? strings.ClearAllFiltersTitle : strings.ClearFilterTitle,
className: "".concat(FilterBar_module_scss_1.default.pill, " ").concat(props.clearAll ? "".concat(FilterBar_module_scss_1.default.pill, " ").concat(FilterBar_module_scss_1.default.clearAll) : ""),
"data-automationid": props.clearAll ? "clearfiltersPill" : "filterPill",
"data-field": props.field
};
if (props.clearAll) {
buttonProps.tabIndex = 0;
}
else {
buttonProps["data-is-focusable"] = true;
buttonProps["data-value"] = props.value;
buttonProps["aria-disabled"] = false;
}
return (react_2.default.createElement("button", tslib_1.__assign({}, buttonProps, { onClick: onClick }),
react_2.default.createElement("span", { className: FilterBar_module_scss_1.default.pillText }, props.clearAll ? strings.ClearAllFiltersText : props.value),
react_2.default.createElement(react_1.Icon, { iconName: "Cancel", role: "presentation", className: "".concat(FilterBar_module_scss_1.default.icon), "data-icon-name": "Cancel" })));
};
exports.Pill = Pill;
//# sourceMappingURL=Pill.js.map