|
|
- /******/ (function(modules) { // webpackBootstrap
- /******/ // The module cache
- /******/ var installedModules = {};
- /******/
- /******/ // The require function
- /******/ function __webpack_require__(moduleId) {
- /******/
- /******/ // Check if module is in cache
- /******/ if(installedModules[moduleId]) {
- /******/ return installedModules[moduleId].exports;
- /******/ }
- /******/ // Create a new module (and put it into the cache)
- /******/ var module = installedModules[moduleId] = {
- /******/ i: moduleId,
- /******/ l: false,
- /******/ exports: {}
- /******/ };
- /******/
- /******/ // Execute the module function
- /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
- /******/
- /******/ // Flag the module as loaded
- /******/ module.l = true;
- /******/
- /******/ // Return the exports of the module
- /******/ return module.exports;
- /******/ }
- /******/
- /******/
- /******/ // expose the modules object (__webpack_modules__)
- /******/ __webpack_require__.m = modules;
- /******/
- /******/ // expose the module cache
- /******/ __webpack_require__.c = installedModules;
- /******/
- /******/ // define getter function for harmony exports
- /******/ __webpack_require__.d = function(exports, name, getter) {
- /******/ if(!__webpack_require__.o(exports, name)) {
- /******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
- /******/ }
- /******/ };
- /******/
- /******/ // define __esModule on exports
- /******/ __webpack_require__.r = function(exports) {
- /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
- /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
- /******/ }
- /******/ Object.defineProperty(exports, '__esModule', { value: true });
- /******/ };
- /******/
- /******/ // create a fake namespace object
- /******/ // mode & 1: value is a module id, require it
- /******/ // mode & 2: merge all properties of value into the ns
- /******/ // mode & 4: return value when already ns object
- /******/ // mode & 8|1: behave like require
- /******/ __webpack_require__.t = function(value, mode) {
- /******/ if(mode & 1) value = __webpack_require__(value);
- /******/ if(mode & 8) return value;
- /******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
- /******/ var ns = Object.create(null);
- /******/ __webpack_require__.r(ns);
- /******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
- /******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
- /******/ return ns;
- /******/ };
- /******/
- /******/ // getDefaultExport function for compatibility with non-harmony modules
- /******/ __webpack_require__.n = function(module) {
- /******/ var getter = module && module.__esModule ?
- /******/ function getDefault() { return module['default']; } :
- /******/ function getModuleExports() { return module; };
- /******/ __webpack_require__.d(getter, 'a', getter);
- /******/ return getter;
- /******/ };
- /******/
- /******/ // Object.prototype.hasOwnProperty.call
- /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
- /******/
- /******/ // __webpack_public_path__
- /******/ __webpack_require__.p = "/";
- /******/
- /******/
- /******/ // Load entry module and return exports
- /******/ return __webpack_require__(__webpack_require__.s = 2);
- /******/ })
- /************************************************************************/
- /******/ ({
-
- /***/ "./node_modules/@tentakelfabrik/tiny-validator/src/validator.js":
- /*!**********************************************************************!*\
- !*** ./node_modules/@tentakelfabrik/tiny-validator/src/validator.js ***!
- \**********************************************************************/
- /*! exports provided: default */
- /***/ (function(module, __webpack_exports__, __webpack_require__) {
-
- "use strict";
- __webpack_require__.r(__webpack_exports__);
- /* harmony import */ var validate_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! validate.js */ "./node_modules/validate.js/validate.js");
- /* harmony import */ var validate_js__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(validate_js__WEBPACK_IMPORTED_MODULE_0__);
- /* harmony import */ var form_serialize__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! form-serialize */ "./node_modules/form-serialize/index.js");
- /* harmony import */ var form_serialize__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(form_serialize__WEBPACK_IMPORTED_MODULE_1__);
-
-
-
- /**
- * Validate entire Form or a single Element
- *
- * Using validator.js
- *
- * @author Björn Hase, Tentakelfabrik, me@tentakelfabrik.de
- *
- */
- class Validator {
-
- /**
- *
- * @param {array} rules
- */
- constructor(rules, component) {
- this._rules = rules
- this._component = component
-
- this._errors = {
-
- }
- }
-
- /**
- * handle validation
- *
- * if key not set,
- *
- * @param {object} event
- * @param {object} key
- *
- */
- handle(event, key) {
-
- event.preventDefault()
-
- let data = null, rules, errors
-
- if (key) {
- if (event.target.value) {
- data = event.target.value
- }
- } else {
- data = form_serialize__WEBPACK_IMPORTED_MODULE_1___default()(event.target, {
- hash: true
- })
- }
-
- // validate single
- if (key) {
- rules = this._rules[key]
-
- errors = validate_js__WEBPACK_IMPORTED_MODULE_0___default.a.single(data, rules, {
- flat: true
- })
-
- if (errors) {
- this._errors[key] = errors
- } else {
- delete this._errors[key]
- }
-
- // validate entire form
- } else {
- this._errors = validate_js__WEBPACK_IMPORTED_MODULE_0___default()(data, this._rules)
- }
-
- // update component
- this._component.update()
- }
-
- /**
- *
- *
- * @param {[type]} key
- * @return {[type]}
- */
- errors(key) {
-
- if (key) {
- return this._errors[key]
- }
-
- return this._errors
-
- }
- }
-
- /* harmony default export */ __webpack_exports__["default"] = (Validator);
-
- /***/ }),
-
- /***/ "./node_modules/form-serialize/index.js":
- /*!**********************************************!*\
- !*** ./node_modules/form-serialize/index.js ***!
- \**********************************************/
- /*! no static exports found */
- /***/ (function(module, exports) {
-
- // get successful control from form and assemble into object
- // http://www.w3.org/TR/html401/interact/forms.html#h-17.13.2
-
- // types which indicate a submit action and are not successful controls
- // these will be ignored
- var k_r_submitter = /^(?:submit|button|image|reset|file)$/i;
-
- // node names which could be successful controls
- var k_r_success_contrls = /^(?:input|select|textarea|keygen)/i;
-
- // Matches bracket notation.
- var brackets = /(\[[^\[\]]*\])/g;
-
- // serializes form fields
- // @param form MUST be an HTMLForm element
- // @param options is an optional argument to configure the serialization. Default output
- // with no options specified is a url encoded string
- // - hash: [true | false] Configure the output type. If true, the output will
- // be a js object.
- // - serializer: [function] Optional serializer function to override the default one.
- // The function takes 3 arguments (result, key, value) and should return new result
- // hash and url encoded str serializers are provided with this module
- // - disabled: [true | false]. If true serialize disabled fields.
- // - empty: [true | false]. If true serialize empty fields
- function serialize(form, options) {
- if (typeof options != 'object') {
- options = { hash: !!options };
- }
- else if (options.hash === undefined) {
- options.hash = true;
- }
-
- var result = (options.hash) ? {} : '';
- var serializer = options.serializer || ((options.hash) ? hash_serializer : str_serialize);
-
- var elements = form && form.elements ? form.elements : [];
-
- //Object store each radio and set if it's empty or not
- var radio_store = Object.create(null);
-
- for (var i=0 ; i<elements.length ; ++i) {
- var element = elements[i];
-
- // ingore disabled fields
- if ((!options.disabled && element.disabled) || !element.name) {
- continue;
- }
- // ignore anyhting that is not considered a success field
- if (!k_r_success_contrls.test(element.nodeName) ||
- k_r_submitter.test(element.type)) {
- continue;
- }
-
- var key = element.name;
- var val = element.value;
-
- // we can't just use element.value for checkboxes cause some browsers lie to us
- // they say "on" for value when the box isn't checked
- if ((element.type === 'checkbox' || element.type === 'radio') && !element.checked) {
- val = undefined;
- }
-
- // If we want empty elements
- if (options.empty) {
- // for checkbox
- if (element.type === 'checkbox' && !element.checked) {
- val = '';
- }
-
- // for radio
- if (element.type === 'radio') {
- if (!radio_store[element.name] && !element.checked) {
- radio_store[element.name] = false;
- }
- else if (element.checked) {
- radio_store[element.name] = true;
- }
- }
-
- // if options empty is true, continue only if its radio
- if (val == undefined && element.type == 'radio') {
- continue;
- }
- }
- else {
- // value-less fields are ignored unless options.empty is true
- if (!val) {
- continue;
- }
- }
-
- // multi select boxes
- if (element.type === 'select-multiple') {
- val = [];
-
- var selectOptions = element.options;
- var isSelectedOptions = false;
- for (var j=0 ; j<selectOptions.length ; ++j) {
- var option = selectOptions[j];
- var allowedEmpty = options.empty && !option.value;
- var hasValue = (option.value || allowedEmpty);
- if (option.selected && hasValue) {
- isSelectedOptions = true;
-
- // If using a hash serializer be sure to add the
- // correct notation for an array in the multi-select
- // context. Here the name attribute on the select element
- // might be missing the trailing bracket pair. Both names
- // "foo" and "foo[]" should be arrays.
- if (options.hash && key.slice(key.length - 2) !== '[]') {
- result = serializer(result, key + '[]', option.value);
- }
- else {
- result = serializer(result, key, option.value);
- }
- }
- }
-
- // Serialize if no selected options and options.empty is true
- if (!isSelectedOptions && options.empty) {
- result = serializer(result, key, '');
- }
-
- continue;
- }
-
- result = serializer(result, key, val);
- }
-
- // Check for all empty radio buttons and serialize them with key=""
- if (options.empty) {
- for (var key in radio_store) {
- if (!radio_store[key]) {
- result = serializer(result, key, '');
- }
- }
- }
-
- return result;
- }
-
- function parse_keys(string) {
- var keys = [];
- var prefix = /^([^\[\]]*)/;
- var children = new RegExp(brackets);
- var match = prefix.exec(string);
-
- if (match[1]) {
- keys.push(match[1]);
- }
-
- while ((match = children.exec(string)) !== null) {
- keys.push(match[1]);
- }
-
- return keys;
- }
-
- function hash_assign(result, keys, value) {
- if (keys.length === 0) {
- result = value;
- return result;
- }
-
- var key = keys.shift();
- var between = key.match(/^\[(.+?)\]$/);
-
- if (key === '[]') {
- result = result || [];
-
- if (Array.isArray(result)) {
- result.push(hash_assign(null, keys, value));
- }
- else {
- // This might be the result of bad name attributes like "[][foo]",
- // in this case the original `result` object will already be
- // assigned to an object literal. Rather than coerce the object to
- // an array, or cause an exception the attribute "_values" is
- // assigned as an array.
- result._values = result._values || [];
- result._values.push(hash_assign(null, keys, value));
- }
-
- return result;
- }
-
- // Key is an attribute name and can be assigned directly.
- if (!between) {
- result[key] = hash_assign(result[key], keys, value);
- }
- else {
- var string = between[1];
- // +var converts the variable into a number
- // better than parseInt because it doesn't truncate away trailing
- // letters and actually fails if whole thing is not a number
- var index = +string;
-
- // If the characters between the brackets is not a number it is an
- // attribute name and can be assigned directly.
- if (isNaN(index)) {
- result = result || {};
- result[string] = hash_assign(result[string], keys, value);
- }
- else {
- result = result || [];
- result[index] = hash_assign(result[index], keys, value);
- }
- }
-
- return result;
- }
-
- // Object/hash encoding serializer.
- function hash_serializer(result, key, value) {
- var matches = key.match(brackets);
-
- // Has brackets? Use the recursive assignment function to walk the keys,
- // construct any missing objects in the result tree and make the assignment
- // at the end of the chain.
- if (matches) {
- var keys = parse_keys(key);
- hash_assign(result, keys, value);
- }
- else {
- // Non bracket notation can make assignments directly.
- var existing = result[key];
-
- // If the value has been assigned already (for instance when a radio and
- // a checkbox have the same name attribute) convert the previous value
- // into an array before pushing into it.
- //
- // NOTE: If this requirement were removed all hash creation and
- // assignment could go through `hash_assign`.
- if (existing) {
- if (!Array.isArray(existing)) {
- result[key] = [ existing ];
- }
-
- result[key].push(value);
- }
- else {
- result[key] = value;
- }
- }
-
- return result;
- }
-
- // urlform encoding serializer
- function str_serialize(result, key, value) {
- // encode newlines as \r\n cause the html spec says so
- value = value.replace(/(\r)?\n/g, '\r\n');
- value = encodeURIComponent(value);
-
- // spaces should be '+' rather than '%20'.
- value = value.replace(/%20/g, '+');
- return result + (result ? '&' : '') + encodeURIComponent(key) + '=' + value;
- }
-
- module.exports = serialize;
-
-
- /***/ }),
-
- /***/ "./node_modules/validate.js/validate.js":
- /*!**********************************************!*\
- !*** ./node_modules/validate.js/validate.js ***!
- \**********************************************/
- /*! no static exports found */
- /***/ (function(module, exports, __webpack_require__) {
-
- /* WEBPACK VAR INJECTION */(function(module) {/*!
- * validate.js 0.13.1
- *
- * (c) 2013-2019 Nicklas Ansman, 2013 Wrapp
- * Validate.js may be freely distributed under the MIT license.
- * For all details and documentation:
- * http://validatejs.org/
- */
-
- (function(exports, module, define) {
- "use strict";
-
- // The main function that calls the validators specified by the constraints.
- // The options are the following:
- // - format (string) - An option that controls how the returned value is formatted
- // * flat - Returns a flat array of just the error messages
- // * grouped - Returns the messages grouped by attribute (default)
- // * detailed - Returns an array of the raw validation data
- // - fullMessages (boolean) - If `true` (default) the attribute name is prepended to the error.
- //
- // Please note that the options are also passed to each validator.
- var validate = function(attributes, constraints, options) {
- options = v.extend({}, v.options, options);
-
- var results = v.runValidations(attributes, constraints, options)
- , attr
- , validator;
-
- if (results.some(function(r) { return v.isPromise(r.error); })) {
- throw new Error("Use validate.async if you want support for promises");
- }
- return validate.processValidationResults(results, options);
- };
-
- var v = validate;
-
- // Copies over attributes from one or more sources to a single destination.
- // Very much similar to underscore's extend.
- // The first argument is the target object and the remaining arguments will be
- // used as sources.
- v.extend = function(obj) {
- [].slice.call(arguments, 1).forEach(function(source) {
- for (var attr in source) {
- obj[attr] = source[attr];
- }
- });
- return obj;
- };
-
- v.extend(validate, {
- // This is the version of the library as a semver.
- // The toString function will allow it to be coerced into a string
- version: {
- major: 0,
- minor: 13,
- patch: 1,
- metadata: null,
- toString: function() {
- var version = v.format("%{major}.%{minor}.%{patch}", v.version);
- if (!v.isEmpty(v.version.metadata)) {
- version += "+" + v.version.metadata;
- }
- return version;
- }
- },
-
- // Below is the dependencies that are used in validate.js
-
- // The constructor of the Promise implementation.
- // If you are using Q.js, RSVP or any other A+ compatible implementation
- // override this attribute to be the constructor of that promise.
- // Since jQuery promises aren't A+ compatible they won't work.
- Promise: typeof Promise !== "undefined" ? Promise : /* istanbul ignore next */ null,
-
- EMPTY_STRING_REGEXP: /^\s*$/,
-
- // Runs the validators specified by the constraints object.
- // Will return an array of the format:
- // [{attribute: "<attribute name>", error: "<validation result>"}, ...]
- runValidations: function(attributes, constraints, options) {
- var results = []
- , attr
- , validatorName
- , value
- , validators
- , validator
- , validatorOptions
- , error;
-
- if (v.isDomElement(attributes) || v.isJqueryElement(attributes)) {
- attributes = v.collectFormValues(attributes);
- }
-
- // Loops through each constraints, finds the correct validator and run it.
- for (attr in constraints) {
- value = v.getDeepObjectValue(attributes, attr);
- // This allows the constraints for an attribute to be a function.
- // The function will be called with the value, attribute name, the complete dict of
- // attributes as well as the options and constraints passed in.
- // This is useful when you want to have different
- // validations depending on the attribute value.
- validators = v.result(constraints[attr], value, attributes, attr, options, constraints);
-
- for (validatorName in validators) {
- validator = v.validators[validatorName];
-
- if (!validator) {
- error = v.format("Unknown validator %{name}", {name: validatorName});
- throw new Error(error);
- }
-
- validatorOptions = validators[validatorName];
- // This allows the options to be a function. The function will be
- // called with the value, attribute name, the complete dict of
- // attributes as well as the options and constraints passed in.
- // This is useful when you want to have different
- // validations depending on the attribute value.
- validatorOptions = v.result(validatorOptions, value, attributes, attr, options, constraints);
- if (!validatorOptions) {
- continue;
- }
- results.push({
- attribute: attr,
- value: value,
- validator: validatorName,
- globalOptions: options,
- attributes: attributes,
- options: validatorOptions,
- error: validator.call(validator,
- value,
- validatorOptions,
- attr,
- attributes,
- options)
- });
- }
- }
-
- return results;
- },
-
- // Takes the output from runValidations and converts it to the correct
- // output format.
- processValidationResults: function(errors, options) {
- errors = v.pruneEmptyErrors(errors, options);
- errors = v.expandMultipleErrors(errors, options);
- errors = v.convertErrorMessages(errors, options);
-
- var format = options.format || "grouped";
-
- if (typeof v.formatters[format] === 'function') {
- errors = v.formatters[format](errors);
- } else {
- throw new Error(v.format("Unknown format %{format}", options));
- }
-
- return v.isEmpty(errors) ? undefined : errors;
- },
-
- // Runs the validations with support for promises.
- // This function will return a promise that is settled when all the
- // validation promises have been completed.
- // It can be called even if no validations returned a promise.
- async: function(attributes, constraints, options) {
- options = v.extend({}, v.async.options, options);
-
- var WrapErrors = options.wrapErrors || function(errors) {
- return errors;
- };
-
- // Removes unknown attributes
- if (options.cleanAttributes !== false) {
- attributes = v.cleanAttributes(attributes, constraints);
- }
-
- var results = v.runValidations(attributes, constraints, options);
-
- return new v.Promise(function(resolve, reject) {
- v.waitForResults(results).then(function() {
- var errors = v.processValidationResults(results, options);
- if (errors) {
- reject(new WrapErrors(errors, options, attributes, constraints));
- } else {
- resolve(attributes);
- }
- }, function(err) {
- reject(err);
- });
- });
- },
-
- single: function(value, constraints, options) {
- options = v.extend({}, v.single.options, options, {
- format: "flat",
- fullMessages: false
- });
- return v({single: value}, {single: constraints}, options);
- },
-
- // Returns a promise that is resolved when all promises in the results array
- // are settled. The promise returned from this function is always resolved,
- // never rejected.
- // This function modifies the input argument, it replaces the promises
- // with the value returned from the promise.
- waitForResults: function(results) {
- // Create a sequence of all the results starting with a resolved promise.
- return results.reduce(function(memo, result) {
- // If this result isn't a promise skip it in the sequence.
- if (!v.isPromise(result.error)) {
- return memo;
- }
-
- return memo.then(function() {
- return result.error.then(function(error) {
- result.error = error || null;
- });
- });
- }, new v.Promise(function(r) { r(); })); // A resolved promise
- },
-
- // If the given argument is a call: function the and: function return the value
- // otherwise just return the value. Additional arguments will be passed as
- // arguments to the function.
- // Example:
- // ```
- // result('foo') // 'foo'
- // result(Math.max, 1, 2) // 2
- // ```
- result: function(value) {
- var args = [].slice.call(arguments, 1);
- if (typeof value === 'function') {
- value = value.apply(null, args);
- }
- return value;
- },
-
- // Checks if the value is a number. This function does not consider NaN a
- // number like many other `isNumber` functions do.
- isNumber: function(value) {
- return typeof value === 'number' && !isNaN(value);
- },
-
- // Returns false if the object is not a function
- isFunction: function(value) {
- return typeof value === 'function';
- },
-
- // A simple check to verify that the value is an integer. Uses `isNumber`
- // and a simple modulo check.
- isInteger: function(value) {
- return v.isNumber(value) && value % 1 === 0;
- },
-
- // Checks if the value is a boolean
- isBoolean: function(value) {
- return typeof value === 'boolean';
- },
-
- // Uses the `Object` function to check if the given argument is an object.
- isObject: function(obj) {
- return obj === Object(obj);
- },
-
- // Simply checks if the object is an instance of a date
- isDate: function(obj) {
- return obj instanceof Date;
- },
-
- // Returns false if the object is `null` of `undefined`
- isDefined: function(obj) {
- return obj !== null && obj !== undefined;
- },
-
- // Checks if the given argument is a promise. Anything with a `then`
- // function is considered a promise.
- isPromise: function(p) {
- return !!p && v.isFunction(p.then);
- },
-
- isJqueryElement: function(o) {
- return o && v.isString(o.jquery);
- },
-
- isDomElement: function(o) {
- if (!o) {
- return false;
- }
-
- if (!o.querySelectorAll || !o.querySelector) {
- return false;
- }
-
- if (v.isObject(document) && o === document) {
- return true;
- }
-
- // http://stackoverflow.com/a/384380/699304
- /* istanbul ignore else */
- if (typeof HTMLElement === "object") {
- return o instanceof HTMLElement;
- } else {
- return o &&
- typeof o === "object" &&
- o !== null &&
- o.nodeType === 1 &&
- typeof o.nodeName === "string";
- }
- },
-
- isEmpty: function(value) {
- var attr;
-
- // Null and undefined are empty
- if (!v.isDefined(value)) {
- return true;
- }
-
- // functions are non empty
- if (v.isFunction(value)) {
- return false;
- }
-
- // Whitespace only strings are empty
- if (v.isString(value)) {
- return v.EMPTY_STRING_REGEXP.test(value);
- }
-
- // For arrays we use the length property
- if (v.isArray(value)) {
- return value.length === 0;
- }
-
- // Dates have no attributes but aren't empty
- if (v.isDate(value)) {
- return false;
- }
-
- // If we find at least one property we consider it non empty
- if (v.isObject(value)) {
- for (attr in value) {
- return false;
- }
- return true;
- }
-
- return false;
- },
-
- // Formats the specified strings with the given values like so:
- // ```
- // format("Foo: %{foo}", {foo: "bar"}) // "Foo bar"
- // ```
- // If you want to write %{...} without having it replaced simply
- // prefix it with % like this `Foo: %%{foo}` and it will be returned
- // as `"Foo: %{foo}"`
- format: v.extend(function(str, vals) {
- if (!v.isString(str)) {
- return str;
- }
- return str.replace(v.format.FORMAT_REGEXP, function(m0, m1, m2) {
- if (m1 === '%') {
- return "%{" + m2 + "}";
- } else {
- return String(vals[m2]);
- }
- });
- }, {
- // Finds %{key} style patterns in the given string
- FORMAT_REGEXP: /(%?)%\{([^\}]+)\}/g
- }),
-
- // "Prettifies" the given string.
- // Prettifying means replacing [.\_-] with spaces as well as splitting
- // camel case words.
- prettify: function(str) {
- if (v.isNumber(str)) {
- // If there are more than 2 decimals round it to two
- if ((str * 100) % 1 === 0) {
- return "" + str;
- } else {
- return parseFloat(Math.round(str * 100) / 100).toFixed(2);
- }
- }
-
- if (v.isArray(str)) {
- return str.map(function(s) { return v.prettify(s); }).join(", ");
- }
-
- if (v.isObject(str)) {
- if (!v.isDefined(str.toString)) {
- return JSON.stringify(str);
- }
-
- return str.toString();
- }
-
- // Ensure the string is actually a string
- str = "" + str;
-
- return str
- // Splits keys separated by periods
- .replace(/([^\s])\.([^\s])/g, '$1 $2')
- // Removes backslashes
- .replace(/\\+/g, '')
- // Replaces - and - with space
- .replace(/[_-]/g, ' ')
- // Splits camel cased words
- .replace(/([a-z])([A-Z])/g, function(m0, m1, m2) {
- return "" + m1 + " " + m2.toLowerCase();
- })
- .toLowerCase();
- },
-
- stringifyValue: function(value, options) {
- var prettify = options && options.prettify || v.prettify;
- return prettify(value);
- },
-
- isString: function(value) {
- return typeof value === 'string';
- },
-
- isArray: function(value) {
- return {}.toString.call(value) === '[object Array]';
- },
-
- // Checks if the object is a hash, which is equivalent to an object that
- // is neither an array nor a function.
- isHash: function(value) {
- return v.isObject(value) && !v.isArray(value) && !v.isFunction(value);
- },
-
- contains: function(obj, value) {
- if (!v.isDefined(obj)) {
- return false;
- }
- if (v.isArray(obj)) {
- return obj.indexOf(value) !== -1;
- }
- return value in obj;
- },
-
- unique: function(array) {
- if (!v.isArray(array)) {
- return array;
- }
- return array.filter(function(el, index, array) {
- return array.indexOf(el) == index;
- });
- },
-
- forEachKeyInKeypath: function(object, keypath, callback) {
- if (!v.isString(keypath)) {
- return undefined;
- }
-
- var key = ""
- , i
- , escape = false;
-
- for (i = 0; i < keypath.length; ++i) {
- switch (keypath[i]) {
- case '.':
- if (escape) {
- escape = false;
- key += '.';
- } else {
- object = callback(object, key, false);
- key = "";
- }
- break;
-
- case '\\':
- if (escape) {
- escape = false;
- key += '\\';
- } else {
- escape = true;
- }
- break;
-
- default:
- escape = false;
- key += keypath[i];
- break;
- }
- }
-
- return callback(object, key, true);
- },
-
- getDeepObjectValue: function(obj, keypath) {
- if (!v.isObject(obj)) {
- return undefined;
- }
-
- return v.forEachKeyInKeypath(obj, keypath, function(obj, key) {
- if (v.isObject(obj)) {
- return obj[key];
- }
- });
- },
-
- // This returns an object with all the values of the form.
- // It uses the input name as key and the value as value
- // So for example this:
- // <input type="text" name="email" value="foo@bar.com" />
- // would return:
- // {email: "foo@bar.com"}
- collectFormValues: function(form, options) {
- var values = {}
- , i
- , j
- , input
- , inputs
- , option
- , value;
-
- if (v.isJqueryElement(form)) {
- form = form[0];
- }
-
- if (!form) {
- return values;
- }
-
- options = options || {};
-
- inputs = form.querySelectorAll("input[name], textarea[name]");
- for (i = 0; i < inputs.length; ++i) {
- input = inputs.item(i);
-
- if (v.isDefined(input.getAttribute("data-ignored"))) {
- continue;
- }
-
- var name = input.name.replace(/\./g, "\\\\.");
- value = v.sanitizeFormValue(input.value, options);
- if (input.type === "number") {
- value = value ? +value : null;
- } else if (input.type === "checkbox") {
- if (input.attributes.value) {
- if (!input.checked) {
- value = values[name] || null;
- }
- } else {
- value = input.checked;
- }
- } else if (input.type === "radio") {
- if (!input.checked) {
- value = values[name] || null;
- }
- }
- values[name] = value;
- }
-
- inputs = form.querySelectorAll("select[name]");
- for (i = 0; i < inputs.length; ++i) {
- input = inputs.item(i);
- if (v.isDefined(input.getAttribute("data-ignored"))) {
- continue;
- }
-
- if (input.multiple) {
- value = [];
- for (j in input.options) {
- option = input.options[j];
- if (option && option.selected) {
- value.push(v.sanitizeFormValue(option.value, options));
- }
- }
- } else {
- var _val = typeof input.options[input.selectedIndex] !== 'undefined' ? input.options[input.selectedIndex].value : /* istanbul ignore next */ '';
- value = v.sanitizeFormValue(_val, options);
- }
- values[input.name] = value;
- }
-
- return values;
- },
-
- sanitizeFormValue: function(value, options) {
- if (options.trim && v.isString(value)) {
- value = value.trim();
- }
-
- if (options.nullify !== false && value === "") {
- return null;
- }
- return value;
- },
-
- capitalize: function(str) {
- if (!v.isString(str)) {
- return str;
- }
- return str[0].toUpperCase() + str.slice(1);
- },
-
- // Remove all errors who's error attribute is empty (null or undefined)
- pruneEmptyErrors: function(errors) {
- return errors.filter(function(error) {
- return !v.isEmpty(error.error);
- });
- },
-
- // In
- // [{error: ["err1", "err2"], ...}]
- // Out
- // [{error: "err1", ...}, {error: "err2", ...}]
- //
- // All attributes in an error with multiple messages are duplicated
- // when expanding the errors.
- expandMultipleErrors: function(errors) {
- var ret = [];
- errors.forEach(function(error) {
- // Removes errors without a message
- if (v.isArray(error.error)) {
- error.error.forEach(function(msg) {
- ret.push(v.extend({}, error, {error: msg}));
- });
- } else {
- ret.push(error);
- }
- });
- return ret;
- },
-
- // Converts the error mesages by prepending the attribute name unless the
- // message is prefixed by ^
- convertErrorMessages: function(errors, options) {
- options = options || {};
-
- var ret = []
- , prettify = options.prettify || v.prettify;
- errors.forEach(function(errorInfo) {
- var error = v.result(errorInfo.error,
- errorInfo.value,
- errorInfo.attribute,
- errorInfo.options,
- errorInfo.attributes,
- errorInfo.globalOptions);
-
- if (!v.isString(error)) {
- ret.push(errorInfo);
- return;
- }
-
- if (error[0] === '^') {
- error = error.slice(1);
- } else if (options.fullMessages !== false) {
- error = v.capitalize(prettify(errorInfo.attribute)) + " " + error;
- }
- error = error.replace(/\\\^/g, "^");
- error = v.format(error, {
- value: v.stringifyValue(errorInfo.value, options)
- });
- ret.push(v.extend({}, errorInfo, {error: error}));
- });
- return ret;
- },
-
- // In:
- // [{attribute: "<attributeName>", ...}]
- // Out:
- // {"<attributeName>": [{attribute: "<attributeName>", ...}]}
- groupErrorsByAttribute: function(errors) {
- var ret = {};
- errors.forEach(function(error) {
- var list = ret[error.attribute];
- if (list) {
- list.push(error);
- } else {
- ret[error.attribute] = [error];
- }
- });
- return ret;
- },
-
- // In:
- // [{error: "<message 1>", ...}, {error: "<message 2>", ...}]
- // Out:
- // ["<message 1>", "<message 2>"]
- flattenErrorsToArray: function(errors) {
- return errors
- .map(function(error) { return error.error; })
- .filter(function(value, index, self) {
- return self.indexOf(value) === index;
- });
- },
-
- cleanAttributes: function(attributes, whitelist) {
- function whitelistCreator(obj, key, last) {
- if (v.isObject(obj[key])) {
- return obj[key];
- }
- return (obj[key] = last ? true : {});
- }
-
- function buildObjectWhitelist(whitelist) {
- var ow = {}
- , lastObject
- , attr;
- for (attr in whitelist) {
- if (!whitelist[attr]) {
- continue;
- }
- v.forEachKeyInKeypath(ow, attr, whitelistCreator);
- }
- return ow;
- }
-
- function cleanRecursive(attributes, whitelist) {
- if (!v.isObject(attributes)) {
- return attributes;
- }
-
- var ret = v.extend({}, attributes)
- , w
- , attribute;
-
- for (attribute in attributes) {
- w = whitelist[attribute];
-
- if (v.isObject(w)) {
- ret[attribute] = cleanRecursive(ret[attribute], w);
- } else if (!w) {
- delete ret[attribute];
- }
- }
- return ret;
- }
-
- if (!v.isObject(whitelist) || !v.isObject(attributes)) {
- return {};
- }
-
- whitelist = buildObjectWhitelist(whitelist);
- return cleanRecursive(attributes, whitelist);
- },
-
- exposeModule: function(validate, root, exports, module, define) {
- if (exports) {
- if (module && module.exports) {
- exports = module.exports = validate;
- }
- exports.validate = validate;
- } else {
- root.validate = validate;
- if (validate.isFunction(define) && define.amd) {
- define([], function () { return validate; });
- }
- }
- },
-
- warn: function(msg) {
- if (typeof console !== "undefined" && console.warn) {
- console.warn("[validate.js] " + msg);
- }
- },
-
- error: function(msg) {
- if (typeof console !== "undefined" && console.error) {
- console.error("[validate.js] " + msg);
- }
- }
- });
-
- validate.validators = {
- // Presence validates that the value isn't empty
- presence: function(value, options) {
- options = v.extend({}, this.options, options);
- if (options.allowEmpty !== false ? !v.isDefined(value) : v.isEmpty(value)) {
- return options.message || this.message || "can't be blank";
- }
- },
- length: function(value, options, attribute) {
- // Empty values are allowed
- if (!v.isDefined(value)) {
- return;
- }
-
- options = v.extend({}, this.options, options);
-
- var is = options.is
- , maximum = options.maximum
- , minimum = options.minimum
- , tokenizer = options.tokenizer || function(val) { return val; }
- , err
- , errors = [];
-
- value = tokenizer(value);
- var length = value.length;
- if(!v.isNumber(length)) {
- return options.message || this.notValid || "has an incorrect length";
- }
-
- // Is checks
- if (v.isNumber(is) && length !== is) {
- err = options.wrongLength ||
- this.wrongLength ||
- "is the wrong length (should be %{count} characters)";
- errors.push(v.format(err, {count: is}));
- }
-
- if (v.isNumber(minimum) && length < minimum) {
- err = options.tooShort ||
- this.tooShort ||
- "is too short (minimum is %{count} characters)";
- errors.push(v.format(err, {count: minimum}));
- }
-
- if (v.isNumber(maximum) && length > maximum) {
- err = options.tooLong ||
- this.tooLong ||
- "is too long (maximum is %{count} characters)";
- errors.push(v.format(err, {count: maximum}));
- }
-
- if (errors.length > 0) {
- return options.message || errors;
- }
- },
- numericality: function(value, options, attribute, attributes, globalOptions) {
- // Empty values are fine
- if (!v.isDefined(value)) {
- return;
- }
-
- options = v.extend({}, this.options, options);
-
- var errors = []
- , name
- , count
- , checks = {
- greaterThan: function(v, c) { return v > c; },
- greaterThanOrEqualTo: function(v, c) { return v >= c; },
- equalTo: function(v, c) { return v === c; },
- lessThan: function(v, c) { return v < c; },
- lessThanOrEqualTo: function(v, c) { return v <= c; },
- divisibleBy: function(v, c) { return v % c === 0; }
- }
- , prettify = options.prettify ||
- (globalOptions && globalOptions.prettify) ||
- v.prettify;
-
- // Strict will check that it is a valid looking number
- if (v.isString(value) && options.strict) {
- var pattern = "^-?(0|[1-9]\\d*)";
- if (!options.onlyInteger) {
- pattern += "(\\.\\d+)?";
- }
- pattern += "$";
-
- if (!(new RegExp(pattern).test(value))) {
- return options.message ||
- options.notValid ||
- this.notValid ||
- this.message ||
- "must be a valid number";
- }
- }
-
- // Coerce the value to a number unless we're being strict.
- if (options.noStrings !== true && v.isString(value) && !v.isEmpty(value)) {
- value = +value;
- }
-
- // If it's not a number we shouldn't continue since it will compare it.
- if (!v.isNumber(value)) {
- return options.message ||
- options.notValid ||
- this.notValid ||
- this.message ||
- "is not a number";
- }
-
- // Same logic as above, sort of. Don't bother with comparisons if this
- // doesn't pass.
- if (options.onlyInteger && !v.isInteger(value)) {
- return options.message ||
- options.notInteger ||
- this.notInteger ||
- this.message ||
- "must be an integer";
- }
-
- for (name in checks) {
- count = options[name];
- if (v.isNumber(count) && !checks[name](value, count)) {
- // This picks the default message if specified
- // For example the greaterThan check uses the message from
- // this.notGreaterThan so we capitalize the name and prepend "not"
- var key = "not" + v.capitalize(name);
- var msg = options[key] ||
- this[key] ||
- this.message ||
- "must be %{type} %{count}";
-
- errors.push(v.format(msg, {
- count: count,
- type: prettify(name)
- }));
- }
- }
-
- if (options.odd && value % 2 !== 1) {
- errors.push(options.notOdd ||
- this.notOdd ||
- this.message ||
- "must be odd");
- }
- if (options.even && value % 2 !== 0) {
- errors.push(options.notEven ||
- this.notEven ||
- this.message ||
- "must be even");
- }
-
- if (errors.length) {
- return options.message || errors;
- }
- },
- datetime: v.extend(function(value, options) {
- if (!v.isFunction(this.parse) || !v.isFunction(this.format)) {
- throw new Error("Both the parse and format functions needs to be set to use the datetime/date validator");
- }
-
- // Empty values are fine
- if (!v.isDefined(value)) {
- return;
- }
-
- options = v.extend({}, this.options, options);
-
- var err
- , errors = []
- , earliest = options.earliest ? this.parse(options.earliest, options) : NaN
- , latest = options.latest ? this.parse(options.latest, options) : NaN;
-
- value = this.parse(value, options);
-
- // 86400000 is the number of milliseconds in a day, this is used to remove
- // the time from the date
- if (isNaN(value) || options.dateOnly && value % 86400000 !== 0) {
- err = options.notValid ||
- options.message ||
- this.notValid ||
- "must be a valid date";
- return v.format(err, {value: arguments[0]});
- }
-
- if (!isNaN(earliest) && value < earliest) {
- err = options.tooEarly ||
- options.message ||
- this.tooEarly ||
- "must be no earlier than %{date}";
- err = v.format(err, {
- value: this.format(value, options),
- date: this.format(earliest, options)
- });
- errors.push(err);
- }
-
- if (!isNaN(latest) && value > latest) {
- err = options.tooLate ||
- options.message ||
- this.tooLate ||
- "must be no later than %{date}";
- err = v.format(err, {
- date: this.format(latest, options),
- value: this.format(value, options)
- });
- errors.push(err);
- }
-
- if (errors.length) {
- return v.unique(errors);
- }
- }, {
- parse: null,
- format: null
- }),
- date: function(value, options) {
- options = v.extend({}, options, {dateOnly: true});
- return v.validators.datetime.call(v.validators.datetime, value, options);
- },
- format: function(value, options) {
- if (v.isString(options) || (options instanceof RegExp)) {
- options = {pattern: options};
- }
-
- options = v.extend({}, this.options, options);
-
- var message = options.message || this.message || "is invalid"
- , pattern = options.pattern
- , match;
-
- // Empty values are allowed
- if (!v.isDefined(value)) {
- return;
- }
- if (!v.isString(value)) {
- return message;
- }
-
- if (v.isString(pattern)) {
- pattern = new RegExp(options.pattern, options.flags);
- }
- match = pattern.exec(value);
- if (!match || match[0].length != value.length) {
- return message;
- }
- },
- inclusion: function(value, options) {
- // Empty values are fine
- if (!v.isDefined(value)) {
- return;
- }
- if (v.isArray(options)) {
- options = {within: options};
- }
- options = v.extend({}, this.options, options);
- if (v.contains(options.within, value)) {
- return;
- }
- var message = options.message ||
- this.message ||
- "^%{value} is not included in the list";
- return v.format(message, {value: value});
- },
- exclusion: function(value, options) {
- // Empty values are fine
- if (!v.isDefined(value)) {
- return;
- }
- if (v.isArray(options)) {
- options = {within: options};
- }
- options = v.extend({}, this.options, options);
- if (!v.contains(options.within, value)) {
- return;
- }
- var message = options.message || this.message || "^%{value} is restricted";
- if (v.isString(options.within[value])) {
- value = options.within[value];
- }
- return v.format(message, {value: value});
- },
- email: v.extend(function(value, options) {
- options = v.extend({}, this.options, options);
- var message = options.message || this.message || "is not a valid email";
- // Empty values are fine
- if (!v.isDefined(value)) {
- return;
- }
- if (!v.isString(value)) {
- return message;
- }
- if (!this.PATTERN.exec(value)) {
- return message;
- }
- }, {
- PATTERN: /^(?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*|"(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])*")@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?|\[(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?|[a-z0-9-]*[a-z0-9]:(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21-\x5a\x53-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])+)\])$/i
- }),
- equality: function(value, options, attribute, attributes, globalOptions) {
- if (!v.isDefined(value)) {
- return;
- }
-
- if (v.isString(options)) {
- options = {attribute: options};
- }
- options = v.extend({}, this.options, options);
- var message = options.message ||
- this.message ||
- "is not equal to %{attribute}";
-
- if (v.isEmpty(options.attribute) || !v.isString(options.attribute)) {
- throw new Error("The attribute must be a non empty string");
- }
-
- var otherValue = v.getDeepObjectValue(attributes, options.attribute)
- , comparator = options.comparator || function(v1, v2) {
- return v1 === v2;
- }
- , prettify = options.prettify ||
- (globalOptions && globalOptions.prettify) ||
- v.prettify;
-
- if (!comparator(value, otherValue, options, attribute, attributes)) {
- return v.format(message, {attribute: prettify(options.attribute)});
- }
- },
- // A URL validator that is used to validate URLs with the ability to
- // restrict schemes and some domains.
- url: function(value, options) {
- if (!v.isDefined(value)) {
- return;
- }
-
- options = v.extend({}, this.options, options);
-
- var message = options.message || this.message || "is not a valid url"
- , schemes = options.schemes || this.schemes || ['http', 'https']
- , allowLocal = options.allowLocal || this.allowLocal || false
- , allowDataUrl = options.allowDataUrl || this.allowDataUrl || false;
- if (!v.isString(value)) {
- return message;
- }
-
- // https://gist.github.com/dperini/729294
- var regex =
- "^" +
- // protocol identifier
- "(?:(?:" + schemes.join("|") + ")://)" +
- // user:pass authentication
- "(?:\\S+(?::\\S*)?@)?" +
- "(?:";
-
- var tld = "(?:\\.(?:[a-z\\u00a1-\\uffff]{2,}))";
-
- if (allowLocal) {
- tld += "?";
- } else {
- regex +=
- // IP address exclusion
- // private & local networks
- "(?!(?:10|127)(?:\\.\\d{1,3}){3})" +
- "(?!(?:169\\.254|192\\.168)(?:\\.\\d{1,3}){2})" +
- "(?!172\\.(?:1[6-9]|2\\d|3[0-1])(?:\\.\\d{1,3}){2})";
- }
-
- regex +=
- // IP address dotted notation octets
- // excludes loopback network 0.0.0.0
- // excludes reserved space >= 224.0.0.0
- // excludes network & broacast addresses
- // (first & last IP address of each class)
- "(?:[1-9]\\d?|1\\d\\d|2[01]\\d|22[0-3])" +
- "(?:\\.(?:1?\\d{1,2}|2[0-4]\\d|25[0-5])){2}" +
- "(?:\\.(?:[1-9]\\d?|1\\d\\d|2[0-4]\\d|25[0-4]))" +
- "|" +
- // host name
- "(?:(?:[a-z\\u00a1-\\uffff0-9]-*)*[a-z\\u00a1-\\uffff0-9]+)" +
- // domain name
- "(?:\\.(?:[a-z\\u00a1-\\uffff0-9]-*)*[a-z\\u00a1-\\uffff0-9]+)*" +
- tld +
- ")" +
- // port number
- "(?::\\d{2,5})?" +
- // resource path
- "(?:[/?#]\\S*)?" +
- "$";
-
- if (allowDataUrl) {
- // RFC 2397
- var mediaType = "\\w+\\/[-+.\\w]+(?:;[\\w=]+)*";
- var urlchar = "[A-Za-z0-9-_.!~\\*'();\\/?:@&=+$,%]*";
- var dataurl = "data:(?:"+mediaType+")?(?:;base64)?,"+urlchar;
- regex = "(?:"+regex+")|(?:^"+dataurl+"$)";
- }
-
- var PATTERN = new RegExp(regex, 'i');
- if (!PATTERN.exec(value)) {
- return message;
- }
- },
- type: v.extend(function(value, originalOptions, attribute, attributes, globalOptions) {
- if (v.isString(originalOptions)) {
- originalOptions = {type: originalOptions};
- }
-
- if (!v.isDefined(value)) {
- return;
- }
-
- var options = v.extend({}, this.options, originalOptions);
-
- var type = options.type;
- if (!v.isDefined(type)) {
- throw new Error("No type was specified");
- }
-
- var check;
- if (v.isFunction(type)) {
- check = type;
- } else {
- check = this.types[type];
- }
-
- if (!v.isFunction(check)) {
- throw new Error("validate.validators.type.types." + type + " must be a function.");
- }
-
- if (!check(value, options, attribute, attributes, globalOptions)) {
- var message = originalOptions.message ||
- this.messages[type] ||
- this.message ||
- options.message ||
- (v.isFunction(type) ? "must be of the correct type" : "must be of type %{type}");
-
- if (v.isFunction(message)) {
- message = message(value, originalOptions, attribute, attributes, globalOptions);
- }
-
- return v.format(message, {attribute: v.prettify(attribute), type: type});
- }
- }, {
- types: {
- object: function(value) {
- return v.isObject(value) && !v.isArray(value);
- },
- array: v.isArray,
- integer: v.isInteger,
- number: v.isNumber,
- string: v.isString,
- date: v.isDate,
- boolean: v.isBoolean
- },
- messages: {}
- })
- };
-
- validate.formatters = {
- detailed: function(errors) {return errors;},
- flat: v.flattenErrorsToArray,
- grouped: function(errors) {
- var attr;
-
- errors = v.groupErrorsByAttribute(errors);
- for (attr in errors) {
- errors[attr] = v.flattenErrorsToArray(errors[attr]);
- }
- return errors;
- },
- constraint: function(errors) {
- var attr;
- errors = v.groupErrorsByAttribute(errors);
- for (attr in errors) {
- errors[attr] = errors[attr].map(function(result) {
- return result.validator;
- }).sort();
- }
- return errors;
- }
- };
-
- validate.exposeModule(validate, this, exports, module, __webpack_require__(/*! !webpack amd define */ "./node_modules/webpack/buildin/amd-define.js"));
- }).call(this,
- true ? /* istanbul ignore next */ exports : undefined,
- true ? /* istanbul ignore next */ module : undefined,
- __webpack_require__(/*! !webpack amd define */ "./node_modules/webpack/buildin/amd-define.js"));
-
- /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../webpack/buildin/module.js */ "./node_modules/webpack/buildin/module.js")(module)))
-
- /***/ }),
-
- /***/ "./node_modules/webpack/buildin/amd-define.js":
- /*!***************************************!*\
- !*** (webpack)/buildin/amd-define.js ***!
- \***************************************/
- /*! no static exports found */
- /***/ (function(module, exports) {
-
- module.exports = function() {
- throw new Error("define cannot be used indirect");
- };
-
-
- /***/ }),
-
- /***/ "./node_modules/webpack/buildin/module.js":
- /*!***********************************!*\
- !*** (webpack)/buildin/module.js ***!
- \***********************************/
- /*! no static exports found */
- /***/ (function(module, exports) {
-
- module.exports = function(module) {
- if (!module.webpackPolyfill) {
- module.deprecate = function() {};
- module.paths = [];
- // module.parent = undefined by default
- if (!module.children) module.children = [];
- Object.defineProperty(module, "loaded", {
- enumerable: true,
- get: function() {
- return module.l;
- }
- });
- Object.defineProperty(module, "id", {
- enumerable: true,
- get: function() {
- return module.i;
- }
- });
- module.webpackPolyfill = 1;
- }
- return module;
- };
-
-
- /***/ }),
-
- /***/ "./resources/js/components/bucket/form.riot":
- /*!**************************************************!*\
- !*** ./resources/js/components/bucket/form.riot ***!
- \**************************************************/
- /*! exports provided: default */
- /***/ (function(module, __webpack_exports__, __webpack_require__) {
-
- "use strict";
- __webpack_require__.r(__webpack_exports__);
- /* harmony import */ var _tentakelfabrik_tiny_validator_src_validator__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @tentakelfabrik/tiny-validator/src/validator */ "./node_modules/@tentakelfabrik/tiny-validator/src/validator.js");
- /* harmony import */ var _field_error_riot__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../field-error.riot */ "./resources/js/components/field-error.riot");
-
-
-
- riot.register('field-error', _field_error_riot__WEBPACK_IMPORTED_MODULE_1__["default"])
-
- /* harmony default export */ __webpack_exports__["default"] = ({
- 'css': null,
-
- 'exports': {
- /**
- *
- * @param {[type]} props [description]
- * @param {[type]} state [description]
- *
- */
- onBeforeMount(props, state) {
- state.validator = new _tentakelfabrik_tiny_validator_src_validator__WEBPACK_IMPORTED_MODULE_0__["default"]({
- name: {
- presence: true,
- length: {
- maximum: 255
- }
- },
- description: {
- length: {
- maximum: 255
- }
- }
- }, this)
-
- //
- const meta = document.querySelector("meta[name='csrf-token']")
-
- if (meta) {
- state.csrfToken = meta.getAttribute("content")
- }
- },
-
- /**
- *
- *
- * @param {[type]} key
- * @param {[type]} defaultClass
- * @return {[type]}
- *
- */
- getClasses(key, defaultClass) {
- const classes = [
- defaultClass
- ]
-
- const errors = this.state.validator.errors(key)
-
- if (errors && errors.length > 0) {
- classes.push('is-danger')
- }
-
- return classes.join(' ')
- }
- },
-
- 'template': function(
- template,
- expressionTypes,
- bindingTypes,
- getComponent
- ) {
- return template(
- '<div class="form"><form method="POST"><input expr8="expr8" type="hidden" name="_token"/><div class="field is-horizontal"><div class="field-label is-normal"><label class="label required" for="name">\n name\n </label></div><div class="field-body"><div class="field"><p class="control"><input expr9="expr9" id="name" type="text" name="name"/><field-error expr10="expr10"></field-error></p></div></div></div><div class="field is-horizontal"><div class="field-label is-normal"><label class="label" for="description">\n description\n </label></div><div class="field-body"><div class="field"><p class="control"><textarea expr11="expr11" id="description" name="description"></textarea><field-error expr12="expr12"></field-error></p></div></div></div><div class="field is-horizontal"><div class="field-label is-normal"><label class="label" for="name">\n path\n </label></div><div class="field-body"><div class="field"><p class="control"><input expr13="expr13" id="path" type="text" name="path"/><field-error expr14="expr14"></field-error><span class="help">\n path for storage files, if empty default path will be used\n </span></p></div></div></div><div class="field is-horizontal"><div class="field-label is-normal"><label class="label" for="public">\n public\n </label></div><div class="field-body"><div class="field"><input expr15="expr15" id="public" type="checkbox" name="public" value="1"/><span class="help">\n everyone can see bucket, files and download them\n </span></div></div></div><div class="field"><div class="control"><button expr16="expr16" class="button is-primary" type="submit">\n Create\n </button></div></div></form></div>',
- [
- {
- 'type': bindingTypes.IF,
-
- 'evaluate': function(
- scope
- ) {
- return scope.state.csrfToken;
- },
-
- 'redundantAttribute': 'expr8',
- 'selector': '[expr8]',
-
- 'template': template(
- null,
- [
- {
- 'expressions': [
- {
- 'type': expressionTypes.ATTRIBUTE,
- 'name': 'value',
-
- 'evaluate': function(
- scope
- ) {
- return scope.state.csrfToken;
- }
- }
- ]
- }
- ]
- )
- },
- {
- 'redundantAttribute': 'expr9',
- 'selector': '[expr9]',
-
- 'expressions': [
- {
- 'type': expressionTypes.ATTRIBUTE,
- 'name': 'class',
-
- 'evaluate': function(
- scope
- ) {
- return scope.getClasses('name', 'input');
- }
- },
- {
- 'type': expressionTypes.VALUE,
-
- 'evaluate': function(
- scope
- ) {
- return scope.props.name;
- }
- },
- {
- 'type': expressionTypes.EVENT,
- 'name': 'onkeyup',
-
- 'evaluate': function(
- scope
- ) {
- return (event) => { scope.state.validator.handle(event, 'name') };
- }
- }
- ]
- },
- {
- 'type': bindingTypes.TAG,
- 'getComponent': getComponent,
-
- 'evaluate': function(
- scope
- ) {
- return 'field-error';
- },
-
- 'slots': [],
-
- 'attributes': [
- {
- 'type': expressionTypes.ATTRIBUTE,
- 'name': 'errors',
-
- 'evaluate': function(
- scope
- ) {
- return scope.state.validator.errors('name');
- }
- }
- ],
-
- 'redundantAttribute': 'expr10',
- 'selector': '[expr10]'
- },
- {
- 'redundantAttribute': 'expr11',
- 'selector': '[expr11]',
-
- 'expressions': [
- {
- 'type': expressionTypes.ATTRIBUTE,
- 'name': 'class',
-
- 'evaluate': function(
- scope
- ) {
- return scope.getClasses('description', 'textarea');
- }
- },
- {
- 'type': expressionTypes.VALUE,
-
- 'evaluate': function(
- scope
- ) {
- return scope.props.description;
- }
- },
- {
- 'type': expressionTypes.EVENT,
- 'name': 'onkeyup',
-
- 'evaluate': function(
- scope
- ) {
- return (event) => { scope.state.validator.handle(event, 'description') };
- }
- }
- ]
- },
- {
- 'type': bindingTypes.TAG,
- 'getComponent': getComponent,
-
- 'evaluate': function(
- scope
- ) {
- return 'field-error';
- },
-
- 'slots': [],
-
- 'attributes': [
- {
- 'type': expressionTypes.ATTRIBUTE,
- 'name': 'errors',
-
- 'evaluate': function(
- scope
- ) {
- return scope.state.validator.errors('description');
- }
- }
- ],
-
- 'redundantAttribute': 'expr12',
- 'selector': '[expr12]'
- },
- {
- 'redundantAttribute': 'expr13',
- 'selector': '[expr13]',
-
- 'expressions': [
- {
- 'type': expressionTypes.ATTRIBUTE,
- 'name': 'class',
-
- 'evaluate': function(
- scope
- ) {
- return scope.getClasses('path', 'input');
- }
- },
- {
- 'type': expressionTypes.VALUE,
-
- 'evaluate': function(
- scope
- ) {
- return scope.props.path;
- }
- },
- {
- 'type': expressionTypes.EVENT,
- 'name': 'onkeyup',
-
- 'evaluate': function(
- scope
- ) {
- return (event) => { scope.state.validator.handle(event, 'path') };
- }
- }
- ]
- },
- {
- 'type': bindingTypes.TAG,
- 'getComponent': getComponent,
-
- 'evaluate': function(
- scope
- ) {
- return 'field-error';
- },
-
- 'slots': [],
-
- 'attributes': [
- {
- 'type': expressionTypes.ATTRIBUTE,
- 'name': 'errors',
-
- 'evaluate': function(
- scope
- ) {
- return scope.state.validator.errors('path');
- }
- }
- ],
-
- 'redundantAttribute': 'expr14',
- 'selector': '[expr14]'
- },
- {
- 'redundantAttribute': 'expr15',
- 'selector': '[expr15]',
-
- 'expressions': [
- {
- 'type': expressionTypes.ATTRIBUTE,
- 'name': 'checked',
-
- 'evaluate': function(
- scope
- ) {
- return scope.props.public;
- }
- }
- ]
- },
- {
- 'redundantAttribute': 'expr16',
- 'selector': '[expr16]',
-
- 'expressions': [
- {
- 'type': expressionTypes.ATTRIBUTE,
- 'name': 'disabled',
-
- 'evaluate': function(
- scope
- ) {
- return scope.state.validator.errors().length > 0;
- }
- }
- ]
- }
- ]
- );
- },
-
- 'name': 'urban-bucket-form'
- });
-
- /***/ }),
-
- /***/ "./resources/js/components/field-error.riot":
- /*!**************************************************!*\
- !*** ./resources/js/components/field-error.riot ***!
- \**************************************************/
- /*! exports provided: default */
- /***/ (function(module, __webpack_exports__, __webpack_require__) {
-
- "use strict";
- __webpack_require__.r(__webpack_exports__);
- /* harmony default export */ __webpack_exports__["default"] = ({
- 'css': null,
-
- 'exports': {
- state: {
- errors: [
-
- ]
- },
-
- /**
- * check if errors from props has an error, if not reset errors in state
- *
- * @param {object} props
- * @param {object} state
- *
- */
- onBeforeUpdate(props, state) {
- if (props.errors && props.errors.length > 0) {
- state.errors = props.errors
- } else {
- state.errors = []
- }
- }
- },
-
- 'template': function(
- template,
- expressionTypes,
- bindingTypes,
- getComponent
- ) {
- return template(
- '<div expr21="expr21" class="field-error"></div>',
- [
- {
- 'type': bindingTypes.IF,
-
- 'evaluate': function(
- scope
- ) {
- return scope.state.errors.length > 0;
- },
-
- 'redundantAttribute': 'expr21',
- 'selector': '[expr21]',
-
- 'template': template(
- '<ul><li expr22="expr22" class="help is-danger"></li></ul>',
- [
- {
- 'type': bindingTypes.EACH,
- 'getKey': null,
- 'condition': null,
-
- 'template': template(
- ' ',
- [
- {
- 'expressions': [
- {
- 'type': expressionTypes.TEXT,
- 'childNodeIndex': 0,
-
- 'evaluate': function(
- scope
- ) {
- return scope.error;
- }
- }
- ]
- }
- ]
- ),
-
- 'redundantAttribute': 'expr22',
- 'selector': '[expr22]',
- 'itemName': 'error',
- 'indexName': null,
-
- 'evaluate': function(
- scope
- ) {
- return scope.state.errors;
- }
- }
- ]
- )
- }
- ]
- );
- },
-
- 'name': 'field-error'
- });
-
- /***/ }),
-
- /***/ "./resources/js/views/bucket.js":
- /*!**************************************!*\
- !*** ./resources/js/views/bucket.js ***!
- \**************************************/
- /*! no exports provided */
- /***/ (function(module, __webpack_exports__, __webpack_require__) {
-
- "use strict";
- __webpack_require__.r(__webpack_exports__);
- /* harmony import */ var _components_bucket_form_riot__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./../components/bucket/form.riot */ "./resources/js/components/bucket/form.riot");
-
- /**
- * Bucket
- *
- *
- */
- // register components
-
- riot.register('urban-bucket-form', _components_bucket_form_riot__WEBPACK_IMPORTED_MODULE_0__["default"]);
-
- /***/ }),
-
- /***/ 2:
- /*!********************************************!*\
- !*** multi ./resources/js/views/bucket.js ***!
- \********************************************/
- /*! no static exports found */
- /***/ (function(module, exports, __webpack_require__) {
-
- module.exports = __webpack_require__(/*! /home/herrhase/Workspace/herrhase/urban-filehub/resources/js/views/bucket.js */"./resources/js/views/bucket.js");
-
-
- /***/ })
-
- /******/ });
|