@dragunio/fe-libs 0.1.8 → 0.1.9

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,6 +1,6 @@
1
1
  import * as react from 'react';
2
- import { ButtonHTMLAttributes, ReactNode, HTMLAttributes, MouseEvent, KeyboardEvent, TableHTMLAttributes, InputHTMLAttributes, TextareaHTMLAttributes, KeyboardEventHandler, ChangeEvent, ReactElement } from 'react';
3
- export { ChevronDownIcon, ChevronUpIcon, CloseIcon, IconProps, MoreHorizontalIcon, MoreVerticalIcon, PlusIcon, SearchIcon, arrow_left, check_square_fill, chevron_down, chevron_left, chevron_right, chevron_up, copy, key, lock, lock_unlocked, log_out, minus_square, plus, plus_square, search, trash, x_close } from './icons.js';
2
+ import { ButtonHTMLAttributes, ReactNode, HTMLAttributes, MouseEvent, KeyboardEvent, TableHTMLAttributes, InputHTMLAttributes, RefObject, TextareaHTMLAttributes, KeyboardEventHandler, ChangeEvent, ReactElement } from 'react';
3
+ export { ChevronDownIcon, ChevronUpIcon, CloseIcon, EyeIcon, EyeOffIcon, IconProps, MailboxIcon, MoreHorizontalIcon, MoreVerticalIcon, PhoneIcon, PlusIcon, SearchIcon, arrow_left, check_square_fill, chevron_down, chevron_left, chevron_right, chevron_up, copy, key, lock, lock_unlocked, log_out, minus_square, plus, plus_square, search, trash, x_close } from './icons.js';
4
4
 
5
5
  type ButtonHierarchy = 'primary' | 'secondary-gray' | 'secondary-color' | 'tertiary-gray' | 'tertiary-color';
6
6
  type ButtonSize = '24' | '32' | '40';
@@ -183,22 +183,39 @@ declare const Toggle: react.ForwardRefExoticComponent<Omit<InputHTMLAttributes<H
183
183
  labelPosition?: "top" | "right";
184
184
  } & react.RefAttributes<HTMLInputElement>>;
185
185
 
186
+ type DrawerSide = 'left' | 'right' | 'top' | 'bottom';
187
+ /** Named width presets for left and right drawers. */
188
+ declare const DrawerWidths: {
189
+ readonly small: 360;
190
+ readonly medium: 400;
191
+ readonly large: 480;
192
+ };
193
+ type DrawerWidthPreset = (typeof DrawerWidths)[keyof typeof DrawerWidths];
194
+ type DrawerWidth = DrawerWidthPreset | number | string;
186
195
  type DrawerProps = Omit<HTMLAttributes<HTMLElement>, 'title'> & {
187
196
  open: boolean;
188
197
  onClose: () => void;
189
198
  title?: ReactNode;
199
+ description?: ReactNode;
190
200
  /** Optional content pinned below the scrollable body. */
191
201
  footer?: ReactNode;
192
- side?: 'left' | 'right' | 'top' | 'bottom';
193
- /** Width of a left/right drawer. Defaults to 400px. */
194
- width?: number | string;
202
+ side?: DrawerSide;
203
+ /** Width of a left/right drawer. Use DrawerWidths presets or any CSS width. Defaults to DrawerWidths.medium (400px). */
204
+ width?: DrawerWidth;
195
205
  /** Makes the panel fill the entire viewport while retaining the chosen entrance direction. */
196
206
  fullScreen?: boolean;
197
207
  children?: ReactNode;
198
208
  closeOnBackdropClick?: boolean;
209
+ /** Allows Escape to request closing the drawer. Defaults to true. */
210
+ closeOnEscape?: boolean;
211
+ closeLabel?: string;
212
+ /** Element that receives focus when the drawer opens. The dialog itself is focused by default. */
213
+ initialFocusRef?: RefObject<HTMLElement | null>;
214
+ /** Restores focus to the opener after closing. Defaults to true. */
215
+ restoreFocus?: boolean;
199
216
  };
200
217
  /** A modal panel with fixed header/footer regions and a scrollable body. */
201
- declare function Drawer({ open, onClose, title, footer, side, width, fullScreen, children, closeOnBackdropClick, className, style, ...props }: DrawerProps): react.ReactPortal | null;
218
+ declare function Drawer({ open, onClose, title, description, footer, side, width, fullScreen, children, closeOnBackdropClick, closeOnEscape, closeLabel, initialFocusRef, restoreFocus, className, style, 'aria-label': ariaLabel, 'aria-describedby': ariaDescribedBy, ...props }: DrawerProps): react.ReactPortal | null;
202
219
 
203
220
  type FieldError = boolean | ReactNode;
204
221
  type DescriptionDisplay = 'inline' | 'tooltip';
@@ -251,6 +268,63 @@ type TextInputProps = Omit<InputHTMLAttributes<HTMLInputElement>, 'size' | 'valu
251
268
  Suffix?: ReactNode;
252
269
  };
253
270
 
271
+ /**
272
+ * Return a message (or `false`) to mark a value invalid. Return `undefined`,
273
+ * `null`, or `true` when the value is valid.
274
+ */
275
+ type InputValidator = (value: string) => string | boolean | null | undefined;
276
+ type ValidationTiming = 'blur' | 'change';
277
+ /** Shared public props for inputs with built-in format validation. */
278
+ type ValidatedTextInputProps = Omit<TextInputProps, 'type' | 'prefix' | 'suffix' | 'Prefix' | 'Suffix'> & {
279
+ /**
280
+ * Extra validation run after the built-in format check. Return an error
281
+ * message (or `false`) when invalid.
282
+ */
283
+ validate?: InputValidator;
284
+ /** When validation runs. It runs on blur by default. */
285
+ validateOn?: ValidationTiming;
286
+ };
287
+
288
+ declare function validateEmail(value: string, required?: boolean): string | undefined;
289
+ declare function validatePassword(value: string, required?: boolean): string | undefined;
290
+ declare function validatePhoneNumber(value: string, required?: boolean): string | undefined;
291
+ declare function normalizePhoneNumber(value: string): string;
292
+
293
+ /** An email field with a mailbox prefix and built-in format validation. */
294
+ declare const EmailInput: react.ForwardRefExoticComponent<Omit<TextInputProps, "prefix" | "type" | "suffix" | "Prefix" | "Suffix"> & {
295
+ validate?: InputValidator;
296
+ validateOn?: ValidationTiming;
297
+ } & react.RefAttributes<HTMLInputElement>>;
298
+
299
+ type EmailInputProps = ValidatedTextInputProps;
300
+
301
+ /** A password field with reveal/hide control and built-in strength validation. */
302
+ declare const PasswordInput: react.ForwardRefExoticComponent<Omit<TextInputProps, "prefix" | "type" | "suffix" | "Prefix" | "Suffix"> & {
303
+ validate?: InputValidator;
304
+ validateOn?: ValidationTiming;
305
+ } & {
306
+ showPasswordLabel?: string;
307
+ hidePasswordLabel?: string;
308
+ } & react.RefAttributes<HTMLInputElement>>;
309
+
310
+ type PasswordInputProps = ValidatedTextInputProps & {
311
+ /** Accessible label for the control that reveals the password. */
312
+ showPasswordLabel?: string;
313
+ /** Accessible label for the control that hides the password. */
314
+ hidePasswordLabel?: string;
315
+ };
316
+
317
+ /**
318
+ * A phone field that accepts digits, spaces, parentheses, and plus signs,
319
+ * with built-in digit-count validation.
320
+ */
321
+ declare const PhoneNumberInput: react.ForwardRefExoticComponent<Omit<TextInputProps, "prefix" | "type" | "suffix" | "Prefix" | "Suffix"> & {
322
+ validate?: InputValidator;
323
+ validateOn?: ValidationTiming;
324
+ } & react.RefAttributes<HTMLInputElement>>;
325
+
326
+ type PhoneNumberInputProps = ValidatedTextInputProps;
327
+
254
328
  /** A multi-line text field with helper/error text and a Button-powered clear action. */
255
329
  declare const TextArea: react.ForwardRefExoticComponent<Omit<react.TextareaHTMLAttributes<HTMLTextAreaElement>, "value" | "defaultValue"> & FieldBaseProps & {
256
330
  clearable?: boolean;
@@ -571,11 +645,17 @@ type ModalProps = Omit<HTMLAttributes<HTMLDivElement>, 'title'> & {
571
645
  actions?: ModalAction[];
572
646
  size?: ModalSize;
573
647
  closeOnBackdropClick?: boolean;
648
+ /** Allows Escape to request closing the modal. Defaults to true. */
649
+ closeOnEscape?: boolean;
574
650
  closeButton?: boolean;
575
651
  closeLabel?: string;
652
+ /** Element that receives focus when the modal opens. The dialog itself is focused by default. */
653
+ initialFocusRef?: RefObject<HTMLElement | null>;
654
+ /** Restores focus to the opener after closing. Defaults to true. */
655
+ restoreFocus?: boolean;
576
656
  };
577
657
  /** A centered, portal-based dialog with Button-powered close and footer actions. */
578
- declare function Modal({ open, onClose, title, description, children, footer, actions, size, closeOnBackdropClick, closeButton, closeLabel, className, ...props }: ModalProps): react.ReactPortal | null;
658
+ declare function Modal({ open, onClose, title, description, children, footer, actions, size, closeOnBackdropClick, closeOnEscape, closeButton, closeLabel, initialFocusRef, restoreFocus, className, 'aria-label': ariaLabel, 'aria-describedby': ariaDescribedBy, ...props }: ModalProps): react.ReactPortal | null;
579
659
 
580
660
  type ProgressBarSize = 'small' | 'medium' | 'large';
581
661
  type ProgressBarProps = HTMLAttributes<HTMLDivElement> & {
@@ -718,4 +798,143 @@ declare function Avatar({ src, content, alt, size, shape, fallbackIndex, classNa
718
798
  */
719
799
  declare function AvatarGroup({ children, maxCount, className, style, role, ...props }: AvatarGroupProps): react.JSX.Element;
720
800
 
721
- export { Avatar, AvatarGroup, type AvatarGroupProps, type AvatarProps, type AvatarShape, type AvatarSize, Button, ButtonBar, type ButtonBarAction, type ButtonBarItem, type ButtonBarProps, type ButtonColor, type ButtonHierarchy, type ButtonProps, type ButtonSize, type ButtonVariant, Checkbox, type CheckboxProps, Chip, type ChipProps, type ChipStatus, type ChipVariant, type ColumnResizeHandler, type ControlLabelPosition, type Currency, CurrencyInput, type CurrencyInputProps, type DateRange, DateTimePicker, type DateTimePickerProps, type DateTimePickerRangeProps, type DateTimePickerSingleProps, type DescriptionDisplay, Drawer, type DrawerProps, ExpandableSection, type ExpandableSectionProps, type FieldError, Loading, type LoadingProps, type LoadingSize, Message, type MessageOptions, type MessageProps, type MessageSeverity, Modal, type ModalAction, type ModalProps, type ModalSize, NumberInput, type NumberInputProps, Pagination, type PaginationProps, ProgressBar, type ProgressBarProps, type ProgressBarSize, RadioButton, type RadioButtonProps, RadioGroup, type RadioGroupOption, type RadioGroupProps, type RadioValue, Selection, type SelectionOption, type SelectionProps, type SelectionValue, Skeleton, SkeletonBox, type SkeletonBoxProps, SkeletonCircle, SkeletonLine, type SkeletonProps, type SkeletonSizeProps, SkeletonSquare, type SkeletonVariant, Snackbar, type SnackbarAnchorOrigin, type SnackbarProps, type TabChangeEvent, type TabItem, Table, TableBody, TableCaption, TableCell, type TableData, TableHead, TableHeader, type TablePaginationPosition, type TableProps, TableRow, Tabs, type TabsProps, type TabsScrollButtons, type TabsVariant, TextArea, type TextAreaProps, TextInput, type TextInputProps, Toggle, type ToggleProps, Tooltip, type TooltipProps, formatNumber, getIconSize, message };
801
+ type FileUploadRejectionCode = 'accept' | 'max-files' | 'max-size' | 'duplicate';
802
+ type FileUploadRejection = {
803
+ file: File;
804
+ code: FileUploadRejectionCode;
805
+ message: string;
806
+ };
807
+ /**
808
+ * Predefined file groups that FileUpload maps to native accept patterns and
809
+ * validates locally. Use `all` to leave the file picker unrestricted.
810
+ */
811
+ declare const FILE_UPLOAD_ACCEPTS: {
812
+ readonly all: readonly [];
813
+ readonly image: readonly ["image/*", ".avif", ".bmp", ".gif", ".heic", ".heif", ".ico", ".jpeg", ".jpg", ".png", ".svg", ".tif", ".tiff", ".webp"];
814
+ readonly pdf: readonly [".pdf"];
815
+ readonly word: readonly [".doc", ".docm", ".docx", ".dot", ".dotx", ".odt", ".rtf"];
816
+ readonly spreadsheet: readonly [".csv", ".ods", ".xls", ".xlsb", ".xlsm", ".xlsx"];
817
+ readonly presentation: readonly [".odp", ".pot", ".potx", ".pps", ".ppsx", ".ppt", ".pptx"];
818
+ readonly document: readonly [".pdf", ".doc", ".docm", ".docx", ".dot", ".dotx", ".odt", ".rtf", ".csv", ".xls", ".xlsb", ".xlsx", ".xlsm", ".ods", ".pot", ".potx", ".pps", ".ppsx", ".ppt", ".pptx", ".odp"];
819
+ readonly text: readonly [".log", ".md", ".rtf", ".text", ".txt"];
820
+ readonly csv: readonly [".csv"];
821
+ readonly json: readonly [".json"];
822
+ readonly xml: readonly [".xml"];
823
+ readonly code: readonly [".c", ".cpp", ".cs", ".css", ".go", ".html", ".java", ".js", ".jsx", ".php", ".py", ".rb", ".rs", ".scss", ".sh", ".sql", ".swift", ".ts", ".tsx", ".vue", ".yml", ".yaml"];
824
+ readonly archive: readonly [".7z", ".bz2", ".gz", ".rar", ".tar", ".tgz", ".xz", ".zip"];
825
+ readonly audio: readonly ["audio/*", ".aac", ".aiff", ".flac", ".m4a", ".mp3", ".ogg", ".opus", ".wav", ".wma"];
826
+ readonly video: readonly ["video/*", ".avi", ".mkv", ".mov", ".mp4", ".mpeg", ".mpg", ".webm", ".wmv"];
827
+ readonly font: readonly [".ttf", ".otf", ".woff", ".woff2"];
828
+ readonly email: readonly [".eml", ".msg"];
829
+ };
830
+ /** A predefined FileUpload group name. */
831
+ type FileUploadFileType = keyof typeof FILE_UPLOAD_ACCEPTS;
832
+ /** One or more predefined FileUpload file groups. */
833
+ type FileUploadAccept = FileUploadFileType | readonly FileUploadFileType[];
834
+ type FileUploadProps = Omit<HTMLAttributes<HTMLDivElement>, 'children' | 'onChange'> & {
835
+ /** Controlled files currently shown by the component. */
836
+ value?: readonly File[];
837
+ /** Initial files for uncontrolled use. */
838
+ defaultValue?: readonly File[];
839
+ /** Called synchronously whenever the accepted file list changes. */
840
+ onChange?: (files: File[]) => void;
841
+ /** Called with only the files accepted during one selection or drop. */
842
+ onAccept?: (files: File[]) => void;
843
+ /** Called with validation failures; no upload or API request is made. */
844
+ onReject?: (rejections: FileUploadRejection[]) => void;
845
+ /** Called before a file is removed from the list. */
846
+ onRemove?: (file: File, index: number) => void;
847
+ /** Predefined file group(s) used to select and validate files. */
848
+ accept?: FileUploadAccept;
849
+ /** Maximum bytes allowed for one file. Defaults to no limit. */
850
+ maxSize?: number;
851
+ /** Maximum files in the list. Defaults to no limit. */
852
+ maxFiles?: number;
853
+ multiple?: boolean;
854
+ disabled?: boolean;
855
+ /** Rejects files with the same name, size, and last-modified timestamp. */
856
+ preventDuplicate?: boolean;
857
+ label?: ReactNode;
858
+ description?: ReactNode;
859
+ dropLabel?: ReactNode;
860
+ browseLabel?: ReactNode;
861
+ removeLabel?: (file: File) => string;
862
+ /** Shows local image previews and file metadata below the drop zone. */
863
+ showFileList?: boolean;
864
+ inputProps?: Omit<InputHTMLAttributes<HTMLInputElement>, 'accept' | 'disabled' | 'multiple' | 'onChange' | 'type' | 'value'>;
865
+ };
866
+ declare function formatFileSize(bytes: number): string;
867
+ /**
868
+ * A local file picker and drop zone. It validates and emits browser File
869
+ * objects only; callers own all persistence, uploads, progress, and API work.
870
+ */
871
+ declare const FileUpload: react.ForwardRefExoticComponent<Omit<HTMLAttributes<HTMLDivElement>, "children" | "onChange"> & {
872
+ /** Controlled files currently shown by the component. */
873
+ value?: readonly File[];
874
+ /** Initial files for uncontrolled use. */
875
+ defaultValue?: readonly File[];
876
+ /** Called synchronously whenever the accepted file list changes. */
877
+ onChange?: (files: File[]) => void;
878
+ /** Called with only the files accepted during one selection or drop. */
879
+ onAccept?: (files: File[]) => void;
880
+ /** Called with validation failures; no upload or API request is made. */
881
+ onReject?: (rejections: FileUploadRejection[]) => void;
882
+ /** Called before a file is removed from the list. */
883
+ onRemove?: (file: File, index: number) => void;
884
+ /** Predefined file group(s) used to select and validate files. */
885
+ accept?: FileUploadAccept;
886
+ /** Maximum bytes allowed for one file. Defaults to no limit. */
887
+ maxSize?: number;
888
+ /** Maximum files in the list. Defaults to no limit. */
889
+ maxFiles?: number;
890
+ multiple?: boolean;
891
+ disabled?: boolean;
892
+ /** Rejects files with the same name, size, and last-modified timestamp. */
893
+ preventDuplicate?: boolean;
894
+ label?: ReactNode;
895
+ description?: ReactNode;
896
+ dropLabel?: ReactNode;
897
+ browseLabel?: ReactNode;
898
+ removeLabel?: (file: File) => string;
899
+ /** Shows local image previews and file metadata below the drop zone. */
900
+ showFileList?: boolean;
901
+ inputProps?: Omit<InputHTMLAttributes<HTMLInputElement>, "accept" | "disabled" | "multiple" | "onChange" | "type" | "value">;
902
+ } & react.RefAttributes<HTMLInputElement>>;
903
+
904
+ type FilePreviewKind = 'audio' | 'image' | 'pdf' | 'unsupported' | 'video';
905
+ type FilePreviewCloseReason = 'backdrop' | 'close' | 'escape';
906
+ type FilePreviewActionHandler = (file: File, index: number) => void;
907
+ type FilePreviewProps = Omit<HTMLAttributes<HTMLDivElement>, 'children' | 'onChange' | 'onClose'> & {
908
+ open: boolean;
909
+ files: readonly File[];
910
+ /** Controlled zero-based index of the file currently shown. */
911
+ activeIndex?: number;
912
+ /** Initial zero-based file index for uncontrolled use. */
913
+ defaultActiveIndex?: number;
914
+ /** Called after a previous/next control or Arrow key changes the active file. */
915
+ onActiveIndexChange?: (index: number, file: File) => void;
916
+ /** Called when the preview requests closing, including the reason. */
917
+ onClose: (reason: FilePreviewCloseReason) => void;
918
+ /** Called immediately before `onClose('escape')`. */
919
+ onEscape?: () => void;
920
+ /** Called when the Delete action is pressed. The owner removes files. */
921
+ onDelete?: FilePreviewActionHandler;
922
+ /** Called when the Download action is pressed, before the local browser download starts. */
923
+ onDownload?: FilePreviewActionHandler;
924
+ closeOnBackdropClick?: boolean;
925
+ closeOnEscape?: boolean;
926
+ closeLabel?: string;
927
+ downloadLabel?: ReactNode;
928
+ deleteLabel?: ReactNode;
929
+ /** Hides the local browser Download action. Defaults to false. */
930
+ hideDownload?: boolean;
931
+ };
932
+ /** Identifies browser-native previews supported by FilePreview. */
933
+ declare function getFilePreviewKind(file: File): FilePreviewKind;
934
+ /**
935
+ * A local File viewer with click and keyboard navigation. It makes no network
936
+ * request: deletion and download notifications always carry the active File.
937
+ */
938
+ declare function FilePreview({ open, files, activeIndex, defaultActiveIndex, onActiveIndexChange, onClose, onEscape, onDelete, onDownload, closeOnBackdropClick, closeOnEscape, closeLabel, downloadLabel, deleteLabel, hideDownload, className, 'aria-label': ariaLabel, ...props }: FilePreviewProps): react.ReactPortal | null;
939
+
940
+ export { Avatar, AvatarGroup, type AvatarGroupProps, type AvatarProps, type AvatarShape, type AvatarSize, Button, ButtonBar, type ButtonBarAction, type ButtonBarItem, type ButtonBarProps, type ButtonColor, type ButtonHierarchy, type ButtonProps, type ButtonSize, type ButtonVariant, Checkbox, type CheckboxProps, Chip, type ChipProps, type ChipStatus, type ChipVariant, type ColumnResizeHandler, type ControlLabelPosition, type Currency, CurrencyInput, type CurrencyInputProps, type DateRange, DateTimePicker, type DateTimePickerProps, type DateTimePickerRangeProps, type DateTimePickerSingleProps, type DescriptionDisplay, Drawer, type DrawerProps, type DrawerSide, type DrawerWidth, type DrawerWidthPreset, DrawerWidths, EmailInput, type EmailInputProps, ExpandableSection, type ExpandableSectionProps, FILE_UPLOAD_ACCEPTS, type FieldError, FilePreview, type FilePreviewActionHandler, type FilePreviewCloseReason, type FilePreviewKind, type FilePreviewProps, FileUpload, type FileUploadAccept, type FileUploadFileType, type FileUploadProps, type FileUploadRejection, type FileUploadRejectionCode, type InputValidator, Loading, type LoadingProps, type LoadingSize, Message, type MessageOptions, type MessageProps, type MessageSeverity, Modal, type ModalAction, type ModalProps, type ModalSize, NumberInput, type NumberInputProps, Pagination, type PaginationProps, PasswordInput, type PasswordInputProps, PhoneNumberInput, type PhoneNumberInputProps, ProgressBar, type ProgressBarProps, type ProgressBarSize, RadioButton, type RadioButtonProps, RadioGroup, type RadioGroupOption, type RadioGroupProps, type RadioValue, Selection, type SelectionOption, type SelectionProps, type SelectionValue, Skeleton, SkeletonBox, type SkeletonBoxProps, SkeletonCircle, SkeletonLine, type SkeletonProps, type SkeletonSizeProps, SkeletonSquare, type SkeletonVariant, Snackbar, type SnackbarAnchorOrigin, type SnackbarProps, type TabChangeEvent, type TabItem, Table, TableBody, TableCaption, TableCell, type TableData, TableHead, TableHeader, type TablePaginationPosition, type TableProps, TableRow, Tabs, type TabsProps, type TabsScrollButtons, type TabsVariant, TextArea, type TextAreaProps, TextInput, type TextInputProps, Toggle, type ToggleProps, Tooltip, type TooltipProps, type ValidatedTextInputProps, type ValidationTiming, formatFileSize, formatNumber, getFilePreviewKind, getIconSize, message, normalizePhoneNumber, validateEmail, validatePassword, validatePhoneNumber };