@bynder/compact-view 2.4.3 → 2.5.0

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