@fluentui-react-native/experimental-shadow 0.7.0 → 0.7.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.
@@ -10,37 +10,37 @@ const appleShadowBlurAdjustment = 0.5;
10
10
  const defaultShadowBlurAdjustment = 1;
11
11
  export const getShadowTokenStyleSet = memoize(getShadowTokenStyleSetWorker);
12
12
  function getShadowTokenStyleSetWorker(shadowToken) {
13
- const keyShadow = shadowToken.key;
14
- const ambientShadow = shadowToken.ambient;
15
- const shadowBlurAdjustment = Platform.OS === 'macos' || Platform.OS === 'ios' ? appleShadowBlurAdjustment : defaultShadowBlurAdjustment;
16
- return {
17
- key: {
18
- shadowColor: shadowColorFromRGBAColor(keyShadow.color),
19
- shadowOpacity: shadowOpacityFromRGBAColor(keyShadow.color),
20
- shadowRadius: keyShadow.blur * shadowBlurAdjustment,
21
- shadowOffset: {
22
- width: keyShadow.x,
23
- height: keyShadow.y,
24
- },
25
- },
26
- ambient: {
27
- shadowColor: shadowColorFromRGBAColor(ambientShadow.color),
28
- shadowOpacity: shadowOpacityFromRGBAColor(ambientShadow.color),
29
- shadowRadius: ambientShadow.blur * shadowBlurAdjustment,
30
- shadowOffset: {
31
- width: ambientShadow.x,
32
- height: ambientShadow.y,
33
- },
34
- },
35
- };
13
+ const keyShadow = shadowToken.key;
14
+ const ambientShadow = shadowToken.ambient;
15
+ const shadowBlurAdjustment = Platform.OS === 'macos' || Platform.OS === 'ios' ? appleShadowBlurAdjustment : defaultShadowBlurAdjustment;
16
+ return {
17
+ key: {
18
+ shadowColor: shadowColorFromRGBAColor(keyShadow.color),
19
+ shadowOpacity: shadowOpacityFromRGBAColor(keyShadow.color),
20
+ shadowRadius: keyShadow.blur * shadowBlurAdjustment,
21
+ shadowOffset: {
22
+ width: keyShadow.x,
23
+ height: keyShadow.y,
24
+ },
25
+ },
26
+ ambient: {
27
+ shadowColor: shadowColorFromRGBAColor(ambientShadow.color),
28
+ shadowOpacity: shadowOpacityFromRGBAColor(ambientShadow.color),
29
+ shadowRadius: ambientShadow.blur * shadowBlurAdjustment,
30
+ shadowOffset: {
31
+ width: ambientShadow.x,
32
+ height: ambientShadow.y,
33
+ },
34
+ },
35
+ };
36
36
  }
37
37
  const shadowColorFromRGBAColor = (rgbaColor) => {
38
- return rgbaColor.toString().substring(0, 7);
38
+ return rgbaColor.toString().substring(0, 7);
39
39
  };
40
40
  const shadowOpacityFromRGBAColor = (rgbaColor) => {
41
- const opacityAsHex = '0x' + rgbaColor.toString().substring(7);
42
- const opacityAsDecimal = Number(opacityAsHex) / 255.0;
43
- // Round to two decimal places
44
- return Math.round(opacityAsDecimal * 100) / 100;
41
+ const opacityAsHex = '0x' + rgbaColor.toString().substring(7);
42
+ const opacityAsDecimal = Number(opacityAsHex) / 255.0;
43
+ // Round to two decimal places
44
+ return Math.round(opacityAsDecimal * 100) / 100;
45
45
  };
46
- //# sourceMappingURL=shadowStyle.js.map
46
+ //# sourceMappingURL=shadowStyle.js.map
@@ -1,4 +1,4 @@
1
1
  import type { ShadowProps } from './Shadow.types';
2
- export declare const Shadow: import('@fluentui-react-native/framework-base').FunctionComponent<ShadowProps>;
2
+ export declare const Shadow: import("@fluentui-react-native/framework-base").FunctionComponent<ShadowProps>;
3
3
  export default Shadow;
4
- //# sourceMappingURL=Shadow.d.ts.map
4
+ //# sourceMappingURL=Shadow.d.ts.map
@@ -1,176 +1,123 @@
1
- 'use strict';
2
- var __createBinding =
3
- (this && this.__createBinding) ||
4
- (Object.create
5
- ? function (o, m, k, k2) {
6
- if (k2 === undefined) k2 = k;
7
- var desc = Object.getOwnPropertyDescriptor(m, k);
8
- if (!desc || ('get' in desc ? !m.__esModule : desc.writable || desc.configurable)) {
9
- desc = {
10
- enumerable: true,
11
- get: function () {
12
- return m[k];
13
- },
14
- };
15
- }
16
- Object.defineProperty(o, k2, desc);
17
- }
18
- : function (o, m, k, k2) {
19
- if (k2 === undefined) k2 = k;
20
- o[k2] = m[k];
21
- });
22
- var __setModuleDefault =
23
- (this && this.__setModuleDefault) ||
24
- (Object.create
25
- ? function (o, v) {
26
- Object.defineProperty(o, 'default', { enumerable: true, value: v });
27
- }
28
- : function (o, v) {
29
- o['default'] = v;
30
- });
31
- var __importStar =
32
- (this && this.__importStar) ||
33
- (function () {
34
- var ownKeys = function (o) {
35
- ownKeys =
36
- Object.getOwnPropertyNames ||
37
- function (o) {
38
- var ar = [];
39
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
40
- return ar;
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
41
24
  };
42
- return ownKeys(o);
25
+ return ownKeys(o);
43
26
  };
44
27
  return function (mod) {
45
- if (mod && mod.__esModule) return mod;
46
- var result = {};
47
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== 'default') __createBinding(result, mod, k[i]);
48
- __setModuleDefault(result, mod);
49
- return result;
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
50
33
  };
51
- })();
52
- Object.defineProperty(exports, '__esModule', { value: true });
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
53
36
  exports.Shadow = void 0;
54
- const jsx_runtime_1 = require('react/jsx-runtime');
55
- const React = __importStar(require('react'));
56
- const react_native_1 = require('react-native');
57
- const framework_base_1 = require('@fluentui-react-native/framework-base');
58
- const Shadow_types_1 = require('./Shadow.types');
59
- const shadowStyle_1 = require('./shadowStyle');
37
+ const jsx_runtime_1 = require("react/jsx-runtime");
38
+ const React = __importStar(require("react"));
39
+ const react_native_1 = require("react-native");
40
+ const framework_base_1 = require("@fluentui-react-native/framework-base");
41
+ const Shadow_types_1 = require("./Shadow.types");
42
+ const shadowStyle_1 = require("./shadowStyle");
60
43
  exports.Shadow = (0, framework_base_1.phasedComponent)((props) => {
61
- return (0, framework_base_1.directComponent)((final) => {
62
- const { children, ...rest } = final;
63
- if (!props.shadowToken) {
64
- return jsx_runtime_1.jsx(jsx_runtime_1.Fragment, { children: children });
65
- }
66
- const { style: childStyle, ...restOfChildProps } = children.props;
67
- const shadowViewStyleProps = getStylePropsForShadowViews(childStyle, props.shadowToken);
68
- const innerShadowViewProps = (0, framework_base_1.mergeProps)(restOfChildProps, shadowViewStyleProps.inner);
69
- const outerShadowViewProps = (0, framework_base_1.mergeProps)(rest, shadowViewStyleProps.outer);
70
- const childWithInnerShadow = React.cloneElement(children, innerShadowViewProps);
71
- return jsx_runtime_1.jsx(react_native_1.View, { ...outerShadowViewProps, children: childWithInnerShadow });
72
- });
44
+ return (0, framework_base_1.directComponent)((final) => {
45
+ const { children, ...rest } = final;
46
+ if (!props.shadowToken) {
47
+ return jsx_runtime_1.jsx(jsx_runtime_1.Fragment, { children: children });
48
+ }
49
+ const { style: childStyle, ...restOfChildProps } = children.props;
50
+ const shadowViewStyleProps = getStylePropsForShadowViews(childStyle, props.shadowToken);
51
+ const innerShadowViewProps = (0, framework_base_1.mergeProps)(restOfChildProps, shadowViewStyleProps.inner);
52
+ const outerShadowViewProps = (0, framework_base_1.mergeProps)(rest, shadowViewStyleProps.outer);
53
+ const childWithInnerShadow = React.cloneElement(children, innerShadowViewProps);
54
+ return jsx_runtime_1.jsx(react_native_1.View, { ...outerShadowViewProps, children: childWithInnerShadow });
55
+ });
73
56
  });
74
57
  const getStylePropsForShadowViews = (0, framework_base_1.memoize)(getStylePropsForShadowViewsWorker);
75
58
  function getStylePropsForShadowViewsWorker(childStyleProps = {}, shadowToken) {
76
- const shadowTokenStyleSet = (0, shadowStyle_1.getShadowTokenStyleSet)(shadowToken);
77
- if (__DEV__) {
78
- if (!childStyleProps.backgroundColor) {
79
- console.warn('The View that the Shadow is set on must have a background color set');
59
+ const shadowTokenStyleSet = (0, shadowStyle_1.getShadowTokenStyleSet)(shadowToken);
60
+ if (__DEV__) {
61
+ if (!childStyleProps.backgroundColor) {
62
+ console.warn('The View that the Shadow is set on must have a background color set');
63
+ }
80
64
  }
81
- }
82
- const {
83
- borderBottomWidth,
84
- borderEndWidth,
85
- borderLeftWidth,
86
- borderRightWidth,
87
- borderStartWidth,
88
- borderTopWidth,
89
- borderWidth,
90
- margin,
91
- marginBottom,
92
- marginEnd,
93
- marginHorizontal,
94
- marginLeft,
95
- marginRight,
96
- marginStart,
97
- marginTop,
98
- marginVertical,
99
- padding,
100
- paddingBottom,
101
- paddingEnd,
102
- paddingHorizontal,
103
- paddingLeft,
104
- paddingRight,
105
- paddingStart,
106
- paddingTop,
107
- paddingVertical,
108
- alignItems,
109
- flexWrap,
110
- flexDirection,
111
- start,
112
- end,
113
- left,
114
- right,
115
- top,
116
- bottom,
117
- ...restOfChildStyleProps
118
- } = childStyleProps;
119
- // Remove undefined properties, otherwise every prop will be added and be set to
120
- // undefined, which can cause unexpected behaviour with some of the styles
121
- const innerStyle = removeUndefinedProperties({
122
- borderBottomWidth,
123
- borderEndWidth,
124
- borderLeftWidth,
125
- borderRightWidth,
126
- borderStartWidth,
127
- borderTopWidth,
128
- borderWidth,
129
- padding,
130
- paddingBottom,
131
- paddingEnd,
132
- paddingHorizontal,
133
- paddingLeft,
134
- paddingRight,
135
- paddingStart,
136
- paddingTop,
137
- paddingVertical,
138
- alignItems,
139
- flexWrap,
140
- flexDirection,
141
- ...shadowTokenStyleSet.key,
142
- ...restOfChildStyleProps,
143
- });
144
- const outerStyle = removeUndefinedProperties({
145
- margin,
146
- marginBottom,
147
- marginEnd,
148
- marginHorizontal,
149
- marginLeft,
150
- marginRight,
151
- marginStart,
152
- marginTop,
153
- marginVertical,
154
- start,
155
- end,
156
- left,
157
- right,
158
- top,
159
- bottom,
160
- ...shadowTokenStyleSet.ambient,
161
- ...restOfChildStyleProps,
162
- });
163
- return { inner: { style: innerStyle }, outer: { style: outerStyle } };
65
+ const { borderBottomWidth, borderEndWidth, borderLeftWidth, borderRightWidth, borderStartWidth, borderTopWidth, borderWidth, margin, marginBottom, marginEnd, marginHorizontal, marginLeft, marginRight, marginStart, marginTop, marginVertical, padding, paddingBottom, paddingEnd, paddingHorizontal, paddingLeft, paddingRight, paddingStart, paddingTop, paddingVertical, alignItems, flexWrap, flexDirection, start, end, left, right, top, bottom, ...restOfChildStyleProps } = childStyleProps;
66
+ // Remove undefined properties, otherwise every prop will be added and be set to
67
+ // undefined, which can cause unexpected behaviour with some of the styles
68
+ const innerStyle = removeUndefinedProperties({
69
+ borderBottomWidth,
70
+ borderEndWidth,
71
+ borderLeftWidth,
72
+ borderRightWidth,
73
+ borderStartWidth,
74
+ borderTopWidth,
75
+ borderWidth,
76
+ padding,
77
+ paddingBottom,
78
+ paddingEnd,
79
+ paddingHorizontal,
80
+ paddingLeft,
81
+ paddingRight,
82
+ paddingStart,
83
+ paddingTop,
84
+ paddingVertical,
85
+ alignItems,
86
+ flexWrap,
87
+ flexDirection,
88
+ ...shadowTokenStyleSet.key,
89
+ ...restOfChildStyleProps,
90
+ });
91
+ const outerStyle = removeUndefinedProperties({
92
+ margin,
93
+ marginBottom,
94
+ marginEnd,
95
+ marginHorizontal,
96
+ marginLeft,
97
+ marginRight,
98
+ marginStart,
99
+ marginTop,
100
+ marginVertical,
101
+ start,
102
+ end,
103
+ left,
104
+ right,
105
+ top,
106
+ bottom,
107
+ ...shadowTokenStyleSet.ambient,
108
+ ...restOfChildStyleProps,
109
+ });
110
+ return { inner: { style: innerStyle }, outer: { style: outerStyle } };
164
111
  }
165
112
  function withObjectAssign(object, [key, value]) {
166
- if (value !== undefined) {
167
- return Object.assign(object, { [key]: value });
168
- }
169
- return object;
113
+ if (value !== undefined) {
114
+ return Object.assign(object, { [key]: value });
115
+ }
116
+ return object;
170
117
  }
171
118
  const removeUndefinedProperties = (object) => {
172
- return Object.entries(object).reduce(withObjectAssign, {});
119
+ return Object.entries(object).reduce(withObjectAssign, {});
173
120
  };
174
121
  exports.Shadow.displayName = Shadow_types_1.shadowName;
175
122
  exports.default = exports.Shadow;
176
- //# sourceMappingURL=Shadow.js.map
123
+ //# sourceMappingURL=Shadow.js.map
@@ -1,10 +1,10 @@
1
1
  import type React from 'react';
2
2
  import type { ViewProps } from 'react-native';
3
3
  import type { ShadowToken } from '@fluentui-react-native/theme-types';
4
- export declare const shadowName = 'Shadow';
4
+ export declare const shadowName = "Shadow";
5
5
  export interface ShadowProps extends ViewProps {
6
- shadowToken?: ShadowToken;
7
- /** Exactly one child */
8
- children: React.ReactElement;
6
+ shadowToken?: ShadowToken;
7
+ /** Exactly one child */
8
+ children: React.ReactElement;
9
9
  }
10
- //# sourceMappingURL=Shadow.types.d.ts.map
10
+ //# sourceMappingURL=Shadow.types.d.ts.map
@@ -1,5 +1,5 @@
1
- 'use strict';
2
- Object.defineProperty(exports, '__esModule', { value: true });
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.shadowName = void 0;
4
4
  exports.shadowName = 'Shadow';
5
- //# sourceMappingURL=Shadow.types.js.map
5
+ //# sourceMappingURL=Shadow.types.js.map
@@ -1,2 +1,2 @@
1
1
  export {};
2
- //# sourceMappingURL=Shadow.test.d.ts.map
2
+ //# sourceMappingURL=Shadow.test.d.ts.map