Skip to content

Commit 3cef191

Browse files
committed
baseline-refactor
1 parent 1a1d55e commit 3cef191

File tree

15 files changed

+50
-15
lines changed

15 files changed

+50
-15
lines changed

packages/rn-declarative-eva/package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/rn-declarative-eva/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "rn-declarative-eva",
3-
"version": "0.0.37",
3+
"version": "0.0.38",
44
"description": "A lighter version of the react-declarative which exports the <One /> component and dependencies only and as such makes the library slightly faster and smaller. Unlike react-declarative, it doesn't provide any additional overhead like state management. For a note, that library should be used when you want to use <One /> forms in existing app",
55
"private": false,
66
"author": {

packages/rn-declarative-eva/src/OneSlotFactory/OneSlotFactory.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ interface IOneSlotFactoryProps {
1515
children: React.ReactNode;
1616
}
1717

18-
const defaultSlots = {
18+
export const defaultSlots = {
1919
CheckBox,
2020
Combo,
2121
Items,
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
export * from './OneSlotFactory';
2+
export { defaultSlots as OneDefaultSlots } from './OneSlotFactory';
23
export { default } from './OneSlotFactory';
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
export { OneSlotFactory } from './OneSlotFactory';
2+
export { OneDefaultSlots } from './OneSlotFactory';

packages/rn-declarative/package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/rn-declarative/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "rn-declarative",
3-
"version": "0.0.45",
3+
"version": "0.0.47",
44
"description": "A lighter version of the react-declarative which exports the <One /> component and dependencies only and as such makes the library slightly faster and smaller. Unlike react-declarative, it doesn't provide any additional overhead like state management. For a note, that library should be used when you want to use <One /> forms in existing app",
55
"private": false,
66
"author": {

packages/rn-declarative/src/components/One/One.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ import useManagedProps from './hooks/useManagedProps';
1717
import createFieldInternal from './config/createField';
1818
import createLayoutInternal from './config/createLayout';
1919

20+
import isBaselineInternal from './config/isBaselineSimple';
21+
2022
const DEFAULT_ONFOCUS = () => null;
2123
const DEFAULT_ONBLUR = () => null;
2224
const DEFAULT_ONPRESS = () => null;
@@ -58,6 +60,8 @@ export const One = <Data extends IAnything = IAnything, Payload = IAnything, Fie
5860
const {
5961
createField = createFieldInternal,
6062
createLayout = createLayoutInternal,
63+
isBaseline = isBaselineInternal,
64+
isBaselineForRoot = isBaselineInternal,
6165
apiRef,
6266
changeSubject,
6367
reloadSubject,
@@ -193,6 +197,8 @@ export const One = <Data extends IAnything = IAnything, Payload = IAnything, Fie
193197
...memoizedProps,
194198
createField,
195199
createLayout,
200+
isBaseline,
201+
isBaselineForRoot,
196202
features,
197203
} as unknown as IOneProps<Data, IField<Data>>;
198204

packages/rn-declarative/src/components/One/components/Container/Container.tsx

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,22 +27,25 @@ interface IContainerProps {
2727
isBaselineAlign?: boolean;
2828
children: React.ReactNode;
2929
}
30-
3130
/**
3231
* В Yoga layout есть баг, если корневой компонент не baseline,
33-
* часть компоновок не покажется. Не зависит от UI kit, в будущем, нужно
34-
* добавить ветвление стилей и убрать `<Adjust />` для `noBaseline`
32+
* часть компоновок не покажется. Не зависит от UI kit
33+
*
34+
* Поэтому, вместо `isBaseline` используется `isBaselineSimple`, которая включает
35+
* baseline всегда, если не указано `noBaseline`
3536
*/
37+
const isBaselineAlign = true;
38+
3639
export const Container = ({
3740
style,
3841
children,
3942
}: IContainerProps) => (
4043
<View style={[styles.root, style]}>
41-
<View style={styles.withBaseline}>
44+
<View style={isBaselineAlign ? styles.withBaseline : styles.noBaseline}>
4245
{children}
4346
</View>
44-
<Adjust />
47+
{!isBaselineAlign && <Adjust />}
4548
</View>
4649
);
4750

48-
export default Container;
51+
export default Container;

packages/rn-declarative/src/components/One/components/OneGenesis/OneGenesis.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ export const OneGenesis = <
6565
const oneConfig = useSingleton(OneConfig[GET_REF_SYMBOL]);
6666

6767
const {
68+
isBaselineForRoot = isBaselineForField,
6869
change = DEFAULT_CHANGE,
6970
ready = DEFAULT_READY,
7071
fields = [],
@@ -176,7 +177,7 @@ export const OneGenesis = <
176177
* Корневой компонент привязывает поля к нижнему краю только если
177178
* нет ни одной компоновки
178179
*/
179-
const isBaselineAlign = useMemo(() => fieldsSnapshot.every(isBaselineForField), []);
180+
const isBaselineAlign = useMemo(() => fieldsSnapshot.every(isBaselineForRoot), []);
180181

181182
return (
182183
<CacheProvider>

0 commit comments

Comments
 (0)