@bynder/compact-view 2.4.0 → 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,239 +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 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 = {
51
36
  tag: "Loading";
52
- value: (null | undefined | data);
37
+ value: undefined | Asset[];
53
38
  } | {
54
39
  tag: "Loaded";
55
- value: data;
56
- } | {
57
- tag: "Failure";
58
- value: string;
59
- }; // tslint:disable-next-line:interface-over-type-literal
60
- // tslint:disable-next-line:interface-over-type-literal
61
- // tslint:disable-next-line:interface-over-type-literal
62
- declare const AssetList: React.ComponentType<{
63
- readonly assets: data<Asset_asset[]>;
64
- readonly children?: React.ReactNode;
65
- readonly count?: number;
66
- readonly hasNextPage?: boolean;
67
- readonly isLoading?: boolean;
68
- readonly loadMore?: () => void;
69
- readonly onSelect?: (_1: Asset_asset[]) => void;
70
- readonly onToggle?: (_1: Asset_asset[]) => void;
71
- readonly renderAsset?: (_1: Asset_asset, _2: {
72
- readonly index: number;
73
- readonly fadeIn: boolean;
74
- readonly isSelected: boolean;
75
- readonly onClick: ((_1: Asset_asset) => void);
76
- }) => JSX.Element;
77
- readonly renderEmptyState?: () => JSX.Element;
78
- readonly selectedAssetIds?: string[];
79
- readonly selectionMode?: ConfigProvider_selectionMode;
80
- readonly theme?: Theming_theme;
81
- }>;
82
- type Mouse_t = React.MouseEvent;
83
- type ReactEvent_Mouse_t = Mouse_t;
84
- type kind = "Flat" | "Primary" | "Secondary" | "FlatSm" | "PrimarySm" | "SecondarySm"; // tslint:disable-next-line:interface-over-type-literal
85
- // tslint:disable-next-line:interface-over-type-literal
86
- // tslint:disable-next-line:interface-over-type-literal
87
- declare const Button: React.ComponentType<{
88
- readonly children: React.ReactNode;
89
- readonly className?: string;
90
- readonly disabled?: boolean;
91
- readonly kind?: kind;
92
- readonly onClick?: (_1: ReactEvent_Mouse_t) => void;
93
- readonly title?: string;
94
- }>;
95
- type style = React.CSSProperties;
96
- type ReactDOMRe_style = style;
97
- declare const Image_make: React.ComponentType<{
98
- readonly cover?: boolean;
99
- readonly url?: string;
100
- }>; // tslint:disable-next-line:interface-over-type-literal
101
- // tslint:disable-next-line:interface-over-type-literal
102
- // tslint:disable-next-line:interface-over-type-literal
103
- declare const Images_make: React.ComponentType<{
104
- readonly totalCount: number;
105
- readonly urls: string[];
106
- }>; // tslint:disable-next-line:interface-over-type-literal
107
- // tslint:disable-next-line:interface-over-type-literal
108
- // tslint:disable-next-line:interface-over-type-literal
109
- declare const Card: React.ComponentType<{
110
- readonly alt?: string;
111
- readonly children?: React.ReactNode;
112
- readonly className?: string;
113
- readonly fadeIn?: boolean;
114
- readonly id?: string;
115
- readonly onClick?: (_1: ReactEvent_Mouse_t) => void;
116
- readonly stacked?: boolean;
117
- readonly style?: ReactDOMRe_style;
118
- readonly title: JSX.Element;
119
- }>;
120
- declare const Checkbox: React.ComponentType<{
121
- readonly checked?: boolean;
122
- readonly className?: string;
123
- readonly onClick?: (_1: ReactEvent_Mouse_t) => void;
124
- }>;
125
- declare const Chip: React.ComponentType<{
126
- readonly children: React.ReactNode;
127
- readonly className?: string;
128
- readonly onClick?: (_1: ReactEvent_Mouse_t) => void;
129
- }>;
130
- type Button_kind = kind;
131
- declare const ListItem_make: React.ComponentType<{
132
- readonly children: React.ReactNode;
133
- readonly className?: string;
134
- readonly onClick?: (_1: ReactEvent_Mouse_t) => void;
135
- readonly selected?: boolean;
136
- }>; // tslint:disable-next-line:interface-over-type-literal
137
- // tslint:disable-next-line:interface-over-type-literal
138
- // tslint:disable-next-line:interface-over-type-literal
139
- declare const Dropdown: React.ComponentType<{
140
- readonly alt?: string;
141
- readonly buttonClassName?: string;
142
- readonly buttonKind?: Button_kind;
143
- readonly children: (_1: {
144
- readonly toggle: ((_1: any) => void);
145
- }) => JSX.Element;
146
- readonly className?: string;
147
- readonly direction?: "Down" | "Up";
148
- readonly disabled?: boolean;
149
- readonly title: JSX.Element;
150
- }>;
151
- // tslint:disable-next-line:interface-over-type-literal
152
- type MetapropertyOption_t = {
153
- readonly id: string;
154
- readonly label: string;
155
- readonly assetCount: number;
156
- }; // tslint:disable-next-line:interface-over-type-literal
157
- // tslint:disable-next-line:interface-over-type-literal
158
- type Metaproperty_t = {
159
- readonly id: string;
160
- readonly label: string;
161
- readonly options: MetapropertyOption_t[];
162
- }; // tslint:disable-next-line:interface-over-type-literal
163
- type Smartfilter_t = {
164
- readonly id: string;
165
- readonly label: string;
166
- readonly metaproperties: Metaproperty_t[];
167
- readonly icon?: string;
168
- readonly zIndex: number;
169
- }; // tslint:disable-next-line:interface-over-type-literal
170
- // tslint:disable-next-line:interface-over-type-literal
171
- // tslint:disable-next-line:interface-over-type-literal
172
- declare const MetapropertyOption_make: React.ComponentType<{
173
- readonly isLoading?: boolean;
174
- readonly mpo: MetapropertyOption_t;
175
- readonly onAddOption: (_1: MetapropertyOption_t) => void;
176
- readonly onRemoveOption: (_1: MetapropertyOption_t) => void;
177
- readonly selectedOptionIds?: string[];
178
- }>; // tslint:disable-next-line:interface-over-type-literal
179
- // tslint:disable-next-line:interface-over-type-literal
180
- // tslint:disable-next-line:interface-over-type-literal
181
- declare const Metaproperty_make: React.ComponentType<{
182
- readonly isLoading?: boolean;
183
- readonly metaproperty: Metaproperty_t;
184
- readonly onAddOption: (_1: MetapropertyOption_t) => void;
185
- readonly onRemoveOption: (_1: MetapropertyOption_t) => void;
186
- readonly selectedOptionIds: string[];
187
- }>; // tslint:disable-next-line:interface-over-type-literal
188
- // tslint:disable-next-line:interface-over-type-literal
189
- // tslint:disable-next-line:interface-over-type-literal
190
- declare const Smartfilter_make: React.ComponentType<{
191
- readonly isLoading?: boolean;
192
- readonly onAddOption: (_1: MetapropertyOption_t) => void;
193
- readonly onRemoveOption: (_1: MetapropertyOption_t) => void;
194
- readonly selectedOptionIds: string[];
195
- readonly smartfilter: Smartfilter_t;
196
- }>;
197
- declare const HorizontalScroll: React.ComponentType<{
198
- readonly children: React.ReactNode;
199
- readonly className?: string;
200
- readonly static?: JSX.Element;
201
- }>;
202
- declare const InfiniteScroll: React.ComponentType<{
203
- readonly children: React.ReactNode;
204
- readonly hasNextPage: boolean;
205
- readonly isLoading: boolean;
206
- readonly loadMore: () => void;
207
- }>;
208
- declare const Modal: React.ComponentType<{
209
- readonly children: React.ReactNode;
210
- readonly isOpen?: boolean;
211
- readonly onClose?: () => void;
212
- readonly style?: ReactDOMRe_style;
213
- }>;
214
- declare const NoResults: React.ComponentType<{
215
- readonly onReset: () => void;
216
- }>;
217
- declare const Oops: React.ComponentType<{
218
- readonly error: any;
219
- readonly onRetry: () => void;
220
- }>;
221
- declare const OverlayButton: React.ComponentType<{
222
- readonly active?: boolean;
223
- readonly children: React.ReactNode;
224
- readonly className?: string;
225
- readonly onClick?: (_1: ReactEvent_Mouse_t) => void;
226
- readonly title?: string;
227
- }>;
228
- declare const ShadowRoot: React.ComponentType<{
229
- readonly children: React.ReactNode;
230
- readonly topLevel?: boolean;
231
- }>;
232
- declare const Skeleton: React.ComponentType<{
233
- readonly className?: string;
234
- readonly width?: number;
235
- }>;
236
- declare const Spinner: React.ComponentType<{
237
- readonly className?: string;
238
- }>;
239
- 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 };