@dragunio/fe-libs 0.1.2 → 0.1.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/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import * as react from 'react';
2
- import { ButtonHTMLAttributes, ReactNode, SVGProps, TableHTMLAttributes, HTMLAttributes, InputHTMLAttributes, KeyboardEventHandler, ReactElement } from 'react';
2
+ import { ButtonHTMLAttributes, ReactNode, SVGProps, TableHTMLAttributes, HTMLAttributes, InputHTMLAttributes, KeyboardEventHandler, TextareaHTMLAttributes, ReactElement } from 'react';
3
3
 
4
4
  type ButtonHierarchy = 'primary' | 'secondary-gray' | 'secondary-color' | 'tertiary-gray' | 'tertiary-color';
5
5
  type ButtonSize = '24' | '32' | '40';
@@ -53,6 +53,7 @@ declare function SearchIcon(props: IconProps): react.JSX.Element;
53
53
 
54
54
  type TableData = readonly (readonly ReactNode[])[];
55
55
  type ColumnResizeHandler = (columnSizes: number[], columnIndex: number) => void;
56
+ type TablePaginationPosition = 'top-right' | 'bottom-right' | 'bottom-center' | 'middle-bottom';
56
57
  type TableProps = TableHTMLAttributes<HTMLTableElement> & {
57
58
  /** Enables alternating background colors for body rows. */
58
59
  striped?: boolean;
@@ -68,12 +69,24 @@ type TableProps = TableHTMLAttributes<HTMLTableElement> & {
68
69
  onColumnResize?: ColumnResizeHandler;
69
70
  /** Smallest width, in pixels, that a user can resize a column to. */
70
71
  minColumnWidth?: number;
72
+ /** Shows the built-in Pagination for data-driven tables. Enabled by pageSize as well. */
73
+ pagination?: boolean;
74
+ /** Number of data rows shown on each page. Defaults to 10 when pagination is enabled. */
75
+ pageSize?: number;
76
+ /** Controlled one-based page number. */
77
+ page?: number;
78
+ /** Initial page number for uncontrolled pagination. */
79
+ defaultPage?: number;
80
+ /** Called with the newly selected one-based page number. */
81
+ onPageChange?: (page: number) => void;
82
+ /** Location of the built-in Pagination. Defaults to bottom-right. */
83
+ paginationPosition?: TablePaginationPosition;
71
84
  };
72
85
  /**
73
86
  * A semantic table. Use its child primitives for custom markup, or pass headers
74
87
  * and data for an automatically sized, striped and resizable table.
75
88
  */
76
- declare function Table({ headers, data, striped, children, ...props }: TableProps): react.JSX.Element;
89
+ declare function Table({ headers, data, striped, children, pagination, pageSize, page, defaultPage, onPageChange, paginationPosition, ...props }: TableProps): react.JSX.Element;
77
90
  declare function TableHead(props: HTMLAttributes<HTMLTableSectionElement>): react.JSX.Element;
78
91
  declare function TableBody(props: HTMLAttributes<HTMLTableSectionElement>): react.JSX.Element;
79
92
  declare function TableRow({ children, ...props }: HTMLAttributes<HTMLTableRowElement>): react.JSX.Element;
@@ -111,6 +124,36 @@ type DrawerProps = Omit<HTMLAttributes<HTMLElement>, 'title'> & {
111
124
  /** A modal panel with fixed header/footer regions and a scrollable body. */
112
125
  declare function Drawer({ open, onClose, title, footer, side, width, fullScreen, children, closeOnBackdropClick, className, style, ...props }: DrawerProps): react.ReactPortal | null;
113
126
 
127
+ type FieldError = boolean | ReactNode;
128
+ type TextFieldBaseProps = {
129
+ label?: ReactNode;
130
+ helperText?: ReactNode;
131
+ /** A string/node is displayed beneath the control; `true` uses a default message. */
132
+ error?: FieldError;
133
+ errorMessage?: ReactNode;
134
+ clearable?: boolean;
135
+ onClear?: () => void;
136
+ onValueChange?: (value: string) => void;
137
+ clearLabel?: string;
138
+ };
139
+ type TextInputProps = Omit<InputHTMLAttributes<HTMLInputElement>, 'size' | 'value' | 'defaultValue'> & TextFieldBaseProps & {
140
+ value?: string;
141
+ defaultValue?: string;
142
+ };
143
+ type TextAreaProps = Omit<TextareaHTMLAttributes<HTMLTextAreaElement>, 'value' | 'defaultValue'> & TextFieldBaseProps & {
144
+ value?: string;
145
+ defaultValue?: string;
146
+ };
147
+ /** A text field with helper/error text and a Button-powered clear action. */
148
+ declare const TextInput: react.ForwardRefExoticComponent<Omit<InputHTMLAttributes<HTMLInputElement>, "size" | "value" | "defaultValue"> & TextFieldBaseProps & {
149
+ value?: string;
150
+ defaultValue?: string;
151
+ } & react.RefAttributes<HTMLInputElement>>;
152
+ /** A multi-line text field with helper/error text and a Button-powered clear action. */
153
+ declare const TextArea: react.ForwardRefExoticComponent<Omit<TextareaHTMLAttributes<HTMLTextAreaElement>, "value" | "defaultValue"> & TextFieldBaseProps & {
154
+ value?: string;
155
+ defaultValue?: string;
156
+ } & react.RefAttributes<HTMLTextAreaElement>>;
114
157
  type SelectionOption = {
115
158
  label: ReactNode;
116
159
  value: string | number;
@@ -170,7 +213,9 @@ type NumberInputProps = Omit<InputHTMLAttributes<HTMLInputElement>, 'type' | 'va
170
213
  thousandSeparator?: string;
171
214
  label?: ReactNode;
172
215
  helperText?: ReactNode;
173
- error?: boolean;
216
+ /** A string/node is displayed beneath the control; `true` uses a default message. */
217
+ error?: FieldError;
218
+ errorMessage?: ReactNode;
174
219
  };
175
220
  declare function formatNumber(value: number, decimals?: number, thousandSeparator?: string, decimalSeparator?: string): string;
176
221
  /** A text input that displays numbers as 1,000.05 by default. */
@@ -189,7 +234,9 @@ declare const NumberInput: react.ForwardRefExoticComponent<Omit<InputHTMLAttribu
189
234
  thousandSeparator?: string;
190
235
  label?: ReactNode;
191
236
  helperText?: ReactNode;
192
- error?: boolean;
237
+ /** A string/node is displayed beneath the control; `true` uses a default message. */
238
+ error?: FieldError;
239
+ errorMessage?: ReactNode;
193
240
  } & react.RefAttributes<HTMLInputElement>>;
194
241
  type Currency = {
195
242
  code: string;
@@ -249,4 +296,186 @@ type ExpandableSectionProps = Omit<HTMLAttributes<HTMLDivElement>, 'title'> & {
249
296
  /** An outlined section that can be expanded or collapsed. */
250
297
  declare function ExpandableSection({ title, children, expanded, defaultExpanded, onExpandedChange, disabled, className, ...props }: ExpandableSectionProps): react.JSX.Element;
251
298
 
252
- export { Button, type ButtonColor, type ButtonHierarchy, type ButtonProps, type ButtonSize, type ButtonVariant, ChevronDownIcon, CloseIcon, type ColumnResizeHandler, type Currency, CurrencyInput, type CurrencyInputProps, type DateRange, DateTimePicker, type DateTimePickerProps, type DateTimePickerRangeProps, type DateTimePickerSingleProps, Drawer, type DrawerProps, ExpandableSection, type ExpandableSectionProps, type IconProps, NumberInput, type NumberInputProps, PlusIcon, SearchIcon, Selection, type SelectionOption, type SelectionProps, type SelectionValue, Table, TableBody, TableCaption, TableCell, type TableData, TableHead, TableHeader, type TableProps, TableRow, Toggle, type ToggleProps, Tooltip, type TooltipProps, formatNumber, getIconSize };
299
+ type LoadingSize = 'small' | 'medium' | 'large' | number;
300
+ type LoadingProps = HTMLAttributes<HTMLSpanElement> & {
301
+ /** Diameter of the spinner. Accepts presets or a pixel value. */
302
+ size?: LoadingSize;
303
+ /** Spinner color. Accepts every valid CSS color. */
304
+ color?: string;
305
+ /** Optional visible status text. */
306
+ label?: ReactNode;
307
+ };
308
+ /** An accessible circular loading indicator with three preset sizes. */
309
+ declare function Loading({ size, color, label, className, style, ...props }: LoadingProps): react.JSX.Element;
310
+
311
+ type SkeletonVariant = 'box' | 'circle' | 'line';
312
+ type SkeletonProps = HTMLAttributes<HTMLDivElement> & {
313
+ /** Visual shape. `box` is the default. */
314
+ variant?: SkeletonVariant;
315
+ /** Alias for variant, useful when describing the visual shape. */
316
+ shape?: SkeletonVariant;
317
+ width?: number | string;
318
+ height?: number | string;
319
+ /** Render multiple stacked placeholders. */
320
+ count?: number;
321
+ /** Turns off the shimmer animation. */
322
+ animated?: boolean;
323
+ };
324
+ type SkeletonSizeProps = Omit<SkeletonProps, 'variant' | 'shape' | 'width' | 'height' | 'count'> & {
325
+ /** Diameter/edge length. A number is converted to pixels. */
326
+ size?: number | string;
327
+ };
328
+ type SkeletonBoxProps = Omit<SkeletonProps, 'variant' | 'shape' | 'count'>;
329
+ /** A shimmer placeholder for rectangular boxes, avatars, and text lines. */
330
+ declare function SkeletonBase({ variant, shape, width, height, count, animated, className, style, ...props }: SkeletonProps): react.JSX.Element;
331
+ /** A circular placeholder, useful for avatars and icon buttons. */
332
+ declare function SkeletonCircle({ size, ...props }: SkeletonSizeProps): react.JSX.Element;
333
+ /** A square placeholder, useful for thumbnails and image previews. */
334
+ declare function SkeletonSquare({ size, ...props }: SkeletonSizeProps): react.JSX.Element;
335
+ /** A rectangular placeholder with explicit width and height. */
336
+ declare function SkeletonBox({ width, height, ...props }: SkeletonBoxProps): react.JSX.Element;
337
+ /** A text-line placeholder with explicit width and height. */
338
+ declare function SkeletonLine({ width, height, ...props }: SkeletonBoxProps): react.JSX.Element;
339
+ type SkeletonComponent = typeof SkeletonBase & {
340
+ Circle: typeof SkeletonCircle;
341
+ Square: typeof SkeletonSquare;
342
+ Box: typeof SkeletonBox;
343
+ Line: typeof SkeletonLine;
344
+ };
345
+ /**
346
+ * A shimmer placeholder. Use the focused helpers for new code:
347
+ * `Skeleton.Circle`, `Skeleton.Square`, `Skeleton.Box`, and `Skeleton.Line`.
348
+ */
349
+ declare const Skeleton: SkeletonComponent;
350
+
351
+ type ModalSize = 'small' | 'medium' | 'large' | 'xlarge' | 'full';
352
+ type ModalAction = Omit<ButtonProps, 'children' | 'content'> & {
353
+ label: ReactNode;
354
+ };
355
+ type ModalProps = Omit<HTMLAttributes<HTMLDivElement>, 'title'> & {
356
+ open: boolean;
357
+ onClose: () => void;
358
+ title?: ReactNode;
359
+ description?: ReactNode;
360
+ children?: ReactNode;
361
+ /** Custom footer content, rendered before actions. */
362
+ footer?: ReactNode;
363
+ /** Actions rendered with the library Button component. */
364
+ actions?: ModalAction[];
365
+ size?: ModalSize;
366
+ closeOnBackdropClick?: boolean;
367
+ closeButton?: boolean;
368
+ closeLabel?: string;
369
+ };
370
+ /** A centered, portal-based dialog with Button-powered close and footer actions. */
371
+ declare function Modal({ open, onClose, title, description, children, footer, actions, size, closeOnBackdropClick, closeButton, closeLabel, className, ...props }: ModalProps): react.ReactPortal | null;
372
+
373
+ type ProgressBarSize = 'small' | 'medium' | 'large';
374
+ type ProgressBarProps = HTMLAttributes<HTMLDivElement> & {
375
+ /** Current value. Omit it for the indeterminate, bouncing state. */
376
+ value?: number | null;
377
+ max?: number;
378
+ label?: ReactNode;
379
+ showValue?: boolean;
380
+ size?: ProgressBarSize;
381
+ color?: string;
382
+ };
383
+ /** A determinate percentage bar or an indeterminate bar that moves back and forth. */
384
+ declare function ProgressBar({ value, max, label, showValue, size, color, className, style, 'aria-label': ariaLabel, ...props }: ProgressBarProps): react.JSX.Element;
385
+
386
+ type ChipStatus = 'default' | 'info' | 'success' | 'warning' | 'error' | 'neutral' | 'pending' | 'processing';
387
+ type ChipVariant = 'subtle' | 'solid' | 'outline';
388
+ type ChipProps = HTMLAttributes<HTMLSpanElement> & {
389
+ children: ReactNode;
390
+ /** Status color palette: default, success, error, info, warning, plus neutral/pending/processing. */
391
+ status?: ChipStatus;
392
+ /** Any CSS color. Overrides the status palette. */
393
+ color?: string;
394
+ variant?: ChipVariant;
395
+ dot?: boolean;
396
+ onRemove?: () => void;
397
+ removeLabel?: string;
398
+ };
399
+ /** A compact status label with status palettes and custom CSS colors. */
400
+ declare function Chip({ children, status, color, variant, dot, onRemove, removeLabel, className, style, ...props }: ChipProps): react.JSX.Element;
401
+
402
+ type PaginationProps = Omit<HTMLAttributes<HTMLElement>, 'onChange'> & {
403
+ /** Current page (one-based). Provide this with onPageChange for controlled use. */
404
+ page?: number;
405
+ /** Starting page for uncontrolled use. */
406
+ defaultPage?: number;
407
+ /** Total number of pages. */
408
+ totalPages: number;
409
+ /** Called whenever the selected page changes. */
410
+ onPageChange?: (page: number) => void;
411
+ /** Number of page buttons shown around the current page. */
412
+ siblingCount?: number;
413
+ /** Number of page buttons retained at each edge. */
414
+ boundaryCount?: number;
415
+ disabled?: boolean;
416
+ previousLabel?: string;
417
+ nextLabel?: string;
418
+ };
419
+ /** A compact, accessible page navigator with controlled and uncontrolled APIs. */
420
+ declare function Pagination({ page, defaultPage, totalPages, onPageChange, siblingCount, boundaryCount, disabled, previousLabel, nextLabel, className, ...props }: PaginationProps): react.JSX.Element;
421
+
422
+ type MessageSeverity = 'success' | 'info' | 'warning' | 'error';
423
+ type MessageOptions = {
424
+ content: ReactNode;
425
+ severity?: MessageSeverity;
426
+ title?: ReactNode;
427
+ /** Set to null to leave the message visible until manually dismissed. */
428
+ duration?: number | null;
429
+ action?: ReactNode;
430
+ onClose?: () => void;
431
+ };
432
+ declare function dismiss(id: number): void;
433
+ declare function show({ duration, severity, ...options }: MessageOptions): number;
434
+ declare const message: {
435
+ show: typeof show;
436
+ success: (content: ReactNode, options?: Omit<MessageOptions, "content" | "severity">) => number;
437
+ info: (content: ReactNode, options?: Omit<MessageOptions, "content" | "severity">) => number;
438
+ warning: (content: ReactNode, options?: Omit<MessageOptions, "content" | "severity">) => number;
439
+ error: (content: ReactNode, options?: Omit<MessageOptions, "content" | "severity">) => number;
440
+ dismiss: typeof dismiss;
441
+ clear: () => void;
442
+ };
443
+ type MessageProps = HTMLAttributes<HTMLDivElement> & {
444
+ /** Maximum notifications shown at the same time. */
445
+ maxCount?: number;
446
+ closeLabel?: string;
447
+ };
448
+ /**
449
+ * Notification viewport for the global `message` trigger.
450
+ * Mount once near the application root, then call `message.success(...)`.
451
+ */
452
+ declare function Message({ maxCount, closeLabel, className, ...props }: MessageProps): react.JSX.Element;
453
+ /** Imperative trigger aliases, available as `Message.success(...)` as well. */
454
+ declare namespace Message {
455
+ const show: ({ duration, severity, ...options }: MessageOptions) => number;
456
+ const success: (content: ReactNode, options?: Omit<MessageOptions, "content" | "severity">) => number;
457
+ const info: (content: ReactNode, options?: Omit<MessageOptions, "content" | "severity">) => number;
458
+ const warning: (content: ReactNode, options?: Omit<MessageOptions, "content" | "severity">) => number;
459
+ const error: (content: ReactNode, options?: Omit<MessageOptions, "content" | "severity">) => number;
460
+ const dismiss: (id: number) => void;
461
+ const clear: () => void;
462
+ }
463
+
464
+ type SnackbarAnchorOrigin = {
465
+ vertical?: 'top' | 'bottom';
466
+ horizontal?: 'left' | 'center' | 'right';
467
+ };
468
+ type SnackbarProps = Omit<HTMLAttributes<HTMLDivElement>, 'onClose'> & {
469
+ open: boolean;
470
+ message: ReactNode;
471
+ /** Set to null to keep the snackbar open until dismissed. */
472
+ autoHideDuration?: number | null;
473
+ onClose?: (reason: 'timeout' | 'closeButton' | 'escapeKeyDown') => void;
474
+ action?: ReactNode;
475
+ anchorOrigin?: SnackbarAnchorOrigin;
476
+ closeLabel?: string;
477
+ };
478
+ /** A controlled, temporary notification surface. */
479
+ declare function Snackbar({ open, message, autoHideDuration, onClose, action, anchorOrigin, closeLabel, className, ...props }: SnackbarProps): react.JSX.Element | null;
480
+
481
+ export { Button, type ButtonColor, type ButtonHierarchy, type ButtonProps, type ButtonSize, type ButtonVariant, ChevronDownIcon, Chip, type ChipProps, type ChipStatus, type ChipVariant, CloseIcon, type ColumnResizeHandler, type Currency, CurrencyInput, type CurrencyInputProps, type DateRange, DateTimePicker, type DateTimePickerProps, type DateTimePickerRangeProps, type DateTimePickerSingleProps, Drawer, type DrawerProps, ExpandableSection, type ExpandableSectionProps, type FieldError, type IconProps, 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, PlusIcon, ProgressBar, type ProgressBarProps, type ProgressBarSize, SearchIcon, 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, Table, TableBody, TableCaption, TableCell, type TableData, TableHead, TableHeader, type TablePaginationPosition, type TableProps, TableRow, TextArea, type TextAreaProps, TextInput, type TextInputProps, Toggle, type ToggleProps, Tooltip, type TooltipProps, formatNumber, getIconSize, message };