powell-react 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- package/api/PowellProvider.tsx +37 -0
- package/api/api.ts +126 -0
- package/api/configService.ts +4 -0
- package/api/index.ts +4 -0
- package/api/powellDefaults.ts +11 -0
- package/components/AutoComplete/AutoComplete.scss +126 -0
- package/components/AutoComplete/AutoComplete.tsx +184 -0
- package/components/AutoComplete/index.ts +1 -0
- package/components/Button/Button.tsx +85 -0
- package/components/Button/index.ts +1 -0
- package/components/Checkbox/Checkbox.scss +35 -0
- package/components/Checkbox/Checkbox.tsx +136 -0
- package/components/Checkbox/index.ts +1 -0
- package/components/Dropdown/Dropdown.scss +126 -0
- package/components/Dropdown/Dropdown.tsx +184 -0
- package/components/Dropdown/index.ts +1 -0
- package/components/ErrorMessage/ErrorMessage.scss +7 -0
- package/components/ErrorMessage/ErrorMessage.tsx +23 -0
- package/components/ErrorMessage/index.ts +1 -0
- package/components/FormContainer/FormContainer.tsx +49 -0
- package/components/FormContainer/FormContext.tsx +17 -0
- package/components/FormContainer/index.ts +2 -0
- package/components/InputText/InputText.scss +126 -0
- package/components/InputText/InputText.tsx +184 -0
- package/components/InputText/index.ts +1 -0
- package/components/InputTextarea/InputTextarea.scss +126 -0
- package/components/InputTextarea/InputTextarea.tsx +181 -0
- package/components/InputTextarea/index.ts +1 -0
- package/hooks/index.ts +4 -0
- package/hooks/useApplyConfig.ts +36 -0
- package/hooks/useFormContext.ts +14 -0
- package/hooks/usePowellConfig.ts +64 -0
- package/hooks/useTransform.ts +27 -0
- package/index.js +1 -0
- package/models/common.ts +7 -0
- package/models/config.ts +86 -0
- package/models/forms.ts +23 -0
- package/models/index.ts +3 -0
- package/package.json +16 -0
- package/themes/arya-blue.css +1 -0
- package/themes/arya-green.css +1 -0
- package/themes/arya-orange.css +1 -0
- package/themes/arya-purple.css +1 -0
- package/themes/bootstrap4-dark-blue.css +1 -0
- package/themes/bootstrap4-dark-purple.css +1 -0
- package/themes/bootstrap4-light-blue.css +1 -0
- package/themes/bootstrap4-light-purple.css +1 -0
- package/themes/fluent-light.css +1 -0
- package/themes/lara-dark-amber.css +1 -0
- package/themes/lara-dark-blue.css +1 -0
- package/themes/lara-dark-cyan.css +1 -0
- package/themes/lara-dark-green.css +1 -0
- package/themes/lara-dark-indigo.css +1 -0
- package/themes/lara-dark-pink.css +1 -0
- package/themes/lara-dark-purple.css +1 -0
- package/themes/lara-dark-teal.css +1 -0
- package/themes/lara-light-amber.css +1 -0
- package/themes/lara-light-blue.css +1 -0
- package/themes/lara-light-cyan.css +1 -0
- package/themes/lara-light-green.css +1 -0
- package/themes/lara-light-indigo.css +1 -0
- package/themes/lara-light-pink.css +1 -0
- package/themes/lara-light-purple.css +1 -0
- package/themes/lara-light-teal.css +1 -0
- package/themes/luna-amber.css +1 -0
- package/themes/luna-blue.css +1 -0
- package/themes/luna-green.css +1 -0
- package/themes/luna-pink.css +1 -0
- package/themes/md-dark-deeppurple.css +1 -0
- package/themes/md-dark-indigo.css +1 -0
- package/themes/md-light-deeppurple.css +1 -0
- package/themes/md-light-indigo.css +1 -0
- package/themes/mdc-dark-deeppurple.css +1 -0
- package/themes/mdc-dark-indigo.css +1 -0
- package/themes/mdc-light-deeppurple.css +1 -0
- package/themes/mdc-light-indigo.css +1 -0
- package/themes/mira.css +1 -0
- package/themes/nano.css +1 -0
- package/themes/nova-accent.css +1 -0
- package/themes/nova-alt.css +1 -0
- package/themes/nova.css +1 -0
- package/themes/rhea.css +1 -0
- package/themes/saga-blue.css +1 -0
- package/themes/saga-green.css +1 -0
- package/themes/saga-orange.css +1 -0
- package/themes/saga-purple.css +1 -0
- package/themes/soho-dark.css +1 -0
- package/themes/soho-light.css +1 -0
- package/themes/tailwind-light.css +1 -0
- package/themes/vela-blue.css +1 -0
- package/themes/vela-green.css +1 -0
- package/themes/vela-orange.css +1 -0
- package/themes/vela-purple.css +1 -0
- package/themes/viva-dark.css +1 -0
- package/themes/viva-light.css +1 -0
- package/utils/globalState.ts +96 -0
- package/utils/index.ts +2 -0
- package/utils/utilsService.tsx +39 -0
package/models/config.ts
ADDED
@@ -0,0 +1,86 @@
|
|
1
|
+
import {PrimeAPIOptions} from "@powell/api";
|
2
|
+
import {Size} from "@powell/models/common";
|
3
|
+
import {FixLabelPosition, LabelPosition} from "@powell/models/forms";
|
4
|
+
|
5
|
+
export type ThemeName =
|
6
|
+
"arya-blue" |
|
7
|
+
"arya-green" |
|
8
|
+
"arya-orange" |
|
9
|
+
"arya-purple" |
|
10
|
+
"bootstrap4-dark-blue" |
|
11
|
+
"bootstrap4-dark-purple" |
|
12
|
+
"bootstrap4-light-blue" |
|
13
|
+
"bootstrap4-light-purple" |
|
14
|
+
"fluent-light" |
|
15
|
+
"lara-dark-amber" |
|
16
|
+
"lara-dark-blue" |
|
17
|
+
"lara-dark-cyan" |
|
18
|
+
"lara-dark-green" |
|
19
|
+
"lara-dark-indigo" |
|
20
|
+
"lara-dark-pink" |
|
21
|
+
"lara-dark-purple" |
|
22
|
+
"lara-dark-teal" |
|
23
|
+
"lara-light-amber" |
|
24
|
+
"lara-light-blue" |
|
25
|
+
"lara-light-cyan" |
|
26
|
+
"lara-light-green" |
|
27
|
+
"lara-light-indigo" |
|
28
|
+
"lara-light-pink" |
|
29
|
+
"lara-light-purple" |
|
30
|
+
"lara-light-teal" |
|
31
|
+
"luna-amber" |
|
32
|
+
"luna-blue" |
|
33
|
+
"luna-green" |
|
34
|
+
"luna-pink" |
|
35
|
+
"md-dark-deeppurple" |
|
36
|
+
"md-dark-indigo" |
|
37
|
+
"md-light-deeppurple" |
|
38
|
+
"md-light-indigo" |
|
39
|
+
"mdc-dark-deeppurple" |
|
40
|
+
"mdc-dark-indigo" |
|
41
|
+
"mdc-light-deeppurple" |
|
42
|
+
"mdc-light-indigo" |
|
43
|
+
"mira" |
|
44
|
+
"nano" |
|
45
|
+
"nova" |
|
46
|
+
"nova-accent" |
|
47
|
+
"nova-alt" |
|
48
|
+
"rhea" |
|
49
|
+
"saga-blue" |
|
50
|
+
"saga-green" |
|
51
|
+
"saga-orange" |
|
52
|
+
"saga-purple" |
|
53
|
+
"soho-dark" |
|
54
|
+
"soho-light" |
|
55
|
+
"tailwind-light" |
|
56
|
+
"vela-blue" |
|
57
|
+
"vela-green" |
|
58
|
+
"vela-orange" |
|
59
|
+
"vela-purple" |
|
60
|
+
"viva-dark" |
|
61
|
+
"viva-light";
|
62
|
+
|
63
|
+
type OmittedPrimeApiOptions = Omit<PrimeAPIOptions,
|
64
|
+
"setAppendTo" |
|
65
|
+
"setStyleContainer" |
|
66
|
+
"setAutoZIndex" |
|
67
|
+
"setCssTransition" |
|
68
|
+
"setFilterMatchModeOptions" |
|
69
|
+
"setHideOverlaysOnDocumentScrolling" |
|
70
|
+
"setInputStyle" |
|
71
|
+
"setLocale" |
|
72
|
+
"setNonce" |
|
73
|
+
"setNullSortOrder" |
|
74
|
+
"setRipple" |
|
75
|
+
"setZIndex" |
|
76
|
+
"setPt" |
|
77
|
+
"changeTheme">;
|
78
|
+
|
79
|
+
export interface PowellConfig extends OmittedPrimeApiOptions {
|
80
|
+
theme?: ThemeName;
|
81
|
+
rtl?: boolean;
|
82
|
+
showRequiredStar?: boolean;
|
83
|
+
inputSize?: Size;
|
84
|
+
labelPosition?: LabelPosition;
|
85
|
+
fixLabelPosition?: FixLabelPosition;
|
86
|
+
}
|
package/models/forms.ts
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
import {PrimeButtonProps} from "@powell/api";
|
2
|
+
import {ButtonAppearance, Position} from "@powell/models";
|
3
|
+
import {MouseEvent} from "react";
|
4
|
+
|
5
|
+
export type LabelPosition = 'float' | 'fix-side' | 'fix-top';
|
6
|
+
export type FixLabelPosition = Exclude<LabelPosition, 'float'>;
|
7
|
+
export type IconPosition = Exclude<Position, 'top' | 'bottom'>;
|
8
|
+
|
9
|
+
export interface AddonConfig {
|
10
|
+
type: 'button' | 'icon' | 'text';
|
11
|
+
label?: string;
|
12
|
+
severity?: PrimeButtonProps["severity"];
|
13
|
+
appearance?: ButtonAppearance;
|
14
|
+
icon?: string;
|
15
|
+
iconPosition?: IconPosition;
|
16
|
+
text?: string;
|
17
|
+
onClick?: (event: MouseEvent<HTMLElement>) => void;
|
18
|
+
}
|
19
|
+
|
20
|
+
export interface Addon {
|
21
|
+
before?: AddonConfig;
|
22
|
+
after?: AddonConfig;
|
23
|
+
}
|
package/models/index.ts
ADDED
package/package.json
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
{
|
2
|
+
"name": "powell-react",
|
3
|
+
"version": "1.0.0",
|
4
|
+
"main": "index.js",
|
5
|
+
"scripts": {
|
6
|
+
"test": "echo \"Error: no test specified\" && exit 1"
|
7
|
+
},
|
8
|
+
"peerDependencies": {
|
9
|
+
"primeicons": "^7.0.0",
|
10
|
+
"primereact": "^10.7.0",
|
11
|
+
"react": "^18.2.0"
|
12
|
+
},
|
13
|
+
"author": "",
|
14
|
+
"license": "ISC",
|
15
|
+
"description": ""
|
16
|
+
}
|
@@ -0,0 +1 @@
|
|
1
|
+
@import "primereact/resources/themes/arya-blue/theme.css" layer(primereact);
|
@@ -0,0 +1 @@
|
|
1
|
+
@import "primereact/resources/themes/arya-green/theme.css" layer(primereact);
|
@@ -0,0 +1 @@
|
|
1
|
+
@import "primereact/resources/themes/arya-orange/theme.css" layer(primereact);
|
@@ -0,0 +1 @@
|
|
1
|
+
@import "primereact/resources/themes/arya-purple/theme.css" layer(primereact);
|
@@ -0,0 +1 @@
|
|
1
|
+
@import "primereact/resources/themes/bootstrap4-dark-blue/theme.css" layer(primereact);
|
@@ -0,0 +1 @@
|
|
1
|
+
@import "primereact/resources/themes/bootstrap4-dark-purple/theme.css" layer(primereact);
|
@@ -0,0 +1 @@
|
|
1
|
+
@import "primereact/resources/themes/bootstrap4-light-blue/theme.css" layer(primereact);
|
@@ -0,0 +1 @@
|
|
1
|
+
@import "primereact/resources/themes/bootstrap4-light-purple/theme.css" layer(primereact);
|
@@ -0,0 +1 @@
|
|
1
|
+
@import "primereact/resources/themes/fluent-light/theme.css" layer(primereact);
|
@@ -0,0 +1 @@
|
|
1
|
+
@import "primereact/resources/themes/lara-dark-amber/theme.css" layer(primereact);
|
@@ -0,0 +1 @@
|
|
1
|
+
@import "primereact/resources/themes/lara-dark-blue/theme.css" layer(primereact);
|
@@ -0,0 +1 @@
|
|
1
|
+
@import "primereact/resources/themes/lara-dark-cyan/theme.css" layer(primereact);
|
@@ -0,0 +1 @@
|
|
1
|
+
@import "primereact/resources/themes/lara-dark-green/theme.css" layer(primereact);
|
@@ -0,0 +1 @@
|
|
1
|
+
@import "primereact/resources/themes/lara-dark-indigo/theme.css" layer(primereact);
|
@@ -0,0 +1 @@
|
|
1
|
+
@import "primereact/resources/themes/lara-dark-pink/theme.css" layer(primereact);
|
@@ -0,0 +1 @@
|
|
1
|
+
@import "primereact/resources/themes/lara-dark-purple/theme.css" layer(primereact);
|
@@ -0,0 +1 @@
|
|
1
|
+
@import "primereact/resources/themes/lara-dark-teal/theme.css" layer(primereact);
|
@@ -0,0 +1 @@
|
|
1
|
+
@import "primereact/resources/themes/lara-light-amber/theme.css" layer(primereact);
|
@@ -0,0 +1 @@
|
|
1
|
+
@import "primereact/resources/themes/lara-light-blue/theme.css" layer(primereact);
|
@@ -0,0 +1 @@
|
|
1
|
+
@import "primereact/resources/themes/lara-light-cyan/theme.css" layer(primereact);
|
@@ -0,0 +1 @@
|
|
1
|
+
@import "primereact/resources/themes/lara-light-green/theme.css" layer(primereact);
|
@@ -0,0 +1 @@
|
|
1
|
+
@import "primereact/resources/themes/lara-light-indigo/theme.css" layer(primereact);
|
@@ -0,0 +1 @@
|
|
1
|
+
@import "primereact/resources/themes/lara-light-pink/theme.css" layer(primereact);
|
@@ -0,0 +1 @@
|
|
1
|
+
@import "primereact/resources/themes/lara-light-purple/theme.css" layer(primereact);
|
@@ -0,0 +1 @@
|
|
1
|
+
@import "primereact/resources/themes/lara-light-teal/theme.css" layer(primereact);
|
@@ -0,0 +1 @@
|
|
1
|
+
@import "primereact/resources/themes/luna-amber/theme.css" layer(primereact);
|
@@ -0,0 +1 @@
|
|
1
|
+
@import "primereact/resources/themes/luna-blue/theme.css" layer(primereact);
|
@@ -0,0 +1 @@
|
|
1
|
+
@import "primereact/resources/themes/luna-green/theme.css" layer(primereact);
|
@@ -0,0 +1 @@
|
|
1
|
+
@import "primereact/resources/themes/luna-pink/theme.css" layer(primereact);
|
@@ -0,0 +1 @@
|
|
1
|
+
@import "primereact/resources/themes/md-dark-deeppurple/theme.css" layer(primereact);
|
@@ -0,0 +1 @@
|
|
1
|
+
@import "primereact/resources/themes/md-dark-indigo/theme.css" layer(primereact);
|
@@ -0,0 +1 @@
|
|
1
|
+
@import "primereact/resources/themes/md-light-deeppurple/theme.css" layer(primereact);
|
@@ -0,0 +1 @@
|
|
1
|
+
@import "primereact/resources/themes/md-light-indigo/theme.css" layer(primereact);
|
@@ -0,0 +1 @@
|
|
1
|
+
@import "primereact/resources/themes/mdc-light-indigo/theme.css" layer(primereact);
|
@@ -0,0 +1 @@
|
|
1
|
+
@import "primereact/resources/themes/mdc-dark-indigo/theme.css" layer(primereact);
|
@@ -0,0 +1 @@
|
|
1
|
+
@import "primereact/resources/themes/mdc-light-deeppurple/theme.css" layer(primereact);
|
@@ -0,0 +1 @@
|
|
1
|
+
@import "primereact/resources/themes/mdc-light-indigo/theme.css" layer(primereact);
|
package/themes/mira.css
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
@import "primereact/resources/themes/nano/theme.css" layer(primereact);
|
package/themes/nano.css
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
@import "primereact/resources/themes/nano/theme.css" layer(primereact);
|
@@ -0,0 +1 @@
|
|
1
|
+
@import "primereact/resources/themes/nova-accent/theme.css" layer(primereact);
|
@@ -0,0 +1 @@
|
|
1
|
+
@import "primereact/resources/themes/nova-alt/theme.css" layer(primereact);
|
package/themes/nova.css
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
@import "primereact/resources/themes/nova/theme.css" layer(primereact);
|
package/themes/rhea.css
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
@import "primereact/resources/themes/rhea/theme.css" layer(primereact);
|
@@ -0,0 +1 @@
|
|
1
|
+
@import "primereact/resources/themes/saga-blue/theme.css" layer(primereact);
|
@@ -0,0 +1 @@
|
|
1
|
+
@import "primereact/resources/themes/saga-green/theme.css" layer(primereact);
|
@@ -0,0 +1 @@
|
|
1
|
+
@import "primereact/resources/themes/saga-orange/theme.css" layer(primereact);
|
@@ -0,0 +1 @@
|
|
1
|
+
@import "primereact/resources/themes/saga-purple/theme.css" layer(primereact);
|
@@ -0,0 +1 @@
|
|
1
|
+
@import "primereact/resources/themes/soho-dark/theme.css" layer(primereact);
|
@@ -0,0 +1 @@
|
|
1
|
+
@import "primereact/resources/themes/soho-light/theme.css" layer(primereact);
|
@@ -0,0 +1 @@
|
|
1
|
+
@import "primereact/resources/themes/tailwind-light/theme.css" layer(primereact);
|
@@ -0,0 +1 @@
|
|
1
|
+
@import "primereact/resources/themes/vela-blue/theme.css" layer(primereact);
|
@@ -0,0 +1 @@
|
|
1
|
+
@import "primereact/resources/themes/vela-green/theme.css" layer(primereact);
|
@@ -0,0 +1 @@
|
|
1
|
+
@import "primereact/resources/themes/vela-orange/theme.css" layer(primereact);
|
@@ -0,0 +1 @@
|
|
1
|
+
@import "primereact/resources/themes/vela-purple/theme.css" layer(primereact);
|
@@ -0,0 +1 @@
|
|
1
|
+
@import "primereact/resources/themes/viva-dark/theme.css" layer(primereact);
|
@@ -0,0 +1 @@
|
|
1
|
+
@import "primereact/resources/themes/viva-light/theme.css" layer(primereact);
|
@@ -0,0 +1,96 @@
|
|
1
|
+
import {SetStateAction, useEffect, useLayoutEffect, useRef, useState} from "react";
|
2
|
+
|
3
|
+
type Set<T> = (newState: SetStateAction<T>, callback?: (newState: T) => void) => void;
|
4
|
+
|
5
|
+
type UseSelector<T> = <TSelected = unknown>(selector: (state: T) => TSelected, equalityFn?: Comparator<TSelected>) => TSelected;
|
6
|
+
|
7
|
+
export interface StateWithValue<T> {
|
8
|
+
use: () => [T, Set<T>];
|
9
|
+
useValue: () => T;
|
10
|
+
get: () => T;
|
11
|
+
useSelector: UseSelector<T>;
|
12
|
+
set: Set<T>;
|
13
|
+
reset: () => void;
|
14
|
+
subscribe(subscriber: SubscriberFunc<T>): () => void;
|
15
|
+
}
|
16
|
+
|
17
|
+
type SubscriberFunc<T> = (newState: T, previousState: T) => void;
|
18
|
+
|
19
|
+
interface Options<T> {
|
20
|
+
onSet?: SubscriberFunc<T>;
|
21
|
+
}
|
22
|
+
|
23
|
+
type Comparator<TSelected = unknown> = (a: TSelected, b: TSelected) => boolean;
|
24
|
+
|
25
|
+
const useIsomorphicLayoutEffect =
|
26
|
+
typeof window !== "undefined" || typeof document !== "undefined"
|
27
|
+
? useLayoutEffect
|
28
|
+
: useEffect;
|
29
|
+
|
30
|
+
const equ: Comparator = (a, b) => a === b;
|
31
|
+
|
32
|
+
const FR = {};
|
33
|
+
|
34
|
+
function useComparator<T>(v: T, c: Comparator<T> = equ): T {
|
35
|
+
const f = useRef(FR as T);
|
36
|
+
let nv = f.current;
|
37
|
+
|
38
|
+
useIsomorphicLayoutEffect(() => {
|
39
|
+
f.current = nv;
|
40
|
+
});
|
41
|
+
|
42
|
+
if (f.current === FR || !c(v, f.current)) {
|
43
|
+
nv = v;
|
44
|
+
}
|
45
|
+
|
46
|
+
return nv;
|
47
|
+
}
|
48
|
+
|
49
|
+
export function globalState<T>(initialValue: T, options?: Options<T>): StateWithValue<T> {
|
50
|
+
let sb: SubscriberFunc<T>[] = [];
|
51
|
+
|
52
|
+
let v: T = initialValue;
|
53
|
+
|
54
|
+
function set(newValue: SetStateAction<T>, callback?: SubscriberFunc<T>) {
|
55
|
+
const pv = v;
|
56
|
+
v = newValue instanceof Function ? newValue(v) : newValue;
|
57
|
+
|
58
|
+
setTimeout(() => {
|
59
|
+
sb.forEach((c) => c(v, pv));
|
60
|
+
callback?.(v, pv);
|
61
|
+
options?.onSet?.(v, pv);
|
62
|
+
});
|
63
|
+
}
|
64
|
+
|
65
|
+
function subscribe(subscriber: SubscriberFunc<T>): () => void {
|
66
|
+
sb.push(subscriber);
|
67
|
+
return () => {
|
68
|
+
sb = sb.filter((f) => f !== subscriber);
|
69
|
+
};
|
70
|
+
}
|
71
|
+
|
72
|
+
function useSubscription(subscriber: SubscriberFunc<T>) {
|
73
|
+
useIsomorphicLayoutEffect(() => subscribe(subscriber), [subscriber]);
|
74
|
+
}
|
75
|
+
|
76
|
+
function use(): [T, Set<T>] {
|
77
|
+
const [l, s] = useState<T>(v);
|
78
|
+
useSubscription(s);
|
79
|
+
return [l, set];
|
80
|
+
}
|
81
|
+
|
82
|
+
function useSelector<TSelected = unknown>(selector: (state: T) => TSelected, comparator: Comparator<TSelected> = equ): TSelected {
|
83
|
+
const [rv] = use();
|
84
|
+
return useComparator(selector(rv), comparator);
|
85
|
+
}
|
86
|
+
|
87
|
+
return {
|
88
|
+
use,
|
89
|
+
useSelector,
|
90
|
+
useValue: () => use()[0],
|
91
|
+
get: () => v,
|
92
|
+
set,
|
93
|
+
reset: () => set(initialValue),
|
94
|
+
subscribe,
|
95
|
+
};
|
96
|
+
}
|
package/utils/index.ts
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
import {AddonConfig} from "@powell/models";
|
2
|
+
import {Button} from "@powell/components/Button";
|
3
|
+
import {SafeAny} from "@powell/models/common";
|
4
|
+
import {UseTransformOptions} from "@powell/hooks";
|
5
|
+
|
6
|
+
export const getAddonTemplate = (config?: AddonConfig) => {
|
7
|
+
if (!config) {
|
8
|
+
return <></>
|
9
|
+
}
|
10
|
+
const {type, ...rest} = config;
|
11
|
+
switch (type) {
|
12
|
+
case "button":
|
13
|
+
return <Button {...rest} />
|
14
|
+
case "icon":
|
15
|
+
return (
|
16
|
+
<span className="p-inputgroup-addon" onClick={rest?.onClick}>
|
17
|
+
<i className={rest.icon}></i>
|
18
|
+
</span>
|
19
|
+
)
|
20
|
+
case "text":
|
21
|
+
return <span className="p-inputgroup-addon">{rest.text}</span>
|
22
|
+
}
|
23
|
+
}
|
24
|
+
|
25
|
+
export const transformer = (options: UseTransformOptions) => {
|
26
|
+
const value = options.transform?.input?.(options.value) || options.value;
|
27
|
+
const onChange = (...event: SafeAny[]) => {
|
28
|
+
if (typeof options.transform?.output === 'function') {
|
29
|
+
options.onChange(options.transform.output(...event));
|
30
|
+
} else {
|
31
|
+
options.onChange(...event);
|
32
|
+
}
|
33
|
+
}
|
34
|
+
|
35
|
+
return {
|
36
|
+
value,
|
37
|
+
onChange
|
38
|
+
}
|
39
|
+
}
|