@arche-mc2/arche-controls
Version:
We know that there are a ton of react UI library projects to choose from. Our hope with this one is to provide the next generation of react components that you can use to bootstrap your next project, or as a reference for building a UIKit. Read on to get
59 lines • 3.35 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
var React = require("react");
var UpPassword_1 = require("./UpPassword");
var stories_1 = require("../../../Common/stories");
var addon_knobs_1 = require("@storybook/addon-knobs");
var utils_1 = require("../../../Common/utils");
var Label_1 = require("../../Display/Label");
exports.default = {
title: 'Components/Inputs/UpPassword',
decorators: [addon_knobs_1.withKnobs, stories_1.getRootContainer('UpPassword')],
component: UpPassword_1.UpPassword,
};
exports.General = function () {
var _a = React.useState(''), value = _a[0], setValue = _a[1];
return (React.createElement(Label_1.default, { text: "Password" },
React.createElement(UpPassword_1.default, { value: value, onChange: function (e, v) { return setValue(v); }, showPasswordOnClick: true })));
};
exports.General.decorators = [
function (General) { return (React.createElement("div", { style: { padding: '30px' } },
React.createElement(General, null))); },
];
exports.WithRules = function () {
var _a = React.useState(''), value = _a[0], setValue = _a[1];
var _b = React.useState(false), focused = _b[0], setFocused = _b[1];
var _c = React.useState(false), touched = _c[0], setTouched = _c[1];
var rules = [
{ text: 'Au moins 8 caractères', regex: /^.{8,}$/ },
{ text: 'Au moins une majuscule', regex: /.*[A-Z]/ },
{ text: 'Au moins une minuscule', regex: /.*[a-z]/ },
{ text: 'Au moins 1 chiffre', regex: /.*[0-9].*/ },
];
var rulesAreValid = utils_1.rulesMatch(value, rules);
return (React.createElement(UpPassword_1.default, { value: value, onChange: function (e, v) { return setValue(v); }, showPasswordOnClick: false, rules: rules, onFocus: function (e) {
setFocused(true);
setTouched(true);
}, onBlur: function (e) { return setFocused(false); }, focused: focused, showError: touched && !rulesAreValid, hasError: touched && !rulesAreValid, touched: touched }));
};
exports.WithRules.decorators = [
function (WithRules) { return (React.createElement("div", { style: { padding: '30px' } },
React.createElement(WithRules, null))); },
];
exports.PasswordWithFloatingLabel = function () {
var _a = React.useState(''), value = _a[0], setValue = _a[1];
return (React.createElement(UpPassword_1.default, { value: value, floatingLabel: 'Password', onChange: function (e, v) { return setValue(v); }, showPasswordOnClick: true }));
};
exports.PasswordWithFloatingLabel.decorators = [
function (PasswordWithFloatingLabel) { return (React.createElement("div", { style: { padding: '30px' } },
React.createElement(PasswordWithFloatingLabel, null))); },
];
exports.PasswordAutocomplete = function () {
var _a = React.useState(''), value = _a[0], setValue = _a[1];
return (React.createElement(UpPassword_1.default, { value: value, floatingLabel: 'Password', onChange: function (e, v) { return setValue(v); }, showPasswordOnClick: true, autocomplete: 'off' }));
};
exports.PasswordAutocomplete.decorators = [
function (Story) { return (React.createElement("div", { style: { padding: '30px' } },
React.createElement(Story, null))); },
];
//# sourceMappingURL=index.stories.js.map