@elliemae/ds-imagelibrarymodal 2.3.0-alpha.9 → 2.3.0-next.3
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/cjs/DSImageLibraryModal.js +64 -0
- package/cjs/components/ImageLibraryModalImpl.js +254 -0
- package/cjs/index.js +7 -0
- package/esm/DSImageLibraryModal.js +57 -0
- package/esm/components/ImageLibraryModalImpl.js +242 -0
- package/esm/index.js +1 -0
- package/package.json +25 -27
- package/{dist/types → types}/DSImageLibraryModal.d.ts +1 -1
- package/{dist/types → types}/components/ImageLibraryModalImpl.d.ts +0 -0
- package/{dist/types → types}/index.d.ts +0 -0
- package/dist/cjs/DSImageLibraryModal.js +0 -83
- package/dist/cjs/DSImageLibraryModal.js.map +0 -7
- package/dist/cjs/components/ImageLibraryModalImpl.js +0 -188
- package/dist/cjs/components/ImageLibraryModalImpl.js.map +0 -7
- package/dist/cjs/index.js +0 -35
- package/dist/cjs/index.js.map +0 -7
- package/dist/esm/DSImageLibraryModal.js +0 -54
- package/dist/esm/DSImageLibraryModal.js.map +0 -7
- package/dist/esm/components/ImageLibraryModalImpl.js +0 -159
- package/dist/esm/components/ImageLibraryModalImpl.js.map +0 -7
- package/dist/esm/index.js +0 -6
- package/dist/esm/index.js.map +0 -7
|
@@ -1,159 +0,0 @@
|
|
|
1
|
-
import * as React from "react";
|
|
2
|
-
import React2 from "react";
|
|
3
|
-
import DSModal from "@elliemae/ds-modal";
|
|
4
|
-
import DSSpinner from "@elliemae/ds-spinner";
|
|
5
|
-
import { DSIconSizes as ICONS_SIZES, DSIconColors as ICONS_COLORS } from "@elliemae/ds-icon";
|
|
6
|
-
import { includes } from "lodash";
|
|
7
|
-
import ImageLoader from "react-loading-image";
|
|
8
|
-
import { ImageMissing } from "@elliemae/ds-icons";
|
|
9
|
-
const elementClassName = "imglibmodal-element";
|
|
10
|
-
class ImageLibraryModalImpl extends React2.PureComponent {
|
|
11
|
-
constructor(props) {
|
|
12
|
-
super(props);
|
|
13
|
-
this.onReject = () => {
|
|
14
|
-
const { onReject, onClose } = this.props;
|
|
15
|
-
if (onReject) {
|
|
16
|
-
onReject();
|
|
17
|
-
} else {
|
|
18
|
-
onClose();
|
|
19
|
-
}
|
|
20
|
-
};
|
|
21
|
-
this.handleElementClick = (e, image) => {
|
|
22
|
-
if (e.key && e.key !== " ") {
|
|
23
|
-
return;
|
|
24
|
-
}
|
|
25
|
-
const { selected } = this.state;
|
|
26
|
-
const { disableDoubleClick, onConfirm, onSelect } = this.props;
|
|
27
|
-
if (image === selected && onConfirm && !disableDoubleClick) {
|
|
28
|
-
onConfirm();
|
|
29
|
-
return;
|
|
30
|
-
}
|
|
31
|
-
this.setState({
|
|
32
|
-
selected: image,
|
|
33
|
-
user: this.getUser(image)
|
|
34
|
-
});
|
|
35
|
-
if (onSelect) {
|
|
36
|
-
onSelect(image);
|
|
37
|
-
}
|
|
38
|
-
};
|
|
39
|
-
this.renderElements = () => {
|
|
40
|
-
const { imagesData } = this.props;
|
|
41
|
-
if (!imagesData) {
|
|
42
|
-
return "Empty";
|
|
43
|
-
}
|
|
44
|
-
const { selected } = this.state;
|
|
45
|
-
return imagesData.map((image, idx) => {
|
|
46
|
-
const extras = {};
|
|
47
|
-
const { name, id } = image;
|
|
48
|
-
if (this.focusFirst && idx === 0) {
|
|
49
|
-
extras.ref = (element) => element && element.focus();
|
|
50
|
-
this.focusFirst = void 0;
|
|
51
|
-
} else if (selected && name === selected.name) {
|
|
52
|
-
extras.ref = (element) => element && element.focus();
|
|
53
|
-
}
|
|
54
|
-
return /* @__PURE__ */ React2.createElement("div", {
|
|
55
|
-
key: id || `${name}_${idx}`,
|
|
56
|
-
className: elementClassName,
|
|
57
|
-
onClick: (e) => this.handleElementClick(e, image),
|
|
58
|
-
onKeyUp: (e) => this.handleElementClick(e, image),
|
|
59
|
-
role: "button",
|
|
60
|
-
tabIndex: 0,
|
|
61
|
-
...extras
|
|
62
|
-
}, /* @__PURE__ */ React2.createElement("div", {
|
|
63
|
-
className: "content"
|
|
64
|
-
}, name));
|
|
65
|
-
});
|
|
66
|
-
};
|
|
67
|
-
this.renderSpinner = () => /* @__PURE__ */ React2.createElement(DSSpinner, {
|
|
68
|
-
message: "Loading...",
|
|
69
|
-
size: "m"
|
|
70
|
-
});
|
|
71
|
-
this.renderError = () => /* @__PURE__ */ React2.createElement(ImageMissing, {
|
|
72
|
-
color: ICONS_COLORS.NEUTRAL,
|
|
73
|
-
size: ICONS_SIZES.M
|
|
74
|
-
});
|
|
75
|
-
this.state = {
|
|
76
|
-
selected: void 0,
|
|
77
|
-
user: void 0
|
|
78
|
-
};
|
|
79
|
-
this.preventSpacebarScroll();
|
|
80
|
-
}
|
|
81
|
-
componentDidMount() {
|
|
82
|
-
const { imagesData } = this.props;
|
|
83
|
-
if (imagesData) {
|
|
84
|
-
this.handleElementClick({}, imagesData[0]);
|
|
85
|
-
this.focusFirst = true;
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
getDerivedStateFromProps(nextProps) {
|
|
89
|
-
const { imagesData } = this.props;
|
|
90
|
-
if (!imagesData && nextProps.imagesData) {
|
|
91
|
-
this.setState({ selected: imagesData[0] });
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
getUser(selected) {
|
|
95
|
-
if (!selected) {
|
|
96
|
-
return "";
|
|
97
|
-
}
|
|
98
|
-
const index = selected.createdBy.lastIndexOf("user:");
|
|
99
|
-
if (index === -1) {
|
|
100
|
-
return selected.createdBy;
|
|
101
|
-
}
|
|
102
|
-
return selected.createdBy.substring(index + 5);
|
|
103
|
-
}
|
|
104
|
-
preventSpacebarScroll() {
|
|
105
|
-
document.onkeypress = function(e) {
|
|
106
|
-
if (!includes(e.target.className, elementClassName)) {
|
|
107
|
-
return true;
|
|
108
|
-
}
|
|
109
|
-
e = e || window.event;
|
|
110
|
-
const charCode = e.keyCode || e.which;
|
|
111
|
-
if (charCode === 32) {
|
|
112
|
-
e.preventDefault();
|
|
113
|
-
return false;
|
|
114
|
-
}
|
|
115
|
-
return true;
|
|
116
|
-
};
|
|
117
|
-
}
|
|
118
|
-
drawDiv(className, content) {
|
|
119
|
-
return /* @__PURE__ */ React2.createElement("div", {
|
|
120
|
-
className
|
|
121
|
-
}, content);
|
|
122
|
-
}
|
|
123
|
-
drawLabel(className, label, value) {
|
|
124
|
-
return /* @__PURE__ */ React2.createElement("div", {
|
|
125
|
-
className
|
|
126
|
-
}, /* @__PURE__ */ React2.createElement("span", {
|
|
127
|
-
className: "label"
|
|
128
|
-
}, label), /* @__PURE__ */ React2.createElement("span", {
|
|
129
|
-
className: "value"
|
|
130
|
-
}, value));
|
|
131
|
-
}
|
|
132
|
-
render() {
|
|
133
|
-
const { selected, user } = this.state;
|
|
134
|
-
const { containerProps, imagesData, onSelect, disableDoubleClick, ...modalProps } = this.props;
|
|
135
|
-
return /* @__PURE__ */ React2.createElement(DSModal, {
|
|
136
|
-
containerProps,
|
|
137
|
-
...modalProps,
|
|
138
|
-
className: "em-ds-modal-image-library",
|
|
139
|
-
onReject: this.onReject
|
|
140
|
-
}, /* @__PURE__ */ React2.createElement("div", {
|
|
141
|
-
className: "wrapper"
|
|
142
|
-
}, /* @__PURE__ */ React2.createElement("div", {
|
|
143
|
-
className: "col-1"
|
|
144
|
-
}, this.drawDiv("title", "Company Images"), this.renderElements()), /* @__PURE__ */ React2.createElement("div", {
|
|
145
|
-
className: "col-2"
|
|
146
|
-
}, this.drawDiv("title", selected ? selected.name : ""), /* @__PURE__ */ React2.createElement(ImageLoader, {
|
|
147
|
-
className: "image-loader",
|
|
148
|
-
error: this.renderError,
|
|
149
|
-
loading: this.renderSpinner,
|
|
150
|
-
src: selected ? selected.url : ""
|
|
151
|
-
}), selected && /* @__PURE__ */ React2.createElement("div", {
|
|
152
|
-
className: "info"
|
|
153
|
-
}, this.drawLabel("info-element", "Created Date:", selected.createdDate), this.drawLabel("info-element", "Created By:", user)))));
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
export {
|
|
157
|
-
ImageLibraryModalImpl as default
|
|
158
|
-
};
|
|
159
|
-
//# sourceMappingURL=ImageLibraryModalImpl.js.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../../../scripts/build/transpile/react-shim.js", "../../../src/components/ImageLibraryModalImpl.tsx"],
|
|
4
|
-
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable max-lines */\nimport React from 'react';\nimport DSModal from '@elliemae/ds-modal';\nimport DSSpinner from '@elliemae/ds-spinner';\nimport { DSIconSizes as ICONS_SIZES, DSIconColors as ICONS_COLORS } from '@elliemae/ds-icon';\nimport { includes } from 'lodash';\nimport ImageLoader from 'react-loading-image';\nimport { ImageMissing } from '@elliemae/ds-icons';\n\nconst elementClassName = 'imglibmodal-element';\n\nexport default class ImageLibraryModalImpl extends React.PureComponent {\n constructor(props) {\n super(props);\n this.state = {\n selected: undefined,\n user: undefined,\n };\n this.preventSpacebarScroll();\n }\n\n componentDidMount() {\n const { imagesData } = this.props;\n if (imagesData) {\n this.handleElementClick({}, imagesData[0]);\n this.focusFirst = true;\n }\n }\n\n getDerivedStateFromProps(nextProps) {\n const { imagesData } = this.props;\n if (!imagesData && nextProps.imagesData) {\n this.setState({ selected: imagesData[0] });\n }\n }\n\n onReject = () => {\n const { onReject, onClose } = this.props;\n if (onReject) {\n onReject();\n } else {\n onClose();\n }\n };\n\n getUser(selected) {\n if (!selected) {\n return '';\n }\n const index = selected.createdBy.lastIndexOf('user:');\n if (index === -1) {\n return selected.createdBy;\n }\n return selected.createdBy.substring(index + 5);\n }\n\n handleElementClick = (e, image) => {\n if (e.key && e.key !== ' ') {\n return;\n }\n const { selected } = this.state;\n const { disableDoubleClick, onConfirm, onSelect } = this.props;\n if (image === selected && onConfirm && !disableDoubleClick) {\n onConfirm();\n return;\n }\n this.setState({\n selected: image,\n user: this.getUser(image),\n });\n if (onSelect) {\n onSelect(image);\n }\n };\n\n preventSpacebarScroll() {\n document.onkeypress = function (e) {\n if (!includes(e.target.className, elementClassName)) {\n return true;\n }\n e = e || window.event;\n const charCode = e.keyCode || e.which;\n if (charCode === 32) {\n e.preventDefault();\n return false;\n }\n return true;\n };\n }\n\n drawDiv(className, content) {\n return <div className={className}>{content}</div>;\n }\n\n drawLabel(className, label, value) {\n return (\n <div className={className}>\n <span className=\"label\">{label}</span>\n <span className=\"value\">{value}</span>\n </div>\n );\n }\n\n renderElements = () => {\n const { imagesData } = this.props;\n if (!imagesData) {\n return 'Empty';\n }\n const { selected } = this.state;\n return imagesData.map((image, idx) => {\n const extras = {};\n const { name, id } = image;\n if (this.focusFirst && idx === 0) {\n extras.ref = (element) => element && element.focus();\n this.focusFirst = undefined;\n } else if (selected && name === selected.name) {\n extras.ref = (element) => element && element.focus();\n }\n return (\n <div\n key={id || `${name}_${idx}`}\n className={elementClassName}\n onClick={(e) => this.handleElementClick(e, image)}\n onKeyUp={(e) => this.handleElementClick(e, image)}\n role=\"button\"\n tabIndex={0}\n {...extras}\n >\n <div className=\"content\">{name}</div>\n </div>\n );\n });\n };\n\n renderSpinner = () => <DSSpinner message=\"Loading...\" size=\"m\" />;\n\n renderError = () => <ImageMissing color={ICONS_COLORS.NEUTRAL} size={ICONS_SIZES.M} />;\n\n render() {\n const { selected, user } = this.state;\n const { containerProps, imagesData, onSelect, disableDoubleClick, ...modalProps } = this.props;\n return (\n <DSModal\n containerProps={containerProps}\n {...modalProps}\n className=\"em-ds-modal-image-library\"\n onReject={this.onReject}\n >\n <div className=\"wrapper\">\n <div className=\"col-1\">\n {this.drawDiv('title', 'Company Images')}\n {this.renderElements()}\n </div>\n <div className=\"col-2\">\n {this.drawDiv('title', selected ? selected.name : '')}\n <ImageLoader\n className=\"image-loader\"\n error={this.renderError}\n loading={this.renderSpinner}\n src={selected ? selected.url : ''}\n />\n {selected && (\n <div className=\"info\">\n {this.drawLabel('info-element', 'Created Date:', selected.createdDate)}\n {this.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ACjC,WACE,qCAAC,OAAD;AAAA,MAAK;AAAA,OACH,qCAAC,QAAD;AAAA,MAAM,WAAU;AAAA,OAAS,QACzB,qCAAC,QAAD;AAAA,MAAM,WAAU;AAAA,OAAS;AAAA;AAAA,EAwC/B,SAAS;AACP,UAAM,EAAE,UAAU,SAAS,KAAK;AAChC,UAAM,EAAE,gBAAgB,YAAY,UAAU,uBAAuB,eAAe,KAAK;AACzF,WACE,qCAAC,SAAD;AAAA,MACE;AAAA,SACI;AAAA,MACJ,WAAU;AAAA,MACV,UAAU,KAAK;AAAA,OAEf,qCAAC,OAAD;AAAA,MAAK,WAAU;AAAA,OACb,qCAAC,OAAD;AAAA,MAAK,WAAU;AAAA,OACZ,KAAK,QAAQ,SAAS,mBACtB,KAAK,mBAER,qCAAC,OAAD;AAAA,MAAK,WAAU;AAAA,OACZ,KAAK,QAAQ,SAAS,WAAW,SAAS,OAAO,KAClD,qCAAC,aAAD;AAAA,MACE,WAAU;AAAA,MACV,OAAO,KAAK;AAAA,MACZ,SAAS,KAAK;AAAA,MACd,KAAK,WAAW,SAAS,MAAM;AAAA,QAEhC,YACC,qCAAC,OAAD;AAAA,MAAK,WAAU;AAAA,OACZ,KAAK,UAAU,gBAAgB,iBAAiB,SAAS,cACzD,KAAK,UAAU,gBAAgB,eAAe;AAAA;AAAA;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
package/dist/esm/index.js
DELETED
package/dist/esm/index.js.map
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../../scripts/build/transpile/react-shim.js", "../../src/index.tsx"],
|
|
4
|
-
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "export { default } from './DSImageLibraryModal';\n"],
|
|
5
|
-
"mappings": "AAAA;ACAA;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|