@apia/components 0.0.7 → 0.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.
package/dist/index.d.ts CHANGED
@@ -1,133 +1,77 @@
1
- import { TRequireOnlyOne, TModify } from '@apia/util';
2
- import { IconType } from '@meronex/icons/lib';
3
- import * as React from 'react';
4
- import React__default, { ChangeEventHandler, FC } from 'react';
5
- import { IconButtonProps, ButtonProps, InputProps, ThemeUICSSObject, BoxProps } from 'theme-ui';
6
- import { TIconName } from '@apia/icons';
7
- import { IconType as IconType$1 } from '@meronex/icons';
1
+ import { TApiaFilter, TApiaFilterValue, TModify, IOnFocusConfiguration, TFocusRetriever, EventEmitter, TId } from '@apia/util';
2
+ import * as React$1 from 'react';
3
+ import React__default, { ChangeEventHandler, FC, ReactNode, MouseEvent, KeyboardEvent, FunctionComponent, ForwardedRef, RefObject } from 'react';
4
+ import { TIconType, TIconName } from '@apia/icons';
8
5
  import * as theme_ui_jsx_runtime from 'theme-ui/jsx-runtime';
6
+ import { ThemeUIStyleObject, IconButtonProps, ButtonProps, InputProps, ThemeUICSSObject, BoxProps } from 'theme-ui';
9
7
  import { Args } from 'react-cool-portal';
10
8
 
11
- interface IFocusProps {
12
- modalsContainerRetriever?: () => HTMLElement;
13
- notificationsContainerRetriever?: () => HTMLElement;
9
+ interface IApiaFilter {
10
+ filter: TApiaFilter;
11
+ onBlur?: (ev: TApiaFilterValue) => void;
12
+ onChange?: (ev: TApiaFilterValue) => void | boolean | string | Promise<boolean | string>;
13
+ onPressEnter?: (ev: TApiaFilterValue) => void;
14
14
  }
15
- interface IOnFocusConfiguration {
16
- /**
17
- * El controlador emite un evento custom cuando se realiza foco, con la
18
- * intención de que los elementos colapsables se abran automáticamente. Si
19
- * este parámetro es pasado con false, se evita ese comportamiento.
20
- */
21
- dispatchCustomEvent?: boolean;
22
- /**
23
- * Cuando la pantalla está bloqueada con el spinner, el controlador no
24
- * intentará hacer foco, a menos que este parámetro se pase en true.
25
- */
26
- focusEvenWhenScreenLocked?: boolean;
27
- scrollIntoViewOptions?: ScrollIntoViewOptions;
15
+ declare const ApiaFilter: React$1.MemoExoticComponent<React$1.ForwardRefExoticComponent<IApiaFilter & React$1.RefAttributes<HTMLInputElement | HTMLSelectElement>>>;
16
+
17
+ interface ICollapsiblePanel {
18
+ children: React.ReactNode;
19
+ className?: string;
20
+ closedIcon?: TIconType | TIconName;
21
+ collapsed?: boolean;
22
+ defaultCollapsed?: boolean;
23
+ disableChildrenFocus?: boolean;
24
+ iconSize?: string | number;
25
+ id?: string;
26
+ minHeight?: number;
27
+ onClose?: () => unknown;
28
+ onOpen?: (ev?: React.MouseEvent) => void | Promise<boolean>;
29
+ openIcon?: TIconType | TIconName;
30
+ label: React.ReactNode;
31
+ titleButtons?: React.ReactNode;
32
+ }
33
+
34
+ declare const CollapsiblePanel: React__default.ForwardRefExoticComponent<ICollapsiblePanel & React__default.RefAttributes<HTMLDivElement>>;
35
+
36
+ type TModalSize = 'editGrid' | 'sm' | 'md' | 'md-fixed' | 'lg' | 'lg-fixed' | 'xl' | 'xl-fixed' | 'xxl' | 'xxxl' | 'xxxl-fixed' | 'flex' | 'cal' | 'finder';
37
+ type TApiaButtonType = 'primary' | 'primary-sm' | 'secondary' | 'light-secondary' | 'secondary-sm' | 'danger' | 'danger-sm' | 'outline' | 'outline-sm' | 'warning' | 'warning-sm' | 'link';
38
+
39
+ interface IBaseButton {
40
+ text?: string;
41
+ children?: string;
42
+ loadingChildren?: string;
43
+ id?: string;
44
+ name?: string;
45
+ onClick?: React.MouseEventHandler<HTMLButtonElement>;
46
+ isLoading?: boolean;
47
+ disabled?: boolean;
48
+ variant?: TApiaButtonType | string;
49
+ type?: 'button' | 'submit' | 'reset';
50
+ SXProps?: ThemeUIStyleObject;
28
51
  }
29
52
  /**
30
- * Al método focus.on se le puede pasar o bien un HTMLElement o bien una
31
- * función que implemente esta interfaz. Cuando se pasa una función, la misma
32
- * será invocada cada vez que se vaya a intentar una acción de foco.
33
- *
34
- * Si la función devuelve un elemento HTML, se intentará hacer foco sobre éste.
35
- *
36
- * Si la función devuelve null, ese intento será tomado como nulo y se volverá
37
- * a intentar luego del tiempo determinado.
38
- *
39
- * Si la función devuelve false, será eliminada de la cola de foco, lo que
40
- * significa que ya no se intentará hacer foco sobre este elemento. En cambio,
41
- * se continuará con los demás elementos de la cola o en caso de no haber
42
- * ninguno, con el último elemento que tuvo foco y aún esté presente en el
43
- * documento.
53
+ * The world's most **basic** button
44
54
  */
45
- type TFocusRetriever = (isLastTry: boolean) => HTMLElement | null | false;
46
- interface IFocusQueryElement {
47
- element: HTMLElement | TFocusRetriever;
48
- configuration?: IOnFocusConfiguration;
49
- }
50
- declare global {
51
- interface Window {
52
- focusStatus: Record<string, unknown>;
53
- }
54
- }
55
- interface IFocusCheck {
56
- currentInstruction: number;
57
- }
58
- declare const focus: {
59
- root: HTMLElement;
60
- props?: IFocusProps;
61
- afterNotificationFocus: IFocusQueryElement | undefined;
62
- "__#5@#actualFocusQuery": IFocusQueryElement[];
63
- "__#5@#currentInstruction": number;
64
- "__#5@#focusDelay": number;
65
- "__#5@#focusRetries": number;
66
- "__#5@#focusTimeout": number;
67
- "__#5@#isIntervalRunning": boolean;
68
- "__#5@#focusQuery": IFocusQueryElement[];
69
- "__#5@#checkInstruction"(focusCheck: IFocusCheck): boolean;
70
- "__#5@#doFocus"(HTMLElement: HTMLElement | TFocusRetriever, focusCheck: IFocusCheck, isLastTry: boolean, configuration?: IOnFocusConfiguration): Promise<false | HTMLElement | null>;
71
- "__#5@#resetInterval"(): void;
72
- "__#5@#runFocusInterval"(focusElement?: IFocusQueryElement, internalCall?: boolean): Promise<false | HTMLElement>;
73
- /**
74
- * Da la instrucción de colocar el foco en el elemento provisto como
75
- * parámetro una vez que todas las notificaciones se hayan cerrado. En caso
76
- * de no existir notificaciones abiertas, hace foco en el elemento
77
- * directamente.
78
- */
79
- afterNotifications(element: HTMLElement | TFocusRetriever, configuration?: IOnFocusConfiguration): void;
80
- /**
81
- * Da la instrucción de colocar el foco en el elemento provisto como
82
- * parámetro luego de recargar la página.
83
- *
84
- * Los parámetros pasados serán ordenados en orden de importancia priorizando
85
- * en el siguiente orden:
86
- * - id
87
- * - name
88
- * - className
89
- * - selector
90
- */
91
- afterReload({ className, id, name, selector, }: TRequireOnlyOne<{
92
- className: string;
93
- id: string;
94
- name: string;
95
- selector: string;
96
- }, "className" | "id" | "name" | "selector">): void;
97
- /**
98
- * Da la instrucción de colocar el foco el elemento pasado como parámetro.
99
- * Se puede pasar también una función que devuelva HTMLElement | false | null.
100
- *
101
- * El segundo parámetro del método on es un objeto de tipo
102
- * ScrollIntoViewOptions, que permite modificar el comportamiento del scroll
103
- * a en el elemento.
104
- *
105
- * @see TFocusRetriever para más detalles sobre la función como parámetro.
106
- */
107
- on(element: HTMLElement | TFocusRetriever, configuration?: IOnFocusConfiguration): Promise<false | HTMLElement>;
108
- focusOnReload: string | null;
109
- restore(): void;
110
- init(): void;
111
- };
55
+ declare const BaseButton: ({ id, name, onClick, isLoading, loadingChildren, disabled, children, text, variant, type, SXProps, ...buttonProps }: IBaseButton) => theme_ui_jsx_runtime.JSX.Element;
112
56
 
113
57
  type TIconSize = number | 'xs' | 'sm' | 'md' | 'lg' | 'xl';
114
58
  type TApiaIconButton = 'icon' | 'icon-primary' | 'icon-outline' | 'icon-only';
115
- type TIconButton = IconButtonProps & React.AriaAttributes & {
59
+ type TIconButton = IconButtonProps & React$1.AriaAttributes & {
116
60
  className?: string;
117
61
  /**
118
62
  * Es posible pasar explícitamente un ícono o el nombre del ícono de
119
63
  * acuerdo a la librería de la aplicación. Ver Icon.tsx
120
64
  */
121
- icon: IconType | TIconName;
65
+ icon: TIconType | TIconName;
122
66
  iconSize?: TIconSize;
123
67
  id?: string;
124
68
  disabled?: boolean;
125
69
  href?: string;
126
70
  isLoading?: boolean;
127
71
  isToggled?: boolean;
128
- onClick?: React.MouseEventHandler<HTMLButtonElement>;
129
- onMouseOut?: React.MouseEventHandler<HTMLButtonElement>;
130
- onMouseOver?: React.MouseEventHandler<HTMLButtonElement>;
72
+ onClick?: React$1.MouseEventHandler<HTMLButtonElement>;
73
+ onMouseOut?: React$1.MouseEventHandler<HTMLButtonElement>;
74
+ onMouseOver?: React$1.MouseEventHandler<HTMLButtonElement>;
131
75
  size?: TIconSize;
132
76
  title?: string;
133
77
  variant?: string;
@@ -139,20 +83,53 @@ type TIconButton = IconButtonProps & React.AriaAttributes & {
139
83
  *
140
84
  * Si se pasa solamente size, el iconSize será
141
85
  */
142
- declare const IconButton: React.ForwardRefExoticComponent<Omit<TIconButton, "ref"> & React.RefAttributes<HTMLButtonElement>>;
86
+ declare const IconButton: React$1.ForwardRefExoticComponent<Omit<TIconButton, "ref"> & React$1.RefAttributes<HTMLButtonElement>>;
143
87
 
144
88
  interface ISimpleButton extends ButtonProps {
145
- icon?: IconType$1;
89
+ icon?: TIconType;
90
+ iconColor?: string;
146
91
  iconPosition?: 'left' | 'right';
147
92
  iconSize?: number;
148
93
  isLoading?: boolean;
149
- onClick?: React.MouseEventHandler<HTMLButtonElement>;
94
+ onClick?: React$1.MouseEventHandler<HTMLButtonElement>;
150
95
  size?: 'sm' | 'md' | 'lg';
151
96
  variant?: string;
152
97
  spinnerSize?: number;
153
98
  type?: 'button' | 'submit' | 'reset';
154
99
  }
155
- declare const SimpleButton: React.ForwardRefExoticComponent<Omit<ISimpleButton, "ref"> & React.RefAttributes<unknown>>;
100
+ declare const SimpleButton: React$1.ForwardRefExoticComponent<Omit<ISimpleButton, "ref"> & React$1.RefAttributes<unknown>>;
101
+
102
+ /**
103
+ * Este hook está pensado para crear un botón utilizando un tag cualquiera.
104
+ *
105
+ * @example
106
+ *
107
+ * const buttonProps = useOtherTagButton(React.useMemo(()=>({
108
+ * onClick(ev) { console.log(ev.target) },
109
+ * onKeyDown(ev) { console.log(ev.code) }
110
+ * }),[])
111
+ *
112
+ * return <div {...buttonProps}>Esto es un botón</div>
113
+ */
114
+ declare function useOtherTagButton(props?: Partial<{
115
+ className?: string;
116
+ onClick: React__default.MouseEventHandler;
117
+ onKeyDown: React__default.KeyboardEventHandler;
118
+ }>): {
119
+ className: string;
120
+ onClick: (ev: React__default.MouseEvent) => void;
121
+ onKeyDown: (ev: React__default.KeyboardEvent) => void;
122
+ role: string;
123
+ tabIndex: number;
124
+ };
125
+
126
+ declare const Captcha: ({ name, imageUrl, onChange, value, className, }: {
127
+ name: string;
128
+ className?: string | undefined;
129
+ imageUrl: string;
130
+ onChange: React.ChangeEventHandler<HTMLInputElement>;
131
+ value: string;
132
+ }) => theme_ui_jsx_runtime.JSX.Element;
156
133
 
157
134
  type TCheckbox = TModify<ButtonProps, {
158
135
  background?: string;
@@ -166,7 +143,7 @@ type TCheckbox = TModify<ButtonProps, {
166
143
  required?: boolean;
167
144
  type?: string;
168
145
  }>;
169
- declare const Checkbox: React.ForwardRefExoticComponent<Omit<TCheckbox, "ref"> & React.RefAttributes<HTMLButtonElement>>;
146
+ declare const Checkbox: React$1.ForwardRefExoticComponent<Omit<TCheckbox, "ref"> & React$1.RefAttributes<HTMLButtonElement>>;
170
147
 
171
148
  interface IField {
172
149
  className?: string;
@@ -179,7 +156,7 @@ interface IIconInput extends IField {
179
156
  buttonProps?: Partial<React__default.ComponentProps<typeof IconButton>>;
180
157
  buttonRef?: React__default.RefObject<HTMLButtonElement>;
181
158
  hideButton?: boolean;
182
- icon?: IconType$1;
159
+ icon?: TIconType | TIconName;
183
160
  inputProps?: Partial<InputProps>;
184
161
  inputRef?: React__default.RefObject<HTMLInputElement>;
185
162
  mask?: string;
@@ -219,7 +196,7 @@ type TDateProps = TModify<InputProps, {
219
196
  declare const DateInput: React__default.ForwardRefExoticComponent<Omit<TDateProps, "ref"> & React__default.RefAttributes<HTMLInputElement>>;
220
197
 
221
198
  interface IFieldErrorMessage {
222
- children: React.ReactNode | string;
199
+ children: React$1.ReactNode | string;
223
200
  name?: string;
224
201
  }
225
202
  declare const FieldErrorMessage: ({ children, name }: IFieldErrorMessage) => theme_ui_jsx_runtime.JSX.Element | null;
@@ -260,6 +237,105 @@ declare const RequiredMark: ({ isFormReadonly, isRequired, isReadonly, }: IRequi
260
237
  declare const getFieldErrorStyles: (isValid: boolean) => ThemeUICSSObject;
261
238
  declare const getFieldTouchedStyles: (isTouched: boolean) => ThemeUICSSObject;
262
239
 
240
+ type TListboxItem = {
241
+ children: ReactNode;
242
+ rowIndex?: number;
243
+ } & BoxProps & {
244
+ /**
245
+ * El label se usa en aria-label por motivos de accesibilidad y además en
246
+ * la funcionalidad de búsqueda.
247
+ */
248
+ label: string;
249
+ };
250
+ declare const ListboxItem: FC<TListboxItem>;
251
+
252
+ type TListboxState = {
253
+ /**
254
+ * El múltipleSearch está de acuerdo a la especificación de wai-aria. Está
255
+ * habilitado por defecto e implica que si el usuario presiona una "rápida
256
+ * sucesión" (según palabras de wai-aria) de caracteres, se irá
257
+ * alternando el foco entre los elementos que comiencen con la cadena
258
+ * introducida.
259
+ */
260
+ allowMultipleCharacterSearch?: boolean;
261
+ allowSelection: boolean;
262
+ /**
263
+ * El singleCharacterSearch está de acuerdo a la especificación de wai-aria.
264
+ * Está habilitado por defecto e implica que si el usuario presiona una
265
+ * "lenta sucesión" (según palabras de wai-aria) de caracteres, se irá
266
+ * alternando el foco entre los elementos que comiencen con la letra
267
+ * introducida.
268
+ */
269
+ allowSingleCharacterSearch?: boolean;
270
+ focusedRow: number;
271
+ hiddenRows: number[];
272
+ id: string;
273
+ isEverythingSelected: boolean;
274
+ isMultipleSelection: boolean;
275
+ lastSelectedRow: number;
276
+ rowsCount: number;
277
+ /**
278
+ * La función de búsqueda debe tomar el label de un campo y el texto
279
+ * introducido en el campo de búsqueda y determinar si el mismo debe ser
280
+ * mostrado o no. Por defecto, se usa una función de matcheo estricto.
281
+ */
282
+ searchFunction: (label: string, searchString: string) => boolean;
283
+ selectedRows: number[];
284
+ shownRows: number[];
285
+ showSearchbox: boolean;
286
+ /**
287
+ * Este método permite determinar si un elemento comienza con una cadena de
288
+ * texto en particular. Por defecto se usa String.startsWith, sin embargo se
289
+ * permite el pasaje de este método para situaciones particulares, ejemplo
290
+ * si se deseara incluir elementos sin tomar en cuenta los espacios.
291
+ */
292
+ startsWithFunction: (label: string, searchString: string) => boolean;
293
+ typing: string | null;
294
+ };
295
+
296
+ type TListbox = {
297
+ children: ReactNode | ReactNode[];
298
+ className?: string;
299
+ /**
300
+ * Permite remover los estilos por defecto de la lista a fin de personalizar
301
+ * su aspecto
302
+ */
303
+ unstyled?: boolean;
304
+ onClickNode?: (ev: MouseEvent<HTMLElement>) => unknown;
305
+ onDoubleClickNode?: (ev: MouseEvent<HTMLElement>) => unknown;
306
+ /**
307
+ * Este evento es lanzado cuando el usuario estando en foco en la lista
308
+ * presiona:
309
+ *
310
+ * - Enter si la selección múltiple está deshabilitada
311
+ * - ctrl+Enter si la selección múltiple está habilitada
312
+ */
313
+ onConfirmSelection?: (ev: TOnConfirmSelection) => unknown;
314
+ onPressEnterOnNode?: (ev: KeyboardEvent<HTMLElement>) => unknown;
315
+ onPressKeyOnNode?: (ev: KeyboardEvent<HTMLElement>) => unknown;
316
+ onSelectionChange?: (ev: TOnSelectionChange) => unknown;
317
+ /**
318
+ * onKeyDown e id no son permitidas dado que se usan para generar el
319
+ * comportamiento correcto del componente
320
+ */
321
+ ulProps?: Omit<BoxProps, 'id' | 'onKeyDown'>;
322
+ } & Partial<Pick<TListboxState, 'allowMultipleCharacterSearch' | 'allowSelection' | 'allowSingleCharacterSearch' | 'isMultipleSelection' | 'searchFunction' | 'startsWithFunction' | 'showSearchbox'>>;
323
+
324
+ type TOnConfirmSelection = {
325
+ originalEvent: KeyboardEvent;
326
+ selectedElements: HTMLElement[];
327
+ focusedElement: HTMLElement;
328
+ };
329
+ type TOnSelectionChange = {
330
+ focusedElement: HTMLElement;
331
+ selectedElements: HTMLElement[];
332
+ };
333
+ type TOnClickNode = MouseEvent;
334
+
335
+ declare const Listbox: React$1.MemoExoticComponent<((props: TListbox) => theme_ui_jsx_runtime.JSX.Element) & {
336
+ displayName: string;
337
+ }>;
338
+
263
339
  declare const LinearLoader: () => theme_ui_jsx_runtime.JSX.Element;
264
340
 
265
341
  interface IProgressBar {
@@ -269,9 +345,6 @@ interface IProgressBar {
269
345
  }
270
346
  declare const ProgressBar: FC<IProgressBar>;
271
347
 
272
- type TModalSize = 'editGrid' | 'sm' | 'md' | 'md-fixed' | 'lg' | 'lg-fixed' | 'xl' | 'xl-fixed' | 'xxl' | 'xxxl' | 'xxxl-fixed' | 'flex' | 'cal' | 'finder';
273
- type TApiaButtonType = 'primary' | 'primary-sm' | 'secondary' | 'light-secondary' | 'secondary-sm' | 'danger' | 'danger-sm' | 'outline' | 'outline-sm' | 'warning' | 'warning-sm' | 'link';
274
-
275
348
  interface IDialogHeader {
276
349
  className?: string;
277
350
  close: () => void;
@@ -524,20 +597,20 @@ declare function useModal(configuration?: TUseModalConfiguration): {
524
597
 
525
598
  declare function getConfirmButton(ref: HTMLElement): HTMLElement;
526
599
  interface IConfirm {
527
- additionalButtons?: React.ReactNode;
528
- additionalButtonsOnRight?: React.ReactNode;
600
+ additionalButtons?: React$1.ReactNode;
601
+ additionalButtonsOnRight?: React$1.ReactNode;
529
602
  cancelButtonText?: string;
530
- children: React.ReactNode;
603
+ children: React$1.ReactNode;
531
604
  className?: string;
532
605
  confirmButtonText?: string;
533
606
  confirmButtonVariant?: TApiaButtonType;
534
- contentRef?: React.Ref<HTMLDivElement>;
607
+ contentRef?: React$1.Ref<HTMLDivElement>;
535
608
  disabled?: boolean;
536
609
  hideCancelButton?: boolean;
537
610
  hideConfirmButton?: boolean;
538
611
  isLoading?: boolean;
539
- onConfirm?: (ev: React.MouseEvent) => unknown;
540
- onCancel?: (ev: React.MouseEvent) => unknown;
612
+ onConfirm?: (ev: React$1.MouseEvent) => unknown;
613
+ onCancel?: (ev: React$1.MouseEvent) => unknown;
541
614
  variant?: string;
542
615
  }
543
616
  declare global {
@@ -545,18 +618,18 @@ declare global {
545
618
  [key: string]: string;
546
619
  }
547
620
  }
548
- declare const Confirm: React.FC<IConfirm>;
621
+ declare const Confirm: React$1.FC<IConfirm>;
549
622
 
550
623
  interface IDialogButtonBar {
551
- children: React.ReactNode;
624
+ children: React$1.ReactNode;
552
625
  className?: string;
553
626
  }
554
- declare const DialogButtonBar: React.FC<IDialogButtonBar>;
627
+ declare const DialogButtonBar: React$1.FC<IDialogButtonBar>;
555
628
 
556
629
  interface IOverlay extends BoxProps {
557
- children: React.ReactNode;
630
+ children: React$1.ReactNode;
558
631
  className?: string;
559
- onOverlayClicked: (event: React.MouseEvent<HTMLDivElement>) => void;
632
+ onOverlayClicked: (event: React$1.MouseEvent<HTMLDivElement>) => void;
560
633
  /**
561
634
  * Permite pasar un callback que será llamado una vez que el overlay termine
562
635
  * de cerrarse.
@@ -567,157 +640,298 @@ interface IOverlay extends BoxProps {
567
640
  stretch?: boolean;
568
641
  transitionDuration?: number;
569
642
  }
570
- declare const Overlay: React.ForwardRefExoticComponent<IOverlay & React.RefAttributes<unknown>>;
571
-
572
- declare const lockController: {
573
- "__#1@#private": any;
574
- on<K extends "lockLinear" | "lock" | "forceLock" | "forceUnlock" | "forceWhiteScreen" | "unlock">(eventName: K, fn: (params: {
575
- forceLock: null;
576
- forceUnlock: null;
577
- forceWhiteScreen: null;
578
- lock: null;
579
- unlock: null;
580
- lockLinear: null;
581
- }[K]) => unknown): () => void;
582
- off<K_1 extends "lockLinear" | "lock" | "forceLock" | "forceUnlock" | "forceWhiteScreen" | "unlock">(eventName: K_1, fn: (params: {
583
- forceLock: null;
584
- forceUnlock: null;
585
- forceWhiteScreen: null;
586
- lock: null;
587
- unlock: null;
588
- lockLinear: null;
589
- }[K_1]) => unknown): void;
590
- emit<K_2 extends "lockLinear" | "lock" | "forceLock" | "forceUnlock" | "forceWhiteScreen" | "unlock">(eventName: K_2, params?: {
591
- forceLock: null;
592
- forceUnlock: null;
593
- forceWhiteScreen: null;
594
- lock: null;
595
- unlock: null;
596
- lockLinear: null;
597
- }[K_2] | undefined): void;
598
- };
599
- /**
600
- * There it exists a hook which handles much better the lock process than this
601
- * method, which is only intended to use outside React components. Please, if
602
- * you will call the lock function within a component:
603
- *
604
- * @see useScreenLock
605
- *
606
- * The lockScreen method will add 1 to a counter, which tells the locking screen
607
- * how much components expect the screen to be locked. The only way the screen
608
- * is unlocked, is that this counter is exactly 0 and that there is no component
609
- * forcing the lock.
610
- *
611
- * @see forceScreenLock
612
- *
613
- * @returns A method which can be used to be sure that the unlocking process will be only made one time, which ensures that any component will interfere with the locking fired by other components.
614
- *
615
- * @example
616
- *
617
- * const unlock = lockScreen();
618
- *
619
- * // Make some heavy stuff
620
- *
621
- * // The unlock method is being called 3 times, but the unlock process is executed once.
622
- * unlock();
623
- * unlock();
624
- * unlock();
625
- */
626
- declare function lockScreen(linear?: boolean): () => void;
643
+ declare const Overlay: React$1.ForwardRefExoticComponent<IOverlay & React$1.RefAttributes<unknown>>;
644
+
627
645
  /**
628
- * This method is the counterpart of lockScreen and must (preferably) not be
629
- * used, use the useScreenLock hook or the method returned from lockScreen in
630
- * order to avoid interfering with other components locking process.
631
- *
632
- * @see lockScreen
633
- * @see useScreenLock
646
+ * Implementación de la clase screenLocker que maneja tres tipos de bloqueo:
647
+ * common, linear, y white. El caso del forced lo trata como common.
634
648
  */
635
- declare function unlockScreen(): void;
649
+ declare const ScreenLock: () => theme_ui_jsx_runtime.JSX.Element | null;
650
+
651
+ interface IMakeResponsiveComponent<P extends Record<string, unknown>> {
652
+ breakPoints: number[];
653
+ Component: FunctionComponent<P & {
654
+ breakPoint: number;
655
+ breakPointWidth: number;
656
+ containerWidth: number;
657
+ }>;
658
+ /**
659
+ * Este HOC hace un setState cada vez que cambia el ancho del contenedor. Hay
660
+ * situaciones en las que es deseable agregar un debounce a este
661
+ * comportamiento para mejorar la performance. *Por defecto usa 100*
662
+ */
663
+ debounce?: number;
664
+ /**
665
+ * Por defecto usa 4.
666
+ */
667
+ defaultBreakpoint?: number;
668
+ }
636
669
  /**
637
- * This method is very determinant: the screen will be locked no matter what is
638
- * happening with other components. To do that, a flag is raised telling the
639
- * screen lock component: lock the screen.
640
- *
641
- * This flag can only be lowered by calling forceUnlockScreen
642
- *
643
- * @see releaseScreenLock
670
+ * El método makeResponsiveComponent agrega un wrapper alrededor de un
671
+ * componente para conocer el ancho del contenedor del mismo. De esta forma, es
672
+ * fácil predecir qué ancho dispone el mismo para renderizarse y de esa forma
673
+ * poder tomar decisiones de responsividad que no dependen del ancho de la
674
+ * pantalla sino del espacio donde se encuentra.
644
675
  */
645
- declare function forceScreenLock(): void;
676
+ declare const makeResponsiveComponent: <P extends Record<string, unknown>>({ breakPoints, Component, debounce, defaultBreakpoint, }: IMakeResponsiveComponent<P>) => (props: P & {
677
+ breakPoints?: number[] | undefined;
678
+ defaultBreakPoint?: number | undefined;
679
+ }) => theme_ui_jsx_runtime.JSX.Element;
680
+
646
681
  /**
647
- * This method is very determinant: the screen will be locked no matter what is
648
- * happening with other components. To do that, a flag is raised telling the
649
- * screen lock component: lock the screen.
682
+ * Type-ahead is a behavior pattern which helps the user in the lists and trees
683
+ * (and literally says: "especially those with more than seven options")
684
+ * navigation. The literal description in Wai-Aria documentation is:
650
685
  *
651
- * This flag can only be lowered by calling forceUnlockScreen
686
+ * - Type a character: focus moves to the next item with a name that starts
687
+ * with the typed character.
652
688
  *
653
- * @see releaseScreenLock
654
- */
655
- declare function forceWhiteScreen(): void;
656
- /**
657
- * This method is the counterpart of forceLockScreen. If the screen is being
658
- * forced to be locked, this method will release it to allow the screen locking
659
- * process to behave normally.
689
+ * - Type multiple characters in rapid succession:
690
+ * focus moves to the next item with a name that starts with the string of
691
+ * characters typed.
660
692
  *
661
- * @see forceScreenLock
662
- */
663
- declare function releaseScreenLock(): void;
664
- /**
665
- * This hook is the ideal way to control the screen locking process, it
666
- * guarantees that the screen will only be unlocked by the component which
667
- * is using it if it has locked it previously. This way the behavior will be
668
- * persistent with what the components expect to happen when they call lock or
669
- * unlock screen.
693
+ * It is a little arbitrary what is rapid succession. As I couln't find any
694
+ * documentation about what rapid succession means, I will make some tests in
695
+ * order to determine what is more comfortable to accomplish one situation or
696
+ * the other.
670
697
  *
671
- * @returns an object containing { lockScreen, unlockScreen } methods that are
672
- * explained by their names.
698
+ * To callibrate this function it is suficient to override the frequency
699
+ * parameter, which after some tests I understand is best at 2.5 (keys per
700
+ * second).
673
701
  */
674
- declare function useScreenLock(): {
675
- lockScreen: () => void;
676
- unlockScreen: () => void;
702
+
703
+ declare class WaiTypeAhead extends EventEmitter<{
704
+ multipleKeys: string;
705
+ singleKey: string;
706
+ typeUpdate: string;
707
+ }> {
708
+ #private;
709
+ frequency: number;
710
+ timeout: number;
711
+ typing: string;
712
+ constructor(props?: {
713
+ onMultipleKeys?: (value: string) => unknown;
714
+ onSingleKey?: (value: string) => unknown;
715
+ onTypeUpdate?: (value: string) => unknown;
716
+ });
717
+ type(ev: KeyboardEvent): void;
718
+ }
719
+
720
+ type TIcon<P = Record<string, unknown>> = {
721
+ /**
722
+ * Permite el pasaje de propoiedades arbitrarias a cada nodo. Se podría usar
723
+ * por ejemplo para almacenar la url que debe ser llamada cuando se hace doble
724
+ * click en un ícono.
725
+ */
726
+ additionalProps?: P;
727
+ /**
728
+ * Se pide un ariaLabel como requerido por motivos de accesibilidad.
729
+ */
730
+ ariaLabel: string;
731
+ /**
732
+ * Permite el pasaje de clases arbitrarias a cada ícono.
733
+ */
734
+ className?: string;
735
+ id: TId;
736
+ imageUrl: string;
737
+ /**
738
+ * Es el texto que se mostrará debajo de la imagen.
739
+ */
740
+ label: string;
741
+ /**
742
+ * Permite modificar el color individual de un ícono.
743
+ */
744
+ textColor?: string;
677
745
  };
678
- declare function isCurrentlyLocked(): boolean;
679
- /**
680
- * **DO NOT USE THIS COMPONENT**
681
- *
682
- * This component is not intended to be used by any component more than the
683
- * BaseApp. If you are looking for a suspense screen to use with a lazy
684
- * component, please refer to ScreenLockSuspense.
685
- *
686
- * **DO NOT USE THIS COMPONENT**
687
- *
688
- * @see ScreenLockSuspense
689
- *
690
- * **DO NOT USE THIS COMPONENT**
691
- */
692
- declare const ScreenLock: () => theme_ui_jsx_runtime.JSX.Element | null;
693
- interface IReadyTools {
746
+ type TIconsList<P = Record<string, unknown>> = {
694
747
  /**
695
- * Con este método se libera el bloqueo de la pantalla,
696
- * y es pasado como parámetro de la función onScreenLockReady
697
- * solamente cuando la pantalla está lista para ser
698
- * desbloqueada.
748
+ * Listado de íconos
699
749
  */
700
- releaseScreenLock: () => void;
701
- }
702
- type TReadyCb = (tools: IReadyTools) => void;
703
- /**
704
- * Permite agendar un callback para que sea ejecutado cuando
705
- * la pantalla esté lista para ser desbloqueada. Este callback
706
- * será llamado con un método como parámetro que ejecuta el
707
- * desbloqueo.
708
- *
709
- * Si la pantalla ya está lista para ser desbloqueada cuando se
710
- * registre el callback, éste sera llamado inmediatamente.
711
- */
712
- declare function onScreenLockReady(cb: TReadyCb): void;
750
+ icons: TIcon<P>[];
751
+ iconRenderer?: TIconRenderer;
752
+ /**
753
+ * Por defecto se usa iconWidth=100.
754
+ *
755
+ * El iconSize indica el ancho del contenedor del ícono.
756
+ */
757
+ iconWidth?: number;
758
+ /**
759
+ * Si bien el gap horizontal es calculado automáticamente, es posible
760
+ * especificar cuál es el mínimo gap que debe mostrarse. *Por defecto se usará
761
+ * 30*
762
+ */
763
+ minHorizontalGap?: number;
764
+ /**
765
+ * Este callback es llamado cuando se hace click en un ícono
766
+ */
767
+ onIconClick?: (ev: MouseEvent<HTMLElement>, icon: TIcon<P>) => unknown;
768
+ /**
769
+ * Este callback es llamado cuando se hace doble click en un ícono
770
+ */
771
+ onIconDoubleClick?: (ev: MouseEvent<HTMLElement>, icon: TIcon<P>) => unknown;
772
+ /**
773
+ * Este método se usa para obtener detalles de un ícono. Es llamado cuando se
774
+ * hace foco o cuando se posiciona el mouse en un ícono. Si no está declarado
775
+ * los íconos no mostrarán detalles. Si está declarado deberá devolver un
776
+ *
777
+ * Record<string, ReactNode> y cada entrada será mostrada como una fila de
778
+ * detalle.
779
+ */
780
+ onIconGetDetails?: (icon: TIcon<P>) => ReactNode;
781
+ /**
782
+ * Permite agregar comportamiento personalizado a los eventos de teclado.
783
+ */
784
+ onIconKeyDown?: (ev: KeyboardEvent<HTMLElement>, icon: TIcon<P>) => unknown;
785
+ /**
786
+ * Normalmente el listado coloca padding horizontal para distribuir
787
+ * uniformemente los íconos, de forma que la distancia entre ellos sea la
788
+ * misma que la existente en la izquierda y derecha. Si se pasa esta
789
+ * propiedad, el primer y úlitmo ícono estarán colocados sobre los bordes y el
790
+ * espacio restante se distribuirá entre los gaps existnetes
791
+ */
792
+ removeHorizontalPadding?: boolean;
793
+ /**
794
+ * El espaciado horizontal se calcula automáticamente, sin embargo si es
795
+ * posible definir el vertical. Por defecto se usa 0.
796
+ */
797
+ verticalGap?: number;
798
+ };
713
799
  /**
714
- * Permite agendar un callback para que sea ejecutado una vez
715
- * que la pantalla haya sido desbloqueada por primera vez.
716
- *
717
- * Si al momento de registrar el callback la pantalla ya fue
718
- * desbloqueada, el callback se ejecuta inmediatamente.
800
+ * Por defecto se usa DefaultIconRenderer. El pasaje de un nuevo IconRenderer
801
+ * permite modificar la forma en que se distribuyen en pantalla los distintos
802
+ * atributos de cada ícono.
803
+ *
804
+ * Una particularidad es cómo se definen los estilos cuando el ícono está en
805
+ * foco: Se usa el selector **'.iconsList__keyHandler:focus .focused
806
+ * .iconsList__icon__wrapper'**, que es donde se aplican los estilos
807
+ * correspondientes al foco.
719
808
  */
720
- declare function onScreenLockReleasedFirstTime(cb: () => void): void;
721
- declare function hasReleasedScreenLock(): boolean;
809
+ type TIconRenderer<P = Record<string, unknown>> = FunctionComponent<TIcon<P>>;
810
+
811
+ declare const IconsList: {
812
+ <P extends Record<string, unknown>>(props: TIconsList<P>, ref: ForwardedRef<HTMLDivElement>): theme_ui_jsx_runtime.JSX.Element;
813
+ displayName: string;
814
+ };
815
+
816
+ type TAttachToElement = (() => HTMLElement) | RefObject<HTMLElement>;
817
+ type TPreferredOrientationX = 'left' | 'right';
818
+ type TPreferredOrientationY = 'top' | 'bottom';
819
+ type TSize = {
820
+ width: number;
821
+ height: number;
822
+ };
823
+ type TSizeWithAuto = {
824
+ width: number | 'auto';
825
+ height: number | 'auto';
826
+ };
827
+ type TPosition = {
828
+ left: number;
829
+ top: number;
830
+ };
831
+ type TAttachToElementAnchorPoint = 'center' | 'topLeft' | 'topRight' | 'bottomLeft' | 'bottomRight';
832
+ type TTooltip = {
833
+ /** Define el contenido del tooltip */
834
+ children?: ReactNode;
835
+ /**
836
+ * Indica si el tooltip se cierra con escape. Valor por defecto: true.
837
+ */
838
+ closeOnEscape?: boolean;
839
+ /**
840
+ * Indica si el tooltip se cierra al desplazar el puntero del mouse fuera del
841
+ * tooltip. Valor por defecto: true.
842
+ */
843
+ closeOnMouseLeaveTooltip?: boolean;
844
+ /**
845
+ * Indica si el tooltip se cierra al desplazar el puntero del mouse fuera del
846
+ * elemento al que el tooltip está anclado. Valor por defecto: true.
847
+ */
848
+ closeOnMouseLeaveAttachedElement?: boolean;
849
+ /**
850
+ * Indica si el tooltip se cierra al hacerle click. Valor por defecto: false.
851
+ */
852
+ closeOnClick?: boolean;
853
+ /**
854
+ * Indica si el tooltip se cierra al hacer click fuera de él. Valor por
855
+ * defecto: true.
856
+ */
857
+ closeOnClickOut?: boolean;
858
+ /**
859
+ * Indica si el tooltip se cierra al hacer scroll en un elemento externo al
860
+ * tooltip. Valor por defecto: true.
861
+ */
862
+ closeOnScrollOut?: boolean;
863
+ /**
864
+ * Permite determinar sobre qué elemento se abre el tooltip
865
+ */
866
+ attachToElement?: TAttachToElement;
867
+ /**
868
+ * Cuando se desea hacer attach a un elemento, es posible posicionar el menú
869
+ * en cualquiera de los cuatro vétices definidos por el box que lo contiene o
870
+ * bien ubicarlo exactamente en el centro.
871
+ *
872
+ * Por defecto se colocará en topRight.
873
+ *
874
+ * Además el tooltip se extenderá según la orientación definida en los
875
+ * parámetros preferredOrientationX y preferredOrientationY.
876
+ */
877
+ attachToElementAnchorPoint?: TAttachToElementAnchorPoint;
878
+ /**
879
+ * Permite indicar que el tooltip se abrirá en un punto específico. En caso
880
+ * de no indicar anchorPoint ni attachToElement se abrirá en {0,0}
881
+ */
882
+ anchorPoint?: TPosition;
883
+ /**
884
+ * El minSize define el espacio mínimo que debe existir para mostrar el
885
+ * tooltip. En caso de que en la orientación definida no exista espacio
886
+ * suficiente, el tooltip se mostrará en otra orientación que si lo permita.
887
+ */
888
+ minSize?: TSize;
889
+ /**
890
+ * El preferredSize define el espacio deseado que debería ocupar el tooltip.
891
+ * En caso de no haber espacio suficiente para cubrir este espacio en la
892
+ * orientación definida, se cubrirá todo el espacio disponible, siempre y
893
+ * cuando sea mayor o igual que minSize, en cuyo caso entrará en juego el
894
+ * comportamiento de minSize.
895
+ *
896
+ * Por defecto usa { height: 'auto', width: 'auto' }.
897
+ */
898
+ preferredSize?: TSizeWithAuto;
899
+ /**
900
+ * Posición en la que el tooltip se muestra en caso de que haya espacio
901
+ * suficiente, por defecto usa right.
902
+ */
903
+ preferredOrientationX?: TPreferredOrientationX;
904
+ /**
905
+ * Posición en la que el tooltip se muestra en caso de que haya espacio
906
+ * suficiente, por defecto usa bottom.
907
+ */
908
+ preferredOrientationY?: TPreferredOrientationY;
909
+ /**
910
+ * Permite agregar classNames al box contenedor.
911
+ */
912
+ className?: string;
913
+ /**
914
+ * Será llamado cuando el tooltip sea cerrado.
915
+ */
916
+ onClose?: () => unknown;
917
+ /**
918
+ * Variante del box contenedor. Por defecto usa
919
+ * layout.common.tooltips.primary.
920
+ */
921
+ variant?: string;
922
+ };
923
+
924
+ type TTooltipEvents = {
925
+ open: TTooltip;
926
+ close: void;
927
+ };
928
+ declare const tooltipsHandler: <K extends keyof TTooltipEvents>(ev: K, args: TTooltipEvents[K]) => void;
929
+ declare const TooltipsProvider: React$1.FC<object>;
930
+ declare function useTooltip(tooltip?: TTooltip): {
931
+ close: () => void;
932
+ open: (otherProps?: Partial<TTooltip>) => void;
933
+ toggle: (otherProps?: Partial<TTooltip>) => void;
934
+ };
722
935
 
723
- export { CalendarModal, Checkbox, Confirm, DateInput, DialogButtonBar, FieldErrorMessage, ICalendarModal, IConfirm, IDialogButtonBar, IDialogHeader, IField, IFieldErrorMessage, IIconInput, IOverlay, IRequiredMark, ISimpleButton, IconButton, IconInput, LinearLoader, Modal, ModalContext, NumberInput, Overlay, ProgressBar, RequiredMark, ScreenLock, SimpleButton, TApiaIconButton, TCheckbox, TDateProps, TIconButton, TIconSize, TModal, TModalContext, TNumberInput, TNumberInputChangeEvent, TUseModalConfiguration, focus, forceScreenLock, forceWhiteScreen, getConfirmButton, getFieldErrorStyles, getFieldTouchedStyles, hasReleasedScreenLock, isCurrentlyLocked, lockController, lockScreen, onScreenLockReady, onScreenLockReleasedFirstTime, parseNumberInputValueToNumber, parseNumberValueToNumberInput, releaseScreenLock, unlockScreen, useModal, useScreenLock };
936
+ export { ApiaFilter, BaseButton, CalendarModal, Captcha, Checkbox, CollapsiblePanel, Confirm, DateInput, DialogButtonBar, FieldErrorMessage, IApiaFilter, ICalendarModal, IConfirm, IDialogButtonBar, IDialogHeader, IField, IFieldErrorMessage, IIconInput, IOverlay, IRequiredMark, ISimpleButton, IconButton, IconInput, IconsList, LinearLoader, Listbox, ListboxItem, Modal, ModalContext, NumberInput, Overlay, ProgressBar, RequiredMark, ScreenLock, SimpleButton, TApiaButtonType, TApiaIconButton, TCheckbox, TDateProps, TIcon, TIconButton, TIconRenderer, TIconSize, TIconsList, TListbox, TModal, TModalContext, TModalSize, TNumberInput, TNumberInputChangeEvent, TOnClickNode, TOnConfirmSelection, TOnSelectionChange, TTooltipEvents, TUseModalConfiguration, TooltipsProvider, WaiTypeAhead, getConfirmButton, getFieldErrorStyles, getFieldTouchedStyles, makeResponsiveComponent, parseNumberInputValueToNumber, parseNumberValueToNumberInput, tooltipsHandler, useModal, useOtherTagButton, useTooltip };
937
+ //# sourceMappingURL=index.d.ts.map