allaw-ui 4.0.9 → 4.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/molecules/DataStepper/Stepper.d.ts +22 -0
- package/dist/components/molecules/DataStepper/Stepper.js +162 -0
- package/dist/components/molecules/DataStepper/Stepper.stories.d.ts +8 -0
- package/dist/components/molecules/DataStepper/Stepper.stories.js +209 -0
- package/dist/components/molecules/DataStepper/index.d.ts +2 -0
- package/dist/components/molecules/DataStepper/index.js +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -0
- package/package.json +1 -1
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
export type StepField = {
|
|
3
|
+
name: string;
|
|
4
|
+
label: string;
|
|
5
|
+
type: "text" | "select" | "combobox" | "date" | "checkbox" | "radio" | "custom";
|
|
6
|
+
options?: string[] | (() => Promise<string[]> | string[]);
|
|
7
|
+
showIf?: (values: Record<string, any>) => boolean;
|
|
8
|
+
customComponent?: React.ComponentType<any>;
|
|
9
|
+
customProps?: Record<string, any>;
|
|
10
|
+
};
|
|
11
|
+
export type StepConfig = {
|
|
12
|
+
title: string;
|
|
13
|
+
description?: string;
|
|
14
|
+
fields: StepField[];
|
|
15
|
+
};
|
|
16
|
+
export type StepperProps = {
|
|
17
|
+
config: StepConfig[];
|
|
18
|
+
onSubmit: (values: Record<string, any>) => void;
|
|
19
|
+
isOpen?: boolean;
|
|
20
|
+
onClose?: () => void;
|
|
21
|
+
};
|
|
22
|
+
export declare const Stepper: React.FC<StepperProps>;
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
var __assign = (this && this.__assign) || function () {
|
|
2
|
+
__assign = Object.assign || function(t) {
|
|
3
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
+
s = arguments[i];
|
|
5
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
+
t[p] = s[p];
|
|
7
|
+
}
|
|
8
|
+
return t;
|
|
9
|
+
};
|
|
10
|
+
return __assign.apply(this, arguments);
|
|
11
|
+
};
|
|
12
|
+
import React, { useState, useMemo } from "react";
|
|
13
|
+
import Input from "../../atoms/inputs/Input";
|
|
14
|
+
import Select from "../../atoms/selects/Select";
|
|
15
|
+
import ComboBox from "../../atoms/selects/ComboBox";
|
|
16
|
+
import Paragraph from "../../atoms/typography/Paragraph";
|
|
17
|
+
// FieldRenderer: rend le bon input selon le type
|
|
18
|
+
var FieldRenderer = function (_a) {
|
|
19
|
+
var field = _a.field, value = _a.value, onChange = _a.onChange;
|
|
20
|
+
// Gestion des options dynamiques
|
|
21
|
+
var _b = React.useState([]), options = _b[0], setOptions = _b[1];
|
|
22
|
+
var _c = React.useState(false), _ = _c[0], setLoading = _c[1];
|
|
23
|
+
React.useEffect(function () {
|
|
24
|
+
if (field.type === "select" || field.type === "combobox" || field.type === "radio") {
|
|
25
|
+
if (typeof field.options === "function") {
|
|
26
|
+
setLoading(true);
|
|
27
|
+
Promise.resolve(field.options()).then(function (opts) {
|
|
28
|
+
setOptions(opts);
|
|
29
|
+
setLoading(false);
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
else if (Array.isArray(field.options)) {
|
|
33
|
+
setOptions(field.options);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}, [field]);
|
|
37
|
+
// Helper pour transformer string[] en {label, value}[]
|
|
38
|
+
var toSelectItems = function (opts) {
|
|
39
|
+
if (opts === void 0) { opts = []; }
|
|
40
|
+
return opts.map(function (o) { return ({ label: o, value: o }); });
|
|
41
|
+
};
|
|
42
|
+
// Gestion des composants custom
|
|
43
|
+
if (field.type === "custom" && field.customComponent) {
|
|
44
|
+
var CustomComp = field.customComponent;
|
|
45
|
+
return React.createElement(CustomComp, __assign({ value: value, onChange: onChange }, (field.customProps || {})));
|
|
46
|
+
}
|
|
47
|
+
// Inputs standards
|
|
48
|
+
switch (field.type) {
|
|
49
|
+
case "text":
|
|
50
|
+
return (React.createElement(Input, { placeholder: field.label, title: field.label, value: value || "", onChange: onChange, name: field.name }));
|
|
51
|
+
case "date":
|
|
52
|
+
return (React.createElement("input", { id: field.name, type: "date", className: "stepper-input", value: value || "", onChange: function (e) { return onChange(e.target.value); } }));
|
|
53
|
+
case "checkbox":
|
|
54
|
+
return (React.createElement("label", { style: { display: "flex", alignItems: "center", gap: 8 } },
|
|
55
|
+
React.createElement("input", { id: field.name, type: "checkbox", className: "stepper-input", style: { width: 18, height: 18 }, checked: !!value, onChange: function (e) { return onChange(e.target.checked); } }),
|
|
56
|
+
field.label));
|
|
57
|
+
case "select": {
|
|
58
|
+
var items = Array.isArray(field.options)
|
|
59
|
+
? toSelectItems(field.options)
|
|
60
|
+
: toSelectItems(options);
|
|
61
|
+
return (React.createElement(Select, { items: items, selectedItem: value || "", onChange: onChange, placeholder: field.label }));
|
|
62
|
+
}
|
|
63
|
+
case "combobox": {
|
|
64
|
+
var items = Array.isArray(field.options)
|
|
65
|
+
? toSelectItems(field.options)
|
|
66
|
+
: toSelectItems(options);
|
|
67
|
+
return (React.createElement(ComboBox, { items: items, selectedItem: value || "", onSelect: onChange, onChange: onChange, placeholder: field.label, title: field.label, openOnMount: false }));
|
|
68
|
+
}
|
|
69
|
+
case "radio":
|
|
70
|
+
return (React.createElement("div", { style: { display: "flex", gap: 16 } }, options.map(function (opt) { return (React.createElement("label", { key: opt, style: { display: "flex", alignItems: "center", gap: 4 } },
|
|
71
|
+
React.createElement("input", { id: field.name + opt, type: "radio", className: "stepper-input", name: field.name, value: opt, checked: value === opt, onChange: function () { return onChange(opt); } }),
|
|
72
|
+
opt)); })));
|
|
73
|
+
default:
|
|
74
|
+
return null;
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
// Ajout/ajustement du style CSS-in-JS pour le layout 2 colonnes et plus de spacing
|
|
78
|
+
var stepperStyle = "\n.stepper-allaw {\n background: var(--pure-white, #fff);\n border: 1px solid var(--grey-venom, #e6edf5);\n border-radius: 16px;\n box-shadow: 0 2px 8px rgba(37, 190, 235, 0.06);\n padding: 32px;\n max-width: 600px;\n min-width: 100%;\n width: 700px;\n margin: 0 auto;\n font-family: 'Inter', 'Open Sans', Arial, sans-serif;\n}\n.stepper-progress-bar {\n width: 100%;\n height: 6px;\n background: var(--grey-light, #f6fcfe);\n border-radius: 8px;\n margin-bottom: 24px;\n overflow: hidden;\n}\n.stepper-progress-inner {\n height: 100%;\n background: var(--bleu-allaw, #25beeb);\n border-radius: 8px;\n transition: width 0.3s;\n}\n.stepper-title {\n color: var(--noir, #171e25);\n font-family: 'Poppins', Arial, sans-serif;\n font-size: 1.5rem;\n font-weight: 600;\n margin-bottom: 8px;\n}\n.stepper-desc {\n color: var(--mid-grey, #728ea7);\n font-family: 'Open Sans', Arial, sans-serif;\n font-size: 1rem;\n margin-bottom: 42px;\n}\n.stepper-fields-grid {\n display: grid;\n grid-template-columns: 1fr;\n gap: 24px 24px;\n margin-bottom: 42px;\n}\n@media (min-width: 600px) {\n .stepper-fields-grid {\n grid-template-columns: 1fr 1fr;\n }\n}\n.stepper-field {\n display: flex;\n flex-direction: column;\n align-items: stretch;\n gap: 8px;\n margin-bottom: 0;\n}\n.stepper-label {\n color: var(--dark-grey, #456073);\n font-size: 1rem;\n font-weight: 500;\n margin-bottom: 2px;\n min-width: 0;\n flex-shrink: 1;\n}\n.stepper-input, .stepper-select, .stepper-datalist {\n border: 1px solid var(--grey-venom, #e6edf5);\n border-radius: 8px;\n padding: 10px 12px;\n font-size: 1rem;\n font-family: inherit;\n background: var(--pure-white, #fff);\n color: var(--noir, #171e25);\n outline: none;\n transition: border-color 0.2s;\n flex: 1 1 0%;\n}\n.stepper-input:focus, .stepper-select:focus, .stepper-datalist:focus {\n border-color: var(--bleu-allaw, #25beeb);\n}\n.stepper-btn-row {\n display: flex;\n gap: 12px;\n margin-top: 24px;\n}\n@media (max-width: 599px) {\n .stepper-btn-row {\n flex-direction: column;\n gap: 12px;\n }\n}\n.stepper-btn {\n background: var(--bleu-allaw, #25beeb);\n color: var(--pure-white, #fff);\n border: none;\n border-radius: 8px;\n padding: 8px 16px;\n font-size: 1rem;\n font-weight: 600;\n cursor: pointer;\n transition: background 0.2s;\n flex: 1 1 0%;\n width: 100%;\n min-width: 0;\n}\n.stepper-btn:disabled {\n background: var(--grey-venom, #e6edf5);\n color: var(--mid-grey, #728ea7);\n cursor: not-allowed;\n}\n.stepper-btn:not(:disabled):hover {\n background: #1ca6d4;\n}\n.stepper-btn-secondary {\n background: var(--grey-light, #f6fcfe);\n color: var(--bleu-allaw, #25beeb);\n border: 1px solid var(--bleu-allaw, #25beeb);\n margin-right: 8px;\n}\n.stepper-modal-backdrop {\n position: fixed;\n top: 0;\n left: 0;\n width: 100vw;\n height: 100vh;\n background: rgba(0, 0, 0, 0.6);\n z-index: 1000;\n display: flex;\n align-items: center;\n justify-content: center;\n pointer-events: all;\n}\n.stepper-modal-center {\n position: fixed;\n top: 50%;\n left: 50%;\n transform: translate(-50%, -50%);\n z-index: 1001;\n max-height: 90vh;\n overflow-y: auto;\n box-shadow: 0 8px 32px rgba(23, 30, 37, 0.18);\n pointer-events: all;\n}\n.stepper-modal-close {\n position: absolute;\n top: 18px;\n right: 18px;\n background: none;\n border: none;\n color: var(--mid-grey, #728ea7);\n font-size: 2rem;\n cursor: pointer;\n z-index: 1002;\n transition: color 0.2s;\n}\n.stepper-modal-close:hover {\n color: var(--noir, #171e25);\n}\n";
|
|
79
|
+
if (typeof window !== 'undefined' && !document.getElementById('stepper-allaw-style')) {
|
|
80
|
+
var style = document.createElement('style');
|
|
81
|
+
style.id = 'stepper-allaw-style';
|
|
82
|
+
style.innerHTML = stepperStyle;
|
|
83
|
+
document.head.appendChild(style);
|
|
84
|
+
}
|
|
85
|
+
// Ajouter le composant CloseButton custom
|
|
86
|
+
var CloseButton = function (_a) {
|
|
87
|
+
var onClick = _a.onClick;
|
|
88
|
+
return (React.createElement("button", { type: "button", "aria-label": "Fermer", onClick: onClick, style: {
|
|
89
|
+
width: 36,
|
|
90
|
+
height: 36,
|
|
91
|
+
borderRadius: "50%",
|
|
92
|
+
border: "none",
|
|
93
|
+
background: "#fff",
|
|
94
|
+
boxShadow: "0 1px 4px rgba(0,0,0,0.04)",
|
|
95
|
+
display: "flex",
|
|
96
|
+
alignItems: "center",
|
|
97
|
+
justifyContent: "center",
|
|
98
|
+
cursor: "pointer",
|
|
99
|
+
transition: "background 0.2s",
|
|
100
|
+
marginLeft: 16,
|
|
101
|
+
padding: 0,
|
|
102
|
+
}, onMouseOver: function (e) { return (e.currentTarget.style.background = '#f2f8fc'); }, onMouseOut: function (e) { return (e.currentTarget.style.background = '#fff'); } },
|
|
103
|
+
React.createElement("svg", { width: "18", height: "18", viewBox: "0 0 18 18", fill: "none", xmlns: "http://www.w3.org/2000/svg" },
|
|
104
|
+
React.createElement("path", { d: "M5 5L13 13M13 5L5 13", stroke: "#171e25", strokeWidth: "2", strokeLinecap: "round" }))));
|
|
105
|
+
};
|
|
106
|
+
export var Stepper = function (_a) {
|
|
107
|
+
var config = _a.config, onSubmit = _a.onSubmit, _b = _a.isOpen, isOpen = _b === void 0 ? true : _b, onClose = _a.onClose;
|
|
108
|
+
var _c = useState(0), step = _c[0], setStep = _c[1];
|
|
109
|
+
var _d = useState({}), values = _d[0], setValues = _d[1];
|
|
110
|
+
var currentStep = config[step];
|
|
111
|
+
// Filtrer les champs à afficher selon showIf
|
|
112
|
+
var visibleFields = useMemo(function () {
|
|
113
|
+
return currentStep.fields.filter(function (field) { return !field.showIf || field.showIf(values); });
|
|
114
|
+
}, [currentStep, values]);
|
|
115
|
+
var handleFieldChange = function (name, value) {
|
|
116
|
+
setValues(function (prev) {
|
|
117
|
+
var _a;
|
|
118
|
+
return (__assign(__assign({}, prev), (_a = {}, _a[name] = value, _a)));
|
|
119
|
+
});
|
|
120
|
+
};
|
|
121
|
+
var handleNext = function () {
|
|
122
|
+
if (step < config.length - 1) {
|
|
123
|
+
setStep(step + 1);
|
|
124
|
+
}
|
|
125
|
+
else {
|
|
126
|
+
onSubmit(values);
|
|
127
|
+
}
|
|
128
|
+
};
|
|
129
|
+
var handlePrev = function () {
|
|
130
|
+
if (step > 0)
|
|
131
|
+
setStep(step - 1);
|
|
132
|
+
};
|
|
133
|
+
// Barre de progression simple
|
|
134
|
+
var progress = ((step + 1) / config.length) * 100;
|
|
135
|
+
if (!isOpen)
|
|
136
|
+
return null;
|
|
137
|
+
return (React.createElement(React.Fragment, null,
|
|
138
|
+
React.createElement("div", { className: "stepper-modal-backdrop" },
|
|
139
|
+
React.createElement("div", { className: "stepper-modal-center" },
|
|
140
|
+
React.createElement("div", { style: { position: "relative" } },
|
|
141
|
+
React.createElement("div", { className: "stepper-allaw" },
|
|
142
|
+
React.createElement("div", { style: { display: "flex", alignItems: "center", justifyContent: "center", gap: 12 } },
|
|
143
|
+
React.createElement("div", { className: "stepper-progress-bar", style: { flex: 1, height: 8, minWidth: 0 } },
|
|
144
|
+
React.createElement("div", { className: "stepper-progress-inner", style: { width: progress + "%", height: 8 } })),
|
|
145
|
+
React.createElement(CloseButton, { onClick: function () { return onClose && onClose(); } })),
|
|
146
|
+
React.createElement("div", { className: "stepper-title" }, currentStep.title),
|
|
147
|
+
currentStep.description && React.createElement("div", { className: "stepper-desc" }, currentStep.description),
|
|
148
|
+
React.createElement("form", { onSubmit: function (e) {
|
|
149
|
+
e.preventDefault();
|
|
150
|
+
handleNext();
|
|
151
|
+
} },
|
|
152
|
+
React.createElement("div", { className: "stepper-fields-grid" }, visibleFields.map(function (field) {
|
|
153
|
+
// On affiche le label au-dessus uniquement pour certains types
|
|
154
|
+
var showLabelAbove = ["select", "date", "checkbox", "radio", "custom"].includes(field.type);
|
|
155
|
+
return (React.createElement("div", { key: field.name, className: "stepper-field" },
|
|
156
|
+
showLabelAbove && (React.createElement(Paragraph, { variant: "medium", color: "noir", text: field.label, className: "stepper-label" })),
|
|
157
|
+
React.createElement(FieldRenderer, { field: field, value: values[field.name], onChange: function (val) { return handleFieldChange(field.name, val); }, values: values })));
|
|
158
|
+
})),
|
|
159
|
+
React.createElement("div", { className: "stepper-btn-row" },
|
|
160
|
+
React.createElement("button", { type: "button", className: "stepper-btn stepper-btn-secondary", onClick: handlePrev, disabled: step === 0 }, "Pr\u00E9c\u00E9dent"),
|
|
161
|
+
React.createElement("button", { type: "submit", className: "stepper-btn" }, step === config.length - 1 ? "Valider" : "Suivant")))))))));
|
|
162
|
+
};
|
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
11
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
12
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
13
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
14
|
+
function step(op) {
|
|
15
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
16
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
17
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
18
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
19
|
+
switch (op[0]) {
|
|
20
|
+
case 0: case 1: t = op; break;
|
|
21
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
22
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
23
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
24
|
+
default:
|
|
25
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
26
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
27
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
28
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
29
|
+
if (t[2]) _.ops.pop();
|
|
30
|
+
_.trys.pop(); continue;
|
|
31
|
+
}
|
|
32
|
+
op = body.call(thisArg, _);
|
|
33
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
34
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
import React from "react";
|
|
38
|
+
import { Stepper } from "./Stepper";
|
|
39
|
+
// Exemple de composant custom
|
|
40
|
+
var CustomInput = function (_a) {
|
|
41
|
+
var value = _a.value, onChange = _a.onChange, foo = _a.foo;
|
|
42
|
+
return (React.createElement("div", null,
|
|
43
|
+
React.createElement("label", null,
|
|
44
|
+
"Custom (",
|
|
45
|
+
foo,
|
|
46
|
+
")"),
|
|
47
|
+
React.createElement("input", { value: value || "", onChange: function (e) { return onChange(e.target.value); } })));
|
|
48
|
+
};
|
|
49
|
+
var fetchCities = function (country) { return __awaiter(void 0, void 0, void 0, function () {
|
|
50
|
+
return __generator(this, function (_a) {
|
|
51
|
+
if (country === "France")
|
|
52
|
+
return [2 /*return*/, ["Paris", "Lyon", "Marseille"]];
|
|
53
|
+
if (country === "Belgique")
|
|
54
|
+
return [2 /*return*/, ["Bruxelles", "Liège", "Anvers"]];
|
|
55
|
+
if (country === "Suisse")
|
|
56
|
+
return [2 /*return*/, ["Genève", "Zurich", "Lausanne"]];
|
|
57
|
+
return [2 /*return*/, []];
|
|
58
|
+
});
|
|
59
|
+
}); };
|
|
60
|
+
var config = [
|
|
61
|
+
{
|
|
62
|
+
title: "Informations personnelles",
|
|
63
|
+
description: "Merci de renseigner vos infos.",
|
|
64
|
+
fields: [
|
|
65
|
+
{ name: "firstName", label: "Prénom", type: "text" },
|
|
66
|
+
{ name: "lastName", label: "Nom", type: "text" },
|
|
67
|
+
{ name: "birthDate", label: "Date de naissance", type: "date" },
|
|
68
|
+
{ name: "gender", label: "Genre", type: "select", options: ["Homme", "Femme", "Autre"] },
|
|
69
|
+
{
|
|
70
|
+
name: "newsletter",
|
|
71
|
+
label: "S'inscrire à la newsletter",
|
|
72
|
+
type: "checkbox",
|
|
73
|
+
showIf: function (values) { return values.gender === "Femme"; },
|
|
74
|
+
},
|
|
75
|
+
],
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
title: "Adresse",
|
|
79
|
+
description: "Où habitez-vous ?",
|
|
80
|
+
fields: [
|
|
81
|
+
{
|
|
82
|
+
name: "country",
|
|
83
|
+
label: "Pays",
|
|
84
|
+
type: "combobox",
|
|
85
|
+
options: function () { return __awaiter(void 0, void 0, void 0, function () { return __generator(this, function (_a) {
|
|
86
|
+
return [2 /*return*/, ["France", "Belgique", "Suisse"]];
|
|
87
|
+
}); }); },
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
name: "city",
|
|
91
|
+
label: "Ville",
|
|
92
|
+
type: "combobox",
|
|
93
|
+
options: function (values) { return __awaiter(void 0, void 0, void 0, function () { return __generator(this, function (_a) {
|
|
94
|
+
return [2 /*return*/, fetchCities(values.country)];
|
|
95
|
+
}); }); },
|
|
96
|
+
showIf: function (values) { return !!values.country; },
|
|
97
|
+
},
|
|
98
|
+
{ name: "postalCode", label: "Code postal", type: "text", showIf: function (values) { return !!values.country; } },
|
|
99
|
+
{ name: "address", label: "Adresse complète", type: "text" },
|
|
100
|
+
],
|
|
101
|
+
},
|
|
102
|
+
{
|
|
103
|
+
title: "Préférences",
|
|
104
|
+
description: "Choisissez vos préférences.",
|
|
105
|
+
fields: [
|
|
106
|
+
{
|
|
107
|
+
name: "color",
|
|
108
|
+
label: "Couleur préférée",
|
|
109
|
+
type: "radio",
|
|
110
|
+
options: ["Rouge", "Vert", "Bleu"],
|
|
111
|
+
},
|
|
112
|
+
{
|
|
113
|
+
name: "animal",
|
|
114
|
+
label: "Animal préféré",
|
|
115
|
+
type: "select",
|
|
116
|
+
options: ["Chien", "Chat", "Oiseau", "Poisson"],
|
|
117
|
+
},
|
|
118
|
+
{
|
|
119
|
+
name: "customField",
|
|
120
|
+
label: "Champ custom",
|
|
121
|
+
type: "custom",
|
|
122
|
+
customComponent: CustomInput,
|
|
123
|
+
customProps: { foo: "bar" },
|
|
124
|
+
},
|
|
125
|
+
],
|
|
126
|
+
},
|
|
127
|
+
{
|
|
128
|
+
title: "Expérience professionnelle",
|
|
129
|
+
description: "Parlez-nous de votre parcours.",
|
|
130
|
+
fields: [
|
|
131
|
+
{ name: "job", label: "Métier actuel", type: "text" },
|
|
132
|
+
{ name: "years", label: "Années d'expérience", type: "select", options: ["0-2", "3-5", "6-10", "10+"] },
|
|
133
|
+
{
|
|
134
|
+
name: "manager",
|
|
135
|
+
label: "Êtes-vous manager ?",
|
|
136
|
+
type: "checkbox",
|
|
137
|
+
},
|
|
138
|
+
{
|
|
139
|
+
name: "teamSize",
|
|
140
|
+
label: "Taille de l'équipe",
|
|
141
|
+
type: "select",
|
|
142
|
+
options: ["1-5", "6-10", "11-20", "20+"],
|
|
143
|
+
showIf: function (values) { return values.manager; },
|
|
144
|
+
},
|
|
145
|
+
],
|
|
146
|
+
},
|
|
147
|
+
{
|
|
148
|
+
title: "Compétences",
|
|
149
|
+
description: "Listez vos compétences principales.",
|
|
150
|
+
fields: [
|
|
151
|
+
{ name: "skills", label: "Compétences (séparées par des virgules)", type: "text" },
|
|
152
|
+
{ name: "certified", label: "Certifié dans un domaine ?", type: "checkbox" },
|
|
153
|
+
{
|
|
154
|
+
name: "certificationName",
|
|
155
|
+
label: "Nom de la certification",
|
|
156
|
+
type: "text",
|
|
157
|
+
showIf: function (values) { return values.certified; },
|
|
158
|
+
},
|
|
159
|
+
],
|
|
160
|
+
},
|
|
161
|
+
{
|
|
162
|
+
title: "Formation",
|
|
163
|
+
description: "Votre parcours scolaire.",
|
|
164
|
+
fields: [
|
|
165
|
+
{ name: "degree", label: "Diplôme le plus élevé", type: "select", options: ["Aucun", "Bac", "Bac+2", "Bac+5", "Doctorat"] },
|
|
166
|
+
{ name: "school", label: "Établissement", type: "text" },
|
|
167
|
+
{ name: "graduationYear", label: "Année d'obtention", type: "text" },
|
|
168
|
+
],
|
|
169
|
+
},
|
|
170
|
+
{
|
|
171
|
+
title: "Langues",
|
|
172
|
+
description: "Quelles langues parlez-vous ?",
|
|
173
|
+
fields: [
|
|
174
|
+
{ name: "languages", label: "Langues (séparées par des virgules)", type: "text" },
|
|
175
|
+
{ name: "native", label: "Langue maternelle", type: "text" },
|
|
176
|
+
],
|
|
177
|
+
},
|
|
178
|
+
{
|
|
179
|
+
title: "Centres d'intérêt",
|
|
180
|
+
description: "Parlez-nous de vos hobbies.",
|
|
181
|
+
fields: [
|
|
182
|
+
{ name: "hobbies", label: "Hobbies", type: "text" },
|
|
183
|
+
{ name: "sport", label: "Pratiquez-vous un sport ?", type: "checkbox" },
|
|
184
|
+
{
|
|
185
|
+
name: "sportName",
|
|
186
|
+
label: "Quel sport ?",
|
|
187
|
+
type: "text",
|
|
188
|
+
showIf: function (values) { return values.sport; },
|
|
189
|
+
},
|
|
190
|
+
],
|
|
191
|
+
},
|
|
192
|
+
{
|
|
193
|
+
title: "Confirmation",
|
|
194
|
+
description: "Merci de vérifier vos informations avant de valider.",
|
|
195
|
+
fields: [
|
|
196
|
+
{ name: "acceptTerms", label: "J'accepte les conditions d'utilisation", type: "checkbox" },
|
|
197
|
+
],
|
|
198
|
+
},
|
|
199
|
+
];
|
|
200
|
+
export default {
|
|
201
|
+
title: "Molecules/DataStepper/Stepper",
|
|
202
|
+
component: Stepper,
|
|
203
|
+
};
|
|
204
|
+
export var GrandExemple = function () { return (React.createElement("div", { style: { maxWidth: 600, margin: "auto" } },
|
|
205
|
+
React.createElement(Stepper, { config: config, onSubmit: function (values) {
|
|
206
|
+
// eslint-disable-next-line no-alert
|
|
207
|
+
alert("Données soumises : " + JSON.stringify(values, null, 2));
|
|
208
|
+
console.log(values);
|
|
209
|
+
} }))); };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './Stepper';
|
package/dist/index.d.ts
CHANGED
|
@@ -62,6 +62,8 @@ export { default as LoadingBox } from "./components/molecules/loadingBox/Loading
|
|
|
62
62
|
export { default as DocumentCard } from "./components/molecules/documentCard/DocumentCard";
|
|
63
63
|
export type { DocumentCardProps } from "./components/molecules/documentCard/DocumentCard";
|
|
64
64
|
export { default as EmployeeCard } from "./components/molecules/employeeCard/EmployeeCard";
|
|
65
|
+
export { Stepper as DataStepper } from "./components/molecules/DataStepper";
|
|
66
|
+
export type { StepField as DataStepField, StepConfig as DataStepConfig, StepperProps as DataStepperProps } from "./components/molecules/DataStepper";
|
|
65
67
|
export { default as Stepper } from "./components/molecules/stepper/Stepper";
|
|
66
68
|
export type { StepperProps } from "./components/molecules/stepper/Stepper";
|
|
67
69
|
export { default as RangeSlider } from "./components/molecules/rangeSlider/RangeSlider";
|
package/dist/index.js
CHANGED
|
@@ -71,6 +71,8 @@ export { default as DocumentCard } from "./components/molecules/documentCard/Doc
|
|
|
71
71
|
// Employee Card
|
|
72
72
|
export { default as EmployeeCard } from "./components/molecules/employeeCard/EmployeeCard";
|
|
73
73
|
// Stepper
|
|
74
|
+
export { Stepper as DataStepper } from "./components/molecules/DataStepper";
|
|
75
|
+
// Ancien Stepper (legacy)
|
|
74
76
|
export { default as Stepper } from "./components/molecules/stepper/Stepper";
|
|
75
77
|
// Range Slider
|
|
76
78
|
export { default as RangeSlider } from "./components/molecules/rangeSlider/RangeSlider";
|