prometeo-design-system 2.0.2 → 2.1.0

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,67 +1,142 @@
1
- import { j as e } from "./jsx-runtime-ByW6EXIE.js";
2
- import { c as d } from "./index-BOQuZ0gG.js";
3
- import { forwardRef as j, useState as D, useRef as x, useCallback as s, useImperativeHandle as b } from "react";
4
- import { Drawer as o } from "vaul";
5
- import { Icons as v } from "./Icons.es.js";
6
- import { c as m } from "./cn-B6yFEsav.js";
7
- const C = d("text-sm cursor-pointer font-medium shadow-sm transition-all absolute z-30", {
8
- variants: {
9
- direction: {
10
- left: "right-4 top-4",
11
- right: "left-4 top-4"
12
- }
13
- }
14
- }), O = d("right-0 top-0 bottom-0 fixed z-50 outline-none w-full md:w-[450px] lg:w-[550px] xl:w-[600px] h-full flex flex-col", {
15
- variants: {
16
- direction: {
17
- left: "left-0",
18
- right: "right-0"
19
- }
20
- }
21
- }), N = j(({ children: t, direction: r, modal: a = !1, className: c, onClose: i, defaultOpen: w = !1 }, h) => {
22
- const [l, n] = D(w), f = x(i);
23
- f.current = i;
24
- const u = s(() => {
1
+ import { j as s } from "./jsx-runtime-ByW6EXIE.js";
2
+ import { c as b } from "./cn-B6yFEsav.js";
3
+ import { c as y, B as h } from "./Button-Bc0LYLfg.js";
4
+ import { createPortal as g } from "react-dom";
5
+ import { Icons as C } from "./Icons.es.js";
6
+ import { forwardRef as k, useState as j, useRef as x, useEffect as v, useCallback as l, useImperativeHandle as D } from "react";
7
+ const O = k((e, a) => {
8
+ const [t, n] = j(e.defaultOpen || !1), o = x(e.onClose), {
9
+ modal: c = !1,
10
+ children: d,
11
+ className: u,
12
+ direction: f = "left",
13
+ attachToParent: i = !1,
14
+ closeOnOverlayClick: p = !1
15
+ } = e;
16
+ v(() => {
17
+ o.current = e.onClose;
18
+ }, [e.onClose]);
19
+ const r = l(() => {
25
20
  n(!0);
26
- }, []), p = s(() => {
27
- n(!1);
28
- }, []), g = s(() => {
29
- n(!1), f.current?.();
21
+ }, []), m = l(() => {
22
+ n(!1), o.current?.();
30
23
  }, []);
31
- return b(h, () => ({
32
- open: u,
33
- close: p,
34
- isOpen: l
35
- }), [u, p, l]), /* @__PURE__ */ e.jsx(o.Root, { direction: r, open: l, onOpenChange: g, modal: a, children: /* @__PURE__ */ e.jsxs(o.Portal, { children: [
36
- /* @__PURE__ */ e.jsx(o.Overlay, { className: "fixed inset-0 bg-black/60 z-50" }),
37
- /* @__PURE__ */ e.jsxs(
38
- o.Content,
24
+ D(a, () => ({
25
+ open: r,
26
+ close: m,
27
+ isOpen: t
28
+ }), [t, r, m]);
29
+ const w = /* @__PURE__ */ s.jsx(
30
+ z,
31
+ {
32
+ isOpen: t,
33
+ close: m,
34
+ direction: f,
35
+ modal: c,
36
+ className: u,
37
+ attachToParent: i,
38
+ closeOnOverlayClick: p,
39
+ children: d
40
+ }
41
+ );
42
+ return i ? w : g(w, document.body);
43
+ });
44
+ O.displayName = "DrawerDesktopV2";
45
+ const z = ({ children: e, direction: a = "left", isOpen: t, close: n, modal: o = !1, className: c, attachToParent: d = !1, closeOnOverlayClick: u = !1 }) => {
46
+ v(() => {
47
+ if (t && o) {
48
+ const r = window.scrollY;
49
+ return document.body.style.position = "fixed", document.body.style.top = `-${r}px`, document.body.style.width = "100%", () => {
50
+ document.body.style.position = "", document.body.style.top = "", document.body.style.width = "", window.scrollTo(0, r);
51
+ };
52
+ }
53
+ }, [t, o]);
54
+ const f = y("border-neutral-strong-default", {
55
+ variants: {
56
+ isOpen: {
57
+ true: "desktop-drawer-visible",
58
+ false: "desktop-drawer-hidden"
59
+ },
60
+ direction: {
61
+ left: "left-0 border-r-[1px] border-l-0",
62
+ right: "right-0 border-l-[1px] border-r-0"
63
+ }
64
+ }
65
+ }), i = y("fixed inset-0 bg-black/60 z-[55] cursor-default", {
66
+ variants: {
67
+ isOpen: {
68
+ true: "drawer-overlay-visible",
69
+ false: "drawer-overlay-hidden"
70
+ }
71
+ }
72
+ }), p = y("", {
73
+ variants: {
74
+ direction: {
75
+ left: "right-0",
76
+ right: "left-0"
77
+ }
78
+ }
79
+ });
80
+ return /* @__PURE__ */ s.jsxs(s.Fragment, { children: [
81
+ o && /* @__PURE__ */ s.jsx(
82
+ "div",
39
83
  {
40
- className: m(O({ direction: r }), c),
41
- style: { "--initial-transform": "calc(100% + 8px)" },
84
+ className: b(i({ isOpen: t })),
85
+ onClick: (r) => {
86
+ r.preventDefault(), r.stopPropagation(), u && n();
87
+ },
88
+ "aria-hidden": "true"
89
+ }
90
+ ),
91
+ /* @__PURE__ */ s.jsxs(
92
+ "div",
93
+ {
94
+ className: b(
95
+ "bg-neutral-strong-default p-4 pt-10 h-full top-0 z-[60] w-max overflow-y-auto",
96
+ d ? "absolute" : "fixed",
97
+ f({ isOpen: t, direction: a }),
98
+ c
99
+ ),
100
+ role: "dialog",
101
+ "aria-modal": o,
42
102
  children: [
43
- /* @__PURE__ */ e.jsx(o.Close, { className: m(C({ direction: r })), children: /* @__PURE__ */ e.jsx(v.Close, { size: 24, className: "text-neutral-default-default" }) }),
44
- /* @__PURE__ */ e.jsx("div", { className: "bg-neutral-default-default w-full flex-1 overflow-y-auto min-h-0 border-l border-neutral-strong-default", children: t })
103
+ /* @__PURE__ */ s.jsx(
104
+ h,
105
+ {
106
+ icon: /* @__PURE__ */ s.jsx(C.Close, { size: 24 }),
107
+ animate: !1,
108
+ type: "button",
109
+ size: "small",
110
+ variant: "text",
111
+ onClick: n,
112
+ label: "",
113
+ color: "secondary",
114
+ className: b(
115
+ "absolute top-0 z-50",
116
+ p({ direction: a })
117
+ ),
118
+ "aria-label": "Close drawer"
119
+ }
120
+ ),
121
+ e
45
122
  ]
46
123
  }
47
124
  )
48
- ] }) });
49
- });
50
- N.displayName = "DrawerDesktop";
51
- const E = () => {
52
- const t = x(null), r = s(() => {
53
- t.current?.open();
54
- }, []), a = s(() => {
55
- t.current?.close();
125
+ ] });
126
+ }, E = () => {
127
+ const e = x(null), a = l(() => {
128
+ e.current?.open();
129
+ }, []), t = l(() => {
130
+ e.current?.close();
56
131
  }, []);
57
132
  return {
58
- isOpen: s(() => t.current?.isOpen ?? !1, []),
59
- open: r,
60
- close: a,
61
- drawerRef: t
133
+ isOpen: l(() => e.current?.isOpen ?? !1, []),
134
+ open: a,
135
+ close: t,
136
+ drawerRef: e
62
137
  };
63
138
  };
64
139
  export {
65
- N as default,
140
+ O as default,
66
141
  E as useDrawerDesktop
67
142
  };
package/dist/Input.es.js CHANGED
@@ -1,10 +1,10 @@
1
1
  import { j as t } from "./jsx-runtime-ByW6EXIE.js";
2
2
  import { Icons as J } from "./Icons.es.js";
3
3
  import { c as e } from "./cn-B6yFEsav.js";
4
- import { memo as ie, useState as v, useRef as K, useCallback as pe, useEffect as L, useLayoutEffect as xe } from "react";
5
- import { useDebounce as me } from "use-debounce";
6
- import ge from "./Spinner.es.js";
7
- const C = {
4
+ import { memo as xe, useState as H, useRef as K, useCallback as me, useEffect as L, useLayoutEffect as ge } from "react";
5
+ import { useDebounce as be } from "use-debounce";
6
+ import he from "./Spinner.es.js";
7
+ const j = {
8
8
  default: {
9
9
  container: "",
10
10
  input: e(
@@ -53,24 +53,24 @@ const C = {
53
53
  "peer-focus:text-success-light"
54
54
  )
55
55
  }
56
- }, he = ({
56
+ }, we = ({
57
57
  label: S,
58
58
  icon: a,
59
59
  iconPosition: g = "left",
60
- onChange: E,
60
+ onChange: P,
61
61
  value: u = "",
62
62
  debounceMs: c = 0,
63
- name: k,
64
- width: h = "100%",
63
+ name: E,
64
+ width: b = "100%",
65
65
  height: o,
66
66
  variant: f = "default",
67
67
  labelVariant: l = "default",
68
68
  size: Q = "medium",
69
- disabled: z = !1,
69
+ disabled: k = !1,
70
70
  type: r = "text",
71
71
  isFetching: d,
72
- errorComponent: P,
73
- helperComponent: R,
72
+ errorComponent: R,
73
+ helperComponent: v,
74
74
  placeholder: U,
75
75
  required: D = !1,
76
76
  onFocus: W,
@@ -79,9 +79,11 @@ const C = {
79
79
  onKeyDown: Y,
80
80
  onKeyUp: Z,
81
81
  className: _,
82
- isActive: i
82
+ isActive: i,
83
+ style: q,
84
+ readOnly: A = !1
83
85
  }) => {
84
- const [b, F] = v(u), [I] = me(b, c), [q, O] = v(i || !1), [B, A] = v(!1), w = K(null), $ = K(null);
86
+ const [h, F] = H(u), [z] = be(h, c), [M, O] = H(i || !1), [I, ee] = H(!1), w = K(null), $ = K(null);
85
87
  let p = Q;
86
88
  o && (p = "customHeight");
87
89
  const x = {
@@ -109,34 +111,34 @@ const C = {
109
111
  label: "text-sm peer-focus:text-sm peer-placeholder-shown:text-xs ",
110
112
  icon: "w-6 h-6 right-3"
111
113
  }
112
- }, T = pe(E, [E]);
114
+ }, T = me(P, []);
113
115
  L(() => {
114
- c > 0 && I !== u && T(I);
115
- }, [I, c, T, u]), L(() => {
116
+ c > 0 && z !== u && T(z);
117
+ }, [z, c, T, u]), L(() => {
116
118
  F(u);
117
119
  }, [u]), L(() => {
118
120
  i && $.current?.focus();
119
121
  }, [i]);
120
- const M = (s) => {
122
+ const te = (s) => {
121
123
  O(!0), W?.(s);
122
- }, ee = (s) => {
124
+ }, re = (s) => {
123
125
  i === void 0 && (O(!1), X?.(s));
124
- }, te = (s) => {
125
- const m = s.target.value, H = s.target.name, n = b;
126
- F(m), n.length > 0 && m.length === 0 && V?.(), (!c || c === 0) && E(m, H);
127
- }, re = () => {
128
- A(!B);
129
- }, N = {};
130
- h && h !== "100%" && (N.width = h), o && (N.height = o);
131
- const se = b.length > 0, G = f === "error" && P, oe = !G && R, le = r === "password", ne = () => l === "static" || i || q || se ? "-top-2 left-2 scale-90" : a ? `top-1/2 -translate-y-1/2 ${g === "left" ? "ml-6" : "mr-6"} scale-100 ` : "top-1/2 -translate-y-1/2 scale-100", ae = () => l === "static" ? o ? "text-sm" : "text-xs" : o ? x.customHeight.label : x[p].label, ue = () => o ? { height: o } : {}, ce = () => l === "default" ? S : U || S || "", fe = () => le ? a ? g === "left" ? "pl-10 pr-10" : "pr-16" : "pr-10" : a ? g === "left" ? "pl-10 pr-3" : "pr-10 pl-3" : "", de = l === "default" && "transition-all duration-200 ease-in-out";
132
- return xe(() => {
126
+ }, se = (s) => {
127
+ const m = s.target.value, N = s.target.name, n = h;
128
+ F(m), n.length > 0 && m.length === 0 && V?.(), (!c || c === 0) && P(m, N);
129
+ }, oe = () => {
130
+ ee(!I);
131
+ }, B = {};
132
+ b && b !== "100%" && (B.width = b), o && (B.height = o);
133
+ const le = h.length > 0, G = f === "error" && R, ne = !G && v, ae = r === "password", ue = () => l === "static" || i || M || le ? "-top-2 left-2 scale-90" : a ? `top-1/2 -translate-y-1/2 ${g === "left" ? "ml-6" : "mr-6"} scale-100 ` : "top-1/2 -translate-y-1/2 scale-100", ce = () => l === "static" ? o ? "text-sm" : "text-xs" : o ? x.customHeight.label : x[p].label, fe = () => o ? { height: o } : {}, de = () => l === "default" ? S : U || S || "", ie = () => ae ? a ? g === "left" ? "pl-10 pr-10" : "pr-16" : "pr-10" : a ? g === "left" ? "pl-10 pr-3" : "pr-10 pl-3" : "", pe = l === "default" && "transition-all duration-200 ease-in-out";
134
+ return ge(() => {
133
135
  if (w.current) {
134
- const m = ((H) => {
135
- let n = H;
136
+ const m = ((N) => {
137
+ let n = N;
136
138
  for (; n && n !== document.body; ) {
137
- const j = window.getComputedStyle(n).backgroundColor;
138
- if (j && j !== "transparent" && j !== "rgba(0, 0, 0, 0)")
139
- return j;
139
+ const C = window.getComputedStyle(n).backgroundColor;
140
+ if (C && C !== "transparent" && C !== "rgba(0, 0, 0, 0)")
141
+ return C;
140
142
  n = n.parentElement;
141
143
  }
142
144
  const y = window.getComputedStyle(document.body).backgroundColor;
@@ -151,84 +153,86 @@ const C = {
151
153
  className: e(
152
154
  "relative",
153
155
  x[p].container,
154
- !h && "w-full",
156
+ !b && "w-full",
155
157
  "bg-inherit",
156
158
  l === "static" && "mt-2",
157
159
  _
158
160
  ),
159
- style: N,
161
+ style: { ...q, ...B },
160
162
  children: [
161
163
  /* @__PURE__ */ t.jsx(
162
164
  "input",
163
165
  {
164
- id: k,
165
- name: k,
166
+ id: E,
167
+ name: E,
166
168
  ref: $,
167
- value: b,
168
- placeholder: ce(),
169
- type: r === "password" && B ? "text" : r,
169
+ value: h,
170
+ placeholder: de(),
171
+ type: r === "password" && I ? "text" : r,
170
172
  className: e(
171
173
  "peer w-full border-1 rounded-lg bg-transparent appearance-none transition-all duration-200 ease-in-out",
172
174
  "focus:outline-none px-3",
173
175
  l === "default" && "placeholder:text-transparent",
174
176
  l === "static" && "placeholder:text-neutral-medium-default placeholder:opacity-50",
175
177
  x[p].input,
176
- C[f].input,
178
+ j[f].input,
177
179
  a && "pr-10",
178
- z && "bg-transparent opacity-60 border-neutral-strong-default text-neutral-medium-disabled",
179
- C[f].container,
180
- fe()
180
+ k && "bg-transparent opacity-60 border-neutral-strong-default text-neutral-medium-disabled",
181
+ j[f].container,
182
+ ie()
181
183
  ),
182
- style: ue(),
183
- onChange: te,
184
- onFocus: M,
185
- onBlur: ee,
186
- disabled: z,
184
+ style: fe(),
185
+ onChange: se,
186
+ onFocus: te,
187
+ onBlur: re,
188
+ disabled: k,
187
189
  required: D,
188
190
  onEmptied: V,
189
191
  onKeyDown: Y,
190
- onKeyUp: Z
192
+ onKeyUp: Z,
193
+ readOnly: A
191
194
  }
192
195
  ),
193
196
  /* @__PURE__ */ t.jsx(
194
197
  "label",
195
198
  {
196
199
  ref: w,
197
- htmlFor: k,
200
+ htmlFor: E,
198
201
  className: e(
199
202
  "absolute left-3 pointer-events-none px-1 z-10",
200
- de,
201
- ae(),
202
- C[f].label,
203
- ne(),
203
+ pe,
204
+ ce(),
205
+ j[f].label,
206
+ ue(),
204
207
  D && "after:content-['*'] after:text-error-default after:ml-1",
205
- z && "text-neutral-medium-disabled prometeo-fonts-label-large"
208
+ k && "text-neutral-medium-disabled prometeo-fonts-label-large"
206
209
  ),
207
210
  children: S
208
211
  }
209
212
  ),
210
213
  (a || r === "password" || d) && /* @__PURE__ */ t.jsx(
211
- "div",
214
+ "button",
212
215
  {
216
+ type: "button",
213
217
  className: e(
214
218
  "absolute top-1/2 -translate-y-1/2 flex items-center justify-center z-10",
215
219
  x[p].icon,
216
- C[f].icon,
220
+ j[f].icon,
217
221
  r === "password" && !d ? "cursor-pointer" : "pointer-events-none",
218
222
  g === "right" ? "right-3" : "left-3"
219
223
  ),
220
- onClick: r === "password" && !d ? re : void 0,
224
+ onClick: r === "password" && !d ? oe : void 0,
221
225
  onMouseDown: (s) => r === "password" && !d && s.preventDefault(),
222
- children: /* @__PURE__ */ t.jsx("div", { children: d && r !== "password" ? /* @__PURE__ */ t.jsx("div", { children: /* @__PURE__ */ t.jsx(ge, { size: 24, color: "#7c86ff", loading: !0, variant: "clip" }) }) : r === "password" ? B ? /* @__PURE__ */ t.jsx(J.EyeVisibility, { size: 24, className: "" }) : /* @__PURE__ */ t.jsx(J.EyeVisibilityOff, { size: 24, className: "" }) : a })
226
+ children: /* @__PURE__ */ t.jsx("div", { children: d && r !== "password" ? /* @__PURE__ */ t.jsx("div", { children: /* @__PURE__ */ t.jsx(he, { size: 24, color: "#7c86ff", loading: !0, variant: "clip" }) }) : r === "password" ? I ? /* @__PURE__ */ t.jsx(J.EyeVisibility, { size: 24, className: "" }) : /* @__PURE__ */ t.jsx(J.EyeVisibilityOff, { size: 24, className: "" }) : a })
223
227
  }
224
228
  )
225
229
  ]
226
230
  }
227
231
  ),
228
- oe && R,
229
- G && P
232
+ ne && v,
233
+ G && R
230
234
  ] });
231
- }, ke = ie(he);
235
+ }, Ie = xe(we);
232
236
  export {
233
- ke as default
237
+ Ie as default
234
238
  };
@@ -25,21 +25,21 @@ interface DatePickerBaseProps {
25
25
  }
26
26
  interface DatePickerSingleProps extends DatePickerBaseProps {
27
27
  mode?: "single";
28
- selected?: Date;
29
- onSelect?: (date: Date | undefined) => void;
28
+ selected: Date | undefined;
29
+ onSelect: (date: Date) => void;
30
30
  }
31
31
  interface DatePickerRangeProps extends DatePickerBaseProps {
32
32
  mode: "range";
33
- selected?: DateRange;
34
- onSelect?: (range: DateRange | undefined) => void;
33
+ selected: DateRange | undefined;
34
+ onSelect: (range: DateRange) => void;
35
35
  min?: number;
36
36
  max?: number;
37
37
  excludeDisabled?: boolean;
38
38
  }
39
39
  interface DatePickerMultipleProps extends DatePickerBaseProps {
40
40
  mode: "multiple";
41
- selected?: Date[];
42
- onSelect?: (dates: Date[] | undefined) => void;
41
+ selected: Date[] | undefined;
42
+ onSelect: (dates: Date[]) => void;
43
43
  min?: number;
44
44
  max?: number;
45
45
  }
@@ -4,12 +4,14 @@ export interface DrawerDesktopHandle {
4
4
  isOpen: boolean;
5
5
  }
6
6
  export interface DrawerDesktopProps {
7
- children: React.ReactNode;
8
- direction: 'left' | 'right';
7
+ children?: React.ReactNode;
8
+ direction?: 'left' | 'right';
9
9
  modal?: boolean;
10
10
  className?: string;
11
11
  onClose?: () => void;
12
12
  defaultOpen?: boolean;
13
+ attachToParent?: boolean;
14
+ closeOnOverlayClick?: boolean;
13
15
  }
14
- declare const DrawerDesktop: import('react').ForwardRefExoticComponent<DrawerDesktopProps & import('react').RefAttributes<DrawerDesktopHandle>>;
15
- export default DrawerDesktop;
16
+ declare const DrawerDesktopV2: import('react').ForwardRefExoticComponent<DrawerDesktopProps & import('react').RefAttributes<DrawerDesktopHandle>>;
17
+ export default DrawerDesktopV2;
@@ -0,0 +1,15 @@
1
+ export interface DrawerDesktopHandle {
2
+ open: () => void;
3
+ close: () => void;
4
+ isOpen: boolean;
5
+ }
6
+ export interface DrawerDesktopProps {
7
+ children: React.ReactNode;
8
+ direction: 'left' | 'right';
9
+ modal?: boolean;
10
+ className?: string;
11
+ onClose?: () => void;
12
+ defaultOpen?: boolean;
13
+ }
14
+ declare const DrawerDesktop: import('react').ForwardRefExoticComponent<DrawerDesktopProps & import('react').RefAttributes<DrawerDesktopHandle>>;
15
+ export default DrawerDesktop;
@@ -29,6 +29,8 @@ export interface InputProps {
29
29
  onKeyDown?: (event: React.KeyboardEvent<HTMLInputElement>) => void;
30
30
  onKeyUp?: (event: React.KeyboardEvent<HTMLInputElement>) => void;
31
31
  isActive?: boolean;
32
+ style?: React.CSSProperties;
33
+ readOnly?: boolean;
32
34
  }
33
- declare const _default: import('react').MemoExoticComponent<({ label, icon, iconPosition, onChange, value, debounceMs, name, width, height, variant, labelVariant, size, disabled, type, isFetching, errorComponent, helperComponent, placeholder, required, onFocus, onBlur, onEmptied, onKeyDown, onKeyUp, className, isActive }: InputProps) => import("react/jsx-runtime").JSX.Element>;
35
+ declare const _default: import('react').MemoExoticComponent<({ label, icon, iconPosition, onChange, value, debounceMs, name, width, height, variant, labelVariant, size, disabled, type, isFetching, errorComponent, helperComponent, placeholder, required, onFocus, onBlur, onEmptied, onKeyDown, onKeyUp, className, isActive, style, readOnly }: InputProps) => import("react/jsx-runtime").JSX.Element>;
34
36
  export default _default;