@fluentui/react-migration-v8-v9 1.0.3 → 1.0.4
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.json +22 -1
- package/CHANGELOG.md +12 -2
- package/lib/components/Button/ActionButtonShim.js +18 -0
- package/lib/components/Button/ActionButtonShim.js.map +1 -0
- package/lib/components/Button/ButtonShim.js +25 -0
- package/lib/components/Button/ButtonShim.js.map +1 -0
- package/lib/components/Button/CommandButtonShim.js +5 -0
- package/lib/components/Button/CommandButtonShim.js.map +1 -0
- package/lib/components/Button/CompoundButtonShim.js +21 -0
- package/lib/components/Button/CompoundButtonShim.js.map +1 -0
- package/lib/components/Button/DefaultButtonShim.js +12 -0
- package/lib/components/Button/DefaultButtonShim.js.map +1 -0
- package/lib/components/Button/MenuButtonShim.js +23 -0
- package/lib/components/Button/MenuButtonShim.js.map +1 -0
- package/lib/components/Button/PrimaryButtonShim.js +13 -0
- package/lib/components/Button/PrimaryButtonShim.js.map +1 -0
- package/lib/components/Button/ToggleButtonShim.js +20 -0
- package/lib/components/Button/ToggleButtonShim.js.map +1 -0
- package/lib/components/Button/index.js +10 -0
- package/lib/components/Button/index.js.map +1 -0
- package/lib/components/Button/shimButtonProps.js +24 -0
- package/lib/components/Button/shimButtonProps.js.map +1 -0
- package/lib/components/Menu/MenuShim.js +49 -0
- package/lib/components/Menu/MenuShim.js.map +1 -0
- package/lib/components/Menu/index.js +3 -0
- package/lib/components/Menu/index.js.map +1 -0
- package/lib/components/Menu/shimMenuProps.js +33 -0
- package/lib/components/Menu/shimMenuProps.js.map +1 -0
- package/lib/components/Stack/StackItemShim.js +177 -0
- package/lib/components/Stack/StackItemShim.js.map +1 -0
- package/lib/components/Stack/StackShim.js +260 -0
- package/lib/components/Stack/StackShim.js.map +1 -0
- package/lib/components/Stack/index.js +3 -0
- package/lib/components/Stack/index.js.map +1 -0
- package/lib/components/Stack/stackUtils.js +168 -0
- package/lib/components/Stack/stackUtils.js.map +1 -0
- package/lib/components/Theme/index.js +5 -0
- package/lib/components/Theme/index.js.map +1 -0
- package/lib/components/Theme/themeDuplicates.js +859 -0
- package/lib/components/Theme/themeDuplicates.js.map +1 -0
- package/lib/components/Theme/v8ThemeShim.js +313 -0
- package/lib/components/Theme/v8ThemeShim.js.map +1 -0
- package/lib/components/Theme/v9BrandVariantsShim.js +77 -0
- package/lib/components/Theme/v9BrandVariantsShim.js.map +1 -0
- package/lib/components/Theme/v9ThemeShim.js +195 -0
- package/lib/components/Theme/v9ThemeShim.js.map +1 -0
- package/lib/index.js +5 -0
- package/lib/index.js.map +1 -0
- package/lib/stories/DefaultButtonShim/index.js +51 -0
- package/lib/stories/DefaultButtonShim/index.js.map +1 -0
- package/lib-amd/components/Button/ActionButtonShim.js +14 -0
- package/lib-amd/components/Button/ActionButtonShim.js.map +1 -0
- package/lib-amd/components/Button/ButtonShim.js +17 -0
- package/lib-amd/components/Button/ButtonShim.js.map +1 -0
- package/lib-amd/components/Button/CommandButtonShim.js +7 -0
- package/lib-amd/components/Button/CommandButtonShim.js.map +1 -0
- package/lib-amd/components/Button/CompoundButtonShim.js +15 -0
- package/lib-amd/components/Button/CompoundButtonShim.js.map +1 -0
- package/lib-amd/components/Button/DefaultButtonShim.js +12 -0
- package/lib-amd/components/Button/DefaultButtonShim.js.map +1 -0
- package/lib-amd/components/Button/MenuButtonShim.js +20 -0
- package/lib-amd/components/Button/MenuButtonShim.js.map +1 -0
- package/lib-amd/components/Button/PrimaryButtonShim.js +12 -0
- package/lib-amd/components/Button/PrimaryButtonShim.js.map +1 -0
- package/lib-amd/components/Button/ToggleButtonShim.js +14 -0
- package/lib-amd/components/Button/ToggleButtonShim.js.map +1 -0
- package/lib-amd/components/Button/index.js +14 -0
- package/lib-amd/components/Button/index.js.map +1 -0
- package/lib-amd/components/Button/shimButtonProps.js +19 -0
- package/lib-amd/components/Button/shimButtonProps.js.map +1 -0
- package/lib-amd/components/Menu/MenuShim.js +42 -0
- package/lib-amd/components/Menu/MenuShim.js.map +1 -0
- package/lib-amd/components/Menu/index.js +7 -0
- package/lib-amd/components/Menu/index.js.map +1 -0
- package/lib-amd/components/Menu/shimMenuProps.js +30 -0
- package/lib-amd/components/Menu/shimMenuProps.js.map +1 -0
- package/lib-amd/components/Stack/StackItemShim.js +150 -0
- package/lib-amd/components/Stack/StackItemShim.js.map +1 -0
- package/lib-amd/components/Stack/StackShim.js +242 -0
- package/lib-amd/components/Stack/StackShim.js.map +1 -0
- package/lib-amd/components/Stack/index.js +7 -0
- package/lib-amd/components/Stack/index.js.map +1 -0
- package/lib-amd/components/Stack/stackUtils.js +168 -0
- package/lib-amd/components/Stack/stackUtils.js.map +1 -0
- package/lib-amd/components/Theme/index.js +9 -0
- package/lib-amd/components/Theme/index.js.map +1 -0
- package/lib-amd/components/Theme/themeDuplicates.js +864 -0
- package/lib-amd/components/Theme/themeDuplicates.js.map +1 -0
- package/lib-amd/components/Theme/v8ThemeShim.js +140 -0
- package/lib-amd/components/Theme/v8ThemeShim.js.map +1 -0
- package/lib-amd/components/Theme/v9BrandVariantsShim.js +75 -0
- package/lib-amd/components/Theme/v9BrandVariantsShim.js.map +1 -0
- package/lib-amd/components/Theme/v9ThemeShim.js +188 -0
- package/lib-amd/components/Theme/v9ThemeShim.js.map +1 -0
- package/lib-amd/index.js +38 -0
- package/lib-amd/index.js.map +1 -0
- package/lib-amd/stories/DefaultButtonShim/index.js +44 -0
- package/lib-amd/stories/DefaultButtonShim/index.js.map +1 -0
- package/lib-commonjs/components/Button/ActionButtonShim.js +28 -0
- package/lib-commonjs/components/Button/ActionButtonShim.js.map +1 -0
- package/lib-commonjs/components/Button/ButtonShim.js +37 -0
- package/lib-commonjs/components/Button/ButtonShim.js.map +1 -0
- package/lib-commonjs/components/Button/CommandButtonShim.js +19 -0
- package/lib-commonjs/components/Button/CommandButtonShim.js.map +1 -0
- package/lib-commonjs/components/Button/CompoundButtonShim.js +31 -0
- package/lib-commonjs/components/Button/CompoundButtonShim.js.map +1 -0
- package/lib-commonjs/components/Button/DefaultButtonShim.js +21 -0
- package/lib-commonjs/components/Button/DefaultButtonShim.js.map +1 -0
- package/lib-commonjs/components/Button/MenuButtonShim.js +32 -0
- package/lib-commonjs/components/Button/MenuButtonShim.js.map +1 -0
- package/lib-commonjs/components/Button/PrimaryButtonShim.js +22 -0
- package/lib-commonjs/components/Button/PrimaryButtonShim.js.map +1 -0
- package/lib-commonjs/components/Button/ToggleButtonShim.js +30 -0
- package/lib-commonjs/components/Button/ToggleButtonShim.js.map +1 -0
- package/lib-commonjs/components/Button/index.js +26 -0
- package/lib-commonjs/components/Button/index.js.map +1 -0
- package/lib-commonjs/components/Button/shimButtonProps.js +35 -0
- package/lib-commonjs/components/Button/shimButtonProps.js.map +1 -0
- package/lib-commonjs/components/Menu/MenuShim.js +58 -0
- package/lib-commonjs/components/Menu/MenuShim.js.map +1 -0
- package/lib-commonjs/components/Menu/index.js +12 -0
- package/lib-commonjs/components/Menu/index.js.map +1 -0
- package/lib-commonjs/components/Menu/shimMenuProps.js +53 -0
- package/lib-commonjs/components/Menu/shimMenuProps.js.map +1 -0
- package/lib-commonjs/components/Stack/StackItemShim.js +188 -0
- package/lib-commonjs/components/Stack/StackItemShim.js.map +1 -0
- package/lib-commonjs/components/Stack/StackShim.js +273 -0
- package/lib-commonjs/components/Stack/StackShim.js.map +1 -0
- package/lib-commonjs/components/Stack/index.js +12 -0
- package/lib-commonjs/components/Stack/index.js.map +1 -0
- package/lib-commonjs/components/Stack/stackUtils.js +182 -0
- package/lib-commonjs/components/Stack/stackUtils.js.map +1 -0
- package/lib-commonjs/components/Theme/index.js +16 -0
- package/lib-commonjs/components/Theme/index.js.map +1 -0
- package/lib-commonjs/components/Theme/themeDuplicates.js +865 -0
- package/lib-commonjs/components/Theme/themeDuplicates.js.map +1 -0
- package/lib-commonjs/components/Theme/v8ThemeShim.js +324 -0
- package/lib-commonjs/components/Theme/v8ThemeShim.js.map +1 -0
- package/lib-commonjs/components/Theme/v9BrandVariantsShim.js +87 -0
- package/lib-commonjs/components/Theme/v9BrandVariantsShim.js.map +1 -0
- package/lib-commonjs/components/Theme/v9ThemeShim.js +206 -0
- package/lib-commonjs/components/Theme/v9ThemeShim.js.map +1 -0
- package/lib-commonjs/index.js +211 -0
- package/lib-commonjs/index.js.map +1 -0
- package/lib-commonjs/stories/DefaultButtonShim/index.js +64 -0
- package/lib-commonjs/stories/DefaultButtonShim/index.js.map +1 -0
- package/package.json +2 -2
|
@@ -0,0 +1,260 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { classNamesFunction } from '@fluentui/react';
|
|
3
|
+
import { __styles, mergeClasses } from '@griffel/react';
|
|
4
|
+
import { getChildrenGapStyles } from './stackUtils';
|
|
5
|
+
const stackClassNames = {
|
|
6
|
+
root: 'ms-Stack',
|
|
7
|
+
inner: 'ms-Stack-inner'
|
|
8
|
+
};
|
|
9
|
+
const getClassNames = /*#__PURE__*/classNamesFunction();
|
|
10
|
+
|
|
11
|
+
const useStackStyles = /*#__PURE__*/__styles({
|
|
12
|
+
"root": {
|
|
13
|
+
"mc9l5x": "f22iagw",
|
|
14
|
+
"Beiy3e4": "f1vx9l62",
|
|
15
|
+
"Eh141a": "flvyvdh",
|
|
16
|
+
"a9b677": "f14z66ap",
|
|
17
|
+
"Bqenvij": "f11ysow2",
|
|
18
|
+
"B7ck84d": "f1ewtqcl",
|
|
19
|
+
"Bj0s3o2": "fh9g2hb",
|
|
20
|
+
"alpwn5": "f1mj8y37"
|
|
21
|
+
},
|
|
22
|
+
"horizontal": {
|
|
23
|
+
"Beiy3e4": "f1063pyq"
|
|
24
|
+
},
|
|
25
|
+
"verticalFill": {
|
|
26
|
+
"Bqenvij": "f1l02sjl"
|
|
27
|
+
},
|
|
28
|
+
"reversedVertical": {
|
|
29
|
+
"Beiy3e4": "f1gkdon0"
|
|
30
|
+
},
|
|
31
|
+
"reversedHorizontal": {
|
|
32
|
+
"Beiy3e4": "f1oztnx0"
|
|
33
|
+
},
|
|
34
|
+
"disableShrink": {
|
|
35
|
+
"alpwn5": "f1am4glz"
|
|
36
|
+
},
|
|
37
|
+
"wrap": {
|
|
38
|
+
"mc9l5x": "f22iagw",
|
|
39
|
+
"Eh141a": "fni485r",
|
|
40
|
+
"Bqenvij": "f1l02sjl"
|
|
41
|
+
},
|
|
42
|
+
"inner": {
|
|
43
|
+
"mc9l5x": "f22iagw",
|
|
44
|
+
"Beiy3e4": "f1vx9l62",
|
|
45
|
+
"Eh141a": "fni485r",
|
|
46
|
+
"B7ck84d": "f1ewtqcl",
|
|
47
|
+
"B2u0y6b": "f1w39fev",
|
|
48
|
+
"alpwn5": "f1mj8y37"
|
|
49
|
+
},
|
|
50
|
+
"innerWidth": {
|
|
51
|
+
"a9b677": "fly5x3f"
|
|
52
|
+
}
|
|
53
|
+
}, {
|
|
54
|
+
"d": [".f22iagw{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;}", ".f1vx9l62{-webkit-flex-direction:column;-ms-flex-direction:column;flex-direction:column;}", ".flvyvdh{-webkit-box-flex-wrap:nowrap;-webkit-flex-wrap:nowrap;-ms-flex-wrap:nowrap;flex-wrap:nowrap;}", ".f14z66ap{width:auto;}", ".f11ysow2{height:auto;}", ".f1ewtqcl{box-sizing:border-box;}", ".fh9g2hb>*{text-overflow:ellipsis;}", ".f1mj8y37>*:not(.ms-StackItem){-webkit-flex-shrink:1;-ms-flex-negative:1;flex-shrink:1;}", ".f1063pyq{-webkit-flex-direction:row;-ms-flex-direction:row;flex-direction:row;}", ".f1l02sjl{height:100%;}", ".f1gkdon0{-webkit-flex-direction:column-reverse;-ms-flex-direction:column-reverse;flex-direction:column-reverse;}", ".f1oztnx0{-webkit-flex-direction:row-reverse;-ms-flex-direction:row-reverse;flex-direction:row-reverse;}", ".f1am4glz>*:not(.ms-StackItem){-webkit-flex-shrink:0;-ms-flex-negative:0;flex-shrink:0;}", ".fni485r{-webkit-box-flex-wrap:wrap;-webkit-flex-wrap:wrap;-ms-flex-wrap:wrap;flex-wrap:wrap;}", ".f1w39fev{max-width:100vw;}", ".fly5x3f{width:100%;}"]
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
const useFlexGrowStyles = /*#__PURE__*/__styles({
|
|
58
|
+
"1": {
|
|
59
|
+
"Bh6795r": "fqerorx"
|
|
60
|
+
},
|
|
61
|
+
"2": {
|
|
62
|
+
"Bh6795r": "fv68sux"
|
|
63
|
+
},
|
|
64
|
+
"3": {
|
|
65
|
+
"Bh6795r": "f1g5s877"
|
|
66
|
+
},
|
|
67
|
+
"inherit": {
|
|
68
|
+
"Bh6795r": "fbrulcr"
|
|
69
|
+
},
|
|
70
|
+
"initial": {
|
|
71
|
+
"Bh6795r": "fqq5sy3"
|
|
72
|
+
},
|
|
73
|
+
"revert": {
|
|
74
|
+
"Bh6795r": "f1kc8nlq"
|
|
75
|
+
},
|
|
76
|
+
"unset": {
|
|
77
|
+
"Bh6795r": "fepjonw"
|
|
78
|
+
}
|
|
79
|
+
}, {
|
|
80
|
+
"d": [".fqerorx{-webkit-box-flex:1;-webkit-flex-grow:1;-ms-flex-positive:1;flex-grow:1;}", ".fv68sux{-webkit-box-flex:2;-webkit-flex-grow:2;-ms-flex-positive:2;flex-grow:2;}", ".f1g5s877{-webkit-box-flex:3;-webkit-flex-grow:3;-ms-flex-positive:3;flex-grow:3;}", ".fbrulcr{-webkit-box-flex:inherit;-webkit-flex-grow:inherit;-ms-flex-positive:inherit;flex-grow:inherit;}", ".fqq5sy3{-webkit-box-flex:initial;-webkit-flex-grow:initial;-ms-flex-positive:initial;flex-grow:initial;}", ".f1kc8nlq{-webkit-box-flex:revert;-webkit-flex-grow:revert;-ms-flex-positive:revert;flex-grow:revert;}", ".fepjonw{-webkit-box-flex:unset;-webkit-flex-grow:unset;-ms-flex-positive:unset;flex-grow:unset;}"]
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
const useFlexAlignItemsStyles = /*#__PURE__*/__styles({
|
|
84
|
+
"baseline": {
|
|
85
|
+
"Bt984gj": "f1guyajx"
|
|
86
|
+
},
|
|
87
|
+
"center": {
|
|
88
|
+
"Bt984gj": "f122n59"
|
|
89
|
+
},
|
|
90
|
+
"start": {
|
|
91
|
+
"Bt984gj": "f6jr5hl"
|
|
92
|
+
},
|
|
93
|
+
"end": {
|
|
94
|
+
"Bt984gj": "fgs5rwf"
|
|
95
|
+
},
|
|
96
|
+
"stretch": {
|
|
97
|
+
"Bt984gj": "f1q9h2pe"
|
|
98
|
+
},
|
|
99
|
+
"space-between": {
|
|
100
|
+
"Bt984gj": "f1jkqsad"
|
|
101
|
+
},
|
|
102
|
+
"space-around": {
|
|
103
|
+
"Bt984gj": "ftnnmgl"
|
|
104
|
+
},
|
|
105
|
+
"space-evenly": {
|
|
106
|
+
"Bt984gj": "f1uhtmqw"
|
|
107
|
+
}
|
|
108
|
+
}, {
|
|
109
|
+
"d": [".f1guyajx{-webkit-align-items:baseline;-webkit-box-align:baseline;-ms-flex-align:baseline;align-items:baseline;}", ".f122n59{-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;}", ".f6jr5hl{-webkit-align-items:flex-start;-webkit-box-align:flex-start;-ms-flex-align:flex-start;align-items:flex-start;}", ".fgs5rwf{-webkit-align-items:flex-end;-webkit-box-align:flex-end;-ms-flex-align:flex-end;align-items:flex-end;}", ".f1q9h2pe{-webkit-align-items:stretch;-webkit-box-align:stretch;-ms-flex-align:stretch;align-items:stretch;}", ".f1jkqsad{-webkit-align-items:space-between;-webkit-box-align:space-between;-ms-flex-align:space-between;align-items:space-between;}", ".ftnnmgl{-webkit-align-items:space-around;-webkit-box-align:space-around;-ms-flex-align:space-around;align-items:space-around;}", ".f1uhtmqw{-webkit-align-items:space-evenly;-webkit-box-align:space-evenly;-ms-flex-align:space-evenly;align-items:space-evenly;}"]
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
const useFlexJustifyContentStyles = /*#__PURE__*/__styles({
|
|
113
|
+
"baseline": {
|
|
114
|
+
"Brf1p80": "f1uf0ky1"
|
|
115
|
+
},
|
|
116
|
+
"center": {
|
|
117
|
+
"Brf1p80": "f4d9j23"
|
|
118
|
+
},
|
|
119
|
+
"start": {
|
|
120
|
+
"Brf1p80": "fbhxue7"
|
|
121
|
+
},
|
|
122
|
+
"end": {
|
|
123
|
+
"Brf1p80": "f9c4gz4"
|
|
124
|
+
},
|
|
125
|
+
"stretch": {
|
|
126
|
+
"Brf1p80": "fsxf2b5"
|
|
127
|
+
},
|
|
128
|
+
"space-between": {
|
|
129
|
+
"Brf1p80": "f1869bpl"
|
|
130
|
+
},
|
|
131
|
+
"space-around": {
|
|
132
|
+
"Brf1p80": "f1iw3tyt"
|
|
133
|
+
},
|
|
134
|
+
"space-evenly": {
|
|
135
|
+
"Brf1p80": "figf6al"
|
|
136
|
+
}
|
|
137
|
+
}, {
|
|
138
|
+
"d": [".f1uf0ky1{-webkit-box-pack:baseline;-ms-flex-pack:baseline;-webkit-justify-content:baseline;justify-content:baseline;}", ".f4d9j23{-webkit-box-pack:center;-ms-flex-pack:center;-webkit-justify-content:center;justify-content:center;}", ".fbhxue7{-webkit-box-pack:start;-ms-flex-pack:start;-webkit-justify-content:flex-start;justify-content:flex-start;}", ".f9c4gz4{-webkit-box-pack:end;-ms-flex-pack:end;-webkit-justify-content:flex-end;justify-content:flex-end;}", ".fsxf2b5{-webkit-box-pack:stretch;-ms-flex-pack:stretch;-webkit-justify-content:stretch;justify-content:stretch;}", ".f1869bpl{-webkit-box-pack:justify;-webkit-justify-content:space-between;justify-content:space-between;}", ".f1iw3tyt{-webkit-box-pack:space-around;-ms-flex-pack:space-around;-webkit-justify-content:space-around;justify-content:space-around;}", ".figf6al{-webkit-box-pack:space-evenly;-ms-flex-pack:space-evenly;-webkit-justify-content:space-evenly;justify-content:space-evenly;}"]
|
|
139
|
+
});
|
|
140
|
+
|
|
141
|
+
export const StackShim = props => {
|
|
142
|
+
const styles = useStackStyles();
|
|
143
|
+
const alignItemsFlexStyles = useFlexAlignItemsStyles();
|
|
144
|
+
const justifyContentFlexStyles = useFlexJustifyContentStyles();
|
|
145
|
+
const growFlexStyles = useFlexGrowStyles();
|
|
146
|
+
const {
|
|
147
|
+
as: RootType = 'div',
|
|
148
|
+
verticalFill,
|
|
149
|
+
horizontal,
|
|
150
|
+
reversed,
|
|
151
|
+
grow,
|
|
152
|
+
wrap,
|
|
153
|
+
horizontalAlign,
|
|
154
|
+
verticalAlign,
|
|
155
|
+
disableShrink,
|
|
156
|
+
className
|
|
157
|
+
} = props;
|
|
158
|
+
const tokens = { ...props.tokens
|
|
159
|
+
};
|
|
160
|
+
let tokensRootStyles = {};
|
|
161
|
+
let tokensInnerStyles = {};
|
|
162
|
+
let childrenGapClassName;
|
|
163
|
+
|
|
164
|
+
if (tokens) {
|
|
165
|
+
tokensRootStyles = {
|
|
166
|
+
padding: !wrap ? tokens.padding : undefined,
|
|
167
|
+
maxHeight: tokens.maxHeight,
|
|
168
|
+
maxWidth: tokens.maxWidth
|
|
169
|
+
};
|
|
170
|
+
tokensInnerStyles = {
|
|
171
|
+
padding: wrap ? tokens.padding : undefined
|
|
172
|
+
};
|
|
173
|
+
|
|
174
|
+
if (tokens.childrenGap) {
|
|
175
|
+
childrenGapClassName = getClassNames(getChildrenGapStyles, {
|
|
176
|
+
horizontal,
|
|
177
|
+
reversed,
|
|
178
|
+
tokens
|
|
179
|
+
});
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
const stackStyles = [wrap ? styles.wrap : styles.root, horizontal && styles.horizontal, verticalFill && styles.verticalFill];
|
|
184
|
+
const stackInnerStyles = [styles.inner, horizontal && styles.horizontal, (!tokens || !tokens.childrenGap) && styles.innerWidth];
|
|
185
|
+
let stackChildren = React.Children.toArray(props.children);
|
|
186
|
+
|
|
187
|
+
if (stackChildren.length === 1 && /*#__PURE__*/React.isValidElement(stackChildren[0]) && stackChildren[0].type === React.Fragment) {
|
|
188
|
+
stackChildren = stackChildren[0].props.children;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
stackChildren = React.Children.map(stackChildren, child => {
|
|
192
|
+
if (!child) {
|
|
193
|
+
return null;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
if (child.type && child.type.name === 'StackItemShim') {
|
|
197
|
+
const defaultItemProps = {
|
|
198
|
+
shrink: !disableShrink
|
|
199
|
+
};
|
|
200
|
+
return /*#__PURE__*/React.cloneElement(child, { ...defaultItemProps,
|
|
201
|
+
...child.props
|
|
202
|
+
});
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
return child;
|
|
206
|
+
});
|
|
207
|
+
|
|
208
|
+
if (reversed) {
|
|
209
|
+
if (horizontal) {
|
|
210
|
+
stackStyles.push(styles.reversedHorizontal);
|
|
211
|
+
stackInnerStyles.push(styles.reversedHorizontal);
|
|
212
|
+
} else {
|
|
213
|
+
stackStyles.push(styles.reversedVertical);
|
|
214
|
+
stackInnerStyles.push(styles.reversedVertical);
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
if (grow) {
|
|
219
|
+
const flexGrow = grow === true ? growFlexStyles[1] : growFlexStyles[grow];
|
|
220
|
+
stackStyles.push(flexGrow);
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
if (disableShrink) {
|
|
224
|
+
stackStyles.push(styles.disableShrink);
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
if (horizontalAlign) {
|
|
228
|
+
if (horizontal) {
|
|
229
|
+
stackStyles.push(justifyContentFlexStyles[horizontalAlign]);
|
|
230
|
+
stackInnerStyles.push(justifyContentFlexStyles[horizontalAlign]);
|
|
231
|
+
} else {
|
|
232
|
+
stackStyles.push(alignItemsFlexStyles[horizontalAlign]);
|
|
233
|
+
stackInnerStyles.push(alignItemsFlexStyles[horizontalAlign]);
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
if (verticalAlign) {
|
|
238
|
+
if (horizontal) {
|
|
239
|
+
stackStyles.push(alignItemsFlexStyles[verticalAlign]);
|
|
240
|
+
stackInnerStyles.push(alignItemsFlexStyles[verticalAlign]);
|
|
241
|
+
} else {
|
|
242
|
+
stackStyles.push(justifyContentFlexStyles[verticalAlign]);
|
|
243
|
+
stackInnerStyles.push(justifyContentFlexStyles[verticalAlign]);
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
const rootClass = mergeClasses(stackClassNames.root, ...stackStyles, childrenGapClassName && !wrap && childrenGapClassName.root, className);
|
|
248
|
+
const innerClass = mergeClasses(stackClassNames.inner, ...stackInnerStyles, childrenGapClassName && wrap && childrenGapClassName.inner);
|
|
249
|
+
return wrap ? /*#__PURE__*/React.createElement(RootType, {
|
|
250
|
+
className: rootClass,
|
|
251
|
+
style: tokensRootStyles
|
|
252
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
253
|
+
className: innerClass,
|
|
254
|
+
style: tokensInnerStyles
|
|
255
|
+
}, stackChildren)) : /*#__PURE__*/React.createElement(RootType, {
|
|
256
|
+
className: rootClass,
|
|
257
|
+
style: tokensRootStyles
|
|
258
|
+
}, stackChildren);
|
|
259
|
+
};
|
|
260
|
+
//# sourceMappingURL=StackShim.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["components/Stack/StackShim.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAZ,MAAuB,OAAvB;AAEA,SAAS,kBAAT,QAAmC,iBAAnC;AAEA,mBAAqB,YAArB,QAAyC,gBAAzC;AACA,SAAS,oBAAT,QAAqC,cAArC;AAGA,MAAM,eAAe,GAAG;EACtB,IAAI,EAAE,UADgB;EAEtB,KAAK,EAAE;AAFe,CAAxB;AAKA,MAAM,aAAa,gBAAG,kBAAkB,EAAxC;;AAEA,MAAM,cAAc,gBAAG;EAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;EAAA;EAAA;IAAA;EAAA;EAAA;IAAA;EAAA;EAA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eAAD,CAA1C;IACD;EACF;;EAED,IAAI,aAAJ,EAAmB;IACjB,IAAI,UAAJ,EAAgB;MACd,WAAW,CAAC,IAAZ,CAAiB,oBAAoB,CAAC,aAAD,CAArC;MACA,gBAAgB,CAAC,IAAjB,CAAsB,oBAAoB,CAAC,aAAD,CAA1C;IACD,CAHD,MAGO;MACL,WAAW,CAAC,IAAZ,CAAiB,wBAAwB,CAAC,aAAD,CAAzC;MACA,gBAAgB,CAAC,IAAjB,CAAsB,wBAAwB,CAAC,aAAD,CAA9C;IACD;EACF;;EAED,MAAM,SAAS,GAAG,YAAY,CAC5B,eAAe,CAAC,IADY,EAE5B,GAAG,WAFyB,EAG5B,oBAAoB,IAAI,CAAC,IAAzB,IAAiC,oBAAoB,CAAC,IAH1B,EAI5B,SAJ4B,CAA9B;EAOA,MAAM,UAAU,GAAG,YAAY,CAC7B,eAAe,CAAC,KADa,EAE7B,GAAG,gBAF0B,EAG7B,oBAAoB,IAAI,IAAxB,IAAgC,oBAAoB,CAAC,KAHxB,CAA/B;EAMA,OAAO,IAAI,gBACT,KAAA,CAAA,aAAA,CAAC,QAAD,EAAS;IAAC,SAAS,EAAE,SAAZ;IAAuB,KAAK,EAAE;EAA9B,CAAT,eACE,KAAA,CAAA,aAAA,CAAA,KAAA,EAAA;IAAK,SAAS,EAAE,UAAhB;IAA4B,KAAK,EAAE;EAAnC,CAAA,EACG,aADH,CADF,CADS,gBAOT,KAAA,CAAA,aAAA,CAAC,QAAD,EAAS;IAAC,SAAS,EAAE,SAAZ;IAAuB,KAAK,EAAE;EAA9B,CAAT,EACG,aADH,CAPF;AAWD,CAvJM","sourcesContent":["import * as React from 'react';\n\nimport { classNamesFunction } from '@fluentui/react';\nimport type { IStackProps, IStackTokens, IStackItemProps } from '@fluentui/react';\nimport { makeStyles, mergeClasses } from '@griffel/react';\nimport { getChildrenGapStyles } from './stackUtils';\nimport type { StackShimStyles } from './stackUtils';\n\nconst stackClassNames = {\n root: 'ms-Stack',\n inner: 'ms-Stack-inner',\n};\n\nconst getClassNames = classNamesFunction<IStackProps, StackShimStyles>();\n\nconst useStackStyles = makeStyles({\n root: {\n display: 'flex',\n flexDirection: 'column',\n flexWrap: 'nowrap',\n width: 'auto',\n height: 'auto',\n boxSizing: 'border-box',\n '> *': {\n textOverflow: 'ellipsis',\n },\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n '> *:not(.ms-StackItem)': {\n flexShrink: 1,\n },\n },\n horizontal: {\n flexDirection: 'row',\n },\n verticalFill: {\n height: '100%',\n },\n reversedVertical: {\n flexDirection: 'column-reverse',\n },\n reversedHorizontal: {\n flexDirection: 'row-reverse',\n },\n disableShrink: {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n '> *:not(.ms-StackItem)': {\n flexShrink: 0,\n },\n },\n wrap: {\n display: 'flex',\n flexWrap: 'wrap',\n height: '100%',\n },\n inner: {\n display: 'flex',\n flexDirection: 'column',\n flexWrap: 'wrap',\n boxSizing: 'border-box',\n maxWidth: '100vw',\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n '> *:not(.ms-StackItem)': {\n flexShrink: 1,\n },\n },\n innerWidth: {\n width: '100%',\n },\n});\n\nconst useFlexGrowStyles = makeStyles({\n inherit: {\n flexGrow: 'inherit',\n },\n initial: {\n flexGrow: 'initial',\n },\n revert: {\n flexGrow: 'revert',\n },\n unset: {\n flexGrow: 'unset',\n },\n '1': {\n flexGrow: 1,\n },\n '2': {\n flexGrow: 2,\n },\n '3': {\n flexGrow: 3,\n },\n});\n\nconst useFlexAlignItemsStyles = makeStyles({\n baseline: {\n alignItems: 'baseline',\n },\n center: {\n alignItems: 'center',\n },\n start: {\n alignItems: 'flex-start',\n },\n end: {\n alignItems: 'flex-end',\n },\n stretch: {\n alignItems: 'stretch',\n },\n 'space-between': {\n alignItems: 'space-between',\n },\n\n 'space-around': {\n alignItems: 'space-around',\n },\n 'space-evenly': {\n alignItems: 'space-evenly',\n },\n});\n\nconst useFlexJustifyContentStyles = makeStyles({\n baseline: {\n justifyContent: 'baseline',\n },\n center: {\n justifyContent: 'center',\n },\n start: {\n justifyContent: 'flex-start',\n },\n end: {\n justifyContent: 'flex-end',\n },\n stretch: {\n justifyContent: 'stretch',\n },\n 'space-between': {\n justifyContent: 'space-between',\n },\n\n 'space-around': {\n justifyContent: 'space-around',\n },\n 'space-evenly': {\n justifyContent: 'space-evenly',\n },\n});\n\nexport const StackShim = (props: IStackProps) => {\n const styles = useStackStyles();\n const alignItemsFlexStyles = useFlexAlignItemsStyles();\n const justifyContentFlexStyles = useFlexJustifyContentStyles();\n const growFlexStyles: Record<string, string> = useFlexGrowStyles();\n\n const {\n as: RootType = 'div',\n verticalFill,\n horizontal,\n reversed,\n grow,\n wrap,\n horizontalAlign,\n verticalAlign,\n disableShrink,\n className,\n } = props;\n\n const tokens: IStackTokens = { ...props.tokens };\n\n let tokensRootStyles = {};\n let tokensInnerStyles = {};\n let childrenGapClassName;\n\n if (tokens) {\n tokensRootStyles = {\n padding: !wrap ? tokens.padding : undefined,\n maxHeight: tokens.maxHeight,\n maxWidth: tokens.maxWidth,\n };\n\n tokensInnerStyles = {\n padding: wrap ? tokens.padding : undefined,\n };\n\n if (tokens.childrenGap) {\n childrenGapClassName = getClassNames(getChildrenGapStyles, {\n horizontal,\n reversed,\n tokens,\n });\n }\n }\n\n const stackStyles = [\n wrap ? styles.wrap : styles.root,\n horizontal && styles.horizontal,\n verticalFill && styles.verticalFill,\n ];\n\n const stackInnerStyles = [\n styles.inner,\n horizontal && styles.horizontal,\n (!tokens || !tokens.childrenGap) && styles.innerWidth,\n ];\n\n let stackChildren = React.Children.toArray(props.children);\n if (\n stackChildren.length === 1 &&\n React.isValidElement(stackChildren[0]) &&\n stackChildren[0].type === React.Fragment\n ) {\n stackChildren = stackChildren[0].props.children;\n }\n\n stackChildren = React.Children.map(\n stackChildren as React.ReactElement[],\n (child: React.ReactElement<IStackItemProps>) => {\n if (!child) {\n return null;\n }\n\n if (child.type && ((child as React.ReactElement).type as React.ComponentType).name === 'StackItemShim') {\n const defaultItemProps: IStackItemProps = {\n shrink: !disableShrink,\n };\n\n return React.cloneElement(child, {\n ...defaultItemProps,\n ...child.props,\n });\n }\n\n return child;\n },\n );\n\n if (reversed) {\n if (horizontal) {\n stackStyles.push(styles.reversedHorizontal);\n stackInnerStyles.push(styles.reversedHorizontal);\n } else {\n stackStyles.push(styles.reversedVertical);\n stackInnerStyles.push(styles.reversedVertical);\n }\n }\n\n if (grow) {\n const flexGrow = grow === true ? growFlexStyles[1] : growFlexStyles[grow];\n stackStyles.push(flexGrow);\n }\n\n if (disableShrink) {\n stackStyles.push(styles.disableShrink);\n }\n\n if (horizontalAlign) {\n if (horizontal) {\n stackStyles.push(justifyContentFlexStyles[horizontalAlign]);\n stackInnerStyles.push(justifyContentFlexStyles[horizontalAlign]);\n } else {\n stackStyles.push(alignItemsFlexStyles[horizontalAlign]);\n stackInnerStyles.push(alignItemsFlexStyles[horizontalAlign]);\n }\n }\n\n if (verticalAlign) {\n if (horizontal) {\n stackStyles.push(alignItemsFlexStyles[verticalAlign]);\n stackInnerStyles.push(alignItemsFlexStyles[verticalAlign]);\n } else {\n stackStyles.push(justifyContentFlexStyles[verticalAlign]);\n stackInnerStyles.push(justifyContentFlexStyles[verticalAlign]);\n }\n }\n\n const rootClass = mergeClasses(\n stackClassNames.root,\n ...stackStyles,\n childrenGapClassName && !wrap && childrenGapClassName.root,\n className,\n );\n\n const innerClass = mergeClasses(\n stackClassNames.inner,\n ...stackInnerStyles,\n childrenGapClassName && wrap && childrenGapClassName.inner,\n );\n\n return wrap ? (\n <RootType className={rootClass} style={tokensRootStyles}>\n <div className={innerClass} style={tokensInnerStyles}>\n {stackChildren}\n </div>\n </RootType>\n ) : (\n <RootType className={rootClass} style={tokensRootStyles}>\n {stackChildren}\n </RootType>\n );\n};\n"],"sourceRoot":"../src/"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"../src/","sources":["components/Stack/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC;AAChC,cAAc,aAAa,CAAC","sourcesContent":["export * from './StackItemShim';\nexport * from './StackShim';\n"]}
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
import { getTheme } from '@fluentui/react'; // Helper function that converts a themed spacing key (if given) to the corresponding themed spacing value.
|
|
2
|
+
|
|
3
|
+
const getThemedSpacing = (space, theme) => {
|
|
4
|
+
if (theme.spacing.hasOwnProperty(space)) {
|
|
5
|
+
return theme.spacing[space];
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
return space;
|
|
9
|
+
}; // Helper function that takes a gap as a string and converts it into a { value, unit } representation.
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
const getValueUnitGap = gap => {
|
|
13
|
+
const numericalPart = parseFloat(gap);
|
|
14
|
+
const numericalValue = isNaN(numericalPart) ? 0 : numericalPart;
|
|
15
|
+
const numericalString = isNaN(numericalPart) ? '' : numericalPart.toString();
|
|
16
|
+
const unitPart = gap.substring(numericalString.toString().length);
|
|
17
|
+
return {
|
|
18
|
+
value: numericalValue,
|
|
19
|
+
unit: unitPart || 'px'
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* Takes in a gap size in either a CSS-style format (e.g. 10 or "10px")
|
|
24
|
+
* or a key of a themed spacing value (e.g. "s1").
|
|
25
|
+
* Returns the separate numerical value of the padding (e.g. 10)
|
|
26
|
+
* and the CSS unit (e.g. "px").
|
|
27
|
+
*/
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
export const parseGap = (gap, theme) => {
|
|
31
|
+
if (gap === undefined || gap === '') {
|
|
32
|
+
return {
|
|
33
|
+
rowGap: {
|
|
34
|
+
value: 0,
|
|
35
|
+
unit: 'px'
|
|
36
|
+
},
|
|
37
|
+
columnGap: {
|
|
38
|
+
value: 0,
|
|
39
|
+
unit: 'px'
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
if (typeof gap === 'number') {
|
|
45
|
+
return {
|
|
46
|
+
rowGap: {
|
|
47
|
+
value: gap,
|
|
48
|
+
unit: 'px'
|
|
49
|
+
},
|
|
50
|
+
columnGap: {
|
|
51
|
+
value: gap,
|
|
52
|
+
unit: 'px'
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
const splitGap = gap.split(' '); // If the array has more than two values, then return 0px.
|
|
58
|
+
|
|
59
|
+
if (splitGap.length > 2) {
|
|
60
|
+
return {
|
|
61
|
+
rowGap: {
|
|
62
|
+
value: 0,
|
|
63
|
+
unit: 'px'
|
|
64
|
+
},
|
|
65
|
+
columnGap: {
|
|
66
|
+
value: 0,
|
|
67
|
+
unit: 'px'
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
} // If the array has two values, then parse each one.
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
if (splitGap.length === 2) {
|
|
74
|
+
return {
|
|
75
|
+
rowGap: getValueUnitGap(getThemedSpacing(splitGap[0], theme)),
|
|
76
|
+
columnGap: getValueUnitGap(getThemedSpacing(splitGap[1], theme))
|
|
77
|
+
};
|
|
78
|
+
} // Else, parse the numerical value and pass it as both the vertical and horizontal gap.
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
const calculatedGap = getValueUnitGap(getThemedSpacing(gap, theme));
|
|
82
|
+
return {
|
|
83
|
+
rowGap: calculatedGap,
|
|
84
|
+
columnGap: calculatedGap
|
|
85
|
+
};
|
|
86
|
+
};
|
|
87
|
+
/**
|
|
88
|
+
* Takes in a padding in a CSS-style format (e.g. 10, "10px", "10px 10px", etc.)
|
|
89
|
+
* where the separate padding values can also be the key of a themed spacing value
|
|
90
|
+
* (e.g. "s1 m", "10px l1 20px l2", etc.).
|
|
91
|
+
* Returns a CSS-style padding.
|
|
92
|
+
*/
|
|
93
|
+
|
|
94
|
+
export const parsePadding = (padding, theme) => {
|
|
95
|
+
if (padding === undefined || typeof padding === 'number' || padding === '') {
|
|
96
|
+
return padding;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
const paddingValues = padding.split(' ');
|
|
100
|
+
|
|
101
|
+
if (paddingValues.length < 2) {
|
|
102
|
+
return getThemedSpacing(padding, theme);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
return paddingValues.reduce((padding1, padding2) => {
|
|
106
|
+
return getThemedSpacing(padding1, theme) + ' ' + getThemedSpacing(padding2, theme);
|
|
107
|
+
});
|
|
108
|
+
};
|
|
109
|
+
/**
|
|
110
|
+
*
|
|
111
|
+
* getStyles function for Stack.tokens.childrenGap prop styling
|
|
112
|
+
*/
|
|
113
|
+
|
|
114
|
+
export const getChildrenGapStyles = props => {
|
|
115
|
+
const theme = getTheme();
|
|
116
|
+
const {
|
|
117
|
+
horizontal,
|
|
118
|
+
reversed
|
|
119
|
+
} = props;
|
|
120
|
+
const tokens = { ...props.tokens
|
|
121
|
+
};
|
|
122
|
+
const {
|
|
123
|
+
rowGap,
|
|
124
|
+
columnGap
|
|
125
|
+
} = parseGap(tokens.childrenGap, theme);
|
|
126
|
+
const horizontalMargin = `${-0.5 * columnGap.value}${columnGap.unit}`;
|
|
127
|
+
const verticalMargin = `${-0.5 * rowGap.value}${rowGap.unit}`;
|
|
128
|
+
return {
|
|
129
|
+
root: [reversed && horizontal && {
|
|
130
|
+
'> *:not(:last-child)': {
|
|
131
|
+
marginLeft: `${columnGap.value}${columnGap.unit}`
|
|
132
|
+
}
|
|
133
|
+
}, reversed && !horizontal && {
|
|
134
|
+
'> *:not(:last-child)': {
|
|
135
|
+
marginTop: `${rowGap.value}${rowGap.unit}`
|
|
136
|
+
}
|
|
137
|
+
}, !reversed && horizontal && {
|
|
138
|
+
'> *:not(:first-child)': {
|
|
139
|
+
marginLeft: `${columnGap.value}${columnGap.unit}`
|
|
140
|
+
}
|
|
141
|
+
}, !reversed && !horizontal && {
|
|
142
|
+
'> *:not(:first-child)': {
|
|
143
|
+
marginTop: `${rowGap.value}${rowGap.unit}`
|
|
144
|
+
}
|
|
145
|
+
}],
|
|
146
|
+
inner: [{
|
|
147
|
+
marginLeft: horizontalMargin,
|
|
148
|
+
marginRight: horizontalMargin,
|
|
149
|
+
marginTop: verticalMargin,
|
|
150
|
+
marginBottom: verticalMargin,
|
|
151
|
+
width: columnGap.value === 0 ? '100%' : `calc(100% + ${columnGap.value}${columnGap.unit})`,
|
|
152
|
+
'> *': {
|
|
153
|
+
margin: `${0.5 * rowGap.value}${rowGap.unit} ${0.5 * columnGap.value}${columnGap.unit}`
|
|
154
|
+
}
|
|
155
|
+
}, horizontal && {
|
|
156
|
+
height: rowGap.value === 0 ? '100%' : `calc(100% + ${rowGap.value}${rowGap.unit})`,
|
|
157
|
+
'> *': {
|
|
158
|
+
maxWidth: columnGap.value === 0 ? '100%' : `calc(100% - ${columnGap.value}${columnGap.unit})`
|
|
159
|
+
}
|
|
160
|
+
}, !horizontal && {
|
|
161
|
+
height: `calc(100% + ${rowGap.value}${rowGap.unit})`,
|
|
162
|
+
'> *': {
|
|
163
|
+
maxHeight: rowGap.value === 0 ? '100%' : `calc(100% - ${rowGap.value}${rowGap.unit})`
|
|
164
|
+
}
|
|
165
|
+
}]
|
|
166
|
+
};
|
|
167
|
+
};
|
|
168
|
+
//# sourceMappingURL=stackUtils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["components/Stack/stackUtils.ts"],"names":[],"mappings":"AAAA,SAAS,QAAT,QAAoE,iBAApE,C,CAEA;;AACA,MAAM,gBAAgB,GAAG,CAAC,KAAD,EAAgB,KAAhB,KAAyC;EAChE,IAAI,KAAK,CAAC,OAAN,CAAc,cAAd,CAA6B,KAA7B,CAAJ,EAAyC;IACvC,OAAO,KAAK,CAAC,OAAN,CAAc,KAAd,CAAP;EACD;;EACD,OAAO,KAAP;AACD,CALD,C,CAOA;;;AACA,MAAM,eAAe,GAAI,GAA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S,CAAC,IAAI;MADhF;IANT,CADK,EAWL,UAAU,IAAI;MACZ,MAAM,EAAE,MAAM,CAAC,KAAP,KAAiB,CAAjB,GAAqB,MAArB,GAA8B,eAAe,MAAM,CAAC,KAAK,GAAG,MAAM,CAAC,IAAI,GADnE;MAEZ,OAAO;QACL,QAAQ,EAAE,SAAS,CAAC,KAAV,KAAoB,CAApB,GAAwB,MAAxB,GAAiC,eAAe,SAAS,CAAC,KAAK,GAAG,SAAS,CAAC,IAAI;MADrF;IAFK,CAXT,EAiBL,CAAC,UAAD,IAAe;MACb,MAAM,EAAE,eAAe,MAAM,CAAC,KAAK,GAAG,MAAM,CAAC,IAAI,GADpC;MAEb,OAAO;QACL,SAAS,EAAE,MAAM,CAAC,KAAP,KAAiB,CAAjB,GAAqB,MAArB,GAA8B,eAAe,MAAM,CAAC,KAAK,GAAG,MAAM,CAAC,IAAI;MAD7E;IAFM,CAjBV;EA3BF,CAAP;AAoDD,CA9DM","sourcesContent":["import { getTheme, IStackProps, IStackTokens, IStyle, ITheme } from '@fluentui/react';\n\n// Helper function that converts a themed spacing key (if given) to the corresponding themed spacing value.\nconst getThemedSpacing = (space: string, theme: ITheme): string => {\n if (theme.spacing.hasOwnProperty(space)) {\n return theme.spacing[space as keyof typeof theme.spacing];\n }\n return space;\n};\n\n// Helper function that takes a gap as a string and converts it into a { value, unit } representation.\nconst getValueUnitGap = (gap: string): { value: number; unit: string } => {\n const numericalPart = parseFloat(gap);\n const numericalValue = isNaN(numericalPart) ? 0 : numericalPart;\n const numericalString = isNaN(numericalPart) ? '' : numericalPart.toString();\n\n const unitPart = gap.substring(numericalString.toString().length);\n\n return {\n value: numericalValue,\n unit: unitPart || 'px',\n };\n};\n\n/**\n * Takes in a gap size in either a CSS-style format (e.g. 10 or \"10px\")\n * or a key of a themed spacing value (e.g. \"s1\").\n * Returns the separate numerical value of the padding (e.g. 10)\n * and the CSS unit (e.g. \"px\").\n */\nexport const parseGap = (\n gap: IStackProps['gap'],\n theme: ITheme,\n): { rowGap: { value: number; unit: string }; columnGap: { value: number; unit: string } } => {\n if (gap === undefined || gap === '') {\n return {\n rowGap: {\n value: 0,\n unit: 'px',\n },\n columnGap: {\n value: 0,\n unit: 'px',\n },\n };\n }\n\n if (typeof gap === 'number') {\n return {\n rowGap: {\n value: gap,\n unit: 'px',\n },\n columnGap: {\n value: gap,\n unit: 'px',\n },\n };\n }\n\n const splitGap = gap.split(' ');\n\n // If the array has more than two values, then return 0px.\n if (splitGap.length > 2) {\n return {\n rowGap: {\n value: 0,\n unit: 'px',\n },\n columnGap: {\n value: 0,\n unit: 'px',\n },\n };\n }\n\n // If the array has two values, then parse each one.\n if (splitGap.length === 2) {\n return {\n rowGap: getValueUnitGap(getThemedSpacing(splitGap[0], theme)),\n columnGap: getValueUnitGap(getThemedSpacing(splitGap[1], theme)),\n };\n }\n\n // Else, parse the numerical value and pass it as both the vertical and horizontal gap.\n const calculatedGap = getValueUnitGap(getThemedSpacing(gap, theme));\n\n return {\n rowGap: calculatedGap,\n columnGap: calculatedGap,\n };\n};\n\n/**\n * Takes in a padding in a CSS-style format (e.g. 10, \"10px\", \"10px 10px\", etc.)\n * where the separate padding values can also be the key of a themed spacing value\n * (e.g. \"s1 m\", \"10px l1 20px l2\", etc.).\n * Returns a CSS-style padding.\n */\nexport const parsePadding = (padding: number | string | undefined, theme: ITheme): number | string | undefined => {\n if (padding === undefined || typeof padding === 'number' || padding === '') {\n return padding;\n }\n\n const paddingValues = padding.split(' ');\n if (paddingValues.length < 2) {\n return getThemedSpacing(padding, theme);\n }\n\n return paddingValues.reduce((padding1: string, padding2: string) => {\n return getThemedSpacing(padding1, theme) + ' ' + getThemedSpacing(padding2, theme);\n });\n};\n\nexport interface StackShimStyles {\n root?: IStyle;\n inner?: IStyle;\n}\n/**\n *\n * getStyles function for Stack.tokens.childrenGap prop styling\n */\nexport const getChildrenGapStyles = (props: IStackProps): StackShimStyles => {\n const theme = getTheme();\n\n const { horizontal, reversed } = props;\n const tokens: IStackTokens = { ...props.tokens };\n\n const { rowGap, columnGap } = parseGap(tokens.childrenGap, theme);\n const horizontalMargin = `${-0.5 * columnGap.value}${columnGap.unit}`;\n const verticalMargin = `${-0.5 * rowGap.value}${rowGap.unit}`;\n\n return {\n root: [\n reversed &&\n horizontal && {\n '> *:not(:last-child)': {\n marginLeft: `${columnGap.value}${columnGap.unit}`,\n },\n },\n reversed &&\n !horizontal && {\n '> *:not(:last-child)': {\n marginTop: `${rowGap.value}${rowGap.unit}`,\n },\n },\n !reversed &&\n horizontal && {\n '> *:not(:first-child)': {\n marginLeft: `${columnGap.value}${columnGap.unit}`,\n },\n },\n !reversed &&\n !horizontal && {\n '> *:not(:first-child)': {\n marginTop: `${rowGap.value}${rowGap.unit}`,\n },\n },\n ],\n inner: [\n {\n marginLeft: horizontalMargin,\n marginRight: horizontalMargin,\n marginTop: verticalMargin,\n marginBottom: verticalMargin,\n width: columnGap.value === 0 ? '100%' : `calc(100% + ${columnGap.value}${columnGap.unit})`,\n '> *': {\n margin: `${0.5 * rowGap.value}${rowGap.unit} ${0.5 * columnGap.value}${columnGap.unit}`,\n },\n },\n horizontal && {\n height: rowGap.value === 0 ? '100%' : `calc(100% + ${rowGap.value}${rowGap.unit})`,\n '> *': {\n maxWidth: columnGap.value === 0 ? '100%' : `calc(100% - ${columnGap.value}${columnGap.unit})`,\n },\n },\n !horizontal && {\n height: `calc(100% + ${rowGap.value}${rowGap.unit})`,\n '> *': {\n maxHeight: rowGap.value === 0 ? '100%' : `calc(100% - ${rowGap.value}${rowGap.unit})`,\n },\n },\n ],\n };\n};\n"],"sourceRoot":"../src/"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"../src/","sources":["components/Theme/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,eAAe,CAAC;AAC9B,cAAc,uBAAuB,CAAC;AACtC,cAAc,eAAe,CAAC","sourcesContent":["export * from './themeDuplicates';\nexport * from './v8ThemeShim';\nexport * from './v9BrandVariantsShim';\nexport * from './v9ThemeShim';\n"]}
|