@fluentui-react-native/stack 0.11.0 → 0.11.3

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.
Files changed (54) hide show
  1. package/CHANGELOG.md +44 -0
  2. package/lib/Stack.d.ts +7 -13
  3. package/lib/Stack.js +44 -44
  4. package/lib/Stack.js.map +1 -1
  5. package/lib/Stack.settings.d.ts +1 -1
  6. package/lib/Stack.settings.js +51 -51
  7. package/lib/Stack.tokens.d.ts +3 -3
  8. package/lib/Stack.tokens.js +71 -70
  9. package/lib/Stack.types.d.ts +80 -79
  10. package/lib/Stack.types.js +1 -1
  11. package/lib/StackItem/StackItem.d.ts +1 -1
  12. package/lib/StackItem/StackItem.js +5 -5
  13. package/lib/StackItem/StackItem.settings.d.ts +1 -1
  14. package/lib/StackItem/StackItem.settings.js +8 -8
  15. package/lib/StackItem/StackItem.tokens.d.ts +2 -6
  16. package/lib/StackItem/StackItem.tokens.js +13 -13
  17. package/lib/StackItem/StackItem.types.d.ts +43 -43
  18. package/lib/StackItem/StackItem.types.js +1 -1
  19. package/lib/StackUtils.d.ts +4 -7
  20. package/lib/StackUtils.js +35 -33
  21. package/lib/StackUtils.test.win32.d.ts +1 -1
  22. package/lib/StackUtils.test.win32.js +50 -50
  23. package/lib/__tests__/Stack.test.d.ts +1 -1
  24. package/lib/__tests__/Stack.test.js +9 -14
  25. package/lib/index.d.ts +1 -1
  26. package/lib/index.js +1 -1
  27. package/lib-commonjs/Stack.d.ts +7 -13
  28. package/lib-commonjs/Stack.js +88 -107
  29. package/lib-commonjs/Stack.js.map +1 -1
  30. package/lib-commonjs/Stack.settings.d.ts +1 -1
  31. package/lib-commonjs/Stack.settings.js +54 -54
  32. package/lib-commonjs/Stack.tokens.d.ts +3 -3
  33. package/lib-commonjs/Stack.tokens.js +75 -74
  34. package/lib-commonjs/Stack.types.d.ts +80 -79
  35. package/lib-commonjs/Stack.types.js +3 -3
  36. package/lib-commonjs/StackItem/StackItem.d.ts +1 -1
  37. package/lib-commonjs/StackItem/StackItem.js +13 -13
  38. package/lib-commonjs/StackItem/StackItem.settings.d.ts +1 -1
  39. package/lib-commonjs/StackItem/StackItem.settings.js +11 -11
  40. package/lib-commonjs/StackItem/StackItem.tokens.d.ts +2 -6
  41. package/lib-commonjs/StackItem/StackItem.tokens.js +16 -16
  42. package/lib-commonjs/StackItem/StackItem.types.d.ts +43 -43
  43. package/lib-commonjs/StackItem/StackItem.types.js +3 -3
  44. package/lib-commonjs/StackUtils.d.ts +4 -7
  45. package/lib-commonjs/StackUtils.js +37 -35
  46. package/lib-commonjs/StackUtils.test.win32.d.ts +1 -1
  47. package/lib-commonjs/StackUtils.test.win32.js +53 -71
  48. package/lib-commonjs/__tests__/Stack.test.d.ts +1 -1
  49. package/lib-commonjs/__tests__/Stack.test.js +44 -70
  50. package/lib-commonjs/index.d.ts +1 -1
  51. package/lib-commonjs/index.js +11 -31
  52. package/package.json +30 -29
  53. package/src/Stack.tsx +1 -1
  54. package/eslint.config.js +0 -3
@@ -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 = 'RNFStack';
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
- Item: React.FunctionComponent<IStackItemProps>;
13
+ Item: React.FunctionComponent<IStackItemProps>;
14
14
  }
15
15
  type SpacingGapValue = `${number}px` | `${number}` | keyof Spacing;
16
16
  /**
@@ -18,90 +18,91 @@ 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
- * 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;
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 {}
89
+ export interface IStackProps extends IStackTokens, ViewProps {
90
+ }
90
91
  export type IStackSlotProps = {
91
- root: ViewProps;
92
- inner: ViewProps;
92
+ root: ViewProps;
93
+ inner: ViewProps;
93
94
  };
94
95
  export interface IStackType {
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
- };
96
+ props: IStackProps;
97
+ tokens: IStackTokens;
98
+ slotProps: IStackSlotProps;
99
+ statics: IStackStatics;
100
+ state: {
101
+ gap: IStackProps['gap'];
102
+ horizontal: IStackProps['horizontal'];
103
+ wrap: IStackProps['wrap'];
104
+ };
104
105
  }
105
106
  export type IStackRenderData = IRenderData<IStackSlotProps, IStackType['state']>;
106
107
  export {};
107
- //# sourceMappingURL=Stack.types.d.ts.map
108
+ //# sourceMappingURL=Stack.types.d.ts.map
@@ -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
- displayName: stackItemName,
9
- settings: settings,
10
- slots: { root: { slotType: View, filter: filterViewProps } },
11
- styles: { root: [stackItemTokenProcessor] },
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
- root: {
5
- style: {
6
- width: 'auto',
7
- },
3
+ {
4
+ root: {
5
+ style: {
6
+ width: 'auto',
7
+ },
8
+ },
8
9
  },
9
- },
10
- stackItemName,
10
+ stackItemName,
11
11
  ];
12
- //# sourceMappingURL=StackItem.settings.js.map
12
+ //# sourceMappingURL=StackItem.settings.js.map
@@ -2,9 +2,5 @@ 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('@fluentui-react-native/tokens').StyleFactoryFunction<
6
- ViewProps,
7
- IStackItemTokens,
8
- Theme
9
- >;
10
- //# sourceMappingURL=StackItem.tokens.d.ts.map
5
+ export declare const stackItemTokenProcessor: import("@fluentui-react-native/tokens").StyleFactoryFunction<ViewProps, IStackItemTokens, Theme>;
6
+ //# sourceMappingURL=StackItem.tokens.d.ts.map
@@ -1,20 +1,20 @@
1
1
  import { styleFunction } from '@uifabricshared/foundation-tokens';
2
2
  const alignMap = {
3
- start: 'flex-start',
4
- end: 'flex-end',
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
- 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
- };
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,52 +1,52 @@
1
1
  import type { DimensionValue, ViewProps } from 'react-native';
2
- export declare const stackItemName = 'RNFStackItem';
2
+ export declare const stackItemName = "RNFStackItem";
3
3
  /**
4
4
  * Stack item props
5
5
  */
6
6
  export interface IStackItemTokens extends ViewProps {
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;
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
- props: IStackItemProps;
47
- slotProps: {
48
- root: ViewProps;
49
- };
50
- tokens: IStackItemTokens;
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
@@ -1,7 +1,7 @@
1
1
  import type { Spacing, Theme } from '@fluentui-react-native/framework';
2
2
  export interface IParseGapResult {
3
- rowGap: number;
4
- columnGap: number;
3
+ rowGap: number;
4
+ columnGap: number;
5
5
  }
6
6
  type SpacingGapValue = `${number}px` | `${number}` | keyof Spacing;
7
7
  /**
@@ -10,14 +10,11 @@ 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(
14
- gap: number | SpacingGapValue | `${SpacingGapValue} ${SpacingGapValue}` | undefined,
15
- theme: Theme,
16
- ): IParseGapResult;
13
+ export declare function parseGap(gap: number | SpacingGapValue | `${SpacingGapValue} ${SpacingGapValue}` | undefined, theme: Theme): IParseGapResult;
17
14
  /**
18
15
  * Takes in a padding in a CSS-style format (e.g. 10, "10px"), or a key of a themed spacing value
19
16
  * (e.g. "s1")
20
17
  */
21
18
  export declare function parsePadding(padding: keyof Spacing | number | `${number}px` | undefined, theme: Theme): number | undefined;
22
19
  export {};
23
- //# sourceMappingURL=StackUtils.d.ts.map
20
+ //# 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
- const spacing = theme[_spacingKey];
9
- if (spacing && typeof spacing === 'object' && typeof space === 'string') {
10
- if (spacing.hasOwnProperty(space)) {
11
- space = spacing[space];
8
+ const spacing = theme[_spacingKey];
9
+ if (spacing && typeof spacing === 'object' && typeof space === 'string') {
10
+ if (spacing.hasOwnProperty(space)) {
11
+ space = spacing[space];
12
+ }
12
13
  }
13
- }
14
- const numericalPart = parseFloat(space);
15
- const numericalValue = isNaN(numericalPart) ? 0 : numericalPart;
16
- return numericalValue;
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,36 +22,38 @@ const _getThemedSpacing = (space, theme) => {
22
22
  * and the CSS unit (e.g. "px").
23
23
  */
24
24
  export function parseGap(gap, theme) {
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
- }
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
+ }
34
+ else {
35
+ const splitGap = gap.split(' ');
36
+ if (splitGap.length === 2) {
37
+ result.rowGap = _getThemedSpacing(splitGap[0], theme);
38
+ result.columnGap = _getThemedSpacing(splitGap[1], theme);
39
+ }
40
+ else {
41
+ const calculatedGap = _getThemedSpacing(gap, theme);
42
+ result.rowGap = calculatedGap;
43
+ result.columnGap = calculatedGap;
44
+ }
45
+ }
43
46
  }
44
- }
45
- return result;
47
+ return result;
46
48
  }
47
49
  /**
48
50
  * Takes in a padding in a CSS-style format (e.g. 10, "10px"), or a key of a themed spacing value
49
51
  * (e.g. "s1")
50
52
  */
51
53
  export function parsePadding(padding, theme) {
52
- if (padding === undefined || typeof padding === 'number') {
53
- return padding;
54
- }
55
- return _getThemedSpacing(padding, theme);
54
+ if (padding === undefined || typeof padding === 'number') {
55
+ return padding;
56
+ }
57
+ return _getThemedSpacing(padding, theme);
56
58
  }
57
- //# sourceMappingURL=StackUtils.js.map
59
+ //# sourceMappingURL=StackUtils.js.map
@@ -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
- 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' } });
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' } });
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
+ });
9
52
  });
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
@@ -1,2 +1,2 @@
1
1
  export {};
2
- //# sourceMappingURL=Stack.test.d.ts.map
2
+ //# sourceMappingURL=Stack.test.d.ts.map