@cagatayfdn/flora-components 0.0.88 → 0.0.89

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.
@@ -1,10 +1,24 @@
1
- import { j as p } from "../../jsx-runtime-BcAkpsdy.js";
2
- import { createContext as i, useState as u, useContext as x } from "react";
3
- const r = i({ isOpen: !1 }), D = ({ children: t }) => {
4
- const [s, e] = u(!1), o = () => e(!0), n = () => e(!1), a = () => e((c) => !c);
5
- return /* @__PURE__ */ p.jsx(r.Provider, { value: { isOpen: s, openDrawer: o, closeDrawer: n, toggleDrawer: a }, children: t });
6
- }, f = () => x(r);
1
+ import { j as a } from "../../jsx-runtime-BcAkpsdy.js";
2
+ import { createContext as c, useReducer as i, useContext as d } from "react";
3
+ const w = {}, D = (e, r) => {
4
+ switch (r.type) {
5
+ case "OPEN_DRAWER":
6
+ return { ...e, [r.id]: !0 };
7
+ case "CLOSE_DRAWER":
8
+ return { ...e, [r.id]: !1 };
9
+ default:
10
+ return e;
11
+ }
12
+ }, s = c(void 0), p = ({ children: e }) => {
13
+ const [r, o] = i(D, w), n = (t) => o({ type: "OPEN_DRAWER", id: t }), u = (t) => o({ type: "CLOSE_DRAWER", id: t });
14
+ return /* @__PURE__ */ a.jsx(s.Provider, { value: { state: r, openDrawer: n, closeDrawer: u }, children: e });
15
+ }, x = () => {
16
+ const e = d(s);
17
+ if (!e)
18
+ throw new Error("useDrawer must be used within a DrawerProvider");
19
+ return e;
20
+ };
7
21
  export {
8
- D as DrawerProvider,
9
- f as useDrawer
22
+ p as DrawerProvider,
23
+ x as useDrawer
10
24
  };
@@ -1,20 +1,20 @@
1
1
  import { j as e } from "../../jsx-runtime-BcAkpsdy.js";
2
- import { c as o } from "../../index-BHf7G3IG.js";
2
+ import { c as n } from "../../index-BHf7G3IG.js";
3
3
  import { useDrawer as i } from "./Provider.js";
4
- import n from "../Icon/index.js";
5
- import '../../index.css';const c = "_drawer_1bno3_1", l = "_header_1bno3_10", m = "_body_1bno3_32", r = {
6
- drawer: c,
7
- header: l,
8
- body: m
4
+ import c from "../Icon/index.js";
5
+ import '../../index.css';const l = "_drawer_1bno3_1", m = "_header_1bno3_10", h = "_body_1bno3_32", s = {
6
+ drawer: l,
7
+ header: m,
8
+ body: h
9
9
  };
10
- function j({ children: s, title: a }) {
11
- const { isOpen: t, closeDrawer: d } = i();
12
- return t ? /* @__PURE__ */ e.jsxs(e.Fragment, { children: [
10
+ function p({ id: r, children: d, title: t }) {
11
+ const { state: o, closeDrawer: a } = i();
12
+ return o[r] || !1 ? /* @__PURE__ */ e.jsxs(e.Fragment, { children: [
13
13
  /* @__PURE__ */ e.jsx(
14
14
  "div",
15
15
  {
16
16
  "data-testid": "drawer-overlay",
17
- onClick: d,
17
+ onClick: () => a(r),
18
18
  style: {
19
19
  position: "fixed",
20
20
  top: 0,
@@ -26,15 +26,15 @@ function j({ children: s, title: a }) {
26
26
  }
27
27
  }
28
28
  ),
29
- /* @__PURE__ */ e.jsxs("div", { "data-testid": "drawer", className: o(r.drawer), children: [
30
- /* @__PURE__ */ e.jsxs("div", { "data-testid": "drawer-header", className: r.header, children: [
31
- /* @__PURE__ */ e.jsx("div", { children: a }),
32
- /* @__PURE__ */ e.jsx("div", { children: /* @__PURE__ */ e.jsx(n, { onClick: d, name: "close" }) })
29
+ /* @__PURE__ */ e.jsxs("div", { "data-testid": "drawer", className: n(s.drawer), children: [
30
+ /* @__PURE__ */ e.jsxs("div", { "data-testid": "drawer-header", className: s.header, children: [
31
+ /* @__PURE__ */ e.jsx("div", { children: t }),
32
+ /* @__PURE__ */ e.jsx("div", { children: /* @__PURE__ */ e.jsx(c, { onClick: () => a(r), name: "close" }) })
33
33
  ] }),
34
- /* @__PURE__ */ e.jsx("div", { "data-testid": "drawer-body", className: r.body, children: s })
34
+ /* @__PURE__ */ e.jsx("div", { "data-testid": "drawer-body", className: s.body, children: d })
35
35
  ] })
36
36
  ] }) : null;
37
37
  }
38
38
  export {
39
- j as default
39
+ p as default
40
40
  };
package/dist/index.d.mts CHANGED
@@ -438,20 +438,24 @@ export declare type DividerProps = {
438
438
  margin?: string;
439
439
  };
440
440
 
441
- export declare function Drawer({ children, title }: DrawerProps): JSX_2.Element | null;
441
+ export declare function Drawer({ id, children, title }: DrawerProps): JSX_2.Element | null;
442
442
 
443
443
  export declare type DrawerContextType = {
444
- isOpen: boolean;
445
- openDrawer: () => void;
446
- closeDrawer: () => void;
447
- toggleDrawer: () => void;
444
+ state: DrawerState;
445
+ openDrawer: (id: string) => void;
446
+ closeDrawer: (id: string) => void;
448
447
  };
449
448
 
450
449
  export declare type DrawerProps = {
450
+ id: string;
451
451
  children: React.ReactNode;
452
452
  title: string;
453
453
  };
454
454
 
455
+ declare type DrawerState = {
456
+ [id: string]: boolean;
457
+ };
458
+
455
459
  export declare type DropdownItemType = {
456
460
  text: string;
457
461
  to?: string;
package/dist/index.d.ts CHANGED
@@ -438,20 +438,24 @@ export declare type DividerProps = {
438
438
  margin?: string;
439
439
  };
440
440
 
441
- export declare function Drawer({ children, title }: DrawerProps): JSX_2.Element | null;
441
+ export declare function Drawer({ id, children, title }: DrawerProps): JSX_2.Element | null;
442
442
 
443
443
  export declare type DrawerContextType = {
444
- isOpen: boolean;
445
- openDrawer: () => void;
446
- closeDrawer: () => void;
447
- toggleDrawer: () => void;
444
+ state: DrawerState;
445
+ openDrawer: (id: string) => void;
446
+ closeDrawer: (id: string) => void;
448
447
  };
449
448
 
450
449
  export declare type DrawerProps = {
450
+ id: string;
451
451
  children: React.ReactNode;
452
452
  title: string;
453
453
  };
454
454
 
455
+ declare type DrawerState = {
456
+ [id: string]: boolean;
457
+ };
458
+
455
459
  export declare type DropdownItemType = {
456
460
  text: string;
457
461
  to?: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cagatayfdn/flora-components",
3
- "version": "0.0.88",
3
+ "version": "0.0.89",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",