@protonradio/proton-ui 0.5.4 → 0.6.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/README.md CHANGED
@@ -1,50 +1,50 @@
1
- # Proton UI
2
-
3
- ![](./.readme.gif)
4
-
5
- ```
6
- npm run storybook
7
- ```
8
-
9
- ### Publishing Updates to NPM
10
-
11
- ```
12
- npm run build
13
- npm version <new_version> // increment version in package.json accordingly using semver
14
- npm publish
15
- ```
16
-
17
- ### Themes
18
-
19
- This library supports themes for the various applications that use it. Ideally, we would unify our app designs, but until then themes is a way to support different design patterns using the same api.
20
-
21
- #### Adding a Theme
22
-
23
- The current supported themes can be found in the `src/themes/config.ts`. To add a new theme, create a new attribute on the `THEMES` object following the pattern `[themeName]: [themeClassName]`.
24
-
25
- When applying to a project, you can import available themes using `THEMES` from this library and apply the theme an outer div on the application. See below for an example.
26
-
27
- ```jsx
28
- function MyApp({ Component, pageProps }) {
29
- return (
30
- <ThemeProvider theme={THEMES.DARK}>
31
- <Component {...pageProps} />
32
- </ThemeProvider>
33
- );
34
- }
35
- ```
36
-
37
- #### Styling for a theme
38
-
39
- To apply theme specific styles in a component, we set theme specific css variables in the `src/themes/config.ts` file, in `generateThemeCssVariables` function. If you need more control, you can add either use the `useTheme` hook to manipulate the DOM, or you can use css selectors that reference the wrapping theme class.
40
-
41
- For example, to apply a style to the dark theme, you can use the following css.
42
- ```css
43
- .proton-ui__theme--dark .myComponent {
44
- background-color: red;
45
- }
46
- ```
47
-
48
- ### Recommended Reading
49
-
50
- - https://www.gabe.pizza/notes-on-component-libraries/
1
+ # Proton UI
2
+
3
+ ![](./.readme.gif)
4
+
5
+ ```
6
+ npm run storybook
7
+ ```
8
+
9
+ ### Publishing Updates to NPM
10
+
11
+ ```
12
+ npm run build
13
+ npm version <new_version> // increment version in package.json accordingly using semver
14
+ npm publish
15
+ ```
16
+
17
+ ### Themes
18
+
19
+ This library supports themes for the various applications that use it. Ideally, we would unify our app designs, but until then themes is a way to support different design patterns using the same api.
20
+
21
+ #### Adding a Theme
22
+
23
+ The current supported themes can be found in the `src/themes/config.ts`. To add a new theme, create a new attribute on the `THEMES` object following the pattern `[themeName]: [themeClassName]`.
24
+
25
+ When applying to a project, you can import available themes using `THEMES` from this library and apply the theme an outer div on the application. See below for an example.
26
+
27
+ ```jsx
28
+ function MyApp({ Component, pageProps }) {
29
+ return (
30
+ <ThemeProvider theme={THEMES.DARK}>
31
+ <Component {...pageProps} />
32
+ </ThemeProvider>
33
+ );
34
+ }
35
+ ```
36
+
37
+ #### Styling for a theme
38
+
39
+ To apply theme specific styles in a component, we set theme specific css variables in the `src/themes/config.ts` file, in `generateThemeCssVariables` function. If you need more control, you can add either use the `useTheme` hook to manipulate the DOM, or you can use css selectors that reference the wrapping theme class.
40
+
41
+ For example, to apply a style to the dark theme, you can use the following css.
42
+ ```css
43
+ .proton-ui__theme--dark .myComponent {
44
+ background-color: red;
45
+ }
46
+ ```
47
+
48
+ ### Recommended Reading
49
+
50
+ - https://www.gabe.pizza/notes-on-component-libraries/
package/dist/icons.svg CHANGED
@@ -1,11 +1,11 @@
1
- <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
2
- <defs>
3
- <symbol id="external-link" viewBox="0 0 512 512">
4
- <path d="M384 224v184a40 40 0 01-40 40H104a40 40 0 01-40-40V168a40 40 0 0140-40h167.48M336 64h112v112M224 288L440 72" fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="32"/>
5
- </symbol>
6
-
7
- <symbol id="caret-down" viewBox="0 0 512 512">
8
- <path fill="currentColor" d="M233.4 406.6c12.5 12.5 32.8 12.5 45.3 0l192-192c12.5-12.5 12.5-32.8 0-45.3s-32.8-12.5-45.3 0L256 338.7L86.6 169.4c-12.5-12.5-32.8-12.5-45.3 0s-12.5 32.8 0 45.3l192 192z"/>
9
- </symbol>
10
- </defs>
1
+ <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
2
+ <defs>
3
+ <symbol id="external-link" viewBox="0 0 512 512">
4
+ <path d="M384 224v184a40 40 0 01-40 40H104a40 40 0 01-40-40V168a40 40 0 0140-40h167.48M336 64h112v112M224 288L440 72" fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="32"/>
5
+ </symbol>
6
+
7
+ <symbol id="caret-down" viewBox="0 0 512 512">
8
+ <path fill="currentColor" d="M233.4 406.6c12.5 12.5 32.8 12.5 45.3 0l192-192c12.5-12.5 12.5-32.8 0-45.3s-32.8-12.5-45.3 0L256 338.7L86.6 169.4c-12.5-12.5-32.8-12.5-45.3 0s-12.5 32.8 0 45.3l192 192z"/>
9
+ </symbol>
10
+ </defs>
11
11
  </svg>
@@ -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> {
@@ -111,7 +119,11 @@ export declare const BRAND: {
111
119
  SECONDARY: string;
112
120
  };
113
121
 
114
- export declare function Button({ variant, ...props }: ButtonProps): JSX_2.Element;
122
+ /**
123
+ * A customizable button component that can render as either a button or anchor element
124
+ * @interface ButtonProps
125
+ */
126
+ export declare function Button({ variant, href, onPress, type, isDisabled, "data-testid": testId, children, }: ButtonProps): JSX_2.Element;
115
127
 
116
128
  export declare function ButtonGroup(props: ButtonGroupProps): JSX_2.Element;
117
129
 
@@ -152,24 +164,32 @@ declare interface ButtonGroupProps {
152
164
  }
153
165
 
154
166
  declare interface ButtonProps {
155
- /**
156
- * The button's visual aesthetic.
167
+ /** The button's visual aesthetic
168
+ * @param {ButtonVariant} variant
157
169
  */
158
170
  variant?: ButtonVariant;
159
- /**
160
- * Should the button be non-interactive?
171
+ /** Should the button be non-interactive?
172
+ * @param {boolean} isDisabled
161
173
  */
162
174
  isDisabled?: boolean;
163
- /**
164
- * The URL that the button should link to. Turns the element into an `a` tag.
175
+ /** The URL that the button should link to. Turns the element into an `a` tag
176
+ * @param {string} href
165
177
  */
166
178
  href?: string;
167
- /**
168
- * Called when the button is pressed (on release, not keydown).
179
+ /** Called when the button is pressed (on release, not keydown)
180
+ * @param {(e: PressEvent) => void} onPress
169
181
  */
170
182
  onPress?: (e: PressEvent) => void;
171
- /**
172
- * The content to display within the button.
183
+ /** The type of button
184
+ * @param {"button" | "submit" | "reset"} type
185
+ */
186
+ type?: "button" | "submit" | "reset";
187
+ /** The test ID for the button
188
+ * @param {string} dataTestId
189
+ */
190
+ "data-testid"?: string;
191
+ /** The content to display within the button
192
+ * @param {React.ReactNode} children
173
193
  */
174
194
  children?: React.ReactNode;
175
195
  }
@@ -180,6 +200,8 @@ export declare const Cell: <T>(props: ProtonColumnProps<T>) => JSX.Element;
180
200
 
181
201
  export declare const Column: <T>(props: ProtonColumnProps<T>) => JSX.Element;
182
202
 
203
+ export declare function csx(...classnames: unknown[]): string;
204
+
183
205
  export declare const DANGER: {
184
206
  SUPER_DARK: string;
185
207
  DARK: string;
@@ -214,6 +236,19 @@ export declare const GRAYSCALE: {
214
236
  BORDER: string;
215
237
  };
216
238
 
239
+ /**
240
+ * Handles internal navigation clicks by preventing default browser behavior and
241
+ * programmatically updating the URL and history state.
242
+ *
243
+ * @param e - The click event from the anchor element
244
+ * @param to - The destination path to navigate to
245
+ *
246
+ * @remarks
247
+ * - Converts relative paths to absolute by prepending "/" if needed
248
+ * - Updates browser history using pushState and dispatches a popstate event
249
+ */
250
+ export declare const handleInternalNavigation: (e: React.MouseEvent<HTMLAnchorElement>, to: string) => void;
251
+
217
252
  export declare function Icon(props: Omit<IconProps, "svgContent">): JSX_2.Element;
218
253
 
219
254
  declare type IconID = "external-link" | "caret-down";
@@ -233,6 +268,19 @@ declare interface IconProps {
233
268
  color?: string;
234
269
  }
235
270
 
271
+ /**
272
+ * [isUrlExternal] - determine if passed absolute url is external to the current domain.
273
+ */
274
+ export declare const isUrlExternal: (url: any) => boolean;
275
+
276
+ /**
277
+ * Lightens an RGB color by a specified factor.
278
+ * @param rgb - The RGB color array to lighten.
279
+ * @param factor - The factor between 0 (darker) - 1 (lighter) by which to transform the color.
280
+ * @returns The lightened RGB color array, RGB values are clamped to 42 (dark) - 179 (light).
281
+ */
282
+ export declare const lightenRGBColor: (rgb: RGBArray, factor: number) => RGBArray;
283
+
236
284
  export declare function Popover({ children, state, arrow, offset, ...props }: PopoverProps): JSX_2.Element;
237
285
 
238
286
  /**
@@ -269,69 +317,6 @@ export declare type RGBArray = [number, number, number];
269
317
 
270
318
  export { Row }
271
319
 
272
- export declare const SearchInput: default_2.FC<SearchInputProps>;
273
-
274
- /** Properties for the SearchInput component
275
- * @interface SearchInputProps
276
- */
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;
299
- /**
300
- * Should the clear button be shown when there is text?
301
- * @param {boolean} isClearable
302
- */
303
- isClearable?: boolean;
304
- /**
305
- * Called when the clear button is clicked.
306
- * @param {() => void} onClear
307
- */
308
- 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
- /**
319
- * URL search parameter key to sync the input value with.
320
- * @param {string} urlSearchParam
321
- */
322
- urlSearchParam?: string;
323
- /**
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
331
- */
332
- "data-testid"?: string;
333
- }
334
-
335
320
  export { Section }
336
321
 
337
322
  export declare const Select: {
@@ -489,6 +474,61 @@ export declare const WARNING: {
489
474
  SUPER_LIGHT: string;
490
475
  };
491
476
 
477
+ /**
478
+ * A waveform visualization component that displays audio data with interactive features.
479
+ *
480
+ * @component
481
+ * @interface WaveformProps
482
+ *
483
+ * @returns {JSX.Element} A waveform visualization with optional timestamps and interactive features
484
+ */
485
+ export declare function Waveform({ data: waveformData, resolution, startDuration, endDuration, currentTime, showTimestamps, totalDuration, onClick, timestampColor: timestampColorProp, "data-testid": testId, }: WaveformProps): JSX_2.Element;
486
+
487
+ declare interface WaveformProps {
488
+ /**
489
+ * Array of normalized amplitude values (0-1) representing the waveform.
490
+ * If not provided, uses a sample sine wave.
491
+ */
492
+ data?: number[];
493
+ /**
494
+ * Total duration of the audio in seconds.
495
+ */
496
+ totalDuration: number;
497
+ /**
498
+ * Current playback position in seconds.
499
+ */
500
+ currentTime?: number;
501
+ /**
502
+ * Width in pixels of each waveform bar.
503
+ */
504
+ resolution?: number;
505
+ /**
506
+ * Start time to display from in seconds.
507
+ */
508
+ startDuration?: number;
509
+ /**
510
+ * End time to display until in seconds.
511
+ */
512
+ endDuration?: number;
513
+ /**
514
+ * Whether to show timestamp markers.
515
+ */
516
+ showTimestamps?: boolean;
517
+ /**
518
+ * Click handler that receives the clicked position (0-1) and event.
519
+ */
520
+ onClick?: (position: number, e: React.MouseEvent<HTMLDivElement>) => void;
521
+ /**
522
+ * Custom color for timestamp text backgrounds.
523
+ * Will use theme color by default.
524
+ */
525
+ timestampColor?: string;
526
+ /**
527
+ * Test ID for testing purposes.
528
+ */
529
+ "data-testid"?: string;
530
+ }
531
+
492
532
  export { }
493
533
 
494
534