@protonradio/proton-ui 0.5.4 → 0.6.1

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.
@@ -20,6 +20,14 @@ import { TableStateProps } from 'react-stately';
20
20
  import { TooltipProps as TooltipProps_2 } from 'react-aria-components';
21
21
  import { TooltipTriggerComponentProps } from 'react-aria-components';
22
22
 
23
+ /**
24
+ * Converts an RGB array to a CSS string representation.
25
+ * @param rgb - The RGB array to convert.
26
+ * @param opacity - Optional opacity value.
27
+ * @returns A CSS string representation of the RGB array, using `rgb()`, or `rgba()` if an opacity value is provided.
28
+ */
29
+ export declare const arrayToRgbString: (rgb: RGBArray, opacity?: number) => string;
30
+
23
31
  export declare const Badge: ({ variant, children, ...props }: BadgeProps) => JSX_2.Element;
24
32
 
25
33
  export declare interface BadgeProps extends React.HTMLAttributes<HTMLDivElement> {
@@ -105,13 +113,120 @@ declare interface BannerProps extends BannerIconProps, default_2.HTMLAttributes<
105
113
 
106
114
  export declare type BannerVariant = "default" | "success" | "warning" | "danger";
107
115
 
116
+ declare interface BaseInputProps {
117
+ /**
118
+ * onChange handler for the input
119
+ * @param {React.ChangeEvent<HTMLInputElement>} event
120
+ */
121
+ onChange?: (value: string) => void;
122
+ /**
123
+ * onKeyDown handler for the input
124
+ * @param {React.KeyboardEvent<HTMLInputElement>} event
125
+ */
126
+ onKeyDown?: (event: default_2.KeyboardEvent<HTMLInputElement>) => void;
127
+ /**
128
+ * Whether the input is disabled.
129
+ * @param {boolean} isDisabled
130
+ */
131
+ isDisabled?: boolean;
132
+ /**
133
+ * Should the input be rounded?
134
+ * @param {boolean} isRounded
135
+ */
136
+ isRounded?: boolean;
137
+ /**
138
+ * Description text shown above the input.
139
+ * @param {React.ReactNode | string} description
140
+ */
141
+ description?: default_2.ReactNode | string;
142
+ /**
143
+ * Error state that changes the input's visual style and displays an error message.
144
+ * @param {React.ReactNode | string} error
145
+ */
146
+ error?: default_2.ReactNode | string;
147
+ /**
148
+ * Label for the input element.
149
+ * @note When a label is provided, the input will have extra padding, and the label will float above the text input when focused or filled.
150
+ * @param {string} label
151
+ */
152
+ label?: string;
153
+ /**
154
+ * Test ID for the component.
155
+ * @param {string} data-testid
156
+ */
157
+ "data-testid"?: string;
158
+ /**
159
+ * Content to display before the input. Typically used for icons.
160
+ * @param {React.ReactNode} prefix
161
+ */
162
+ prefix?: default_2.ReactNode;
163
+ /**
164
+ * Content to display after the input. Typically used for icons.
165
+ * @param {React.ReactNode} suffix
166
+ */
167
+ suffix?: default_2.ReactNode;
168
+ /**
169
+ * Should the browser's autocomplete be enabled?
170
+ * @external https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/autocomplete
171
+ * @param {boolean} autoComplete
172
+ */
173
+ autoComplete?: boolean;
174
+ /**
175
+ * Should the input be autofocused?
176
+ * @external https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/autofocus
177
+ * @param {boolean} autoFocus
178
+ */
179
+ autoFocus?: boolean;
180
+ /**
181
+ * The name attribute of the input element.
182
+ * @external https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/name
183
+ * @param {string} name
184
+ */
185
+ name?: string;
186
+ /**
187
+ * The placeholder text to display when the input is empty.
188
+ * @note Placeholder takes precedence over label, if both are provided.
189
+ * @external https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/placeholder
190
+ * @param {string} placeholder
191
+ */
192
+ placeholder?: string;
193
+ /**
194
+ * The pattern attribute of the input element.
195
+ * @external https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/pattern
196
+ * @param {string} pattern
197
+ */
198
+ pattern?: string;
199
+ /**
200
+ * The tab index of the input element.
201
+ * @external https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/tabindex
202
+ * @param {number} tabIndex
203
+ */
204
+ tabIndex?: number;
205
+ /**
206
+ * The type attribute of the input element.
207
+ * @external https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/type
208
+ * @param {string} type
209
+ */
210
+ type?: string;
211
+ /**
212
+ * The value of the input.
213
+ * @external https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#value
214
+ * @param {string} value
215
+ */
216
+ value?: string;
217
+ }
218
+
108
219
  export declare const BRAND: {
109
220
  PRIMARY: string;
110
221
  PRIMARY_LIGHT: string;
111
222
  SECONDARY: string;
112
223
  };
113
224
 
114
- export declare function Button({ variant, ...props }: ButtonProps): JSX_2.Element;
225
+ /**
226
+ * A customizable button component that can render as either a button or anchor element
227
+ * @interface ButtonProps
228
+ */
229
+ export declare function Button({ variant, href, onPress, type, isDisabled, "data-testid": testId, children, }: ButtonProps): JSX_2.Element;
115
230
 
116
231
  export declare function ButtonGroup(props: ButtonGroupProps): JSX_2.Element;
117
232
 
@@ -152,24 +267,32 @@ declare interface ButtonGroupProps {
152
267
  }
153
268
 
154
269
  declare interface ButtonProps {
155
- /**
156
- * The button's visual aesthetic.
270
+ /** The button's visual aesthetic
271
+ * @param {ButtonVariant} variant
157
272
  */
158
273
  variant?: ButtonVariant;
159
- /**
160
- * Should the button be non-interactive?
274
+ /** Should the button be non-interactive?
275
+ * @param {boolean} isDisabled
161
276
  */
162
277
  isDisabled?: boolean;
163
- /**
164
- * The URL that the button should link to. Turns the element into an `a` tag.
278
+ /** The URL that the button should link to. Turns the element into an `a` tag
279
+ * @param {string} href
165
280
  */
166
281
  href?: string;
167
- /**
168
- * Called when the button is pressed (on release, not keydown).
282
+ /** Called when the button is pressed (on release, not keydown)
283
+ * @param {(e: PressEvent) => void} onPress
169
284
  */
170
285
  onPress?: (e: PressEvent) => void;
171
- /**
172
- * The content to display within the button.
286
+ /** The type of button
287
+ * @param {"button" | "submit" | "reset"} type
288
+ */
289
+ type?: "button" | "submit" | "reset";
290
+ /** The test ID for the button
291
+ * @param {string} dataTestId
292
+ */
293
+ "data-testid"?: string;
294
+ /** The content to display within the button
295
+ * @param {React.ReactNode} children
173
296
  */
174
297
  children?: React.ReactNode;
175
298
  }
@@ -180,6 +303,8 @@ export declare const Cell: <T>(props: ProtonColumnProps<T>) => JSX.Element;
180
303
 
181
304
  export declare const Column: <T>(props: ProtonColumnProps<T>) => JSX.Element;
182
305
 
306
+ export declare function csx(...classnames: unknown[]): string;
307
+
183
308
  export declare const DANGER: {
184
309
  SUPER_DARK: string;
185
310
  DARK: string;
@@ -214,6 +339,19 @@ export declare const GRAYSCALE: {
214
339
  BORDER: string;
215
340
  };
216
341
 
342
+ /**
343
+ * Handles internal navigation clicks by preventing default browser behavior and
344
+ * programmatically updating the URL and history state.
345
+ *
346
+ * @param e - The click event from the anchor element
347
+ * @param to - The destination path to navigate to
348
+ *
349
+ * @remarks
350
+ * - Converts relative paths to absolute by prepending "/" if needed
351
+ * - Updates browser history using pushState and dispatches a popstate event
352
+ */
353
+ export declare const handleInternalNavigation: (e: React.MouseEvent<HTMLAnchorElement>, to: string) => void;
354
+
217
355
  export declare function Icon(props: Omit<IconProps, "svgContent">): JSX_2.Element;
218
356
 
219
357
  declare type IconID = "external-link" | "caret-down";
@@ -233,6 +371,24 @@ declare interface IconProps {
233
371
  color?: string;
234
372
  }
235
373
 
374
+ /**
375
+ * A controlled and customizable input component with support for labels, prefixes, suffixes, and error states.
376
+ */
377
+ export declare const Input: default_2.ForwardRefExoticComponent<BaseInputProps & default_2.RefAttributes<HTMLInputElement>>;
378
+
379
+ /**
380
+ * [isUrlExternal] - determine if passed absolute url is external to the current domain.
381
+ */
382
+ export declare const isUrlExternal: (url: any) => boolean;
383
+
384
+ /**
385
+ * Lightens an RGB color by a specified factor.
386
+ * @param rgb - The RGB color array to lighten.
387
+ * @param factor - The factor between 0 (darker) - 1 (lighter) by which to transform the color.
388
+ * @returns The lightened RGB color array, RGB values are clamped to 42 (dark) - 179 (light).
389
+ */
390
+ export declare const lightenRGBColor: (rgb: RGBArray, factor: number) => RGBArray;
391
+
236
392
  export declare function Popover({ children, state, arrow, offset, ...props }: PopoverProps): JSX_2.Element;
237
393
 
238
394
  /**
@@ -269,67 +425,38 @@ export declare type RGBArray = [number, number, number];
269
425
 
270
426
  export { Row }
271
427
 
272
- export declare const SearchInput: default_2.FC<SearchInputProps>;
273
-
274
- /** Properties for the SearchInput component
275
- * @interface SearchInputProps
428
+ /**
429
+ * A search input component with optional clear functionality and URL parameter sync.
276
430
  */
277
- declare interface SearchInputProps {
278
- /**
279
- * The controlled value of the search input.
280
- * If you provide a value, you should typically also provide an onChange handler to update it.
281
- * @param {string} value
282
- */
283
- defaultValue?: string;
284
- /**
285
- * Should the browser's autocomplete be enabled?
286
- * @param {boolean} autoComplete
287
- */
288
- autoComplete?: boolean;
289
- /**
290
- * The name attribute of the input element.
291
- * @param {string} name
292
- */
293
- name?: string;
294
- /**
295
- * The placeholder text to display when the input is empty.
296
- * @param {string} placeholder
297
- */
298
- placeholder?: string;
431
+ export declare const SearchInput: ({ name, placeholder, autoComplete, isClearable, isRounded, error, urlSearchParam, defaultValue, "data-testid": testId, onChange, onClear, }: SearchInputProps) => JSX_2.Element;
432
+
433
+ declare interface SearchInputProps extends Omit<BaseInputProps, "prefix" | "suffix" | "value" | "onChange"> {
299
434
  /**
300
435
  * Should the clear button be shown when there is text?
301
436
  * @param {boolean} isClearable
302
437
  */
303
438
  isClearable?: boolean;
439
+ /**
440
+ * Called when the input value changes.
441
+ * @note Required when using the input as a controlled component.
442
+ * @param {(value: string) => void} onChange
443
+ */
444
+ onChange?: (value: string) => void;
304
445
  /**
305
446
  * Called when the clear button is clicked.
306
447
  * @param {() => void} onClear
307
448
  */
308
449
  onClear?: () => void;
309
- /**
310
- * Called when the input value changes. Required when using the input as a controlled component.
311
- * @param {(event: { target: { value: string } }) => void} onChange
312
- */
313
- onChange?: (event: {
314
- target: {
315
- value: string;
316
- };
317
- }) => void;
318
450
  /**
319
451
  * URL search parameter key to sync the input value with.
320
452
  * @param {string} urlSearchParam
321
453
  */
322
454
  urlSearchParam?: string;
323
455
  /**
324
- * Error state that changes the input's visual style.
325
- * @param {React.ReactNode | string} error
326
- */
327
- error?: default_2.ReactNode | string;
328
- /**
329
- * Test ID for the component.
330
- * @param {string} data-testid
456
+ * The initial value of the input.
457
+ * @param {string} defaultValue
331
458
  */
332
- "data-testid"?: string;
459
+ defaultValue?: string;
333
460
  }
334
461
 
335
462
  export { Section }
@@ -489,6 +616,61 @@ export declare const WARNING: {
489
616
  SUPER_LIGHT: string;
490
617
  };
491
618
 
619
+ /**
620
+ * A waveform visualization component that displays audio data with interactive features.
621
+ *
622
+ * @component
623
+ * @interface WaveformProps
624
+ *
625
+ * @returns {JSX.Element} A waveform visualization with optional timestamps and interactive features
626
+ */
627
+ export declare function Waveform({ data: waveformData, resolution, startDuration, endDuration, currentTime, showTimestamps, totalDuration, onClick, timestampColor: timestampColorProp, "data-testid": testId, }: WaveformProps): JSX_2.Element;
628
+
629
+ declare interface WaveformProps {
630
+ /**
631
+ * Array of normalized amplitude values (0-1) representing the waveform.
632
+ * If not provided, uses a sample sine wave.
633
+ */
634
+ data?: number[];
635
+ /**
636
+ * Total duration of the audio in seconds.
637
+ */
638
+ totalDuration: number;
639
+ /**
640
+ * Current playback position in seconds.
641
+ */
642
+ currentTime?: number;
643
+ /**
644
+ * Width in pixels of each waveform bar.
645
+ */
646
+ resolution?: number;
647
+ /**
648
+ * Start time to display from in seconds.
649
+ */
650
+ startDuration?: number;
651
+ /**
652
+ * End time to display until in seconds.
653
+ */
654
+ endDuration?: number;
655
+ /**
656
+ * Whether to show timestamp markers.
657
+ */
658
+ showTimestamps?: boolean;
659
+ /**
660
+ * Click handler that receives the clicked position (0-1) and event.
661
+ */
662
+ onClick?: (position: number, e: React.MouseEvent<HTMLDivElement>) => void;
663
+ /**
664
+ * Custom color for timestamp text backgrounds.
665
+ * Will use theme color by default.
666
+ */
667
+ timestampColor?: string;
668
+ /**
669
+ * Test ID for testing purposes.
670
+ */
671
+ "data-testid"?: string;
672
+ }
673
+
492
674
  export { }
493
675
 
494
676