allaw-ui 2.7.7 → 2.7.9

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.
@@ -0,0 +1,20 @@
1
+ import React from "react";
2
+ import "../../../styles/icons.css";
3
+ export type ResponsiveConfig = {
4
+ label?: string;
5
+ height?: number;
6
+ width?: number;
7
+ };
8
+ export type ResponsiveBreakpoints = Record<number, ResponsiveConfig>;
9
+ export interface SelectCardProps {
10
+ iconName?: string;
11
+ iconUrl?: string;
12
+ label: string;
13
+ isActive?: boolean;
14
+ isDisabled?: boolean;
15
+ size?: "small" | "medium" | "large";
16
+ onClick: () => void;
17
+ responsiveConfig?: ResponsiveBreakpoints;
18
+ }
19
+ declare const SelectCard: React.FC<SelectCardProps>;
20
+ export default SelectCard;
@@ -0,0 +1,70 @@
1
+ import React, { useEffect, useState } from "react";
2
+ import styles from "./SelectCard.module.css";
3
+ import "../../../styles/icons.css";
4
+ var SelectCard = function (_a) {
5
+ var iconName = _a.iconName, iconUrl = _a.iconUrl, label = _a.label, _b = _a.isActive, isActive = _b === void 0 ? false : _b, _c = _a.isDisabled, isDisabled = _c === void 0 ? false : _c, _d = _a.size, size = _d === void 0 ? "medium" : _d, onClick = _a.onClick, responsiveConfig = _a.responsiveConfig;
6
+ var _e = useState(label), currentLabel = _e[0], setCurrentLabel = _e[1];
7
+ var _f = useState({}), currentStyle = _f[0], setCurrentStyle = _f[1];
8
+ useEffect(function () {
9
+ if (!responsiveConfig)
10
+ return;
11
+ var handleResize = function () {
12
+ var width = window.innerWidth;
13
+ var breakpoints = Object.keys(responsiveConfig)
14
+ .map(Number)
15
+ .sort(function (a, b) { return a - b; });
16
+ // Réinitialiser aux valeurs par défaut
17
+ var selectedLabel = label;
18
+ var selectedWidth = undefined;
19
+ var selectedHeight = undefined;
20
+ // Trouver la configuration appropriée pour la largeur actuelle
21
+ for (var _i = 0, breakpoints_1 = breakpoints; _i < breakpoints_1.length; _i++) {
22
+ var breakpoint = breakpoints_1[_i];
23
+ if (width >= breakpoint) {
24
+ var config = responsiveConfig[breakpoint];
25
+ if (config.label)
26
+ selectedLabel = config.label;
27
+ if (config.width)
28
+ selectedWidth = config.width;
29
+ if (config.height)
30
+ selectedHeight = config.height;
31
+ }
32
+ else {
33
+ break;
34
+ }
35
+ }
36
+ setCurrentLabel(selectedLabel);
37
+ setCurrentStyle({
38
+ width: selectedWidth ? "".concat(selectedWidth, "px") : undefined,
39
+ height: selectedHeight ? "".concat(selectedHeight, "px") : undefined,
40
+ });
41
+ };
42
+ // Vérification initiale
43
+ handleResize();
44
+ // Ajouter un écouteur d'événement
45
+ window.addEventListener("resize", handleResize);
46
+ // Nettoyage
47
+ return function () {
48
+ window.removeEventListener("resize", handleResize);
49
+ };
50
+ }, [responsiveConfig, label]);
51
+ var handleClick = function () {
52
+ if (!isDisabled) {
53
+ onClick();
54
+ }
55
+ };
56
+ var renderIcon = function () {
57
+ if (iconUrl) {
58
+ return (React.createElement("img", { src: iconUrl, alt: currentLabel, className: styles.iconImage }));
59
+ }
60
+ else if (iconName) {
61
+ return React.createElement("i", { className: "".concat(iconName, " ").concat(styles.iconFont) });
62
+ }
63
+ return null;
64
+ };
65
+ return (React.createElement("button", { className: "".concat(styles.selectCard, " \n ").concat(isActive ? styles.active : "", " \n ").concat(isDisabled ? styles.disabled : "", " \n ").concat(styles[size]), onClick: handleClick, disabled: isDisabled, type: "button", style: currentStyle, title: currentLabel },
66
+ React.createElement("div", { className: styles.contentWrapper },
67
+ (iconName || iconUrl) && (React.createElement("div", { className: styles.iconWrapper }, renderIcon())),
68
+ React.createElement("span", { className: styles.label }, currentLabel))));
69
+ };
70
+ export default SelectCard;
@@ -0,0 +1,174 @@
1
+ .selectCard {
2
+ display: flex;
3
+ align-items: center;
4
+ justify-content: center;
5
+ border: 2px solid #e6edf5;
6
+ border-radius: 12px;
7
+ background: #fff;
8
+ cursor: pointer;
9
+ font-family: "Open Sans", sans-serif;
10
+ font-size: 14px;
11
+ font-weight: 600;
12
+ padding: 0;
13
+ transition: all 0.2s ease;
14
+ outline: none;
15
+ width: fit-content;
16
+ box-sizing: border-box;
17
+ }
18
+
19
+ .contentWrapper {
20
+ display: flex;
21
+ flex-direction: column;
22
+ align-items: center;
23
+ justify-content: center;
24
+ gap: 16px;
25
+ padding: 16px;
26
+ width: 100%;
27
+ height: 100%;
28
+ box-sizing: border-box;
29
+ }
30
+
31
+ .iconWrapper {
32
+ display: flex;
33
+ align-items: center;
34
+ justify-content: center;
35
+ height: 48px; /* Hauteur fixe pour l'icône */
36
+ margin-bottom: 4px; /* Espace supplémentaire en bas de l'icône */
37
+ }
38
+
39
+ /* Taille d'icône par défaut */
40
+ .iconFont {
41
+ color: #456073;
42
+ }
43
+
44
+ .iconImage {
45
+ object-fit: contain;
46
+ }
47
+
48
+ .label {
49
+ font-family: "Open Sans", sans-serif;
50
+ font-size: 14px;
51
+ font-style: normal;
52
+ font-weight: 600;
53
+ line-height: 1.2;
54
+ color: #456073;
55
+ text-align: center;
56
+ max-width: 100%;
57
+ overflow: hidden;
58
+ text-overflow: ellipsis;
59
+ display: -webkit-box;
60
+ -webkit-line-clamp: 2; /* Limite à 2 lignes */
61
+ -webkit-box-orient: vertical;
62
+ height: 2.4em; /* Hauteur fixe pour 2 lignes */
63
+ }
64
+
65
+ /* Tailles */
66
+ .small {
67
+ min-width: 80px;
68
+ min-height: 80px;
69
+ max-width: 80px;
70
+ }
71
+
72
+ .small .iconFont {
73
+ font-size: 24px;
74
+ }
75
+
76
+ .small .iconImage {
77
+ width: 24px;
78
+ height: 24px;
79
+ }
80
+
81
+ .small .iconWrapper {
82
+ height: 32px;
83
+ }
84
+
85
+ .medium {
86
+ min-width: 120px;
87
+ min-height: 120px;
88
+ max-width: 120px;
89
+ }
90
+
91
+ .medium .iconFont {
92
+ font-size: 32px;
93
+ }
94
+
95
+ .medium .iconImage {
96
+ width: 32px;
97
+ height: 32px;
98
+ }
99
+
100
+ .medium .iconWrapper {
101
+ height: 48px;
102
+ }
103
+
104
+ .large {
105
+ min-width: 160px;
106
+ min-height: 160px;
107
+ max-width: 160px;
108
+ }
109
+
110
+ .large .iconFont {
111
+ font-size: 48px;
112
+ }
113
+
114
+ .large .iconImage {
115
+ width: 48px;
116
+ height: 48px;
117
+ }
118
+
119
+ .large .iconWrapper {
120
+ height: 64px;
121
+ }
122
+
123
+ /* États - Non sélectionné */
124
+ .selectCard {
125
+ background-color: #fff;
126
+ border-color: #e6edf5;
127
+ }
128
+
129
+ .selectCard:hover {
130
+ border-color: #d1dce8;
131
+ box-shadow: 0px 2px 4px rgba(0, 0, 0, 0.05);
132
+ }
133
+
134
+ .selectCard:active {
135
+ border-color: #d1dce7;
136
+ background-color: #f4f7fb;
137
+ }
138
+
139
+ /* États - Sélectionné */
140
+ .active {
141
+ border-color: #25beeb;
142
+ }
143
+
144
+ .active .iconFont,
145
+ .active .label {
146
+ color: #25beeb;
147
+ }
148
+
149
+ .active:hover {
150
+ border-color: #7dd5f2;
151
+ }
152
+
153
+ .active:active {
154
+ border-color: #1a9bc2;
155
+ background-color: #e6edf5;
156
+ }
157
+
158
+ /* États - Désactivé */
159
+ .disabled {
160
+ opacity: 0.5;
161
+ cursor: not-allowed;
162
+ border-color: #d1dce7;
163
+ background-color: #f4f7fb;
164
+ }
165
+
166
+ .disabled:hover {
167
+ border-color: #d1dce7;
168
+ box-shadow: none;
169
+ }
170
+
171
+ .disabled .iconFont,
172
+ .disabled .label {
173
+ color: #728ea7;
174
+ }
@@ -0,0 +1,77 @@
1
+ export namespace ActionsData {
2
+ namespace onClick {
3
+ let action: string;
4
+ }
5
+ }
6
+ declare namespace _default {
7
+ export let title: string;
8
+ export { SelectCard as component };
9
+ export let tags: string[];
10
+ export let excludeStories: RegExp;
11
+ export namespace args { }
12
+ export namespace argTypes {
13
+ namespace iconName {
14
+ let control: string;
15
+ let description: string;
16
+ }
17
+ namespace iconUrl {
18
+ let control_1: string;
19
+ export { control_1 as control };
20
+ let description_1: string;
21
+ export { description_1 as description };
22
+ }
23
+ namespace label {
24
+ let control_2: string;
25
+ export { control_2 as control };
26
+ let description_2: string;
27
+ export { description_2 as description };
28
+ }
29
+ namespace isActive {
30
+ let control_3: string;
31
+ export { control_3 as control };
32
+ let description_3: string;
33
+ export { description_3 as description };
34
+ }
35
+ namespace isDisabled {
36
+ let control_4: string;
37
+ export { control_4 as control };
38
+ let description_4: string;
39
+ export { description_4 as description };
40
+ }
41
+ namespace size {
42
+ export namespace control_5 {
43
+ let type: string;
44
+ let options: string[];
45
+ }
46
+ export { control_5 as control };
47
+ let description_5: string;
48
+ export { description_5 as description };
49
+ }
50
+ namespace responsiveConfig {
51
+ let control_6: string;
52
+ export { control_6 as control };
53
+ let description_6: string;
54
+ export { description_6 as description };
55
+ }
56
+ }
57
+ export namespace parameters {
58
+ namespace backgrounds {
59
+ let _default: string;
60
+ export { _default as default };
61
+ export let values: {
62
+ name: string;
63
+ value: string;
64
+ }[];
65
+ }
66
+ }
67
+ }
68
+ export default _default;
69
+ export const Default: any;
70
+ export const Active: any;
71
+ export const Disabled: any;
72
+ export const Small: any;
73
+ export const Large: any;
74
+ export const WithImageUrl: any;
75
+ export const WithLongText: any;
76
+ export const WithResponsiveConfig: any;
77
+ import SelectCard from "./SelectCard";
@@ -0,0 +1,153 @@
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 } from "react";
13
+ import SelectCard from "./SelectCard";
14
+ export var ActionsData = {
15
+ onClick: { action: "clicked" },
16
+ };
17
+ export default {
18
+ title: "Components/Atoms/Radios/SelectCard",
19
+ component: SelectCard,
20
+ tags: ["autodocs"],
21
+ excludeStories: /.*Data$/,
22
+ args: __assign({}, ActionsData),
23
+ argTypes: {
24
+ iconName: {
25
+ control: "text",
26
+ description: "Nom de l'icône à afficher (utilise la font allaw-font)",
27
+ },
28
+ iconUrl: {
29
+ control: "text",
30
+ description: "URL de l'image à afficher (alternative à iconName)",
31
+ },
32
+ label: {
33
+ control: "text",
34
+ description: "Texte du bouton",
35
+ },
36
+ isActive: {
37
+ control: "boolean",
38
+ description: "État actif du bouton",
39
+ },
40
+ isDisabled: {
41
+ control: "boolean",
42
+ description: "État désactivé du bouton",
43
+ },
44
+ size: {
45
+ control: {
46
+ type: "select",
47
+ options: ["small", "medium", "large"],
48
+ },
49
+ description: "Taille du bouton",
50
+ },
51
+ responsiveConfig: {
52
+ control: "object",
53
+ description: "Configuration responsive du bouton",
54
+ },
55
+ },
56
+ parameters: {
57
+ backgrounds: {
58
+ default: "light",
59
+ values: [
60
+ { name: "light", value: "#ffffff" },
61
+ { name: "grey", value: "#728ea7" },
62
+ { name: "figma", value: "#404040" },
63
+ { name: "dark", value: "#171e25" },
64
+ ],
65
+ },
66
+ },
67
+ };
68
+ var Template = function (args) {
69
+ var _a = useState(args.isActive || false), isActive = _a[0], setIsActive = _a[1];
70
+ var handleClick = function () {
71
+ if (!args.isDisabled) {
72
+ setIsActive(!isActive);
73
+ args.onClick();
74
+ }
75
+ };
76
+ return React.createElement(SelectCard, __assign({}, args, { isActive: isActive, onClick: handleClick }));
77
+ };
78
+ export var Default = Template.bind({});
79
+ Default.args = {
80
+ label: "Utiliser la convention type d'allaw",
81
+ iconName: "allaw-icon-upload-file",
82
+ isActive: false,
83
+ isDisabled: false,
84
+ size: "medium",
85
+ };
86
+ export var Active = Template.bind({});
87
+ Active.args = {
88
+ label: "Choix 1",
89
+ iconName: "allaw-icon-upload-file",
90
+ isActive: true,
91
+ isDisabled: false,
92
+ size: "medium",
93
+ };
94
+ export var Disabled = Template.bind({});
95
+ Disabled.args = {
96
+ label: "Choix 1",
97
+ iconName: "allaw-icon-upload-file",
98
+ isActive: false,
99
+ isDisabled: true,
100
+ size: "medium",
101
+ };
102
+ export var Small = Template.bind({});
103
+ Small.args = {
104
+ label: "Choix 1",
105
+ iconName: "allaw-icon-upload-file",
106
+ isActive: false,
107
+ isDisabled: false,
108
+ size: "small",
109
+ };
110
+ export var Large = Template.bind({});
111
+ Large.args = {
112
+ label: "Choix 1",
113
+ iconName: "allaw-icon-upload-file",
114
+ isActive: false,
115
+ isDisabled: false,
116
+ size: "large",
117
+ };
118
+ export var WithImageUrl = Template.bind({});
119
+ WithImageUrl.args = {
120
+ label: "Choix 1",
121
+ iconUrl: "https://www.svgrepo.com/show/428478/file-choose.svg",
122
+ isActive: false,
123
+ isDisabled: false,
124
+ size: "medium",
125
+ };
126
+ export var WithLongText = Template.bind({});
127
+ WithLongText.args = {
128
+ label: "Texte très long qui devrait être tronqué avec des points de suspension",
129
+ iconUrl: "https://www.svgrepo.com/show/428478/file-choose.svg",
130
+ isActive: false,
131
+ isDisabled: false,
132
+ size: "medium",
133
+ };
134
+ export var WithResponsiveConfig = Template.bind({});
135
+ WithResponsiveConfig.args = {
136
+ label: "Version Desktop",
137
+ iconName: "allaw-icon-upload-file",
138
+ isActive: false,
139
+ isDisabled: false,
140
+ size: "medium",
141
+ responsiveConfig: {
142
+ 768: {
143
+ label: "Version Tablette",
144
+ width: 100,
145
+ height: 100,
146
+ },
147
+ 480: {
148
+ label: "Mobile",
149
+ width: 80,
150
+ height: 80,
151
+ },
152
+ },
153
+ };
@@ -1,2 +1,4 @@
1
1
  export { default as RadioButton } from "./RadioButton";
2
2
  export type { RadioButtonProps } from "./RadioButton";
3
+ export { default as SelectCard } from "./SelectCard";
4
+ export type { SelectCardProps } from "./SelectCard";
@@ -1 +1,2 @@
1
1
  export { default as RadioButton } from "./RadioButton";
2
+ export { default as SelectCard } from "./SelectCard";
@@ -94,15 +94,14 @@
94
94
  left: 0;
95
95
  width: 100%;
96
96
  height: 100%;
97
- background: rgba(0, 0, 0, 0.5);
98
- z-index: 1000;
97
+ background-color: rgba(0, 0, 0, 0.5);
99
98
  display: flex;
100
99
  justify-content: center;
101
100
  align-items: center;
101
+ z-index: 3000;
102
102
  opacity: 0;
103
103
  visibility: hidden;
104
104
  transition: opacity 0.3s ease, visibility 0.3s ease;
105
- box-sizing: border-box;
106
105
  }
107
106
 
108
107
  .stepper-overlay.visible {
@@ -110,6 +109,14 @@
110
109
  visibility: visible;
111
110
  }
112
111
 
112
+ /* Classe pour bloquer le scroll du body */
113
+ body.stepper-open {
114
+ overflow: hidden;
115
+ position: fixed;
116
+ width: 100%;
117
+ height: 100%;
118
+ }
119
+
113
120
  @media (max-width: 800px) {
114
121
  .stepper-container {
115
122
  height: 96dvh;
@@ -50,6 +50,19 @@ var Stepper = function (_a) {
50
50
  var _m = useState(false), isVisible = _m[0], setIsVisible = _m[1];
51
51
  var portalContainerRef = useRef(null);
52
52
  var stepperContainerRef = useRef(null);
53
+ // Effet pour bloquer le scroll du body quand le stepper est visible
54
+ useEffect(function () {
55
+ if (isVisible) {
56
+ document.body.classList.add("stepper-open");
57
+ }
58
+ else {
59
+ document.body.classList.remove("stepper-open");
60
+ }
61
+ // Nettoyage lors du démontage du composant
62
+ return function () {
63
+ document.body.classList.remove("stepper-open");
64
+ };
65
+ }, [isVisible]);
53
66
  useEffect(function () {
54
67
  var container = document.createElement("div");
55
68
  document.body.appendChild(container);
package/dist/index.d.ts CHANGED
@@ -21,6 +21,8 @@ export { default as SearchBar } from "./components/atoms/inputs/SearchBar";
21
21
  export { default as ProgressBar } from "./components/atoms/progressBars/ProgressBar";
22
22
  export { default as RadioButton } from "./components/atoms/radios/RadioButton";
23
23
  export { default as SingleFilter } from "./components/atoms/filters/SingleFilter";
24
+ export { default as SelectCard } from "./components/atoms/radios/SelectCard";
25
+ export type { SelectCardProps } from "./components/atoms/radios/SelectCard";
24
26
  export { default as Select } from "./components/atoms/selects/Select";
25
27
  export type { SelectItem, SelectProps, SelectRef, } from "./components/atoms/selects/Select";
26
28
  export { default as ComboBox } from "./components/atoms/selects/ComboBox";
package/dist/index.js CHANGED
@@ -25,6 +25,7 @@ export { default as ProgressBar } from "./components/atoms/progressBars/Progress
25
25
  // Radios
26
26
  export { default as RadioButton } from "./components/atoms/radios/RadioButton";
27
27
  export { default as SingleFilter } from "./components/atoms/filters/SingleFilter";
28
+ export { default as SelectCard } from "./components/atoms/radios/SelectCard";
28
29
  // Selects
29
30
  export { default as Select } from "./components/atoms/selects/Select";
30
31
  export { default as ComboBox } from "./components/atoms/selects/ComboBox";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "allaw-ui",
3
- "version": "2.7.7",
3
+ "version": "2.7.9",
4
4
  "description": "Composants UI pour l'application Allaw",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.esm.js",