@elliemae/ds-imagelibrarymodal 2.3.1-rc.2 → 3.0.0-alpha.2
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/dist/cjs/DSImageLibraryModal.js +122 -0
- package/dist/cjs/DSImageLibraryModal.js.map +7 -0
- package/dist/cjs/components/ImageLibraryModalImpl.js +216 -0
- package/dist/cjs/components/ImageLibraryModalImpl.js.map +7 -0
- package/dist/cjs/index.js +35 -0
- package/dist/cjs/index.js.map +7 -0
- package/dist/esm/DSImageLibraryModal.js +95 -0
- package/dist/esm/DSImageLibraryModal.js.map +7 -0
- package/dist/esm/components/ImageLibraryModalImpl.js +189 -0
- package/dist/esm/components/ImageLibraryModalImpl.js.map +7 -0
- package/dist/esm/index.js +6 -0
- package/dist/esm/index.js.map +7 -0
- package/package.json +33 -24
- package/cjs/DSImageLibraryModal.js +0 -64
- package/cjs/components/ImageLibraryModalImpl.js +0 -254
- package/cjs/index.js +0 -7
- package/esm/DSImageLibraryModal.js +0 -57
- package/esm/components/ImageLibraryModalImpl.js +0 -242
- package/esm/index.js +0 -1
- package/types/DSImageLibraryModal.d.ts +0 -35
- package/types/components/ImageLibraryModalImpl.d.ts +0 -16
- package/types/index.d.ts +0 -1
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
import 'core-js/modules/esnext.async-iterator.filter.js';
|
|
2
|
-
import 'core-js/modules/esnext.iterator.constructor.js';
|
|
3
|
-
import 'core-js/modules/esnext.iterator.filter.js';
|
|
4
|
-
import 'core-js/modules/esnext.async-iterator.for-each.js';
|
|
5
|
-
import 'core-js/modules/esnext.iterator.for-each.js';
|
|
6
|
-
import _defineProperty from '@babel/runtime/helpers/esm/defineProperty';
|
|
7
|
-
import _objectWithoutProperties from '@babel/runtime/helpers/esm/objectWithoutProperties';
|
|
8
|
-
import 'react';
|
|
9
|
-
import { MODAL_TYPE } from '@elliemae/ds-modal';
|
|
10
|
-
import { sizeOptions } from '@elliemae/ds-shared/constants';
|
|
11
|
-
import ImageLibraryModalImpl from './components/ImageLibraryModalImpl.js';
|
|
12
|
-
import { jsx } from 'react/jsx-runtime';
|
|
13
|
-
|
|
14
|
-
const _excluded = ["containerProps", "confirmLabel", "disableDoubleClick", "isOpen", "modalTitle", "modalType", "rejectLabel", "shouldCloseOnOverlayClick", "size", "imagesData", "onSelect"];
|
|
15
|
-
|
|
16
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
17
|
-
|
|
18
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
19
|
-
const modalTypes = Object.values(MODAL_TYPE);
|
|
20
|
-
|
|
21
|
-
const DSImageLibraryModal = _ref => {
|
|
22
|
-
let {
|
|
23
|
-
containerProps = {},
|
|
24
|
-
confirmLabel = 'Add',
|
|
25
|
-
disableDoubleClick = false,
|
|
26
|
-
isOpen = true,
|
|
27
|
-
modalTitle = 'Add Image',
|
|
28
|
-
modalType = modalTypes[2],
|
|
29
|
-
rejectLabel = 'Cancel',
|
|
30
|
-
shouldCloseOnOverlayClick = true,
|
|
31
|
-
size = sizeOptions[3],
|
|
32
|
-
imagesData = [{
|
|
33
|
-
url: 'https://www.freeiconspng.com/minicovers/no-image-icon-6.png',
|
|
34
|
-
name: 'no image',
|
|
35
|
-
createdBy: 'user:John Doe',
|
|
36
|
-
createdDate: '0000-01-01 00:00 AM UTC'
|
|
37
|
-
}],
|
|
38
|
-
onSelect = () => null
|
|
39
|
-
} = _ref,
|
|
40
|
-
rest = _objectWithoutProperties(_ref, _excluded);
|
|
41
|
-
|
|
42
|
-
return /*#__PURE__*/jsx(ImageLibraryModalImpl, _objectSpread({
|
|
43
|
-
confirmLabel: confirmLabel,
|
|
44
|
-
containerProps: containerProps,
|
|
45
|
-
disableDoubleClick: disableDoubleClick,
|
|
46
|
-
imagesData: imagesData,
|
|
47
|
-
isOpen: isOpen,
|
|
48
|
-
modalTitle: modalTitle,
|
|
49
|
-
modalType: modalType,
|
|
50
|
-
onSelect: onSelect,
|
|
51
|
-
rejectLabel: rejectLabel,
|
|
52
|
-
shouldCloseOnOverlayClick: shouldCloseOnOverlayClick,
|
|
53
|
-
size: size
|
|
54
|
-
}, rest));
|
|
55
|
-
};
|
|
56
|
-
|
|
57
|
-
export { DSImageLibraryModal as default };
|
|
@@ -1,242 +0,0 @@
|
|
|
1
|
-
import _objectWithoutProperties from '@babel/runtime/helpers/esm/objectWithoutProperties';
|
|
2
|
-
import _defineProperty from '@babel/runtime/helpers/esm/defineProperty';
|
|
3
|
-
import _jsx from '@babel/runtime/helpers/esm/jsx';
|
|
4
|
-
import 'core-js/modules/esnext.async-iterator.map.js';
|
|
5
|
-
import 'core-js/modules/esnext.iterator.map.js';
|
|
6
|
-
import 'core-js/modules/esnext.async-iterator.filter.js';
|
|
7
|
-
import 'core-js/modules/esnext.iterator.constructor.js';
|
|
8
|
-
import 'core-js/modules/esnext.iterator.filter.js';
|
|
9
|
-
import 'core-js/modules/esnext.async-iterator.for-each.js';
|
|
10
|
-
import 'core-js/modules/esnext.iterator.for-each.js';
|
|
11
|
-
import React from 'react';
|
|
12
|
-
import DSModal from '@elliemae/ds-modal';
|
|
13
|
-
import DSSpinner from '@elliemae/ds-spinner';
|
|
14
|
-
import { DSIconColors, DSIconSizes } from '@elliemae/ds-icon';
|
|
15
|
-
import { includes } from 'lodash';
|
|
16
|
-
import ImageLoader from 'react-loading-image';
|
|
17
|
-
import { ImageMissing } from '@elliemae/ds-icons';
|
|
18
|
-
import { jsx } from 'react/jsx-runtime';
|
|
19
|
-
|
|
20
|
-
const _excluded = ["containerProps", "imagesData", "onSelect", "disableDoubleClick"];
|
|
21
|
-
|
|
22
|
-
var _DSSpinner;
|
|
23
|
-
|
|
24
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
25
|
-
|
|
26
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
27
|
-
const elementClassName = 'imglibmodal-element';
|
|
28
|
-
class ImageLibraryModalImpl extends React.PureComponent {
|
|
29
|
-
constructor(props) {
|
|
30
|
-
super(props);
|
|
31
|
-
|
|
32
|
-
this.onReject = () => {
|
|
33
|
-
const {
|
|
34
|
-
onReject,
|
|
35
|
-
onClose
|
|
36
|
-
} = this.props;
|
|
37
|
-
|
|
38
|
-
if (onReject) {
|
|
39
|
-
onReject();
|
|
40
|
-
} else {
|
|
41
|
-
onClose();
|
|
42
|
-
}
|
|
43
|
-
};
|
|
44
|
-
|
|
45
|
-
this.handleElementClick = (e, image) => {
|
|
46
|
-
if (e.key && e.key !== ' ') {
|
|
47
|
-
return;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
const {
|
|
51
|
-
selected
|
|
52
|
-
} = this.state;
|
|
53
|
-
const {
|
|
54
|
-
disableDoubleClick,
|
|
55
|
-
onConfirm,
|
|
56
|
-
onSelect
|
|
57
|
-
} = this.props;
|
|
58
|
-
|
|
59
|
-
if (image === selected && onConfirm && !disableDoubleClick) {
|
|
60
|
-
onConfirm();
|
|
61
|
-
return;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
this.setState({
|
|
65
|
-
selected: image,
|
|
66
|
-
user: this.getUser(image)
|
|
67
|
-
});
|
|
68
|
-
|
|
69
|
-
if (onSelect) {
|
|
70
|
-
onSelect(image);
|
|
71
|
-
}
|
|
72
|
-
};
|
|
73
|
-
|
|
74
|
-
this.renderElements = () => {
|
|
75
|
-
const {
|
|
76
|
-
imagesData
|
|
77
|
-
} = this.props;
|
|
78
|
-
|
|
79
|
-
if (!imagesData) {
|
|
80
|
-
return 'Empty';
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
const {
|
|
84
|
-
selected
|
|
85
|
-
} = this.state;
|
|
86
|
-
return imagesData.map((image, idx) => {
|
|
87
|
-
const extras = {};
|
|
88
|
-
const {
|
|
89
|
-
name,
|
|
90
|
-
id
|
|
91
|
-
} = image;
|
|
92
|
-
|
|
93
|
-
if (this.focusFirst && idx === 0) {
|
|
94
|
-
extras.ref = element => element && element.focus();
|
|
95
|
-
|
|
96
|
-
this.focusFirst = undefined;
|
|
97
|
-
} else if (selected && name === selected.name) {
|
|
98
|
-
extras.ref = element => element && element.focus();
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
return /*#__PURE__*/jsx("div", _objectSpread(_objectSpread({
|
|
102
|
-
className: elementClassName,
|
|
103
|
-
onClick: e => this.handleElementClick(e, image),
|
|
104
|
-
onKeyUp: e => this.handleElementClick(e, image),
|
|
105
|
-
role: "button",
|
|
106
|
-
tabIndex: 0
|
|
107
|
-
}, extras), {}, {
|
|
108
|
-
children: /*#__PURE__*/_jsx("div", {
|
|
109
|
-
className: "content"
|
|
110
|
-
}, void 0, name)
|
|
111
|
-
}), id || "".concat(name, "_").concat(idx));
|
|
112
|
-
});
|
|
113
|
-
};
|
|
114
|
-
|
|
115
|
-
this.renderSpinner = () => _DSSpinner || (_DSSpinner = /*#__PURE__*/_jsx(DSSpinner, {
|
|
116
|
-
message: "Loading...",
|
|
117
|
-
size: "m"
|
|
118
|
-
}));
|
|
119
|
-
|
|
120
|
-
this.renderError = () => /*#__PURE__*/_jsx(ImageMissing, {
|
|
121
|
-
color: DSIconColors.NEUTRAL,
|
|
122
|
-
size: DSIconSizes.M
|
|
123
|
-
});
|
|
124
|
-
|
|
125
|
-
this.state = {
|
|
126
|
-
selected: undefined,
|
|
127
|
-
user: undefined
|
|
128
|
-
};
|
|
129
|
-
this.preventSpacebarScroll();
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
componentDidMount() {
|
|
133
|
-
const {
|
|
134
|
-
imagesData
|
|
135
|
-
} = this.props;
|
|
136
|
-
|
|
137
|
-
if (imagesData) {
|
|
138
|
-
this.handleElementClick({}, imagesData[0]);
|
|
139
|
-
this.focusFirst = true;
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
getDerivedStateFromProps(nextProps) {
|
|
144
|
-
const {
|
|
145
|
-
imagesData
|
|
146
|
-
} = this.props;
|
|
147
|
-
|
|
148
|
-
if (!imagesData && nextProps.imagesData) {
|
|
149
|
-
this.setState({
|
|
150
|
-
selected: imagesData[0]
|
|
151
|
-
});
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
getUser(selected) {
|
|
156
|
-
if (!selected) {
|
|
157
|
-
return '';
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
const index = selected.createdBy.lastIndexOf('user:');
|
|
161
|
-
|
|
162
|
-
if (index === -1) {
|
|
163
|
-
return selected.createdBy;
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
return selected.createdBy.substring(index + 5);
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
preventSpacebarScroll() {
|
|
170
|
-
document.onkeypress = function (e) {
|
|
171
|
-
if (!includes(e.target.className, elementClassName)) {
|
|
172
|
-
return true;
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
e = e || window.event;
|
|
176
|
-
const charCode = e.keyCode || e.which;
|
|
177
|
-
|
|
178
|
-
if (charCode === 32) {
|
|
179
|
-
e.preventDefault();
|
|
180
|
-
return false;
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
return true;
|
|
184
|
-
};
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
drawDiv(className, content) {
|
|
188
|
-
return /*#__PURE__*/_jsx("div", {
|
|
189
|
-
className: className
|
|
190
|
-
}, void 0, content);
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
drawLabel(className, label, value) {
|
|
194
|
-
return /*#__PURE__*/_jsx("div", {
|
|
195
|
-
className: className
|
|
196
|
-
}, void 0, /*#__PURE__*/_jsx("span", {
|
|
197
|
-
className: "label"
|
|
198
|
-
}, void 0, label), /*#__PURE__*/_jsx("span", {
|
|
199
|
-
className: "value"
|
|
200
|
-
}, void 0, value));
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
render() {
|
|
204
|
-
const {
|
|
205
|
-
selected,
|
|
206
|
-
user
|
|
207
|
-
} = this.state;
|
|
208
|
-
|
|
209
|
-
const _this$props = this.props,
|
|
210
|
-
{
|
|
211
|
-
containerProps,
|
|
212
|
-
imagesData,
|
|
213
|
-
onSelect,
|
|
214
|
-
disableDoubleClick
|
|
215
|
-
} = _this$props,
|
|
216
|
-
modalProps = _objectWithoutProperties(_this$props, _excluded);
|
|
217
|
-
|
|
218
|
-
return /*#__PURE__*/jsx(DSModal, _objectSpread(_objectSpread({
|
|
219
|
-
containerProps: containerProps
|
|
220
|
-
}, modalProps), {}, {
|
|
221
|
-
className: "em-ds-modal-image-library",
|
|
222
|
-
onReject: this.onReject,
|
|
223
|
-
children: /*#__PURE__*/_jsx("div", {
|
|
224
|
-
className: "wrapper"
|
|
225
|
-
}, void 0, /*#__PURE__*/_jsx("div", {
|
|
226
|
-
className: "col-1"
|
|
227
|
-
}, void 0, this.drawDiv('title', 'Company Images'), this.renderElements()), /*#__PURE__*/_jsx("div", {
|
|
228
|
-
className: "col-2"
|
|
229
|
-
}, void 0, this.drawDiv('title', selected ? selected.name : ''), /*#__PURE__*/_jsx(ImageLoader, {
|
|
230
|
-
className: "image-loader",
|
|
231
|
-
error: this.renderError,
|
|
232
|
-
loading: this.renderSpinner,
|
|
233
|
-
src: selected ? selected.url : ''
|
|
234
|
-
}), selected && /*#__PURE__*/_jsx("div", {
|
|
235
|
-
className: "info"
|
|
236
|
-
}, void 0, this.drawLabel('info-element', 'Created Date:', selected.createdDate), this.drawLabel('info-element', 'Created By:', user))))
|
|
237
|
-
}));
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
}
|
|
241
|
-
|
|
242
|
-
export { ImageLibraryModalImpl as default };
|
package/esm/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { default } from './DSImageLibraryModal.js';
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
|
-
import PropTypes from 'prop-types';
|
|
3
|
-
declare const DSImageLibraryModal: {
|
|
4
|
-
({ containerProps, confirmLabel, disableDoubleClick, isOpen, modalTitle, modalType, rejectLabel, shouldCloseOnOverlayClick, size, imagesData, onSelect, ...rest }: {
|
|
5
|
-
[x: string]: any;
|
|
6
|
-
containerProps?: {} | undefined;
|
|
7
|
-
confirmLabel?: string | undefined;
|
|
8
|
-
disableDoubleClick?: boolean | undefined;
|
|
9
|
-
isOpen?: boolean | undefined;
|
|
10
|
-
modalTitle?: string | undefined;
|
|
11
|
-
modalType?: string | undefined;
|
|
12
|
-
rejectLabel?: string | undefined;
|
|
13
|
-
shouldCloseOnOverlayClick?: boolean | undefined;
|
|
14
|
-
size?: any;
|
|
15
|
-
imagesData?: {
|
|
16
|
-
url: string;
|
|
17
|
-
name: string;
|
|
18
|
-
createdBy: string;
|
|
19
|
-
createdDate: string;
|
|
20
|
-
}[] | undefined;
|
|
21
|
-
onSelect?: (() => null) | undefined;
|
|
22
|
-
}): JSX.Element;
|
|
23
|
-
/** Inherits DSModal props */
|
|
24
|
-
propTypes: {
|
|
25
|
-
containerProps: PropTypes.Requireable<PropTypes.InferProps<{}>>;
|
|
26
|
-
/** List of images src */
|
|
27
|
-
imagesData: PropTypes.Requireable<(PropTypes.InferProps<{
|
|
28
|
-
url: PropTypes.Requireable<string>;
|
|
29
|
-
name: PropTypes.Requireable<string>;
|
|
30
|
-
}> | null | undefined)[]>;
|
|
31
|
-
/** Handler when user selects an image */
|
|
32
|
-
onSelect: PropTypes.Requireable<(...args: any[]) => any>;
|
|
33
|
-
};
|
|
34
|
-
};
|
|
35
|
-
export default DSImageLibraryModal;
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
export default class ImageLibraryModalImpl extends React.PureComponent {
|
|
3
|
-
constructor(props: any);
|
|
4
|
-
componentDidMount(): void;
|
|
5
|
-
getDerivedStateFromProps(nextProps: any): void;
|
|
6
|
-
onReject: () => void;
|
|
7
|
-
getUser(selected: any): any;
|
|
8
|
-
handleElementClick: (e: any, image: any) => void;
|
|
9
|
-
preventSpacebarScroll(): void;
|
|
10
|
-
drawDiv(className: any, content: any): JSX.Element;
|
|
11
|
-
drawLabel(className: any, label: any, value: any): JSX.Element;
|
|
12
|
-
renderElements: () => any;
|
|
13
|
-
renderSpinner: () => JSX.Element;
|
|
14
|
-
renderError: () => JSX.Element;
|
|
15
|
-
render(): JSX.Element;
|
|
16
|
-
}
|
package/types/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { default } from './DSImageLibraryModal';
|