@navinc/base-react-components
Version:
Nav's Pattern Library
30 lines • 1.96 kB
JavaScript
var __rest = (this && this.__rest) || function (s, e) {
var t = {};
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
t[p] = s[p];
if (s != null && typeof Object.getOwnPropertySymbols === "function")
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
t[p[i]] = s[p[i]];
}
return t;
};
import { jsx as _jsx } from "react/jsx-runtime";
import { styled } from 'styled-components';
import { useState } from 'react';
import { InputWithSensitivityButton } from './input-with-sensitivity-button.js';
const UnstyledSensitiveContentDisplayInput = (_a) => {
var { value, maskedValue, type = 'text' } = _a, props = __rest(_a, ["value", "maskedValue", "type"]);
const [isVisible, setIsVisible] = useState(false);
return (_jsx(InputWithSensitivityButton, Object.assign({ type: type, value: isVisible ? value : maskedValue, isVisible: isVisible, onToggle: () => setIsVisible((prevIsVisible) => !prevIsVisible), readOnly: true }, props)));
};
/** A **read-only input** that displays sensitive content that can be toggled on/off. User may still use keyboard to
* access the input and copy the value. Keyboard can also access the toggle button.
*
* To keep this component usage simple, it takes a `value` which is the visible string, and a `maskedValue` which is the
* hidden string. This eliminates the need to use any special masking, pattern, regex, etc. to transform the string.
*
* @deprecated This component is deprecated and will be removed in a future release. Avoid using it in new code.
*/
export const SensitiveContentDisplayInput = styled(UnstyledSensitiveContentDisplayInput).withConfig({ displayName: "brc-sc-SensitiveContentDisplayInput", componentId: "brc-sc-1uunh43" }) ``;
//# sourceMappingURL=sensitive-content-display-input.js.map