Skip to content

Commit

Permalink
file-filepond initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
priyadi committed Oct 9, 2023
1 parent 4c9fa12 commit c16a9c4
Show file tree
Hide file tree
Showing 20 changed files with 3,319 additions and 3 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/split.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ jobs:
-
local_path: 'file-derivation'
split_repository: 'file-derivation'
-
local_path: 'file-filepond'
split_repository: 'file-filepond'
-
local_path: 'file-image'
split_repository: 'file-image'
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# CHANGELOG

## 1.6.0

* Add FilePond form type.

## 1.5.6

* Fix passing translation in ZIP file name.
Expand Down
7 changes: 6 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"rekalogika/direct-property-access": "^1.1.2 || ^1.2",
"rekalogika/doctrine-collections-decorator": "^2.0",
"rekalogika/reconstitutor": "^1.0",
"rekalogika/temporary-url-bundle": "^1.2",
"rekalogika/temporary-url-bundle": "^1.3",
"symfony/config": "^6.2",
"symfony/dependency-injection": "^6.2",
"symfony/deprecation-contracts": "^3.1",
Expand All @@ -39,12 +39,15 @@
"symfony/http-foundation": "^6.2",
"symfony/http-kernel": "^6.2",
"symfony/mime": "^6.2",
"symfony/options-resolver": "^6.2",
"symfony/property-access": "^6.2",
"symfony/serializer": "^6.2",
"symfony/service-contracts": "^3.3",
"symfony/stimulus-bundle": "^2.12",
"symfony/string": "^6.0",
"symfony/translation-contracts": "^3.0",
"symfony/validator": "^6.2",
"symfony/webpack-encore-bundle": "^2.1",
"thecodingmachine/safe": "^2.5",
"twig/twig": "^2.12|^3.0",
"webmozart/assert": "^1.11"
Expand Down Expand Up @@ -80,6 +83,7 @@
"Rekalogika\\Domain\\File\\Null\\": "packages/file-null/src/",
"Rekalogika\\File\\": "packages/file/src/",
"Rekalogika\\File\\Association\\": "packages/file-association/src/",
"Rekalogika\\File\\Bridge\\FilePond\\": "packages/file-filepond/src/",
"Rekalogika\\File\\Bridge\\Flysystem\\": "packages/file-flysystem-bridge/src/",
"Rekalogika\\File\\Bridge\\OneupUploader\\": "packages/file-oneup-uploader-bridge/src/",
"Rekalogika\\File\\Bridge\\Symfony\\": "packages/file-symfony-bridge/src/",
Expand All @@ -103,6 +107,7 @@
"rekalogika/file-bundle": "1.5.6",
"rekalogika/file-contracts": "1.5.6",
"rekalogika/file-derivation": "1.5.6",
"rekalogika/file-filepond": "self.version",
"rekalogika/file-image": "1.5.6",
"rekalogika/file-metadata": "1.5.6",
"rekalogika/file-metadata-contracts": "1.5.6",
Expand Down
1 change: 1 addition & 0 deletions packages/file-filepond/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
composer.lock
18 changes: 18 additions & 0 deletions packages/file-filepond/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
Copyright (c) 2023-present Priyadi Iman Nurcahyo

Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
17 changes: 17 additions & 0 deletions packages/file-filepond/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# rekalogika/file-filepond



## Documentation

[rekalogika.dev/file-bundle](https://rekalogika.dev/file-bundle)

## License

MIT

## Contributing

The `rekalogika/file-filepond` repository is a read-only repo split from the
main repo. Issues and pull requests should be submitted to the
[rekalogika/file-src](https://github.com/rekalogika/file-src) monorepo.
3 changes: 3 additions & 0 deletions packages/file-filepond/assets/.babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"presets": ["@babel/env"]
}
1 change: 1 addition & 0 deletions packages/file-filepond/assets/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/node_modules/
106 changes: 106 additions & 0 deletions packages/file-filepond/assets/dist/filepond.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
/*
* This file is part of rekalogika/file-src package.
*
* (c) Priyadi Iman Nurcahyo <https://rekalogika.dev>
*
* For the full copyright and license information, please view the LICENSE file
* that was distributed with this source code.
*/

'use strict';

function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
Object.defineProperty(exports, "__esModule", {
value: true
});
exports["default"] = void 0;
var _stimulus = require("@hotwired/stimulus");
var FilePond = _interopRequireWildcard(require("filepond"));
var _filepondPluginFileEncode = _interopRequireDefault(require("filepond-plugin-file-encode"));
var _filepondPluginFileMetadata = _interopRequireDefault(require("filepond-plugin-file-metadata"));
var _filepondPluginFilePoster = _interopRequireDefault(require("filepond-plugin-file-poster"));
var _filepondPluginFileValidateSize = _interopRequireDefault(require("filepond-plugin-file-validate-size"));
var _filepondPluginFileValidateType = _interopRequireDefault(require("filepond-plugin-file-validate-type"));
var _filepondPluginImageCrop = _interopRequireDefault(require("filepond-plugin-image-crop"));
var _filepondPluginImageEdit = _interopRequireDefault(require("filepond-plugin-image-edit"));
var _filepondPluginImageExifOrientation = _interopRequireDefault(require("filepond-plugin-image-exif-orientation"));
var _filepondPluginImagePreview = _interopRequireDefault(require("filepond-plugin-image-preview"));
var _filepondPluginImageResize = _interopRequireDefault(require("filepond-plugin-image-resize"));
var _filepondPluginImageTransform = _interopRequireDefault(require("filepond-plugin-image-transform"));
var _filepondPluginImageValidateSize = _interopRequireDefault(require("filepond-plugin-image-validate-size"));
require("filepond/dist/filepond.min.css");
require("filepond-plugin-file-poster/dist/filepond-plugin-file-poster.css");
require("filepond-plugin-image-edit/dist/filepond-plugin-image-edit.css");
require("filepond-plugin-image-preview/dist/filepond-plugin-image-preview.css");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
FilePond.registerPlugin(_filepondPluginFileEncode["default"], _filepondPluginFileMetadata["default"], _filepondPluginFilePoster["default"], _filepondPluginFileValidateSize["default"], _filepondPluginFileValidateType["default"], _filepondPluginImageCrop["default"], _filepondPluginImageEdit["default"], _filepondPluginImageExifOrientation["default"], _filepondPluginImagePreview["default"], _filepondPluginImageResize["default"], _filepondPluginImageTransform["default"], _filepondPluginImageValidateSize["default"]);

/* stimulusFetch: 'lazy' */
var _default = exports["default"] = /*#__PURE__*/function (_Controller) {
_inherits(_default, _Controller);
var _super = _createSuper(_default);
function _default() {
_classCallCheck(this, _default);
return _super.apply(this, arguments);
}
_createClass(_default, [{
key: "connect",
value: function connect() {
var files = [];
var _iterator = _createForOfIteratorHelper(this.element.children),
_step;
try {
for (_iterator.s(); !(_step = _iterator.n()).done;) {
var child = _step.value;
if (child.tagName !== 'DATA') {
continue;
}
var file = {
// sentinel value sent to server. if this is value is sent
// to the server, then the user didn't remove the image from
// the filepond field
source: '__NOT_DELETED__',
options: {
type: 'local',
file: {
name: child.dataset.name,
size: child.dataset.size,
type: child.dataset.type
}
}
};
if (child.dataset.href) {
file.options.metadata.poster = child.dataset.href;
}
files.push(file);
}
} catch (err) {
_iterator.e(err);
} finally {
_iterator.f();
}
FilePond.create(input[0], {
files: files,
credits: false
});
}
}]);
return _default;
}(_stimulus.Controller);
Loading

0 comments on commit c16a9c4

Please sign in to comment.