ados-rcm 1.0.31 → 1.0.32

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.
@@ -2,19 +2,19 @@ import React from 'react';
2
2
  import { TUseValues } from '../../AHooks/useValues';
3
3
  import { IABaseProps } from '../ABase/ABase';
4
4
  import { IAWrapProps } from '../AWrap/AWrap';
5
- export interface IASelectSelectedRendererProps<TItem, TGivenSelected, TSelected = TGivenSelected extends Array<TItem> ? TItem[] : null | TItem> {
5
+ export interface IASelectSelectedRendererProps<I, S extends (null | I) | I[]> {
6
6
  /**
7
- * OptionRenderer : (props: IASelectOptionRendererProps<T>) => React.ReactNode
7
+ * OptionRenderer : (props: IASelectOptionRendererProps<I>) => React.ReactNode
8
8
  *
9
9
  * Description : OptionRenderer of ASelect
10
10
  */
11
- OptionRenderer: (props: IASelectOptionRendererProps<TItem>) => React.ReactNode;
11
+ OptionRenderer: (props: IASelectOptionRendererProps<I>) => React.ReactNode;
12
12
  /**
13
- * selected : T[]
13
+ * selected : S
14
14
  *
15
15
  * Description : selected items of ASelect
16
16
  */
17
- selected: TSelected;
17
+ selected: S;
18
18
  /**
19
19
  * placeholder : React.ReactNode
20
20
  *
@@ -22,27 +22,27 @@ export interface IASelectSelectedRendererProps<TItem, TGivenSelected, TSelected
22
22
  */
23
23
  placeholder?: React.ReactNode;
24
24
  }
25
- export interface IASelectOptionRendererProps<TItem> {
25
+ export interface IASelectOptionRendererProps<I> {
26
26
  /**
27
- * option : T
27
+ * option : I
28
28
  *
29
29
  * Description : option of ASelect
30
30
  */
31
- option: TItem;
31
+ option: I;
32
32
  }
33
- export interface IASelectProps<TItem, TGivenSelected, TSelected = TGivenSelected extends Array<TItem> ? TItem[] : null | TItem> extends IABaseProps, IAWrapProps {
33
+ export interface IASelectProps<I, S extends (null | I) | I[]> extends IABaseProps, IAWrapProps {
34
34
  /**
35
- * options : T[]
35
+ * options : I[]
36
36
  *
37
37
  * Description : options of ASelect
38
38
  */
39
- options: TItem[];
39
+ options: I[];
40
40
  /**
41
- * useSelect? : TUseValues<T[]>
41
+ * useSelect? : TUseValues<K>
42
42
  *
43
43
  * Description : useSelect of ASelect
44
44
  */
45
- useSelect?: TUseValues<TSelected>;
45
+ useSelect?: TUseValues<S>;
46
46
  /**
47
47
  * type? : 'Primary' | 'Secondary' = 'Primary'
48
48
  *
@@ -55,12 +55,6 @@ export interface IASelectProps<TItem, TGivenSelected, TSelected = TGivenSelected
55
55
  * Description : placeholder of ASelect. it is shown when no option is selected
56
56
  */
57
57
  placeholder?: React.ReactNode;
58
- /**
59
- * isSelectMulti? : boolean = false
60
- *
61
- * Description : isSelectMulti of ASelect. if it is true, multiple options can be selected
62
- */
63
- isSelectMulti?: boolean;
64
58
  /**
65
59
  * onClose? : () => void
66
60
  *
@@ -72,13 +66,13 @@ export interface IASelectProps<TItem, TGivenSelected, TSelected = TGivenSelected
72
66
  *
73
67
  * Description : Renderer of Selected Options of ASelect
74
68
  */
75
- SelectedRenderer?: (props: IASelectSelectedRendererProps<TItem, TGivenSelected, TSelected>) => React.ReactNode;
69
+ SelectedRenderer?: (props: IASelectSelectedRendererProps<I, S>) => React.ReactNode;
76
70
  /**
77
71
  * OptionRenderer? : (props: IASelectOptionRendererProps<T>) => React.ReactNode = DefaultOptionRenderer
78
72
  *
79
73
  * Description : Renderer of Options of ASelect
80
74
  */
81
- OptionRenderer?: (props: IASelectOptionRendererProps<TItem>) => React.ReactNode;
75
+ OptionRenderer?: (props: IASelectOptionRendererProps<I>) => React.ReactNode;
82
76
  /**
83
77
  * minShowRows? : number = 2
84
78
  *
@@ -102,33 +96,38 @@ export interface IASelectProps<TItem, TGivenSelected, TSelected = TGivenSelected
102
96
  * AComponent : ASelect
103
97
  *
104
98
  * Description : ASelect is a select component. give options and useSelect to select an option.
99
+ * if useSelect is given for I[], it will act as a multi select, otherwise it will act as a single select.
105
100
  *
106
101
  * Basic Usage :
107
102
  *
108
- * const strOptions = ['Option1', 'Option2', 'Option3'];
109
103
  * const options = [{idx : 1, name : 'option1'}, {idx : 2, name : 'option2'}, {idx : 3, name : 'option3'}];
110
- * const [strSelected, setStrSelected] = useState<string | null>(null);
111
- * const [selected, setSelected] = useState<{idx : number, name : string}[]>([]);
104
+ * const [selected, setSelected] = useState<typeof options[0]>(options[0]);
112
105
  * const OptionRenderer = ({option}) => <div>{option.name}</div>;
113
- * const SelectedRenderer = ({selected, placeholder}) => selected.length > 0 ? string.join(selected.map(e => e.name), ', ') : placeholder;
106
+ * const SelectedRenderer = ({selected, placeholder}) => selected ? selected.name : placeholder;
107
+ * const [multiSelected, setMultiSelected] = useState<(typeof options[0])[]>([options[0]]);
108
+ * const MultiSelectedRenderer = ({selected, placeholder}) => selected.length > 0 ? string.join(selected.map(e => e.name), ', ') : placeholder;
114
109
  *
115
110
  * if (case 1)
116
111
  * <ASelect options={strOptions}
117
- * useSelect={[strSelected, setStrSelected]}/>
112
+ * useSelect={[selected, setSelected]}/>
118
113
  *
119
114
  * if (case 2)
120
115
  * <ASelect options={options}
121
116
  * useSelect={[selected, setSelected]}
122
- * OptionRenderer={OptionRenderer}
123
- * isSelectMulti
117
+ * OptionRenderer={OptionRenderer}/>
124
118
  *
125
119
  * if (case 3)
126
120
  * <ASelect options={options}
127
121
  * useSelect={[selected, setSelected]}
128
122
  * OptionRenderer={OptionRenderer}
129
- * SelectedRenderer={SelectedRenderer}
130
- * isSelectMulti/>
123
+ * SelectedRenderer={SelectedRenderer}/>
124
+ *
125
+ * if (case 4)
126
+ * <ASelect options={options}
127
+ * useSelect={[multiSelected, setMultiSelected]}
128
+ * OptionRenderer={OptionRenderer}
129
+ * SelectedRenderer={MultiSelectedRenderer}/>
131
130
  *
132
131
  */
133
- export declare const ASelect: <TItem, TGivenSelected, TSelected = TGivenSelected extends TItem[] ? TItem[] : TItem | null>(props: IASelectProps<TItem, TGivenSelected, TSelected>) => React.ReactNode;
132
+ export declare const ASelect: <I, S extends I | I[] | null>(props: IASelectProps<I, S>) => React.ReactNode;
134
133
  export declare const DefaultOptionRenderer: <T>(props: IASelectOptionRendererProps<T>) => React.ReactNode;