@fluentui-react-native/stack 0.10.21 → 0.11.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/CHANGELOG.md +43 -1
- package/lib/Stack.d.ts +13 -7
- package/lib/Stack.d.ts.map +1 -1
- package/lib/Stack.js +45 -47
- package/lib/Stack.js.map +1 -1
- package/lib/Stack.settings.d.ts +1 -1
- package/lib/Stack.settings.js +51 -51
- package/lib/Stack.tokens.d.ts +3 -3
- package/lib/Stack.tokens.js +70 -71
- package/lib/Stack.tokens.js.map +1 -1
- package/lib/Stack.types.d.ts +79 -80
- package/lib/Stack.types.js +1 -1
- package/lib/StackItem/StackItem.d.ts +1 -1
- package/lib/StackItem/StackItem.js +5 -5
- package/lib/StackItem/StackItem.settings.d.ts +1 -1
- package/lib/StackItem/StackItem.settings.js +8 -8
- package/lib/StackItem/StackItem.tokens.d.ts +6 -2
- package/lib/StackItem/StackItem.tokens.js +13 -13
- package/lib/StackItem/StackItem.tokens.js.map +1 -1
- package/lib/StackItem/StackItem.types.d.ts +43 -43
- package/lib/StackItem/StackItem.types.js +1 -1
- package/lib/StackUtils.d.ts +7 -4
- package/lib/StackUtils.js +33 -35
- package/lib/StackUtils.js.map +1 -1
- package/lib/StackUtils.test.win32.d.ts +1 -1
- package/lib/StackUtils.test.win32.js +50 -50
- package/lib/StackUtils.test.win32.js.map +1 -1
- package/lib/__tests__/Stack.test.d.ts +1 -1
- package/lib/__tests__/Stack.test.js +15 -9
- package/lib/__tests__/Stack.test.js.map +1 -1
- package/lib/index.d.ts +1 -1
- package/lib/index.js +1 -1
- package/lib-commonjs/Stack.d.ts +13 -7
- package/lib-commonjs/Stack.d.ts.map +1 -1
- package/lib-commonjs/Stack.js +112 -85
- package/lib-commonjs/Stack.js.map +1 -1
- package/lib-commonjs/Stack.settings.d.ts +1 -1
- package/lib-commonjs/Stack.settings.js +54 -54
- package/lib-commonjs/Stack.tokens.d.ts +3 -3
- package/lib-commonjs/Stack.tokens.js +74 -75
- package/lib-commonjs/Stack.tokens.js.map +1 -1
- package/lib-commonjs/Stack.types.d.ts +79 -80
- package/lib-commonjs/Stack.types.js +3 -3
- package/lib-commonjs/StackItem/StackItem.d.ts +1 -1
- package/lib-commonjs/StackItem/StackItem.js +13 -13
- package/lib-commonjs/StackItem/StackItem.js.map +1 -1
- package/lib-commonjs/StackItem/StackItem.settings.d.ts +1 -1
- package/lib-commonjs/StackItem/StackItem.settings.js +11 -11
- package/lib-commonjs/StackItem/StackItem.tokens.d.ts +6 -2
- package/lib-commonjs/StackItem/StackItem.tokens.js +18 -18
- package/lib-commonjs/StackItem/StackItem.tokens.js.map +1 -1
- package/lib-commonjs/StackItem/StackItem.types.d.ts +43 -43
- package/lib-commonjs/StackItem/StackItem.types.js +3 -3
- package/lib-commonjs/StackUtils.d.ts +7 -4
- package/lib-commonjs/StackUtils.js +37 -40
- package/lib-commonjs/StackUtils.js.map +1 -1
- package/lib-commonjs/StackUtils.test.win32.d.ts +1 -1
- package/lib-commonjs/StackUtils.test.win32.js +71 -53
- package/lib-commonjs/StackUtils.test.win32.js.map +1 -1
- package/lib-commonjs/__tests__/Stack.test.d.ts +1 -1
- package/lib-commonjs/__tests__/Stack.test.js +74 -37
- package/lib-commonjs/__tests__/Stack.test.js.map +1 -1
- package/lib-commonjs/index.d.ts +1 -1
- package/lib-commonjs/index.js +31 -11
- package/lib-commonjs/index.js.map +1 -1
- package/package.json +65 -64
- package/src/Stack.tsx +2 -4
- package/src/__tests__/Stack.test.tsx +7 -6
package/lib/Stack.types.d.ts
CHANGED
|
@@ -3,14 +3,14 @@ import type { Spacing } from '@fluentui-react-native/framework';
|
|
|
3
3
|
import type { IBackgroundColorTokens, IBorderTokens, FontTokens } from '@fluentui-react-native/tokens';
|
|
4
4
|
import type { IRenderData } from '@uifabricshared/foundation-composable';
|
|
5
5
|
import type { IStackItemProps } from './StackItem/StackItem.types';
|
|
6
|
-
export declare const stackName =
|
|
6
|
+
export declare const stackName = 'RNFStack';
|
|
7
7
|
/**
|
|
8
8
|
* Defines a type made by the union of the different values that the align-items and justify-content flexbox
|
|
9
9
|
* properties can take.
|
|
10
10
|
*/
|
|
11
11
|
export type Alignment = ViewStyle['justifyContent'] | 'start' | 'end';
|
|
12
12
|
export interface IStackStatics {
|
|
13
|
-
|
|
13
|
+
Item: React.FunctionComponent<IStackItemProps>;
|
|
14
14
|
}
|
|
15
15
|
type SpacingGapValue = `${number}px` | `${number}` | keyof Spacing;
|
|
16
16
|
/**
|
|
@@ -18,91 +18,90 @@ type SpacingGapValue = `${number}px` | `${number}` | keyof Spacing;
|
|
|
18
18
|
* the right approach
|
|
19
19
|
*/
|
|
20
20
|
export interface IStackTokens extends FontTokens, IBackgroundColorTokens, IBorderTokens {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
21
|
+
/**
|
|
22
|
+
* Defines the spacing between Stack children.
|
|
23
|
+
* The property is specified as a value for 'row gap', followed optionally by a value for 'column gap'.
|
|
24
|
+
* If 'column gap' is omitted, it's set to the same value as 'row gap'.
|
|
25
|
+
*/
|
|
26
|
+
childrenGap?: number | SpacingGapValue | `${SpacingGapValue} ${SpacingGapValue}`;
|
|
27
|
+
/**
|
|
28
|
+
* Defines a maximum height for the Stack.
|
|
29
|
+
*/
|
|
30
|
+
maxHeight?: DimensionValue;
|
|
31
|
+
/**
|
|
32
|
+
* Defines a maximum width for the Stack.
|
|
33
|
+
*/
|
|
34
|
+
maxWidth?: DimensionValue;
|
|
35
|
+
/**
|
|
36
|
+
* Defines the padding to be applied to the Stack contents relative to its border.
|
|
37
|
+
*/
|
|
38
|
+
padding?: number | `${number}px` | keyof Spacing;
|
|
39
|
+
/**
|
|
40
|
+
* Defines whether to render Stack children horizontally.
|
|
41
|
+
* @defaultvalue false
|
|
42
|
+
*/
|
|
43
|
+
horizontal?: boolean;
|
|
44
|
+
/**
|
|
45
|
+
* Defines whether to render Stack children in the opposite direction (bottom-to-top if it's a vertical Stack and
|
|
46
|
+
* right-to-left if it's a horizontal Stack).
|
|
47
|
+
* @defaultvalue false
|
|
48
|
+
*/
|
|
49
|
+
reversed?: boolean;
|
|
50
|
+
/**
|
|
51
|
+
* Defines how to align Stack children horizontally (along the x-axis).
|
|
52
|
+
*/
|
|
53
|
+
horizontalAlign?: Alignment;
|
|
54
|
+
/**
|
|
55
|
+
* Defines how to align Stack children vertically (along the y-axis).
|
|
56
|
+
*/
|
|
57
|
+
verticalAlign?: Alignment;
|
|
58
|
+
/**
|
|
59
|
+
* Defines whether the Stack should take up 100% of the height of its parent.
|
|
60
|
+
* This property is required to be set to true when using the `grow` flag on children in vertical oriented Stacks.
|
|
61
|
+
* Stacks are rendered as block elements and grow horizontally to the container already.
|
|
62
|
+
* @defaultvalue false
|
|
63
|
+
*/
|
|
64
|
+
verticalFill?: boolean;
|
|
65
|
+
/**
|
|
66
|
+
* Defines whether Stack children should not shrink to fit the available space.
|
|
67
|
+
* @defaultvalue false
|
|
68
|
+
*/
|
|
69
|
+
disableShrink?: boolean;
|
|
70
|
+
/**
|
|
71
|
+
* Defines how much to grow the Stack in proportion to its siblings.
|
|
72
|
+
*/
|
|
73
|
+
grow?: boolean | number;
|
|
74
|
+
/**
|
|
75
|
+
* Defines whether Stack children should wrap onto multiple rows or columns when they are about to overflow
|
|
76
|
+
* the size of the Stack.
|
|
77
|
+
* @defaultvalue false
|
|
78
|
+
*/
|
|
79
|
+
wrap?: boolean;
|
|
80
|
+
/**
|
|
81
|
+
* Gap between items, multiplied by theme gap spacing
|
|
82
|
+
* Does not work while running Chakra for reasons specific to that engine (refer to https://github.com/microsoft/fluentui-react-native/issues/767)
|
|
83
|
+
*/
|
|
84
|
+
gap?: number;
|
|
85
85
|
}
|
|
86
86
|
/**
|
|
87
87
|
* Base property definitions, these generally match fabric
|
|
88
88
|
*/
|
|
89
|
-
export interface IStackProps extends IStackTokens, ViewProps {
|
|
90
|
-
}
|
|
89
|
+
export interface IStackProps extends IStackTokens, ViewProps {}
|
|
91
90
|
export type IStackSlotProps = {
|
|
92
|
-
|
|
93
|
-
|
|
91
|
+
root: ViewProps;
|
|
92
|
+
inner: ViewProps;
|
|
94
93
|
};
|
|
95
94
|
export interface IStackType {
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
95
|
+
props: IStackProps;
|
|
96
|
+
tokens: IStackTokens;
|
|
97
|
+
slotProps: IStackSlotProps;
|
|
98
|
+
statics: IStackStatics;
|
|
99
|
+
state: {
|
|
100
|
+
gap: IStackProps['gap'];
|
|
101
|
+
horizontal: IStackProps['horizontal'];
|
|
102
|
+
wrap: IStackProps['wrap'];
|
|
103
|
+
};
|
|
105
104
|
}
|
|
106
105
|
export type IStackRenderData = IRenderData<IStackSlotProps, IStackType['state']>;
|
|
107
106
|
export {};
|
|
108
|
-
//# sourceMappingURL=Stack.types.d.ts.map
|
|
107
|
+
//# sourceMappingURL=Stack.types.d.ts.map
|
package/lib/Stack.types.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export const stackName = 'RNFStack';
|
|
2
|
-
//# sourceMappingURL=Stack.types.js.map
|
|
2
|
+
//# sourceMappingURL=Stack.types.js.map
|
|
@@ -2,4 +2,4 @@ import type * as React from 'react';
|
|
|
2
2
|
import type { IStackItemProps } from './StackItem.types';
|
|
3
3
|
export declare const StackItem: React.FunctionComponent<IStackItemProps>;
|
|
4
4
|
export default StackItem;
|
|
5
|
-
//# sourceMappingURL=StackItem.d.ts.map
|
|
5
|
+
//# sourceMappingURL=StackItem.d.ts.map
|
|
@@ -5,10 +5,10 @@ import { settings } from './StackItem.settings';
|
|
|
5
5
|
import { stackItemTokenProcessor } from './StackItem.tokens';
|
|
6
6
|
import { stackItemName } from './StackItem.types';
|
|
7
7
|
export const StackItem = compose({
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
8
|
+
displayName: stackItemName,
|
|
9
|
+
settings: settings,
|
|
10
|
+
slots: { root: { slotType: View, filter: filterViewProps } },
|
|
11
|
+
styles: { root: [stackItemTokenProcessor] },
|
|
12
12
|
});
|
|
13
13
|
export default StackItem;
|
|
14
|
-
//# sourceMappingURL=StackItem.js.map
|
|
14
|
+
//# sourceMappingURL=StackItem.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { IComposeSettings } from '@uifabricshared/foundation-compose';
|
|
2
2
|
import type { IStackItemType } from './StackItem.types';
|
|
3
3
|
export declare const settings: IComposeSettings<IStackItemType>;
|
|
4
|
-
//# sourceMappingURL=StackItem.settings.d.ts.map
|
|
4
|
+
//# sourceMappingURL=StackItem.settings.d.ts.map
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { stackItemName } from './StackItem.types';
|
|
2
2
|
export const settings = [
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
},
|
|
3
|
+
{
|
|
4
|
+
root: {
|
|
5
|
+
style: {
|
|
6
|
+
width: 'auto',
|
|
7
|
+
},
|
|
9
8
|
},
|
|
10
|
-
|
|
9
|
+
},
|
|
10
|
+
stackItemName,
|
|
11
11
|
];
|
|
12
|
-
//# sourceMappingURL=StackItem.settings.js.map
|
|
12
|
+
//# sourceMappingURL=StackItem.settings.js.map
|
|
@@ -2,5 +2,9 @@ import type { ViewProps } from 'react-native';
|
|
|
2
2
|
import type { Theme } from '@fluentui-react-native/framework';
|
|
3
3
|
import type { IStackItemTokens } from './StackItem.types';
|
|
4
4
|
export declare function _processor(tokenProps: IStackItemTokens): ViewProps;
|
|
5
|
-
export declare const stackItemTokenProcessor: import(
|
|
6
|
-
|
|
5
|
+
export declare const stackItemTokenProcessor: import('@fluentui-react-native/tokens').StyleFactoryFunction<
|
|
6
|
+
ViewProps,
|
|
7
|
+
IStackItemTokens,
|
|
8
|
+
Theme
|
|
9
|
+
>;
|
|
10
|
+
//# sourceMappingURL=StackItem.tokens.d.ts.map
|
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
import { styleFunction } from '@uifabricshared/foundation-tokens';
|
|
2
2
|
const alignMap = {
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
start: 'flex-start',
|
|
4
|
+
end: 'flex-end',
|
|
5
5
|
};
|
|
6
6
|
const _keyProps = ['align', 'disableShrink', 'grow', 'margin', 'shrink', 'verticalFill'];
|
|
7
7
|
export function _processor(tokenProps) {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
8
|
+
const { grow, shrink, disableShrink, align, verticalFill, margin } = tokenProps;
|
|
9
|
+
return {
|
|
10
|
+
style: {
|
|
11
|
+
margin,
|
|
12
|
+
height: verticalFill ? '100%' : 'auto',
|
|
13
|
+
flexShrink: disableShrink || (!grow && !shrink) ? 0 : 1,
|
|
14
|
+
flexGrow: typeof grow === 'number' ? grow : grow ? 1 : undefined,
|
|
15
|
+
alignSelf: (align && alignMap[align]) || undefined,
|
|
16
|
+
},
|
|
17
|
+
};
|
|
18
18
|
}
|
|
19
19
|
export const stackItemTokenProcessor = styleFunction(_processor, _keyProps);
|
|
20
|
-
//# sourceMappingURL=StackItem.tokens.js.map
|
|
20
|
+
//# sourceMappingURL=StackItem.tokens.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StackItem.tokens.js","sourceRoot":"","sources":["../../src/StackItem/StackItem.tokens.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,aAAa,EAAE,MAAM,mCAAmC,CAAC;AAIlE,MAAM,QAAQ,GAA8C;IAC1D,KAAK,EAAE,YAAY;IACnB,GAAG,EAAE,UAAU;CAChB,CAAC;AAEF,MAAM,SAAS,GAA+B,CAAC,OAAO,EAAE,eAAe,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,cAAc,CAAC,CAAC;AAErH,MAAM,UAAU,UAAU,CAAC,UAA4B;
|
|
1
|
+
{"version":3,"file":"StackItem.tokens.js","sourceRoot":"","sources":["../../src/StackItem/StackItem.tokens.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,aAAa,EAAE,MAAM,mCAAmC,CAAC;AAIlE,MAAM,QAAQ,GAA8C;IAC1D,KAAK,EAAE,YAAY;IACnB,GAAG,EAAE,UAAU;CAChB,CAAC;AAEF,MAAM,SAAS,GAA+B,CAAC,OAAO,EAAE,eAAe,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,cAAc,CAAC,CAAC;AAErH,MAAM,UAAU,UAAU,CAAC,UAA4B,EAAa;IAClE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,aAAa,EAAE,KAAK,EAAE,YAAY,EAAE,MAAM,EAAE,GAAG,UAAU,CAAC;IAEhF,OAAO;QACL,KAAK,EAAE;YACL,MAAM;YACN,MAAM,EAAE,YAAY,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM;YACtC,UAAU,EAAE,aAAa,IAAI,CAAC,CAAC,IAAI,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;YACvD,QAAQ,EAAE,OAAO,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS;YAChE,SAAS,EAAE,CAAC,KAAK,IAAI,QAAQ,CAAC,KAAK,CAAC,CAAC,IAAI,SAAS;SACnD;KACF,CAAC;AAAA,CACH;AAED,MAAM,CAAC,MAAM,uBAAuB,GAAG,aAAa,CAAqC,UAAU,EAAE,SAAS,CAAC,CAAC"}
|
|
@@ -1,52 +1,52 @@
|
|
|
1
1
|
import type { DimensionValue, ViewProps } from 'react-native';
|
|
2
|
-
export declare const stackItemName =
|
|
2
|
+
export declare const stackItemName = 'RNFStackItem';
|
|
3
3
|
/**
|
|
4
4
|
* Stack item props
|
|
5
5
|
*/
|
|
6
6
|
export interface IStackItemTokens extends ViewProps {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
7
|
+
/**
|
|
8
|
+
* Defines the margin to be applied to the StackItem relative to its container.
|
|
9
|
+
*/
|
|
10
|
+
margin?: DimensionValue;
|
|
11
|
+
/**
|
|
12
|
+
* Defines the padding to be applied to the StackItem contents relative to its border.
|
|
13
|
+
*/
|
|
14
|
+
padding?: DimensionValue;
|
|
15
|
+
/**
|
|
16
|
+
* Defines how much to grow the StackItem in proportion to its siblings.
|
|
17
|
+
*/
|
|
18
|
+
grow?: boolean | number | 'inherit' | 'initial' | 'unset';
|
|
19
|
+
/**
|
|
20
|
+
* Defines at what ratio should the StackItem shrink to fit the available space.
|
|
21
|
+
*/
|
|
22
|
+
shrink?: boolean | number | 'inherit' | 'initial' | 'unset';
|
|
23
|
+
/**
|
|
24
|
+
* Defines whether the StackItem should be prevented from shrinking.
|
|
25
|
+
* This can be used to prevent a StackItem from shrinking when it is inside of a Stack that has shrinking items.
|
|
26
|
+
* @defaultvalue false
|
|
27
|
+
*/
|
|
28
|
+
disableShrink?: boolean;
|
|
29
|
+
/**
|
|
30
|
+
* Defines how to align the StackItem along the x-axis (for vertical Stacks) or the y-axis (for horizontal Stacks).
|
|
31
|
+
*/
|
|
32
|
+
align?: 'auto' | 'stretch' | 'baseline' | 'start' | 'center' | 'end';
|
|
33
|
+
/**
|
|
34
|
+
* Defines whether the StackItem should take up 100% of the height of its parent.
|
|
35
|
+
* @defaultvalue true
|
|
36
|
+
*/
|
|
37
|
+
verticalFill?: boolean;
|
|
38
|
+
/**
|
|
39
|
+
* Defines order of the StackItem.
|
|
40
|
+
* @defaultvalue 0
|
|
41
|
+
*/
|
|
42
|
+
order?: number | string;
|
|
43
43
|
}
|
|
44
44
|
export type IStackItemProps = IStackItemTokens & ViewProps;
|
|
45
45
|
export interface IStackItemType {
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
46
|
+
props: IStackItemProps;
|
|
47
|
+
slotProps: {
|
|
48
|
+
root: ViewProps;
|
|
49
|
+
};
|
|
50
|
+
tokens: IStackItemTokens;
|
|
51
51
|
}
|
|
52
|
-
//# sourceMappingURL=StackItem.types.d.ts.map
|
|
52
|
+
//# sourceMappingURL=StackItem.types.d.ts.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export const stackItemName = 'RNFStackItem';
|
|
2
|
-
//# sourceMappingURL=StackItem.types.js.map
|
|
2
|
+
//# sourceMappingURL=StackItem.types.js.map
|
package/lib/StackUtils.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Spacing, Theme } from '@fluentui-react-native/framework';
|
|
2
2
|
export interface IParseGapResult {
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
rowGap: number;
|
|
4
|
+
columnGap: number;
|
|
5
5
|
}
|
|
6
6
|
type SpacingGapValue = `${number}px` | `${number}` | keyof Spacing;
|
|
7
7
|
/**
|
|
@@ -10,11 +10,14 @@ type SpacingGapValue = `${number}px` | `${number}` | keyof Spacing;
|
|
|
10
10
|
* Returns the separate numerical value of the padding (e.g. 10)
|
|
11
11
|
* and the CSS unit (e.g. "px").
|
|
12
12
|
*/
|
|
13
|
-
export declare function parseGap(
|
|
13
|
+
export declare function parseGap(
|
|
14
|
+
gap: number | SpacingGapValue | `${SpacingGapValue} ${SpacingGapValue}` | undefined,
|
|
15
|
+
theme: Theme,
|
|
16
|
+
): IParseGapResult;
|
|
14
17
|
/**
|
|
15
18
|
* Takes in a padding in a CSS-style format (e.g. 10, "10px"), or a key of a themed spacing value
|
|
16
19
|
* (e.g. "s1")
|
|
17
20
|
*/
|
|
18
21
|
export declare function parsePadding(padding: keyof Spacing | number | `${number}px` | undefined, theme: Theme): number | undefined;
|
|
19
22
|
export {};
|
|
20
|
-
//# sourceMappingURL=StackUtils.d.ts.map
|
|
23
|
+
//# sourceMappingURL=StackUtils.d.ts.map
|
package/lib/StackUtils.js
CHANGED
|
@@ -5,15 +5,15 @@
|
|
|
5
5
|
const _spacingKey = 'spacing';
|
|
6
6
|
// Helper function that converts a themed spacing key (if given) to the corresponding themed spacing value.
|
|
7
7
|
const _getThemedSpacing = (space, theme) => {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
}
|
|
8
|
+
const spacing = theme[_spacingKey];
|
|
9
|
+
if (spacing && typeof spacing === 'object' && typeof space === 'string') {
|
|
10
|
+
if (spacing.hasOwnProperty(space)) {
|
|
11
|
+
space = spacing[space];
|
|
13
12
|
}
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
13
|
+
}
|
|
14
|
+
const numericalPart = parseFloat(space);
|
|
15
|
+
const numericalValue = isNaN(numericalPart) ? 0 : numericalPart;
|
|
16
|
+
return numericalValue;
|
|
17
17
|
};
|
|
18
18
|
/**
|
|
19
19
|
* Takes in a gap size in either a CSS-style format (e.g. 10 or "10px")
|
|
@@ -22,38 +22,36 @@ const _getThemedSpacing = (space, theme) => {
|
|
|
22
22
|
* and the CSS unit (e.g. "px").
|
|
23
23
|
*/
|
|
24
24
|
export function parseGap(gap, theme) {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
result.columnGap = calculatedGap;
|
|
44
|
-
}
|
|
45
|
-
}
|
|
25
|
+
const result = {
|
|
26
|
+
rowGap: 0,
|
|
27
|
+
columnGap: 0,
|
|
28
|
+
};
|
|
29
|
+
if (gap) {
|
|
30
|
+
if (typeof gap === 'number') {
|
|
31
|
+
result.rowGap = gap;
|
|
32
|
+
result.columnGap = gap;
|
|
33
|
+
} else {
|
|
34
|
+
const splitGap = gap.split(' ');
|
|
35
|
+
if (splitGap.length === 2) {
|
|
36
|
+
result.rowGap = _getThemedSpacing(splitGap[0], theme);
|
|
37
|
+
result.columnGap = _getThemedSpacing(splitGap[1], theme);
|
|
38
|
+
} else {
|
|
39
|
+
const calculatedGap = _getThemedSpacing(gap, theme);
|
|
40
|
+
result.rowGap = calculatedGap;
|
|
41
|
+
result.columnGap = calculatedGap;
|
|
42
|
+
}
|
|
46
43
|
}
|
|
47
|
-
|
|
44
|
+
}
|
|
45
|
+
return result;
|
|
48
46
|
}
|
|
49
47
|
/**
|
|
50
48
|
* Takes in a padding in a CSS-style format (e.g. 10, "10px"), or a key of a themed spacing value
|
|
51
49
|
* (e.g. "s1")
|
|
52
50
|
*/
|
|
53
51
|
export function parsePadding(padding, theme) {
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
52
|
+
if (padding === undefined || typeof padding === 'number') {
|
|
53
|
+
return padding;
|
|
54
|
+
}
|
|
55
|
+
return _getThemedSpacing(padding, theme);
|
|
58
56
|
}
|
|
59
|
-
//# sourceMappingURL=StackUtils.js.map
|
|
57
|
+
//# sourceMappingURL=StackUtils.js.map
|
package/lib/StackUtils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StackUtils.js","sourceRoot":"","sources":["../src/StackUtils.ts"],"names":[],"mappings":"AAEA;;GAEG;AAEH,gFAAgF;AAChF,MAAM,WAAW,GAAG,SAAS,CAAC;AAE9B,2GAA2G;AAC3G,MAAM,iBAAiB,GAAG,CAAC,KAAkD,EAAE,KAAY,EAAU,EAAE;
|
|
1
|
+
{"version":3,"file":"StackUtils.js","sourceRoot":"","sources":["../src/StackUtils.ts"],"names":[],"mappings":"AAEA;;GAEG;AAEH,gFAAgF;AAChF,MAAM,WAAW,GAAG,SAAS,CAAC;AAE9B,2GAA2G;AAC3G,MAAM,iBAAiB,GAAG,CAAC,KAAkD,EAAE,KAAY,EAAU,EAAE,CAAC;IACtG,MAAM,OAAO,GAAG,KAAK,CAAC,WAAW,CAAC,CAAC;IACnC,IAAI,OAAO,IAAI,OAAO,OAAO,KAAK,QAAQ,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QACxE,IAAI,OAAO,CAAC,cAAc,CAAC,KAAK,CAAC,EAAE,CAAC;YAClC,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC;QACzB,CAAC;IACH,CAAC;IAED,MAAM,aAAa,GAAG,UAAU,CAAC,KAAK,CAAC,CAAC;IACxC,MAAM,cAAc,GAAG,KAAK,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,aAAa,CAAC;IAChE,OAAO,cAAc,CAAC;AAAA,CACvB,CAAC;AASF;;;;;GAKG;AACH,MAAM,UAAU,QAAQ,CACtB,GAAmF,EACnF,KAAY,EACK;IACjB,MAAM,MAAM,GAAoB;QAC9B,MAAM,EAAE,CAAC;QACT,SAAS,EAAE,CAAC;KACb,CAAC;IACF,IAAI,GAAG,EAAE,CAAC;QACR,IAAI,OAAO,GAAG,KAAK,QAAQ,EAAE,CAAC;YAC5B,MAAM,CAAC,MAAM,GAAG,GAAG,CAAC;YACpB,MAAM,CAAC,SAAS,GAAG,GAAG,CAAC;QACzB,CAAC;aAAM,CAAC;YACN,MAAM,QAAQ,GAAG,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;YAChC,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;gBAC1B,MAAM,CAAC,MAAM,GAAG,iBAAiB,CAAC,QAAQ,CAAC,CAAC,CAAoB,EAAE,KAAK,CAAC,CAAC;gBACzE,MAAM,CAAC,SAAS,GAAG,iBAAiB,CAAC,QAAQ,CAAC,CAAC,CAAoB,EAAE,KAAK,CAAC,CAAC;YAC9E,CAAC;iBAAM,CAAC;gBACN,MAAM,aAAa,GAAG,iBAAiB,CAAC,GAAsB,EAAE,KAAK,CAAC,CAAC;gBACvE,MAAM,CAAC,MAAM,GAAG,aAAa,CAAC;gBAC9B,MAAM,CAAC,SAAS,GAAG,aAAa,CAAC;YACnC,CAAC;QACH,CAAC;IACH,CAAC;IACD,OAAO,MAAM,CAAC;AAAA,CACf;AAED;;;GAGG;AACH,MAAM,UAAU,YAAY,CAAC,OAA2D,EAAE,KAAY,EAAsB;IAC1H,IAAI,OAAO,KAAK,SAAS,IAAI,OAAO,OAAO,KAAK,QAAQ,EAAE,CAAC;QACzD,OAAO,OAA6B,CAAC;IACvC,CAAC;IAED,OAAO,iBAAiB,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;AAAA,CAC1C"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export {};
|
|
2
|
-
//# sourceMappingURL=StackUtils.test.win32.d.ts.map
|
|
2
|
+
//# sourceMappingURL=StackUtils.test.win32.d.ts.map
|
|
@@ -1,54 +1,54 @@
|
|
|
1
1
|
import { parseGap, parsePadding } from './StackUtils';
|
|
2
2
|
describe('StackUtils', () => {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
});
|
|
10
|
-
it('returns a value with px when given a number', () => {
|
|
11
|
-
expect(parseGap(10, theme)).toEqual({ rowGap: { value: 10, unit: 'px' }, columnGap: { value: 10, unit: 'px' } });
|
|
12
|
-
});
|
|
13
|
-
it('can parse a string with px', () => {
|
|
14
|
-
expect(parseGap('32px', theme)).toEqual({ rowGap: { value: 32, unit: 'px' }, columnGap: { value: 32, unit: 'px' } });
|
|
15
|
-
});
|
|
16
|
-
it('can parse a string with a float', () => {
|
|
17
|
-
expect(parseGap('20.5px', theme)).toEqual({ rowGap: { value: 20.5, unit: 'px' }, columnGap: { value: 20.5, unit: 'px' } });
|
|
18
|
-
});
|
|
19
|
-
it('parses the value from the theme when given a spacing key', () => {
|
|
20
|
-
expect(parseGap('m', theme)).toEqual({ rowGap: { value: 16, unit: 'em' }, columnGap: { value: 16, unit: 'em' } });
|
|
21
|
-
});
|
|
22
|
-
it('can parse a string with both horizontal and vertical gap', () => {
|
|
23
|
-
expect(parseGap('30px 10px', theme)).toEqual({ rowGap: { value: 30, unit: 'px' }, columnGap: { value: 10, unit: 'px' } });
|
|
24
|
-
});
|
|
25
|
-
it('defaults to px with a string with horizontal and vertical gap with no units', () => {
|
|
26
|
-
expect(parseGap('50 30', theme)).toEqual({ rowGap: { value: 50, unit: 'px' }, columnGap: { value: 30, unit: 'px' } });
|
|
27
|
-
});
|
|
28
|
-
it('can parse a string with horizontal and vertical gap with one of them getting value from the theme when given a spacing key', () => {
|
|
29
|
-
expect(parseGap('50px m', theme)).toEqual({ rowGap: { value: 50, unit: 'px' }, columnGap: { value: 16, unit: 'em' } });
|
|
30
|
-
});
|
|
31
|
-
});
|
|
32
|
-
describe('parsePadding', () => {
|
|
33
|
-
const theme = {
|
|
34
|
-
spacing: {
|
|
35
|
-
s2: '5px',
|
|
36
|
-
s1: '10px',
|
|
37
|
-
m: '15px',
|
|
38
|
-
l1: '20px',
|
|
39
|
-
l2: '25px',
|
|
40
|
-
},
|
|
41
|
-
};
|
|
42
|
-
it('returns its argument when given undefined, a number, or an empty string', () => {
|
|
43
|
-
expect(parsePadding(undefined, theme)).toEqual(undefined);
|
|
44
|
-
expect(parsePadding(0, theme)).toEqual(0);
|
|
45
|
-
});
|
|
46
|
-
it('returns its argument when given a CSS-style padding', () => {
|
|
47
|
-
expect(parsePadding('10px', theme)).toEqual('10px');
|
|
48
|
-
});
|
|
49
|
-
it('converts themed spacing keys to CSS-style paddings', () => {
|
|
50
|
-
expect(parsePadding('s2', theme)).toEqual('5px');
|
|
51
|
-
});
|
|
3
|
+
describe('parseGap', () => {
|
|
4
|
+
const theme = {
|
|
5
|
+
spacing: { m: '16em' },
|
|
6
|
+
};
|
|
7
|
+
it('returns a default value when given undefined', () => {
|
|
8
|
+
expect(parseGap(undefined, theme)).toEqual({ rowGap: { value: 0, unit: 'px' }, columnGap: { value: 0, unit: 'px' } });
|
|
52
9
|
});
|
|
10
|
+
it('returns a value with px when given a number', () => {
|
|
11
|
+
expect(parseGap(10, theme)).toEqual({ rowGap: { value: 10, unit: 'px' }, columnGap: { value: 10, unit: 'px' } });
|
|
12
|
+
});
|
|
13
|
+
it('can parse a string with px', () => {
|
|
14
|
+
expect(parseGap('32px', theme)).toEqual({ rowGap: { value: 32, unit: 'px' }, columnGap: { value: 32, unit: 'px' } });
|
|
15
|
+
});
|
|
16
|
+
it('can parse a string with a float', () => {
|
|
17
|
+
expect(parseGap('20.5px', theme)).toEqual({ rowGap: { value: 20.5, unit: 'px' }, columnGap: { value: 20.5, unit: 'px' } });
|
|
18
|
+
});
|
|
19
|
+
it('parses the value from the theme when given a spacing key', () => {
|
|
20
|
+
expect(parseGap('m', theme)).toEqual({ rowGap: { value: 16, unit: 'em' }, columnGap: { value: 16, unit: 'em' } });
|
|
21
|
+
});
|
|
22
|
+
it('can parse a string with both horizontal and vertical gap', () => {
|
|
23
|
+
expect(parseGap('30px 10px', theme)).toEqual({ rowGap: { value: 30, unit: 'px' }, columnGap: { value: 10, unit: 'px' } });
|
|
24
|
+
});
|
|
25
|
+
it('defaults to px with a string with horizontal and vertical gap with no units', () => {
|
|
26
|
+
expect(parseGap('50 30', theme)).toEqual({ rowGap: { value: 50, unit: 'px' }, columnGap: { value: 30, unit: 'px' } });
|
|
27
|
+
});
|
|
28
|
+
it('can parse a string with horizontal and vertical gap with one of them getting value from the theme when given a spacing key', () => {
|
|
29
|
+
expect(parseGap('50px m', theme)).toEqual({ rowGap: { value: 50, unit: 'px' }, columnGap: { value: 16, unit: 'em' } });
|
|
30
|
+
});
|
|
31
|
+
});
|
|
32
|
+
describe('parsePadding', () => {
|
|
33
|
+
const theme = {
|
|
34
|
+
spacing: {
|
|
35
|
+
s2: '5px',
|
|
36
|
+
s1: '10px',
|
|
37
|
+
m: '15px',
|
|
38
|
+
l1: '20px',
|
|
39
|
+
l2: '25px',
|
|
40
|
+
},
|
|
41
|
+
};
|
|
42
|
+
it('returns its argument when given undefined, a number, or an empty string', () => {
|
|
43
|
+
expect(parsePadding(undefined, theme)).toEqual(undefined);
|
|
44
|
+
expect(parsePadding(0, theme)).toEqual(0);
|
|
45
|
+
});
|
|
46
|
+
it('returns its argument when given a CSS-style padding', () => {
|
|
47
|
+
expect(parsePadding('10px', theme)).toEqual('10px');
|
|
48
|
+
});
|
|
49
|
+
it('converts themed spacing keys to CSS-style paddings', () => {
|
|
50
|
+
expect(parsePadding('s2', theme)).toEqual('5px');
|
|
51
|
+
});
|
|
52
|
+
});
|
|
53
53
|
});
|
|
54
|
-
//# sourceMappingURL=StackUtils.test.win32.js.map
|
|
54
|
+
//# sourceMappingURL=StackUtils.test.win32.js.map
|