@codeleap/web 7.1.4 → 7.3.0-next.0
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/components/CropPicker/types.d.ts +1 -1
- package/dist/components/CropPicker/types.d.ts.map +1 -1
- package/dist/components/Field/useFieldInput.js +1 -1
- package/dist/components/Field/useFieldInput.js.map +1 -1
- package/dist/components/RadioInput/index.d.ts +3 -1
- package/dist/components/RadioInput/index.d.ts.map +1 -1
- package/dist/components/RadioInput/index.js +7 -3
- package/dist/components/RadioInput/index.js.map +1 -1
- package/dist/components/RadioInput/types.d.ts +7 -4
- package/dist/components/RadioInput/types.d.ts.map +1 -1
- package/dist/components/SearchInput/index.js +1 -1
- package/dist/components/SearchInput/index.js.map +1 -1
- package/package.json +18 -18
- package/src/components/CropPicker/types.ts +1 -0
- package/src/components/Field/useFieldInput.ts +1 -1
- package/src/components/RadioInput/index.tsx +16 -5
- package/src/components/RadioInput/types.ts +8 -4
- package/src/components/SearchInput/index.tsx +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/components/CropPicker/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAc,MAAM,kBAAkB,CAAA;AACxD,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAA;AAC3C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAA;AACtD,OAAO,EAAE,qBAAqB,EAAE,MAAM,UAAU,CAAA;AAChD,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AACvC,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAEjC,KAAK,eAAe,GAAG,IAAI,CAAC,cAAc,EAAE,MAAM,GAAG,UAAU,GAAG,YAAY,GAAG,OAAO,CAAC,CAAA;AAEzF,MAAM,WAAW,kBAAkB;CAAG;AAEtC,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AAM,CAAC,EAAE,MAAM,CAAA;IACf,2IAA2I;IAC3I,SAAS,CAAC,EAAE,eAAe,CAAA;IAC3B,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAA;IAC1B,GAAG,CAAC,EAAE,SAAS,CAAC,YAAY,GAAG,IAAI,CAAC,CAAA;CACrC,CAAA;AACH,OAAO,EAAE,cAAc,EAAE,CAAA"}
|
|
@@ -13,7 +13,7 @@ import { TypeGuards } from '@codeleap/types';
|
|
|
13
13
|
*/
|
|
14
14
|
export function useFieldInput(field, defaultField = fields.text, internalState, params = {}, deps = []) {
|
|
15
15
|
const { value, onValueChange } = internalState;
|
|
16
|
-
const hasInternalState = useMemo(() => TypeGuards.isFunction(onValueChange) && !TypeGuards.
|
|
16
|
+
const hasInternalState = useMemo(() => TypeGuards.isFunction(onValueChange) && !TypeGuards.isUndefined(value), []);
|
|
17
17
|
const wrapperRef = useRef(undefined);
|
|
18
18
|
const innerInputRef = useRef(null);
|
|
19
19
|
const fieldHandle = hasInternalState ? {} : useField(field, [
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useFieldInput.js","sourceRoot":"","sources":["../../../src/components/Field/useFieldInput.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,OAAO,CAAA;AACvC,OAAO,EAAoB,MAAM,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAA;AACnE,OAAO,EAAa,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAEvD;;;;;;;;;GASG;AACH,MAAM,UAAU,aAAa,CAC3B,KAAQ,EACR,eAA2C,MAAM,CAAC,IAAe,EACjE,aAA8D,EAC9D,SAAgC,EAAE,EAClC,OAAc,EAAE;IAEhB,MAAM,EAAE,KAAK,EAAE,aAAa,EAAE,GAAG,aAAa,CAAA;IAE9C,MAAM,gBAAgB,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC,UAAU,CAAC,UAAU,CAAC,aAAa,CAAC,IAA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U,CAAA;IAE1C,OAAO;QACL,WAAW;QACX,UAAU;QACV,UAAU;QACV,aAAa;QACb,UAAU,EAAE,CAAC,gBAAgB,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,WAAW,EAAE,KAAK,CAAM;QAChE,kBAAkB,EAAE,gBAAgB,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,WAAW,EAAE,QAAQ;KAC7E,CAAA;AACH,CAAC"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { RadioInputProps } from './types';
|
|
1
|
+
import { RadioOptionProps, RadioInputProps } from './types';
|
|
2
2
|
export * from './styles';
|
|
3
3
|
export * from './types';
|
|
4
|
+
export declare const RadioOption: <T extends string | number>(props: RadioOptionProps<T>) => import("@emotion/react/jsx-runtime").JSX.Element;
|
|
4
5
|
/**
|
|
5
6
|
* Single-select radio group that renders each option as a `Touchable` row with an indicator circle and label, separated by optional dividers.
|
|
6
7
|
* Integrates with `@codeleap/form` via `SelectableField`; pair with `field` or `value`/`onValueChange`.
|
|
@@ -8,6 +9,7 @@ export * from './types';
|
|
|
8
9
|
*/
|
|
9
10
|
export declare const RadioInput: {
|
|
10
11
|
<T extends string | number>(props: RadioInputProps<T>): import("@emotion/react/jsx-runtime").JSX.Element;
|
|
12
|
+
Option: <T extends string | number>(props: RadioOptionProps<T>) => import("@emotion/react/jsx-runtime").JSX.Element;
|
|
11
13
|
styleRegistryName: string;
|
|
12
14
|
elements: string[];
|
|
13
15
|
rootElement: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/RadioInput/index.tsx"],"names":[],"mappings":"AAKA,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/RadioInput/index.tsx"],"names":[],"mappings":"AAKA,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AAQ3D,cAAc,UAAU,CAAA;AACxB,cAAc,SAAS,CAAA;AAEvB,eAAO,MAAM,WAAW,GAAI,CAAC,SAAS,MAAM,GAAG,MAAM,EAAE,OAAO,gBAAgB,CAAC,CAAC,CAAC,qDAwChF,CAAA;AAED;;;;GAIG;AACH,eAAO,MAAM,UAAU;KAAI,CAAC,SAAS,MAAM,GAAG,MAAM,SAAS,eAAe,CAAC,CAAC,CAAC;aA/CnD,CAAC,SAAS,MAAM,GAAG,MAAM,SAAS,gBAAgB,CAAC,CAAC,CAAC;;;;;CAuHhF,CAAA"}
|
|
@@ -12,8 +12,11 @@ import { Field } from '../Field';
|
|
|
12
12
|
import { toDataAttrs } from '../../lib';
|
|
13
13
|
export * from './styles';
|
|
14
14
|
export * from './types';
|
|
15
|
-
const
|
|
16
|
-
const { debugName,
|
|
15
|
+
export const RadioOption = (props) => {
|
|
16
|
+
const { debugName, disabled, styles: providedStyles, fieldContext, style, selected, onSelect, separator = false, } = props;
|
|
17
|
+
const item = 'item' in props ? props?.item : { label: props.label, value: props?.value, disabled: disabled || props?.disabled };
|
|
18
|
+
const ownStyles = useStylesFor(RadioInput.styleRegistryName, style, fieldContext);
|
|
19
|
+
const styles = providedStyles ?? ownStyles;
|
|
17
20
|
const isDisabled = disabled || item?.disabled;
|
|
18
21
|
const stateAttrs = toDataAttrs({ selected: !!selected, disabled: !!isDisabled });
|
|
19
22
|
return (_jsxs(React.Fragment, { children: [_jsxs(Touchable, { debugName: `${debugName} option ${item.value}`, style: styles.optionWrapper, onPress: onSelect, disabled: isDisabled, children: [_jsx(View, { style: styles.optionIndicator, ...stateAttrs, children: _jsx(View, { style: styles.optionIndicatorInner, ...stateAttrs }) }), TypeGuards.isString(item.label) ? _jsx(Text, { style: styles.optionLabel, text: item.label }) : item.label] }), separator ? _jsx(View, { style: styles.optionSeparator }) : null] }));
|
|
@@ -37,8 +40,9 @@ export const RadioInput = (props) => {
|
|
|
37
40
|
focused: false,
|
|
38
41
|
};
|
|
39
42
|
const styles = useStylesFor(RadioInput.styleRegistryName, style, fieldContext);
|
|
40
|
-
return (_jsx(Field.Provider, { context: fieldContext, label: label, helper: validation?.showError ? validation?.message : helper, leftSection: leftSection, rightSection: rightSection, componentName: 'radioInput', children: _jsxs(Field.Wrapper, { ref: wrapperRef, style: styles.wrapper, children: [_jsx(Field.Heading, { style: styles.heading }), _jsx(View, { style: styles.box, children: options?.map((item, idx) => (_jsx(
|
|
43
|
+
return (_jsx(Field.Provider, { context: fieldContext, label: label, helper: validation?.showError ? validation?.message : helper, leftSection: leftSection, rightSection: rightSection, componentName: 'radioInput', children: _jsxs(Field.Wrapper, { ref: wrapperRef, style: styles.wrapper, children: [_jsx(Field.Heading, { style: styles.heading }), _jsx(View, { style: styles.box, children: options?.map((item, idx) => (_jsx(RadioOption, { debugName: debugName, item: item, fieldContext: fieldContext, disabled: disabled, styles: styles, selected: inputValue === item.value, onSelect: () => onInputValueChange(item.value), separator: idx < options?.length - 1 }, idx))) }), _jsx(Field.Helper, { style: styles.helper })] }) }));
|
|
41
44
|
};
|
|
45
|
+
RadioInput.Option = RadioOption;
|
|
42
46
|
RadioInput.styleRegistryName = 'RadioInput';
|
|
43
47
|
RadioInput.elements = [...Field.elements, 'optionWrapper', 'optionLabel', 'optionIndicator', 'optionIndicatorInner', 'optionSeparator'];
|
|
44
48
|
RadioInput.rootElement = 'wrapper';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/RadioInput/index.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAA;AAC9B,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AACxC,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAC5C,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAA;AAE9B,OAAO,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAA;AAC3D,OAAO,EAAE,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MAAM,EACd,QAAQ,EAAE,UAAU,KAAK,IAAI,CAAC,KAAK,EACnC,QAAQ,EAAE,GAAG,EAAE,CAAC,kBAAkB,CAAC,IAAI,CAAC,KAAK,CAAC,EAC9C,SAAS,EAAE,GAAG,GAAG,OAAO,EAAE,MAAM,GAAG,CAAC,IAN/B,GAAG,CAOR,CACH,CAAC,GACG,EAEP,KAAC,KAAK,CAAC,MAAM,IAAC,KAAK,EAAE,MAAM,CAAC,MAAM,GAAI,IACxB,GACD,CAClB,CAAA;AACH,CAAC,CAAA;AAED,UAAU,CAAC,MAAM,GAAG,WAAW,CAAA;AAE/B,UAAU,CAAC,iBAAiB,GAAG,YAAY,CAAA;AAC3C,UAAU,CAAC,QAAQ,GAAG,CAAC,GAAG,KAAK,CAAC,QAAQ,EAAE,eAAe,EAAE,aAAa,EAAE,iBAAiB,EAAE,sBAAsB,EAAE,iBAAiB,CAAC,CAAA;AACvI,UAAU,CAAC,WAAW,GAAG,SAAS,CAAA;AAClC,UAAU,CAAC,YAAY,GAAG,EAA+C,CAAA;AAEzE,gBAAgB,CAAC,iBAAiB,CAAC,UAAU,CAAC,CAAA"}
|
|
@@ -2,7 +2,7 @@ import { Option } from '@codeleap/types';
|
|
|
2
2
|
import { ICSS, StyleProp } from '@codeleap/styles';
|
|
3
3
|
import { RadioInputComposition } from './styles';
|
|
4
4
|
import { SelectableField } from '@codeleap/form';
|
|
5
|
-
import { FieldProps } from '../Field';
|
|
5
|
+
import { FieldProps, FieldStateContext } from '../Field';
|
|
6
6
|
type RadioOption<T extends string | number> = Option<T> & {
|
|
7
7
|
disabled?: boolean;
|
|
8
8
|
};
|
|
@@ -24,13 +24,16 @@ export type RadioInputProps<T extends string | number> = Pick<FieldProps, 'label
|
|
|
24
24
|
};
|
|
25
25
|
/** Internal props for the per-option row rendered inside `RadioInput`. */
|
|
26
26
|
export type RadioOptionProps<T extends string | number> = {
|
|
27
|
-
item: RadioOption<T>;
|
|
28
27
|
selected: boolean;
|
|
29
28
|
onSelect(): void;
|
|
30
|
-
|
|
29
|
+
fieldContext?: FieldStateContext;
|
|
30
|
+
style?: RadioInputProps<T>['style'];
|
|
31
|
+
styles?: Record<RadioInputComposition, ICSS>;
|
|
31
32
|
debugName?: string;
|
|
32
33
|
disabled?: boolean;
|
|
33
34
|
separator?: boolean;
|
|
34
|
-
}
|
|
35
|
+
} & (RadioOption<T> | {
|
|
36
|
+
item: RadioOption<T>;
|
|
37
|
+
});
|
|
35
38
|
export {};
|
|
36
39
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/components/RadioInput/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAA;AACxC,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAA;AAClD,OAAO,EAAE,qBAAqB,EAAE,MAAM,UAAU,CAAA;AAChD,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAA;AAChD,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAA;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/components/RadioInput/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAA;AACxC,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAA;AAClD,OAAO,EAAE,qBAAqB,EAAE,MAAM,UAAU,CAAA;AAChD,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAA;AAChD,OAAO,EAAE,UAAU,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAA;AAExD,KAAK,WAAW,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM,IAAI,MAAM,CAAC,CAAC,CAAC,GAAG;IACxD,QAAQ,CAAC,EAAE,OAAO,CAAA;CACnB,CAAA;AAED,MAAM,WAAW,kBAAkB;I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ps,
|
|
14
14
|
...props,
|
|
15
15
|
};
|
|
16
|
-
const hasStateProps = !TypeGuards.
|
|
16
|
+
const hasStateProps = !TypeGuards.isUndefined(value) && TypeGuards.isFunction(onValueChange);
|
|
17
17
|
const [search, setSearch] = hasStateProps ? [value, onValueChange] : useState(defaultValue);
|
|
18
18
|
const setSearchTimeout = React.useRef(null);
|
|
19
19
|
const handleChangeSearch = (value) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/SearchInput/index.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,EAAE,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AACvC,OAAO,EAAE,SAAS,EAAkB,MAAM,cAAc,CAAA;AACxD,OAAO,EAAe,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAwBzD;;;;;GAKG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,KAAuB,EAAE,EAAE;IACrD,MAAM,EACJ,SAAS,EACT,cAAc,EACd,cAAc,EACd,OAAO,EACP,SAAS,EACT,WAAW,EACX,SAAS,EACT,UAAU,EACV,QAAQ,EACR,KAAK,EACL,aAAa,EACb,iBAAiB,EACjB,YAAY,EACZ,GAAG,IAAI,EACR,GAAG;QACF,GAAG,WAAW,CAAC,YAAY;QAC3B,GAAG,KAAK;KACT,CAAA;IAED,MAAM,aAAa,GAAG,CAAC,UAAU,CAAC,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/SearchInput/index.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,EAAE,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AACvC,OAAO,EAAE,SAAS,EAAkB,MAAM,cAAc,CAAA;AACxD,OAAO,EAAe,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAwBzD;;;;;GAKG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,KAAuB,EAAE,EAAE;IACrD,MAAM,EACJ,SA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EAAE,CAAC,CAAA;QACpB,IAAI,UAAU,CAAC,UAAU,CAAC,OAAO,CAAC;YAAE,OAAO,EAAE,EAAE,CAAA;IACjD,CAAC,CAAA;IAED,MAAM,aAAa,GAAG,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,IAAI,SAAS,CAAA;IAG3D,IAAI,YAAY,GAAG,CAAC,KAAuB,EAAE,EAAE;QAC7C,IAAG,CAAC,aAAa;YAAE,OAAO,IAAI,CAAA;QAE9B,OAAO,iBAAiB,EAAE,CAAC;YACzB,GAAG,KAAK;YACR,KAAK,EAAE,WAAW;SACnB,CAAC,IAAI,IAAI,CAAA;IACZ,CAAC,CAAA;IAED,OAAO,CACL,KAAC,SAAS,IACR,KAAK,EAAE,MAAM,EACb,WAAW,EAAE,WAAW,EACxB,aAAa,EAAE,CAAC,KAAK,EAAE,EAAE;YACvB,cAAc,EAAE,CAAC,IAAI,CAAC,CAAA;YACtB,kBAAkB,CAAC,KAAK,CAAC,CAAA;QAC3B,CAAC,EACD,SAAS,EAAE,UAAU,SAAS,EAAE,EAChC,IAAI,EAAC,QAAQ,EAEb,YAAY,EACV,KAAK,EAAE,YAAY,IAAI,YAAY,KAGjC,IAAI,GACR,CACH,CAAA;AACH,CAAC,CAAA;AAED,WAAW,CAAC,YAAY,GAAG;IACzB,QAAQ,EAAE,IAAI;IACd,SAAS,EAAE,IAAI;IACf,SAAS,EAAE,GAAc;IACzB,UAAU,EAAE,QAAmB;IAC/B,YAAY,EAAE,EAAE;CACY,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@codeleap/web",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.3.0-next.0",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"exports": {
|
|
@@ -22,20 +22,20 @@
|
|
|
22
22
|
},
|
|
23
23
|
"license": "UNLICENSED",
|
|
24
24
|
"devDependencies": {
|
|
25
|
-
"@codeleap/config": "7.
|
|
26
|
-
"@codeleap/form": "7.
|
|
27
|
-
"@codeleap/hooks": "7.
|
|
28
|
-
"@codeleap/logger": "7.
|
|
29
|
-
"@codeleap/query": "7.
|
|
30
|
-
"@codeleap/styles": "7.
|
|
31
|
-
"@codeleap/types": "7.
|
|
32
|
-
"@codeleap/utils": "7.
|
|
33
|
-
"@codeleap/store": "7.
|
|
25
|
+
"@codeleap/config": "7.3.0-next.0",
|
|
26
|
+
"@codeleap/form": "7.3.0-next.0",
|
|
27
|
+
"@codeleap/hooks": "7.3.0-next.0",
|
|
28
|
+
"@codeleap/logger": "7.3.0-next.0",
|
|
29
|
+
"@codeleap/query": "7.3.0-next.0",
|
|
30
|
+
"@codeleap/styles": "7.3.0-next.0",
|
|
31
|
+
"@codeleap/types": "7.3.0-next.0",
|
|
32
|
+
"@codeleap/utils": "7.3.0-next.0",
|
|
33
|
+
"@codeleap/store": "7.3.0-next.0",
|
|
34
34
|
"@tanstack/react-query": "5.100.9"
|
|
35
35
|
},
|
|
36
36
|
"scripts": {
|
|
37
37
|
"build": "tsc --build tsconfig.build.json",
|
|
38
|
-
"lint": "eslint
|
|
38
|
+
"lint": "eslint \"./src/**/*.{ts,tsx,js,jsx}\""
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
41
|
"@fastify/deepmerge": "3.1.0",
|
|
@@ -60,13 +60,13 @@
|
|
|
60
60
|
"uuid": "13.0.0"
|
|
61
61
|
},
|
|
62
62
|
"peerDependencies": {
|
|
63
|
-
"@codeleap/types": "7.
|
|
64
|
-
"@codeleap/utils": "7.
|
|
65
|
-
"@codeleap/hooks": "7.
|
|
66
|
-
"@codeleap/query": "7.
|
|
67
|
-
"@codeleap/logger": "7.
|
|
68
|
-
"@codeleap/styles": "7.
|
|
69
|
-
"@codeleap/store": "7.
|
|
63
|
+
"@codeleap/types": "7.3.0-next.0",
|
|
64
|
+
"@codeleap/utils": "7.3.0-next.0",
|
|
65
|
+
"@codeleap/hooks": "7.3.0-next.0",
|
|
66
|
+
"@codeleap/query": "7.3.0-next.0",
|
|
67
|
+
"@codeleap/logger": "7.3.0-next.0",
|
|
68
|
+
"@codeleap/styles": "7.3.0-next.0",
|
|
69
|
+
"@codeleap/store": "7.3.0-next.0",
|
|
70
70
|
"@emotion/react": "11.14.0",
|
|
71
71
|
"@reach/router": "^1.3.4",
|
|
72
72
|
"dayjs": "1.11.18",
|
|
@@ -21,7 +21,7 @@ export function useFieldInput<V, T extends Field<V, any, any, any> = Field<V, a
|
|
|
21
21
|
) {
|
|
22
22
|
const { value, onValueChange } = internalState
|
|
23
23
|
|
|
24
|
-
const hasInternalState = useMemo(() => TypeGuards.isFunction(onValueChange) && !TypeGuards.
|
|
24
|
+
const hasInternalState = useMemo(() => TypeGuards.isFunction(onValueChange) && !TypeGuards.isUndefined(value), [])
|
|
25
25
|
|
|
26
26
|
const wrapperRef = useRef<HTMLDivElement>(undefined)
|
|
27
27
|
|
|
@@ -7,24 +7,32 @@ import { RadioOptionProps, RadioInputProps } from './types'
|
|
|
7
7
|
import { useStylesFor } from '../../lib/hooks/useStylesFor'
|
|
8
8
|
import { WebStyleRegistry } from '../../lib/WebStyleRegistry'
|
|
9
9
|
import { useFieldInput } from '../Field'
|
|
10
|
-
import {
|
|
10
|
+
import { fields } from '@codeleap/form'
|
|
11
11
|
import { Field } from '../Field'
|
|
12
12
|
import { toDataAttrs } from '../../lib'
|
|
13
13
|
|
|
14
14
|
export * from './styles'
|
|
15
15
|
export * from './types'
|
|
16
16
|
|
|
17
|
-
const
|
|
17
|
+
export const RadioOption = <T extends string | number>(props: RadioOptionProps<T>) => {
|
|
18
18
|
const {
|
|
19
19
|
debugName,
|
|
20
|
-
|
|
20
|
+
|
|
21
21
|
disabled,
|
|
22
|
-
styles,
|
|
22
|
+
styles: providedStyles,
|
|
23
|
+
fieldContext,
|
|
24
|
+
style,
|
|
23
25
|
selected,
|
|
24
26
|
onSelect,
|
|
25
27
|
separator = false,
|
|
26
28
|
} = props
|
|
27
29
|
|
|
30
|
+
const item = 'item' in props ? props?.item : { label: props.label, value: props?.value, disabled: disabled || props?.disabled }
|
|
31
|
+
|
|
32
|
+
const ownStyles = useStylesFor(RadioInput.styleRegistryName, style, fieldContext)
|
|
33
|
+
|
|
34
|
+
const styles = providedStyles ?? ownStyles
|
|
35
|
+
|
|
28
36
|
const isDisabled = disabled || item?.disabled
|
|
29
37
|
const stateAttrs = toDataAttrs({ selected: !!selected, disabled: !!isDisabled })
|
|
30
38
|
|
|
@@ -107,10 +115,11 @@ export const RadioInput = <T extends string | number>(props: RadioInputProps<T>)
|
|
|
107
115
|
|
|
108
116
|
<View style={styles.box}>
|
|
109
117
|
{options?.map((item, idx) => (
|
|
110
|
-
<
|
|
118
|
+
<RadioOption
|
|
111
119
|
debugName={debugName}
|
|
112
120
|
item={item}
|
|
113
121
|
key={idx}
|
|
122
|
+
fieldContext={fieldContext}
|
|
114
123
|
disabled={disabled}
|
|
115
124
|
styles={styles}
|
|
116
125
|
selected={inputValue === item.value}
|
|
@@ -126,6 +135,8 @@ export const RadioInput = <T extends string | number>(props: RadioInputProps<T>)
|
|
|
126
135
|
)
|
|
127
136
|
}
|
|
128
137
|
|
|
138
|
+
RadioInput.Option = RadioOption
|
|
139
|
+
|
|
129
140
|
RadioInput.styleRegistryName = 'RadioInput'
|
|
130
141
|
RadioInput.elements = [...Field.elements, 'optionWrapper', 'optionLabel', 'optionIndicator', 'optionIndicatorInner', 'optionSeparator']
|
|
131
142
|
RadioInput.rootElement = 'wrapper'
|
|
@@ -2,7 +2,7 @@ import { Option } from '@codeleap/types'
|
|
|
2
2
|
import { ICSS, StyleProp } from '@codeleap/styles'
|
|
3
3
|
import { RadioInputComposition } from './styles'
|
|
4
4
|
import { SelectableField } from '@codeleap/form'
|
|
5
|
-
import { FieldProps } from '../Field'
|
|
5
|
+
import { FieldProps, FieldStateContext } from '../Field'
|
|
6
6
|
|
|
7
7
|
type RadioOption<T extends string | number> = Option<T> & {
|
|
8
8
|
disabled?: boolean
|
|
@@ -29,11 +29,15 @@ export type RadioInputProps<T extends string | number> =
|
|
|
29
29
|
|
|
30
30
|
/** Internal props for the per-option row rendered inside `RadioInput`. */
|
|
31
31
|
export type RadioOptionProps<T extends string | number> = {
|
|
32
|
-
|
|
32
|
+
|
|
33
33
|
selected: boolean
|
|
34
34
|
onSelect(): void
|
|
35
|
-
|
|
35
|
+
fieldContext?: FieldStateContext
|
|
36
|
+
style?: RadioInputProps<T>['style']
|
|
37
|
+
styles?: Record<RadioInputComposition, ICSS>
|
|
36
38
|
debugName?: string
|
|
37
39
|
disabled?: boolean
|
|
38
40
|
separator?: boolean
|
|
39
|
-
}
|
|
41
|
+
} & (RadioOption<T> | {
|
|
42
|
+
item: RadioOption<T>
|
|
43
|
+
})
|
|
@@ -51,7 +51,7 @@ export const SearchInput = (props: SearchInputProps) => {
|
|
|
51
51
|
...props,
|
|
52
52
|
}
|
|
53
53
|
|
|
54
|
-
const hasStateProps = !TypeGuards.
|
|
54
|
+
const hasStateProps = !TypeGuards.isUndefined(value) && TypeGuards.isFunction(onValueChange)
|
|
55
55
|
|
|
56
56
|
const [search, setSearch] = hasStateProps ? [value, onValueChange] : useState(defaultValue)
|
|
57
57
|
const setSearchTimeout = React.useRef<ReturnType<typeof setTimeout> | null>(null)
|