@protonradio/proton-ui 0.6.0 → 0.6.2-beta1

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
+
34
+ /**
35
+ * @interface ActionMenuProps
36
+ * @description Props interface for the ActionMenu component
37
+ */
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
+
23
59
  /**
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.
60
+ * @interface ActionMenuToggleState
61
+ * @description State interface for controlling the ActionMenu's open/close behavior
28
62
  */
29
- export declare const arrayToRgbString: (rgb: RGBArray, opacity?: number) => string;
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,7 +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
- export declare const BRAND: {
163
+ declare const BRAND: {
117
164
  PRIMARY: string;
118
165
  PRIMARY_LIGHT: string;
119
166
  SECONDARY: string;
@@ -198,11 +245,19 @@ export declare type ButtonVariant = "primary" | "secondary" | "success" | "dange
198
245
 
199
246
  export declare const Cell: <T>(props: ProtonColumnProps<T>) => JSX.Element;
200
247
 
201
- 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
+ }
202
257
 
203
- export declare function csx(...classnames: unknown[]): string;
258
+ export declare const Column: <T>(props: ProtonColumnProps<T>) => JSX.Element;
204
259
 
205
- export declare const DANGER: {
260
+ declare const DANGER: {
206
261
  SUPER_DARK: string;
207
262
  DARK: string;
208
263
  MEDIUM: string;
@@ -220,11 +275,9 @@ declare interface DialogProps extends AriaDialogProps {
220
275
  children: React.ReactNode;
221
276
  }
222
277
 
223
- export declare const generateThemeCssVariables: (baseColor: RGBArray | null) => Record<Theme, ThemeVariables>;
224
-
225
- export declare const generateThemedRGBArray: (baseColor: RGBArray | null) => RGBArray;
278
+ declare function generateThemeCssVariables(baseColor: RGBArray | null): Record<Theme, ThemeVariables>;
226
279
 
227
- export declare const GRAYSCALE: {
280
+ declare const GRAYSCALE: {
228
281
  GRAY_SUPER_DARK: string;
229
282
  GRAY_DARK: string;
230
283
  GRAY_MEDIUM: string;
@@ -236,19 +289,6 @@ export declare const GRAYSCALE: {
236
289
  BORDER: string;
237
290
  };
238
291
 
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
-
252
292
  export declare function Icon(props: Omit<IconProps, "svgContent">): JSX_2.Element;
253
293
 
254
294
  declare type IconID = "external-link" | "caret-down";
@@ -268,19 +308,6 @@ declare interface IconProps {
268
308
  color?: string;
269
309
  }
270
310
 
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
-
284
311
  export declare function Popover({ children, state, arrow, offset, ...props }: PopoverProps): JSX_2.Element;
285
312
 
286
313
  /**
@@ -313,7 +340,7 @@ export declare interface ProtonColumnProps<T> extends ColumnProps<T> {
313
340
  align?: "left" | "center" | "right";
314
341
  }
315
342
 
316
- export declare type RGBArray = [number, number, number];
343
+ declare type RGBArray = [number, number, number];
317
344
 
318
345
  export { Row }
319
346
 
@@ -324,14 +351,53 @@ export declare const Select: {
324
351
  Option: <T>(props: ItemProps<T>) => JSX_3.Element;
325
352
  };
326
353
 
327
- 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;
328
355
 
329
- declare interface SelectProps<T> extends AriaSelectProps<T> {
330
- 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
+ */
331
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>;
332
398
  }
333
399
 
334
- export declare const SUCCESS: {
400
+ declare const SUCCESS: {
335
401
  DARK: string;
336
402
  MEDIUM: string;
337
403
  LIGHT: string;
@@ -397,12 +463,7 @@ declare interface TextEmphasisProps extends React.HTMLAttributes<HTMLSpanElement
397
463
  "data-testid"?: string;
398
464
  }
399
465
 
400
- export declare type Theme = (typeof THEMES)[keyof typeof THEMES];
401
-
402
- export declare const THEME_CLASSES: {
403
- dark: string;
404
- light: string;
405
- };
466
+ declare type Theme = (typeof THEMES)[keyof typeof THEMES];
406
467
 
407
468
  declare interface ThemeContextType {
408
469
  theme: Theme;
@@ -425,7 +486,7 @@ export declare const THEMES: {
425
486
  readonly LIGHT: "light";
426
487
  };
427
488
 
428
- export declare interface ThemeVariables {
489
+ declare interface ThemeVariables {
429
490
  "--proton-control__background-color": string;
430
491
  "--proton-control__text-color": string;
431
492
  "--proton-control__border-color": string;
@@ -467,7 +528,7 @@ export declare function usePopoverTrigger(props?: OverlayTriggerProps): {
467
528
 
468
529
  export declare const useTheme: () => ThemeContextType;
469
530
 
470
- export declare const WARNING: {
531
+ declare const WARNING: {
471
532
  DARK: string;
472
533
  MEDIUM: string;
473
534
  LIGHT: string;
@@ -535,3 +596,8 @@ export { }
535
596
  declare namespace ButtonGroup {
536
597
  var Option: (props: ButtonGroupOptionProps) => import("react/jsx-runtime").JSX.Element;
537
598
  }
599
+
600
+
601
+ declare namespace ActionMenu {
602
+ var Item: ({ name, to }: ActionMenuItemProps) => import("react/jsx-runtime").JSX.Element;
603
+ }