@bynder/compact-view 2.4.3 → 2.6.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.
- package/README.md +27 -37
- package/components.d.ts +225 -237
- package/components.js +22 -3
- package/index.d.ts +64 -104
- package/index.js +22 -3
- package/package.json +20 -20
package/README.md
CHANGED
|
@@ -3,10 +3,9 @@
|
|
|
3
3
|
## Usage example
|
|
4
4
|
|
|
5
5
|
```jsx
|
|
6
|
-
import * as React from
|
|
7
|
-
import * as ReactDOM from
|
|
8
|
-
import { CompactView, Modal, Login } from
|
|
9
|
-
|
|
6
|
+
import * as React from 'react';
|
|
7
|
+
import * as ReactDOM from 'react-dom';
|
|
8
|
+
import { CompactView, Modal, Login } from '@bynder/compact-view';
|
|
10
9
|
const assetFieldSelection = `
|
|
11
10
|
name
|
|
12
11
|
url
|
|
@@ -19,39 +18,30 @@ const assetFieldSelection = `
|
|
|
19
18
|
previewUrls
|
|
20
19
|
}
|
|
21
20
|
`;
|
|
22
|
-
|
|
23
21
|
class App extends React.Component {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
assetFieldSelection={assetFieldSelection}
|
|
48
|
-
/>
|
|
49
|
-
</Login>
|
|
50
|
-
</Modal>
|
|
51
|
-
</>
|
|
52
|
-
);
|
|
53
|
-
}
|
|
22
|
+
constructor(props) {
|
|
23
|
+
super(props);
|
|
24
|
+
this.state = { isOpen: false };
|
|
25
|
+
}
|
|
26
|
+
onSuccess(assets) {
|
|
27
|
+
console.log(assets);
|
|
28
|
+
}
|
|
29
|
+
render() {
|
|
30
|
+
return (
|
|
31
|
+
<>
|
|
32
|
+
<button onClick={() => this.setState({ isOpen: true })}>Open Compact View</button>
|
|
33
|
+
<Modal isOpen={this.state.isOpen} onClose={() => this.setState({ isOpen: false })}>
|
|
34
|
+
<Login>
|
|
35
|
+
<CompactView
|
|
36
|
+
language="en_US"
|
|
37
|
+
onSuccess={this.onSuccess}
|
|
38
|
+
assetFieldSelection={assetFieldSelection}
|
|
39
|
+
/>
|
|
40
|
+
</Login>
|
|
41
|
+
</Modal>
|
|
42
|
+
</>
|
|
43
|
+
);
|
|
44
|
+
}
|
|
54
45
|
}
|
|
55
|
-
|
|
56
|
-
ReactDOM.render(<App />, document.getElementById("app"));
|
|
46
|
+
ReactDOM.render(<App />, document.getElementById('app'));
|
|
57
47
|
```
|
package/components.d.ts
CHANGED
|
@@ -1,241 +1,229 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
2
|
+
import React from "react";
|
|
3
|
+
interface MetapropertyOptionType {
|
|
4
|
+
id: string;
|
|
5
|
+
label: string;
|
|
6
|
+
assetCount: number;
|
|
7
|
+
}
|
|
8
|
+
interface MetapropertyOptionProps {
|
|
9
|
+
metapropertyOption: MetapropertyOptionType;
|
|
10
|
+
selectedOptionIds?: string[];
|
|
11
|
+
isLoading?: boolean;
|
|
12
|
+
onAddOption: () => void;
|
|
13
|
+
onRemoveOption: () => void;
|
|
14
|
+
}
|
|
15
|
+
declare function MetapropertyOptionComponent(props: MetapropertyOptionProps): JSX.Element;
|
|
16
|
+
interface MetapropertyType {
|
|
17
|
+
__typename: "Metaproperty";
|
|
18
|
+
id: string;
|
|
19
|
+
label: string;
|
|
20
|
+
options: MetapropertyOptionType[];
|
|
21
|
+
showInGridView: boolean;
|
|
22
|
+
showInListView: boolean;
|
|
23
|
+
}
|
|
24
|
+
interface MetapropertyProps {
|
|
25
|
+
metaproperty: MetapropertyType;
|
|
26
|
+
selectedOptionIds: string[];
|
|
27
|
+
isLoading: boolean;
|
|
28
|
+
onAddOption: (metapropertyOption: MetapropertyOptionType) => void;
|
|
29
|
+
onRemoveOption: (metapropertyOption: MetapropertyOptionType) => void;
|
|
30
|
+
}
|
|
31
|
+
declare function MetaPropertyFilterContent(props: MetapropertyProps): JSX.Element;
|
|
32
|
+
interface Derivatives {
|
|
33
|
+
thumbnail?: string;
|
|
34
|
+
}
|
|
35
|
+
interface Asset {
|
|
36
|
+
id: string;
|
|
37
|
+
derivatives: Derivatives;
|
|
38
|
+
extensions: string[];
|
|
39
|
+
name: string;
|
|
40
|
+
url: string;
|
|
41
|
+
isArchived: boolean;
|
|
42
|
+
isWatermarked: boolean;
|
|
43
|
+
metaproperties?: {
|
|
44
|
+
nodes: MetapropertyType[];
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
interface Props {
|
|
48
|
+
className?: string;
|
|
49
|
+
fadeIn?: boolean;
|
|
50
|
+
asset: Asset;
|
|
51
|
+
isSelected: boolean;
|
|
52
|
+
onClick?: (asset: Asset, event: React.MouseEvent) => void;
|
|
53
|
+
isOutlined: boolean;
|
|
54
|
+
children?: React.ReactNode;
|
|
55
|
+
}
|
|
56
|
+
declare function AssetCard({ className, fadeIn, asset, isSelected, isOutlined, onClick, children }: Props): JSX.Element;
|
|
57
|
+
type Kind = "Flat" | "Primary" | "Secondary" | "FlatSm" | "PrimarySm" | "SecondarySm";
|
|
58
|
+
interface Theme {
|
|
59
|
+
colorPrimary?: string;
|
|
60
|
+
colorButtonPrimary?: string;
|
|
61
|
+
colorButtonPrimaryLabel?: string;
|
|
62
|
+
colorButtonPrimaryActive?: string;
|
|
63
|
+
colorButtonPrimaryHover?: string;
|
|
64
|
+
colorButtonPrimaryHoverLabel?: string;
|
|
65
|
+
}
|
|
66
|
+
type SelectionMode = "SingleSelect" | "SingleSelectFile" | "MultiSelect";
|
|
67
|
+
type AssetData = {
|
|
52
68
|
tag: "Loading";
|
|
53
|
-
value:
|
|
69
|
+
value: undefined | Asset[];
|
|
54
70
|
} | {
|
|
55
71
|
tag: "Loaded";
|
|
56
|
-
value:
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
}
|
|
122
|
-
declare
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
declare
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
readonly style?: ReactDOMRe_style;
|
|
215
|
-
}>;
|
|
216
|
-
declare const NoResults: React.ComponentType<{
|
|
217
|
-
readonly onReset: () => void;
|
|
218
|
-
}>;
|
|
219
|
-
declare const Oops: React.ComponentType<{
|
|
220
|
-
readonly error: any;
|
|
221
|
-
readonly onRetry: () => void;
|
|
222
|
-
}>;
|
|
223
|
-
declare const OverlayButton: React.ComponentType<{
|
|
224
|
-
readonly active?: boolean;
|
|
225
|
-
readonly children: React.ReactNode;
|
|
226
|
-
readonly className?: string;
|
|
227
|
-
readonly onClick?: (_1: ReactEvent_Mouse_t) => void;
|
|
228
|
-
readonly title?: string;
|
|
229
|
-
}>;
|
|
230
|
-
declare const ShadowRoot: React.ComponentType<{
|
|
231
|
-
readonly children: React.ReactNode;
|
|
232
|
-
readonly topLevel?: boolean;
|
|
233
|
-
}>;
|
|
234
|
-
declare const Skeleton: React.ComponentType<{
|
|
235
|
-
readonly className?: string;
|
|
236
|
-
readonly width?: number;
|
|
237
|
-
}>;
|
|
238
|
-
declare const Spinner: React.ComponentType<{
|
|
239
|
-
readonly className?: string;
|
|
240
|
-
}>;
|
|
241
|
-
export { Asset, asset as displayAsset, AssetList, data, Button, Card, Images_make as CardImages, Image_make as CardImage, Checkbox, Chip, Dropdown, ListItem_make as DropdownListItem, MetapropertyOption_make as MetapropertyOption, MetapropertyOption_t as metapropertyOption, Metaproperty_make as Metaproperty, Metaproperty_t as metaproperty, Smartfilter_make as Smartfilter, Smartfilter_t as smartfilter, HorizontalScroll, InfiniteScroll, Modal, NoResults, Oops, OverlayButton, ShadowRoot, Skeleton, Spinner };
|
|
72
|
+
value: Asset[];
|
|
73
|
+
};
|
|
74
|
+
interface Props$0 {
|
|
75
|
+
assets: AssetData;
|
|
76
|
+
count?: number;
|
|
77
|
+
hasNextPage?: boolean;
|
|
78
|
+
isLoading?: boolean;
|
|
79
|
+
loadMore?: () => void;
|
|
80
|
+
onSelect?: (assets: Asset[]) => void;
|
|
81
|
+
onToggle?: (assets: Asset[]) => void;
|
|
82
|
+
emptyStateElement?: React.ReactElement | null;
|
|
83
|
+
selectedAssetIds?: string[];
|
|
84
|
+
selectionMode?: SelectionMode;
|
|
85
|
+
theme?: Theme;
|
|
86
|
+
children?: React.ReactNode;
|
|
87
|
+
}
|
|
88
|
+
declare function AssetList({ assets, count, hasNextPage, isLoading, loadMore, onSelect, onToggle, emptyStateElement, selectedAssetIds, selectionMode, theme, children }: Props$0): JSX.Element;
|
|
89
|
+
interface Props$1 {
|
|
90
|
+
className?: string;
|
|
91
|
+
title?: string;
|
|
92
|
+
isDisabled?: boolean;
|
|
93
|
+
onClick?: React.MouseEventHandler;
|
|
94
|
+
kind?: Kind;
|
|
95
|
+
testId?: string;
|
|
96
|
+
children: React.ReactNode;
|
|
97
|
+
}
|
|
98
|
+
declare const Button: React.ForwardRefExoticComponent<Props$1 & React.RefAttributes<HTMLButtonElement>>;
|
|
99
|
+
interface CardProps {
|
|
100
|
+
alt?: string;
|
|
101
|
+
className?: string;
|
|
102
|
+
fadeIn?: boolean;
|
|
103
|
+
id?: string;
|
|
104
|
+
style?: React.CSSProperties;
|
|
105
|
+
stacked?: boolean;
|
|
106
|
+
title: React.ReactNode;
|
|
107
|
+
onClick?: (e: React.MouseEvent) => void;
|
|
108
|
+
children?: React.ReactNode;
|
|
109
|
+
["aria-selected"]?: boolean;
|
|
110
|
+
metaproperties?: MetapropertyType[];
|
|
111
|
+
}
|
|
112
|
+
declare function Card({ alt, className, fadeIn, id, style, stacked, title, onClick, children, metaproperties, ...props }: CardProps): JSX.Element;
|
|
113
|
+
interface CardImagesProps {
|
|
114
|
+
urls: string[];
|
|
115
|
+
totalCount: number;
|
|
116
|
+
alt: string;
|
|
117
|
+
}
|
|
118
|
+
declare function CardImages({ urls, totalCount, alt }: CardImagesProps): JSX.Element;
|
|
119
|
+
interface ImageProps {
|
|
120
|
+
url?: string;
|
|
121
|
+
cover?: boolean;
|
|
122
|
+
alt?: string;
|
|
123
|
+
}
|
|
124
|
+
declare function CardImage({ url, cover, alt }: ImageProps): JSX.Element;
|
|
125
|
+
interface Props$2 {
|
|
126
|
+
className?: string;
|
|
127
|
+
onClick?: () => void;
|
|
128
|
+
isChecked?: boolean;
|
|
129
|
+
title?: string;
|
|
130
|
+
}
|
|
131
|
+
declare function Checkbox({ className, onClick, isChecked, title }: Props$2): JSX.Element;
|
|
132
|
+
interface Props$3 {
|
|
133
|
+
className?: string;
|
|
134
|
+
onClick?: () => void;
|
|
135
|
+
children: React.ReactNode;
|
|
136
|
+
["data-testid"]?: string;
|
|
137
|
+
}
|
|
138
|
+
declare function Chip(props: Props$3): JSX.Element;
|
|
139
|
+
interface Props$4 {
|
|
140
|
+
className?: string;
|
|
141
|
+
buttonClassName?: string;
|
|
142
|
+
buttonKind?: Kind;
|
|
143
|
+
direction?: "Down" | "Up";
|
|
144
|
+
title: React.ReactNode;
|
|
145
|
+
alt?: string;
|
|
146
|
+
disabled?: boolean;
|
|
147
|
+
children: (toggle: () => void) => React.ReactNode;
|
|
148
|
+
}
|
|
149
|
+
declare function Dropdown({ buttonKind, direction, ...props }: Props$4): JSX.Element;
|
|
150
|
+
interface ListItemProps {
|
|
151
|
+
className?: string;
|
|
152
|
+
onClick?: () => void;
|
|
153
|
+
selected?: boolean;
|
|
154
|
+
children: React.ReactNode;
|
|
155
|
+
}
|
|
156
|
+
declare function DropdownListItem({ selected, ...props }: ListItemProps): JSX.Element;
|
|
157
|
+
interface SmartfilterType {
|
|
158
|
+
__typename: "Smartfilter";
|
|
159
|
+
id: string;
|
|
160
|
+
label: string;
|
|
161
|
+
metaproperties: MetapropertyType[];
|
|
162
|
+
icon?: string;
|
|
163
|
+
zIndex: number;
|
|
164
|
+
}
|
|
165
|
+
interface SmartfilterProps {
|
|
166
|
+
smartfilter: SmartfilterType;
|
|
167
|
+
selectedOptionIds: string[];
|
|
168
|
+
isLoading: boolean;
|
|
169
|
+
onAddOption: (metapropertyOption: MetapropertyOptionType) => void;
|
|
170
|
+
onRemoveOption: (metapropertyOption: MetapropertyOptionType) => void;
|
|
171
|
+
}
|
|
172
|
+
declare function SmartFilterContent(props: SmartfilterProps): JSX.Element;
|
|
173
|
+
interface Props$5 {
|
|
174
|
+
static?: React.ReactNode;
|
|
175
|
+
className: string;
|
|
176
|
+
children: React.ReactNode;
|
|
177
|
+
}
|
|
178
|
+
declare function HorizontalScroll(props: Props$5): JSX.Element;
|
|
179
|
+
interface Props$6 {
|
|
180
|
+
isLoading: boolean;
|
|
181
|
+
hasNextPage: boolean;
|
|
182
|
+
loadMore: () => void;
|
|
183
|
+
children: React.ReactNode;
|
|
184
|
+
}
|
|
185
|
+
declare function InfiniteScroll(props: Props$6): JSX.Element;
|
|
186
|
+
interface Props$7 {
|
|
187
|
+
children: React.ReactNode;
|
|
188
|
+
isOpen?: boolean;
|
|
189
|
+
style?: React.CSSProperties;
|
|
190
|
+
onClose?: () => void;
|
|
191
|
+
}
|
|
192
|
+
declare function Modal({ children, isOpen, style, onClose }: Props$7): JSX.Element | null;
|
|
193
|
+
interface Props$8 {
|
|
194
|
+
onReset: () => void;
|
|
195
|
+
}
|
|
196
|
+
declare function NoResults(props: Props$8): JSX.Element;
|
|
197
|
+
interface Props$9 {
|
|
198
|
+
error: Error;
|
|
199
|
+
onRetry: () => void;
|
|
200
|
+
}
|
|
201
|
+
declare function Oops({ error, onRetry }: Props$9): JSX.Element;
|
|
202
|
+
interface Props$10 {
|
|
203
|
+
className?: string;
|
|
204
|
+
active?: boolean;
|
|
205
|
+
onClick?: (e: React.MouseEvent) => void;
|
|
206
|
+
title?: string;
|
|
207
|
+
children: React.ReactNode;
|
|
208
|
+
tabIndex?: 0 | -1;
|
|
209
|
+
}
|
|
210
|
+
declare function OverlayButton({ title, onClick, active, className, children, ...props }: Props$10): JSX.Element;
|
|
211
|
+
/**
|
|
212
|
+
* This component will create a shadow root if it is the first ShadowRoot in the tree.
|
|
213
|
+
* Otherwise it will just render it's childred. This is useful as we don't always know
|
|
214
|
+
* which component will be first in the tree, especially when the components are used
|
|
215
|
+
* externally from the npm package.
|
|
216
|
+
*/
|
|
217
|
+
declare function ShadowRoot(props: {
|
|
218
|
+
children: React.ReactNode;
|
|
219
|
+
}): JSX.Element;
|
|
220
|
+
interface Props$11 {
|
|
221
|
+
width?: number;
|
|
222
|
+
className?: string;
|
|
223
|
+
}
|
|
224
|
+
declare function Skeleton({ width, className }: Props$11): JSX.Element;
|
|
225
|
+
interface Props$12 {
|
|
226
|
+
className?: string;
|
|
227
|
+
}
|
|
228
|
+
declare function Spinner(props: Props$12): JSX.Element;
|
|
229
|
+
export { AssetCard as Asset, Asset as displayAsset, AssetList, Button, Card, CardImages, CardImage, Checkbox, Chip, Dropdown, DropdownListItem, MetaPropertyFilterContent as Metaproperty, MetapropertyType as metaproperty, MetapropertyOptionComponent as MetapropertyOption, MetapropertyOptionType as metapropertyOption, SmartFilterContent as Smartfilter, SmartfilterType as smartfilter, HorizontalScroll, InfiniteScroll, Modal, NoResults, Oops, OverlayButton, ShadowRoot, Skeleton, Spinner };
|