@fluentui/react-image 9.0.0-alpha.9 → 9.0.0-alpha.90
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 +2081 -1
- package/CHANGELOG.md +814 -2
- package/README.md +42 -4
- package/Spec.md +173 -0
- package/dist/react-image.d.ts +28 -24
- package/lib/Image.js.map +1 -1
- package/lib/common/isConformant.d.ts +4 -0
- package/lib/common/isConformant.js +13 -0
- package/lib/common/isConformant.js.map +1 -0
- package/lib/components/Image/Image.d.ts +6 -3
- package/lib/components/Image/Image.js +8 -4
- package/lib/components/Image/Image.js.map +1 -1
- package/lib/components/Image/Image.types.d.ts +14 -20
- package/lib/components/Image/Image.types.js +1 -0
- package/lib/components/Image/Image.types.js.map +1 -1
- package/lib/components/Image/index.js +1 -0
- package/lib/components/Image/index.js.map +1 -1
- package/lib/components/Image/renderImage.js +7 -2
- package/lib/components/Image/renderImage.js.map +1 -1
- package/lib/components/Image/useImage.d.ts +3 -2
- package/lib/components/Image/useImage.js +25 -26
- package/lib/components/Image/useImage.js.map +1 -1
- package/lib/components/Image/useImageStyles.d.ts +1 -2
- package/lib/components/Image/useImageStyles.js +64 -76
- package/lib/components/Image/useImageStyles.js.map +1 -1
- package/lib/index.js.map +1 -1
- package/lib/tsdoc-metadata.json +1 -1
- package/lib-commonjs/Image.js +7 -2
- package/lib-commonjs/Image.js.map +1 -1
- package/lib-commonjs/common/isConformant.d.ts +4 -0
- package/lib-commonjs/common/isConformant.js +24 -0
- package/lib-commonjs/common/isConformant.js.map +1 -0
- package/lib-commonjs/components/Image/Image.d.ts +6 -3
- package/lib-commonjs/components/Image/Image.js +22 -9
- package/lib-commonjs/components/Image/Image.js.map +1 -1
- package/lib-commonjs/components/Image/Image.types.d.ts +14 -20
- package/lib-commonjs/components/Image/Image.types.js +4 -1
- package/lib-commonjs/components/Image/Image.types.js.map +1 -1
- package/lib-commonjs/components/Image/index.js +12 -2
- package/lib-commonjs/components/Image/index.js.map +1 -1
- package/lib-commonjs/components/Image/renderImage.js +23 -7
- package/lib-commonjs/components/Image/renderImage.js.map +1 -1
- package/lib-commonjs/components/Image/useImage.d.ts +3 -2
- package/lib-commonjs/components/Image/useImage.js +35 -27
- package/lib-commonjs/components/Image/useImage.js.map +1 -1
- package/lib-commonjs/components/Image/useImageStyles.d.ts +1 -2
- package/lib-commonjs/components/Image/useImageStyles.js +73 -78
- package/lib-commonjs/components/Image/useImageStyles.js.map +1 -1
- package/lib-commonjs/index.js +7 -2
- package/lib-commonjs/index.js.map +1 -1
- package/package.json +16 -17
- package/config/api-extractor.json +0 -3
- package/config/tests.js +0 -6
- package/etc/react-image.api.md +0 -45
- package/just.config.ts +0 -3
- package/lib-amd/Image.d.ts +0 -1
- package/lib-amd/Image.js +0 -6
- package/lib-amd/Image.js.map +0 -1
- package/lib-amd/components/Image/Image.d.ts +0 -3
- package/lib-amd/components/Image/Image.js +0 -11
- package/lib-amd/components/Image/Image.js.map +0 -1
- package/lib-amd/components/Image/Image.types.d.ts +0 -35
- package/lib-amd/components/Image/Image.types.js +0 -5
- package/lib-amd/components/Image/Image.types.js.map +0 -1
- package/lib-amd/components/Image/index.d.ts +0 -5
- package/lib-amd/components/Image/index.js +0 -9
- package/lib-amd/components/Image/index.js.map +0 -1
- package/lib-amd/components/Image/renderImage.d.ts +0 -6
- package/lib-amd/components/Image/renderImage.js +0 -13
- package/lib-amd/components/Image/renderImage.js.map +0 -1
- package/lib-amd/components/Image/useImage.d.ts +0 -6
- package/lib-amd/components/Image/useImage.js +0 -30
- package/lib-amd/components/Image/useImage.js.map +0 -1
- package/lib-amd/components/Image/useImageStyles.d.ts +0 -3
- package/lib-amd/components/Image/useImageStyles.js +0 -82
- package/lib-amd/components/Image/useImageStyles.js.map +0 -1
- package/lib-amd/index.d.ts +0 -1
- package/lib-amd/index.js +0 -6
- package/lib-amd/index.js.map +0 -1
- package/src/components/Image/Image.types.ts +0 -43
package/README.md
CHANGED
|
@@ -2,14 +2,52 @@
|
|
|
2
2
|
|
|
3
3
|
**React Image component for [Fluent UI React](https://developer.microsoft.com/en-us/fluentui)**
|
|
4
4
|
|
|
5
|
-
These are not production-ready components
|
|
5
|
+
> WIP 🚧 - These are not production-ready components as we are still in a Beta phase.
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
Usage of Image component ensures consistent styling and behaviour of images in your application based on the Fluent UI Design System.
|
|
8
|
+
|
|
9
|
+
## Usage
|
|
10
|
+
|
|
11
|
+
To use the Image component, it is required to install the main package of Fluent UI components:
|
|
12
|
+
|
|
13
|
+
```sh
|
|
14
|
+
npm install @fluentui/react-components
|
|
15
|
+
```
|
|
8
16
|
|
|
9
17
|
```js
|
|
10
|
-
import { Image } from '@fluentui/react-
|
|
18
|
+
import { Image } from '@fluentui/react-components';
|
|
11
19
|
|
|
12
20
|
const App = () => {
|
|
13
|
-
return <Image src="
|
|
21
|
+
return <Image src="example_image.png" />;
|
|
14
22
|
};
|
|
15
23
|
```
|
|
24
|
+
|
|
25
|
+
Or, installing only the `react-image` package:
|
|
26
|
+
|
|
27
|
+
```sh
|
|
28
|
+
npm install @fluentui/react-image
|
|
29
|
+
npm install @fluentui/react-provider
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
```js
|
|
33
|
+
import { Image } from '@fluentui/react-image';
|
|
34
|
+
import { FluentProvider } from '@fluentui/react-provider';
|
|
35
|
+
|
|
36
|
+
const App = () => (
|
|
37
|
+
<FluentProvider>
|
|
38
|
+
<Image src="example_image.png" alt="Example image" />;
|
|
39
|
+
</FluentProvider>
|
|
40
|
+
);
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
The DOM structure will result into:
|
|
44
|
+
|
|
45
|
+
```jsx
|
|
46
|
+
<img src="example_image.png" alt="Example image" />
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
## API
|
|
50
|
+
|
|
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
|
+
|
|
53
|
+
For more information on the component, please refer to the [API documentation](https://aka.ms/fluentui-storybook).
|
package/Spec.md
ADDED
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
# @fluentui/react-image
|
|
2
|
+
|
|
3
|
+
## Background
|
|
4
|
+
|
|
5
|
+
Image is a visual representation of some content, such as a photo, illustration etc.
|
|
6
|
+
|
|
7
|
+
## Concerns
|
|
8
|
+
|
|
9
|
+
Based on the OpenUI research and the Figma specification, Image seems to be one of those components that is purely styling, thus I would appreciate your answers in any of these questions:
|
|
10
|
+
|
|
11
|
+
- Are there any components would need to use Image?
|
|
12
|
+
- Apart from styling, are there any other functionalities for Image?
|
|
13
|
+
|
|
14
|
+
**Conclusion**: Some potential features that Image can have are:
|
|
15
|
+
|
|
16
|
+
- fallback image placeholder when image fails to load
|
|
17
|
+
- onLoading callback when image fails to load
|
|
18
|
+
- styling helpers
|
|
19
|
+
These will be addressed on later iterations when needed
|
|
20
|
+
|
|
21
|
+
- Is there any benefit of having Image as a component? (taking into consideration that it is css styling and we will need to maintain it over time.)
|
|
22
|
+
|
|
23
|
+
**Conclusion**: The image component will ensure correct styling and behaviour regardless of the Theme
|
|
24
|
+
|
|
25
|
+
## Prior Art
|
|
26
|
+
|
|
27
|
+
- Convergence epic issue: [#16658](https://github.com/microsoft/fluentui/issues/16658)
|
|
28
|
+
- Open UI research [Link](https://open-ui.org/components/image.research), PR: [#274](https://github.com/openui/open-ui/pull/274)
|
|
29
|
+
|
|
30
|
+
### V8/v0 comparison
|
|
31
|
+
|
|
32
|
+
Comparison done in: [#17608](https://github.com/microsoft/fluentui/pull/17608)
|
|
33
|
+
|
|
34
|
+
[image@v7/v8]: https://developer.microsoft.com/en-us/fluentui#/controls/web/image
|
|
35
|
+
[image@v0]: https://fluentsite.z22.web.core.windows.net/0.53.0/components/image/props
|
|
36
|
+
|
|
37
|
+
| Purpose | v7 / v8 | v0 | Matching |
|
|
38
|
+
| ----------------------------------------------------------------------- | ----------------------- | --------------- | ----------------------------- |
|
|
39
|
+
| Additional CSS class name(s) to apply | `className` | `className` | matching |
|
|
40
|
+
| Specifies the cover style to be used for this image | `coverStyle` | N/A | v0 missing |
|
|
41
|
+
| Replaces the src in case of errors | `errorSrc` [DEPRECATED] | N/A | _See `onLoadingStateChanged`_ |
|
|
42
|
+
| Determines how the image is scaled and cropped to fit the frame | `imageFit` | `fluid` | partially matching |
|
|
43
|
+
| Expands image frame to fill its parent container | `maximizeFrame` | `fluid` | partially matching |
|
|
44
|
+
| Optional callback for when the image load state changed | `onLoadingStateChanged` | N/A | v0 missing |
|
|
45
|
+
| Fades the image in when loaded | `shouldFadeIn` | N/A | v0 missing |
|
|
46
|
+
| The image starts as visible and is hidden on error | `shouldStartVisible` | N/A | v0 missing |
|
|
47
|
+
| Provides customized styling that will layer on top of the variant rules | `styles` | `styles` | matching |
|
|
48
|
+
| Theme provided by HOC | `theme` | `variables` | matching |
|
|
49
|
+
| Accessibility behavior overridden by the user | N/A | `accessibility` | v7/v8 missing |
|
|
50
|
+
| An element type to render as (string or component) | N/A | `as` | v7/v8 missing |
|
|
51
|
+
| An image may be formatted to appear inline with text as an avatar | N/A | `avatar` | v7/v8 missing |
|
|
52
|
+
| An image can appear circular | N/A | `circular` | v7/v8 missing |
|
|
53
|
+
| Component design prop | N/A | `design` | v7/v8 missing |
|
|
54
|
+
| Image source URL | N/A | `src` | v7/v8 missing |
|
|
55
|
+
|
|
56
|
+
### v8 usage
|
|
57
|
+
|
|
58
|
+
```jsx
|
|
59
|
+
import { Image, ImageFit } from '@fluentui/react/lib/Image';
|
|
60
|
+
|
|
61
|
+
<Image maximizeFrame imageFit={ImageFit.contain} src="..." alt="Example of the image component in v8" />;
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
### v0 usage
|
|
65
|
+
|
|
66
|
+
```jsx
|
|
67
|
+
<Image block src="..." alt="Example of the image component in v0" />
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
## Variants
|
|
71
|
+
|
|
72
|
+
n/a
|
|
73
|
+
|
|
74
|
+
## API proposal
|
|
75
|
+
|
|
76
|
+
See [react-image/Image.types.ts] for the API.
|
|
77
|
+
|
|
78
|
+
[react-image/image.types.ts]: https://github.com/microsoft/fluentui/blob/master/packages/react-image/src/components/Image/Image.types.ts
|
|
79
|
+
|
|
80
|
+
Proposed component props:
|
|
81
|
+
|
|
82
|
+
| Name | Type | Default value | Comments |
|
|
83
|
+
| ---------- | --------- | ------------- | -------------------------------------------- |
|
|
84
|
+
| `bordered` | `boolean` | `false` | |
|
|
85
|
+
| `fit` | `string` | "`none`" | One of: `none`, `center`, `contain`, `cover` |
|
|
86
|
+
| `block` | `boolean` | `false` | |
|
|
87
|
+
| `shape ` | `string ` | `false` | One of: `square`, `circular` , `rounded` |
|
|
88
|
+
| `shadow` | `boolean` | `false` | |
|
|
89
|
+
|
|
90
|
+
All native html attributes of the `<img />` will be available to be used as props of the Image component.
|
|
91
|
+
|
|
92
|
+
## Sample Code
|
|
93
|
+
|
|
94
|
+
Sample code based on the proposed API:
|
|
95
|
+
|
|
96
|
+
### Bordered
|
|
97
|
+
|
|
98
|
+
```jsx
|
|
99
|
+
<Image bordered src="..." />
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
### Block
|
|
103
|
+
|
|
104
|
+
```jsx
|
|
105
|
+
<Image block src="..." />
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
### Rounded
|
|
109
|
+
|
|
110
|
+
```jsx
|
|
111
|
+
<Image shape="rounded" src="..." />
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
### Circular
|
|
115
|
+
|
|
116
|
+
```jsx
|
|
117
|
+
<Image shape="circular" src="..." />
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
### Fit
|
|
121
|
+
|
|
122
|
+
```jsx
|
|
123
|
+
// None
|
|
124
|
+
<Image fit="none" src="..." />
|
|
125
|
+
|
|
126
|
+
// Center
|
|
127
|
+
<Image fit="center" src="..." />
|
|
128
|
+
|
|
129
|
+
// Contain
|
|
130
|
+
<Image fit="contain" src="..." />
|
|
131
|
+
|
|
132
|
+
// Cover
|
|
133
|
+
<Image fit="cover" src="..." />
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
## Structure
|
|
137
|
+
|
|
138
|
+
### Public
|
|
139
|
+
|
|
140
|
+
```tsx
|
|
141
|
+
<Image src=".." />
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
### Internal
|
|
145
|
+
|
|
146
|
+
```tsx
|
|
147
|
+
<slots.root {...slotProps.root} />
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
### DOM
|
|
151
|
+
|
|
152
|
+
```tsx
|
|
153
|
+
<img src="..." class="...">
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
<!-- ## Migration -->
|
|
157
|
+
|
|
158
|
+
<!-- _Describe what will need to be done to upgrade from the existing implementations:_
|
|
159
|
+
|
|
160
|
+
- _Migration from v8_
|
|
161
|
+
- _Migration from v0_ -->
|
|
162
|
+
|
|
163
|
+
## Accessibility
|
|
164
|
+
|
|
165
|
+
Images should include the `alt` attribute that includes a description of the image's content and function to be accessible to assistive technologies. The alt description should be concise and clearly communicate the meaning and purpose of the image on where it was included. Avoid using "image of", "picture of" etc. as it is redundant.
|
|
166
|
+
|
|
167
|
+
The images that are only decorative and do not have the structural relevance implied by the semantic element should use the `alt=""` (null alt text) or `role="presentation"`/`role="none"` which will remove the semantic meaning of the element. In case the image is needed to be removed from the accessibility tree then `aria-hidden="true"` can be used.
|
|
168
|
+
|
|
169
|
+
### Relevant documents
|
|
170
|
+
|
|
171
|
+
- [WAI-ARIA 1.1 img Spec](https://www.w3.org/TR/wai-aria-1.1/#img)
|
|
172
|
+
- [WAI-ARIA 1.2 img Spec](https://www.w3.org/TR/wai-aria-1.2/#img)
|
|
173
|
+
- [WAI-ARIA 1.1 Hiding Semantics](https://www.w3.org/TR/wai-aria-practices-1.1/#presentation_role)
|
package/dist/react-image.d.ts
CHANGED
|
@@ -1,13 +1,16 @@
|
|
|
1
|
-
import { ComponentProps } from '@fluentui/react-utilities';
|
|
2
|
-
import
|
|
1
|
+
import type { ComponentProps } from '@fluentui/react-utilities';
|
|
2
|
+
import type { ComponentState } from '@fluentui/react-utilities';
|
|
3
|
+
import type { ForwardRefComponent } from '@fluentui/react-utilities';
|
|
4
|
+
import type { IntrinsicShorthandProps } from '@fluentui/react-utilities';
|
|
5
|
+
import * as React_2 from 'react';
|
|
3
6
|
|
|
4
|
-
|
|
7
|
+
/**
|
|
8
|
+
* The Image component ensures the consistent styling of images.
|
|
9
|
+
*/
|
|
10
|
+
declare const Image_2: ForwardRefComponent<ImageProps>;
|
|
11
|
+
export { Image_2 as Image }
|
|
5
12
|
|
|
6
|
-
export declare
|
|
7
|
-
/**
|
|
8
|
-
* An alternative text for an image.
|
|
9
|
-
*/
|
|
10
|
-
alt?: string;
|
|
13
|
+
export declare type ImageCommons = {
|
|
11
14
|
/**
|
|
12
15
|
* An image can appear with rectangular border.
|
|
13
16
|
*/
|
|
@@ -19,24 +22,27 @@ export declare interface ImageProps extends ComponentProps, React.ImgHTMLAttribu
|
|
|
19
22
|
/**
|
|
20
23
|
* An image can take up the width of its container.
|
|
21
24
|
*/
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* An image can appear circular.
|
|
25
|
-
*/
|
|
26
|
-
circular?: boolean;
|
|
25
|
+
block?: boolean;
|
|
27
26
|
/**
|
|
28
|
-
* An image can appear rounded.
|
|
27
|
+
* An image can appear square, circular, or rounded.
|
|
28
|
+
* @defaultvalue square
|
|
29
29
|
*/
|
|
30
|
-
|
|
30
|
+
shape?: 'square' | 'circular' | 'rounded';
|
|
31
31
|
/**
|
|
32
|
-
* An image can
|
|
32
|
+
* An image can appear elevated with shadow.
|
|
33
33
|
*/
|
|
34
|
-
|
|
35
|
-
}
|
|
34
|
+
shadow?: boolean;
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
export declare type ImageProps = ComponentProps<ImageSlots> & Partial<ImageCommons>;
|
|
38
|
+
|
|
39
|
+
export declare const imageShorthandProps: Array<keyof ImageSlots>;
|
|
36
40
|
|
|
37
|
-
export declare
|
|
38
|
-
|
|
39
|
-
}
|
|
41
|
+
export declare type ImageSlots = {
|
|
42
|
+
root: IntrinsicShorthandProps<'img'>;
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
export declare type ImageState = ComponentState<ImageSlots> & ImageCommons;
|
|
40
46
|
|
|
41
47
|
/**
|
|
42
48
|
* Define the render function.
|
|
@@ -47,10 +53,8 @@ export declare const renderImage: (state: ImageState) => JSX.Element;
|
|
|
47
53
|
/**
|
|
48
54
|
* Given user props, returns state and render function for an Image.
|
|
49
55
|
*/
|
|
50
|
-
export declare const useImage: (props: ImageProps, ref:
|
|
56
|
+
export declare const useImage: (props: ImageProps, ref: React_2.Ref<HTMLImageElement>) => ImageState;
|
|
51
57
|
|
|
52
58
|
export declare const useImageStyles: (state: ImageState) => void;
|
|
53
59
|
|
|
54
|
-
export declare const useRootStyles: (selectors: ImageState) => string;
|
|
55
|
-
|
|
56
60
|
export { }
|
package/lib/Image.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Image.js","sourceRoot":"
|
|
1
|
+
{"version":3,"file":"Image.js","sourceRoot":"","sources":["../src/Image.ts"],"names":[],"mappings":"AAAA,cAAc,0BAA0B,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { isConformant as baseIsConformant } from '@fluentui/react-conformance';
|
|
2
|
+
import makeStylesTests from '@fluentui/react-conformance-make-styles';
|
|
3
|
+
export function isConformant(testInfo) {
|
|
4
|
+
var defaultOptions = {
|
|
5
|
+
asPropHandlesRef: true,
|
|
6
|
+
componentPath: module.parent.filename.replace('.test', ''),
|
|
7
|
+
disabledTests: ['has-docblock'],
|
|
8
|
+
extraTests: makeStylesTests,
|
|
9
|
+
skipAsPropTests: true
|
|
10
|
+
};
|
|
11
|
+
baseIsConformant(defaultOptions, testInfo);
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=isConformant.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/common/isConformant.ts"],"names":[],"mappings":"AAAA,SAAS,YAAY,IAAI,gBAAzB,QAAiD,6BAAjD;AAEA,OAAO,eAAP,MAA4B,yCAA5B;AAEA,OAAM,SAAU,YAAV,CACJ,QADI,EACqF;AAEzF,MAAM,cAAc,GAAyC;AAC3D,IAAA,gBAAgB,EAAE,IADyC;AAE3D,IAAA,aAAa,EAAE,MAAO,CAAC,MAAR,CAAgB,QAAhB,CAAyB,OAAzB,CAAiC,OAAjC,EAA0C,EAA1C,CAF4C;AAG3D,IAAA,aAAa,EAAE,CAAC,cAAD,CAH4C;AAI3D,IAAA,UAAU,EAAE,eAJ+C;AAK3D,IAAA,eAAe,EAAE;AAL0C,GAA7D;AAQA,EAAA,gBAAgB,CAAC,cAAD,EAAiB,QAAjB,CAAhB;AACD","sourceRoot":""}
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
|
|
1
|
+
import type { ImageProps } from './Image.types';
|
|
2
|
+
import type { ForwardRefComponent } from '@fluentui/react-utilities';
|
|
3
|
+
/**
|
|
4
|
+
* The Image component ensures the consistent styling of images.
|
|
5
|
+
*/
|
|
6
|
+
export declare const Image: ForwardRefComponent<ImageProps>;
|
|
@@ -2,10 +2,14 @@ import * as React from 'react';
|
|
|
2
2
|
import { renderImage } from './renderImage';
|
|
3
3
|
import { useImage } from './useImage';
|
|
4
4
|
import { useImageStyles } from './useImageStyles';
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
/**
|
|
6
|
+
* The Image component ensures the consistent styling of images.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
export var Image = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
10
|
+
var state = useImage(props, ref);
|
|
11
|
+
useImageStyles(state);
|
|
12
|
+
return renderImage(state);
|
|
9
13
|
});
|
|
10
14
|
Image.displayName = 'Image';
|
|
11
15
|
//# sourceMappingURL=Image.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"sources":["../../../src/components/Image/Image.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAZ,MAAuB,OAAvB;AACA,SAAS,WAAT,QAA4B,eAA5B;AACA,SAAS,QAAT,QAAyB,YAAzB;AACA,SAAS,cAAT,QAA+B,kBAA/B;AAIA;;AAEG;;AACH,OAAO,IAAM,KAAK,gBAAoC,KAAK,CAAC,UAAN,CAAiB,UAAC,KAAD,EAAQ,GAAR,EAAW;AAChF,MAAM,KAAK,GAAG,QAAQ,CAAC,KAAD,EAAQ,GAAR,CAAtB;AACA,EAAA,cAAc,CAAC,KAAD,CAAd;AAEA,SAAO,WAAW,CAAC,KAAD,CAAlB;AACD,CALqD,CAA/C;AAOP,KAAK,CAAC,WAAN,GAAoB,OAApB","sourceRoot":""}
|
|
@@ -1,10 +1,8 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
*/
|
|
7
|
-
alt?: string;
|
|
1
|
+
import type { ComponentState, ComponentProps, IntrinsicShorthandProps } from '@fluentui/react-utilities';
|
|
2
|
+
export declare type ImageSlots = {
|
|
3
|
+
root: IntrinsicShorthandProps<'img'>;
|
|
4
|
+
};
|
|
5
|
+
export declare type ImageCommons = {
|
|
8
6
|
/**
|
|
9
7
|
* An image can appear with rectangular border.
|
|
10
8
|
*/
|
|
@@ -16,20 +14,16 @@ export interface ImageProps extends ComponentProps, React.ImgHTMLAttributes<HTML
|
|
|
16
14
|
/**
|
|
17
15
|
* An image can take up the width of its container.
|
|
18
16
|
*/
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* An image can appear circular.
|
|
22
|
-
*/
|
|
23
|
-
circular?: boolean;
|
|
17
|
+
block?: boolean;
|
|
24
18
|
/**
|
|
25
|
-
* An image can appear rounded.
|
|
19
|
+
* An image can appear square, circular, or rounded.
|
|
20
|
+
* @defaultvalue square
|
|
26
21
|
*/
|
|
27
|
-
|
|
22
|
+
shape?: 'square' | 'circular' | 'rounded';
|
|
28
23
|
/**
|
|
29
|
-
* An image can
|
|
24
|
+
* An image can appear elevated with shadow.
|
|
30
25
|
*/
|
|
31
|
-
|
|
32
|
-
}
|
|
33
|
-
export
|
|
34
|
-
|
|
35
|
-
}
|
|
26
|
+
shadow?: boolean;
|
|
27
|
+
};
|
|
28
|
+
export declare type ImageProps = ComponentProps<ImageSlots> & Partial<ImageCommons>;
|
|
29
|
+
export declare type ImageState = ComponentState<ImageSlots> & ImageCommons;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Image.types.js","sourceRoot":"
|
|
1
|
+
{"version":3,"file":"Image.types.js","sourceRoot":"","sources":["../../../src/components/Image/Image.types.ts"],"names":[],"mappings":""}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/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"}
|
|
@@ -1,12 +1,17 @@
|
|
|
1
1
|
import { __assign } from "tslib";
|
|
2
2
|
import * as React from 'react';
|
|
3
3
|
import { getSlots } from '@fluentui/react-utilities';
|
|
4
|
+
import { imageShorthandProps } from './useImage';
|
|
4
5
|
/**
|
|
5
6
|
* Define the render function.
|
|
6
7
|
* Given the state of an image, renders it.
|
|
7
8
|
*/
|
|
9
|
+
|
|
8
10
|
export var renderImage = function (state) {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
+
var _a = getSlots(state, imageShorthandProps),
|
|
12
|
+
slots = _a.slots,
|
|
13
|
+
slotProps = _a.slotProps;
|
|
14
|
+
|
|
15
|
+
return /*#__PURE__*/React.createElement(slots.root, __assign({}, slotProps.root));
|
|
11
16
|
};
|
|
12
17
|
//# sourceMappingURL=renderImage.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"sources":["../../../src/components/Image/renderImage.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,KAAZ,MAAuB,OAAvB;AACA,SAAS,QAAT,QAAyB,2BAAzB;AAEA,SAAS,mBAAT,QAAoC,YAApC;AAEA;;;AAGG;;AACH,OAAO,IAAM,WAAW,GAAG,UAAC,KAAD,EAAkB;AACrC,MAAA,EAAA,GAAuB,QAAQ,CAAa,KAAb,EAAoB,mBAApB,CAA/B;AAAA,MAAE,KAAK,GAAA,EAAA,CAAA,KAAP;AAAA,MAAS,SAAS,GAAA,EAAA,CAAA,SAAlB;;AAEN,sBAAO,KAAA,CAAA,aAAA,CAAC,KAAK,CAAC,IAAP,EAAW,QAAA,CAAA,EAAA,EAAK,SAAS,CAAC,IAAf,CAAX,CAAP;AACD,CAJM","sourceRoot":""}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import { ImageProps, ImageState } from './Image.types';
|
|
2
|
+
import type { ImageProps, ImageSlots, ImageState } from './Image.types';
|
|
3
|
+
export declare const imageShorthandProps: Array<keyof ImageSlots>;
|
|
3
4
|
/**
|
|
4
5
|
* Given user props, returns state and render function for an Image.
|
|
5
6
|
*/
|
|
6
|
-
export declare const useImage: (props: ImageProps, ref: React.Ref<
|
|
7
|
+
export declare const useImage: (props: ImageProps, ref: React.Ref<HTMLImageElement>) => ImageState;
|
|
@@ -1,31 +1,30 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import { objectFitImages } from 'object-fit-images';
|
|
5
|
-
import { makeMergeProps, resolveShorthandProps, useMergedRefs } from '@fluentui/react-utilities';
|
|
6
|
-
var mergeProps = makeMergeProps();
|
|
7
|
-
var isFitSupported = (function () {
|
|
8
|
-
var testImg = new Image();
|
|
9
|
-
return 'object-fit' in testImg.style && 'object-position' in testImg.style;
|
|
10
|
-
})();
|
|
1
|
+
import { __assign } from "tslib";
|
|
2
|
+
import { getNativeElementProps } from '@fluentui/react-utilities';
|
|
3
|
+
export var imageShorthandProps = ['root'];
|
|
11
4
|
/**
|
|
12
5
|
* Given user props, returns state and render function for an Image.
|
|
13
6
|
*/
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
7
|
+
|
|
8
|
+
export var useImage = function (props, ref) {
|
|
9
|
+
var bordered = props.bordered,
|
|
10
|
+
fit = props.fit,
|
|
11
|
+
block = props.block,
|
|
12
|
+
_a = props.shape,
|
|
13
|
+
shape = _a === void 0 ? 'square' : _a,
|
|
14
|
+
shadow = props.shadow;
|
|
15
|
+
var state = {
|
|
16
|
+
bordered: bordered,
|
|
17
|
+
fit: fit,
|
|
18
|
+
block: block,
|
|
19
|
+
shape: shape,
|
|
20
|
+
shadow: shadow,
|
|
21
|
+
components: {
|
|
22
|
+
root: 'img'
|
|
23
|
+
},
|
|
24
|
+
root: getNativeElementProps('img', __assign({
|
|
25
|
+
ref: ref
|
|
26
|
+
}, props))
|
|
27
|
+
};
|
|
28
|
+
return state;
|
|
30
29
|
};
|
|
31
30
|
//# sourceMappingURL=useImage.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"sources":["../../../src/components/Image/useImage.ts"],"names":[],"mappings":";AACA,SAAS,qBAAT,QAAsC,2BAAtC;AAGA,OAAO,IAAM,mBAAmB,GAA4B,CAAC,MAAD,CAArD;AAEP;;AAEG;;AACH,OAAO,IAAM,QAAQ,GAAG,UAAC,KAAD,EAAoB,GAApB,EAAoD;AAClE,MAAA,QAAQ,GAA2C,KAAK,CAAhD,QAAR;AAAA,MAAU,GAAG,GAAsC,KAAK,CAA3C,GAAb;AAAA,MAAe,KAAK,GAA+B,KAAK,CAApC,KAApB;AAAA,MAAsB,EAAA,GAA6B,KAAK,CAAlB,KAAtC;AAAA,MAAsB,KAAK,GAAA,EAAA,KAAA,KAAA,CAAA,GAAG,QAAH,GAAW,EAAtC;AAAA,MAAwC,MAAM,GAAK,KAAK,CAAV,MAA9C;AAER,MAAM,KAAK,GAAe;AACxB,IAAA,QAAQ,EAAA,QADgB;AAExB,IAAA,GAAG,EAAA,GAFqB;AAGxB,IAAA,KAAK,EAAA,KAHmB;AAIxB,IAAA,KAAK,EAAA,KAJmB;AAKxB,IAAA,MAAM,EAAA,MALkB;AAMxB,IAAA,UAAU,EAAE;AACV,MAAA,IAAI,EAAE;AADI,KANY;AASxB,IAAA,IAAI,EAAE,qBAAqB,CAAC,KAAD,EAAM,QAAA,CAAA;AAC/B,MAAA,GAAG,EAAA;AAD4B,KAAA,EAE5B,KAF4B,CAAN;AATH,GAA1B;AAeA,SAAO,KAAP;AACD,CAnBM","sourceRoot":""}
|