@protonradio/proton-ui 0.6.1 → 0.6.2

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.
@@ -1,7 +1,7 @@
1
1
  import { AriaDialogProps } from 'react-aria';
2
2
  import { AriaPopoverProps } from 'react-aria';
3
- import { AriaSelectProps } from 'react-aria';
4
3
  import { AriaTableProps } from 'react-aria';
4
+ import { CollectionChildren } from '@react-types/shared';
5
5
  import { ColumnProps } from '@react-stately/table';
6
6
  import { default as default_2 } from 'react';
7
7
  import { DOMProps } from '@react-types/shared';
@@ -20,13 +20,60 @@ 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
+ export declare function ActionMenu({ children, closeOnNavigation, isDisabled, showCancel, isOpen, close, "data-testId": testId, }: ActionMenuProps): JSX_2.Element;
24
+
25
+ export declare namespace ActionMenu {
26
+ var Item: ({ name, to }: ActionMenuItemProps) => JSX_2.Element;
27
+ }
28
+
29
+ declare interface ActionMenuItemProps {
30
+ name: string | ReactNode;
31
+ to?: string;
32
+ }
33
+
23
34
  /**
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.
35
+ * @interface ActionMenuProps
36
+ * @description Props interface for the ActionMenu component
28
37
  */
29
- export declare const arrayToRgbString: (rgb: RGBArray, opacity?: number) => string;
38
+ declare interface ActionMenuProps extends ActionMenuToggleState {
39
+ /**
40
+ * @param {ReactNode | function} children - Content to be rendered inside the menu, can be components or render function
41
+ */
42
+ children?: ReactNode | ((props: {
43
+ close: () => void;
44
+ }) => ReactNode);
45
+ /**
46
+ * @param {boolean} isDisabled - Prevents the menu from closing
47
+ */
48
+ isDisabled?: boolean;
49
+ /**
50
+ * @param {boolean} showCancel - Shows the cancel button
51
+ */
52
+ showCancel?: boolean;
53
+ /**
54
+ * @param {string} data-testId - Test ID for the menu container
55
+ */
56
+ "data-testId"?: string;
57
+ }
58
+
59
+ /**
60
+ * @interface ActionMenuToggleState
61
+ * @description State interface for controlling the ActionMenu's open/close behavior
62
+ */
63
+ declare interface ActionMenuToggleState {
64
+ /**
65
+ * @param {boolean} isOpen - Controls whether the menu is displayed
66
+ */
67
+ isOpen: boolean;
68
+ /**
69
+ * @param {() => void} close - Closes the menu
70
+ */
71
+ close: () => void;
72
+ /**
73
+ * @param {boolean} closeOnNavigation - Automatically closes when route changes
74
+ */
75
+ closeOnNavigation?: boolean;
76
+ }
30
77
 
31
78
  export declare const Badge: ({ variant, children, ...props }: BadgeProps) => JSX_2.Element;
32
79
 
@@ -113,110 +160,7 @@ declare interface BannerProps extends BannerIconProps, default_2.HTMLAttributes<
113
160
 
114
161
  export declare type BannerVariant = "default" | "success" | "warning" | "danger";
115
162
 
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
-
219
- export declare const BRAND: {
163
+ declare const BRAND: {
220
164
  PRIMARY: string;
221
165
  PRIMARY_LIGHT: string;
222
166
  SECONDARY: string;
@@ -301,11 +245,19 @@ export declare type ButtonVariant = "primary" | "secondary" | "success" | "dange
301
245
 
302
246
  export declare const Cell: <T>(props: ProtonColumnProps<T>) => JSX.Element;
303
247
 
304
- export declare const Column: <T>(props: ProtonColumnProps<T>) => JSX.Element;
248
+ export declare namespace COLORS {
249
+ export {
250
+ BRAND,
251
+ GRAYSCALE,
252
+ DANGER,
253
+ WARNING,
254
+ SUCCESS
255
+ }
256
+ }
305
257
 
306
- export declare function csx(...classnames: unknown[]): string;
258
+ export declare const Column: <T>(props: ProtonColumnProps<T>) => JSX.Element;
307
259
 
308
- export declare const DANGER: {
260
+ declare const DANGER: {
309
261
  SUPER_DARK: string;
310
262
  DARK: string;
311
263
  MEDIUM: string;
@@ -323,11 +275,9 @@ declare interface DialogProps extends AriaDialogProps {
323
275
  children: React.ReactNode;
324
276
  }
325
277
 
326
- export declare const generateThemeCssVariables: (baseColor: RGBArray | null) => Record<Theme, ThemeVariables>;
327
-
328
- export declare const generateThemedRGBArray: (baseColor: RGBArray | null) => RGBArray;
278
+ declare function generateThemeCssVariables(baseColor: RGBArray | null): Record<Theme, ThemeVariables>;
329
279
 
330
- export declare const GRAYSCALE: {
280
+ declare const GRAYSCALE: {
331
281
  GRAY_SUPER_DARK: string;
332
282
  GRAY_DARK: string;
333
283
  GRAY_MEDIUM: string;
@@ -339,19 +289,6 @@ export declare const GRAYSCALE: {
339
289
  BORDER: string;
340
290
  };
341
291
 
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
-
355
292
  export declare function Icon(props: Omit<IconProps, "svgContent">): JSX_2.Element;
356
293
 
357
294
  declare type IconID = "external-link" | "caret-down";
@@ -371,24 +308,6 @@ declare interface IconProps {
371
308
  color?: string;
372
309
  }
373
310
 
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
-
392
311
  export declare function Popover({ children, state, arrow, offset, ...props }: PopoverProps): JSX_2.Element;
393
312
 
394
313
  /**
@@ -421,44 +340,10 @@ export declare interface ProtonColumnProps<T> extends ColumnProps<T> {
421
340
  align?: "left" | "center" | "right";
422
341
  }
423
342
 
424
- export declare type RGBArray = [number, number, number];
343
+ declare type RGBArray = [number, number, number];
425
344
 
426
345
  export { Row }
427
346
 
428
- /**
429
- * A search input component with optional clear functionality and URL parameter sync.
430
- */
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"> {
434
- /**
435
- * Should the clear button be shown when there is text?
436
- * @param {boolean} isClearable
437
- */
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;
445
- /**
446
- * Called when the clear button is clicked.
447
- * @param {() => void} onClear
448
- */
449
- onClear?: () => void;
450
- /**
451
- * URL search parameter key to sync the input value with.
452
- * @param {string} urlSearchParam
453
- */
454
- urlSearchParam?: string;
455
- /**
456
- * The initial value of the input.
457
- * @param {string} defaultValue
458
- */
459
- defaultValue?: string;
460
- }
461
-
462
347
  export { Section }
463
348
 
464
349
  export declare const Select: {
@@ -466,14 +351,53 @@ export declare const Select: {
466
351
  Option: <T>(props: ItemProps<T>) => JSX_3.Element;
467
352
  };
468
353
 
469
- declare function SelectMenu<T extends object>({ label, name, isDisabled, ...props }: SelectProps<T>): JSX_2.Element;
354
+ declare function SelectMenu<T extends object>({ label, name, isDisabled, disabledKeys, selectedKey, onSelectionChange, items, "data-testid": testId, children, }: SelectProps<T>): JSX_2.Element;
470
355
 
471
- declare interface SelectProps<T> extends AriaSelectProps<T> {
472
- label?: string;
356
+ declare interface SelectProps<T> {
357
+ /** The name of the select field
358
+ * @external https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#name
359
+ * @prop {string} name
360
+ */
473
361
  name: string;
362
+ /** Label to display above the select
363
+ * @external https://developer.mozilla.org/en-US/docs/Web/HTML/Element/label#text
364
+ * @prop {string} label
365
+ */
366
+ label?: string;
367
+ /** Whether the select is disabled
368
+ * @prop {boolean} isDisabled
369
+ */
370
+ isDisabled?: boolean;
371
+ /** Array of keys that should be disabled
372
+ * @example ["Thing 1", "Thing 2"]
373
+ * @prop {string[] | number[]} disabledKeys
374
+ */
375
+ disabledKeys?: (string | number)[];
376
+ /** Currently selected key
377
+ * @prop {string | number} selectedKey
378
+ */
379
+ selectedKey?: string | number;
380
+ /** Callback fired when selection changes
381
+ * @prop {(key: string | number) => void} onSelectionChange
382
+ */
383
+ onSelectionChange?: (key: string | number) => void;
384
+ /** Array of items to display
385
+ * @example [{ name: "thing 1", label: "Thing 1" }, { name: "thing 2", label: "Thing 2" }]
386
+ * @prop {object[]} items
387
+ */
388
+ items?: T[];
389
+ /**
390
+ * Test ID for the select
391
+ * @prop {string} data-testid
392
+ */
393
+ "data-testid"?: string;
394
+ /** Children elements or render function
395
+ * @prop {CollectionChildren<T>} children
396
+ */
397
+ children: CollectionChildren<T>;
474
398
  }
475
399
 
476
- export declare const SUCCESS: {
400
+ declare const SUCCESS: {
477
401
  DARK: string;
478
402
  MEDIUM: string;
479
403
  LIGHT: string;
@@ -539,12 +463,7 @@ declare interface TextEmphasisProps extends React.HTMLAttributes<HTMLSpanElement
539
463
  "data-testid"?: string;
540
464
  }
541
465
 
542
- export declare type Theme = (typeof THEMES)[keyof typeof THEMES];
543
-
544
- export declare const THEME_CLASSES: {
545
- dark: string;
546
- light: string;
547
- };
466
+ declare type Theme = (typeof THEMES)[keyof typeof THEMES];
548
467
 
549
468
  declare interface ThemeContextType {
550
469
  theme: Theme;
@@ -567,7 +486,7 @@ export declare const THEMES: {
567
486
  readonly LIGHT: "light";
568
487
  };
569
488
 
570
- export declare interface ThemeVariables {
489
+ declare interface ThemeVariables {
571
490
  "--proton-control__background-color": string;
572
491
  "--proton-control__text-color": string;
573
492
  "--proton-control__border-color": string;
@@ -609,7 +528,7 @@ export declare function usePopoverTrigger(props?: OverlayTriggerProps): {
609
528
 
610
529
  export declare const useTheme: () => ThemeContextType;
611
530
 
612
- export declare const WARNING: {
531
+ declare const WARNING: {
613
532
  DARK: string;
614
533
  MEDIUM: string;
615
534
  LIGHT: string;
@@ -674,6 +593,11 @@ declare interface WaveformProps {
674
593
  export { }
675
594
 
676
595
 
596
+ declare namespace ActionMenu {
597
+ var Item: ({ name, to }: ActionMenuItemProps) => import("react/jsx-runtime").JSX.Element;
598
+ }
599
+
600
+
677
601
  declare namespace ButtonGroup {
678
602
  var Option: (props: ButtonGroupOptionProps) => import("react/jsx-runtime").JSX.Element;
679
603
  }