@selkirk-systems/attachments 1.0.4
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 +0 -0
- package/dist/actions/AttachmentActions.js +11 -0
- package/dist/actions/FileActions.js +37 -0
- package/dist/actions/ImageUploadActions.js +99 -0
- package/dist/actions/PhotoActions.js +53 -0
- package/dist/components/FileDeleteIcon.js +30 -0
- package/dist/components/FileDownloadIcon.js +34 -0
- package/dist/components/FileList.js +111 -0
- package/dist/components/Icons/ExcelFileTypeImage.js +8 -0
- package/dist/components/Icons/HTMLFileTypeImage.js +7 -0
- package/dist/components/Icons/JSONFileTypeImage.js +7 -0
- package/dist/components/Icons/PDFFileTypeImage.js +7 -0
- package/dist/components/Icons/PhotoFileTypeImage.js +6 -0
- package/dist/components/Icons/PowerPointTypeImage.js +7 -0
- package/dist/components/Icons/TextFileTypeImage.js +7 -0
- package/dist/components/Icons/UnknownFileTypeImage.js +7 -0
- package/dist/components/Icons/WordFileTypeImage.js +7 -0
- package/dist/components/Icons/ZipFileTypeImage.js +7 -0
- package/dist/components/ImageViewerDialog.js +78 -0
- package/dist/components/MimeTypeIcons.js +28 -0
- package/dist/components/PhotoGallery.js +130 -0
- package/dist/components/ResponsiveImageUploadList.js +57 -0
- package/dist/components/UploadImageDialog.js +85 -0
- package/dist/constants/MessageConstants.js +5 -0
- package/dist/constants/PhotosConstants.js +18 -0
- package/dist/css/attachments.css +143 -0
- package/dist/css/image-viewer.css +45 -0
- package/dist/img/PowerPoint-filetype.png +0 -0
- package/dist/img/blue-pattern-bg.jpg +0 -0
- package/dist/img/excel-filetype.png +0 -0
- package/dist/img/html-filetype.png +0 -0
- package/dist/img/json-filetype.png +0 -0
- package/dist/img/pdf-filetype.png +0 -0
- package/dist/img/photo-filetype.png +0 -0
- package/dist/img/txt-filetype.png +0 -0
- package/dist/img/unknown-filetype.png +0 -0
- package/dist/img/word-filetype.png +0 -0
- package/dist/img/zip-filetype.png +0 -0
- package/dist/index.js +19 -0
- package/dist/stores/DownloadStore.js +16 -0
- package/dist/stores/ImageUploadStore.js +24 -0
- package/dist/stores/PhotosStore.js +59 -0
- package/lib/actions/AttachmentActions.js +14 -0
- package/lib/actions/FileActions.js +34 -0
- package/lib/actions/ImageUploadActions.js +134 -0
- package/lib/actions/PhotoActions.js +65 -0
- package/lib/components/FileDeleteIcon.jsx +42 -0
- package/lib/components/FileDownloadIcon.jsx +42 -0
- package/lib/components/FileList.jsx +111 -0
- package/lib/components/Icons/ExcelFileTypeImage.jsx +6 -0
- package/lib/components/Icons/HTMLFileTypeImage.jsx +5 -0
- package/lib/components/Icons/JSONFileTypeImage.jsx +5 -0
- package/lib/components/Icons/PDFFileTypeImage.jsx +5 -0
- package/lib/components/Icons/PhotoFileTypeImage.jsx +5 -0
- package/lib/components/Icons/PowerPointTypeImage.jsx +5 -0
- package/lib/components/Icons/TextFileTypeImage.jsx +5 -0
- package/lib/components/Icons/UnknownFileTypeImage.jsx +5 -0
- package/lib/components/Icons/WordFileTypeImage.jsx +5 -0
- package/lib/components/Icons/ZipFileTypeImage.jsx +5 -0
- package/lib/components/ImageViewerDialog.jsx +72 -0
- package/lib/components/MimeTypeIcons.jsx +30 -0
- package/lib/components/PhotoGallery.jsx +160 -0
- package/lib/components/ResponsiveImageUploadList.jsx +61 -0
- package/lib/components/UploadImageDialog.jsx +93 -0
- package/lib/constants/MessageConstants.js +5 -0
- package/lib/constants/PhotosConstants.js +21 -0
- package/lib/css/attachments.css +143 -0
- package/lib/css/image-viewer.css +45 -0
- package/lib/img/PowerPoint-filetype.png +0 -0
- package/lib/img/blue-pattern-bg.jpg +0 -0
- package/lib/img/excel-filetype.png +0 -0
- package/lib/img/html-filetype.png +0 -0
- package/lib/img/json-filetype.png +0 -0
- package/lib/img/pdf-filetype.png +0 -0
- package/lib/img/photo-filetype.png +0 -0
- package/lib/img/txt-filetype.png +0 -0
- package/lib/img/unknown-filetype.png +0 -0
- package/lib/img/word-filetype.png +0 -0
- package/lib/img/zip-filetype.png +0 -0
- package/lib/index.js +19 -0
- package/lib/stores/DownloadStore.js +23 -0
- package/lib/stores/ImageUploadStore.js +31 -0
- package/lib/stores/PhotosStore.js +81 -0
- package/package.json +50 -0
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import update from "@mbernal/simple-immutable";
|
|
2
|
+
import { CreateStore, setFalse, setStore, setTrue, setValues, withPayload } from "@selkirk-systems/state-management";
|
|
3
|
+
import { CLEAR_PHOTOS, DELETED_IMAGE, DELETE_IMAGE, FETCHED_PHOTOS, FETCH_PHOTOS, FILE_DELETED, FILE_DOWNLOAD, FILE_DOWNLOADED, HIDE_IMAGE_VIEWER_DIALOG, IMAGE_UPLOAD_COMPLETE, SET_UPLOAD_PROGRESS, SHOW_IMAGE_VIEWER_DIALOG } from "../constants/PhotosConstants";
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
const PhotoStore = CreateStore( {
|
|
7
|
+
|
|
8
|
+
name: "PhotoStore",
|
|
9
|
+
|
|
10
|
+
events: {
|
|
11
|
+
[IMAGE_UPLOAD_COMPLETE]: setTrue( "reload" ),
|
|
12
|
+
[FETCH_PHOTOS]: setFalse( "reload" ).setTrue( "fetching" ),
|
|
13
|
+
[FETCHED_PHOTOS]: withPayload().setValues( "photos" ).setFalse( "fetching" ),
|
|
14
|
+
[CLEAR_PHOTOS]: setStore( () => init() ),
|
|
15
|
+
[DELETE_IMAGE]: setTrue( "deleting" ),
|
|
16
|
+
[SHOW_IMAGE_VIEWER_DIALOG]: withPayload().setValues( "imageViewer" ),
|
|
17
|
+
[HIDE_IMAGE_VIEWER_DIALOG]: setValues( "imageViewer", {} ),
|
|
18
|
+
[SET_UPLOAD_PROGRESS]: ( action, state ) => {
|
|
19
|
+
|
|
20
|
+
const payload = action.payload;
|
|
21
|
+
|
|
22
|
+
if ( payload.error || payload.progress !== 100 ) return state;
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
const matchIndex = state.photos.findIndex( p => p.name.toLowerCase() === payload.id.toLowerCase() );
|
|
26
|
+
|
|
27
|
+
if ( matchIndex >= 0 ) {
|
|
28
|
+
return update( state, {
|
|
29
|
+
[`set photos.${matchIndex}`]: payload.response.data[0]
|
|
30
|
+
} )
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
return update( state, {
|
|
34
|
+
'unshift photos': Array.isArray( payload.response.data ) ? payload.response.data : [payload.response.data]
|
|
35
|
+
} )
|
|
36
|
+
|
|
37
|
+
},
|
|
38
|
+
[FILE_DELETED]: ( action, state ) => {
|
|
39
|
+
const { fileName } = action.payload;
|
|
40
|
+
const index = state.photos.findIndex( p => p.name === fileName );
|
|
41
|
+
|
|
42
|
+
if ( index < 0 ) return state;
|
|
43
|
+
|
|
44
|
+
return update( state, {
|
|
45
|
+
'splice photos': [[index, 1]],
|
|
46
|
+
'set deleting': false
|
|
47
|
+
} );
|
|
48
|
+
},
|
|
49
|
+
[DELETED_IMAGE]: ( action, state ) => {
|
|
50
|
+
|
|
51
|
+
const name = action.payload;
|
|
52
|
+
const index = state.photos.findIndex( p => p.name === name );
|
|
53
|
+
|
|
54
|
+
if ( index < 0 ) return state;
|
|
55
|
+
|
|
56
|
+
return update( state, {
|
|
57
|
+
'splice photos': [[index, 1]],
|
|
58
|
+
'set deleting': false
|
|
59
|
+
} );
|
|
60
|
+
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
},
|
|
65
|
+
|
|
66
|
+
state: init()
|
|
67
|
+
|
|
68
|
+
} );
|
|
69
|
+
|
|
70
|
+
function init() {
|
|
71
|
+
return {
|
|
72
|
+
imageViewer: {},
|
|
73
|
+
fetching: true,
|
|
74
|
+
deleting: false,
|
|
75
|
+
reload: false,
|
|
76
|
+
photos: []
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
export default PhotoStore;
|
package/package.json
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@selkirk-systems/attachments",
|
|
3
|
+
"version": "1.0.4",
|
|
4
|
+
"description": "Attachment and photo upload components for Selkirk Systems web projects",
|
|
5
|
+
"keywords": [],
|
|
6
|
+
"author": "Marcos Bernal <mbernal@selkirksystems.com>",
|
|
7
|
+
"license": "ISC",
|
|
8
|
+
"main": "dist/index.js",
|
|
9
|
+
"module": "dist/index.js",
|
|
10
|
+
"directories": {
|
|
11
|
+
"dist": "dist",
|
|
12
|
+
"lib": "lib"
|
|
13
|
+
},
|
|
14
|
+
"files": [
|
|
15
|
+
"dist/**",
|
|
16
|
+
"lib/**"
|
|
17
|
+
],
|
|
18
|
+
"publishConfig": {
|
|
19
|
+
"access": "public"
|
|
20
|
+
},
|
|
21
|
+
"repository": {
|
|
22
|
+
"type": "git",
|
|
23
|
+
"url": "git+https://galderak@bitbucket.org/selkirk/web-component-library.git"
|
|
24
|
+
},
|
|
25
|
+
"scripts": {
|
|
26
|
+
"docs": "jsdoc --configure ../../jsdoc.json -r ./lib -d docs",
|
|
27
|
+
"build": "del dist /Q && cross-env CI=false NODE_ENV=production babel lib --out-dir dist --copy-files --ignore __tests__,spec.js,test.js,__snapshots__",
|
|
28
|
+
"prepublishOnly": "npm run build"
|
|
29
|
+
},
|
|
30
|
+
"bugs": {
|
|
31
|
+
"url": "https://bitbucket.org/selkirk/web-component-library/issues"
|
|
32
|
+
},
|
|
33
|
+
"homepage": "https://bitbucket.org/selkirk/web-component-library#readme",
|
|
34
|
+
"peerDependencies": {
|
|
35
|
+
"@selkirk-systems/fetch": "^1.8.0",
|
|
36
|
+
"@selkirk-systems/layout": "^1.3.1",
|
|
37
|
+
"@selkirk-systems/selkirk-components": "^1.0.0",
|
|
38
|
+
"@selkirk-systems/selkirk-utils": "^1.0.0",
|
|
39
|
+
"@selkirk-systems/state-management": "^2.0.0",
|
|
40
|
+
"lucide-react": "*",
|
|
41
|
+
"primereact": "^10.9.4",
|
|
42
|
+
"react": "^19.0.0"
|
|
43
|
+
},
|
|
44
|
+
"dependencies": {
|
|
45
|
+
"@mbernal/simple-immutable": "*",
|
|
46
|
+
"clsx": "^2.1.1",
|
|
47
|
+
"memoizee": "*"
|
|
48
|
+
},
|
|
49
|
+
"gitHead": "6662f923b61e841ddd3a8f6f048da254637fcc8e"
|
|
50
|
+
}
|