@sebgroup/green-react 1.0.0-beta.23 → 1.0.0-beta.25
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/index.esm.js +25 -26
- package/index.umd.js +25 -26
- package/lib/dropdown/dropdown.d.ts +4 -15
- package/lib/dropdown/hooks.d.ts +5 -15
- package/lib/form/button/button.d.ts +2 -1
- package/package.json +3 -3
package/index.esm.js
CHANGED
|
@@ -1061,11 +1061,13 @@ function Button({
|
|
|
1061
1061
|
children,
|
|
1062
1062
|
variant,
|
|
1063
1063
|
onClick,
|
|
1064
|
+
disabled,
|
|
1064
1065
|
active = false,
|
|
1065
1066
|
type = 'button'
|
|
1066
1067
|
}) {
|
|
1067
1068
|
const props = {
|
|
1068
|
-
type
|
|
1069
|
+
type,
|
|
1070
|
+
disabled
|
|
1069
1071
|
};
|
|
1070
1072
|
const classNames = [];
|
|
1071
1073
|
if (variant) classNames.push(variant);
|
|
@@ -2671,13 +2673,14 @@ function Stepper(_a) {
|
|
|
2671
2673
|
|
|
2672
2674
|
const useDropdown = ({
|
|
2673
2675
|
id,
|
|
2676
|
+
value,
|
|
2674
2677
|
texts,
|
|
2675
2678
|
options,
|
|
2676
2679
|
loop,
|
|
2677
2680
|
multiSelect,
|
|
2678
2681
|
searchable,
|
|
2679
|
-
|
|
2680
|
-
|
|
2682
|
+
searchFilter,
|
|
2683
|
+
compareWith,
|
|
2681
2684
|
useValue,
|
|
2682
2685
|
display,
|
|
2683
2686
|
togglerRef,
|
|
@@ -2721,14 +2724,7 @@ const useDropdown = ({
|
|
|
2721
2724
|
className: (_a = o.classes) === null || _a === void 0 ? void 0 : _a.join(' '),
|
|
2722
2725
|
children: o[dropdown.display],
|
|
2723
2726
|
selected: o.selected,
|
|
2724
|
-
onClick: () =>
|
|
2725
|
-
handler === null || handler === void 0 ? void 0 : handler.select(o).then(() => {
|
|
2726
|
-
if (onChange) {
|
|
2727
|
-
const result = options.find(item => item.key === o.key);
|
|
2728
|
-
result && onChange(result);
|
|
2729
|
-
}
|
|
2730
|
-
});
|
|
2731
|
-
}
|
|
2727
|
+
onClick: () => handler === null || handler === void 0 ? void 0 : handler.select(o)
|
|
2732
2728
|
});
|
|
2733
2729
|
});
|
|
2734
2730
|
setListItems(newListItems);
|
|
@@ -2740,14 +2736,7 @@ const useDropdown = ({
|
|
|
2740
2736
|
inputProps: {
|
|
2741
2737
|
defaultChecked: o.selected,
|
|
2742
2738
|
type: 'checkbox',
|
|
2743
|
-
|
|
2744
|
-
handler === null || handler === void 0 ? void 0 : handler.select(o, false).then(() => {
|
|
2745
|
-
if (onChange) {
|
|
2746
|
-
const result = options.find(item => item.key === o.key);
|
|
2747
|
-
result && onChange(result);
|
|
2748
|
-
}
|
|
2749
|
-
});
|
|
2750
|
-
}
|
|
2739
|
+
onClick: () => handler === null || handler === void 0 ? void 0 : handler.select(o, false)
|
|
2751
2740
|
},
|
|
2752
2741
|
spanProps: {
|
|
2753
2742
|
children: o[dropdown.display]
|
|
@@ -2776,12 +2765,19 @@ const useDropdown = ({
|
|
|
2776
2765
|
if (!dropdown) return;
|
|
2777
2766
|
handler === null || handler === void 0 ? void 0 : handler.update({
|
|
2778
2767
|
id,
|
|
2768
|
+
value,
|
|
2779
2769
|
texts,
|
|
2780
2770
|
options,
|
|
2781
2771
|
loop,
|
|
2782
|
-
multiSelect
|
|
2772
|
+
multiSelect,
|
|
2773
|
+
searchable,
|
|
2774
|
+
searchFilter,
|
|
2775
|
+
compareWith,
|
|
2776
|
+
useValue,
|
|
2777
|
+
display,
|
|
2778
|
+
validator
|
|
2783
2779
|
}); // eslint-disable-next-line react-hooks/exhaustive-deps
|
|
2784
|
-
}, [id, texts, options, loop, multiSelect, searchable,
|
|
2780
|
+
}, [id, value, texts, options, loop, multiSelect, searchable, searchFilter, compareWith, useValue, display]); // When validator changes
|
|
2785
2781
|
|
|
2786
2782
|
useEffect(() => {
|
|
2787
2783
|
if (!dropdown) return;
|
|
@@ -2792,17 +2788,18 @@ const useDropdown = ({
|
|
|
2792
2788
|
if (!handler && togglerRef.current && listboxRef.current) {
|
|
2793
2789
|
setHandler(createDropdown({
|
|
2794
2790
|
id,
|
|
2791
|
+
value,
|
|
2795
2792
|
texts,
|
|
2796
2793
|
options,
|
|
2797
2794
|
loop,
|
|
2798
2795
|
multiSelect,
|
|
2799
2796
|
searchable,
|
|
2800
|
-
|
|
2801
|
-
|
|
2797
|
+
searchFilter,
|
|
2798
|
+
compareWith,
|
|
2802
2799
|
useValue,
|
|
2803
2800
|
display,
|
|
2804
2801
|
validator
|
|
2805
|
-
}, togglerRef.current, listboxRef.current, listboxRef.current, dd => setDropdown(dd)));
|
|
2802
|
+
}, togglerRef.current, listboxRef.current, listboxRef.current, dd => setDropdown(dd), value => onChange === null || onChange === void 0 ? void 0 : onChange(value)));
|
|
2806
2803
|
}
|
|
2807
2804
|
|
|
2808
2805
|
return () => handler === null || handler === void 0 ? void 0 : handler.destroy(); // eslint-disable-next-line react-hooks/exhaustive-deps
|
|
@@ -2822,7 +2819,8 @@ const Dropdown = ({
|
|
|
2822
2819
|
loop,
|
|
2823
2820
|
multiSelect,
|
|
2824
2821
|
searchable,
|
|
2825
|
-
|
|
2822
|
+
searchFilter,
|
|
2823
|
+
compareWith,
|
|
2826
2824
|
useValue,
|
|
2827
2825
|
display,
|
|
2828
2826
|
texts,
|
|
@@ -2845,7 +2843,8 @@ const Dropdown = ({
|
|
|
2845
2843
|
loop,
|
|
2846
2844
|
multiSelect,
|
|
2847
2845
|
searchable,
|
|
2848
|
-
|
|
2846
|
+
searchFilter,
|
|
2847
|
+
compareWith,
|
|
2849
2848
|
useValue,
|
|
2850
2849
|
display,
|
|
2851
2850
|
togglerRef,
|
package/index.umd.js
CHANGED
|
@@ -1067,11 +1067,13 @@
|
|
|
1067
1067
|
children,
|
|
1068
1068
|
variant,
|
|
1069
1069
|
onClick,
|
|
1070
|
+
disabled,
|
|
1070
1071
|
active = false,
|
|
1071
1072
|
type = 'button'
|
|
1072
1073
|
}) {
|
|
1073
1074
|
const props = {
|
|
1074
|
-
type
|
|
1075
|
+
type,
|
|
1076
|
+
disabled
|
|
1075
1077
|
};
|
|
1076
1078
|
const classNames = [];
|
|
1077
1079
|
if (variant) classNames.push(variant);
|
|
@@ -2677,13 +2679,14 @@
|
|
|
2677
2679
|
|
|
2678
2680
|
const useDropdown = ({
|
|
2679
2681
|
id,
|
|
2682
|
+
value,
|
|
2680
2683
|
texts,
|
|
2681
2684
|
options,
|
|
2682
2685
|
loop,
|
|
2683
2686
|
multiSelect,
|
|
2684
2687
|
searchable,
|
|
2685
|
-
|
|
2686
|
-
|
|
2688
|
+
searchFilter,
|
|
2689
|
+
compareWith,
|
|
2687
2690
|
useValue,
|
|
2688
2691
|
display,
|
|
2689
2692
|
togglerRef,
|
|
@@ -2727,14 +2730,7 @@
|
|
|
2727
2730
|
className: (_a = o.classes) === null || _a === void 0 ? void 0 : _a.join(' '),
|
|
2728
2731
|
children: o[dropdown.display],
|
|
2729
2732
|
selected: o.selected,
|
|
2730
|
-
onClick: () =>
|
|
2731
|
-
handler === null || handler === void 0 ? void 0 : handler.select(o).then(() => {
|
|
2732
|
-
if (onChange) {
|
|
2733
|
-
const result = options.find(item => item.key === o.key);
|
|
2734
|
-
result && onChange(result);
|
|
2735
|
-
}
|
|
2736
|
-
});
|
|
2737
|
-
}
|
|
2733
|
+
onClick: () => handler === null || handler === void 0 ? void 0 : handler.select(o)
|
|
2738
2734
|
});
|
|
2739
2735
|
});
|
|
2740
2736
|
setListItems(newListItems);
|
|
@@ -2746,14 +2742,7 @@
|
|
|
2746
2742
|
inputProps: {
|
|
2747
2743
|
defaultChecked: o.selected,
|
|
2748
2744
|
type: 'checkbox',
|
|
2749
|
-
|
|
2750
|
-
handler === null || handler === void 0 ? void 0 : handler.select(o, false).then(() => {
|
|
2751
|
-
if (onChange) {
|
|
2752
|
-
const result = options.find(item => item.key === o.key);
|
|
2753
|
-
result && onChange(result);
|
|
2754
|
-
}
|
|
2755
|
-
});
|
|
2756
|
-
}
|
|
2745
|
+
onClick: () => handler === null || handler === void 0 ? void 0 : handler.select(o, false)
|
|
2757
2746
|
},
|
|
2758
2747
|
spanProps: {
|
|
2759
2748
|
children: o[dropdown.display]
|
|
@@ -2782,12 +2771,19 @@
|
|
|
2782
2771
|
if (!dropdown) return;
|
|
2783
2772
|
handler === null || handler === void 0 ? void 0 : handler.update({
|
|
2784
2773
|
id,
|
|
2774
|
+
value,
|
|
2785
2775
|
texts,
|
|
2786
2776
|
options,
|
|
2787
2777
|
loop,
|
|
2788
|
-
multiSelect
|
|
2778
|
+
multiSelect,
|
|
2779
|
+
searchable,
|
|
2780
|
+
searchFilter,
|
|
2781
|
+
compareWith,
|
|
2782
|
+
useValue,
|
|
2783
|
+
display,
|
|
2784
|
+
validator
|
|
2789
2785
|
}); // eslint-disable-next-line react-hooks/exhaustive-deps
|
|
2790
|
-
}, [id, texts, options, loop, multiSelect, searchable,
|
|
2786
|
+
}, [id, value, texts, options, loop, multiSelect, searchable, searchFilter, compareWith, useValue, display]); // When validator changes
|
|
2791
2787
|
|
|
2792
2788
|
React.useEffect(() => {
|
|
2793
2789
|
if (!dropdown) return;
|
|
@@ -2798,17 +2794,18 @@
|
|
|
2798
2794
|
if (!handler && togglerRef.current && listboxRef.current) {
|
|
2799
2795
|
setHandler(extract.createDropdown({
|
|
2800
2796
|
id,
|
|
2797
|
+
value,
|
|
2801
2798
|
texts,
|
|
2802
2799
|
options,
|
|
2803
2800
|
loop,
|
|
2804
2801
|
multiSelect,
|
|
2805
2802
|
searchable,
|
|
2806
|
-
|
|
2807
|
-
|
|
2803
|
+
searchFilter,
|
|
2804
|
+
compareWith,
|
|
2808
2805
|
useValue,
|
|
2809
2806
|
display,
|
|
2810
2807
|
validator
|
|
2811
|
-
}, togglerRef.current, listboxRef.current, listboxRef.current, dd => setDropdown(dd)));
|
|
2808
|
+
}, togglerRef.current, listboxRef.current, listboxRef.current, dd => setDropdown(dd), value => onChange === null || onChange === void 0 ? void 0 : onChange(value)));
|
|
2812
2809
|
}
|
|
2813
2810
|
|
|
2814
2811
|
return () => handler === null || handler === void 0 ? void 0 : handler.destroy(); // eslint-disable-next-line react-hooks/exhaustive-deps
|
|
@@ -2828,7 +2825,8 @@
|
|
|
2828
2825
|
loop,
|
|
2829
2826
|
multiSelect,
|
|
2830
2827
|
searchable,
|
|
2831
|
-
|
|
2828
|
+
searchFilter,
|
|
2829
|
+
compareWith,
|
|
2832
2830
|
useValue,
|
|
2833
2831
|
display,
|
|
2834
2832
|
texts,
|
|
@@ -2851,7 +2849,8 @@
|
|
|
2851
2849
|
loop,
|
|
2852
2850
|
multiSelect,
|
|
2853
2851
|
searchable,
|
|
2854
|
-
|
|
2852
|
+
searchFilter,
|
|
2853
|
+
compareWith,
|
|
2855
2854
|
useValue,
|
|
2856
2855
|
display,
|
|
2857
2856
|
togglerRef,
|
|
@@ -1,17 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
id?: string;
|
|
5
|
-
texts?: DropdownTexts;
|
|
6
|
-
options: DropdownOption[];
|
|
7
|
-
useValue?: string;
|
|
8
|
-
display?: string;
|
|
9
|
-
selectValue?: string;
|
|
10
|
-
loop?: boolean;
|
|
11
|
-
multiSelect?: boolean;
|
|
12
|
-
searchable?: boolean;
|
|
13
|
-
onChange?: (o: DropdownOption) => void;
|
|
14
|
-
validator?: IValidator;
|
|
1
|
+
import { DropdownArgs, OnChange } from '@sebgroup/extract';
|
|
2
|
+
export interface DropdownProps extends DropdownArgs {
|
|
3
|
+
onChange?: OnChange;
|
|
15
4
|
}
|
|
16
|
-
export declare const Dropdown: ({ id, options, loop, multiSelect, searchable,
|
|
5
|
+
export declare const Dropdown: ({ id, options, loop, multiSelect, searchable, searchFilter, compareWith, useValue, display, texts, onChange, validator, }: DropdownProps) => JSX.Element;
|
|
17
6
|
export default Dropdown;
|
package/lib/dropdown/hooks.d.ts
CHANGED
|
@@ -1,20 +1,10 @@
|
|
|
1
|
-
import { DropdownHandler,
|
|
1
|
+
import { DropdownHandler, OnChange, DropdownArgs } from '@sebgroup/extract';
|
|
2
2
|
import { HTMLAttributes, InputHTMLAttributes, RefObject } from 'react';
|
|
3
|
-
import { IValidator } from
|
|
4
|
-
interface HookArgs {
|
|
5
|
-
id?: string;
|
|
6
|
-
texts?: DropdownTexts;
|
|
7
|
-
options: DropdownOption[];
|
|
8
|
-
multiSelect?: boolean;
|
|
9
|
-
searchable?: boolean;
|
|
10
|
-
searchableProperties?: string[];
|
|
11
|
-
loop?: boolean;
|
|
12
|
-
selectValue?: string;
|
|
13
|
-
useValue?: string;
|
|
14
|
-
display?: string;
|
|
3
|
+
import { IValidator } from '@sebgroup/extract';
|
|
4
|
+
interface HookArgs extends DropdownArgs {
|
|
15
5
|
togglerRef: RefObject<HTMLElement>;
|
|
16
6
|
listboxRef: RefObject<HTMLElement>;
|
|
17
|
-
onChange?:
|
|
7
|
+
onChange?: OnChange;
|
|
18
8
|
validator?: IValidator;
|
|
19
9
|
}
|
|
20
10
|
declare type Props = HTMLAttributes<HTMLElement>;
|
|
@@ -35,5 +25,5 @@ interface HookResult {
|
|
|
35
25
|
listItems: Props[];
|
|
36
26
|
multiSelectProps: MultiSelectProps;
|
|
37
27
|
}
|
|
38
|
-
export declare const useDropdown: ({ id, texts, options, loop, multiSelect, searchable,
|
|
28
|
+
export declare const useDropdown: ({ id, value, texts, options, loop, multiSelect, searchable, searchFilter, compareWith, useValue, display, togglerRef, listboxRef, onChange, validator, }: HookArgs) => HookResult;
|
|
39
29
|
export {};
|
|
@@ -6,6 +6,7 @@ export interface ButtonProps {
|
|
|
6
6
|
variant?: ButtonVariant;
|
|
7
7
|
active?: boolean;
|
|
8
8
|
onClick?: MouseEventHandler<HTMLButtonElement>;
|
|
9
|
+
disabled?: boolean;
|
|
9
10
|
}
|
|
10
|
-
export declare function Button({ children, variant, onClick, active, type, }: ButtonProps): JSX.Element;
|
|
11
|
+
export declare function Button({ children, variant, onClick, disabled, active, type, }: ButtonProps): JSX.Element;
|
|
11
12
|
export default Button;
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sebgroup/green-react",
|
|
3
|
-
"version": "1.0.0-beta.
|
|
3
|
+
"version": "1.0.0-beta.25",
|
|
4
4
|
"peerDependencies": {
|
|
5
5
|
"react": "^17 || ^18",
|
|
6
6
|
"react-dom": "^17 || ^18"
|
|
7
7
|
},
|
|
8
8
|
"dependencies": {
|
|
9
|
-
"@sebgroup/chlorophyll": "^1.0.0-beta.
|
|
10
|
-
"@sebgroup/extract": "^1.0.0-beta.
|
|
9
|
+
"@sebgroup/chlorophyll": "^1.0.0-beta.26",
|
|
10
|
+
"@sebgroup/extract": "^1.0.0-beta.25"
|
|
11
11
|
},
|
|
12
12
|
"description": "React components built on top of @sebgroup/chlorophyll.",
|
|
13
13
|
"repository": {
|