kelt-ui-kit-react 0.6.0 → 0.6.2

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": "0.6.0",
4
+ "version": "0.6.2",
5
5
  "private": false,
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",
package/public/index.html CHANGED
@@ -1,43 +1,43 @@
1
- <!DOCTYPE html>
2
- <html lang="en">
3
- <head>
4
- <meta charset="utf-8" />
5
- <link rel="icon" href="%PUBLIC_URL%/favicon.ico" />
6
- <meta name="viewport" content="width=device-width, initial-scale=1" />
7
- <meta name="theme-color" content="#000000" />
8
- <meta
9
- name="description"
10
- content="Web site created using create-react-app"
11
- />
12
- <link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" />
13
- <!--
14
- manifest.json provides metadata used when your web app is installed on a
15
- user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/
16
- -->
17
- <link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
18
- <!--
19
- Notice the use of %PUBLIC_URL% in the tags above.
20
- It will be replaced with the URL of the `public` folder during the build.
21
- Only files inside the `public` folder can be referenced from the HTML.
22
-
23
- Unlike "/favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will
24
- work correctly both with client-side routing and a non-root public URL.
25
- Learn how to configure a non-root public URL by running `npm run build`.
26
- -->
27
- <title>React App</title>
28
- </head>
29
- <body>
30
- <noscript>You need to enable JavaScript to run this app.</noscript>
31
- <div id="root"></div>
32
- <!--
33
- This HTML file is a template.
34
- If you open it directly in the browser, you will see an empty page.
35
-
36
- You can add webfonts, meta tags, or analytics to this file.
37
- The build step will place the bundled scripts into the <body> tag.
38
-
39
- To begin the development, run `npm start` or `yarn start`.
40
- To create a production bundle, use `npm run build` or `yarn build`.
41
- -->
42
- </body>
43
- </html>
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="utf-8" />
5
+ <link rel="icon" href="%PUBLIC_URL%/favicon.ico" />
6
+ <meta name="viewport" content="width=device-width, initial-scale=1" />
7
+ <meta name="theme-color" content="#000000" />
8
+ <meta
9
+ name="description"
10
+ content="Web site created using create-react-app"
11
+ />
12
+ <link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" />
13
+ <!--
14
+ manifest.json provides metadata used when your web app is installed on a
15
+ user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/
16
+ -->
17
+ <link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
18
+ <!--
19
+ Notice the use of %PUBLIC_URL% in the tags above.
20
+ It will be replaced with the URL of the `public` folder during the build.
21
+ Only files inside the `public` folder can be referenced from the HTML.
22
+
23
+ Unlike "/favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will
24
+ work correctly both with client-side routing and a non-root public URL.
25
+ Learn how to configure a non-root public URL by running `npm run build`.
26
+ -->
27
+ <title>React App</title>
28
+ </head>
29
+ <body>
30
+ <noscript>You need to enable JavaScript to run this app.</noscript>
31
+ <div id="root"></div>
32
+ <!--
33
+ This HTML file is a template.
34
+ If you open it directly in the browser, you will see an empty page.
35
+
36
+ You can add webfonts, meta tags, or analytics to this file.
37
+ The build step will place the bundled scripts into the <body> tag.
38
+
39
+ To begin the development, run `npm start` or `yarn start`.
40
+ To create a production bundle, use `npm run build` or `yarn build`.
41
+ -->
42
+ </body>
43
+ </html>
@@ -1,25 +1,25 @@
1
- {
2
- "short_name": "React App",
3
- "name": "Create React App Sample",
4
- "icons": [
5
- {
6
- "src": "favicon.ico",
7
- "sizes": "64x64 32x32 24x24 16x16",
8
- "type": "image/x-icon"
9
- },
10
- {
11
- "src": "logo192.png",
12
- "type": "image/png",
13
- "sizes": "192x192"
14
- },
15
- {
16
- "src": "logo512.png",
17
- "type": "image/png",
18
- "sizes": "512x512"
19
- }
20
- ],
21
- "start_url": ".",
22
- "display": "standalone",
23
- "theme_color": "#000000",
24
- "background_color": "#ffffff"
25
- }
1
+ {
2
+ "short_name": "React App",
3
+ "name": "Create React App Sample",
4
+ "icons": [
5
+ {
6
+ "src": "favicon.ico",
7
+ "sizes": "64x64 32x32 24x24 16x16",
8
+ "type": "image/x-icon"
9
+ },
10
+ {
11
+ "src": "logo192.png",
12
+ "type": "image/png",
13
+ "sizes": "192x192"
14
+ },
15
+ {
16
+ "src": "logo512.png",
17
+ "type": "image/png",
18
+ "sizes": "512x512"
19
+ }
20
+ ],
21
+ "start_url": ".",
22
+ "display": "standalone",
23
+ "theme_color": "#000000",
24
+ "background_color": "#ffffff"
25
+ }
package/public/robots.txt CHANGED
@@ -1,3 +1,3 @@
1
- # https://www.robotstxt.org/robotstxt.html
2
- User-agent: *
3
- Disallow:
1
+ # https://www.robotstxt.org/robotstxt.html
2
+ User-agent: *
3
+ Disallow:
package/src/App.css CHANGED
@@ -1,11 +1,11 @@
1
- .main-layout {
2
- display: flex;
3
- height: 100vh;
4
- width: 100%;
5
- flex-direction: column;
6
- container: app-container/ inline-size;
7
- & .main-layout-content {
8
- flex: 1;
9
- padding: 2rem;
10
- }
11
- }
1
+ .main-layout {
2
+ display: flex;
3
+ height: 100vh;
4
+ width: 100%;
5
+ flex-direction: column;
6
+ container: app-container/ inline-size;
7
+ & .main-layout-content {
8
+ flex: 1;
9
+ padding: 2rem;
10
+ }
11
+ }
@@ -12,10 +12,12 @@ export const Button = ({
12
12
  disabled = false,
13
13
  }: ButtonInterface) => {
14
14
  const handleClick = (e: React.MouseEvent) => {
15
+ e.stopPropagation();
15
16
  if (onClick) {
16
17
  onClick(e);
17
18
  }
18
19
  };
20
+
19
21
  return (
20
22
  <button
21
23
  disabled={disabled}
@@ -1,5 +1,10 @@
1
+ import { useMemo } from "react";
1
2
  import { Button } from "./Button";
2
3
  import { ButtonInterface } from "./button.interface";
4
+ import {
5
+ ButtonActions,
6
+ ButtonActionsProps,
7
+ } from "./buttonActions/ButtonActions";
3
8
 
4
9
  export const ButtonView = (): JSX.Element => {
5
10
  const mockButtonItems: ButtonInterface[] = [
@@ -15,14 +20,33 @@ export const ButtonView = (): JSX.Element => {
15
20
  className: "button--secondary",
16
21
  },
17
22
  ];
18
-
23
+ const mockButtonAction: ButtonActionsProps = useMemo(() => {
24
+ return {
25
+ title: "Supprimer",
26
+ onClick: () => console.log("Supprimer"),
27
+ className: "button--secondary",
28
+ actions: [
29
+ {
30
+ id: "1",
31
+ label: "Supprimer",
32
+ onClick: () => console.log("Supprimer action"),
33
+ },
34
+ {
35
+ id: "2",
36
+ label: "Supprimer définitivement",
37
+ onClick: () => console.log("Supprimer définitivement"),
38
+ },
39
+ ],
40
+ };
41
+ }, []);
19
42
  return (
20
43
  <div className="d-flex">
21
- {mockButtonItems.map((item) => (
22
- <div className="mr-2">
44
+ {mockButtonItems.map((item, index) => (
45
+ <div className="mr-2" key={index}>
23
46
  <Button {...item} />
24
47
  </div>
25
48
  ))}
49
+ <ButtonActions {...mockButtonAction} />
26
50
  </div>
27
51
  );
28
52
  };
@@ -14,6 +14,7 @@ button {
14
14
  align-items: center;
15
15
  justify-content: center;
16
16
  font-family: "Raleway", sans-serif !important;
17
+
17
18
  &:disabled {
18
19
  opacity: 0.5;
19
20
  cursor: not-allowed;
@@ -28,6 +29,7 @@ button {
28
29
  &.button--transparent {
29
30
  background-color: transparent;
30
31
  color: var(--primary-color);
32
+ border: 1px solid;
31
33
  }
32
34
  &.button--success {
33
35
  background-color: var(--success-color);
@@ -9,3 +9,9 @@ export interface ButtonInterface {
9
9
  disabled?: boolean;
10
10
  sizeIcon?: IconSizeEnum;
11
11
  }
12
+ export interface buttonActionInterface {
13
+ icon?: string;
14
+ id?: number | string;
15
+ label: string;
16
+ onClick: (a: buttonActionInterface) => void;
17
+ }
@@ -0,0 +1,101 @@
1
+ import { useCallback, useMemo, useRef, useState } from "react";
2
+ import { Icon } from "../../icon/Icon";
3
+ import { IconSizeEnum } from "../../icon/iconSize.enum";
4
+ import { MenuInterface } from "../../menus/menu/menu.interface";
5
+ import { Menus } from "../../menus/Menus";
6
+ import { OverlayPanel, PositionOverlay } from "../../overlayPanel/OverlayPanel";
7
+ import { Button } from "../Button";
8
+ import { buttonActionInterface } from "../button.interface";
9
+
10
+ export type ButtonActionsProps = {
11
+ className?: string;
12
+ onClick?: (e: React.MouseEvent) => void;
13
+ title: string;
14
+ actions?: buttonActionInterface[];
15
+ classIcon?: string;
16
+ positionActions?: PositionOverlay;
17
+ disabled?: boolean;
18
+ };
19
+ export const ButtonActions = ({
20
+ className,
21
+ onClick,
22
+ title,
23
+ actions,
24
+ positionActions = "topRight",
25
+ disabled = false,
26
+ }: ButtonActionsProps) => {
27
+ const handleClick = (e: React.MouseEvent) => {
28
+ e.preventDefault();
29
+ if (onClick) {
30
+ onClick(e);
31
+ }
32
+ };
33
+ const refButton = useRef<HTMLDivElement>(null);
34
+ const [openOverlay, setOpenOverlay] = useState(false);
35
+ const onClickActions = useCallback(
36
+ (e: React.MouseEvent) => {
37
+ e.stopPropagation();
38
+ if (actions) setOpenOverlay(!openOverlay);
39
+ },
40
+ [openOverlay, setOpenOverlay]
41
+ );
42
+ const overlayMenu: MenuInterface[] = useMemo(() => {
43
+ if (!actions) return [];
44
+ return actions.map((a, index) => {
45
+ return {
46
+ id: a.id ?? index,
47
+ icon: a.icon,
48
+ name: a.label,
49
+ children: (
50
+ <Button
51
+ key={index}
52
+ classIcon={a.icon}
53
+ sizeIcon={IconSizeEnum.LARGE}
54
+ onClick={(e) => {
55
+ e.stopPropagation();
56
+ closeOverlay();
57
+ a.onClick && a.onClick(a);
58
+ }}
59
+ title={a.label || ""}
60
+ />
61
+ ),
62
+ };
63
+ }) as MenuInterface[];
64
+ }, [actions]);
65
+ const closeOverlay = useCallback(() => {
66
+ setOpenOverlay(false);
67
+ }, [setOpenOverlay]);
68
+ return (
69
+ <>
70
+ <button
71
+ disabled={disabled}
72
+ type="submit"
73
+ onClick={(e) => handleClick(e)}
74
+ className={` ${className} button-actions`}
75
+ >
76
+ <span className="mr-2 flex-1">{title}</span>
77
+
78
+ <span
79
+ className="ml-2"
80
+ ref={refButton}
81
+ onClick={(e) => onClickActions(e)}
82
+ >
83
+ <Icon classIcon="bi-chevron-up" />
84
+ </span>
85
+ </button>
86
+ {actions && openOverlay && refButton.current && (
87
+ <OverlayPanel
88
+ show={openOverlay}
89
+ position={positionActions}
90
+ closeOverlay={setOpenOverlay}
91
+ referenceElement={refButton.current}
92
+ children={
93
+ <div>
94
+ <Menus className="card-action-menu" items={overlayMenu} />
95
+ </div>
96
+ }
97
+ />
98
+ )}
99
+ </>
100
+ );
101
+ };
package/src/card/Card.tsx CHANGED
@@ -37,6 +37,7 @@ export const Card = ({
37
37
  (e: React.MouseEvent, item: CardInterface) => {
38
38
  e.stopPropagation();
39
39
  if (openActions) {
40
+ setPositions(undefined);
40
41
  return setOpenActions(false);
41
42
  }
42
43
  if (
@@ -80,7 +81,7 @@ export const Card = ({
80
81
  <div className="card-text d-flex">
81
82
  {item.image && (
82
83
  <div className="card-img">
83
- <img src={item.image} alt={item.title} />
84
+ <img src={item.image} alt={"card-image"} />
84
85
  </div>
85
86
  )}
86
87
  {item.title && <div className="card-title">{item.title}</div>}
@@ -1,8 +1,8 @@
1
1
  export interface CardInterface {
2
2
  id?: number | string;
3
3
  uuid?: string;
4
- title: string;
5
- description?: string;
4
+ title: string | JSX.Element;
5
+ description?: string | JSX.Element;
6
6
  image?: string;
7
7
  prix?: string | JSX.Element;
8
8
  quantity?: number;
@@ -43,6 +43,7 @@ export const CardAction = ({
43
43
 
44
44
  const handleChangeOverlay = useCallback(
45
45
  (e: any, openOverlay: boolean) => {
46
+ if (actions.length === 0) return;
46
47
  e.preventDefault();
47
48
  console.log("je set la position");
48
49
  setPosition("bottomRight");
@@ -73,6 +74,7 @@ export const CardAction = ({
73
74
  children: (
74
75
  <Button
75
76
  classIcon={a.icon}
77
+ key={index}
76
78
  sizeIcon={IconSizeEnum.LARGE}
77
79
  onClick={(e) => {
78
80
  e.stopPropagation();
@@ -87,24 +89,23 @@ export const CardAction = ({
87
89
  }, [actions]);
88
90
  return (
89
91
  <div className="card-actions">
90
- {actions.filter((a) => a.type === "menu").length ? (
91
- <div
92
- ref={refButton}
93
- className="card-action"
94
- onClick={(e) => handleChangeOverlay(e, !openOverlay)}
95
- >
96
- <Icon
97
- size={IconSizeEnum.MEDIUM}
98
- classIcon={"bi-three-dots-vertical cursor-pointer"}
99
- />
100
- <Icon
101
- size={IconSizeEnum.MEDIUM}
102
- classIcon={"bi-three-dots cursor-pointer"}
103
- />
104
- </div>
105
- ) : (
106
- ""
107
- )}
92
+ <div
93
+ ref={refButton}
94
+ className={`card-action ${
95
+ actions.filter((a) => a.type === "menu").length ? "visible" : "hidden"
96
+ }`}
97
+ onClick={(e) => handleChangeOverlay(e, !openOverlay)}
98
+ >
99
+ <Icon
100
+ size={IconSizeEnum.MEDIUM}
101
+ classIcon={"bi-three-dots-vertical cursor-pointer"}
102
+ />
103
+ <Icon
104
+ size={IconSizeEnum.MEDIUM}
105
+ classIcon={"bi-three-dots cursor-pointer"}
106
+ />
107
+ </div>
108
+
108
109
  {openOverlay && refButton.current && (
109
110
  <OverlayPanel
110
111
  position={position}
package/src/form/Form.tsx CHANGED
@@ -67,15 +67,12 @@ export const DynamicForm = forwardRef(
67
67
  [onChange]
68
68
  );
69
69
 
70
- const handleSubmit = useCallback(
71
- (event: React.FormEvent<HTMLFormElement>) => {
72
- event.preventDefault();
73
- if (onSubmit) {
74
- onSubmit(values);
75
- }
76
- },
77
- [onSubmit, values]
78
- );
70
+ const handleSubmit = useCallback(() => {
71
+ console.log("je passeee");
72
+ if (onSubmit) {
73
+ onSubmit(values);
74
+ }
75
+ }, [onSubmit, values]);
79
76
 
80
77
  const resetForm = () => {
81
78
  setValues(() => {
@@ -100,7 +97,7 @@ export const DynamicForm = forwardRef(
100
97
  const focusedField = initialForm.find((field) => field.focus);
101
98
  if (focusedField && inputRefs.current[focusedField.name]) {
102
99
  setTimeout(() => {
103
- inputRefs.current[focusedField.name]?.focus();
100
+ inputRefs.current[focusedField.name]?.select();
104
101
  }, 500);
105
102
  }
106
103
  };
package/src/index.css CHANGED
@@ -33,6 +33,9 @@ body {
33
33
  .d-flex {
34
34
  display: flex;
35
35
  }
36
+ .justify-content-start {
37
+ justify-content: start;
38
+ }
36
39
  .justify-content-end {
37
40
  justify-content: end;
38
41
  }
@@ -387,6 +390,12 @@ a {
387
390
  }
388
391
 
389
392
  /* class generique*/
393
+ .visible {
394
+ visibility: visible;
395
+ }
396
+ .hidden {
397
+ visibility: hidden;
398
+ }
390
399
  .position-relative {
391
400
  position: relative;
392
401
  }
package/src/index.ts CHANGED
@@ -2,6 +2,7 @@ import "bootstrap-icons/font/bootstrap-icons.css";
2
2
  import "./index.css";
3
3
  export { ButtonAction } from "./action/ButtonAction";
4
4
  export { Button } from "./button/Button";
5
+ export { ButtonActions } from "./button/buttonActions/ButtonActions";
5
6
  export { Card } from "./card/Card";
6
7
  export { Carousel } from "./carousel/Carousel";
7
8
  export { Damier } from "./damier/Damier";
@@ -1,19 +1,37 @@
1
+ import { createPortal } from "react-dom";
1
2
  import { IconSizeEnum } from "../icon/iconSize.enum";
2
3
  import "./loader.css";
3
4
  export type LoaderProps = {
4
5
  display: boolean;
5
6
  message?: string;
6
7
  size?: IconSizeEnum;
8
+ full?: true;
7
9
  };
8
- export const Loader = ({ display, message }: LoaderProps) => (
10
+ export const Loader = ({ display, full, message }: LoaderProps) => (
9
11
  <>
10
- {display && (
11
- <div className="d-flex flex-column align-items-center">
12
+ {display && !full && (
13
+ <div className={`d-flex flex-column align-items-center`}>
12
14
  {message && <span className="mb-3">{message}</span>}
13
15
  <div className="position-relative">
14
16
  <span className="loader"></span>
15
17
  </div>
16
18
  </div>
17
19
  )}
20
+
21
+ {display &&
22
+ full &&
23
+ createPortal(
24
+ <div className="loader-overlay">
25
+ <div>
26
+ <div className={`d-flex flex-column align-items-center`}>
27
+ {message && <span className="mb-3">{message}</span>}
28
+ <div className="position-relative">
29
+ <span className="loader"></span>
30
+ </div>
31
+ </div>
32
+ </div>
33
+ </div>,
34
+ document.body
35
+ )}
18
36
  </>
19
37
  );
@@ -1,12 +1,20 @@
1
+ import { useState } from "react";
2
+ import { Button } from "../button/Button";
1
3
  import { IconSizeEnum } from "../icon/iconSize.enum";
2
4
  import { Loader } from "./Loader";
3
5
 
4
6
  export const LoaderView = () => {
7
+ const [display, setDisplay] = useState(false);
8
+
5
9
  return (
6
- <Loader
7
- size={IconSizeEnum.EXTRA_LARGE}
8
- display={true}
9
- message={"Loading..."}
10
- />
10
+ <>
11
+ <Button title={"loader-overlay"} onClick={() => setDisplay(!display)} />
12
+ <Loader
13
+ size={IconSizeEnum.EXTRA_LARGE}
14
+ display={!display}
15
+ message={"Loading..."}
16
+ />
17
+ <Loader display={display} message={"Loading..."} full={true} />
18
+ </>
11
19
  );
12
20
  };
@@ -8,6 +8,18 @@
8
8
  -webkit-animation: rotation 1s linear infinite;
9
9
  animation: rotation 1s linear infinite;
10
10
  }
11
+ .loader-overlay {
12
+ position: fixed;
13
+ top: 0;
14
+ left: 0;
15
+ right: 0;
16
+ bottom: 0;
17
+ background-color: rgba(0, 0, 0, 0.5);
18
+ display: flex;
19
+ justify-content: center;
20
+ align-items: center;
21
+ z-index: 1000;
22
+ }
11
23
  @keyframes rotation {
12
24
  0% {
13
25
  transform: rotate(0deg);
@@ -10,7 +10,7 @@
10
10
  display: flex;
11
11
  justify-content: center;
12
12
  align-items: center;
13
- z-index: 1000;
13
+ z-index: 2;
14
14
  }
15
15
 
16
16
  .modal-container {
@@ -172,7 +172,11 @@ export const OverlayPanel = forwardRef(
172
172
 
173
173
  return ReactDOM.createPortal(
174
174
  <OverlayPanelStyled ref={boxRef} $top={coords.top} $left={coords.left}>
175
- <div className="overlayPanel">
175
+ <div
176
+ className={`overlayPanel ${
177
+ coords.top > 0 && coords.left > 0 ? "visible" : "hide"
178
+ }`}
179
+ >
176
180
  <button className="toggle-btn" onClick={closeOverlayHandler}>
177
181
  <Icon classIcon="bi-x-lg" />
178
182
  </button>
@@ -1,5 +1,12 @@
1
1
  .overlayPanel {
2
2
  position: relative;
3
+
4
+ &.hide {
5
+ visibility: hidden;
6
+ }
7
+ &.visible {
8
+ visibility: visible !important;
9
+ }
3
10
  button {
4
11
  span {
5
12
  text-align: left;
@@ -7,6 +7,7 @@ interface OverlayPanelStyledProps {
7
7
 
8
8
  export const OverlayPanelStyled = styled.div<OverlayPanelStyledProps>`
9
9
  position: absolute;
10
+ z-index: 5;
10
11
  top: ${({ $top }) => $top}px;
11
12
  left: ${({ $left }) => $left}px;
12
13
  background-color: white;