@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
137 lines • 8.83 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
var React = require("react");
var UpRadio_1 = require("./UpRadio");
var Heading_1 = require("../../Display/Heading");
var addon_knobs_1 = require("@storybook/addon-knobs");
var stories_1 = require("../../../Common/stories");
var formik_1 = require("formik");
var Yup = require("yup");
var Input_1 = require("../Input");
var UpNumber_1 = require("../Number/UpNumber");
var Checkbox_1 = require("../Checkbox");
exports.default = {
title: 'Components/Inputs/UpRadio',
decorators: [
addon_knobs_1.withKnobs,
stories_1.getRootContainer('UpRadio')
],
component: UpRadio_1.UpRadio
};
exports.General = function () {
var _a = React.useState(null), selectedValue = _a[0], setValue = _a[1];
var onChange = function (event, value) {
setValue(value);
};
return (React.createElement(UpRadio_1.default, { flexWrap: true, onChange: onChange, gutter: 30, value: selectedValue, defaultValue: "option1", alignMode: "vertical", name: "modeAdresse", options: [
{ text: "Option 1", value: "option1" },
{ text: "Option 2", value: "option2" },
{ text: "Option 3", value: "option3" },
{ text: "Option 4", value: "option4" },
{ text: "Option 5", value: "option5" },
{ text: "Option 6", value: "option6", disabled: true }
] }));
};
exports.General.decorators = [function (General) { return React.createElement("div", { style: { padding: "30px", height: 200 } },
React.createElement(General, null)); }];
exports.DisplayHorizontally = function () { return (React.createElement(UpRadio_1.default, { defaultValue: "option1", name: "modeAdresse", alignMode: "horizontal", gutter: 8, options: [
{ text: "Option 1", value: "option1" },
{ text: "Option 2", value: "option2" },
{ text: "Option 3", value: "option3", disabled: true }
] })); };
exports.DisplayVertically = function () { return (React.createElement(UpRadio_1.default, { defaultValue: "option1", name: "modeAdresse", alignMode: "vertical", gutter: 8, options: [
{ text: "Option 1", value: "option1" },
{ text: "Option 2", value: "option2" },
{ text: "Option 3", value: "option3" }
] })); };
exports.DisplayAsButton = function () { return (React.createElement(UpRadio_1.default, { name: "modeAdresse", displayMode: "button", options: [
{ text: "Option 1", value: "option1" },
{ text: "Option 2", value: "option2" },
{ text: "Option 3", value: "option3" }
] })); };
exports.DisplayAsButtonWithGutter0 = function () { return (React.createElement(UpRadio_1.default, { name: "modeAdresse", displayMode: "button", gutter: 0, options: [
{ text: "Option 1", value: "option1" },
{ text: "Option 2", value: "option2" },
{ text: "Option 3", value: "option3" }
] })); };
exports.DisplayAsButtonWithRequired = function () { return (React.createElement(UpRadio_1.default, { name: "modeAdresse", isRequired: true, displayMode: "button", gutter: 8, options: [
{ text: "Option 1", value: "option1" },
{ text: "Option 2", value: "option2", intent: 'success' },
{ text: "Option 3", value: "option3", intent: 'danger' }
] })); };
exports.DisplayAsLarge = function () {
return (React.createElement(React.Fragment, null,
React.createElement("div", { style: { marginTop: "10px" } },
React.createElement(Heading_1.default, { tag: 'h3', textAlign: 'left', margin: 'medium' }, "Afficher horizontalement, et large :"),
React.createElement(UpRadio_1.default, { name: "value1", alignMode: "horizontal", displayMode: "large", gutter: 8, options: [
{ text: "Option 1", value: "option1" },
{ text: "Option 2", value: "option2" },
{ text: "Option 3", value: "option3" }
] })),
React.createElement("div", { style: { marginTop: "10px" } },
React.createElement(Heading_1.default, { tag: "h3", textAlign: "left", margin: "medium" }, "Afficher verticalement, et large :"),
React.createElement(UpRadio_1.default, { name: "value2", alignMode: "vertical", displayMode: "large", options: [
{ text: "Option 1", value: "option1" },
{ text: "Option 2", value: "option2" },
{ text: "Option 3", value: "option3" }
] })),
React.createElement("div", { style: { marginTop: "10px" } },
React.createElement(Heading_1.default, { tag: "h3", textAlign: "left", margin: "medium" }, "Afficher horizontalement, avec ic\u00F4ne et large :"),
React.createElement(UpRadio_1.default, { name: "value3", alignMode: "horizontal", displayMode: "large", gutter: 8, options: [
{ text: "Option 1", value: "option1", iconName: 'calendar' },
{ text: "Option 2", value: "option2", iconName: 'message-circle' },
{ text: "Option 3", value: "option3", iconName: 'link' }
] }))));
};
exports.DisplayWithToggledElement = function () { return (React.createElement(UpRadio_1.default, { gutter: 30, defaultValue: "option1", alignMode: "vertical", name: "modeAdresse", options: [
{ text: "Option 1", value: "option1", toggledElement: React.createElement(Input_1.default, { placeholder: "Saisir votre message" }) },
{ text: "Option 2", value: "option2", toggledElement: React.createElement(UpNumber_1.default, null) },
{ text: "Option 3", value: "option3", toggledElement: React.createElement(Checkbox_1.default, { options: [{ name: "case", text: "Cocher la case suivante" }] }) }
] })); };
var RadioForm = function (props) {
var _a = React.useState({}), onBlurState = _a[0], setOnBlurState = _a[1];
var values = props.values, touched = props.touched, errors = props.errors, dirty = props.dirty, isSubmitting = props.isSubmitting, handleChange = props.handleChange, handleBlur = props.handleBlur, handleSubmit = props.handleSubmit, handleReset = props.handleReset;
return (React.createElement("form", { onSubmit: handleSubmit },
React.createElement(UpRadio_1.default, { defaultValue: "option1", name: "modeAdresse", onChange: handleChange, alignMode: "horizontal", value: values.modeAdresse, gutter: 8, options: [
{ text: "Option 1", value: "option1" },
{ text: "Option 2", value: "option2" },
{ text: "Option 3", value: "option3" }
] })));
};
exports.IntegrationInForm = function () { return (React.createElement(formik_1.Formik, { initialValues: { modeAdresse: null }, onSubmit: function (values, _a) {
var setSubmitting = _a.setSubmitting;
setTimeout(function () {
alert(JSON.stringify(values, null, 2));
setSubmitting(false);
}, 500);
}, validateOnBlur: true, validationSchema: Yup.object().shape({
email: Yup.string().required('Le choix est requis'),
}) }, function (props) { return React.createElement(RadioForm, tslib_1.__assign({}, props)); })); };
exports.RadioWithMultipleDescription = function () { return (React.createElement(React.Fragment, null,
React.createElement(Heading_1.default, { tag: "h3", textAlign: "left", margin: "medium" }, "Afficher horizontalement, et large :"),
React.createElement(UpRadio_1.default, { name: "value1", alignMode: "horizontal", displayMode: "large", gutter: 8, options: [
{
text: [
{ title: 'Code CRT', value: 'Code CRT' },
{ title: 'N° Compte Client', value: '123445678' },
{ title: 'Raison Sociale', value: 'La raison sociale' },
{ title: 'Dén. Commerciale', value: 'La Dénomination commerciale' },
{ title: 'Ville', value: 'Paris' }
],
value: "option1",
additionalData: { value: 'Source-BMC', color: '#F59100' }
},
{
text: [
{ title: 'Code CRT', value: 'Code CRT' },
{ title: 'N° Compte Client', value: '123445678' },
{ title: 'Raison Sociale', value: 'La raison sociale' },
{ title: 'Dén. Commerciale', value: 'La Dénomination commerciale' },
{ title: 'Ville', value: 'Paris' },
],
value: "option2",
additionalData: { value: 'INSEE', color: 'black' }
},
] }))); };
//# sourceMappingURL=index.stories.js.map