allaw-ui 0.1.25 → 0.1.27

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.
@@ -11,6 +11,7 @@ export interface CheckboxFormProps {
11
11
  linkUrl?: string;
12
12
  size?: "default" | "small";
13
13
  style?: "default" | "light";
14
+ markType?: "cross" | "check";
14
15
  }
15
16
  declare const CheckboxForm: React.FC<CheckboxFormProps>;
16
17
  export default CheckboxForm;
@@ -3,7 +3,7 @@ import Checkbox from "../../atoms/checkboxes/Checkbox";
3
3
  import Paragraph from "../../atoms/typography/Paragraph";
4
4
  import "./CheckboxForm.css";
5
5
  var CheckboxForm = function (_a) {
6
- var _b = _a.checked, checked = _b === void 0 ? false : _b, onChange = _a.onChange, _c = _a.color, color = _c === void 0 ? "noir" : _c, label = _a.label, _d = _a.isRequired, isRequired = _d === void 0 ? false : _d, linkText = _a.linkText, linkUrl = _a.linkUrl, _e = _a.size, size = _e === void 0 ? "default" : _e, _f = _a.style, style = _f === void 0 ? "default" : _f;
6
+ var _b = _a.checked, checked = _b === void 0 ? false : _b, onChange = _a.onChange, _c = _a.color, color = _c === void 0 ? "noir" : _c, label = _a.label, _d = _a.isRequired, isRequired = _d === void 0 ? false : _d, linkText = _a.linkText, linkUrl = _a.linkUrl, _e = _a.size, size = _e === void 0 ? "default" : _e, _f = _a.style, style = _f === void 0 ? "default" : _f, _g = _a.markType, markType = _g === void 0 ? "cross" : _g;
7
7
  var checkboxId = "checkbox-".concat(Math.random().toString(36).substr(2, 9));
8
8
  var handleCheckboxChange = function (checked) {
9
9
  if (onChange) {
@@ -12,7 +12,7 @@ var CheckboxForm = function (_a) {
12
12
  };
13
13
  var checkboxColor = style === "light" ? "light" : color;
14
14
  return (React.createElement("div", { className: "checkbox-form checkbox-form-".concat(checkboxColor, " ").concat(size === "small" ? "checkbox-form-small" : "") },
15
- React.createElement(Checkbox, { id: checkboxId, checked: checked, onChange: handleCheckboxChange, color: checkboxColor, size: size, style: style }),
15
+ React.createElement(Checkbox, { id: checkboxId, checked: checked, onChange: handleCheckboxChange, color: checkboxColor, size: size, style: style, markType: markType }),
16
16
  label && (React.createElement("label", { htmlFor: checkboxId, className: "checkbox-form-label-container" },
17
17
  React.createElement(Paragraph, { variant: "semiBold", color: color, text: React.createElement(React.Fragment, null,
18
18
  React.createElement("span", null, label),
@@ -25,7 +25,7 @@ export interface StepperProps {
25
25
  }[];
26
26
  showProgressBar?: boolean[];
27
27
  onClose?: () => void;
28
- validateStep?: (step: number) => boolean;
28
+ validateStep?: (step: number) => boolean | Promise<boolean>;
29
29
  }
30
30
  declare const Stepper: React.FC<StepperProps>;
31
31
  export default Stepper;
@@ -1,4 +1,40 @@
1
1
  "use client";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __generator = (this && this.__generator) || function (thisArg, body) {
12
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
13
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
+ function verb(n) { return function (v) { return step([n, v]); }; }
15
+ function step(op) {
16
+ if (f) throw new TypeError("Generator is already executing.");
17
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
18
+ 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;
19
+ if (y = 0, t) op = [op[0] & 2, t.value];
20
+ switch (op[0]) {
21
+ case 0: case 1: t = op; break;
22
+ case 4: _.label++; return { value: op[1], done: false };
23
+ case 5: _.label++; y = op[1]; op = [0]; continue;
24
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
+ default:
26
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
+ if (t[2]) _.ops.pop();
31
+ _.trys.pop(); continue;
32
+ }
33
+ op = body.call(thisArg, _);
34
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
+ }
37
+ };
2
38
  import React, { useState, useEffect, useCallback, useRef } from "react";
3
39
  import ReactDOM from "react-dom";
4
40
  import "./Stepper.css";
@@ -28,28 +64,34 @@ var Stepper = function (_a) {
28
64
  useEffect(function () {
29
65
  setStep(currentStep || 1);
30
66
  }, [currentStep]);
31
- var handleNext = useCallback(function () {
32
- // console.log("Stepper: Validating current step");
33
- var currentPrimaryButton = primaryButton[step - 1];
34
- if (currentPrimaryButton === null || currentPrimaryButton === void 0 ? void 0 : currentPrimaryButton.onPrimaryButtonClick) {
35
- currentPrimaryButton.onPrimaryButtonClick(step);
36
- }
37
- if (validateStep) {
38
- var isValid = validateStep(step);
39
- // console.log(
40
- // `Stepper: Step ${step} validation result - ${isValid ? "valid" : "invalid"}`
41
- // );
42
- if (!isValid) {
43
- return;
67
+ var handleNext = useCallback(function () { return __awaiter(void 0, void 0, void 0, function () {
68
+ var currentPrimaryButton, isValid;
69
+ return __generator(this, function (_a) {
70
+ switch (_a.label) {
71
+ case 0:
72
+ currentPrimaryButton = primaryButton[step - 1];
73
+ if (currentPrimaryButton === null || currentPrimaryButton === void 0 ? void 0 : currentPrimaryButton.onPrimaryButtonClick) {
74
+ currentPrimaryButton.onPrimaryButtonClick(step);
75
+ }
76
+ if (!validateStep) return [3 /*break*/, 2];
77
+ return [4 /*yield*/, validateStep(step)];
78
+ case 1:
79
+ isValid = _a.sent();
80
+ if (!isValid) {
81
+ return [2 /*return*/];
82
+ }
83
+ _a.label = 2;
84
+ case 2:
85
+ if (step < steps) {
86
+ setStep(step + 1);
87
+ }
88
+ else if (step === steps && onClose) {
89
+ onClose();
90
+ }
91
+ return [2 /*return*/];
44
92
  }
45
- }
46
- if (step < steps) {
47
- setStep(step + 1);
48
- }
49
- else if (step === steps && onClose) {
50
- onClose();
51
- }
52
- }, [step, steps, validateStep, primaryButton, onClose]);
93
+ });
94
+ }); }, [step, steps, validateStep, primaryButton, onClose]);
53
95
  var handlePrevious = useCallback(function () {
54
96
  if (step > 1) {
55
97
  setStep(step - 1);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "allaw-ui",
3
- "version": "0.1.25",
3
+ "version": "0.1.27",
4
4
  "description": "Composants UI pour l'application Allaw",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.esm.js",