@atlaskit/media-card 77.12.0 → 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 (52) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/dist/cjs/card/card.js +5 -5
  3. package/dist/cjs/card/inlinePlayerWrapperStyles.js +1 -1
  4. package/dist/cjs/card/media-card-analytics-error-boundary.js +1 -1
  5. package/dist/cjs/card/ui/wrapper/styles.js +1 -1
  6. package/dist/cjs/card/v2/cardV2.js +1 -1
  7. package/dist/cjs/card/v2/fileCard.js +1 -1
  8. package/dist/cjs/inline/loader.js +1 -1
  9. package/dist/cjs/inline/mediaInlineAnalyticsErrorBoundary.js +11 -11
  10. package/dist/cjs/utils/ufoExperiences.js +1 -1
  11. package/dist/es2019/card/card.js +5 -5
  12. package/dist/es2019/card/inlinePlayerWrapperStyles.js +12 -12
  13. package/dist/es2019/card/media-card-analytics-error-boundary.js +1 -1
  14. package/dist/es2019/card/ui/wrapper/styles.js +21 -21
  15. package/dist/es2019/card/v2/cardV2.js +1 -1
  16. package/dist/es2019/card/v2/fileCard.js +1 -1
  17. package/dist/es2019/inline/loader.js +1 -1
  18. package/dist/es2019/inline/mediaInlineAnalyticsErrorBoundary.js +11 -11
  19. package/dist/es2019/utils/ufoExperiences.js +1 -1
  20. package/dist/esm/card/card.js +5 -5
  21. package/dist/esm/card/inlinePlayerWrapperStyles.js +1 -1
  22. package/dist/esm/card/media-card-analytics-error-boundary.js +1 -1
  23. package/dist/esm/card/ui/wrapper/styles.js +1 -1
  24. package/dist/esm/card/v2/cardV2.js +1 -1
  25. package/dist/esm/card/v2/fileCard.js +1 -1
  26. package/dist/esm/inline/loader.js +1 -1
  27. package/dist/esm/inline/mediaInlineAnalyticsErrorBoundary.js +11 -11
  28. package/dist/esm/utils/ufoExperiences.js +1 -1
  29. package/dist/types/card/ui/iconWrapper/styles.d.ts +1 -1
  30. package/dist/types/card/ui/titleBox/styles.d.ts +1 -1
  31. package/dist/types/utils/preventClickThrough.d.ts +1 -1
  32. package/dist/types/utils/viewportDetector.d.ts +1 -1
  33. package/dist/types-ts4.5/card/ui/iconWrapper/styles.d.ts +1 -1
  34. package/dist/types-ts4.5/card/ui/titleBox/styles.d.ts +1 -1
  35. package/dist/types-ts4.5/utils/preventClickThrough.d.ts +1 -1
  36. package/dist/types-ts4.5/utils/viewportDetector.d.ts +1 -1
  37. package/example-helpers/DelayedRender.tsx +19 -19
  38. package/example-helpers/cardViewWrapper.tsx +18 -22
  39. package/example-helpers/cards.tsx +268 -331
  40. package/example-helpers/developmentUseMessage.tsx +8 -9
  41. package/example-helpers/index.tsx +100 -124
  42. package/example-helpers/selectableCard.tsx +32 -35
  43. package/example-helpers/ssrHelpers.tsx +19 -29
  44. package/example-helpers/styles.ts +73 -73
  45. package/example-helpers/svg-helpers/cardContainer.tsx +15 -21
  46. package/example-helpers/svg-helpers/controls.tsx +11 -11
  47. package/example-helpers/svg-helpers/dimensionPicker.tsx +85 -93
  48. package/example-helpers/svg-helpers/svgContainer.tsx +18 -18
  49. package/example-helpers/svg-helpers/toggle.tsx +28 -29
  50. package/example-helpers/svg-helpers/uploader.ts +33 -33
  51. package/package.json +5 -5
  52. package/report.api.md +227 -232
@@ -3,28 +3,22 @@ import React from 'react';
3
3
 
4
4
  import { jsx } from '@emotion/react';
5
5
 
6
- export const CardBox = ({
7
- title,
8
- children,
9
- }: {
10
- title: string;
11
- children: React.ReactNode;
12
- }) => (
13
- <div style={{ marginBottom: '10px' }}>
14
- <h3 style={{ textAlign: 'center' }}>{title}</h3>
15
- {children}
16
- </div>
6
+ export const CardBox = ({ title, children }: { title: string; children: React.ReactNode }) => (
7
+ <div style={{ marginBottom: '10px' }}>
8
+ <h3 style={{ textAlign: 'center' }}>{title}</h3>
9
+ {children}
10
+ </div>
17
11
  );
18
12
 
19
13
  export const CardRow = ({ children }: { children: React.ReactNode }) => (
20
- <div
21
- style={{
22
- display: 'flex',
23
- flexWrap: 'wrap',
24
- gap: '10px',
25
- marginBottom: '10px',
26
- }}
27
- >
28
- {children}
29
- </div>
14
+ <div
15
+ style={{
16
+ display: 'flex',
17
+ flexWrap: 'wrap',
18
+ gap: '10px',
19
+ marginBottom: '10px',
20
+ }}
21
+ >
22
+ {children}
23
+ </div>
30
24
  );
@@ -4,18 +4,18 @@ import { Box, xcss } from '@atlaskit/primitives';
4
4
  import { media } from '@atlaskit/primitives/responsive';
5
5
 
6
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
- },
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
17
  });
18
18
 
19
19
  export const ControlsBox = ({ children }: { children: ReactNode }) => (
20
- <Box xcss={controlsBoxStyles}>{children}</Box>
20
+ <Box xcss={controlsBoxStyles}>{children}</Box>
21
21
  );
@@ -17,108 +17,100 @@ type OnValue = (value: string | undefined) => void;
17
17
  const defaultVlue = 500;
18
18
 
19
19
  export const DimensionPicker = ({
20
- targetName,
21
- dimensionName,
22
- onChange,
23
- initialValue,
24
- initialUnit,
20
+ targetName,
21
+ dimensionName,
22
+ onChange,
23
+ initialValue,
24
+ initialUnit,
25
25
  }: {
26
- initialValue?: number;
27
- initialUnit?: '%' | 'px';
28
- targetName: string;
29
- dimensionName: string;
30
- onChange: OnValue;
26
+ initialValue?: number;
27
+ initialUnit?: '%' | 'px';
28
+ targetName: string;
29
+ dimensionName: string;
30
+ onChange: OnValue;
31
31
  }) => {
32
- const rangeId = `range-${targetName}-${dimensionName}`;
32
+ const rangeId = `range-${targetName}-${dimensionName}`;
33
33
 
34
- const [isPercent, setIsPercent] = useState(initialUnit === '%');
35
- const [rawValue, setRawValue] = useState<number | undefined>(initialValue);
36
- const rangeValues = useMemo(
37
- () => (isPercent ? percentRange : pixelRange),
38
- [isPercent],
39
- );
34
+ const [isPercent, setIsPercent] = useState(initialUnit === '%');
35
+ const [rawValue, setRawValue] = useState<number | undefined>(initialValue);
36
+ const rangeValues = useMemo(() => (isPercent ? percentRange : pixelRange), [isPercent]);
40
37
 
41
- const value = useMemo(
42
- () => (isPercent && !!rawValue && rawValue > 100 ? 100 : rawValue),
43
- [isPercent, rawValue],
44
- );
45
- const unit = useMemo(() => (isPercent ? '%' : 'px'), [isPercent]);
38
+ const value = useMemo(
39
+ () => (isPercent && !!rawValue && rawValue > 100 ? 100 : rawValue),
40
+ [isPercent, rawValue],
41
+ );
42
+ const unit = useMemo(() => (isPercent ? '%' : 'px'), [isPercent]);
46
43
 
47
- useEffect(() => {
48
- onChange(value === undefined ? value : `${value}${unit}`);
49
- }, [value, unit, onChange]);
44
+ useEffect(() => {
45
+ onChange(value === undefined ? value : `${value}${unit}`);
46
+ }, [value, unit, onChange]);
50
47
 
51
- return (
52
- <Box xcss={boxStyles}>
53
- <Label htmlFor={rangeId}>
54
- {targetName} {dimensionName}:{' '}
55
- {value ? `${value} ${isPercent ? '%' : 'px'}` : 'Not set'}
56
- </Label>
57
- <ToggleBox
58
- label="Use %"
59
- defaultChecked={initialUnit === '%'}
60
- onChange={setIsPercent}
61
- />
62
- <ToggleBox
63
- label="Unset"
64
- defaultChecked={!initialValue}
65
- onChange={(value) => {
66
- value ? setRawValue(undefined) : setRawValue(defaultVlue);
67
- }}
68
- />
69
- {rawValue && (
70
- <Range
71
- id={rangeId}
72
- step={1}
73
- min={rangeValues[0]}
74
- max={rangeValues[1]}
75
- onChange={setRawValue}
76
- value={value}
77
- />
78
- )}
79
- </Box>
80
- );
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
+ );
81
73
  };
82
74
 
83
75
  export const DimensionsPicker = ({
84
- onContainerWidth,
85
- onContainerHeight,
86
- onImageWidth,
87
- onImageHeight,
76
+ onContainerWidth,
77
+ onContainerHeight,
78
+ onImageWidth,
79
+ onImageHeight,
88
80
  }: {
89
- onContainerWidth: OnValue;
90
- onContainerHeight: OnValue;
91
- onImageWidth: OnValue;
92
- onImageHeight: OnValue;
81
+ onContainerWidth: OnValue;
82
+ onContainerHeight: OnValue;
83
+ onImageWidth: OnValue;
84
+ onImageHeight: OnValue;
93
85
  }) => {
94
- return (
95
- <Flex alignItems="stretch" direction="row" xcss={wrapperStyles}>
96
- <DimensionPicker
97
- targetName="Container"
98
- dimensionName="width"
99
- onChange={onContainerWidth}
100
- initialValue={defaultVlue}
101
- />
102
- <DimensionPicker
103
- targetName="Container"
104
- dimensionName="height"
105
- onChange={onContainerHeight}
106
- initialValue={defaultVlue}
107
- />
108
- <DimensionPicker
109
- targetName="Image"
110
- dimensionName="width"
111
- onChange={onImageWidth}
112
- initialValue={80}
113
- initialUnit="%"
114
- />
115
- <DimensionPicker
116
- targetName="Image"
117
- dimensionName="height"
118
- onChange={onImageHeight}
119
- initialValue={80}
120
- initialUnit="%"
121
- />
122
- </Flex>
123
- );
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
+ );
124
116
  };
@@ -6,27 +6,27 @@ import { jsx } from '@emotion/react';
6
6
  import { Box, xcss } from '@atlaskit/primitives';
7
7
 
8
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',
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
16
  });
17
17
 
18
18
  export const SvgContainer = ({
19
- children,
20
- width,
21
- height,
19
+ children,
20
+ width,
21
+ height,
22
22
  }: {
23
- children: React.ReactNode;
24
- width?: string;
25
- height?: string;
23
+ children: React.ReactNode;
24
+ width?: string;
25
+ height?: string;
26
26
  }) => {
27
- return (
28
- <Box xcss={containerStyles} style={{ width, height }}>
29
- {children}
30
- </Box>
31
- );
27
+ return (
28
+ <Box xcss={containerStyles} style={{ width, height }}>
29
+ {children}
30
+ </Box>
31
+ );
32
32
  };
@@ -5,39 +5,38 @@ import { Box } from '@atlaskit/primitives';
5
5
  import Toggle from '@atlaskit/toggle';
6
6
 
7
7
  function makeid(length = 12) {
8
- let result = '';
9
- const characters =
10
- 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
11
- const charactersLength = characters.length;
12
- let counter = 0;
13
- while (counter < length) {
14
- result += characters.charAt(Math.floor(Math.random() * charactersLength));
15
- counter += 1;
16
- }
17
- return result;
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;
18
17
  }
19
18
 
20
19
  export const ToggleBox = ({
21
- label,
22
- onChange,
23
- ...props
20
+ label,
21
+ onChange,
22
+ ...props
24
23
  }: Omit<React.ComponentProps<typeof Toggle>, 'onChange'> & {
25
- label: string;
26
- onChange: (val: boolean) => void;
24
+ label: string;
25
+ onChange: (val: boolean) => void;
27
26
  }) => {
28
- const [id] = useState(makeid());
27
+ const [id] = useState(makeid());
29
28
 
30
- return (
31
- <Box>
32
- <Label htmlFor={id}>{label}</Label>
33
- <Toggle
34
- onChange={evt => {
35
- const { checked } = evt.target;
36
- onChange(checked);
37
- }}
38
- {...props}
39
- id={id}
40
- />
41
- </Box>
42
- );
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
+ );
43
42
  };
@@ -4,41 +4,41 @@ import { type FileIdentifier } from '@atlaskit/media-client';
4
4
  import { useMediaClient } from '@atlaskit/media-client-react';
5
5
 
6
6
  export const useSvgUploader = (collectionName?: string) => {
7
- const mediaClient = useMediaClient();
8
- const [identifier, setIdentifier] = useState<FileIdentifier>();
9
- const [status, setStatus] = useState<string>('');
7
+ const mediaClient = useMediaClient();
8
+ const [identifier, setIdentifier] = useState<FileIdentifier>();
9
+ const [status, setStatus] = useState<string>('');
10
10
 
11
- const uploadFn = async (event: SyntheticEvent<HTMLInputElement>) => {
12
- if (!event.currentTarget.files || !event.currentTarget.files.length) {
13
- return;
14
- }
15
- setStatus('Uploading');
11
+ const uploadFn = async (event: SyntheticEvent<HTMLInputElement>) => {
12
+ if (!event.currentTarget.files || !event.currentTarget.files.length) {
13
+ return;
14
+ }
15
+ setStatus('Uploading');
16
16
 
17
- const file = event.currentTarget.files[0];
18
- const uplodableFile = {
19
- content: file,
20
- name: file.name,
21
- collection: collectionName,
22
- };
17
+ const file = event.currentTarget.files[0];
18
+ const uplodableFile = {
19
+ content: file,
20
+ name: file.name,
21
+ collection: collectionName,
22
+ };
23
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
- };
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
42
 
43
- return { status, identifier, uploadFn };
43
+ return { status, identifier, uploadFn };
44
44
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/media-card",
3
- "version": "77.12.0",
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,7 +37,7 @@
37
37
  },
38
38
  "dependencies": {
39
39
  "@atlaskit/analytics-next": "^9.3.0",
40
- "@atlaskit/dropdown-menu": "^12.10.0",
40
+ "@atlaskit/dropdown-menu": "^12.11.0",
41
41
  "@atlaskit/editor-shared-styles": "^2.12.0",
42
42
  "@atlaskit/icon": "^22.3.0",
43
43
  "@atlaskit/media-client": "^27.2.0",
@@ -49,7 +49,7 @@
49
49
  "@atlaskit/media-viewer": "^48.6.0",
50
50
  "@atlaskit/platform-feature-flags": "^0.2.2",
51
51
  "@atlaskit/spinner": "^16.1.0",
52
- "@atlaskit/theme": "^12.8.0",
52
+ "@atlaskit/theme": "^12.9.0",
53
53
  "@atlaskit/tokens": "^1.49.0",
54
54
  "@atlaskit/tooltip": "^18.4.0",
55
55
  "@atlaskit/ufo": "^0.2.0",
@@ -77,7 +77,7 @@
77
77
  "@atlaskit/media-state": "^1.1.0",
78
78
  "@atlaskit/media-test-data": "^2.3.0",
79
79
  "@atlaskit/media-test-helpers": "^33.0.0",
80
- "@atlaskit/primitives": "^6.5.0",
80
+ "@atlaskit/primitives": "^7.0.0",
81
81
  "@atlaskit/range": "^7.2.0",
82
82
  "@atlaskit/ssr": "*",
83
83
  "@atlaskit/toggle": "^13.1.0",
@@ -106,7 +106,7 @@
106
106
  "platform.media-experience.card-views-refactor_b91lr": {
107
107
  "type": "boolean"
108
108
  },
109
- "platform.media-svg-rendering": {
109
+ "platform.media-card-svg-rendering_6tdbv": {
110
110
  "type": "boolean"
111
111
  }
112
112
  },