prometeo-design-system 2.6.2 → 2.6.4

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/dist/Select.es.js CHANGED
@@ -1,4 +1,4 @@
1
- import { S as f } from "./Select-IAQKEfnq.js";
1
+ import { S as f } from "./Select-CSFKGhU7.js";
2
2
  export {
3
3
  f as default
4
4
  };
@@ -1,6 +1,6 @@
1
1
  import { j as d } from "./jsx-runtime-ByW6EXIE.js";
2
2
  import { useField as y } from "formik";
3
- import { S as m } from "./Select-IAQKEfnq.js";
3
+ import { S as m } from "./Select-CSFKGhU7.js";
4
4
  import { useRef as p, useEffect as g } from "react";
5
5
  function f(e) {
6
6
  return Array.isArray(e) && e.every(
@@ -1,9 +1,9 @@
1
1
  import { j as G } from "./jsx-runtime-ByW6EXIE.js";
2
- import { g as i, S as H } from "./Select-IAQKEfnq.js";
3
- import { useState as w, useRef as T, useEffect as m, useMemo as Q, useCallback as X } from "react";
2
+ import { g as i, S as H } from "./Select-CSFKGhU7.js";
3
+ import { useState as w, useRef as T, useEffect as h, useMemo as Q, useCallback as X } from "react";
4
4
  function te(e) {
5
5
  const {
6
- options: L,
6
+ options: p,
7
7
  fetcher: s,
8
8
  asyncMode: V = "fetch_in_open",
9
9
  disabled: x = !1,
@@ -11,32 +11,32 @@ function te(e) {
11
11
  minCharacters: S = 3,
12
12
  optionLabel: f,
13
13
  optionValue: u,
14
- controlledValue: h,
14
+ controlledValue: m,
15
15
  isOpen: F,
16
16
  inputRef: R,
17
- name: p
18
- } = e || {}, [O, j] = w(L || []), [J, y] = w(L || []), [a, k] = w(""), [M, r] = w(!1), [C, b] = w(!1), g = T(null), D = T(null), N = T(!1), E = T(s), P = e?.multiple === !0 || !1, _ = T(P ? [] : void 0), [d, A] = w(P ? [] : void 0);
19
- m(() => {
17
+ name: O
18
+ } = e || {}, [y, j] = w(p || []), [J, C] = w(p || []), [a, k] = w(""), [M, r] = w(!1), [v, b] = w(!1), g = T(null), D = T(null), N = T(!1), E = T(s), P = e?.multiple === !0 || !1, _ = T(P ? [] : void 0), [d, A] = w(P ? [] : void 0);
19
+ h(() => {
20
20
  E.current = s;
21
- }, [s]), m(() => {
22
- h !== void 0 && A(h);
23
- }, [h]), m(() => {
24
- _.current = h !== void 0 ? h : d;
25
- }, [h, d]), m(() => {
26
- e?.options && (j(e.options), y(e.options));
21
+ }, [s]), h(() => {
22
+ m !== void 0 && A(m);
23
+ }, [m]), h(() => {
24
+ _.current = m !== void 0 ? m : d;
25
+ }, [m, d]), h(() => {
26
+ e?.options && (j(e.options), C(e.options));
27
27
  }, [e?.options]);
28
28
  const U = Q(() => (t, n) => new Promise((o, l) => {
29
29
  g.current && clearTimeout(g.current), g.current = setTimeout(() => t(a).then(o).catch(l), n);
30
30
  }), [a]), Y = (t) => {
31
- const n = h !== void 0, o = (l) => u ? i(l, u) : i(l, "id");
31
+ const n = m !== void 0, o = (l) => u ? i(l, u) : i(l, "id");
32
32
  if (e?.multiple === !0) {
33
33
  const l = _.current || [];
34
34
  let c;
35
- l.some((v) => o(v) === o(t)) ? c = l.filter((v) => o(v) !== o(t)) : c = [...l, t], n ? (_.current = c, e?.onChange?.(c, p)) : (_.current = c, A(c), e?.onChange?.(c, p));
35
+ l.some((L) => o(L) === o(t)) ? c = l.filter((L) => o(L) !== o(t)) : c = [...l, t], n ? (_.current = c, e?.onChange?.(c, O)) : (_.current = c, A(c), e?.onChange?.(c, O));
36
36
  } else
37
- n ? (_.current = t, e?.onChange?.(t, p)) : (_.current = t, A(t), e?.onChange?.(t, p));
37
+ n ? (_.current = t, e?.onChange?.(t, O)) : (_.current = t, A(t), e?.onChange?.(t, O));
38
38
  }, W = (t) => (e?.onFetchingStart?.(), E.current?.(t) || Promise.resolve([])), K = X((t, n) => t.length === 0 ? n : u ? n.filter((o) => !t.some((l) => i(l, u) === i(o, u))) : n.filter((o) => !t.some((l) => i(l, "id") === i(o, "id"))), [u]);
39
- m(() => {
39
+ h(() => {
40
40
  const t = e?.subscribeOpenChange;
41
41
  if (!t) return;
42
42
  const n = t((o) => {
@@ -46,8 +46,8 @@ function te(e) {
46
46
  n && n();
47
47
  };
48
48
  }, [e?.subscribeOpenChange]);
49
- const B = F !== void 0 ? F : C;
50
- m(() => {
49
+ const B = F !== void 0 ? F : v;
50
+ h(() => {
51
51
  if (!x && E.current && V === "fetch_on_type") {
52
52
  if (!a || a === "" || a.length < S) {
53
53
  g.current && clearTimeout(g.current), r(!1);
@@ -60,7 +60,7 @@ function te(e) {
60
60
  r(!1), e?.onFetchingEnd?.();
61
61
  });
62
62
  }
63
- }, [V, a, x, I, U, S]), m(() => {
63
+ }, [V, a, x, I, U, S]), h(() => {
64
64
  if (B) {
65
65
  if (e?.onOpen?.(), V === "fetch_in_open") {
66
66
  if (!E.current)
@@ -91,7 +91,7 @@ function te(e) {
91
91
  if (f)
92
92
  return i(n, f) < i(o, f) ? -1 : 1;
93
93
  {
94
- const c = ["label", "name", "value"].find((v) => typeof n == "object" && Object.keys(n).includes(v));
94
+ const c = ["label", "name", "value"].find((L) => typeof n == "object" && Object.keys(n).includes(L));
95
95
  switch (typeof n) {
96
96
  case "string":
97
97
  return n < o ? -1 : 1;
@@ -99,8 +99,8 @@ function te(e) {
99
99
  return n < o ? -1 : 1;
100
100
  case "object":
101
101
  if (c) {
102
- const v = i(n, c), ee = i(o, c);
103
- return v < ee ? -1 : 1;
102
+ const L = i(n, c), ee = i(o, c);
103
+ return L < ee ? -1 : 1;
104
104
  } else
105
105
  return 1;
106
106
  default:
@@ -113,17 +113,17 @@ function te(e) {
113
113
  N.current = !1;
114
114
  }, I));
115
115
  };
116
- return m(() => {
116
+ return h(() => {
117
117
  if (a === "")
118
- y(Z(O));
118
+ C(Z(y));
119
119
  else if (P) {
120
- const t = K(d, O);
121
- y([...q(t, a), ...d]);
120
+ const t = K(d, y);
121
+ C([...q(t, a), ...d]);
122
122
  } else {
123
- const t = K([d], O);
124
- y([...q(t, a), d]);
123
+ const t = K([d], y);
124
+ C([...q(t, a), d]);
125
125
  }
126
- }, [O]), m(() => (document.addEventListener("keydown", z), () => {
126
+ }, [y]), h(() => (document.addEventListener("keydown", z), () => {
127
127
  document.removeEventListener("keydown", z);
128
128
  }), []), {
129
129
  inputValue: a,
@@ -139,18 +139,22 @@ function te(e) {
139
139
  };
140
140
  }
141
141
  const ie = (e) => {
142
- const L = T(null), { asyncMode: s = "fetch_in_open" } = e, V = (r, C, b) => {
142
+ const p = T(null);
143
+ h(() => {
144
+ e.controls && (e.controls.current = p.current);
145
+ }, [e.controls]);
146
+ const { asyncMode: s = "fetch_in_open" } = e, V = (r, v, b) => {
143
147
  const g = {
144
148
  options: r.options,
145
149
  fetcher: r.fetcher,
146
- asyncMode: C,
150
+ asyncMode: v,
147
151
  debounceDelay: r.debounceDelay,
148
152
  minCharacters: r.minCharacters,
149
153
  disabled: r.disabled,
150
154
  optionValue: r.optionValue,
151
155
  optionLabel: r.optionLabel,
152
156
  onFetchingStart: () => {
153
- C === "fetch_on_type" && b.current?.open();
157
+ v === "fetch_on_type" && b.current?.open();
154
158
  },
155
159
  onTypeStart: () => {
156
160
  !r?.fetcher && b.current?.open();
@@ -170,10 +174,10 @@ const ie = (e) => {
170
174
  controlledValue: r.value,
171
175
  onChange: r.onChange
172
176
  };
173
- }, { inputValue: x, setInputValue: I, filteredOptions: S, isLoading: f, value: u, onOptionClick: h, cleanInputValue: F } = te(V(e, s, L)), R = X(() => s === "fetch_on_type" ? f : !1, [s, f]), p = Q(() => e.multiple ? u.map((r) => i(r, e.optionValue)) : u ? i(u, e.optionValue) : void 0, [u, e.optionValue, e.multiple]), O = (r) => {
174
- const C = S.find((b) => i(b, e.optionValue) === r.id);
175
- C && h(C);
176
- }, { displayMode: j = e.multiple ? "chips" : "compact", dropdownOptions: J, overflow: y = "scroll", onChange: a, ...k } = e.selectComponentProps || {}, M = {
177
+ }, { inputValue: x, setInputValue: I, filteredOptions: S, isLoading: f, value: u, onOptionClick: m, cleanInputValue: F } = te(V(e, s, p)), R = X(() => s === "fetch_on_type" ? f : !1, [s, f]), O = Q(() => e.multiple ? u.map((r) => i(r, e.optionValue)) : u ? i(u, e.optionValue) : void 0, [u, e.optionValue, e.multiple]), y = (r) => {
178
+ const v = S.find((b) => i(b, e.optionValue) === r.id);
179
+ v && m(v);
180
+ }, { displayMode: j = e.multiple ? "chips" : "compact", dropdownOptions: J, overflow: C = "scroll", onChange: a, ...k } = e.selectComponentProps || {}, M = {
177
181
  controledSearchValue: x,
178
182
  onSearchValueChange: s === "fetch_on_type" ? I : void 0,
179
183
  onSearchClear: s === "fetch_on_type" ? F : void 0,
@@ -186,18 +190,18 @@ const ie = (e) => {
186
190
  {
187
191
  className: e.className,
188
192
  name: e.name,
189
- overflow: y,
193
+ overflow: C,
190
194
  ...k,
191
195
  multiple: !0,
192
- value: p,
196
+ value: O,
193
197
  label: e.label || "",
194
198
  options: S,
195
199
  optionValue: e.optionValue,
196
200
  optionLabel: e.optionLabel,
197
201
  renderOption: e.renderOption,
198
- onOptionClick: O,
202
+ onOptionClick: y,
199
203
  displayMode: j,
200
- controls: L,
204
+ controls: p,
201
205
  emptyMessage: "Use el buscador para obtener las opciones disponibles",
202
206
  dropdownOptions: M,
203
207
  isLoading: s === "fetch_in_open" ? f : !1
@@ -207,18 +211,18 @@ const ie = (e) => {
207
211
  {
208
212
  ...k,
209
213
  className: e.className,
210
- overflow: y,
214
+ overflow: C,
211
215
  name: e.name,
212
216
  multiple: !1,
213
- value: p,
217
+ value: O,
214
218
  label: e.label || "",
215
219
  options: S,
216
220
  optionValue: e.optionValue,
217
221
  optionLabel: e.optionLabel,
218
222
  renderOption: e.renderOption,
219
- onOptionClick: O,
223
+ onOptionClick: y,
220
224
  displayMode: "compact",
221
- controls: L,
225
+ controls: p,
222
226
  emptyMessage: "Use el buscador para obtener las opciones disponibles",
223
227
  dropdownOptions: M,
224
228
  isLoading: s === "fetch_in_open" ? f : !1
@@ -0,0 +1,35 @@
1
+ interface DialogProps<TContext = unknown> {
2
+ title?: string;
3
+ children: React.ReactNode | ((context: TContext | null) => React.ReactNode);
4
+ onClose?: (context: TContext | null) => void;
5
+ className?: string;
6
+ }
7
+ export interface DialogHandle<TContext = unknown> {
8
+ open: (context?: TContext) => void;
9
+ close: () => void;
10
+ isOpen: boolean;
11
+ getContext: () => TContext | null;
12
+ }
13
+ interface DialogContentProps {
14
+ children?: React.ReactNode;
15
+ className?: string;
16
+ }
17
+ interface DialogTitleProps {
18
+ children?: React.ReactNode;
19
+ className?: string;
20
+ }
21
+ interface DialogHeaderProps {
22
+ children?: React.ReactNode;
23
+ className?: string;
24
+ }
25
+ interface DialogFooterProps {
26
+ children?: React.ReactNode;
27
+ className?: string;
28
+ }
29
+ declare const DialogModal: import('react').ForwardRefExoticComponent<DialogProps<any> & import('react').RefAttributes<DialogHandle<any>>> & {
30
+ Content: import('react').MemoExoticComponent<({ children, className }: DialogContentProps) => import("react/jsx-runtime").JSX.Element>;
31
+ Header: import('react').MemoExoticComponent<({ children, className }: DialogHeaderProps) => import("react/jsx-runtime").JSX.Element>;
32
+ Footer: import('react').MemoExoticComponent<({ children, className }: DialogFooterProps) => import("react/jsx-runtime").JSX.Element>;
33
+ Title: import('react').MemoExoticComponent<({ children, className }: DialogTitleProps) => import("react/jsx-runtime").JSX.Element>;
34
+ };
35
+ export default DialogModal;
@@ -1,5 +1,6 @@
1
1
  import { ComponentType, JSX, default as React } from 'react';
2
2
  import { ComponentVariant, LabelVariant, OptionAccessor } from '../Shared/types';
3
+ import { InputProps } from '../Input/Input';
3
4
  export type SelectDisplayMode = "compact" | "chips";
4
5
  export type SelectOptionType = {
5
6
  label: string;
@@ -21,39 +22,45 @@ interface SelectOptionRendererProps<T = unknown> {
21
22
  disabled?: boolean;
22
23
  isLoading?: boolean;
23
24
  }
24
- export interface CustomSelectOptionRendererProps<T> extends SelectOptionRendererProps<T> {
25
+ export interface CustomSelectOptionRendererProps<T, TContext = unknown> extends Omit<SelectOptionRendererProps<T>, 'onSelect'> {
25
26
  option: T;
26
- onSelect: () => void;
27
+ onSelect: (closeOnSelect?: boolean) => void;
27
28
  disabled?: boolean;
28
29
  isLoading?: boolean;
30
+ renderContext?: TContext;
29
31
  }
30
32
  export type SelectVariant = "default" | "error" | "success";
31
33
  export type SelectControlsHandler = {
32
34
  open: () => void;
33
35
  close: () => void;
34
36
  toggle: () => void;
37
+ handleOptionSelect: (option: SelectOptionType, closeOnSelect: boolean) => void;
35
38
  subscribeOpenChange: (cb: (open: boolean) => void) => () => void;
36
39
  searchInputRef: React.RefObject<HTMLInputElement | null>;
37
40
  };
38
41
  export type SelectControlsRef = React.RefObject<SelectControlsHandler | null>;
39
42
  export interface DropdownOptionsProps {
40
43
  hideSearchBar?: boolean;
44
+ inputProps?: Partial<InputProps>;
41
45
  dropdownHeight?: string;
42
46
  controledSearchValue?: string;
43
47
  onSearchValueChange?: (value: string) => void;
44
48
  onSearchClear?: () => void;
45
49
  inputSearchPlaceholder?: string;
46
50
  isLoading?: boolean;
51
+ footer?: React.ReactNode;
52
+ loadingComponent?: React.ReactNode;
47
53
  }
48
- export interface BaseSelectProps<T> {
54
+ export interface BaseSelectProps<T, TContext = unknown> {
49
55
  id?: string;
50
56
  name?: string;
51
57
  label: string;
52
58
  options: T[];
53
59
  optionLabel: OptionAccessor<T, string>;
54
60
  optionValue: OptionAccessor<T, string | number>;
55
- renderOption?: ComponentType<CustomSelectOptionRendererProps<T>>;
61
+ renderOption?: ComponentType<CustomSelectOptionRendererProps<T, TContext>>;
56
62
  renderSelection?: ComponentType<CustomSelectionDisplayProps<T>>;
63
+ renderOptionContext?: TContext;
57
64
  disabled?: boolean;
58
65
  className?: string;
59
66
  isLoading?: boolean;
@@ -78,21 +85,21 @@ export interface BaseSelectProps<T> {
78
85
  onOptionClick?: (option: SelectOptionType, name?: string) => void;
79
86
  dropdownOptions?: DropdownOptionsProps;
80
87
  }
81
- export interface MultipleSelectProps<T> extends BaseSelectProps<T> {
88
+ export interface MultipleSelectProps<T, TContext = unknown> extends BaseSelectProps<T, TContext> {
82
89
  multiple: true;
83
90
  value: (string | number)[];
84
91
  onChange?: (newValue: SelectOptionType[], name?: string) => void;
85
92
  displayMode?: 'compact' | 'chips';
86
93
  }
87
- export interface SingleSelectProps<T> extends BaseSelectProps<T> {
94
+ export interface SingleSelectProps<T, TContext = unknown> extends BaseSelectProps<T, TContext> {
88
95
  multiple?: false;
89
96
  value: string | number | undefined;
90
97
  onChange?: (newValue: SelectOptionType | undefined, name?: string) => void;
91
98
  displayMode?: 'compact';
92
99
  }
93
- export type SelectProps<T = unknown> = MultipleSelectProps<T> | SingleSelectProps<T>;
100
+ export type SelectProps<T = unknown, TContext = unknown> = MultipleSelectProps<T, TContext> | SingleSelectProps<T, TContext>;
94
101
  declare const SelectWithOverloads: {
95
- <T>(props: MultipleSelectProps<T>): JSX.Element;
96
- <T>(props: SingleSelectProps<T>): JSX.Element;
102
+ <T, TContext = unknown>(props: MultipleSelectProps<T, TContext>): JSX.Element;
103
+ <T, TContext = unknown>(props: SingleSelectProps<T, TContext>): JSX.Element;
97
104
  };
98
105
  export default SelectWithOverloads;
@@ -1,5 +1,5 @@
1
1
  import { ComponentType } from 'react';
2
- import { CustomSelectionDisplayProps, CustomSelectOptionRendererProps, SelectProps } from '../Select/Select';
2
+ import { CustomSelectionDisplayProps, CustomSelectOptionRendererProps, SelectControlsHandler, SelectProps } from '../Select/Select';
3
3
  import { OptionAccessor } from '../Shared/types';
4
4
  interface SimpleSelectSearchProps<T> extends BaseSelectSearchProps<T> {
5
5
  multiple?: false;
@@ -28,7 +28,8 @@ export interface BaseSelectSearchProps<T> {
28
28
  className?: string;
29
29
  renderOption?: ComponentType<CustomSelectOptionRendererProps<T>>;
30
30
  renderSelection?: ComponentType<CustomSelectionDisplayProps<T>>;
31
- selectComponentProps?: Partial<SelectProps<T>>;
31
+ controls?: React.RefObject<SelectControlsHandler | null>;
32
+ selectComponentProps?: Partial<Omit<SelectProps<T>, 'controls'>>;
32
33
  }
33
34
  export type SelectSearchProps<T> = SimpleSelectSearchProps<T> | MultipleSelectSearchProps<T>;
34
35
  declare const SelectSearch: <T>(props: SelectSearchProps<T>) => import("react/jsx-runtime").JSX.Element;
package/dist/index.d.ts CHANGED
@@ -101,6 +101,7 @@ export type { DrawerMobileHandle } from './components/Drawer/DrawerMobile';
101
101
  export type { DrawerDesktopHandle } from './components/Drawer/DrawerDesktop';
102
102
  export type { CustomSelectionDisplayProps } from './components/Select/Select';
103
103
  export type { CustomSelectOptionRendererProps } from './components/Select/Select';
104
+ export type { SelectControlsHandler } from './components/Select/Select';
104
105
  export type { SelectOptionType } from './components/Select/Select';
105
106
  export type { BaseSelectSearchProps as SelectSearchProps } from './components/SelectSearch/SelectSearch';
106
107
  export type { FAButtonProps } from './components/FAB/FAButton';
@@ -0,0 +1,2 @@
1
+ declare const DialogPage: () => import("react/jsx-runtime").JSX.Element;
2
+ export default DialogPage;
@@ -0,0 +1,2 @@
1
+ declare const DialogModalPreview: () => import("react/jsx-runtime").JSX.Element;
2
+ export default DialogModalPreview;
@@ -0,0 +1,2 @@
1
+ declare const CustomFooterExample: () => import("react/jsx-runtime").JSX.Element;
2
+ export default CustomFooterExample;