@dragunio/fe-libs 0.1.4 → 0.1.6

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.mts CHANGED
@@ -1,5 +1,6 @@
1
1
  import * as react from 'react';
2
- import { ButtonHTMLAttributes, ReactNode, SVGProps, TableHTMLAttributes, HTMLAttributes, InputHTMLAttributes, KeyboardEventHandler, TextareaHTMLAttributes, ReactElement } from 'react';
2
+ import { ButtonHTMLAttributes, ReactNode, TableHTMLAttributes, HTMLAttributes, InputHTMLAttributes, TextareaHTMLAttributes, KeyboardEventHandler, ChangeEvent, ReactElement } from 'react';
3
+ export { ChevronDownIcon, ChevronUpIcon, CloseIcon, IconProps, 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.mjs';
3
4
 
4
5
  type ButtonHierarchy = 'primary' | 'secondary-gray' | 'secondary-color' | 'tertiary-gray' | 'tertiary-color';
5
6
  type ButtonSize = '24' | '32' | '40';
@@ -43,14 +44,6 @@ declare const Button: react.ForwardRefExoticComponent<Omit<ButtonHTMLAttributes<
43
44
  variant?: ButtonVariant;
44
45
  } & react.RefAttributes<HTMLButtonElement>>;
45
46
 
46
- type IconProps = SVGProps<SVGSVGElement> & {
47
- size?: number | string;
48
- };
49
- declare function PlusIcon(props: IconProps): react.JSX.Element;
50
- declare function ChevronDownIcon(props: IconProps): react.JSX.Element;
51
- declare function CloseIcon(props: IconProps): react.JSX.Element;
52
- declare function SearchIcon(props: IconProps): react.JSX.Element;
53
-
54
47
  type TableData = readonly (readonly ReactNode[])[];
55
48
  type ColumnResizeHandler = (columnSizes: number[], columnIndex: number) => void;
56
49
  type TablePaginationPosition = 'top-right' | 'bottom-right' | 'bottom-center' | 'middle-bottom';
@@ -99,12 +92,16 @@ type ToggleProps = Omit<InputHTMLAttributes<HTMLInputElement>, 'color' | 'type'>
99
92
  color?: string;
100
93
  /** Optional text displayed next to the switch. */
101
94
  label?: ReactNode;
95
+ /** Places the label above or to the right of the switch. Defaults to `right`. */
96
+ labelPosition?: 'top' | 'right';
102
97
  };
103
98
  declare const Toggle: react.ForwardRefExoticComponent<Omit<InputHTMLAttributes<HTMLInputElement>, "color" | "type"> & {
104
99
  /** Active track color. Accepts any valid CSS color, for example `#16a34a`. */
105
100
  color?: string;
106
101
  /** Optional text displayed next to the switch. */
107
102
  label?: ReactNode;
103
+ /** Places the label above or to the right of the switch. Defaults to `right`. */
104
+ labelPosition?: "top" | "right";
108
105
  } & react.RefAttributes<HTMLInputElement>>;
109
106
 
110
107
  type DrawerProps = Omit<HTMLAttributes<HTMLElement>, 'title'> & {
@@ -125,35 +122,75 @@ type DrawerProps = Omit<HTMLAttributes<HTMLElement>, 'title'> & {
125
122
  declare function Drawer({ open, onClose, title, footer, side, width, fullScreen, children, closeOnBackdropClick, className, style, ...props }: DrawerProps): react.ReactPortal | null;
126
123
 
127
124
  type FieldError = boolean | ReactNode;
128
- type TextFieldBaseProps = {
125
+ type DescriptionDisplay = 'inline' | 'tooltip';
126
+ type FieldBaseProps = {
129
127
  label?: ReactNode;
128
+ /** Marks the field as required and displays a red asterisk. */
129
+ isRequired?: boolean;
130
+ /** Supporting text below the field. Takes precedence over helperText. */
131
+ description?: ReactNode;
132
+ /** Displays description below the field or from the label's information icon. */
133
+ descriptionDisplay?: DescriptionDisplay;
134
+ /** @deprecated Use description instead. Kept for backwards compatibility. */
130
135
  helperText?: ReactNode;
131
- /** A string/node is displayed beneath the control; `true` uses a default message. */
136
+ /** A string/node is displayed beneath the control; true uses a default message. */
132
137
  error?: FieldError;
133
138
  errorMessage?: ReactNode;
139
+ };
140
+ type TextFieldBaseProps = FieldBaseProps & {
134
141
  clearable?: boolean;
135
142
  onClear?: () => void;
136
143
  onValueChange?: (value: string) => void;
137
144
  clearLabel?: string;
138
145
  };
139
- type TextInputProps = Omit<InputHTMLAttributes<HTMLInputElement>, 'size' | 'value' | 'defaultValue'> & TextFieldBaseProps & {
146
+
147
+ /** A text field with helper/error text and a Button-powered clear action. */
148
+ declare const TextInput: react.ForwardRefExoticComponent<Omit<react.InputHTMLAttributes<HTMLInputElement>, "size" | "prefix" | "value" | "defaultValue"> & FieldBaseProps & {
149
+ clearable?: boolean;
150
+ onClear?: () => void;
151
+ onValueChange?: (value: string) => void;
152
+ clearLabel?: string;
153
+ } & {
140
154
  value?: string;
141
155
  defaultValue?: string;
142
- };
143
- type TextAreaProps = Omit<TextareaHTMLAttributes<HTMLTextAreaElement>, 'value' | 'defaultValue'> & TextFieldBaseProps & {
156
+ prefix?: react.ReactNode;
157
+ suffix?: react.ReactNode;
158
+ Prefix?: react.ReactNode;
159
+ Suffix?: react.ReactNode;
160
+ } & react.RefAttributes<HTMLInputElement>>;
161
+
162
+ type TextInputProps = Omit<InputHTMLAttributes<HTMLInputElement>, 'size' | 'value' | 'defaultValue' | 'prefix'> & TextFieldBaseProps & {
144
163
  value?: string;
145
164
  defaultValue?: string;
165
+ /** Content rendered inside the control before the input value. */
166
+ prefix?: ReactNode;
167
+ /** Content rendered inside the control after the input value. */
168
+ suffix?: ReactNode;
169
+ /** Alias for prefix. */
170
+ Prefix?: ReactNode;
171
+ /** Alias for suffix. */
172
+ Suffix?: ReactNode;
146
173
  };
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>>;
174
+
152
175
  /** 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 & {
176
+ declare const TextArea: react.ForwardRefExoticComponent<Omit<react.TextareaHTMLAttributes<HTMLTextAreaElement>, "value" | "defaultValue"> & FieldBaseProps & {
177
+ clearable?: boolean;
178
+ onClear?: () => void;
179
+ onValueChange?: (value: string) => void;
180
+ clearLabel?: string;
181
+ } & {
182
+ autosize?: boolean;
154
183
  value?: string;
155
184
  defaultValue?: string;
156
185
  } & react.RefAttributes<HTMLTextAreaElement>>;
186
+
187
+ type TextAreaProps = Omit<TextareaHTMLAttributes<HTMLTextAreaElement>, 'value' | 'defaultValue'> & TextFieldBaseProps & {
188
+ /** Expands the textarea to fit its content. */
189
+ autosize?: boolean;
190
+ value?: string;
191
+ defaultValue?: string;
192
+ };
193
+
157
194
  type SelectionOption = {
158
195
  label: ReactNode;
159
196
  value: string | number;
@@ -163,8 +200,13 @@ type SelectionOption = {
163
200
  type SelectionValue = string | number | Array<string | number>;
164
201
  type SelectionProps = Omit<HTMLAttributes<HTMLDivElement>, 'onChange' | 'defaultValue' | 'value' | 'onKeyDown'> & {
165
202
  label?: ReactNode;
203
+ /** Marks the field as required and displays a red asterisk. */
204
+ isRequired?: boolean;
205
+ description?: ReactNode;
206
+ descriptionDisplay?: DescriptionDisplay;
166
207
  helperText?: ReactNode;
167
- error?: boolean;
208
+ error?: FieldError;
209
+ errorMessage?: ReactNode;
168
210
  options: SelectionOption[];
169
211
  placeholder?: string;
170
212
  size?: 'small' | 'medium';
@@ -179,11 +221,16 @@ type SelectionProps = Omit<HTMLAttributes<HTMLDivElement>, 'onChange' | 'default
179
221
  name?: string;
180
222
  onKeyDown?: KeyboardEventHandler<HTMLButtonElement>;
181
223
  };
224
+
182
225
  /** A rounded, searchable custom dropdown with single, multiple, and tag modes. */
183
- declare const Selection: react.ForwardRefExoticComponent<Omit<HTMLAttributes<HTMLDivElement>, "value" | "defaultValue" | "onChange" | "onKeyDown"> & {
184
- label?: ReactNode;
185
- helperText?: ReactNode;
186
- error?: boolean;
226
+ declare const Selection: react.ForwardRefExoticComponent<Omit<react.HTMLAttributes<HTMLDivElement>, "value" | "defaultValue" | "onChange" | "onKeyDown"> & {
227
+ label?: react.ReactNode;
228
+ isRequired?: boolean;
229
+ description?: react.ReactNode;
230
+ descriptionDisplay?: DescriptionDisplay;
231
+ helperText?: react.ReactNode;
232
+ error?: FieldError;
233
+ errorMessage?: react.ReactNode;
187
234
  options: SelectionOption[];
188
235
  placeholder?: string;
189
236
  size?: "small" | "medium";
@@ -196,30 +243,33 @@ declare const Selection: react.ForwardRefExoticComponent<Omit<HTMLAttributes<HTM
196
243
  clearable?: boolean;
197
244
  disabled?: boolean;
198
245
  name?: string;
199
- onKeyDown?: KeyboardEventHandler<HTMLButtonElement>;
246
+ onKeyDown?: react.KeyboardEventHandler<HTMLButtonElement>;
200
247
  } & react.RefAttributes<HTMLDivElement>>;
201
- type NumberInputProps = Omit<InputHTMLAttributes<HTMLInputElement>, 'type' | 'value' | 'defaultValue' | 'onChange' | 'min' | 'max'> & {
248
+
249
+ declare function formatNumber(value: number, decimals?: number, thousandSeparator?: string, decimalSeparator?: string): string;
250
+ /** A text input that displays numbers as 1,000.05 by default. */
251
+ declare const NumberInput: react.ForwardRefExoticComponent<Omit<react.InputHTMLAttributes<HTMLInputElement>, "type" | "value" | "defaultValue" | "onChange" | "step" | "max" | "min"> & {
202
252
  value?: number | null;
203
253
  defaultValue?: number | null;
204
254
  onValueChange?: (value: number | null) => void;
205
- /** Allows the decimal separator and fractional digits. Defaults to true. */
206
255
  allowDecimal?: boolean;
207
- /** Maximum number of fractional digits when allowDecimal is enabled. Defaults to 2. */
208
256
  decimals?: number;
209
- /** Numeric limits applied immediately as the value changes. */
210
257
  min?: number;
211
258
  max?: number;
212
259
  decimalSeparator?: string;
213
260
  thousandSeparator?: string;
214
- label?: ReactNode;
215
- helperText?: ReactNode;
216
- /** A string/node is displayed beneath the control; `true` uses a default message. */
217
- error?: FieldError;
218
- errorMessage?: ReactNode;
219
- };
220
- declare function formatNumber(value: number, decimals?: number, thousandSeparator?: string, decimalSeparator?: string): string;
221
- /** A text input that displays numbers as 1,000.05 by default. */
222
- declare const NumberInput: react.ForwardRefExoticComponent<Omit<InputHTMLAttributes<HTMLInputElement>, "type" | "value" | "defaultValue" | "onChange" | "max" | "min"> & {
261
+ prefix?: react.ReactNode;
262
+ suffix?: react.ReactNode;
263
+ Prefix?: react.ReactNode;
264
+ Suffix?: react.ReactNode;
265
+ endAdornment?: react.ReactNode;
266
+ step?: number;
267
+ showStepper?: boolean;
268
+ incrementLabel?: string;
269
+ decrementLabel?: string;
270
+ } & FieldBaseProps & react.RefAttributes<HTMLInputElement>>;
271
+
272
+ type NumberInputProps = Omit<InputHTMLAttributes<HTMLInputElement>, 'type' | 'value' | 'defaultValue' | 'onChange' | 'min' | 'max' | 'step'> & {
223
273
  value?: number | null;
224
274
  defaultValue?: number | null;
225
275
  onValueChange?: (value: number | null) => void;
@@ -232,29 +282,44 @@ declare const NumberInput: react.ForwardRefExoticComponent<Omit<InputHTMLAttribu
232
282
  max?: number;
233
283
  decimalSeparator?: string;
234
284
  thousandSeparator?: string;
235
- label?: ReactNode;
236
- helperText?: ReactNode;
237
- /** A string/node is displayed beneath the control; `true` uses a default message. */
238
- error?: FieldError;
239
- errorMessage?: ReactNode;
240
- } & react.RefAttributes<HTMLInputElement>>;
285
+ /** Content rendered inside the control before the numeric value. */
286
+ prefix?: ReactNode;
287
+ /** Content rendered inside the control after the numeric value. */
288
+ suffix?: ReactNode;
289
+ /** Alias for prefix. */
290
+ Prefix?: ReactNode;
291
+ /** Alias for suffix. */
292
+ Suffix?: ReactNode;
293
+ /** Content rendered inside the control after the numeric value. */
294
+ endAdornment?: ReactNode;
295
+ /** Amount added or subtracted by the increment and decrement controls. Defaults to 1. */
296
+ step?: number;
297
+ /** Shows the increment and decrement controls. Defaults to true. */
298
+ showStepper?: boolean;
299
+ /** Accessible label for the increment control. */
300
+ incrementLabel?: string;
301
+ /** Accessible label for the decrement control. */
302
+ decrementLabel?: string;
303
+ } & FieldBaseProps;
304
+
241
305
  type Currency = {
242
306
  code: string;
243
307
  label?: string;
244
308
  suffix?: string;
245
309
  };
246
- type CurrencyInputProps = Omit<NumberInputProps, 'suffix'> & {
310
+ type CurrencyInputProps = Omit<NumberInputProps, 'suffix' | 'endAdornment'> & {
247
311
  suffix?: ReactNode;
248
312
  currencies?: Currency[];
249
313
  currency?: string;
250
314
  defaultCurrency?: string;
251
315
  onCurrencyChange?: (currency: Currency) => void;
252
316
  };
317
+
253
318
  /** NumberInput with an optional currency suffix or currency list dropdown. */
254
- declare function CurrencyInput({ suffix, currencies, currency, defaultCurrency, onCurrencyChange, className, ...props }: CurrencyInputProps): react.JSX.Element;
319
+ declare function CurrencyInput({ suffix, currencies, currency, defaultCurrency, onCurrencyChange, className, disabled, ...props }: CurrencyInputProps): react.JSX.Element;
320
+
255
321
  type DateRange = [Date | null, Date | null];
256
- type DateTimeBaseProps = Omit<HTMLAttributes<HTMLDivElement>, 'onChange' | 'defaultValue'> & {
257
- label?: ReactNode;
322
+ type DateTimeBaseProps = Omit<HTMLAttributes<HTMLDivElement>, 'onChange' | 'defaultValue'> & FieldBaseProps & {
258
323
  format?: string;
259
324
  disabled?: boolean;
260
325
  placeholder?: string;
@@ -273,9 +338,72 @@ type DateTimePickerRangeProps = DateTimeBaseProps & {
273
338
  onChange?: (value: DateRange) => void;
274
339
  };
275
340
  type DateTimePickerProps = DateTimePickerSingleProps | DateTimePickerRangeProps;
341
+
276
342
  /** Calendar and time picker. Supports a single Date or [start, end] range. */
277
343
  declare function DateTimePicker(props: DateTimePickerProps): react.JSX.Element;
278
344
 
345
+ type ControlLabelPosition = 'top' | 'right';
346
+ type CheckboxProps = Omit<InputHTMLAttributes<HTMLInputElement>, 'type'> & {
347
+ /** Optional text associated with the checkbox. */
348
+ label?: ReactNode;
349
+ /** Places the label above or to the right of the checkbox. Defaults to `right`. */
350
+ labelPosition?: ControlLabelPosition;
351
+ };
352
+
353
+ /** A native checkbox with an accessible, custom visual control. */
354
+ declare const Checkbox: react.ForwardRefExoticComponent<Omit<react.InputHTMLAttributes<HTMLInputElement>, "type"> & {
355
+ label?: react.ReactNode;
356
+ labelPosition?: ControlLabelPosition;
357
+ } & react.RefAttributes<HTMLInputElement>>;
358
+
359
+ /** A native radio input with an accessible, custom visual control. */
360
+ declare const RadioButton: react.ForwardRefExoticComponent<Omit<react.InputHTMLAttributes<HTMLInputElement>, "type"> & {
361
+ label?: react.ReactNode;
362
+ labelPosition?: ControlLabelPosition;
363
+ } & react.RefAttributes<HTMLInputElement>>;
364
+
365
+ type RadioButtonProps = Omit<InputHTMLAttributes<HTMLInputElement>, 'type'> & {
366
+ /** Optional text associated with the radio button. */
367
+ label?: ReactNode;
368
+ /** Places the label above or to the right of the radio button. Defaults to `right`. */
369
+ labelPosition?: ControlLabelPosition;
370
+ };
371
+
372
+ type RadioValue = string | number;
373
+ type RadioGroupOption = {
374
+ label: ReactNode;
375
+ value: RadioValue;
376
+ disabled?: boolean;
377
+ };
378
+ type RadioGroupProps = Omit<HTMLAttributes<HTMLDivElement>, 'onChange' | 'defaultValue' | 'value'> & {
379
+ /** Optional text that names the radio group. */
380
+ label?: ReactNode;
381
+ /** Places the group label above or to the right of its options. Defaults to `top`. */
382
+ labelPosition?: ControlLabelPosition;
383
+ options: RadioGroupOption[];
384
+ name?: string;
385
+ value?: RadioValue;
386
+ defaultValue?: RadioValue;
387
+ onChange?: (value: RadioValue, option: RadioGroupOption, event: ChangeEvent<HTMLInputElement>) => void;
388
+ disabled?: boolean;
389
+ direction?: 'horizontal' | 'vertical';
390
+ isRequired?: boolean;
391
+ };
392
+
393
+ /** A named collection of native radio buttons with controlled and uncontrolled values. */
394
+ declare const RadioGroup: react.ForwardRefExoticComponent<Omit<react.HTMLAttributes<HTMLDivElement>, "value" | "defaultValue" | "onChange"> & {
395
+ label?: react.ReactNode;
396
+ labelPosition?: ControlLabelPosition;
397
+ options: RadioGroupOption[];
398
+ name?: string;
399
+ value?: RadioValue;
400
+ defaultValue?: RadioValue;
401
+ onChange?: (value: RadioValue, option: RadioGroupOption, event: ChangeEvent<HTMLInputElement>) => void;
402
+ disabled?: boolean;
403
+ direction?: "horizontal" | "vertical";
404
+ isRequired?: boolean;
405
+ } & react.RefAttributes<HTMLDivElement>>;
406
+
279
407
  type TooltipProps = Omit<HTMLAttributes<HTMLSpanElement>, 'content'> & {
280
408
  content: ReactNode;
281
409
  children: ReactElement;
@@ -478,4 +606,4 @@ type SnackbarProps = Omit<HTMLAttributes<HTMLDivElement>, 'onClose'> & {
478
606
  /** A controlled, temporary notification surface. */
479
607
  declare function Snackbar({ open, message, autoHideDuration, onClose, action, anchorOrigin, closeLabel, className, ...props }: SnackbarProps): react.JSX.Element | null;
480
608
 
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 };
609
+ export { Button, 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, 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 };