@cagatayfdn/flora-components 0.0.88 → 0.0.90

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,15 +1,20 @@
1
1
  import { j as e } from "../../jsx-runtime-BcAkpsdy.js";
2
- import { c as o } from "../../index-BHf7G3IG.js";
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
2
+ import { c } from "../../index-BHf7G3IG.js";
3
+ import { useDrawer as l } from "./Provider.js";
4
+ import m from "../Icon/index.js";
5
+ import '../../index.css';const h = "_drawer_1bno3_1", w = "_header_1bno3_10", x = "_body_1bno3_32", r = {
6
+ drawer: h,
7
+ header: w,
8
+ body: x
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 u({ id: s, children: t, title: o, onClose: a }) {
11
+ const { state: i, closeDrawer: n } = l();
12
+ if (!(i[s] || !1))
13
+ return null;
14
+ const d = () => {
15
+ n(s), a && a();
16
+ };
17
+ return /* @__PURE__ */ e.jsxs(e.Fragment, { children: [
13
18
  /* @__PURE__ */ e.jsx(
14
19
  "div",
15
20
  {
@@ -26,15 +31,15 @@ function j({ children: s, title: a }) {
26
31
  }
27
32
  }
28
33
  ),
29
- /* @__PURE__ */ e.jsxs("div", { "data-testid": "drawer", className: o(r.drawer), children: [
34
+ /* @__PURE__ */ e.jsxs("div", { "data-testid": "drawer", className: c(r.drawer), children: [
30
35
  /* @__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" }) })
36
+ /* @__PURE__ */ e.jsx("div", { children: o }),
37
+ /* @__PURE__ */ e.jsx("div", { children: /* @__PURE__ */ e.jsx(m, { onClick: d, name: "close" }) })
33
38
  ] }),
34
- /* @__PURE__ */ e.jsx("div", { "data-testid": "drawer-body", className: r.body, children: s })
39
+ /* @__PURE__ */ e.jsx("div", { "data-testid": "drawer-body", className: r.body, children: t })
35
40
  ] })
36
- ] }) : null;
41
+ ] });
37
42
  }
38
43
  export {
39
- j as default
44
+ u as default
40
45
  };
package/dist/index.d.mts CHANGED
@@ -438,18 +438,23 @@ 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, onClose }: 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
+ onClose?: () => void;
454
+ };
455
+
456
+ declare type DrawerState = {
457
+ [id: string]: boolean;
453
458
  };
454
459
 
455
460
  export declare type DropdownItemType = {
package/dist/index.d.ts CHANGED
@@ -438,18 +438,23 @@ 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, onClose }: 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
+ onClose?: () => void;
454
+ };
455
+
456
+ declare type DrawerState = {
457
+ [id: string]: boolean;
453
458
  };
454
459
 
455
460
  export declare type DropdownItemType = {
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.90",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",