@apia/components 0.2.4 → 0.3.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 +138 -60
- package/dist/index.js +1340 -906
- package/dist/index.js.map +1 -1
- package/package.json +8 -8
package/dist/index.d.ts
CHANGED
|
@@ -1,10 +1,36 @@
|
|
|
1
1
|
import * as React$1 from 'react';
|
|
2
|
-
import React__default, { ReactNode, FC, ChangeEventHandler, MouseEvent, KeyboardEvent, FunctionComponent, ForwardedRef, ComponentType, RefObject } from 'react';
|
|
2
|
+
import React__default, { ReactNode, FC, Ref, ChangeEventHandler, MouseEvent, KeyboardEvent, FunctionComponent, ForwardedRef, ComponentType, RefObject } from 'react';
|
|
3
3
|
import { TId, TApiaFilter, TApiaFilterValue, TModify, IOnFocusConfiguration, TFocusRetriever, EventEmitter } from '@apia/util';
|
|
4
4
|
import { TIconName, TIconType } from '@apia/icons';
|
|
5
5
|
import { ThemeUIStyleObject, IconButtonProps, ButtonProps, InputProps, ThemeUICSSObject, BoxProps } from '@apia/theme';
|
|
6
6
|
import { Args } from 'react-cool-portal';
|
|
7
7
|
|
|
8
|
+
interface IAccordionItemButton {
|
|
9
|
+
ariaLabel: string;
|
|
10
|
+
/**
|
|
11
|
+
* Si checked !== undefined => se mostrará un checkbox.
|
|
12
|
+
*/
|
|
13
|
+
checked?: boolean;
|
|
14
|
+
/**
|
|
15
|
+
* Solamente se utiliza en conjunto con el checkbox y permite evitar que el
|
|
16
|
+
* usuario pueda marcar o desmarcar el checkbox.
|
|
17
|
+
*/
|
|
18
|
+
disableSelection?: boolean;
|
|
19
|
+
label: string;
|
|
20
|
+
/**
|
|
21
|
+
* Evento que se dispara cuando el usuario hace click en el checkbox o
|
|
22
|
+
* presiona espacio sobre el botón del acordeón.
|
|
23
|
+
*/
|
|
24
|
+
onChange?: (checked: boolean) => unknown;
|
|
25
|
+
rightIcons?: TIconName[] | TIconName;
|
|
26
|
+
tabIndex?: number;
|
|
27
|
+
/**
|
|
28
|
+
* Si no se pasa title se usará ariaLabel.
|
|
29
|
+
*/
|
|
30
|
+
title?: string;
|
|
31
|
+
}
|
|
32
|
+
declare const DefaultAccordionItemButton: (props: IAccordionItemButton) => React$1.JSX.Element;
|
|
33
|
+
|
|
8
34
|
interface IAccordionProps {
|
|
9
35
|
/**
|
|
10
36
|
* Tiempo en ms que dura la animación. Por defecto se usa 150.
|
|
@@ -20,23 +46,23 @@ interface IAccordionProps {
|
|
|
20
46
|
}
|
|
21
47
|
declare const Accordion: FC<IAccordionProps>;
|
|
22
48
|
|
|
23
|
-
type TItemState = {
|
|
49
|
+
type TItemState$1 = {
|
|
24
50
|
isChecked: boolean;
|
|
25
51
|
isExpanded: boolean;
|
|
26
52
|
};
|
|
27
|
-
type TItemStateListener = (state: TItemState) => unknown;
|
|
53
|
+
type TItemStateListener = (state: TItemState$1) => unknown;
|
|
28
54
|
type TPropsListener = (props: IAccordionProps) => unknown;
|
|
29
55
|
|
|
30
56
|
type TSelectionComparator<T> = (prev: T, next: T) => boolean;
|
|
31
|
-
type TItemUpdater = Partial<TItemState> | ((currentProps: TItemState) => Partial<TItemState>);
|
|
57
|
+
type TItemUpdater = Partial<TItemState$1> | ((currentProps: TItemState$1) => Partial<TItemState$1>);
|
|
32
58
|
declare class AccordionHandler {
|
|
33
59
|
id: string;
|
|
34
60
|
props: IAccordionProps;
|
|
35
|
-
itemsState: Record<TId, TItemState>;
|
|
61
|
+
itemsState: Record<TId, TItemState$1>;
|
|
36
62
|
itemsStateListeners: Record<TId, TItemStateListener[]>;
|
|
37
63
|
propsListeners: TPropsListener[];
|
|
38
64
|
constructor(id: string, props: IAccordionProps);
|
|
39
|
-
registerItem(itemId: TId, initialState: TItemState): void;
|
|
65
|
+
registerItem(itemId: TId, initialState: TItemState$1): void;
|
|
40
66
|
toggleItem(itemId: TId, isExpanded: boolean): void;
|
|
41
67
|
unregisterItem(itemId: TId): void;
|
|
42
68
|
/**
|
|
@@ -52,37 +78,13 @@ declare class AccordionHandler {
|
|
|
52
78
|
children: ReactNode;
|
|
53
79
|
}) => React$1.JSX.Element;
|
|
54
80
|
useItemId: () => TId;
|
|
55
|
-
useItemStateSelector: <T>(selector: (props: TItemState) => T, comparator?: TSelectionComparator<T>) => T;
|
|
81
|
+
useItemStateSelector: <T>(selector: (props: TItemState$1) => T, comparator?: TSelectionComparator<T>) => T;
|
|
56
82
|
useItemStateUpdate: (cb: TItemStateListener) => void;
|
|
57
83
|
usePropsSelector: <T_1>(selector: (props: IAccordionProps) => T_1, comparator?: TSelectionComparator<T_1>) => T_1;
|
|
58
84
|
usePropsUpdate: (cb: TPropsListener) => void;
|
|
59
85
|
};
|
|
60
86
|
}
|
|
61
87
|
|
|
62
|
-
interface IAccordionItemButton {
|
|
63
|
-
ariaLabel: string;
|
|
64
|
-
/**
|
|
65
|
-
* Si checked !== undefined => se mostrará un checkbox.
|
|
66
|
-
*/
|
|
67
|
-
checked?: boolean;
|
|
68
|
-
/**
|
|
69
|
-
* Solamente se utiliza en conjunto con el checkbox y permite evitar que el
|
|
70
|
-
* usuario pueda marcar o desmarcar el checkbox.
|
|
71
|
-
*/
|
|
72
|
-
disableSelection?: boolean;
|
|
73
|
-
label: string;
|
|
74
|
-
/**
|
|
75
|
-
* Evento que se dispara cuando el usuario hace click en el checkbox o
|
|
76
|
-
* presiona espacio sobre el botón del acordeón.
|
|
77
|
-
*/
|
|
78
|
-
onChange?: (checked: boolean) => unknown;
|
|
79
|
-
rightIcons?: TIconName[] | TIconName;
|
|
80
|
-
/**
|
|
81
|
-
* Si no se pasa title se usará ariaLabel.
|
|
82
|
-
*/
|
|
83
|
-
title?: string;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
88
|
interface IAccordionItemProps {
|
|
87
89
|
/**
|
|
88
90
|
* Cada elemento del acordeón tiene dos formas de renderizar el botón. O bien
|
|
@@ -135,9 +137,36 @@ interface ICollapsiblePanel {
|
|
|
135
137
|
|
|
136
138
|
declare const CollapsiblePanel: React__default.ForwardRefExoticComponent<ICollapsiblePanel & React__default.RefAttributes<HTMLDivElement>>;
|
|
137
139
|
|
|
140
|
+
interface IAlert {
|
|
141
|
+
children: React.ReactNode;
|
|
142
|
+
onClose: () => void;
|
|
143
|
+
title?: string;
|
|
144
|
+
}
|
|
145
|
+
declare const AlertModal: ({ children, onClose, title }: IAlert) => React$1.JSX.Element;
|
|
146
|
+
|
|
138
147
|
type TModalSize = 'editGrid' | 'sm' | 'md' | 'md-fixed' | 'lg' | 'lg-fixed' | 'xl' | 'xl-fixed' | 'xxl' | 'xxxl' | 'xxxl-fixed' | 'flex' | 'cal' | 'finder';
|
|
139
148
|
type TApiaButtonType = 'primary' | 'primary-sm' | 'secondary' | 'light-secondary' | 'secondary-sm' | 'danger' | 'danger-sm' | 'outline' | 'outline-sm' | 'warning' | 'warning-sm' | 'link';
|
|
140
149
|
|
|
150
|
+
interface IConfirm {
|
|
151
|
+
additionalButtons?: ReactNode;
|
|
152
|
+
additionalButtonsOnRight?: ReactNode;
|
|
153
|
+
cancelButtonText?: string;
|
|
154
|
+
children: ReactNode;
|
|
155
|
+
className?: string;
|
|
156
|
+
confirmButtonText?: string;
|
|
157
|
+
confirmButtonVariant?: TApiaButtonType;
|
|
158
|
+
contentRef?: Ref<HTMLDivElement>;
|
|
159
|
+
disabled?: boolean;
|
|
160
|
+
hideCancelButton?: boolean;
|
|
161
|
+
hideConfirmButton?: boolean;
|
|
162
|
+
isLoading?: boolean;
|
|
163
|
+
onConfirm?: () => unknown;
|
|
164
|
+
onCancel?: () => unknown;
|
|
165
|
+
title?: string;
|
|
166
|
+
variant?: string;
|
|
167
|
+
}
|
|
168
|
+
declare const ConfirmModal: ({ onConfirm, onCancel, title, ...props }: IConfirm) => JSX.Element;
|
|
169
|
+
|
|
141
170
|
interface IBaseButton {
|
|
142
171
|
text?: string;
|
|
143
172
|
children?: string;
|
|
@@ -392,7 +421,7 @@ declare const FieldLabel: React$1.ForwardRefExoticComponent<{
|
|
|
392
421
|
} & BoxProps & React$1.RefAttributes<HTMLDivElement>>;
|
|
393
422
|
|
|
394
423
|
type TListboxItem = {
|
|
395
|
-
children
|
|
424
|
+
children?: ReactNode;
|
|
396
425
|
rowIndex?: number;
|
|
397
426
|
} & BoxProps & {
|
|
398
427
|
/**
|
|
@@ -760,31 +789,7 @@ declare function useModal(configuration?: TUseModalConfiguration): {
|
|
|
760
789
|
show: () => void;
|
|
761
790
|
};
|
|
762
791
|
|
|
763
|
-
declare
|
|
764
|
-
interface Window {
|
|
765
|
-
BTN_CONFIRM: string;
|
|
766
|
-
BTN_CANCEL: string;
|
|
767
|
-
}
|
|
768
|
-
}
|
|
769
|
-
declare function getConfirmButton(ref: HTMLElement): HTMLElement;
|
|
770
|
-
interface IConfirm {
|
|
771
|
-
additionalButtons?: React$1.ReactNode;
|
|
772
|
-
additionalButtonsOnRight?: React$1.ReactNode;
|
|
773
|
-
cancelButtonText?: string;
|
|
774
|
-
children: React$1.ReactNode;
|
|
775
|
-
className?: string;
|
|
776
|
-
confirmButtonText?: string;
|
|
777
|
-
confirmButtonVariant?: TApiaButtonType;
|
|
778
|
-
contentRef?: React$1.Ref<HTMLDivElement>;
|
|
779
|
-
disabled?: boolean;
|
|
780
|
-
hideCancelButton?: boolean;
|
|
781
|
-
hideConfirmButton?: boolean;
|
|
782
|
-
isLoading?: boolean;
|
|
783
|
-
onConfirm?: (ev: React$1.MouseEvent) => unknown;
|
|
784
|
-
onCancel?: (ev: React$1.MouseEvent) => unknown;
|
|
785
|
-
variant?: string;
|
|
786
|
-
}
|
|
787
|
-
declare const Confirm: React$1.FC<IConfirm>;
|
|
792
|
+
declare const Confirm: ({ children, additionalButtons, additionalButtonsOnRight, cancelButtonText: cancelText, className, confirmButtonText: confirmText, confirmButtonVariant, contentRef, disabled, hideCancelButton, hideConfirmButton, isLoading, onCancel, onConfirm, variant, }: Omit<IConfirm, 'title'>) => React$1.JSX.Element;
|
|
788
793
|
|
|
789
794
|
interface IDialogButtonBar {
|
|
790
795
|
children: React$1.ReactNode;
|
|
@@ -819,8 +824,20 @@ declare global {
|
|
|
819
824
|
*/
|
|
820
825
|
declare const ScreenLock: () => React__default.JSX.Element | null;
|
|
821
826
|
|
|
822
|
-
declare const AutoEllipsis: ({ children }: {
|
|
827
|
+
declare const AutoEllipsis: ({ children, findParent, overrideStyles, }: {
|
|
823
828
|
children: ReactNode;
|
|
829
|
+
/**
|
|
830
|
+
* Si se pasa el método findParent, será invocado con el nodo de AutoEllipsis
|
|
831
|
+
* para dar control sobre cuál es el elemento al que se le clonarán los
|
|
832
|
+
* estilos.
|
|
833
|
+
*/
|
|
834
|
+
findParent?: ((currentElement: HTMLElement) => HTMLElement) | undefined;
|
|
835
|
+
/**
|
|
836
|
+
* Si se pasa overrideStyles, será invocado con el nodo actual de
|
|
837
|
+
* AutoEllipsis para tomar decisiones acerca de cuáles estilos serán
|
|
838
|
+
* aplicados.
|
|
839
|
+
*/
|
|
840
|
+
overrideStyles?: ((currentElement: HTMLElement) => Partial<CSSStyleDeclaration>) | undefined;
|
|
824
841
|
}) => React$1.JSX.Element;
|
|
825
842
|
|
|
826
843
|
interface IMakeResponsiveComponent<P extends Record<string, unknown>> {
|
|
@@ -853,7 +870,7 @@ interface IResponsiveComponent<P> extends FC<P> {
|
|
|
853
870
|
* poder tomar decisiones de responsividad que no dependen del ancho de la
|
|
854
871
|
* pantalla sino del espacio donde se encuentra.
|
|
855
872
|
*/
|
|
856
|
-
declare const makeResponsiveComponent: <P extends Record<string, unknown>>({ breakPoints, Component,
|
|
873
|
+
declare const makeResponsiveComponent: <P extends Record<string, unknown>>({ breakPoints, Component, defaultBreakpoint, }: IMakeResponsiveComponent<P>) => IResponsiveComponent<P & {
|
|
857
874
|
breakPoints?: number[] | undefined;
|
|
858
875
|
}>;
|
|
859
876
|
|
|
@@ -994,6 +1011,67 @@ declare const IconsList: {
|
|
|
994
1011
|
|
|
995
1012
|
declare function importComponent<T = unknown>(path: string): React$1.LazyExoticComponent<ComponentType<T>>;
|
|
996
1013
|
|
|
1014
|
+
type TToolEventState = {
|
|
1015
|
+
isToggled: boolean;
|
|
1016
|
+
};
|
|
1017
|
+
type TSeparator = {
|
|
1018
|
+
separator: true;
|
|
1019
|
+
};
|
|
1020
|
+
type TToolDefinition = {
|
|
1021
|
+
action: (props: TToolEventState) => unknown;
|
|
1022
|
+
/**
|
|
1023
|
+
* Si se pasa allowToggle y no se pasa toggled ( ni en true ni en false ),
|
|
1024
|
+
* entonces el estado de toggle será controlado internamente en el toolbar
|
|
1025
|
+
*/
|
|
1026
|
+
allowToggle?: boolean;
|
|
1027
|
+
/**
|
|
1028
|
+
* Si se desea usar defaultToggled, debería pasarse también allowToggle
|
|
1029
|
+
*/
|
|
1030
|
+
defaultToggled?: boolean;
|
|
1031
|
+
disabled?: boolean;
|
|
1032
|
+
icon: TIconType | TIconName;
|
|
1033
|
+
id: string;
|
|
1034
|
+
title: string;
|
|
1035
|
+
iconSize?: 'Xs' | 'Sm' | 'Md' | 'Lg' | 'Xl' | undefined;
|
|
1036
|
+
/**
|
|
1037
|
+
* Siempre que se pase toggled, no importa si en true o en false, el
|
|
1038
|
+
* usuario del toolbar deberá mantener la lógica de persistencia del
|
|
1039
|
+
* toggle
|
|
1040
|
+
*/
|
|
1041
|
+
toggled?: boolean;
|
|
1042
|
+
};
|
|
1043
|
+
type TTool = TToolDefinition | TSeparator;
|
|
1044
|
+
|
|
1045
|
+
type TClickListener = () => unknown;
|
|
1046
|
+
type TItemState = Pick<TToolDefinition, 'disabled' | 'toggled'>;
|
|
1047
|
+
declare class ToolbarController extends EventEmitter<{
|
|
1048
|
+
pressEnter: string;
|
|
1049
|
+
updateItemState: string;
|
|
1050
|
+
}> {
|
|
1051
|
+
eventListeners: Record<string, TClickListener[]>;
|
|
1052
|
+
itemsState: Record<string, TItemState>;
|
|
1053
|
+
hooks: {
|
|
1054
|
+
useItemState: (id: string, initialState: TItemState) => TItemState;
|
|
1055
|
+
};
|
|
1056
|
+
setItemState: (id: string, newState: Partial<TItemState>) => void;
|
|
1057
|
+
Context: ({ children }: {
|
|
1058
|
+
children: ReactNode;
|
|
1059
|
+
}) => React$1.JSX.Element;
|
|
1060
|
+
}
|
|
1061
|
+
|
|
1062
|
+
declare const ToolbarItem: (props: TTool) => React$1.JSX.Element;
|
|
1063
|
+
|
|
1064
|
+
declare const Toolbar: ((props: {
|
|
1065
|
+
children: ReactNode;
|
|
1066
|
+
/**
|
|
1067
|
+
* El controlador permite gestionar el estado de los distintos elementos de
|
|
1068
|
+
* la toolbar
|
|
1069
|
+
*/
|
|
1070
|
+
getController?: ((newController: ToolbarController) => unknown) | undefined;
|
|
1071
|
+
}) => React$1.JSX.Element) & {
|
|
1072
|
+
displayName: string;
|
|
1073
|
+
};
|
|
1074
|
+
|
|
997
1075
|
type TAttachToElement = (() => HTMLElement) | RefObject<HTMLElement>;
|
|
998
1076
|
type TPreferredOrientationX = 'left' | 'right';
|
|
999
1077
|
type TPreferredOrientationY = 'top' | 'bottom';
|
|
@@ -1114,4 +1192,4 @@ declare function useTooltip(tooltip?: TTooltip): {
|
|
|
1114
1192
|
toggle: (otherProps?: Partial<TTooltip>) => void;
|
|
1115
1193
|
};
|
|
1116
1194
|
|
|
1117
|
-
export { Accordion, AccordionContext, AccordionItem, AccordionItemButton, AccordionItemContent, AccordionItemContext, ApiaFilter, AutoEllipsis, BaseButton, CalendarModal, Captcha, Checkbox, CollapsiblePanel, Confirm, DateInput, DialogButtonBar, FieldErrorMessage, FieldLabel, IAccordionItemProps, IAccordionProps, IApiaFilter, ICalendarModal, IConfirm, IDialogButtonBar, IDialogHeader, IField, IFieldErrorMessage, IIconInput, IOverlay, IRequiredMark, IResponsiveComponent, ISimpleButton, IconButton, IconInput, IconsList, LinearLoader, Listbox, ListboxItem, LoaderSpinner, Modal, ModalContext, NumberInput, Overlay, ProgressBar, RequiredMark, ScreenLock, SimpleButton, TAccordionHandler, TAccordionItemButton, TApiaButtonType, TApiaIconButton, TCheckbox, TDateProps, TFieldLabel, TIcon, TIconButton, TIconRenderer, TIconSize, TIconsList, TListbox, TModal, TModalContext, TModalSize, TNumberInput, TNumberInputChangeEvent, TOnClickNode, TOnConfirmSelection, TOnSelectionChange, TTooltip, TTooltipEvents, TUseModalConfiguration, TooltipsProvider, WaiTypeAhead,
|
|
1195
|
+
export { Accordion, AccordionContext, AccordionItem, AccordionItemButton, AccordionItemContent, AccordionItemContext, AlertModal, ApiaFilter, AutoEllipsis, BaseButton, CalendarModal, Captcha, Checkbox, CollapsiblePanel, Confirm, ConfirmModal, DateInput, DefaultAccordionItemButton, DialogButtonBar, FieldErrorMessage, FieldLabel, IAccordionItemProps, IAccordionProps, IAlert, IApiaFilter, ICalendarModal, IConfirm, IDialogButtonBar, IDialogHeader, IField, IFieldErrorMessage, IIconInput, IOverlay, IRequiredMark, IResponsiveComponent, ISimpleButton, IconButton, IconInput, IconsList, LinearLoader, Listbox, ListboxItem, LoaderSpinner, Modal, ModalContext, NumberInput, Overlay, ProgressBar, RequiredMark, ScreenLock, SimpleButton, TAccordionHandler, TAccordionItemButton, TApiaButtonType, TApiaIconButton, TCheckbox, TDateProps, TFieldLabel, TIcon, TIconButton, TIconRenderer, TIconSize, TIconsList, TListbox, TModal, TModalContext, TModalSize, TNumberInput, TNumberInputChangeEvent, TOnClickNode, TOnConfirmSelection, TOnSelectionChange, TTool, TTooltip, TTooltipEvents, TUseModalConfiguration, Toolbar, ToolbarController, ToolbarItem, TooltipsProvider, WaiTypeAhead, getFieldErrorStyles, getFieldTouchedStyles, importComponent, makeResponsiveComponent, parseNumberInputValueToNumber, parseNumberValueToNumberInput, tooltipsHandler, useAccordionContext, useModal, useOtherTagButton, useTooltip };
|