@atlaskit/media-card 77.11.3 → 77.12.1

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 (93) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/dist/cjs/card/card.js +5 -5
  3. package/dist/cjs/card/cardView.js +6 -10
  4. package/dist/cjs/card/inlinePlayerWrapperStyles.js +1 -1
  5. package/dist/cjs/card/media-card-analytics-error-boundary.js +1 -1
  6. package/dist/cjs/card/ui/styles.js +1 -12
  7. package/dist/cjs/card/ui/wrapper/imageContainer.js +52 -0
  8. package/dist/cjs/card/ui/wrapper/index.js +8 -1
  9. package/dist/cjs/card/ui/wrapper/styles.js +1 -1
  10. package/dist/cjs/card/v2/cardV2.js +1 -1
  11. package/dist/cjs/card/v2/cardViewV2.js +12 -17
  12. package/dist/cjs/card/v2/cardviews/cardViewWrapper.js +5 -9
  13. package/dist/cjs/card/v2/fileCard.js +66 -20
  14. package/dist/cjs/card/v2/svgView/helpers.js +16 -0
  15. package/dist/cjs/card/v2/svgView/index.js +12 -0
  16. package/dist/cjs/card/v2/svgView/svgView.js +134 -0
  17. package/dist/cjs/inline/loader.js +1 -1
  18. package/dist/cjs/inline/mediaInlineAnalyticsErrorBoundary.js +11 -11
  19. package/dist/cjs/utils/ufoExperiences.js +1 -1
  20. package/dist/es2019/card/card.js +5 -5
  21. package/dist/es2019/card/cardView.js +8 -12
  22. package/dist/es2019/card/inlinePlayerWrapperStyles.js +12 -12
  23. package/dist/es2019/card/media-card-analytics-error-boundary.js +1 -1
  24. package/dist/es2019/card/ui/styles.js +0 -11
  25. package/dist/es2019/card/ui/wrapper/imageContainer.js +44 -0
  26. package/dist/es2019/card/ui/wrapper/index.js +2 -1
  27. package/dist/es2019/card/ui/wrapper/styles.js +21 -21
  28. package/dist/es2019/card/v2/cardV2.js +1 -1
  29. package/dist/es2019/card/v2/cardViewV2.js +13 -18
  30. package/dist/es2019/card/v2/cardviews/cardViewWrapper.js +6 -10
  31. package/dist/es2019/card/v2/fileCard.js +51 -8
  32. package/dist/es2019/card/v2/svgView/helpers.js +12 -0
  33. package/dist/es2019/card/v2/svgView/index.js +1 -0
  34. package/dist/es2019/card/v2/svgView/svgView.js +113 -0
  35. package/dist/es2019/inline/loader.js +1 -1
  36. package/dist/es2019/inline/mediaInlineAnalyticsErrorBoundary.js +11 -11
  37. package/dist/es2019/utils/ufoExperiences.js +1 -1
  38. package/dist/esm/card/card.js +5 -5
  39. package/dist/esm/card/cardView.js +8 -12
  40. package/dist/esm/card/inlinePlayerWrapperStyles.js +1 -1
  41. package/dist/esm/card/media-card-analytics-error-boundary.js +1 -1
  42. package/dist/esm/card/ui/styles.js +0 -11
  43. package/dist/esm/card/ui/wrapper/imageContainer.js +45 -0
  44. package/dist/esm/card/ui/wrapper/index.js +2 -1
  45. package/dist/esm/card/ui/wrapper/styles.js +1 -1
  46. package/dist/esm/card/v2/cardV2.js +1 -1
  47. package/dist/esm/card/v2/cardViewV2.js +13 -18
  48. package/dist/esm/card/v2/cardviews/cardViewWrapper.js +6 -10
  49. package/dist/esm/card/v2/fileCard.js +66 -20
  50. package/dist/esm/card/v2/svgView/helpers.js +10 -0
  51. package/dist/esm/card/v2/svgView/index.js +1 -0
  52. package/dist/esm/card/v2/svgView/svgView.js +123 -0
  53. package/dist/esm/inline/loader.js +1 -1
  54. package/dist/esm/inline/mediaInlineAnalyticsErrorBoundary.js +11 -11
  55. package/dist/esm/utils/ufoExperiences.js +1 -1
  56. package/dist/types/card/ui/iconWrapper/styles.d.ts +1 -1
  57. package/dist/types/card/ui/styles.d.ts +0 -1
  58. package/dist/types/card/ui/titleBox/styles.d.ts +1 -1
  59. package/dist/types/card/ui/wrapper/imageContainer.d.ts +15 -0
  60. package/dist/types/card/ui/wrapper/index.d.ts +1 -0
  61. package/dist/types/card/v2/svgView/helpers.d.ts +3 -0
  62. package/dist/types/card/v2/svgView/index.d.ts +1 -0
  63. package/dist/types/card/v2/svgView/svgView.d.ts +31 -0
  64. package/dist/types/utils/preventClickThrough.d.ts +1 -1
  65. package/dist/types/utils/viewportDetector.d.ts +1 -1
  66. package/dist/types-ts4.5/card/ui/iconWrapper/styles.d.ts +1 -1
  67. package/dist/types-ts4.5/card/ui/styles.d.ts +0 -1
  68. package/dist/types-ts4.5/card/ui/titleBox/styles.d.ts +1 -1
  69. package/dist/types-ts4.5/card/ui/wrapper/imageContainer.d.ts +15 -0
  70. package/dist/types-ts4.5/card/ui/wrapper/index.d.ts +1 -0
  71. package/dist/types-ts4.5/card/v2/svgView/helpers.d.ts +3 -0
  72. package/dist/types-ts4.5/card/v2/svgView/index.d.ts +1 -0
  73. package/dist/types-ts4.5/card/v2/svgView/svgView.d.ts +31 -0
  74. package/dist/types-ts4.5/utils/preventClickThrough.d.ts +1 -1
  75. package/dist/types-ts4.5/utils/viewportDetector.d.ts +1 -1
  76. package/example-helpers/DelayedRender.tsx +19 -19
  77. package/example-helpers/cardViewWrapper.tsx +18 -22
  78. package/example-helpers/cards.tsx +268 -331
  79. package/example-helpers/developmentUseMessage.tsx +8 -9
  80. package/example-helpers/index.tsx +100 -124
  81. package/example-helpers/selectableCard.tsx +32 -35
  82. package/example-helpers/ssrHelpers.tsx +19 -29
  83. package/example-helpers/styles.ts +73 -73
  84. package/example-helpers/svg-helpers/cardContainer.tsx +24 -0
  85. package/example-helpers/svg-helpers/controls.tsx +21 -0
  86. package/example-helpers/svg-helpers/delayApiResponses.ts +31 -0
  87. package/example-helpers/svg-helpers/dimensionPicker.tsx +116 -0
  88. package/example-helpers/svg-helpers/index.ts +7 -0
  89. package/example-helpers/svg-helpers/svgContainer.tsx +32 -0
  90. package/example-helpers/svg-helpers/toggle.tsx +42 -0
  91. package/example-helpers/svg-helpers/uploader.ts +44 -0
  92. package/package.json +13 -5
  93. package/report.api.md +227 -232
@@ -0,0 +1,21 @@
1
+ import React, { type ReactNode } from 'react';
2
+
3
+ import { Box, xcss } from '@atlaskit/primitives';
4
+ import { media } from '@atlaskit/primitives/responsive';
5
+
6
+ const controlsBoxStyles = xcss({
7
+ maxWidth: '1500px',
8
+ width: '90%',
9
+ margin: 'auto',
10
+ padding: 'space.100',
11
+ [media.above.sm]: {
12
+ width: '70%',
13
+ },
14
+ [media.above.lg]: {
15
+ width: '50%',
16
+ },
17
+ });
18
+
19
+ export const ControlsBox = ({ children }: { children: ReactNode }) => (
20
+ <Box xcss={controlsBoxStyles}>{children}</Box>
21
+ );
@@ -0,0 +1,31 @@
1
+ import { type MediaApi } from '@atlaskit/media-client';
2
+ import { sleep } from '@atlaskit/media-test-helpers';
3
+
4
+ type Endpoints = {
5
+ getImage: number;
6
+ getItems: number;
7
+ getFileBinary: number;
8
+ };
9
+
10
+ export const delayApiResponses = (
11
+ mediaApi: MediaApi,
12
+ { getImage, getItems, getFileBinary }: Endpoints,
13
+ ) => {
14
+ const baseGetImage = mediaApi.getImage;
15
+ mediaApi.getImage = async (...params) => {
16
+ await sleep(getImage);
17
+ return baseGetImage(...params);
18
+ };
19
+
20
+ const baseGetItems = mediaApi.getItems;
21
+ mediaApi.getItems = async (...params) => {
22
+ await sleep(getItems);
23
+ return baseGetItems(...params);
24
+ };
25
+
26
+ const baseGetFileBinary = mediaApi.getFileBinary;
27
+ mediaApi.getFileBinary = async (...params) => {
28
+ await sleep(getFileBinary);
29
+ return baseGetFileBinary(...params);
30
+ };
31
+ };
@@ -0,0 +1,116 @@
1
+ import React, { useEffect, useMemo, useState } from 'react';
2
+
3
+ import { Label } from '@atlaskit/form';
4
+ import { Box, Flex, xcss } from '@atlaskit/primitives';
5
+ import Range from '@atlaskit/range';
6
+
7
+ import { ToggleBox } from './toggle';
8
+
9
+ const boxStyles = xcss({ width: '25%', padding: 'space.025' });
10
+ const wrapperStyles = xcss({ padding: 'space.025' });
11
+
12
+ const pixelRange = [1, 1600];
13
+ const percentRange = [1, 100];
14
+
15
+ type OnValue = (value: string | undefined) => void;
16
+
17
+ const defaultVlue = 500;
18
+
19
+ export const DimensionPicker = ({
20
+ targetName,
21
+ dimensionName,
22
+ onChange,
23
+ initialValue,
24
+ initialUnit,
25
+ }: {
26
+ initialValue?: number;
27
+ initialUnit?: '%' | 'px';
28
+ targetName: string;
29
+ dimensionName: string;
30
+ onChange: OnValue;
31
+ }) => {
32
+ const rangeId = `range-${targetName}-${dimensionName}`;
33
+
34
+ const [isPercent, setIsPercent] = useState(initialUnit === '%');
35
+ const [rawValue, setRawValue] = useState<number | undefined>(initialValue);
36
+ const rangeValues = useMemo(() => (isPercent ? percentRange : pixelRange), [isPercent]);
37
+
38
+ const value = useMemo(
39
+ () => (isPercent && !!rawValue && rawValue > 100 ? 100 : rawValue),
40
+ [isPercent, rawValue],
41
+ );
42
+ const unit = useMemo(() => (isPercent ? '%' : 'px'), [isPercent]);
43
+
44
+ useEffect(() => {
45
+ onChange(value === undefined ? value : `${value}${unit}`);
46
+ }, [value, unit, onChange]);
47
+
48
+ return (
49
+ <Box xcss={boxStyles}>
50
+ <Label htmlFor={rangeId}>
51
+ {targetName} {dimensionName}: {value ? `${value} ${isPercent ? '%' : 'px'}` : 'Not set'}
52
+ </Label>
53
+ <ToggleBox label="Use %" defaultChecked={initialUnit === '%'} onChange={setIsPercent} />
54
+ <ToggleBox
55
+ label="Unset"
56
+ defaultChecked={!initialValue}
57
+ onChange={(value) => {
58
+ value ? setRawValue(undefined) : setRawValue(defaultVlue);
59
+ }}
60
+ />
61
+ {rawValue && (
62
+ <Range
63
+ id={rangeId}
64
+ step={1}
65
+ min={rangeValues[0]}
66
+ max={rangeValues[1]}
67
+ onChange={setRawValue}
68
+ value={value}
69
+ />
70
+ )}
71
+ </Box>
72
+ );
73
+ };
74
+
75
+ export const DimensionsPicker = ({
76
+ onContainerWidth,
77
+ onContainerHeight,
78
+ onImageWidth,
79
+ onImageHeight,
80
+ }: {
81
+ onContainerWidth: OnValue;
82
+ onContainerHeight: OnValue;
83
+ onImageWidth: OnValue;
84
+ onImageHeight: OnValue;
85
+ }) => {
86
+ return (
87
+ <Flex alignItems="stretch" direction="row" xcss={wrapperStyles}>
88
+ <DimensionPicker
89
+ targetName="Container"
90
+ dimensionName="width"
91
+ onChange={onContainerWidth}
92
+ initialValue={defaultVlue}
93
+ />
94
+ <DimensionPicker
95
+ targetName="Container"
96
+ dimensionName="height"
97
+ onChange={onContainerHeight}
98
+ initialValue={defaultVlue}
99
+ />
100
+ <DimensionPicker
101
+ targetName="Image"
102
+ dimensionName="width"
103
+ onChange={onImageWidth}
104
+ initialValue={80}
105
+ initialUnit="%"
106
+ />
107
+ <DimensionPicker
108
+ targetName="Image"
109
+ dimensionName="height"
110
+ onChange={onImageHeight}
111
+ initialValue={80}
112
+ initialUnit="%"
113
+ />
114
+ </Flex>
115
+ );
116
+ };
@@ -0,0 +1,7 @@
1
+ export { ControlsBox } from './controls';
2
+ export { DimensionsPicker } from './dimensionPicker';
3
+ export { ToggleBox } from './toggle';
4
+ export { SvgContainer } from './svgContainer';
5
+ export { useSvgUploader } from './uploader';
6
+ export { CardBox, CardRow } from './cardContainer';
7
+ export { delayApiResponses } from './delayApiResponses';
@@ -0,0 +1,32 @@
1
+ /** @jsx jsx */
2
+ import React from 'react';
3
+
4
+ import { jsx } from '@emotion/react';
5
+
6
+ import { Box, xcss } from '@atlaskit/primitives';
7
+
8
+ const containerStyles = xcss({
9
+ boxSizing: 'border-box',
10
+ borderColor: 'color.border.accent.orange',
11
+ borderStyle: 'solid',
12
+ borderWidth: 'border.width.indicator',
13
+ margin: 'auto',
14
+ marginTop: 'space.100',
15
+ backgroundColor: 'color.background.accent.green.subtler',
16
+ });
17
+
18
+ export const SvgContainer = ({
19
+ children,
20
+ width,
21
+ height,
22
+ }: {
23
+ children: React.ReactNode;
24
+ width?: string;
25
+ height?: string;
26
+ }) => {
27
+ return (
28
+ <Box xcss={containerStyles} style={{ width, height }}>
29
+ {children}
30
+ </Box>
31
+ );
32
+ };
@@ -0,0 +1,42 @@
1
+ import React, { useState } from 'react';
2
+
3
+ import { Label } from '@atlaskit/form';
4
+ import { Box } from '@atlaskit/primitives';
5
+ import Toggle from '@atlaskit/toggle';
6
+
7
+ function makeid(length = 12) {
8
+ let result = '';
9
+ const characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
10
+ const charactersLength = characters.length;
11
+ let counter = 0;
12
+ while (counter < length) {
13
+ result += characters.charAt(Math.floor(Math.random() * charactersLength));
14
+ counter += 1;
15
+ }
16
+ return result;
17
+ }
18
+
19
+ export const ToggleBox = ({
20
+ label,
21
+ onChange,
22
+ ...props
23
+ }: Omit<React.ComponentProps<typeof Toggle>, 'onChange'> & {
24
+ label: string;
25
+ onChange: (val: boolean) => void;
26
+ }) => {
27
+ const [id] = useState(makeid());
28
+
29
+ return (
30
+ <Box>
31
+ <Label htmlFor={id}>{label}</Label>
32
+ <Toggle
33
+ onChange={(evt) => {
34
+ const { checked } = evt.target;
35
+ onChange(checked);
36
+ }}
37
+ {...props}
38
+ id={id}
39
+ />
40
+ </Box>
41
+ );
42
+ };
@@ -0,0 +1,44 @@
1
+ import { type SyntheticEvent, useState } from 'react';
2
+
3
+ import { type FileIdentifier } from '@atlaskit/media-client';
4
+ import { useMediaClient } from '@atlaskit/media-client-react';
5
+
6
+ export const useSvgUploader = (collectionName?: string) => {
7
+ const mediaClient = useMediaClient();
8
+ const [identifier, setIdentifier] = useState<FileIdentifier>();
9
+ const [status, setStatus] = useState<string>('');
10
+
11
+ const uploadFn = async (event: SyntheticEvent<HTMLInputElement>) => {
12
+ if (!event.currentTarget.files || !event.currentTarget.files.length) {
13
+ return;
14
+ }
15
+ setStatus('Uploading');
16
+
17
+ const file = event.currentTarget.files[0];
18
+ const uplodableFile = {
19
+ content: file,
20
+ name: file.name,
21
+ collection: collectionName,
22
+ };
23
+
24
+ mediaClient.file.upload(uplodableFile).subscribe({
25
+ next: ({ status, id }) => {
26
+ if (status === 'error') {
27
+ setStatus('Error while uploading');
28
+ return;
29
+ }
30
+ setStatus(status);
31
+ setIdentifier({
32
+ id,
33
+ mediaItemType: 'file' as const,
34
+ collectionName,
35
+ });
36
+ },
37
+ error: () => {
38
+ setStatus('Error while uploading');
39
+ },
40
+ });
41
+ };
42
+
43
+ return { status, identifier, uploadFn };
44
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/media-card",
3
- "version": "77.11.3",
3
+ "version": "77.12.1",
4
4
  "description": "Includes all media card related components, CardView, CardViewSmall, Card...",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -37,18 +37,19 @@
37
37
  },
38
38
  "dependencies": {
39
39
  "@atlaskit/analytics-next": "^9.3.0",
40
- "@atlaskit/dropdown-menu": "^12.10.0",
41
- "@atlaskit/editor-shared-styles": "^2.11.0",
40
+ "@atlaskit/dropdown-menu": "^12.11.0",
41
+ "@atlaskit/editor-shared-styles": "^2.12.0",
42
42
  "@atlaskit/icon": "^22.3.0",
43
43
  "@atlaskit/media-client": "^27.2.0",
44
44
  "@atlaskit/media-client-react": "^2.0.0",
45
45
  "@atlaskit/media-common": "^11.2.0",
46
46
  "@atlaskit/media-file-preview": "^0.5.0",
47
+ "@atlaskit/media-svg": "^0.1.3",
47
48
  "@atlaskit/media-ui": "^25.10.0",
48
49
  "@atlaskit/media-viewer": "^48.6.0",
49
50
  "@atlaskit/platform-feature-flags": "^0.2.2",
50
51
  "@atlaskit/spinner": "^16.1.0",
51
- "@atlaskit/theme": "^12.8.0",
52
+ "@atlaskit/theme": "^12.9.0",
52
53
  "@atlaskit/tokens": "^1.49.0",
53
54
  "@atlaskit/tooltip": "^18.4.0",
54
55
  "@atlaskit/ufo": "^0.2.0",
@@ -69,15 +70,19 @@
69
70
  "@af/integration-testing": "*",
70
71
  "@atlaskit/analytics-listeners": "^8.9.0",
71
72
  "@atlaskit/analytics-namespaced-context": "^6.9.0",
73
+ "@atlaskit/form": "^10.2.0",
72
74
  "@atlaskit/inline-message": "^12.1.0",
73
75
  "@atlaskit/media-core": "^34.2.0",
74
76
  "@atlaskit/media-picker": "^66.4.0",
75
77
  "@atlaskit/media-state": "^1.1.0",
76
78
  "@atlaskit/media-test-data": "^2.3.0",
77
79
  "@atlaskit/media-test-helpers": "^33.0.0",
78
- "@atlaskit/primitives": "^6.4.0",
80
+ "@atlaskit/primitives": "^7.0.0",
81
+ "@atlaskit/range": "^7.2.0",
79
82
  "@atlaskit/ssr": "*",
83
+ "@atlaskit/toggle": "^13.1.0",
80
84
  "@atlaskit/visual-regression": "*",
85
+ "@atlassian/feature-flags-test-utils": "^0.2.0",
81
86
  "@atlassian/ufo": "^0.2.0",
82
87
  "@testing-library/dom": "^8.17.1",
83
88
  "@testing-library/react": "^12.1.5",
@@ -100,6 +105,9 @@
100
105
  },
101
106
  "platform.media-experience.card-views-refactor_b91lr": {
102
107
  "type": "boolean"
108
+ },
109
+ "platform.media-card-svg-rendering_6tdbv": {
110
+ "type": "boolean"
103
111
  }
104
112
  },
105
113
  "techstack": {