@ws-ui/ui-components 1.0.12 → 1.0.13

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.ts CHANGED
@@ -1,18 +1,26 @@
1
1
  import { Context } from 'react';
2
2
  import { CSSProperties } from 'react';
3
3
  import { default as default_2 } from 'react';
4
+ import { Dispatch } from 'react';
4
5
  import { ElementType } from 'react';
6
+ import { FocusEvent as FocusEvent_2 } from 'react';
5
7
  import { ForwardRefExoticComponent } from 'react';
6
8
  import { HTMLAttributes } from 'react';
9
+ import { InputHTMLAttributes } from 'react';
7
10
  import { JSX } from 'react';
8
11
  import { JSX as JSX_2 } from 'react/jsx-runtime';
12
+ import { MouseEvent as MouseEvent_2 } from 'react';
9
13
  import { default as Qodly } from './Qodly.svg?react';
14
+ import { ReactElement } from 'react';
10
15
  import { ReactNode } from 'react';
11
16
  import { Ref } from 'react';
12
17
  import { RefAttributes } from 'react';
18
+ import { SetStateAction } from 'react';
13
19
  import { UseComboboxReturnValue } from 'downshift';
20
+ import { UseComboboxStateChange } from 'downshift';
14
21
  import { UseMultipleSelectionReturnValue } from 'downshift';
15
22
  import { UseSelectReturnValue } from 'downshift';
23
+ import { UseSelectStateChange } from 'downshift';
16
24
 
17
25
  export declare type BreadcrumbColorConfig = {
18
26
  active: string;
@@ -2616,8 +2624,8 @@ declare interface HandleProps {
2616
2624
 
2617
2625
  export declare type IconType = (props: JSX.IntrinsicElements['svg']) => JSX.Element;
2618
2626
 
2619
- export declare interface IDownshiftHookParams<T = unknown> {
2620
- options?: ISelectOption<T>[] | ISelectOptionGroup<T>[];
2627
+ export declare interface IDownshiftHookParams<T> {
2628
+ options?: T[] | ISelectOptionGroup<T>[];
2621
2629
  value?: SelectValue<T>;
2622
2630
  defaultValue?: SelectValue<T>;
2623
2631
  onChange?: ((value: SelectValue<T>) => void) | ((value: SelectValue<T> | ((prev: SelectValue<T>) => SelectValue<T>)) => void);
@@ -2628,32 +2636,35 @@ export declare interface IDownshiftHookParams<T = unknown> {
2628
2636
  onOpenChange?: (isOpen: boolean) => void;
2629
2637
  inputValue?: string;
2630
2638
  onInputChange?: (value: string) => void;
2631
- getOptionLabel?: (option: ISelectOption<T>) => string;
2632
- getOptionValue?: (option: ISelectOption<T>) => string | number;
2633
- items?: ISelectOption<T>[];
2639
+ getOptionLabel?: (option: T) => string;
2640
+ getOptionValue?: (option: T) => string | number;
2641
+ formatOptionLabel?: (option: T) => ReactNode;
2642
+ items?: T[];
2634
2643
  customOptionGenerator?: OptionGenerator<T>;
2635
2644
  disableInternalFiltering?: boolean;
2645
+ isOptionDisabled?: (option: T) => boolean;
2646
+ stateReducer?: (state: any, actionAndChanges: UseComboboxStateChange<T> | UseSelectStateChange<T>) => Partial<any>;
2636
2647
  }
2637
2648
 
2638
- export declare interface IDownshiftHookReturn<T = unknown> {
2649
+ export declare interface IDownshiftHookReturn<T> {
2639
2650
  isOpen: boolean;
2640
- selectedItem: ISelectOption<T> | null;
2651
+ selectedItem: T | null;
2641
2652
  highlightedIndex: number;
2642
2653
  inputValue: string;
2643
- getToggleButtonProps: UseSelectReturnValue<ISelectOption<T>>['getToggleButtonProps'] | UseComboboxReturnValue<ISelectOption<T>>['getToggleButtonProps'];
2644
- getMenuProps: UseSelectReturnValue<ISelectOption<T>>['getMenuProps'] | UseComboboxReturnValue<ISelectOption<T>>['getMenuProps'];
2645
- getItemProps: UseSelectReturnValue<ISelectOption<T>>['getItemProps'] | UseComboboxReturnValue<ISelectOption<T>>['getItemProps'];
2646
- getInputProps?: UseComboboxReturnValue<ISelectOption<T>>['getInputProps'];
2647
- selectedItems: ISelectOption<T>[];
2648
- filteredItems: ISelectOption<T>[];
2654
+ getToggleButtonProps: UseSelectReturnValue<T>['getToggleButtonProps'] | UseComboboxReturnValue<T>['getToggleButtonProps'];
2655
+ getMenuProps: UseSelectReturnValue<T>['getMenuProps'] | UseComboboxReturnValue<T>['getMenuProps'];
2656
+ getItemProps: UseSelectReturnValue<T>['getItemProps'] | UseComboboxReturnValue<T>['getItemProps'];
2657
+ getInputProps?: UseComboboxReturnValue<T>['getInputProps'];
2658
+ selectedItems: T[];
2659
+ filteredItems: T[];
2649
2660
  setInputValue: (value: string) => void;
2650
2661
  setIsOpen: (isOpen: boolean) => void;
2651
2662
  toggleMenu: () => void;
2652
2663
  openMenu: () => void;
2653
2664
  closeMenu: () => void;
2654
2665
  clearSelection: () => void;
2655
- removeItem: (item: ISelectOption<T>) => void;
2656
- multipleSelection: UseMultipleSelectionReturnValue<ISelectOption<T>>;
2666
+ removeItem: (item: T) => void;
2667
+ multipleSelection: UseMultipleSelectionReturnValue<T>;
2657
2668
  isMulti: boolean;
2658
2669
  isSearchable: boolean;
2659
2670
  }
@@ -2798,33 +2809,27 @@ export declare interface ISelectContextValue<T = unknown> {
2798
2809
  isInvalid: boolean;
2799
2810
  isDisabled: boolean;
2800
2811
  hasMessage: boolean;
2801
- setHasMessage: default_2.Dispatch<default_2.SetStateAction<boolean>>;
2802
- options?: ISelectOption<T>[] | ISelectOptionGroup<T>[];
2812
+ setHasMessage: Dispatch<SetStateAction<boolean>>;
2813
+ options?: T[] | ISelectOptionGroup<T>[];
2803
2814
  downshift: IDownshiftHookReturn<T>;
2815
+ getOptionLabel: (option: T) => string | number;
2816
+ getOptionValue: (option: T) => string | number;
2817
+ isOptionDisabled: (option: T) => boolean;
2818
+ formatOptionLabel?: (option: T) => ReactNode;
2804
2819
  }
2805
2820
 
2806
2821
  export declare interface ISelectOption<T = unknown> {
2807
2822
  value: string | number;
2808
- label: string;
2823
+ label: string | number;
2809
2824
  data?: T;
2810
2825
  isDisabled?: boolean;
2811
2826
  icon?: ReactNode;
2812
- [index: string]: string | number | boolean | ReactNode | T;
2827
+ [index: string]: unknown;
2813
2828
  }
2814
2829
 
2815
- export declare interface ISelectOptionGroup<T = unknown> {
2830
+ export declare interface ISelectOptionGroup<T> {
2816
2831
  label: string;
2817
- options: ISelectOption<T>[];
2818
- }
2819
-
2820
- export declare interface ISelectOptionProps<T = unknown> extends default_2.HTMLAttributes<HTMLDivElement> {
2821
- className?: string;
2822
- children?: ReactNode;
2823
- data: ISelectOption<T>;
2824
- isDisabled?: boolean;
2825
- isFocused?: boolean;
2826
- isSelected?: boolean;
2827
- innerProps?: default_2.HTMLAttributes<HTMLDivElement>;
2832
+ options: T[];
2828
2833
  }
2829
2834
 
2830
2835
  export declare const ListItem: ForwardRefExoticComponent<ListItemProps & RefAttributes<HTMLElement>>;
@@ -2898,7 +2903,7 @@ export declare type NumberSize = {
2898
2903
  height: number;
2899
2904
  };
2900
2905
 
2901
- export declare type OptionGenerator<T = unknown> = (inputValue: string, currentOptions: ISelectOption<T>[]) => ISelectOption<T>[];
2906
+ export declare type OptionGenerator<T> = (inputValue: string, currentOptions: T[]) => T[];
2902
2907
 
2903
2908
  export declare const Panel: default_2.ForwardRefExoticComponent<PanelProps & default_2.RefAttributes<HTMLDivElement>>;
2904
2909
 
@@ -3289,7 +3294,7 @@ export declare const Select: {
3289
3294
  Menu: ForwardRefExoticComponent<SelectMenuProps & RefAttributes<HTMLDivElement>>;
3290
3295
  MenuList: ForwardRefExoticComponent<SelectMenuListProps & RefAttributes<HTMLDivElement>>;
3291
3296
  Option: {
3292
- <T>({ className, children, data, isDisabled, isFocused, isSelected, innerProps, ...props }: ISelectOptionProps<T>): JSX_2.Element;
3297
+ <T>({ className, children, data, isDisabled, isFocused, isSelected, innerProps, ...props }: SelectOptionProps<T>): JSX_2.Element;
3293
3298
  displayName: string;
3294
3299
  };
3295
3300
  Group: {
@@ -3313,56 +3318,18 @@ export declare const Select: {
3313
3318
  }) => React.ReactElement;
3314
3319
  };
3315
3320
 
3316
- /**
3317
- * Adapter component to usage the system Select with the legacy interface.
3318
- * Original interface:
3319
- * {
3320
- * value: string;
3321
- * onChange: (val: string) => void;
3322
- * options: { name: string }[];
3323
- * errorMessage?: string;
3324
- * onBlur?: () => void;
3325
- * }
3326
- */
3327
- export declare const SelectAdapter: ({ value, onChange, options, errorMessage, onBlur, }: SelectAdapterProps) => JSX_2.Element;
3328
-
3329
- declare interface SelectAdapterProps {
3330
- /**
3331
- * The current value of the select (name property of the option)
3332
- */
3333
- value: string;
3334
- /**
3335
- * Callback when value changes. Returns the name property.
3336
- */
3337
- onChange: (val: string) => void;
3338
- /**
3339
- * List of options. Each option must have a name property.
3340
- */
3341
- options: {
3342
- name: string;
3343
- }[];
3344
- /**
3345
- * Error message to display. If provided, shows error state.
3346
- */
3347
- errorMessage?: string;
3348
- /**
3349
- * Blur handler
3350
- */
3351
- onBlur?: () => void;
3352
- }
3353
-
3354
- export declare interface SelectClearIndicatorProps extends default_2.HTMLAttributes<HTMLDivElement> {
3321
+ export declare interface SelectClearIndicatorProps extends HTMLAttributes<HTMLDivElement> {
3355
3322
  color?: SelectColor;
3356
3323
  className?: string;
3357
3324
  children?: ReactNode;
3358
- onClick?: (event: default_2.MouseEvent) => void;
3325
+ onClick?: (event: MouseEvent_2) => void;
3359
3326
  isDisabled?: boolean;
3360
3327
  }
3361
3328
 
3362
- export declare interface SelectClearSearchIndicatorProps extends default_2.HTMLAttributes<HTMLDivElement> {
3329
+ export declare interface SelectClearSearchIndicatorProps extends HTMLAttributes<HTMLDivElement> {
3363
3330
  className?: string;
3364
3331
  children?: ReactNode;
3365
- onClick?: (event: default_2.MouseEvent) => void;
3332
+ onClick?: (event: MouseEvent_2) => void;
3366
3333
  isDisabled?: boolean;
3367
3334
  }
3368
3335
 
@@ -3405,22 +3372,22 @@ export declare interface SelectColorConfig {
3405
3372
  iconActionHover: string;
3406
3373
  }
3407
3374
 
3408
- export declare interface SelectControlProps extends default_2.HTMLAttributes<HTMLDivElement> {
3375
+ export declare interface SelectControlProps extends HTMLAttributes<HTMLDivElement> {
3409
3376
  className?: string;
3410
3377
  children: ReactNode;
3411
3378
  isFocused?: boolean;
3412
3379
  isDisabled?: boolean;
3413
3380
  }
3414
3381
 
3415
- export declare interface SelectDropdownIndicatorProps extends default_2.HTMLAttributes<HTMLDivElement> {
3382
+ export declare interface SelectDropdownIndicatorProps extends HTMLAttributes<HTMLDivElement> {
3416
3383
  color?: SelectColor;
3417
3384
  className?: string;
3418
3385
  children?: ReactNode;
3419
- onClick?: (event: default_2.MouseEvent) => void;
3386
+ onClick?: (event: MouseEvent_2) => void;
3420
3387
  isDisabled?: boolean;
3421
3388
  }
3422
3389
 
3423
- export declare interface SelectFieldProps<T = unknown> extends default_2.InputHTMLAttributes<HTMLInputElement> {
3390
+ export declare interface SelectFieldProps<T> extends InputHTMLAttributes<HTMLInputElement> {
3424
3391
  placeholder?: string;
3425
3392
  noOptionsMessage?: string | ((inputValue: string) => string);
3426
3393
  hideNoOptions?: boolean;
@@ -3435,28 +3402,28 @@ export declare interface SelectFieldProps<T = unknown> extends default_2.InputHT
3435
3402
  hideSelectedOptions?: boolean;
3436
3403
  isSearchClearable?: boolean;
3437
3404
  searchPlacement?: 'trigger' | 'menu';
3438
- onFocus?: (event: default_2.FocusEvent<HTMLElement>) => void;
3439
- onBlur?: (event: default_2.FocusEvent<HTMLElement>) => void;
3405
+ onFocus?: (event: FocusEvent_2<HTMLElement>) => void;
3406
+ onBlur?: (event: FocusEvent_2<HTMLElement>) => void;
3440
3407
  onMenuOpen?: () => void;
3441
3408
  onMenuClose?: () => void;
3442
3409
  renderMenuHeader?: (props: IDownshiftHookReturn<T>) => ReactNode;
3443
- formatOptionLabel?: (option: ISelectOption<T> & {
3444
- data?: Record<string, unknown>;
3445
- }) => ReactNode;
3410
+ formatOptionLabel?: (option: T) => ReactNode;
3446
3411
  displayFormattedOption?: boolean;
3447
- isOptionDisabled?: (option: ISelectOption<T>) => boolean;
3412
+ isOptionDisabled?: (option: T) => boolean;
3413
+ renderMultiValue?: (props: SelectMultiValueProps<T>) => ReactNode;
3414
+ renderOption?: (props: SelectOptionProps<T>) => ReactNode;
3448
3415
  name?: string;
3449
3416
  id?: string;
3450
3417
  className?: string;
3451
3418
  'aria-label'?: string;
3452
3419
  'aria-labelledby'?: string;
3453
3420
  'aria-describedby'?: string;
3454
- inputRef?: default_2.Ref<HTMLInputElement>;
3421
+ inputRef?: Ref<HTMLInputElement>;
3455
3422
  controlShouldRenderValue?: boolean;
3456
3423
  blurInputOnSelect?: boolean;
3457
3424
  tabSelectsValue?: boolean;
3458
3425
  backspaceRemovesValue?: boolean;
3459
- onSelectionComplete?: (value: string, option: ISelectOption<T> | null) => void;
3426
+ onSelectionComplete?: (value: string, option: T | null) => void;
3460
3427
  children?: ReactNode;
3461
3428
  }
3462
3429
 
@@ -3465,48 +3432,50 @@ export declare interface SelectGroupHeadingProps {
3465
3432
  children: ReactNode;
3466
3433
  }
3467
3434
 
3468
- export declare interface SelectGroupProps<T = unknown> {
3435
+ export declare interface SelectGroupProps<T> {
3469
3436
  className?: string;
3470
3437
  children: ReactNode;
3471
3438
  data: ISelectOptionGroup<T>;
3472
3439
  label: string;
3473
- options: ISelectOption<T>[];
3440
+ options: T[];
3474
3441
  }
3475
3442
 
3476
- export declare interface SelectInputProps extends Omit<default_2.InputHTMLAttributes<HTMLInputElement>, 'size'> {
3443
+ export declare interface SelectInputProps extends Omit<InputHTMLAttributes<HTMLInputElement>, 'size'> {
3477
3444
  isHidden?: boolean;
3478
3445
  inputClassName?: string;
3479
3446
  inputStyle?: CSSProperties;
3480
3447
  }
3481
3448
 
3482
- export declare interface SelectMenuListProps extends default_2.HTMLAttributes<HTMLDivElement> {
3449
+ export declare interface SelectMenuListProps extends HTMLAttributes<HTMLDivElement> {
3483
3450
  className?: string;
3484
3451
  children: ReactNode;
3485
3452
  isLoading?: boolean;
3486
3453
  maxHeight?: number;
3487
3454
  }
3488
3455
 
3489
- export declare interface SelectMenuProps extends default_2.HTMLAttributes<HTMLDivElement> {
3456
+ export declare interface SelectMenuProps extends HTMLAttributes<HTMLDivElement> {
3490
3457
  className?: string;
3491
3458
  children: ReactNode;
3492
3459
  placement?: 'auto' | 'bottom' | 'top';
3493
3460
  position?: 'absolute' | 'fixed';
3494
3461
  }
3495
3462
 
3496
- export declare interface SelectMessageProps extends default_2.HTMLAttributes<HTMLDivElement> {
3497
- icon?: default_2.ReactElement;
3463
+ export declare interface SelectMessageProps extends HTMLAttributes<HTMLDivElement> {
3464
+ icon?: ReactElement;
3498
3465
  className?: string;
3499
3466
  children: ReactNode;
3500
3467
  }
3501
3468
 
3502
- export declare interface SelectMultiValueProps<T = unknown> {
3469
+ export declare type SelectMultiValue<T> = T[];
3470
+
3471
+ export declare interface SelectMultiValueProps<T> {
3503
3472
  className?: string;
3504
3473
  children?: ReactNode;
3505
- data: ISelectOption<T>;
3474
+ data: T;
3506
3475
  index: number;
3507
3476
  isDisabled?: boolean;
3508
3477
  isFocused?: boolean;
3509
- onRemove?: (item: ISelectOption<T>) => void;
3478
+ onRemove?: (item: T) => void;
3510
3479
  }
3511
3480
 
3512
3481
  export declare interface SelectNoOptionsMessageProps {
@@ -3515,25 +3484,37 @@ export declare interface SelectNoOptionsMessageProps {
3515
3484
  inputValue?: string;
3516
3485
  }
3517
3486
 
3487
+ export declare interface SelectOptionProps<T> extends HTMLAttributes<HTMLDivElement> {
3488
+ className?: string;
3489
+ children?: ReactNode;
3490
+ data: T;
3491
+ isDisabled?: boolean;
3492
+ isFocused?: boolean;
3493
+ isSelected?: boolean;
3494
+ innerProps?: HTMLAttributes<HTMLDivElement>;
3495
+ }
3496
+
3518
3497
  export declare interface SelectPlaceholderProps {
3519
3498
  className?: string;
3520
3499
  children: ReactNode;
3521
3500
  }
3522
3501
 
3523
- export declare interface SelectRootProps<T = unknown> extends Omit<default_2.HTMLAttributes<HTMLDivElement>, 'defaultValue' | 'onChange'> {
3502
+ export declare interface SelectRootProps<T = unknown> extends Omit<HTMLAttributes<HTMLDivElement>, 'defaultValue' | 'onChange'> {
3524
3503
  size?: SelectSize;
3525
3504
  color?: 'primary' | 'positive' | 'warning' | 'negative';
3526
3505
  isInvalid?: boolean;
3527
3506
  isDisabled?: boolean;
3528
3507
  className?: string;
3529
3508
  children: ReactNode;
3530
- downshiftParams?: IDownshiftHookParams<T>;
3509
+ downshiftParams?: SelectStrictParams<T>;
3531
3510
  }
3532
3511
 
3533
- export declare interface SelectSingleValueProps<T = unknown> {
3512
+ export declare type SelectSingleValue<T> = T | null;
3513
+
3514
+ export declare interface SelectSingleValueProps<T> {
3534
3515
  className?: string;
3535
3516
  children?: ReactNode;
3536
- data: ISelectOption<T>;
3517
+ data: T;
3537
3518
  isDisabled?: boolean;
3538
3519
  }
3539
3520
 
@@ -3564,7 +3545,19 @@ export declare interface SelectSizeConfig {
3564
3545
  icon: string;
3565
3546
  }
3566
3547
 
3567
- export declare type SelectValue<T = unknown> = ISelectOption<T> | ISelectOption<T>[] | null;
3548
+ export declare type SelectStrictParams<T> = Omit<IDownshiftHookParams<T>, 'onChange' | 'value' | 'defaultValue' | 'isMulti'> & ({
3549
+ isMulti?: false;
3550
+ value?: T | null;
3551
+ defaultValue?: T | null;
3552
+ onChange?: (value: T | null) => void;
3553
+ } | {
3554
+ isMulti: true;
3555
+ value?: T[];
3556
+ defaultValue?: T[];
3557
+ onChange?: (value: T[]) => void;
3558
+ });
3559
+
3560
+ export declare type SelectValue<T> = SelectSingleValue<T> | SelectMultiValue<T>;
3568
3561
 
3569
3562
  export declare interface SelectValueContainerProps {
3570
3563
  className?: string;
@@ -3814,6 +3807,7 @@ export declare interface TooltipProps {
3814
3807
  delay?: number;
3815
3808
  /** Controle whether to trigger the tooltip visibility by eather click or hover event */
3816
3809
  trigger?: 'hover' | 'click';
3810
+ className?: string;
3817
3811
  }
3818
3812
 
3819
3813
  export declare const useTabsContext: () => TabsContextType;