kelt-ui-kit-react 1.3.4 → 1.3.6

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "kelt-ui-kit-react",
3
3
  "type": "module",
4
- "version": "1.3.4",
4
+ "version": "1.3.6",
5
5
  "private": false,
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",
@@ -70,7 +70,7 @@ export function DataTable<T>(props: DataTableProps<T>) {
70
70
  };
71
71
  }, [onLoadMore, hasMore]);
72
72
  return (
73
- <div>
73
+ <div className="data-table-container">
74
74
  {name && <h2 className="mb-2">{name}</h2>}
75
75
  {element}
76
76
  <table className={`data-table ${className ? className : ""}`} id={id}>
@@ -1,17 +1,20 @@
1
- .data-table {
2
- width: 100%;
3
- border-spacing: 5px;
4
- font-size: 14px;
5
- color: #333;
1
+ .data-table-container {
2
+ overflow: auto;
3
+ .data-table {
4
+ width: 100%;
5
+ border-spacing: 5px;
6
+ font-size: 14px;
7
+ color: #333;
6
8
 
7
- thead {
8
- margin-bottom: 1rem;
9
- position : sticky;
10
- top : 0;
11
- background-color: #fff;
12
- th {
13
- color: #bdbaba;
14
- min-width: 100px;
9
+ thead {
10
+ margin-bottom: 1rem;
11
+ position: sticky;
12
+ top: 0;
13
+ background-color: #fff;
14
+ th {
15
+ color: #bdbaba;
16
+ min-width: 100px;
17
+ }
15
18
  }
16
19
  }
17
20
  }
@@ -37,6 +37,18 @@ export const FormView = (): JSX.Element => {
37
37
  label: "Password",
38
38
  type: TypeInputEnum.PASSWORD,
39
39
  },
40
+ {
41
+ value: "",
42
+ name: "selectOption",
43
+ label: "Select Option",
44
+ placeholder: "Choose an option",
45
+ type: TypeInputEnum.SELECT,
46
+ options: [
47
+ { value: "option1", label: "Option 1" },
48
+ { value: "option2", label: "Option 2" },
49
+ { value: "option3", label: "Option 3" },
50
+ ],
51
+ },
40
52
  ];
41
53
 
42
54
  // Fonction qui sera appelée lors de la soumission du formulaire
@@ -1,4 +1,5 @@
1
- import { useRef } from "react";
1
+ import { useCallback, useRef } from "react";
2
+ import { Icon } from "../icon/Icon";
2
3
  import "./select.css";
3
4
  import { SelectOptionInterface } from "./selectOption.interface";
4
5
 
@@ -49,12 +50,23 @@ export const Select = ({
49
50
  }
50
51
  }
51
52
  };
52
-
53
+ const resetValue = useCallback(() => {
54
+ if (onChange) {
55
+ onChange("");
56
+ }
57
+ }, [onChange]);
53
58
  return (
54
59
  <div id={id} className={`select-container ${className ? className : ""}`}>
55
- {label && <label className="select-container-label">{label}</label>}
60
+ {label && (
61
+ <label htmlFor={`select-${id}`} className="select-container-label">
62
+ {label}
63
+ </label>
64
+ )}
56
65
  <select
66
+ defaultValue=""
67
+ required
57
68
  disabled={disabled}
69
+ id={`select-${id}`}
58
70
  className="select-container-select"
59
71
  value={value ?? defaultValue ?? (multiple ? [] : "")}
60
72
  onChange={handleChange}
@@ -62,7 +74,9 @@ export const Select = ({
62
74
  ref={(el) => (inputRefs.current[id ?? "select"] = el)}
63
75
  >
64
76
  {placeholder && !defaultValue && !multiple && (
65
- <option value="">{placeholder}</option>
77
+ <option selected disabled hidden value="">
78
+ {placeholder}
79
+ </option>
66
80
  )}
67
81
  {options.map((option, index) => (
68
82
  <option key={index} value={option.value}>
@@ -70,6 +84,15 @@ export const Select = ({
70
84
  </option>
71
85
  ))}
72
86
  </select>
87
+ {value !== "" && placeholder && (
88
+ <div
89
+ className="clear-btn"
90
+ onClick={resetValue}
91
+ aria-label="Réinitialiser"
92
+ >
93
+ <Icon classIcon="bi-x" />
94
+ </div>
95
+ )}
73
96
  </div>
74
97
  );
75
98
  };
@@ -64,7 +64,7 @@ export const SelectView = () => {
64
64
  return (
65
65
  <>
66
66
  {selectData.map((data) => (
67
- <Select {...data} />
67
+ <Select key={data.id} {...data} />
68
68
  ))}
69
69
  </>
70
70
  );
@@ -8,7 +8,23 @@
8
8
  right: 1rem;
9
9
  pointer-events: none;
10
10
  }
11
-
11
+ select:invalid {
12
+ color: gray;
13
+ }
14
+ option {
15
+ color: #000;
16
+ }
17
+ .clear-btn {
18
+ position: absolute;
19
+ top: 2px;
20
+ display: flex;
21
+ align-items: center;
22
+ z-index: 5;
23
+ justify-content: center;
24
+ bottom: 0;
25
+ right: 30px;
26
+ cursor: pointer;
27
+ }
12
28
  &::before {
13
29
  border-left: var(--size) solid transparent;
14
30
  border-right: var(--size) solid transparent;