@fluentui/react-image 9.0.0-nightly.d730088d7f.0 → 9.0.0-rc.10
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 +516 -18
- package/CHANGELOG.md +263 -121
- package/MIGRATION.md +235 -0
- package/README.md +4 -0
- package/dist/{react-image.d.ts → index.d.ts} +28 -20
- package/{lib → dist}/tsdoc-metadata.json +0 -0
- package/lib/Image.js.map +1 -1
- package/lib/components/Image/Image.js +7 -7
- package/lib/components/Image/Image.js.map +1 -1
- package/lib/components/Image/Image.types.js.map +1 -1
- package/lib/components/Image/index.js.map +1 -1
- package/lib/components/Image/renderImage.js +7 -8
- package/lib/components/Image/renderImage.js.map +1 -1
- package/lib/components/Image/useImage.js +18 -18
- package/lib/components/Image/useImage.js.map +1 -1
- package/lib/components/Image/useImageStyles.js +39 -24
- package/lib/components/Image/useImageStyles.js.map +1 -1
- package/lib/index.js +1 -1
- package/lib/index.js.map +1 -1
- package/lib-commonjs/Image.js +1 -1
- package/lib-commonjs/Image.js.map +1 -1
- package/lib-commonjs/components/Image/Image.js +8 -8
- package/lib-commonjs/components/Image/Image.js.map +1 -1
- package/lib-commonjs/components/Image/Image.types.js.map +1 -1
- package/lib-commonjs/components/Image/index.js +1 -1
- package/lib-commonjs/components/Image/index.js.map +1 -1
- package/lib-commonjs/components/Image/renderImage.js +11 -14
- package/lib-commonjs/components/Image/renderImage.js.map +1 -1
- package/lib-commonjs/components/Image/useImage.js +22 -23
- package/lib-commonjs/components/Image/useImage.js.map +1 -1
- package/lib-commonjs/components/Image/useImageStyles.js +43 -26
- package/lib-commonjs/components/Image/useImageStyles.js.map +1 -1
- package/lib-commonjs/index.js +32 -2
- package/lib-commonjs/index.js.map +1 -1
- package/package.json +18 -23
- package/lib/Image.d.ts +0 -1
- package/lib/common/isConformant.d.ts +0 -4
- package/lib/common/isConformant.js +0 -13
- package/lib/common/isConformant.js.map +0 -1
- package/lib/components/Image/Image.d.ts +0 -6
- package/lib/components/Image/Image.types.d.ts +0 -29
- package/lib/components/Image/index.d.ts +0 -5
- package/lib/components/Image/renderImage.d.ts +0 -6
- package/lib/components/Image/useImage.d.ts +0 -7
- package/lib/components/Image/useImageStyles.d.ts +0 -2
- package/lib/index.d.ts +0 -1
- package/lib-commonjs/Image.d.ts +0 -1
- package/lib-commonjs/common/isConformant.d.ts +0 -4
- package/lib-commonjs/common/isConformant.js +0 -24
- package/lib-commonjs/common/isConformant.js.map +0 -1
- package/lib-commonjs/components/Image/Image.d.ts +0 -6
- package/lib-commonjs/components/Image/Image.types.d.ts +0 -29
- package/lib-commonjs/components/Image/index.d.ts +0 -5
- package/lib-commonjs/components/Image/renderImage.d.ts +0 -6
- package/lib-commonjs/components/Image/useImage.d.ts +0 -7
- package/lib-commonjs/components/Image/useImageStyles.d.ts +0 -2
- package/lib-commonjs/index.d.ts +0 -1
package/MIGRATION.md
ADDED
|
@@ -0,0 +1,235 @@
|
|
|
1
|
+
# Image Migration
|
|
2
|
+
|
|
3
|
+
## Introduction
|
|
4
|
+
|
|
5
|
+
This guide is a reference for upgrading the Image component from v8 (Fabric) or v0 (Northstar) to v9 (FluentUI vNext).
|
|
6
|
+
|
|
7
|
+
## Migration from v8 (Fabric)
|
|
8
|
+
|
|
9
|
+
### Property mapping
|
|
10
|
+
|
|
11
|
+
The table below presents a mapping of props between the v8 (FabricUI) and v9 (Fluent UI vNext) in order to clarify which properties require changes to achieve the same result.
|
|
12
|
+
|
|
13
|
+
> ⚠️ Note - Properties not in this table are considered deprecated.
|
|
14
|
+
|
|
15
|
+
| v7 / v8 | v9 | Good to go? |
|
|
16
|
+
| ----------------------- | ------- | ----------- |
|
|
17
|
+
| `className` | - | ✔️ |
|
|
18
|
+
| `coverStyle` | `fit` | ⚠️ |
|
|
19
|
+
| `imageFit` | `fit` | ✔️ |
|
|
20
|
+
| `maximizeFrame` | `block` | ✔️ |
|
|
21
|
+
| `loading` | - | ✔️ |
|
|
22
|
+
| `onLoadingStateChanged` | - | ❌ |
|
|
23
|
+
| `shouldFadeIn` | - | ❌ |
|
|
24
|
+
| `shouldStartVisible` | - | ❌ |
|
|
25
|
+
| `styles` | - | ❌ |
|
|
26
|
+
| `theme` | - | ❓ |
|
|
27
|
+
|
|
28
|
+
### className
|
|
29
|
+
|
|
30
|
+
_This property has not changed and can be left as is._
|
|
31
|
+
|
|
32
|
+
### coverStyle
|
|
33
|
+
|
|
34
|
+
The behaviour of this prop can be achieved using the `fit` prop with the value of `cover`.
|
|
35
|
+
|
|
36
|
+
```jsx
|
|
37
|
+
<Image src="example.jpg" fit="cover" />
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
### imageFit
|
|
41
|
+
|
|
42
|
+
This can be achieved using the `fit` prop by asigning the value of `contain`.
|
|
43
|
+
|
|
44
|
+
```jsx
|
|
45
|
+
<Image src="example.jpg" fit="contain" />
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
### maximizeFrame
|
|
49
|
+
|
|
50
|
+
This prop has been renamed to `block` which will result in the same behaviour as before.
|
|
51
|
+
|
|
52
|
+
```jsx
|
|
53
|
+
<Image src="example.jpg" block />
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
### loading
|
|
57
|
+
|
|
58
|
+
_This property has not changed and can be used as is._
|
|
59
|
+
|
|
60
|
+
### onLoadingStateChanged
|
|
61
|
+
|
|
62
|
+
For v9, this feature is no longer supported. The alternative would be to use the global events such as: `onLoad`, `onError` to detect the image loading state.
|
|
63
|
+
|
|
64
|
+
### shouldFadeIn
|
|
65
|
+
|
|
66
|
+
For v9, this feature is no longer supported. The alternative is to apply the animation through `make-styles` and using the global event `onLoad`. Below is an example of a migration:
|
|
67
|
+
|
|
68
|
+
```jsx
|
|
69
|
+
import { useState } from 'react';
|
|
70
|
+
import { Image } from '@fluentui/react-image';
|
|
71
|
+
import { makeStyles } from '@griffel/react';
|
|
72
|
+
|
|
73
|
+
const useStyles = makeStyles(theme => ({
|
|
74
|
+
fadeIn400: {
|
|
75
|
+
animationName: {
|
|
76
|
+
from : {
|
|
77
|
+
opacity: 0,
|
|
78
|
+
},
|
|
79
|
+
to: {
|
|
80
|
+
opacity: 1,
|
|
81
|
+
}
|
|
82
|
+
},
|
|
83
|
+
animationIterationCount: 'infinite',
|
|
84
|
+
animationDuration: '0.367s',
|
|
85
|
+
},
|
|
86
|
+
})
|
|
87
|
+
|
|
88
|
+
const MyComponent = () => {
|
|
89
|
+
const [isLoaded, setLoaded] = useState(false);
|
|
90
|
+
const styles = useStyles()
|
|
91
|
+
|
|
92
|
+
return <Image src="example.jpg" onLoad={()=> setLoaded(true)} className={!isLoaded? styles.fadeIn400 : ''} />
|
|
93
|
+
}
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
### shouldStartVisible
|
|
97
|
+
|
|
98
|
+
For v9, this feature is no longer supported. The alternative would be to use the global events such as: `onLoad` and `onError` to achieve the same behaviour. Below is an example showcasing this:
|
|
99
|
+
|
|
100
|
+
```jsx
|
|
101
|
+
import { useState } from 'react';
|
|
102
|
+
import { makeStyles } from '@griffel/react';
|
|
103
|
+
import { Image } from '@fluentui/react-image';
|
|
104
|
+
|
|
105
|
+
const useStyles = makeStyles({
|
|
106
|
+
root: {
|
|
107
|
+
display: 'none',
|
|
108
|
+
},
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
export default function App() {
|
|
112
|
+
const [isLoaded, setLoaded] = useState(null);
|
|
113
|
+
|
|
114
|
+
const styles = useStyles();
|
|
115
|
+
|
|
116
|
+
return (
|
|
117
|
+
<Image
|
|
118
|
+
src="https://via.placeholder.com/300x300"
|
|
119
|
+
alt="Example image"
|
|
120
|
+
onLoad={() => setLoaded(true)}
|
|
121
|
+
onError={() => setLoaded(false)}
|
|
122
|
+
className={isLoaded === false ? styles.root : ''}
|
|
123
|
+
/>
|
|
124
|
+
);
|
|
125
|
+
}
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
### styles
|
|
129
|
+
|
|
130
|
+
_This property has not changed and can be used as is. However, we highly recommend that you migrate to a `make-styles` styling solution for performance reasons._
|
|
131
|
+
|
|
132
|
+
### theme
|
|
133
|
+
|
|
134
|
+
_This property has not changed and can be used as is. However, we highly recommend that you migrate to a `make-styles` styling solution for performance reasons._
|
|
135
|
+
|
|
136
|
+
## Migration from v0 (Northstar)
|
|
137
|
+
|
|
138
|
+
### Property mapping
|
|
139
|
+
|
|
140
|
+
The table below presents a mapping of props between the v0 and v9 versions in order to make it clear which properties require changes to achieve the same result.
|
|
141
|
+
|
|
142
|
+
| v0 | v9 | Good to go? |
|
|
143
|
+
| --------------- | ------------------ | ----------- |
|
|
144
|
+
| `accessibility` | - | ❌ |
|
|
145
|
+
| `alt` | - | ✔️ |
|
|
146
|
+
| `aria-label` | - | ✔️ |
|
|
147
|
+
| `as` | - | ❌ |
|
|
148
|
+
| `avatar` | `shape="circular"` | ✔️ |
|
|
149
|
+
| `circular` | `shape="circular"` | ✔️ |
|
|
150
|
+
| `className` | - | ✔️ |
|
|
151
|
+
| `fluid` | `block` | ✔️ |
|
|
152
|
+
| `styles` | - | ❌ |
|
|
153
|
+
| `variables` | - | ❌ |
|
|
154
|
+
|
|
155
|
+
### accessibility
|
|
156
|
+
|
|
157
|
+
For v9, this property is no longer supported. It is recommended to follow the best practices of a11y in order for Image to be accessible to assistive tools. Thus:
|
|
158
|
+
|
|
159
|
+
- It is important for Image to have the `alt` description.
|
|
160
|
+
- In case the Image is decorative only, have either `role="presentation"` or `aria-hidden`. Ensure the correct usage of these two attributes, based on your objectives.
|
|
161
|
+
|
|
162
|
+
### alt
|
|
163
|
+
|
|
164
|
+
_This property has not changed and can be left as is._
|
|
165
|
+
|
|
166
|
+
### aria-label
|
|
167
|
+
|
|
168
|
+
_This property has not changed and can be left as is._
|
|
169
|
+
|
|
170
|
+
### as
|
|
171
|
+
|
|
172
|
+
For v9, this property is no longer supported. The Image prop will always be an `<img/>` element, it is not possible to show an image as any other element.
|
|
173
|
+
|
|
174
|
+
### avatar
|
|
175
|
+
|
|
176
|
+
This can be achieved using the `shape` prop with the value of `circular`.
|
|
177
|
+
|
|
178
|
+
```jsx
|
|
179
|
+
<Image src="example.jpg" shape="circular" />
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
### circular
|
|
183
|
+
|
|
184
|
+
This can be achieved using the `shape` prop with the value of `circular`.
|
|
185
|
+
|
|
186
|
+
```jsx
|
|
187
|
+
<Image src="example.jpg" shape="circular" />
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
### className
|
|
191
|
+
|
|
192
|
+
_This property has not changed and can be left as is._
|
|
193
|
+
|
|
194
|
+
### fluid
|
|
195
|
+
|
|
196
|
+
This prop has been renamed to `block` which will result into the same behaviour as before.
|
|
197
|
+
|
|
198
|
+
```jsx
|
|
199
|
+
<Image src="example.jpg" block />
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
### styles
|
|
203
|
+
|
|
204
|
+
_This property has not changed and can be used as is. However, we highly recommend that you migrate to a `make-styles` styling solution for performance reasons._
|
|
205
|
+
|
|
206
|
+
### variables
|
|
207
|
+
|
|
208
|
+
For v9, this feature is no longer supported. The alternative is to apply styles through `make-styles`. Below is an example of a migration:
|
|
209
|
+
|
|
210
|
+
#### v0 (Northstar) implementation
|
|
211
|
+
|
|
212
|
+
```jsx
|
|
213
|
+
const MyComponent = () => {
|
|
214
|
+
return <Image src="example.jpg" variables={{ width: '100px' }} />;
|
|
215
|
+
};
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
#### v9 (Fluent UI vNext) implementation
|
|
219
|
+
|
|
220
|
+
```jsx
|
|
221
|
+
import { Image } from '@fluentui/react-image';
|
|
222
|
+
import { makeStyles } from '@griffel/react';
|
|
223
|
+
|
|
224
|
+
const useStyles = makeStyles(theme => ({
|
|
225
|
+
width100: {
|
|
226
|
+
width: '100px'
|
|
227
|
+
},
|
|
228
|
+
})
|
|
229
|
+
|
|
230
|
+
const MyComponent = () => {
|
|
231
|
+
const styles = useStyles()
|
|
232
|
+
|
|
233
|
+
return <Image src="example.jpg" className={styles.width100} />
|
|
234
|
+
}
|
|
235
|
+
```
|
package/README.md
CHANGED
|
@@ -51,3 +51,7 @@ The DOM structure will result into:
|
|
|
51
51
|
Image component is build upon the `<img/>` tag, which does support all the native attributes. Additionaly, the following properties are available: `bordered`, `fit`, `block`, `shape` and `shadow`.
|
|
52
52
|
|
|
53
53
|
For more information on the component, please refer to the [API documentation](https://aka.ms/fluentui-storybook).
|
|
54
|
+
|
|
55
|
+
## Migration
|
|
56
|
+
|
|
57
|
+
For migrating from older versions of FluentUI, please check out the [migration guide](./MIGRATION.md)
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import type { ComponentProps } from '@fluentui/react-utilities';
|
|
2
2
|
import type { ComponentState } from '@fluentui/react-utilities';
|
|
3
3
|
import type { ForwardRefComponent } from '@fluentui/react-utilities';
|
|
4
|
-
import type { IntrinsicShorthandProps } from '@fluentui/react-utilities';
|
|
5
4
|
import * as React_2 from 'react';
|
|
5
|
+
import type { Slot } from '@fluentui/react-utilities';
|
|
6
|
+
import type { SlotClassNames } from '@fluentui/react-utilities';
|
|
6
7
|
|
|
7
8
|
/**
|
|
8
9
|
* The Image component ensures the consistent styling of images.
|
|
@@ -10,51 +11,58 @@ import * as React_2 from 'react';
|
|
|
10
11
|
declare const Image_2: ForwardRefComponent<ImageProps>;
|
|
11
12
|
export { Image_2 as Image }
|
|
12
13
|
|
|
13
|
-
export declare
|
|
14
|
+
export declare const imageClassNames: SlotClassNames<ImageSlots>;
|
|
15
|
+
|
|
16
|
+
export declare type ImageProps = ComponentProps<ImageSlots> & {
|
|
17
|
+
/**
|
|
18
|
+
* An image can take up the width of its container.
|
|
19
|
+
*
|
|
20
|
+
* @default false
|
|
21
|
+
*/
|
|
22
|
+
block?: boolean;
|
|
14
23
|
/**
|
|
15
|
-
* An image can appear with rectangular border.
|
|
24
|
+
* An image can appear with a rectangular border.
|
|
25
|
+
*
|
|
26
|
+
* @default false
|
|
16
27
|
*/
|
|
17
28
|
bordered?: boolean;
|
|
18
29
|
/**
|
|
19
30
|
* An image can set how it should be resized to fit its container.
|
|
31
|
+
*
|
|
32
|
+
* @default 'default'
|
|
20
33
|
*/
|
|
21
|
-
fit?: 'none' | 'center' | 'contain' | 'cover';
|
|
34
|
+
fit?: 'none' | 'center' | 'contain' | 'cover' | 'default';
|
|
22
35
|
/**
|
|
23
|
-
* An image can
|
|
36
|
+
* An image can appear elevated with shadow.
|
|
37
|
+
*
|
|
38
|
+
* @default false
|
|
24
39
|
*/
|
|
25
|
-
|
|
40
|
+
shadow?: boolean;
|
|
26
41
|
/**
|
|
27
42
|
* An image can appear square, circular, or rounded.
|
|
28
|
-
*
|
|
43
|
+
*
|
|
44
|
+
* @default 'square'
|
|
29
45
|
*/
|
|
30
46
|
shape?: 'square' | 'circular' | 'rounded';
|
|
31
|
-
/**
|
|
32
|
-
* An image can appear elevated with shadow.
|
|
33
|
-
*/
|
|
34
|
-
shadow?: boolean;
|
|
35
47
|
};
|
|
36
48
|
|
|
37
|
-
export declare type ImageProps = ComponentProps<ImageSlots> & Partial<ImageCommons>;
|
|
38
|
-
|
|
39
|
-
export declare const imageShorthandProps: Array<keyof ImageSlots>;
|
|
40
|
-
|
|
41
49
|
export declare type ImageSlots = {
|
|
42
|
-
root:
|
|
50
|
+
root: Slot<'img'>;
|
|
43
51
|
};
|
|
44
52
|
|
|
45
|
-
export declare type ImageState = ComponentState<ImageSlots> &
|
|
53
|
+
export declare type ImageState = ComponentState<ImageSlots> & Required<Pick<ImageProps, 'block' | 'bordered' | 'fit' | 'shadow' | 'shape'>>;
|
|
46
54
|
|
|
47
55
|
/**
|
|
48
56
|
* Define the render function.
|
|
49
57
|
* Given the state of an image, renders it.
|
|
50
58
|
*/
|
|
51
|
-
export declare const
|
|
59
|
+
export declare const renderImage_unstable: (state: ImageState) => JSX.Element;
|
|
52
60
|
|
|
53
61
|
/**
|
|
54
62
|
* Given user props, returns state and render function for an Image.
|
|
55
63
|
*/
|
|
56
|
-
export declare const
|
|
64
|
+
export declare const useImage_unstable: (props: ImageProps, ref: React_2.Ref<HTMLImageElement>) => ImageState;
|
|
57
65
|
|
|
58
|
-
export declare const
|
|
66
|
+
export declare const useImageStyles_unstable: (state: ImageState) => void;
|
|
59
67
|
|
|
60
68
|
export { }
|
|
File without changes
|
package/lib/Image.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Image.js","sourceRoot":"","sources":["
|
|
1
|
+
{"version":3,"file":"Image.js","sourceRoot":"../src/","sources":["Image.ts"],"names":[],"mappings":"AAAA,cAAc,0BAA0B,CAAC","sourcesContent":["export * from './components/Image/index';\n"]}
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
2
|
+
import { renderImage_unstable } from './renderImage';
|
|
3
|
+
import { useImage_unstable } from './useImage';
|
|
4
|
+
import { useImageStyles_unstable } from './useImageStyles';
|
|
5
5
|
/**
|
|
6
6
|
* The Image component ensures the consistent styling of images.
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
-
export
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
return
|
|
9
|
+
export const Image = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
10
|
+
const state = useImage_unstable(props, ref);
|
|
11
|
+
useImageStyles_unstable(state);
|
|
12
|
+
return renderImage_unstable(state);
|
|
13
13
|
});
|
|
14
14
|
Image.displayName = 'Image';
|
|
15
15
|
//# sourceMappingURL=Image.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["
|
|
1
|
+
{"version":3,"sources":["components/Image/Image.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAZ,MAAuB,OAAvB;AACA,SAAS,oBAAT,QAAqC,eAArC;AACA,SAAS,iBAAT,QAAkC,YAAlC;AACA,SAAS,uBAAT,QAAwC,kBAAxC;AAIA;;AAEG;;AACH,OAAO,MAAM,KAAK,gBAAoC,KAAK,CAAC,UAAN,CAAiB,CAAC,KAAD,EAAQ,GAAR,KAAe;AACpF,QAAM,KAAK,GAAG,iBAAiB,CAAC,KAAD,EAAQ,GAAR,CAA/B;AACA,EAAA,uBAAuB,CAAC,KAAD,CAAvB;AAEA,SAAO,oBAAoB,CAAC,KAAD,CAA3B;AACD,CALqD,CAA/C;AAOP,KAAK,CAAC,WAAN,GAAoB,OAApB","sourcesContent":["import * as React from 'react';\nimport { renderImage_unstable } from './renderImage';\nimport { useImage_unstable } from './useImage';\nimport { useImageStyles_unstable } from './useImageStyles';\nimport type { ImageProps } from './Image.types';\nimport type { ForwardRefComponent } from '@fluentui/react-utilities';\n\n/**\n * The Image component ensures the consistent styling of images.\n */\nexport const Image: ForwardRefComponent<ImageProps> = React.forwardRef((props, ref) => {\n const state = useImage_unstable(props, ref);\n useImageStyles_unstable(state);\n\n return renderImage_unstable(state);\n});\n\nImage.displayName = 'Image';\n"],"sourceRoot":"../src/"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Image.types.js","sourceRoot":"","sources":["
|
|
1
|
+
{"version":3,"file":"Image.types.js","sourceRoot":"../src/","sources":["components/Image/Image.types.ts"],"names":[],"mappings":"","sourcesContent":["import type { ComponentState, ComponentProps, Slot } from '@fluentui/react-utilities';\n\nexport type ImageSlots = {\n root: Slot<'img'>;\n};\n\nexport type ImageProps = ComponentProps<ImageSlots> & {\n /**\n * An image can take up the width of its container.\n *\n * @default false\n */\n block?: boolean;\n\n /**\n * An image can appear with a rectangular border.\n *\n * @default false\n */\n bordered?: boolean;\n\n /**\n * An image can set how it should be resized to fit its container.\n *\n * @default 'default'\n */\n fit?: 'none' | 'center' | 'contain' | 'cover' | 'default';\n\n /**\n * An image can appear elevated with shadow.\n *\n * @default false\n */\n shadow?: boolean;\n\n /**\n * An image can appear square, circular, or rounded.\n *\n * @default 'square'\n */\n shape?: 'square' | 'circular' | 'rounded';\n};\n\nexport type ImageState = ComponentState<ImageSlots> &\n Required<Pick<ImageProps, 'block' | 'bordered' | 'fit' | 'shadow' | 'shape'>>;\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"../src/","sources":["components/Image/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAC9B,cAAc,SAAS,CAAC;AACxB,cAAc,eAAe,CAAC;AAC9B,cAAc,YAAY,CAAC;AAC3B,cAAc,kBAAkB,CAAC","sourcesContent":["export * from './Image.types';\nexport * from './Image';\nexport * from './renderImage';\nexport * from './useImage';\nexport * from './useImageStyles';\n"]}
|
|
@@ -1,17 +1,16 @@
|
|
|
1
|
-
import { __assign } from "tslib";
|
|
2
1
|
import * as React from 'react';
|
|
3
2
|
import { getSlots } from '@fluentui/react-utilities';
|
|
4
|
-
import { imageShorthandProps } from './useImage';
|
|
5
3
|
/**
|
|
6
4
|
* Define the render function.
|
|
7
5
|
* Given the state of an image, renders it.
|
|
8
6
|
*/
|
|
9
7
|
|
|
10
|
-
export
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
return /*#__PURE__*/React.createElement(slots.root,
|
|
8
|
+
export const renderImage_unstable = state => {
|
|
9
|
+
const {
|
|
10
|
+
slots,
|
|
11
|
+
slotProps
|
|
12
|
+
} = getSlots(state);
|
|
13
|
+
return /*#__PURE__*/React.createElement(slots.root, { ...slotProps.root
|
|
14
|
+
});
|
|
16
15
|
};
|
|
17
16
|
//# sourceMappingURL=renderImage.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["
|
|
1
|
+
{"version":3,"sources":["components/Image/renderImage.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAZ,MAAuB,OAAvB;AACA,SAAS,QAAT,QAAyB,2BAAzB;AAGA;;;AAGG;;AACH,OAAO,MAAM,oBAAoB,GAAI,KAAD,IAAsB;AACxD,QAAM;AAAE,IAAA,KAAF;AAAS,IAAA;AAAT,MAAuB,QAAQ,CAAa,KAAb,CAArC;AAEA,sBAAO,KAAA,CAAA,aAAA,CAAC,KAAK,CAAC,IAAP,EAAW,EAAA,GAAK,SAAS,CAAC;AAAf,GAAX,CAAP;AACD,CAJM","sourcesContent":["import * as React from 'react';\nimport { getSlots } from '@fluentui/react-utilities';\nimport { ImageSlots, ImageState } from './Image.types';\n\n/**\n * Define the render function.\n * Given the state of an image, renders it.\n */\nexport const renderImage_unstable = (state: ImageState) => {\n const { slots, slotProps } = getSlots<ImageSlots>(state);\n\n return <slots.root {...slotProps.root} />;\n};\n"],"sourceRoot":"../src/"}
|
|
@@ -1,29 +1,29 @@
|
|
|
1
|
-
import { __assign } from "tslib";
|
|
2
1
|
import { getNativeElementProps } from '@fluentui/react-utilities';
|
|
3
|
-
export var imageShorthandProps = ['root'];
|
|
4
2
|
/**
|
|
5
3
|
* Given user props, returns state and render function for an Image.
|
|
6
4
|
*/
|
|
7
5
|
|
|
8
|
-
export
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
6
|
+
export const useImage_unstable = (props, ref) => {
|
|
7
|
+
const {
|
|
8
|
+
bordered = false,
|
|
9
|
+
fit = 'default',
|
|
10
|
+
block = false,
|
|
11
|
+
shape = 'square',
|
|
12
|
+
shadow = false
|
|
13
|
+
} = props;
|
|
14
|
+
const state = {
|
|
15
|
+
bordered,
|
|
16
|
+
fit,
|
|
17
|
+
block,
|
|
18
|
+
shape,
|
|
19
|
+
shadow,
|
|
21
20
|
components: {
|
|
22
21
|
root: 'img'
|
|
23
22
|
},
|
|
24
|
-
root: getNativeElementProps('img',
|
|
25
|
-
ref
|
|
26
|
-
|
|
23
|
+
root: getNativeElementProps('img', {
|
|
24
|
+
ref,
|
|
25
|
+
...props
|
|
26
|
+
})
|
|
27
27
|
};
|
|
28
28
|
return state;
|
|
29
29
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["
|
|
1
|
+
{"version":3,"sources":["components/Image/useImage.ts"],"names":[],"mappings":"AACA,SAAS,qBAAT,QAAsC,2BAAtC;AAGA;;AAEG;;AACH,OAAO,MAAM,iBAAiB,GAAG,CAAC,KAAD,EAAoB,GAApB,KAAoE;AACnG,QAAM;AAAE,IAAA,QAAQ,GAAG,KAAb;AAAoB,IAAA,GAAG,GAAG,SAA1B;AAAqC,IAAA,KAAK,GAAG,KAA7C;AAAoD,IAAA,KAAK,GAAG,QAA5D;AAAsE,IAAA,MAAM,GAAG;AAA/E,MAAyF,KAA/F;AAEA,QAAM,KAAK,GAAe;AACxB,IAAA,QADwB;AAExB,IAAA,GAFwB;AAGxB,IAAA,KAHwB;AAIxB,IAAA,KAJwB;AAKxB,IAAA,MALwB;AAMxB,IAAA,UAAU,EAAE;AACV,MAAA,IAAI,EAAE;AADI,KANY;AASxB,IAAA,IAAI,EAAE,qBAAqB,CAAC,KAAD,EAAQ;AACjC,MAAA,GADiC;AAEjC,SAAG;AAF8B,KAAR;AATH,GAA1B;AAeA,SAAO,KAAP;AACD,CAnBM","sourcesContent":["import * as React from 'react';\nimport { getNativeElementProps } from '@fluentui/react-utilities';\nimport type { ImageProps, ImageState } from './Image.types';\n\n/**\n * Given user props, returns state and render function for an Image.\n */\nexport const useImage_unstable = (props: ImageProps, ref: React.Ref<HTMLImageElement>): ImageState => {\n const { bordered = false, fit = 'default', block = false, shape = 'square', shadow = false } = props;\n\n const state: ImageState = {\n bordered,\n fit,\n block,\n shape,\n shadow,\n components: {\n root: 'img',\n },\n root: getNativeElementProps('img', {\n ref,\n ...props,\n }),\n };\n\n return state;\n};\n"],"sourceRoot":"../src/"}
|
|
@@ -1,16 +1,23 @@
|
|
|
1
|
-
import { mergeClasses, __styles } from '@
|
|
1
|
+
import { shorthands, mergeClasses, __styles } from '@griffel/react';
|
|
2
|
+
import { tokens } from '@fluentui/react-theme';
|
|
3
|
+
export const imageClassNames = {
|
|
4
|
+
root: 'fui-Image'
|
|
5
|
+
};
|
|
2
6
|
|
|
3
|
-
|
|
4
|
-
"
|
|
7
|
+
const useStyles = /*#__PURE__*/__styles({
|
|
8
|
+
"base": {
|
|
5
9
|
"g2u3we": "fj3muxo",
|
|
6
10
|
"h3c5rm": ["f1akhkt", "f1lxtadh"],
|
|
7
11
|
"B9xav0g": "f1aperda",
|
|
8
12
|
"zhjwy3": ["f1lxtadh", "f1akhkt"],
|
|
9
|
-
"
|
|
13
|
+
"Bbmb7ep": ["fzi6hpg", "fyowgf4"],
|
|
14
|
+
"Beyfa6y": ["fyowgf4", "fzi6hpg"],
|
|
15
|
+
"B7oj6ja": ["f3fg2lr", "f13av6d4"],
|
|
16
|
+
"Btl43ni": ["f13av6d4", "f3fg2lr"],
|
|
10
17
|
"B7ck84d": "f1ewtqcl",
|
|
11
18
|
"mc9l5x": "f14t3ns0"
|
|
12
19
|
},
|
|
13
|
-
"
|
|
20
|
+
"bordered": {
|
|
14
21
|
"icvyot": "fzkkow9",
|
|
15
22
|
"vrafjx": ["fcdblym", "fjik90z"],
|
|
16
23
|
"oivjwe": "fg706s2",
|
|
@@ -20,48 +27,56 @@ var useStyles = /*#__PURE__*/__styles({
|
|
|
20
27
|
"Bn0qgzm": "f1vxd6vx",
|
|
21
28
|
"ibv6hh": ["f1ojsxk5", "f5tn483"]
|
|
22
29
|
},
|
|
23
|
-
"
|
|
24
|
-
"
|
|
30
|
+
"circular": {
|
|
31
|
+
"Bbmb7ep": ["f8fbkgy", "f1nfllo7"],
|
|
32
|
+
"Beyfa6y": ["f1nfllo7", "f8fbkgy"],
|
|
33
|
+
"B7oj6ja": ["f1djnp8u", "f1s8kh49"],
|
|
34
|
+
"Btl43ni": ["f1s8kh49", "f1djnp8u"]
|
|
25
35
|
},
|
|
26
|
-
"
|
|
27
|
-
"
|
|
36
|
+
"rounded": {
|
|
37
|
+
"Bbmb7ep": ["f1aa9q02", "f16jpd5f"],
|
|
38
|
+
"Beyfa6y": ["f16jpd5f", "f1aa9q02"],
|
|
39
|
+
"B7oj6ja": ["f1jar5jt", "fyu767a"],
|
|
40
|
+
"Btl43ni": ["fyu767a", "f1jar5jt"]
|
|
28
41
|
},
|
|
29
|
-
"
|
|
30
|
-
|
|
42
|
+
"square": {},
|
|
43
|
+
"shadow": {
|
|
44
|
+
"E5pizo": "f1whvlc6"
|
|
31
45
|
},
|
|
32
|
-
"
|
|
46
|
+
"center": {
|
|
33
47
|
"st4lth": "f1plgu50",
|
|
34
|
-
"Ermj5k":
|
|
48
|
+
"Ermj5k": "f14xojzb",
|
|
35
49
|
"Bqenvij": "f1l02sjl",
|
|
36
50
|
"a9b677": "fly5x3f"
|
|
37
51
|
},
|
|
38
|
-
"
|
|
39
|
-
"st4lth": "
|
|
52
|
+
"contain": {
|
|
53
|
+
"st4lth": "f1kle4es",
|
|
40
54
|
"Ermj5k": "f14xojzb",
|
|
41
55
|
"Bqenvij": "f1l02sjl",
|
|
42
56
|
"a9b677": "fly5x3f"
|
|
43
57
|
},
|
|
44
|
-
"
|
|
58
|
+
"default": {},
|
|
59
|
+
"cover": {
|
|
45
60
|
"st4lth": "f1ps3kmd",
|
|
46
61
|
"Ermj5k": "f14xojzb",
|
|
47
62
|
"Bqenvij": "f1l02sjl",
|
|
48
63
|
"a9b677": "fly5x3f"
|
|
49
64
|
},
|
|
50
|
-
"
|
|
51
|
-
"st4lth": "
|
|
52
|
-
"Ermj5k": "
|
|
65
|
+
"none": {
|
|
66
|
+
"st4lth": "f1plgu50",
|
|
67
|
+
"Ermj5k": ["f13uwng7", "fjmyj0p"],
|
|
53
68
|
"Bqenvij": "f1l02sjl",
|
|
54
69
|
"a9b677": "fly5x3f"
|
|
55
70
|
},
|
|
56
|
-
"
|
|
71
|
+
"block": {
|
|
57
72
|
"a9b677": "fly5x3f"
|
|
58
73
|
}
|
|
59
74
|
}, {
|
|
60
|
-
"d": [".fj3muxo{border-top-color:var(--colorNeutralStroke1);}", ".f1akhkt{border-right-color:var(--colorNeutralStroke1);}", ".f1lxtadh{border-left-color:var(--colorNeutralStroke1);}", ".f1aperda{border-bottom-color:var(--colorNeutralStroke1);}", ".
|
|
75
|
+
"d": [".fj3muxo{border-top-color:var(--colorNeutralStroke1);}", ".f1akhkt{border-right-color:var(--colorNeutralStroke1);}", ".f1lxtadh{border-left-color:var(--colorNeutralStroke1);}", ".f1aperda{border-bottom-color:var(--colorNeutralStroke1);}", ".fzi6hpg{border-bottom-right-radius:var(--borderRadiusNone);}", ".fyowgf4{border-bottom-left-radius:var(--borderRadiusNone);}", ".f3fg2lr{border-top-right-radius:var(--borderRadiusNone);}", ".f13av6d4{border-top-left-radius:var(--borderRadiusNone);}", ".f1ewtqcl{box-sizing:border-box;}", ".f14t3ns0{display:inline-block;}", ".fzkkow9{border-top-style:solid;}", ".fcdblym{border-right-style:solid;}", ".fjik90z{border-left-style:solid;}", ".fg706s2{border-bottom-style:solid;}", ".f192inf7{border-top-width:var(--strokeWidthThin);}", ".f5tn483{border-right-width:var(--strokeWidthThin);}", ".f1ojsxk5{border-left-width:var(--strokeWidthThin);}", ".f1vxd6vx{border-bottom-width:var(--strokeWidthThin);}", ".f8fbkgy{border-bottom-right-radius:var(--borderRadiusCircular);}", ".f1nfllo7{border-bottom-left-radius:var(--borderRadiusCircular);}", ".f1djnp8u{border-top-right-radius:var(--borderRadiusCircular);}", ".f1s8kh49{border-top-left-radius:var(--borderRadiusCircular);}", ".f1aa9q02{border-bottom-right-radius:var(--borderRadiusMedium);}", ".f16jpd5f{border-bottom-left-radius:var(--borderRadiusMedium);}", ".f1jar5jt{border-top-right-radius:var(--borderRadiusMedium);}", ".fyu767a{border-top-left-radius:var(--borderRadiusMedium);}", ".f1whvlc6{box-shadow:var(--shadow4);}", ".f1plgu50{object-fit:none;}", ".f14xojzb{object-position:center;}", ".f1l02sjl{height:100%;}", ".fly5x3f{width:100%;}", ".f1kle4es{object-fit:contain;}", ".f1ps3kmd{object-fit:cover;}", ".f13uwng7{object-position:left top;}", ".fjmyj0p{object-position:right top;}"]
|
|
61
76
|
});
|
|
62
77
|
|
|
63
|
-
export
|
|
64
|
-
|
|
65
|
-
state.root.className = mergeClasses(
|
|
78
|
+
export const useImageStyles_unstable = state => {
|
|
79
|
+
const styles = useStyles();
|
|
80
|
+
state.root.className = mergeClasses(imageClassNames.root, styles.base, state.block && styles.block, state.bordered && styles.bordered, state.shadow && styles.shadow, styles[state.fit], styles[state.shape], state.root.className);
|
|
66
81
|
};
|
|
67
82
|
//# sourceMappingURL=useImageStyles.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["
|
|
1
|
+
{"version":3,"sources":["components/Image/useImageStyles.ts"],"names":[],"mappings":"AAAA,SAAS,UAAT,EAAqB,YAArB,kBAAqD,gBAArD;AACA,SAAS,MAAT,QAAuB,uBAAvB;AAIA,OAAO,MAAM,eAAe,GAA+B;AACzD,EAAA,IAAI,EAAE;AADmD,CAApD;;AAIP,MAAM,SAAS,gBAAG;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAAlB;;AAmEA,OAAO,MAAM,uBAAuB,GAAI,KAAD,IAAsB;AAC3D,QAAM,MAAM,GAAG,SAAS,EAAxB;AACA,EAAA,KAAK,CAAC,IAAN,CAAW,SAAX,GAAuB,YAAY,CACjC,eAAe,CAAC,IADiB,EAEjC,MAAM,CAAC,IAF0B,EAGjC,KAAK,CAAC,KAAN,IAAe,MAAM,CAAC,KAHW,EAIjC,KAAK,CAAC,QAAN,IAAkB,MAAM,CAAC,QAJQ,EAKjC,KAAK,CAAC,MAAN,IAAgB,MAAM,CAAC,MALU,EAMjC,MAAM,CAAC,KAAK,CAAC,GAAP,CAN2B,EAOjC,MAAM,CAAC,KAAK,CAAC,KAAP,CAP2B,EAQjC,KAAK,CAAC,IAAN,CAAW,SARsB,CAAnC;AAUD,CAZM","sourcesContent":["import { shorthands, mergeClasses, makeStyles } from '@griffel/react';\nimport { tokens } from '@fluentui/react-theme';\nimport type { ImageSlots, ImageState } from './Image.types';\nimport type { SlotClassNames } from '@fluentui/react-utilities';\n\nexport const imageClassNames: SlotClassNames<ImageSlots> = {\n root: 'fui-Image',\n};\n\nconst useStyles = makeStyles({\n // Base styles\n base: {\n ...shorthands.borderColor(tokens.colorNeutralStroke1),\n ...shorthands.borderRadius(tokens.borderRadiusNone),\n\n boxSizing: 'border-box',\n display: 'inline-block',\n },\n\n // Bordered styles\n bordered: {\n ...shorthands.borderStyle('solid'),\n ...shorthands.borderWidth(tokens.strokeWidthThin),\n },\n\n // Shape variations\n circular: {\n ...shorthands.borderRadius(tokens.borderRadiusCircular),\n },\n rounded: {\n ...shorthands.borderRadius(tokens.borderRadiusMedium),\n },\n square: {\n /* The square styles are exactly the same as the base styles. */\n },\n\n // Shadow styles\n shadow: {\n boxShadow: tokens.shadow4,\n },\n\n // Fit variations\n center: {\n objectFit: 'none',\n objectPosition: 'center',\n height: '100%',\n width: '100%',\n },\n contain: {\n objectFit: 'contain',\n objectPosition: 'center',\n height: '100%',\n width: '100%',\n },\n default: {\n /* The default styles are exactly the same as the base styles. */\n },\n cover: {\n objectFit: 'cover',\n objectPosition: 'center',\n height: '100%',\n width: '100%',\n },\n none: {\n objectFit: 'none',\n objectPosition: 'left top',\n height: '100%',\n width: '100%',\n },\n\n // Block styles\n block: {\n width: '100%',\n },\n});\n\nexport const useImageStyles_unstable = (state: ImageState) => {\n const styles = useStyles();\n state.root.className = mergeClasses(\n imageClassNames.root,\n styles.base,\n state.block && styles.block,\n state.bordered && styles.bordered,\n state.shadow && styles.shadow,\n styles[state.fit],\n styles[state.shape],\n state.root.className,\n );\n};\n"],"sourceRoot":"../src/"}
|
package/lib/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export
|
|
1
|
+
export { Image, imageClassNames, renderImage_unstable, useImageStyles_unstable, useImage_unstable } from './Image';
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"../src/","sources":["index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,eAAe,EAAE,oBAAoB,EAAE,uBAAuB,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC","sourcesContent":["export { Image, imageClassNames, renderImage_unstable, useImageStyles_unstable, useImage_unstable } from './Image';\nexport type { ImageProps, ImageSlots, ImageState } from './Image';\n"]}
|
package/lib-commonjs/Image.js
CHANGED
|
@@ -4,7 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
const tslib_1 = /*#__PURE__*/require("tslib");
|
|
8
8
|
|
|
9
9
|
tslib_1.__exportStar(require("./components/Image/index"), exports);
|
|
10
10
|
//# sourceMappingURL=Image.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["
|
|
1
|
+
{"version":3,"sources":["Image.ts"],"names":[],"mappings":";;;;;;;;AAAA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,0BAAA,CAAA,EAAA,OAAA","sourcesContent":["export * from './components/Image/index';\n"],"sourceRoot":"../src/"}
|