diff --git a/Changelog.md b/Changelog.md index a36393bd..9222d69f 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,3 +1,7 @@ +## 1.3.0-rc.5 +### Changed + - Fixing the lib to contain production build of js files. + ## 1.3.0-rc.4 ### Changed - "main" in package.json changed to "dist" to support imports into other libraries. diff --git a/config/webpack.lib.js b/config/webpack.lib.js new file mode 100644 index 00000000..30e2670f --- /dev/null +++ b/config/webpack.lib.js @@ -0,0 +1,36 @@ +const path = require('path'); +const TsconfigPathsPlugin = require('tsconfig-paths-webpack-plugin'); +module.exports = { + mode: 'production', + entry: { + 'index': './src/index.ts', + 'base/index': './src/base/index.ts', + 'components/index': './src/components/index.ts', + 'model/index': './src/model/index.ts', + 'modules/index': './src/modules/index.ts', + 'sdk/index': './src/sdk/index.ts', + 'utils/index': './src/utils/index.ts', + 'validator/index': './src/validator/index.ts' + }, + output: { + path: path.resolve(__dirname, '../lib'), + environment: { + arrowFunction: false + }, + }, + resolve: { + extensions: ['.ts', '.js'], + plugins: [new TsconfigPathsPlugin({ + configFile: path.resolve(__dirname, '..', 'tsconfig.json') + })] + }, + module: { + rules: [ + { + test: /\.ts$/, + exclude: /\.spec\.ts$/, + loader: "ts-loader" + } + ] + } +}; \ No newline at end of file diff --git a/lib/base/Components.js b/lib/base/Components.js deleted file mode 100644 index 88202294..00000000 --- a/lib/base/Components.js +++ /dev/null @@ -1,120 +0,0 @@ -"use strict"; -var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { - var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; - if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); - else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; - return c > 3 && r && Object.defineProperty(target, key, r), r; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.render = exports.Components = void 0; -/** - * Manages all of the components within the Form.io renderer. - */ -var Components = /** @class */ (function () { - function Components() { - } - /** - * Gets a specific component type. - * - * @param type - * @param from - * @returns - */ - Components.component = function (type, from) { - if (from === void 0) { from = 'components'; } - if (Components[from][type]) { - return Components[from][type]; - } - else { - return Components[from].component; - } - }; - /** - * Create a new component. - * - * ```ts - * const htmlComp = Components.createComponent({ - * type: 'html', - * tag: 'p', - * content: 'This is a test.' - * }) - * ``` - * - * @param comp The component JSON you wish to create. - * @param options The options to pass to this component. - * @param data The data you wish to provide to this component. - */ - Components.create = function (comp, options, data) { - return new (Components.component(comp.type))(comp, options, data); - }; - /** - * Adds a base decorator type component. - * - * @param baseComponent - * @param type - */ - Components.addDecorator = function (decorator, type) { - Components.decorators[type] = decorator; - }; - /** - * Adds a new component to the renderer. Can either be a component class or a component JSON - * to be imported. - * - * @param component - */ - Components.addComponent = function (component, type) { - if (!component) { - return; - } - if (typeof component !== 'function') { - return Components.importComponent(component); - } - Components.components[type] = component; - return component; - }; - /** - * Imports a new component based on the JSON decorator of that component. - * @param component - */ - Components.importComponent = function (props) { - if (props === void 0) { props = {}; } - var Decorator = Components.component(props.extends, 'decorators'); - var ExtendedComponent = /** @class */ (function () { - function ExtendedComponent() { - } - ExtendedComponent = __decorate([ - Decorator(props) - ], ExtendedComponent); - return ExtendedComponent; - }()); - Components.addComponent(ExtendedComponent, props.type); - }; - /** - * Sets the components used within this renderer. - * @param components - */ - Components.setComponents = function (components) { - Object.assign(Components.components, components); - }; - /** - * An array of Components available to be rendered. - */ - Components.components = {}; - Components.decorators = {}; - return Components; -}()); -exports.Components = Components; -/** - * Render a component attached to an html component. - * - * @param element - * @param component - * @param options - * @param data - */ -function render(element, component, options, data) { - if (options === void 0) { options = {}; } - if (data === void 0) { data = {}; } - return Components.create(component, options, data).attach(element); -} -exports.render = render; diff --git a/lib/base/Template.js b/lib/base/Template.js deleted file mode 100644 index b86b4a8a..00000000 --- a/lib/base/Template.js +++ /dev/null @@ -1,129 +0,0 @@ -"use strict"; -var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { - if (k2 === undefined) k2 = k; - var desc = Object.getOwnPropertyDescriptor(m, k); - if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { - desc = { enumerable: true, get: function() { return m[k]; } }; - } - Object.defineProperty(o, k2, desc); -}) : (function(o, m, k, k2) { - if (k2 === undefined) k2 = k; - o[k2] = m[k]; -})); -var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { - Object.defineProperty(o, "default", { enumerable: true, value: v }); -}) : function(o, v) { - o["default"] = v; -}); -var __importStar = (this && this.__importStar) || function (mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); - __setModuleDefault(result, mod); - return result; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.Template = void 0; -var _ = __importStar(require("@formio/lodash")); -/** - * Manages all the available templates which can be rendered. - */ -var Template = /** @class */ (function () { - function Template() { - } - /** - * Adds a collection of template frameworks to the renderer. - * @param templates - */ - Template.addTemplates = function (templates) { - var framework = Template.framework; - Template.templates = _.merge(Template.templates, templates); - Template.framework = framework; - }; - /** - * Adds some templates to the existing template. - * @param name - * @param template - */ - Template.addTemplate = function (name, template) { - Template.templates[name] = _.merge(Template.current, template); - }; - /** - * Extend an existing template. - * @param name - * @param template - */ - Template.extendTemplate = function (name, template) { - Template.templates[name] = _.merge(Template.templates[name], template); - }; - /** - * Sets a template. - * @param name - * @param template - */ - Template.setTemplate = function (name, template) { - Template.addTemplate(name, template); - }; - Object.defineProperty(Template, "current", { - /** - * Get the current template. - */ - get: function () { - return Template._current; - }, - /** - * Set the current template. - */ - set: function (templates) { - var defaultTemplates = Template.current; - Template._current = _.merge(defaultTemplates, templates); - }, - enumerable: false, - configurable: true - }); - Object.defineProperty(Template, "framework", { - /** - * Gets the current framework. - */ - get: function () { - return Template._framework; - }, - /** - * Sets the current framework. - */ - set: function (framework) { - if (Template.templates.hasOwnProperty(framework)) { - Template._framework = framework; - Template._current = Template.templates[framework]; - } - }, - enumerable: false, - configurable: true - }); - /** - * Render a partial within the current template. - * @param name - * @param ctx - * @param mode - * @returns - */ - Template.render = function (name, ctx, mode, defaultTemplate) { - if (mode === void 0) { mode = 'html'; } - if (defaultTemplate === void 0) { defaultTemplate = null; } - if (typeof name === 'function') { - return name(ctx); - } - if (this.current[name] && this.current[name][mode]) { - return this.current[name][mode](ctx); - } - if (defaultTemplate) { - return defaultTemplate(ctx); - } - return 'Unknown template'; - }; - Template.templates = []; - Template._current = {}; - Template._framework = 'bootstrap'; - return Template; -}()); -exports.Template = Template; diff --git a/lib/base/array/ArrayComponent.js b/lib/base/array/ArrayComponent.js deleted file mode 100644 index 0b249178..00000000 --- a/lib/base/array/ArrayComponent.js +++ /dev/null @@ -1,78 +0,0 @@ -"use strict"; -var __extends = (this && this.__extends) || (function () { - var extendStatics = function (d, b) { - extendStatics = Object.setPrototypeOf || - ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || - function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; - return extendStatics(d, b); - }; - return function (d, b) { - if (typeof b !== "function" && b !== null) - throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); - extendStatics(d, b); - function __() { this.constructor = d; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); - }; -})(); -Object.defineProperty(exports, "__esModule", { value: true }); -exports.ArrayComponent = void 0; -var Components_1 = require("../Components"); -var model_1 = require("@formio/model"); -var NestedComponent_1 = require("../nested/NestedComponent"); -/** - * An array data type component. This provides a nested component that creates "rows" of data - * where each row creates new instances of the JSON components and sets the data context for - * each row according to the row it is within. - * - * For example, if you have the following JSON schema. - * - * ``` - * { - * type: 'array', - * key: 'customers', - * components: [ - * { - * type: 'datavalue', - * key: 'firstName' - * }, - * { - * type: 'datavalue', - * key: 'lastName' - * } - * ] - * } - * ``` - * - * You can now create multiple rows using the following data. - * - * ``` - * { - * customers: [ - * {firstName: 'Joe', lastName: 'Smith'}, - * {firstName: 'Sally', lastName: 'Thompson'}, - * {firstName: 'Sue', lastName: 'Warner'} - * ] - * } - * ``` - */ -function ArrayComponent(props) { - if (props === void 0) { props = {}; } - if (!props.type) { - props.type = 'array'; - } - if (!props.model) { - props.model = model_1.NestedArrayModel; - } - return function (BaseClass) { - return /** @class */ (function (_super) { - __extends(ExtendedArrayComponent, _super); - function ExtendedArrayComponent() { - return _super !== null && _super.apply(this, arguments) || this; - } - return ExtendedArrayComponent; - }((0, NestedComponent_1.NestedComponent)(props)(BaseClass))); - }; -} -exports.ArrayComponent = ArrayComponent; -Components_1.Components.addDecorator(ArrayComponent, 'array'); -Components_1.Components.addComponent(ArrayComponent()(), 'array'); diff --git a/lib/base/array/fixtures/comp1.js b/lib/base/array/fixtures/comp1.js deleted file mode 100644 index f47b5651..00000000 --- a/lib/base/array/fixtures/comp1.js +++ /dev/null @@ -1,16 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.default = { - type: 'array', - key: 'employees', - components: [ - { - type: 'component', - key: 'firstName' - }, - { - type: 'component', - key: 'lastName' - } - ] -}; diff --git a/lib/base/array/fixtures/comp2.js b/lib/base/array/fixtures/comp2.js deleted file mode 100644 index 13b79cbf..00000000 --- a/lib/base/array/fixtures/comp2.js +++ /dev/null @@ -1,44 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.default = { - type: 'array', - key: 'employees', - components: [ - { - type: 'component', - key: 'firstName' - }, - { - type: 'component', - key: 'lastName' - }, - { - type: 'data', - key: 'department', - components: [ - { - type: 'component', - key: 'name' - }, - { - type: 'component', - key: 'phoneNumber' - } - ] - }, - { - type: 'array', - key: 'children', - components: [ - { - type: 'component', - key: 'firstName' - }, - { - type: 'component', - key: 'dob' - } - ] - } - ] -}; diff --git a/lib/base/array/fixtures/index.js b/lib/base/array/fixtures/index.js deleted file mode 100644 index 03120ec2..00000000 --- a/lib/base/array/fixtures/index.js +++ /dev/null @@ -1,10 +0,0 @@ -"use strict"; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.comp2 = exports.comp1 = void 0; -var comp1_1 = __importDefault(require("./comp1")); -exports.comp1 = comp1_1.default; -var comp2_1 = __importDefault(require("./comp2")); -exports.comp2 = comp2_1.default; diff --git a/lib/base/component/Component.js b/lib/base/component/Component.js deleted file mode 100644 index 857d9301..00000000 --- a/lib/base/component/Component.js +++ /dev/null @@ -1,439 +0,0 @@ -"use strict"; -var __extends = (this && this.__extends) || (function () { - var extendStatics = function (d, b) { - extendStatics = Object.setPrototypeOf || - ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || - function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; - return extendStatics(d, b); - }; - return function (d, b) { - if (typeof b !== "function" && b !== null) - throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); - extendStatics(d, b); - function __() { this.constructor = d; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); - }; -})(); -var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { - if (k2 === undefined) k2 = k; - var desc = Object.getOwnPropertyDescriptor(m, k); - if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { - desc = { enumerable: true, get: function() { return m[k]; } }; - } - Object.defineProperty(o, k2, desc); -}) : (function(o, m, k, k2) { - if (k2 === undefined) k2 = k; - o[k2] = m[k]; -})); -var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { - Object.defineProperty(o, "default", { enumerable: true, value: v }); -}) : function(o, v) { - o["default"] = v; -}); -var __importStar = (this && this.__importStar) || function (mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); - __setModuleDefault(result, mod); - return result; -}; -var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { - function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } - return new (P || (P = Promise))(function (resolve, reject) { - function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } - function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } - function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } - step((generator = generator.apply(thisArg, _arguments || [])).next()); - }); -}; -var __generator = (this && this.__generator) || function (thisArg, body) { - var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; - return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; - function verb(n) { return function (v) { return step([n, v]); }; } - function step(op) { - if (f) throw new TypeError("Generator is already executing."); - while (g && (g = 0, op[0] && (_ = 0)), _) try { - if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; - if (y = 0, t) op = [op[0] & 2, t.value]; - switch (op[0]) { - case 0: case 1: t = op; break; - case 4: _.label++; return { value: op[1], done: false }; - case 5: _.label++; y = op[1]; op = [0]; continue; - case 7: op = _.ops.pop(); _.trys.pop(); continue; - default: - if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } - if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } - if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } - if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } - if (t[2]) _.ops.pop(); - _.trys.pop(); continue; - } - op = body.call(thisArg, _); - } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } - if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; - } -}; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.Component = void 0; -var Components_1 = require("../Components"); -var Template_1 = require("../Template"); -var Evaluator_1 = require("@formio/utils/Evaluator"); -var dom = __importStar(require("@formio/utils/dom")); -var sanitize_1 = require("@formio/utils/sanitize"); -var model_1 = require("@formio/model"); -var object_1 = require("@formio/lodash/lib/object"); -function Component(props) { - if (props === void 0) { props = {}; } - props = (0, object_1.merge)({ - type: 'component', - template: false, - schema: { - persistent: true, - protected: false, - } - }, props); - props.schema.type = props.type; - var ModelClass = props.model || model_1.Model; - return function (BaseClass) { - return /** @class */ (function (_super) { - __extends(ExtendedComponent, _super); - function ExtendedComponent() { - var _this = _super !== null && _super.apply(this, arguments) || this; - /** - * Boolean to let us know if this component is attached to the DOM or not. - */ - _this.attached = false; - /** - * The DOM element references used for component logic. - */ - _this.refs = {}; - /** - * The template to render for this component. - */ - _this.template = props.template; - /** - * An array of attached listeners. - */ - _this.attachedListeners = []; - return _this; - } - Object.defineProperty(ExtendedComponent.prototype, "defaultOptions", { - get: function () { - return { - language: 'en', - namespace: 'formio' - }; - }, - enumerable: false, - configurable: true - }); - Object.defineProperty(ExtendedComponent.prototype, "defaultTemplate", { - get: function () { - return function (ctx) { return "".concat(ctx.t('Unknown Component'), ""); }; - }, - enumerable: false, - configurable: true - }); - /** - * Interpolate a template string. - * @param template - The template string to interpolate. - * @param context - The context variables to pass to the interpolation. - */ - ExtendedComponent.prototype.interpolate = function (template, context) { - return Evaluator_1.Evaluator.interpolate(template, context); - }; - /** - * The rendering context. - * @param context - The existing contexts from parent classes. - */ - ExtendedComponent.prototype.renderContext = function (context) { - if (context === void 0) { context = {}; } - if (_super.prototype.renderContext) { - return _super.prototype.renderContext.call(this, context); - } - return context; - }; - /** - * Performs an evaluation using the evaluation context of this component. - * - * @param func - * @param args - * @param ret - * @param tokenize - * @return {*} - */ - ExtendedComponent.prototype.evaluate = function (func, args, ret, tokenize) { - if (args === void 0) { args = {}; } - if (ret === void 0) { ret = ''; } - if (tokenize === void 0) { tokenize = false; } - return Evaluator_1.Evaluator.evaluate(func, this.evalContext(args), ret, tokenize); - }; - /** - * Renders this component as an HTML string. - */ - ExtendedComponent.prototype.render = function (context) { - if (context === void 0) { context = {}; } - if (_super.prototype.render) { - return _super.prototype.render.call(this, context); - } - return this.renderTemplate((this.template || this.component.type), this.renderContext(context)); - }; - /** - * Returns the template references. - */ - ExtendedComponent.prototype.getRefs = function () { - if (_super.prototype.getRefs) { - return _super.prototype.getRefs.call(this); - } - return {}; - }; - /** - * Loads the elemement references. - * @param element - */ - ExtendedComponent.prototype.loadRefs = function (element) { - var refs = this.getRefs(); - for (var ref in refs) { - if (refs[ref] === 'single') { - this.refs[ref] = element.querySelector("[ref=\"".concat(ref, "\"]")); - } - else { - this.refs[ref] = element.querySelectorAll("[ref=\"".concat(ref, "\"]")); - } - } - }; - /** - * Renders the component and then attaches this component to the HTMLElement. - * @param element - */ - ExtendedComponent.prototype.attach = function (element) { - return __awaiter(this, void 0, void 0, function () { - var parent, index; - return __generator(this, function (_a) { - switch (_a.label) { - case 0: - if (this.element && !element) { - element = this.element; - } - if (!element) { - return [2 /*return*/, this]; - } - parent = element.parentNode; - if (!parent) { - return [2 /*return*/, this]; - } - index = Array.prototype.indexOf.call(parent.children, element); - element.outerHTML = String(this.sanitize(this.render())); - element = parent.children[index]; - this.element = element; - this.loadRefs(this.element); - if (!_super.prototype.attach) return [3 /*break*/, 2]; - return [4 /*yield*/, _super.prototype.attach.call(this, element)]; - case 1: - _a.sent(); - _a.label = 2; - case 2: - this.attached = true; - return [2 /*return*/, this]; - } - }); - }); - }; - /** - * Redraw this component. - * @returns - */ - ExtendedComponent.prototype.redraw = function () { - return __awaiter(this, void 0, void 0, function () { - return __generator(this, function (_a) { - if (this.element) { - this.clear(); - return [2 /*return*/, this.attach()]; - } - return [2 /*return*/]; - }); - }); - }; - /** - * Sanitize an html string. - * - * @param string - * @returns {*} - */ - ExtendedComponent.prototype.sanitize = function (dirty) { - return (0, sanitize_1.sanitize)(dirty, this.options); - }; - Object.defineProperty(ExtendedComponent.prototype, "translations", { - /** - * Get all available translations. - */ - get: function () { - if (this.options.language && - this.options.i18n && - this.options.i18n[this.options.language]) { - return this.options.i18n[this.options.language]; - } - return {}; - }, - enumerable: false, - configurable: true - }); - /** - * Tranlation method to translate a string being rendered. - * @param str - */ - ExtendedComponent.prototype.t = function (str) { - if (this.translations[str]) { - return this.translations[str]; - } - return str; - }; - /** - * The evaluation context for interpolations. - * @param extend - */ - ExtendedComponent.prototype.evalContext = function (extend) { - var _this = this; - if (extend === void 0) { extend = {}; } - return Object.assign({ - instance: this, - component: this.component, - options: this.options, - row: this.data, - data: this.root ? this.root.data : this.data, - rowIndex: this.rowIndex, - value: function () { return _this.dataValue; }, - t: function (str) { return _this.t(str); } - }, extend); - }; - /** - * Render a template with provided context. - * @param name - * @param ctx - */ - ExtendedComponent.prototype.renderTemplate = function (name, ctx) { - if (ctx === void 0) { ctx = {}; } - return Template_1.Template.render(name, this.evalContext(ctx), 'html', this.defaultTemplate); - }; - /** - * Determines if the value of this component is redacted from the user as if it is coming from the server, but is protected. - * - * @return {boolean|*} - */ - ExtendedComponent.prototype.isValueRedacted = function () { - return (this.component.protected || - !this.component.persistent || - (this.component.persistent === 'client-only')); - }; - /** - * Sets the data value and updates the view representation. - * @param value - */ - ExtendedComponent.prototype.setValue = function (value) { - var changed = false; - if (_super.prototype.setValue) { - changed = _super.prototype.setValue.call(this, value); - } - return this.updateValue(value) || changed; - }; - /** - * Returns the main HTML Element for this component. - */ - ExtendedComponent.prototype.getElement = function () { - return this.element; - }; - /** - * Remove all event handlers. - */ - ExtendedComponent.prototype.detach = function () { - this.refs = {}; - this.attached = false; - this.removeAttachedListeners(); - if (_super.prototype.detach) { - _super.prototype.detach.call(this); - } - }; - /** - * Clear an element. - */ - ExtendedComponent.prototype.clear = function () { - this.detach(); - dom.empty(this.getElement()); - if (_super.prototype.clear) { - _super.prototype.clear.call(this); - } - }; - /** - * Appends an element to this component. - * @param element - */ - ExtendedComponent.prototype.append = function (element) { - dom.appendTo(element, this.element); - }; - /** - * Prepends an element to this component. - * @param element - */ - ExtendedComponent.prototype.prepend = function (element) { - dom.prependTo(element, this.element); - }; - /** - * Removes an element from this component. - * @param element - */ - ExtendedComponent.prototype.removeChild = function (element) { - dom.removeChildFrom(element, this.element); - }; - /** - * Wrapper method to add an event listener to an HTML element. - * - * @param obj - * The DOM element to add the event to. - * @param type - * The event name to add. - * @param func - * The callback function to be executed when the listener is triggered. - * @param persistent - * If this listener should persist beyond "destroy" commands. - */ - ExtendedComponent.prototype.addEventListener = function (obj, type, func) { - if (!obj) { - return; - } - if ('addEventListener' in obj) { - obj.addEventListener(type, func, false); - } - else if ('attachEvent' in obj) { - obj.attachEvent("on".concat(type), func); - } - this.attachedListeners.push({ obj: obj, type: type, func: func }); - return this; - }; - /** - * Remove all the attached listeners. - */ - ExtendedComponent.prototype.removeAttachedListeners = function () { - var _this = this; - this.attachedListeners.forEach(function (item) { return _this.removeEventListener(item.obj, item.type, item.func); }); - this.attachedListeners = []; - }; - /** - * Remove an event listener from the object. - * - * @param obj - * @param type - */ - ExtendedComponent.prototype.removeEventListener = function (obj, type, func) { - if (obj) { - obj.removeEventListener(type, func); - } - return this; - }; - return ExtendedComponent; - }(ModelClass(props)(BaseClass))); - }; -} -exports.Component = Component; -// Add the default component. -Components_1.Components.addDecorator(Component, 'component'); -Components_1.Components.addComponent(Component()(), 'component'); diff --git a/lib/base/data/DataComponent.js b/lib/base/data/DataComponent.js deleted file mode 100644 index 8d07c674..00000000 --- a/lib/base/data/DataComponent.js +++ /dev/null @@ -1,56 +0,0 @@ -"use strict"; -var __extends = (this && this.__extends) || (function () { - var extendStatics = function (d, b) { - extendStatics = Object.setPrototypeOf || - ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || - function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; - return extendStatics(d, b); - }; - return function (d, b) { - if (typeof b !== "function" && b !== null) - throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); - extendStatics(d, b); - function __() { this.constructor = d; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); - }; -})(); -Object.defineProperty(exports, "__esModule", { value: true }); -exports.DataComponent = void 0; -var Components_1 = require("../Components"); -var model_1 = require("@formio/model"); -var NestedComponent_1 = require("../nested/NestedComponent"); -/** - * A DataComponent is one that establishes a new data context for all of its - * children at the specified "key" of this comopnent. For example, if this data - * component has a key of "employee", and then some components within the data - * component of "firstName" and "lastName", the data structure provided by this - * component would resemble the following. - * - * { - * "employee": { - * "firstName": "Bob", - * "lastName": "Smith" - * } - * } - */ -function DataComponent(props) { - if (props === void 0) { props = {}; } - if (!props.type) { - props.type = 'data'; - } - if (!props.model) { - props.model = model_1.NestedDataModel; - } - return function (BaseClass) { - return /** @class */ (function (_super) { - __extends(ExtendedDataComponent, _super); - function ExtendedDataComponent() { - return _super !== null && _super.apply(this, arguments) || this; - } - return ExtendedDataComponent; - }((0, NestedComponent_1.NestedComponent)(props)(BaseClass))); - }; -} -exports.DataComponent = DataComponent; -Components_1.Components.addDecorator(DataComponent, 'data'); -Components_1.Components.addComponent(DataComponent()(), 'data'); diff --git a/lib/base/data/fixtures/comp1.js b/lib/base/data/fixtures/comp1.js deleted file mode 100644 index d17116f1..00000000 --- a/lib/base/data/fixtures/comp1.js +++ /dev/null @@ -1,16 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.default = { - type: 'data', - key: 'employee', - components: [ - { - type: 'component', - key: 'firstName' - }, - { - type: 'component', - key: 'lastName' - } - ] -}; diff --git a/lib/base/data/fixtures/index.js b/lib/base/data/fixtures/index.js deleted file mode 100644 index c561dacd..00000000 --- a/lib/base/data/fixtures/index.js +++ /dev/null @@ -1,8 +0,0 @@ -"use strict"; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.comp1 = void 0; -var comp1_1 = __importDefault(require("./comp1")); -exports.comp1 = comp1_1.default; diff --git a/lib/base/index.js b/lib/base/index.js index a8de38d4..1c3905a1 100644 --- a/lib/base/index.js +++ b/lib/base/index.js @@ -1,31 +1,2 @@ -"use strict"; -var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { - if (k2 === undefined) k2 = k; - var desc = Object.getOwnPropertyDescriptor(m, k); - if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { - desc = { enumerable: true, get: function() { return m[k]; } }; - } - Object.defineProperty(o, k2, desc); -}) : (function(o, m, k, k2) { - if (k2 === undefined) k2 = k; - o[k2] = m[k]; -})); -var __exportStar = (this && this.__exportStar) || function(m, exports) { - for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p); -}; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.Template = exports.ArrayComponent = exports.DataComponent = exports.NestedComponent = exports.Component = exports.render = exports.Components = void 0; -var Components_1 = require("./Components"); -Object.defineProperty(exports, "Components", { enumerable: true, get: function () { return Components_1.Components; } }); -Object.defineProperty(exports, "render", { enumerable: true, get: function () { return Components_1.render; } }); -var Component_1 = require("./component/Component"); -Object.defineProperty(exports, "Component", { enumerable: true, get: function () { return Component_1.Component; } }); -var NestedComponent_1 = require("./nested/NestedComponent"); -Object.defineProperty(exports, "NestedComponent", { enumerable: true, get: function () { return NestedComponent_1.NestedComponent; } }); -var DataComponent_1 = require("./data/DataComponent"); -Object.defineProperty(exports, "DataComponent", { enumerable: true, get: function () { return DataComponent_1.DataComponent; } }); -var ArrayComponent_1 = require("./array/ArrayComponent"); -Object.defineProperty(exports, "ArrayComponent", { enumerable: true, get: function () { return ArrayComponent_1.ArrayComponent; } }); -var Template_1 = require("./Template"); -Object.defineProperty(exports, "Template", { enumerable: true, get: function () { return Template_1.Template; } }); -__exportStar(require("@formio/model"), exports); +/*! For license information please see index.js.LICENSE.txt */ +!function(){var t={2937:function(t,e,n){"use strict";var r=this&&this.__spreadArray||function(t,e,n){if(n||2===arguments.length)for(var r,o=0,i=e.length;o0?t.slice(e):t},e.dropRight=function(t,e){return void 0===e&&(e=1),e>0?t.slice(0,-e):t},e.each=a,e.find=c,e.findIndex=function(t,e){return c(t,e,!0)},e.matches=u,e.findEach=l,e.filter=function(t,e){if(!t)return[];if(e||(e=function(t){return!!t}),Array.isArray(t)&&"function"==typeof e)return t.filter(e);var n=[];return l(t,e,(function(e,r){n.push(e),Array.isArray(e)?t.splice(r,1):delete t[r]})),n},e.last=function(t){return t[t.length-1]},e.head=function(t){return t[0]},e.map=function(t,e){return t.map(e)},e.intersection=function(t,e){return t.filter((function(t){return e.includes(t)}))}},3254:function(t,e){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.debounce=void 0,e.debounce=function(t,e){var n;return void 0===e&&(e=100),function(){for(var r=[],o=0;o=t.length:!t.hasOwnProperty(e))||othis.length)&&(e=this.length),this.substring(e-t.length,e)===t}),e.endsWith=function(t,e){return t.endsWith(e)}},7856:function(t){t.exports=function(){"use strict";function t(e){return t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},t(e)}function e(t,n){return e=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t},e(t,n)}function n(t,r,o){return n=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}()?Reflect.construct:function(t,n,r){var o=[null];o.push.apply(o,n);var i=new(Function.bind.apply(t,o));return r&&e(i,r.prototype),i},n.apply(null,arguments)}function r(t){return function(t){if(Array.isArray(t))return o(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||function(t,e){if(t){if("string"==typeof t)return o(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?o(t,e):void 0}}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function o(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n1?n-1:0),o=1;o/gm),W=f(/\${[\w\W]*}/gm),q=f(/^data-[\-\w.\u00B7-\uFFFF]/),$=f(/^aria-[\-\w]+$/),Y=f(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|cid|xmpp):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),K=f(/^(?:\w+script|data):/i),X=f(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),J=f(/^html$/i),Z=function(){return"undefined"==typeof window?null:window},Q=function(e,n){if("object"!==t(e)||"function"!=typeof e.createPolicy)return null;var r=null,o="data-tt-policy-suffix";n.currentScript&&n.currentScript.hasAttribute(o)&&(r=n.currentScript.getAttribute(o));var i="dompurify"+(r?"#"+r:"");try{return e.createPolicy(i,{createHTML:function(t){return t},createScriptURL:function(t){return t}})}catch(t){return console.warn("TrustedTypes policy "+i+" could not be created."),null}};return function e(){var n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:Z(),o=function(t){return e(t)};if(o.version="2.4.5",o.removed=[],!n||!n.document||9!==n.document.nodeType)return o.isSupported=!1,o;var i=n.document,a=n.document,c=n.DocumentFragment,u=n.HTMLTemplateElement,l=n.Node,f=n.Element,p=n.NodeFilter,d=n.NamedNodeMap,h=void 0===d?n.NamedNodeMap||n.MozNamedAttrMap:d,y=n.HTMLFormElement,m=n.DOMParser,T=n.trustedTypes,tt=f.prototype,et=M(tt,"cloneNode"),nt=M(tt,"nextSibling"),rt=M(tt,"childNodes"),ot=M(tt,"parentNode");if("function"==typeof u){var it=a.createElement("template");it.content&&it.content.ownerDocument&&(a=it.content.ownerDocument)}var at=Q(T,i),ct=at?at.createHTML(""):"",ut=a,lt=ut.implementation,st=ut.createNodeIterator,ft=ut.createDocumentFragment,pt=ut.getElementsByTagName,dt=i.importNode,ht={};try{ht=P(a).documentMode?a.documentMode:{}}catch(t){}var yt={};o.isSupported="function"==typeof ot&<&&void 0!==lt.createHTMLDocument&&9!==ht;var mt,vt,gt=H,bt=G,_t=W,Ot=q,wt=$,At=K,jt=X,Ct=Y,Et=null,xt=N({},[].concat(r(S),r(k),r(D),r(L),r(z))),Tt=null,Nt=N({},[].concat(r(V),r(U),r(F),r(B))),Pt=Object.seal(Object.create(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),Mt=null,St=null,kt=!0,Dt=!0,Rt=!1,Lt=!0,It=!1,zt=!1,Vt=!1,Ut=!1,Ft=!1,Bt=!1,Ht=!1,Gt=!0,Wt=!1,qt=!0,$t=!1,Yt={},Kt=null,Xt=N({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","style","svg","template","thead","title","video","xmp"]),Jt=null,Zt=N({},["audio","video","img","source","image","track"]),Qt=null,te=N({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),ee="http://www.w3.org/1998/Math/MathML",ne="http://www.w3.org/2000/svg",re="http://www.w3.org/1999/xhtml",oe=re,ie=!1,ae=null,ce=N({},[ee,ne,re],O),ue=["application/xhtml+xml","text/html"],le=null,se=a.createElement("form"),fe=function(t){return t instanceof RegExp||t instanceof Function},pe=function(e){le&&le===e||(e&&"object"===t(e)||(e={}),e=P(e),mt=mt=-1===ue.indexOf(e.PARSER_MEDIA_TYPE)?"text/html":e.PARSER_MEDIA_TYPE,vt="application/xhtml+xml"===mt?O:_,Et="ALLOWED_TAGS"in e?N({},e.ALLOWED_TAGS,vt):xt,Tt="ALLOWED_ATTR"in e?N({},e.ALLOWED_ATTR,vt):Nt,ae="ALLOWED_NAMESPACES"in e?N({},e.ALLOWED_NAMESPACES,O):ce,Qt="ADD_URI_SAFE_ATTR"in e?N(P(te),e.ADD_URI_SAFE_ATTR,vt):te,Jt="ADD_DATA_URI_TAGS"in e?N(P(Zt),e.ADD_DATA_URI_TAGS,vt):Zt,Kt="FORBID_CONTENTS"in e?N({},e.FORBID_CONTENTS,vt):Xt,Mt="FORBID_TAGS"in e?N({},e.FORBID_TAGS,vt):{},St="FORBID_ATTR"in e?N({},e.FORBID_ATTR,vt):{},Yt="USE_PROFILES"in e&&e.USE_PROFILES,kt=!1!==e.ALLOW_ARIA_ATTR,Dt=!1!==e.ALLOW_DATA_ATTR,Rt=e.ALLOW_UNKNOWN_PROTOCOLS||!1,Lt=!1!==e.ALLOW_SELF_CLOSE_IN_ATTR,It=e.SAFE_FOR_TEMPLATES||!1,zt=e.WHOLE_DOCUMENT||!1,Ft=e.RETURN_DOM||!1,Bt=e.RETURN_DOM_FRAGMENT||!1,Ht=e.RETURN_TRUSTED_TYPE||!1,Ut=e.FORCE_BODY||!1,Gt=!1!==e.SANITIZE_DOM,Wt=e.SANITIZE_NAMED_PROPS||!1,qt=!1!==e.KEEP_CONTENT,$t=e.IN_PLACE||!1,Ct=e.ALLOWED_URI_REGEXP||Ct,oe=e.NAMESPACE||re,Pt=e.CUSTOM_ELEMENT_HANDLING||{},e.CUSTOM_ELEMENT_HANDLING&&fe(e.CUSTOM_ELEMENT_HANDLING.tagNameCheck)&&(Pt.tagNameCheck=e.CUSTOM_ELEMENT_HANDLING.tagNameCheck),e.CUSTOM_ELEMENT_HANDLING&&fe(e.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)&&(Pt.attributeNameCheck=e.CUSTOM_ELEMENT_HANDLING.attributeNameCheck),e.CUSTOM_ELEMENT_HANDLING&&"boolean"==typeof e.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements&&(Pt.allowCustomizedBuiltInElements=e.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements),It&&(Dt=!1),Bt&&(Ft=!0),Yt&&(Et=N({},r(z)),Tt=[],!0===Yt.html&&(N(Et,S),N(Tt,V)),!0===Yt.svg&&(N(Et,k),N(Tt,U),N(Tt,B)),!0===Yt.svgFilters&&(N(Et,D),N(Tt,U),N(Tt,B)),!0===Yt.mathMl&&(N(Et,L),N(Tt,F),N(Tt,B))),e.ADD_TAGS&&(Et===xt&&(Et=P(Et)),N(Et,e.ADD_TAGS,vt)),e.ADD_ATTR&&(Tt===Nt&&(Tt=P(Tt)),N(Tt,e.ADD_ATTR,vt)),e.ADD_URI_SAFE_ATTR&&N(Qt,e.ADD_URI_SAFE_ATTR,vt),e.FORBID_CONTENTS&&(Kt===Xt&&(Kt=P(Kt)),N(Kt,e.FORBID_CONTENTS,vt)),qt&&(Et["#text"]=!0),zt&&N(Et,["html","head","body"]),Et.table&&(N(Et,["tbody"]),delete Mt.tbody),s&&s(e),le=e)},de=N({},["mi","mo","mn","ms","mtext"]),he=N({},["foreignobject","desc","title","annotation-xml"]),ye=N({},["title","style","font","a","script"]),me=N({},k);N(me,D),N(me,R);var ve=N({},L);N(ve,I);var ge=function(t){b(o.removed,{element:t});try{t.parentNode.removeChild(t)}catch(e){try{t.outerHTML=ct}catch(e){t.remove()}}},be=function(t,e){try{b(o.removed,{attribute:e.getAttributeNode(t),from:e})}catch(t){b(o.removed,{attribute:null,from:e})}if(e.removeAttribute(t),"is"===t&&!Tt[t])if(Ft||Bt)try{ge(e)}catch(t){}else try{e.setAttribute(t,"")}catch(t){}},_e=function(t){var e,n;if(Ut)t=""+t;else{var r=w(t,/^[\r\n\t ]+/);n=r&&r[0]}"application/xhtml+xml"===mt&&oe===re&&(t=''+t+"");var o=at?at.createHTML(t):t;if(oe===re)try{e=(new m).parseFromString(o,mt)}catch(t){}if(!e||!e.documentElement){e=lt.createDocument(oe,"template",null);try{e.documentElement.innerHTML=ie?ct:o}catch(t){}}var i=e.body||e.documentElement;return t&&n&&i.insertBefore(a.createTextNode(n),i.childNodes[0]||null),oe===re?pt.call(e,zt?"html":"body")[0]:zt?e.documentElement:i},Oe=function(t){return st.call(t.ownerDocument||t,t,p.SHOW_ELEMENT|p.SHOW_COMMENT|p.SHOW_TEXT,null,!1)},we=function(e){return"object"===t(l)?e instanceof l:e&&"object"===t(e)&&"number"==typeof e.nodeType&&"string"==typeof e.nodeName},Ae=function(t,e,n){yt[t]&&v(yt[t],(function(t){t.call(o,e,n,le)}))},je=function(t){var e,n;if(Ae("beforeSanitizeElements",t,null),(n=t)instanceof y&&("string"!=typeof n.nodeName||"string"!=typeof n.textContent||"function"!=typeof n.removeChild||!(n.attributes instanceof h)||"function"!=typeof n.removeAttribute||"function"!=typeof n.setAttribute||"string"!=typeof n.namespaceURI||"function"!=typeof n.insertBefore||"function"!=typeof n.hasChildNodes))return ge(t),!0;if(E(/[\u0080-\uFFFF]/,t.nodeName))return ge(t),!0;var r=vt(t.nodeName);if(Ae("uponSanitizeElement",t,{tagName:r,allowedTags:Et}),t.hasChildNodes()&&!we(t.firstElementChild)&&(!we(t.content)||!we(t.content.firstElementChild))&&E(/<[/\w]/g,t.innerHTML)&&E(/<[/\w]/g,t.textContent))return ge(t),!0;if("select"===r&&E(/