@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.
Files changed (80) hide show
  1. package/CHANGELOG.json +2081 -1
  2. package/CHANGELOG.md +814 -2
  3. package/README.md +42 -4
  4. package/Spec.md +173 -0
  5. package/dist/react-image.d.ts +28 -24
  6. package/lib/Image.js.map +1 -1
  7. package/lib/common/isConformant.d.ts +4 -0
  8. package/lib/common/isConformant.js +13 -0
  9. package/lib/common/isConformant.js.map +1 -0
  10. package/lib/components/Image/Image.d.ts +6 -3
  11. package/lib/components/Image/Image.js +8 -4
  12. package/lib/components/Image/Image.js.map +1 -1
  13. package/lib/components/Image/Image.types.d.ts +14 -20
  14. package/lib/components/Image/Image.types.js +1 -0
  15. package/lib/components/Image/Image.types.js.map +1 -1
  16. package/lib/components/Image/index.js +1 -0
  17. package/lib/components/Image/index.js.map +1 -1
  18. package/lib/components/Image/renderImage.js +7 -2
  19. package/lib/components/Image/renderImage.js.map +1 -1
  20. package/lib/components/Image/useImage.d.ts +3 -2
  21. package/lib/components/Image/useImage.js +25 -26
  22. package/lib/components/Image/useImage.js.map +1 -1
  23. package/lib/components/Image/useImageStyles.d.ts +1 -2
  24. package/lib/components/Image/useImageStyles.js +64 -76
  25. package/lib/components/Image/useImageStyles.js.map +1 -1
  26. package/lib/index.js.map +1 -1
  27. package/lib/tsdoc-metadata.json +1 -1
  28. package/lib-commonjs/Image.js +7 -2
  29. package/lib-commonjs/Image.js.map +1 -1
  30. package/lib-commonjs/common/isConformant.d.ts +4 -0
  31. package/lib-commonjs/common/isConformant.js +24 -0
  32. package/lib-commonjs/common/isConformant.js.map +1 -0
  33. package/lib-commonjs/components/Image/Image.d.ts +6 -3
  34. package/lib-commonjs/components/Image/Image.js +22 -9
  35. package/lib-commonjs/components/Image/Image.js.map +1 -1
  36. package/lib-commonjs/components/Image/Image.types.d.ts +14 -20
  37. package/lib-commonjs/components/Image/Image.types.js +4 -1
  38. package/lib-commonjs/components/Image/Image.types.js.map +1 -1
  39. package/lib-commonjs/components/Image/index.js +12 -2
  40. package/lib-commonjs/components/Image/index.js.map +1 -1
  41. package/lib-commonjs/components/Image/renderImage.js +23 -7
  42. package/lib-commonjs/components/Image/renderImage.js.map +1 -1
  43. package/lib-commonjs/components/Image/useImage.d.ts +3 -2
  44. package/lib-commonjs/components/Image/useImage.js +35 -27
  45. package/lib-commonjs/components/Image/useImage.js.map +1 -1
  46. package/lib-commonjs/components/Image/useImageStyles.d.ts +1 -2
  47. package/lib-commonjs/components/Image/useImageStyles.js +73 -78
  48. package/lib-commonjs/components/Image/useImageStyles.js.map +1 -1
  49. package/lib-commonjs/index.js +7 -2
  50. package/lib-commonjs/index.js.map +1 -1
  51. package/package.json +16 -17
  52. package/config/api-extractor.json +0 -3
  53. package/config/tests.js +0 -6
  54. package/etc/react-image.api.md +0 -45
  55. package/just.config.ts +0 -3
  56. package/lib-amd/Image.d.ts +0 -1
  57. package/lib-amd/Image.js +0 -6
  58. package/lib-amd/Image.js.map +0 -1
  59. package/lib-amd/components/Image/Image.d.ts +0 -3
  60. package/lib-amd/components/Image/Image.js +0 -11
  61. package/lib-amd/components/Image/Image.js.map +0 -1
  62. package/lib-amd/components/Image/Image.types.d.ts +0 -35
  63. package/lib-amd/components/Image/Image.types.js +0 -5
  64. package/lib-amd/components/Image/Image.types.js.map +0 -1
  65. package/lib-amd/components/Image/index.d.ts +0 -5
  66. package/lib-amd/components/Image/index.js +0 -9
  67. package/lib-amd/components/Image/index.js.map +0 -1
  68. package/lib-amd/components/Image/renderImage.d.ts +0 -6
  69. package/lib-amd/components/Image/renderImage.js +0 -13
  70. package/lib-amd/components/Image/renderImage.js.map +0 -1
  71. package/lib-amd/components/Image/useImage.d.ts +0 -6
  72. package/lib-amd/components/Image/useImage.js +0 -30
  73. package/lib-amd/components/Image/useImage.js.map +0 -1
  74. package/lib-amd/components/Image/useImageStyles.d.ts +0 -3
  75. package/lib-amd/components/Image/useImageStyles.js +0 -82
  76. package/lib-amd/components/Image/useImageStyles.js.map +0 -1
  77. package/lib-amd/index.d.ts +0 -1
  78. package/lib-amd/index.js +0 -6
  79. package/lib-amd/index.js.map +0 -1
  80. 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 and **should never be used in product**. This space is useful for testing new components whose APIs might change before final release.
5
+ > WIP 🚧 - These are not production-ready components as we are still in a Beta phase.
6
6
 
7
- To import React Image component:
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-image';
18
+ import { Image } from '@fluentui/react-components';
11
19
 
12
20
  const App = () => {
13
- return <Image src="image.png" />;
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)
@@ -1,13 +1,16 @@
1
- import { ComponentProps } from '@fluentui/react-utilities';
2
- import * as React from 'react';
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
- export declare const Image: React.ForwardRefExoticComponent<ImageProps & React.RefAttributes<HTMLElement>>;
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 interface ImageProps extends ComponentProps, React.ImgHTMLAttributes<HTMLImageElement> {
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
- fluid?: boolean;
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
- rounded?: boolean;
30
+ shape?: 'square' | 'circular' | 'rounded';
31
31
  /**
32
- * An image can have source URL.
32
+ * An image can appear elevated with shadow.
33
33
  */
34
- src?: string;
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 interface ImageState extends ImageProps {
38
- ref: React.RefObject<HTMLImageElement>;
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: React.Ref<HTMLElement>, defaultProps?: ImageProps | undefined) => ImageState;
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":"../src/","sources":["Image.ts"],"names":[],"mappings":"AAAA,cAAc,0BAA0B,CAAC","sourcesContent":["export * from './components/Image/index';\n"]}
1
+ {"version":3,"file":"Image.js","sourceRoot":"","sources":["../src/Image.ts"],"names":[],"mappings":"AAAA,cAAc,0BAA0B,CAAC"}
@@ -0,0 +1,4 @@
1
+ import type { IsConformantOptions } from '@fluentui/react-conformance';
2
+ export declare function isConformant<TProps = {}>(testInfo: Omit<IsConformantOptions<TProps>, 'componentPath'> & {
3
+ componentPath?: string;
4
+ }): void;
@@ -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 * as React from 'react';
2
- import { ImageProps } from './Image.types';
3
- export declare const Image: React.ForwardRefExoticComponent<ImageProps & React.RefAttributes<HTMLElement>>;
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
- export var Image = React.forwardRef(function (props, ref) {
6
- var state = useImage(props, ref);
7
- useImageStyles(state);
8
- return renderImage(state);
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,"file":"Image.js","sourceRoot":"../src/","sources":["components/Image/Image.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAElD,MAAM,CAAC,IAAM,KAAK,GAAG,KAAK,CAAC,UAAU,CAAC,UAAC,KAAiB,EAAE,GAA2B;IACnF,IAAM,KAAK,GAAG,QAAQ,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;IACnC,cAAc,CAAC,KAAK,CAAC,CAAC;IAEtB,OAAO,WAAW,CAAC,KAAK,CAAC,CAAC;AAC5B,CAAC,CAAC,CAAC;AAEH,KAAK,CAAC,WAAW,GAAG,OAAO,CAAC","sourcesContent":["import * as React from 'react';\nimport { ImageProps } from './Image.types';\nimport { renderImage } from './renderImage';\nimport { useImage } from './useImage';\nimport { useImageStyles } from './useImageStyles';\n\nexport const Image = React.forwardRef((props: ImageProps, ref: React.Ref<HTMLElement>) => {\n const state = useImage(props, ref);\n useImageStyles(state);\n\n return renderImage(state);\n});\n\nImage.displayName = 'Image';\n"]}
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 * as React from 'react';
2
- import { ComponentProps } from '@fluentui/react-utilities';
3
- export interface ImageProps extends ComponentProps, React.ImgHTMLAttributes<HTMLImageElement> {
4
- /**
5
- * An alternative text for an image.
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
- fluid?: boolean;
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
- rounded?: boolean;
22
+ shape?: 'square' | 'circular' | 'rounded';
28
23
  /**
29
- * An image can have source URL.
24
+ * An image can appear elevated with shadow.
30
25
  */
31
- src?: string;
32
- }
33
- export interface ImageState extends ImageProps {
34
- ref: React.RefObject<HTMLImageElement>;
35
- }
26
+ shadow?: boolean;
27
+ };
28
+ export declare type ImageProps = ComponentProps<ImageSlots> & Partial<ImageCommons>;
29
+ export declare type ImageState = ComponentState<ImageSlots> & ImageCommons;
@@ -1 +1,2 @@
1
+ export {};
1
2
  //# sourceMappingURL=Image.types.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Image.types.js","sourceRoot":"../src/","sources":["components/Image/Image.types.ts"],"names":[],"mappings":"","sourcesContent":["import * as React from 'react';\nimport { ComponentProps } from '@fluentui/react-utilities';\n\nexport interface ImageProps extends ComponentProps, React.ImgHTMLAttributes<HTMLImageElement> {\n /**\n * An alternative text for an image.\n */\n alt?: string;\n\n /**\n * An image can appear with rectangular border.\n */\n bordered?: boolean;\n\n /**\n * An image can set how it should be resized to fit its container.\n */\n fit?: 'none' | 'center' | 'contain' | 'cover';\n\n /**\n * An image can take up the width of its container.\n */\n fluid?: boolean;\n\n /**\n * An image can appear circular.\n */\n circular?: boolean;\n\n /**\n * An image can appear rounded.\n */\n rounded?: boolean;\n\n /**\n * An image can have source URL.\n */\n src?: string;\n}\n\nexport interface ImageState extends ImageProps {\n ref: React.RefObject<HTMLImageElement>;\n}\n"]}
1
+ {"version":3,"file":"Image.types.js","sourceRoot":"","sources":["../../../src/components/Image/Image.types.ts"],"names":[],"mappings":""}
@@ -1,3 +1,4 @@
1
+ export * from './Image.types';
1
2
  export * from './Image';
2
3
  export * from './renderImage';
3
4
  export * from './useImage';
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"../src/","sources":["components/Image/index.ts"],"names":[],"mappings":"AACA,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
+ {"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
- var _a = getSlots(state), slots = _a.slots, slotProps = _a.slotProps;
10
- return React.createElement(slots.root, __assign({}, slotProps.root));
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,"file":"renderImage.js","sourceRoot":"../src/","sources":["components/Image/renderImage.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AAGrD;;;GAGG;AACH,MAAM,CAAC,IAAM,WAAW,GAAG,UAAC,KAAiB;IACrC,IAAA,oBAAsC,EAApC,gBAAK,EAAE,wBAA6B,CAAC;IAE7C,OAAO,oBAAC,KAAK,CAAC,IAAI,eAAK,SAAS,CAAC,IAAI,EAAI,CAAC;AAC5C,CAAC,CAAC","sourcesContent":["import * as React from 'react';\nimport { getSlots } from '@fluentui/react-utilities';\nimport { ImageState } from './Image.types';\n\n/**\n * Define the render function.\n * Given the state of an image, renders it.\n */\nexport const renderImage = (state: ImageState) => {\n const { slots, slotProps } = getSlots(state);\n\n return <slots.root {...slotProps.root} />;\n};\n"]}
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<HTMLElement>, defaultProps?: ImageProps | undefined) => ImageState;
7
+ export declare const useImage: (props: ImageProps, ref: React.Ref<HTMLImageElement>) => ImageState;
@@ -1,31 +1,30 @@
1
- import * as React from 'react';
2
- /* eslint-disable @typescript-eslint/ban-ts-comment */
3
- // @ts-ignore Typings require esModuleInterop
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
- export var useImage = function (props, ref, defaultProps) {
15
- var resolvedRef = useMergedRefs(ref, React.useRef(null));
16
- var state = mergeProps({
17
- ref: resolvedRef,
18
- as: 'img',
19
- }, defaultProps, resolveShorthandProps(props, []));
20
- React.useEffect(function () {
21
- if (!isFitSupported) {
22
- objectFitImages(state.ref.current);
23
- }
24
- },
25
- // objectFitImages() should be executed once per element
26
- // eslint-disable-next-line react-hooks/exhaustive-deps
27
- []);
28
- state['aria-hidden'] = state.alt || state['aria-label'] ? undefined : 'true';
29
- return state;
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,"file":"useImage.js","sourceRoot":"../src/","sources":["components/Image/useImage.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,sDAAsD;AACtD,6CAA6C;AAC7C,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,cAAc,EAAE,qBAAqB,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAGjG,IAAM,UAAU,GAAG,cAAc,EAAc,CAAC;AAEhD,IAAM,cAAc,GAAG,CAAC;IACtB,IAAM,OAAO,GAAG,IAAI,KAAK,EAAE,CAAC;IAE5B,OAAO,YAAY,IAAI,OAAO,CAAC,KAAK,IAAI,iBAAiB,IAAI,OAAO,CAAC,KAAK,CAAC;AAC7E,CAAC,CAAC,EAAE,CAAC;AAEL;;GAEG;AACH,MAAM,CAAC,IAAM,QAAQ,GAAG,UAAC,KAAiB,EAAE,GAA2B,EAAE,YAAyB;IAChG,IAAM,WAAW,GAAG,aAAa,CAAC,GAAG,EAAE,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC;IAC3D,IAAM,KAAK,GAAG,UAAU,CACtB;QACE,GAAG,EAAE,WAAW;QAChB,EAAE,EAAE,KAAK;KACV,EACD,YAAY,EACZ,qBAAqB,CAAC,KAAK,EAAE,EAAE,CAAC,CACjC,CAAC;IAEF,KAAK,CAAC,SAAS,CACb;QACE,IAAI,CAAC,cAAc,EAAE;YACnB,eAAe,CAAC,KAAK,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;SACpC;IACH,CAAC;IACD,wDAAwD;IACxD,uDAAuD;IACvD,EAAE,CACH,CAAC;IAEF,KAAK,CAAC,aAAa,CAAC,GAAG,KAAK,CAAC,GAAG,IAAI,KAAK,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC;IAE7E,OAAO,KAAK,CAAC;AACf,CAAC,CAAC","sourcesContent":["import * as React from 'react';\n/* eslint-disable @typescript-eslint/ban-ts-comment */\n// @ts-ignore Typings require esModuleInterop\nimport { objectFitImages } from 'object-fit-images';\nimport { makeMergeProps, resolveShorthandProps, useMergedRefs } from '@fluentui/react-utilities';\nimport { ImageProps, ImageState } from './Image.types';\n\nconst mergeProps = makeMergeProps<ImageState>();\n\nconst isFitSupported = (function() {\n const testImg = new Image();\n\n return 'object-fit' in testImg.style && 'object-position' in testImg.style;\n})();\n\n/**\n * Given user props, returns state and render function for an Image.\n */\nexport const useImage = (props: ImageProps, ref: React.Ref<HTMLElement>, defaultProps?: ImageProps): ImageState => {\n const resolvedRef = useMergedRefs(ref, React.useRef(null));\n const state = mergeProps(\n {\n ref: resolvedRef,\n as: 'img',\n },\n defaultProps,\n resolveShorthandProps(props, []),\n );\n\n React.useEffect(\n () => {\n if (!isFitSupported) {\n objectFitImages(state.ref.current);\n }\n },\n // objectFitImages() should be executed once per element\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [],\n );\n\n state['aria-hidden'] = state.alt || state['aria-label'] ? undefined : 'true';\n\n return state;\n};\n"]}
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":""}
@@ -1,3 +1,2 @@
1
- import { ImageState } from './Image.types';
2
- export declare const useRootStyles: (selectors: ImageState) => string;
1
+ import type { ImageState } from './Image.types';
3
2
  export declare const useImageStyles: (state: ImageState) => void;