Skip to content

Commit 964ac8d

Browse files
chore: destructure options
1 parent 8507bb2 commit 964ac8d

9 files changed

Lines changed: 48 additions & 16 deletions

File tree

src/components/hv-date-field/field/index.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ export default (props: Props) => {
2121
stylesheets,
2222
value,
2323
} = props;
24+
const { pressedSelected, selected } = options;
2425
// Styles selected based on pressed state of the field.
2526
const [pressed, setPressed] = useState(false);
2627

@@ -34,9 +35,10 @@ export default (props: Props) => {
3435

3536
const labelStyle: StyleSheetType = StyleSheet.flatten(
3637
useStyleProp(element, stylesheets, {
37-
...options,
3838
focused,
3939
pressed,
40+
pressedSelected,
41+
selected,
4042
styleAttr: 'field-text-style',
4143
}),
4244
);

src/components/hv-image/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@ import { useProps } from 'hyperview/src/services';
1313
const HvImage = (props: HvComponentProps) => {
1414
// eslint-disable-next-line react/destructuring-assignment
1515
const { element, onUpdate, options, stylesheets } = props;
16-
const { skipHref } = options || {};
16+
const { screenUrl, skipHref } = options;
1717
// eslint-disable-next-line @typescript-eslint/no-explicit-any
1818
const imageProps: Record<string, any> = {};
1919
let source = element.getAttribute('source');
2020
if (source) {
21-
source = urlParse(source, options.screenUrl, true).toString();
21+
source = urlParse(source, screenUrl, true).toString();
2222
imageProps.source = { uri: source };
2323
}
2424
const componentProps = {

src/components/hv-picker-field/field-label/index.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,15 @@ import { useStyleProp } from 'hyperview/src/services';
1212
export default (props: Props) => {
1313
// eslint-disable-next-line react/destructuring-assignment
1414
const { element, focused, pressed, options, stylesheets, value } = props;
15+
const { pressedSelected, selected } = options;
1516
const placeholder = element.getAttribute('placeholder');
1617
const placeholderTextColor = element.getAttribute('placeholderTextColor');
1718
const style: StyleSheetType = StyleSheet.flatten(
1819
useStyleProp(element, stylesheets, {
19-
...options,
2020
focused,
2121
pressed,
22+
pressedSelected,
23+
selected,
2224
styleAttr: 'field-text-style',
2325
}),
2426
);

src/components/hv-picker-field/index.ios.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import { View } from 'react-native';
2626
const HvPickerField = (props: HvComponentProps) => {
2727
// eslint-disable-next-line react/destructuring-assignment
2828
const { element, onUpdate, options, stylesheets } = props;
29+
const { focused, pressed, pressedSelected, selected } = options;
2930

3031
const getPickerInitialValue = (): string => {
3132
const value = getValue();
@@ -143,7 +144,10 @@ const HvPickerField = (props: HvComponentProps) => {
143144
const isFocused = (): boolean => element.getAttribute('focused') === 'true';
144145

145146
const style: Array<StyleSheet> = useStyleProp(element, stylesheets, {
146-
...options,
147+
focused,
148+
pressed,
149+
pressedSelected,
150+
selected,
147151
styleAttr: 'field-text-style',
148152
});
149153
const { testID, accessibilityLabel } = createTestProps(element);

src/components/hv-picker-field/index.tsx

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import { View } from 'react-native';
2424
const HvPickerField = (props: HvComponentProps) => {
2525
// eslint-disable-next-line react/destructuring-assignment
2626
const { element, onUpdate, options, stylesheets } = props;
27+
const { focused, pressed, pressedSelected, selected } = options;
2728

2829
/**
2930
* Returns a string representing the value in the field.
@@ -94,7 +95,10 @@ const HvPickerField = (props: HvComponentProps) => {
9495
};
9596

9697
const style: Array<StyleSheet> = useStyleProp(element, stylesheets, {
97-
...options,
98+
focused,
99+
pressed,
100+
pressedSelected,
101+
selected,
98102
styleAttr: 'field-text-style',
99103
});
100104
const { testID, accessibilityLabel } = createTestProps(element);
@@ -108,7 +112,10 @@ const HvPickerField = (props: HvComponentProps) => {
108112
}
109113

110114
const fieldStyle: Array<StyleSheet> = useStyleProp(element, stylesheets, {
111-
...options,
115+
focused,
116+
pressed,
117+
pressedSelected,
118+
selected,
112119
styleAttr: 'field-style',
113120
});
114121

src/components/hv-view/View.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ export default (props: ViewProps) => {
2626
options,
2727
stylesheets,
2828
} = props;
29+
const { focused, pressed, pressedSelected, selected, styleAttr } = options;
30+
2931
/**
3032
* Useful when you want keyboard avoiding behavior in non-scrollable views.
3133
* Note: Android has built-in support for avoiding keyboard.

src/components/hv-view/index.tsx

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import { useStyleProp } from 'hyperview/src/services';
2121
const HvView = (props: HvComponentProps) => {
2222
// eslint-disable-next-line react/destructuring-assignment
2323
const { element, onUpdate, options, stylesheets } = props;
24+
const { focused, pressed, pressedSelected, selected, styleAttr } = options;
2425

2526
const getAttributes = (): Attributes => {
2627
// eslint-disable-next-line @typescript-eslint/no-explicit-any
@@ -42,11 +43,13 @@ const HvView = (props: HvComponentProps) => {
4243
return textFields.length > 0;
4344
};
4445

45-
const style = (useStyleProp(
46-
element,
47-
stylesheets,
48-
options,
49-
) as unknown) as ViewStyle;
46+
const style = (useStyleProp(element, stylesheets, {
47+
focused,
48+
pressed,
49+
pressedSelected,
50+
selected,
51+
styleAttr,
52+
}) as unknown) as ViewStyle;
5053

5154
const getCommonProps = (): CommonProps => {
5255
// TODO: fix type
@@ -64,7 +67,10 @@ const HvView = (props: HvComponentProps) => {
6467
};
6568

6669
const containerStyle = useStyleProp(element, stylesheets, {
67-
...options,
70+
focused,
71+
pressed,
72+
pressedSelected,
73+
selected,
6874
styleAttr: ATTRIBUTES.CONTENT_CONTAINER_STYLE,
6975
});
7076

src/core/components/modal/index.tsx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,10 @@ export default (props: Props): JSX.Element => {
4242
const contentOpacity = useRef(new Animated.Value(0)).current;
4343

4444
const style: Array<StyleSheetType> = useStyleProp(element, stylesheets, {
45-
...options,
45+
focused,
46+
pressed,
47+
pressedSelected,
48+
selected,
4649
styleAttr: 'modal-style',
4750
});
4851

@@ -51,7 +54,10 @@ export default (props: Props): JSX.Element => {
5154

5255
const overlayStyle = StyleSheet.flatten(
5356
useStyleProp(element, stylesheets, {
54-
...options,
57+
focused,
58+
pressed,
59+
pressedSelected,
60+
selected,
5561
styleAttr: 'modal-overlay-style',
5662
}),
5763
);

src/core/components/modal/modal-button/index.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,14 @@ import { useStyleProp } from 'hyperview/src/services';
1111
export default (props: Props) => {
1212
// eslint-disable-next-line react/destructuring-assignment
1313
const { element, label, onPress, options, stylesheets } = props;
14+
const { focused, pressedSelected, selected } = options;
1415
const [pressed, setPressed] = useState(false);
1516

1617
const style: Array<StyleSheet> = useStyleProp(element, stylesheets, {
17-
...options,
18+
focused,
1819
pressed,
20+
pressedSelected,
21+
selected,
1922
styleAttr: 'modal-text-style',
2023
});
2124

0 commit comments

Comments
 (0)