Lightcord/LightcordApi/js/main.js

1012 lines
121 KiB
JavaScript
Raw Normal View History

2020-06-10 16:16:33 +02:00
module.exports =
/******/ (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 = "./src/index.ts");
/******/ })
/************************************************************************/
/******/ ({
2020-06-16 15:51:21 +02:00
/***/ "./src/alias/react-dom.ts":
/*!********************************!*\
!*** ./src/alias/react-dom.ts ***!
\********************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
module.exports = window["Reac" + "tDOM"];
/***/ }),
/***/ "./src/components/components.ts":
/*!**************************************!*\
!*** ./src/components/components.ts ***!
\**************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const Button_1 = __webpack_require__(/*! ./inputs/Button */ "./src/components/inputs/Button.tsx");
const Switch_1 = __webpack_require__(/*! ./inputs/Switch */ "./src/components/inputs/Switch.tsx");
const RadioGroup_1 = __webpack_require__(/*! ./inputs/RadioGroup */ "./src/components/inputs/RadioGroup.tsx");
const TextArea_1 = __webpack_require__(/*! ./inputs/TextArea */ "./src/components/inputs/TextArea.tsx");
const TextInput_1 = __webpack_require__(/*! ./inputs/TextInput */ "./src/components/inputs/TextInput.tsx");
const Dropdown_1 = __webpack_require__(/*! ./inputs/Dropdown */ "./src/components/inputs/Dropdown.tsx");
const Title_1 = __webpack_require__(/*! ./general/Title */ "./src/components/general/Title.tsx");
const SettingsTitle_1 = __webpack_require__(/*! ./general/SettingsTitle */ "./src/components/general/SettingsTitle.tsx");
exports.default = {
inputs: {
Button: Button_1.default,
Switch: Switch_1.default,
Choices: RadioGroup_1.default,
RadioGroup: RadioGroup_1.default,
TextArea: TextArea_1.default,
TextInput: TextInput_1.default,
Dropdown: Dropdown_1.default
},
general: {
Title: Title_1.default,
SettingsTitle: SettingsTitle_1.default
}
};
/***/ }),
/***/ "./src/components/general/SettingsTitle.tsx":
/*!**************************************************!*\
!*** ./src/components/general/SettingsTitle.tsx ***!
\**************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const WebpackLoader_1 = __webpack_require__(/*! ../../modules/WebpackLoader */ "./src/modules/WebpackLoader.ts");
const Title_1 = __webpack_require__(/*! ./Title */ "./src/components/general/Title.tsx");
const Utils_1 = __webpack_require__(/*! ../../modules/Utils */ "./src/modules/Utils.ts");
let TitleModules;
class SettingsTitle extends React.Component {
constructor(props) {
super(props);
props = SettingsTitle.normalizeProps(props);
this.state = Object.create(props);
}
static normalizeProps(props) {
props = Object.create(props);
if (!props || typeof props !== "object")
props = { children: [] };
if (typeof props.className !== "string")
delete props.className;
let levels = [props];
while (Utils_1.default.getNestedProps(props, levels.map(e => "__proto__").join("."))) {
levels.push(Utils_1.default.getNestedProps(props, levels.map(e => "__proto__").join(".")));
}
let finals = Object.assign({}, ...levels);
return finals;
}
get modules() {
return TitleModules || (TitleModules = [
WebpackLoader_1.default.find(e => typeof e.marginTop60 === "string")
]);
}
render() {
let [marginModule] = this.modules;
let props = SettingsTitle.normalizeProps(this.state || this.props);
if (!this.state) {
this.state = Object.create(props);
}
let className = `${marginModule.marginTop60} ${marginModule.marginBottom20}`;
if (props.className)
className = +" " + props.className;
return React.createElement(Title_1.default, { className }, props.children);
}
}
exports.default = SettingsTitle;
/***/ }),
/***/ "./src/components/general/Title.tsx":
/*!******************************************!*\
!*** ./src/components/general/Title.tsx ***!
\******************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const WebpackLoader_1 = __webpack_require__(/*! ../../modules/WebpackLoader */ "./src/modules/WebpackLoader.ts");
const uuid_1 = __webpack_require__(/*! ../../modules/uuid */ "./src/modules/uuid.ts");
const Utils_1 = __webpack_require__(/*! ../../modules/Utils */ "./src/modules/Utils.ts");
let TitleModules;
class Title extends React.Component {
constructor(props) {
super(props);
props = Title.normalizeProps(props);
this.state = Object.create(props);
}
get key() {
return this._key || uuid_1.default();
}
static normalizeProps(props) {
props = Object.create(props);
if (!props || typeof props !== "object")
props = { children: [] };
if (!props.children)
props.children = [];
if (typeof props.className !== "string")
props.className = "";
let levels = [props];
while (Utils_1.default.getNestedProps(props, levels.map(e => "__proto__").join("."))) {
levels.push(Utils_1.default.getNestedProps(props, levels.map(e => "__proto__").join(".")));
}
let finals = Object.assign({}, ...levels);
return finals;
}
get modules() {
return TitleModules || (TitleModules = [
WebpackLoader_1.default.find(e => typeof e.colorStandard === "string"),
WebpackLoader_1.default.find(e => typeof e.size32 === "string"),
WebpackLoader_1.default.find(e => typeof e.h2 === "string")
]);
}
render() {
let [colorModule, sizeModule, titleModule] = this.modules;
let props = Title.normalizeProps(this.state || this.props);
if (!this.state) {
this.state = props;
}
let className = `${colorModule.colorStandard} ${sizeModule.size14} ${titleModule.h2} ${titleModule.defaultColor} ${titleModule.defaultMarginh2}`;
if (props.className)
className += " " + props.className;
return React.createElement("h2", { className, key: this.key }, props.children);
}
}
exports.default = Title;
/***/ }),
/***/ "./src/components/inputs/Button.tsx":
/*!******************************************!*\
!*** ./src/components/inputs/Button.tsx ***!
\******************************************/
2020-06-10 16:16:33 +02:00
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const WebpackLoader_1 = __webpack_require__(/*! ../../modules/WebpackLoader */ "./src/modules/WebpackLoader.ts");
let ButtonModules;
2020-06-10 16:16:33 +02:00
class Button extends React.Component {
constructor(props) {
if (props.color) {
props.color = props.color.toLowerCase();
if (!["brand", "grey", "red", "green", "yellow", "primary", "link", "white", "black", "transparent"].includes(props.color)) {
props.color = "brand";
}
}
else {
props.color = "brand";
}
props.onClick = typeof props.onClick === "function" ? props.onClick : () => { };
super(props);
}
get modules() {
return ButtonModules || (ButtonModules = [
WebpackLoader_1.default.findByUniqueProperties(["_horizontal"]),
WebpackLoader_1.default.findByUniqueProperties(["colorTransparent"]),
WebpackLoader_1.default.findByUniqueProperties(["buttonWrapper"]),
WebpackLoader_1.default.findByUniqueProperties(["ButtonColors"]),
]);
}
2020-06-10 16:16:33 +02:00
render() {
let [flexModule, euhModule1, buttonModule, colorsModule,] = this.modules;
2020-06-10 16:16:33 +02:00
return (React.createElement("div", { className: buttonModule.buttonWrapper },
React.createElement("button", { type: "button", className: `${flexModule.flexChild} ${euhModule1.button} ${euhModule1.lookFilled} ${colorsModule.ButtonColors[this.props.color.toUpperCase()]} ${euhModule1.sizeSmall} ${euhModule1.grow}`, style: { flex: "0 1 auto" }, onClick: this.props.onClick },
React.createElement("div", { className: euhModule1.contents }, this.props.text))));
}
2020-06-16 15:51:21 +02:00
static get AllPreviews() {
return AllPreviews || (AllPreviews = []);
}
2020-06-10 16:16:33 +02:00
}
exports.default = Button;
/***/ }),
2020-06-16 15:51:21 +02:00
/***/ "./src/components/inputs/Dropdown.tsx":
/*!********************************************!*\
!*** ./src/components/inputs/Dropdown.tsx ***!
\********************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const noop_1 = __webpack_require__(/*! ../../modules/noop */ "./src/modules/noop.ts");
const WebpackLoader_1 = __webpack_require__(/*! ../../modules/WebpackLoader */ "./src/modules/WebpackLoader.ts");
2020-06-16 15:51:21 +02:00
const Utils_1 = __webpack_require__(/*! ../../modules/Utils */ "./src/modules/Utils.ts");
let DropdownModules;
class Dropdown extends React.Component {
constructor(props) {
super(props);
2020-06-16 15:51:21 +02:00
props = Dropdown.normalizeProps(props);
this.state = props;
this.onChange = this.onChange.bind(this);
}
static normalizeProps(props) {
2020-06-16 15:51:21 +02:00
props = Object.create(props);
if (!props || typeof props !== "object")
props = {};
if (typeof props.className !== "string")
delete props.className;
if (typeof props.darkThemeColorOverrides !== "object" || !props.darkThemeColorOverrides)
delete props.darkThemeColorOverrides;
if (typeof props.disabled !== "boolean")
props.disabled = false;
if (typeof props.error !== "string")
delete props.error;
if (typeof props.isMulti !== "boolean")
props.isMulti = false;
if (typeof props.lightThemeColorOverrides !== "object" || !props.lightThemeColorOverrides)
delete props.lightThemeColorOverrides;
if (typeof props.multiValueRenderer !== "function")
delete props.multiValueRenderer;
if (typeof props.valueRenderer !== "function")
delete props.valueRenderer;
if (typeof props.optionRenderer !== "function")
delete props.optionRenderer;
if (typeof props.onChange !== "function")
props.onChange = noop_1.default;
if (!Array.isArray(props.options))
props.options = [{
value: "none",
"label": "No options - No options was passed to Dropdown. If you meant to put an empty dropdown, input an empty array."
}];
if (typeof props.searchable !== "boolean")
props.searchable = false;
if (typeof props.styleOverrides !== "object")
delete props.styleOverrides;
if (typeof props.value !== "string")
props.value = null;
2020-06-16 15:51:21 +02:00
let levels = [props];
while (Utils_1.default.getNestedProps(props, levels.map(e => "__proto__").join("."))) {
levels.push(Utils_1.default.getNestedProps(props, levels.map(e => "__proto__").join(".")));
}
let finals = Object.assign({}, ...levels);
return finals;
}
onChange(value) {
console.log(value);
this.state.onChange(value);
this.setState({
value: value
});
}
get modules() {
return DropdownModules || (DropdownModules = [
WebpackLoader_1.default.find(e => e.default && e.default.displayName === "SelectTempWrapper").default
]);
}
render() {
let [DropdownComponent] = this.modules;
let props = Dropdown.normalizeProps(this.state || this.props);
if (!this.state) {
this.state = Object.create(props);
}
return React.createElement(DropdownComponent, Object.assign({}, this.props, { onChange: this.onChange }));
}
get value() {
return this.state.value;
}
}
exports.default = Dropdown;
/***/ }),
2020-06-16 15:51:21 +02:00
/***/ "./src/components/inputs/RadioGroup.tsx":
/*!**********************************************!*\
!*** ./src/components/inputs/RadioGroup.tsx ***!
\**********************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const noop_1 = __webpack_require__(/*! ../../modules/noop */ "./src/modules/noop.ts");
const WebpackLoader_1 = __webpack_require__(/*! ../../modules/WebpackLoader */ "./src/modules/WebpackLoader.ts");
2020-06-16 15:51:21 +02:00
const Utils_1 = __webpack_require__(/*! ../../modules/Utils */ "./src/modules/Utils.ts");
let RadioGroupModule;
class RadioGroup extends React.Component {
constructor(props) {
super(props);
2020-06-16 15:51:21 +02:00
props = RadioGroup.normalizeProps(props);
this.state = props;
this.onChange = this.onChange.bind(this);
}
static normalizeProps(props) {
2020-06-16 15:51:21 +02:00
props = Object.create(props);
if (!props || typeof props !== "object")
props = {};
let defaultOptions = false;
if (!props.options || !Array.isArray(props.options)) {
props.options = [{
value: "none",
name: "No options",
desc: "No options was passed to Choices. If you meant to display no options at all, please pass an empty array.",
color: "#f04747"
}];
defaultOptions = true;
}
if (!props.value || typeof props.value !== "string") {
if (defaultOptions) {
props.value = "none";
}
else {
props.value = null;
}
}
if (typeof props.disabled !== "boolean")
props.disabled = false;
if (typeof props.size !== "string" || !["small", "medium"].includes(props.size.toLowerCase()))
props.size = "medium";
if (typeof props.itemType !== "string" || !["bar", "panel"].includes(props.itemType))
props.itemType = "bar";
if (typeof props.infoClassName !== "string")
props.infoClassName = "";
if (!props.onChange || typeof props.onChange !== "function")
props.onChange = noop_1.default;
2020-06-16 15:51:21 +02:00
let levels = [props];
while (Utils_1.default.getNestedProps(props, levels.map(e => "__proto__").join("."))) {
levels.push(Utils_1.default.getNestedProps(props, levels.map(e => "__proto__").join(".")));
}
let finals = Object.assign({}, ...levels);
return finals;
}
onChange(ev) {
this.state.onChange(ev.value);
this.setState({
value: ev.value
});
}
get modules() {
return RadioGroupModule || (RadioGroupModule = [
WebpackLoader_1.default.find(e => e.default && e.default.displayName === "RadioGroup").default
]);
}
render() {
let [RadioGroupComponent] = this.modules;
let props = RadioGroup.normalizeProps(this.state || this.props);
if (!this.state) {
this.state = Object.create(props);
}
return React.createElement(RadioGroupComponent, { options: props.options, onChange: this.onChange, value: props.value, disabled: props.disabled, size: RadioGroupComponent.Sizes[props.size.toUpperCase()], itemType: RadioGroupComponent.ItemTypes[props.itemType.toUpperCase()], infoClassName: props.infoClassName });
}
get value() {
return this.state.value;
}
}
exports.default = RadioGroup;
/***/ }),
2020-06-16 15:51:21 +02:00
/***/ "./src/components/inputs/Switch.tsx":
/*!******************************************!*\
!*** ./src/components/inputs/Switch.tsx ***!
\******************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const WebpackLoader_1 = __webpack_require__(/*! ../../modules/WebpackLoader */ "./src/modules/WebpackLoader.ts");
const noop_1 = __webpack_require__(/*! ../../modules/noop */ "./src/modules/noop.ts");
2020-06-16 15:51:21 +02:00
const Utils_1 = __webpack_require__(/*! ../../modules/Utils */ "./src/modules/Utils.ts");
let SwitchModules;
class Switch extends React.Component {
constructor(props) {
super(props);
2020-06-16 15:51:21 +02:00
props = Switch.normalizeProps(props);
this.state = Object.create(props);
this.onChange = this.onChange.bind(this);
}
static normalizeProps(props) {
2020-06-16 15:51:21 +02:00
props = Object.create(props);
if (!props)
props = {};
if (!props.id || typeof props.id !== "string")
props.id = null;
if (!props.onChange || typeof props.onChange !== "function")
props.onChange = noop_1.default;
if (!props.value || typeof props.value !== "boolean")
props.value = false;
if (!props.fill || typeof props.fill !== "string")
props.fill = null;
if (!props.theme || !["default", "clear"].includes(props.theme.toLowerCase()))
props.theme = "default";
if (!("disabled" in props) || typeof props.disabled !== "boolean")
props.disabled = false;
if (!props.className || typeof props.className !== "string")
props.className = "";
if (!props.size || !["default", "mini"].includes(props.size.toLowerCase()))
props.size = "default";
if (!props.style || typeof props.style !== "object")
props.style = {};
2020-06-16 15:51:21 +02:00
let levels = [props];
while (Utils_1.default.getNestedProps(props, levels.map(e => "__proto__").join("."))) {
levels.push(Utils_1.default.getNestedProps(props, levels.map(e => "__proto__").join(".")));
}
let finals = Object.assign({}, ...levels);
return finals;
}
get modules() {
return SwitchModules || (SwitchModules = [
WebpackLoader_1.default.find(e => e.default && e.default.displayName === "Switch").default
]);
}
render() {
let [SwitchComponent] = this.modules;
let props = Switch.normalizeProps(this.state || this.props);
if (!this.state) {
this.state = Object.create(props);
}
return (React.createElement(SwitchComponent, { id: props.id, onChange: this.onChange, value: this.state.value || false, fill: props.fill, theme: SwitchComponent.Themes[props.theme.toUpperCase()], disabled: props.disabled, className: props.className, size: SwitchComponent.Sizes[props.size.toUpperCase()], style: props.style }));
}
onChange(value) {
this.props.onChange(!this.state.value);
this.setState({
value: !this.state.value
});
}
get value() {
return this.state.value;
}
}
exports.default = Switch;
/***/ }),
2020-06-16 15:51:21 +02:00
/***/ "./src/components/inputs/TextArea.tsx":
/*!********************************************!*\
!*** ./src/components/inputs/TextArea.tsx ***!
\********************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const WebpackLoader_1 = __webpack_require__(/*! ../../modules/WebpackLoader */ "./src/modules/WebpackLoader.ts");
const noop_1 = __webpack_require__(/*! ../../modules/noop */ "./src/modules/noop.ts");
2020-06-16 15:51:21 +02:00
const Utils_1 = __webpack_require__(/*! ../../modules/Utils */ "./src/modules/Utils.ts");
let TextAreaModules;
class TextArea extends React.Component {
constructor(props) {
super(props);
2020-06-16 15:51:21 +02:00
props = TextArea.normalizeProps(props);
this.state = Object.create(props);
this.onChange = this.onChange.bind(this);
this.onFocus = this.onFocus.bind(this);
this.onBlur = this.onBlur.bind(this);
this.onKeyDown = this.onKeyDown.bind(this);
}
static normalizeProps(props) {
2020-06-16 15:51:21 +02:00
props = Object.create(props);
if (!props)
props = {};
if (!props.name || typeof props.name !== "string")
props.name = "";
if (!props.disabled || typeof props.disabled !== "boolean")
props.disabled = false;
if (typeof props.placeholder !== "string")
props.placeholder = "";
if (typeof props.autoFocus !== "boolean")
props.autoFocus = false;
if (typeof props.resizeable !== "boolean")
props.resizeable = false;
if (typeof props.flex !== "boolean")
props.flex = false;
if (typeof props.autosize !== "boolean")
props.autosize = false;
if (typeof props.rows !== "number")
props.rows = 3;
if (typeof props.value !== "string")
props.value = "";
if (typeof props.error !== "string")
props.error = null;
if (props.maxLength && typeof props.maxLength !== "number")
props.maxLength = 999;
if (typeof props.className !== "string")
props.className = "";
if (typeof props.id !== "string")
props.id = null;
if (typeof props.onChange !== "function")
props.onChange = noop_1.default;
if (typeof props.onFocus !== "function")
props.onFocus = noop_1.default;
if (typeof props.onBlur !== "function")
props.onBlur = noop_1.default;
if (typeof props.onKeyDown !== "function")
props.onKeyDown = noop_1.default;
2020-06-16 15:51:21 +02:00
let levels = [props];
while (Utils_1.default.getNestedProps(props, levels.map(e => "__proto__").join("."))) {
levels.push(Utils_1.default.getNestedProps(props, levels.map(e => "__proto__").join(".")));
}
let finals = Object.assign({}, ...levels);
return finals;
}
get modules() {
return TextAreaModules || (TextAreaModules = [
WebpackLoader_1.default.find(e => e.default && e.default.displayName === "TextArea").default
]);
}
onChange(value, name) {
this.state.onChange(value, name);
this.setState({
value
});
}
onFocus(ev, name) {
this.state.onFocus(ev, name);
}
onBlur(ev, name) {
this.state.onBlur(ev, name);
}
onKeyDown(ev) {
this.state.onKeyDown(ev);
}
render() {
let [TextAreaComponent] = this.modules;
let props = TextArea.normalizeProps(this.state || this.props);
if (!this.state) {
this.state = Object.create(props);
}
return React.createElement(TextAreaComponent, Object.assign({}, props, { onChange: this.onChange, onFocus: this.onFocus, onBlur: this.onBlur, onKeyDown: this.onKeyDown }));
}
get value() {
return this.state.value;
}
}
exports.default = TextArea;
/***/ }),
2020-06-16 15:51:21 +02:00
/***/ "./src/components/inputs/TextInput.tsx":
/*!*********************************************!*\
!*** ./src/components/inputs/TextInput.tsx ***!
\*********************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const WebpackLoader_1 = __webpack_require__(/*! ../../modules/WebpackLoader */ "./src/modules/WebpackLoader.ts");
const noop_1 = __webpack_require__(/*! ../../modules/noop */ "./src/modules/noop.ts");
2020-06-16 15:51:21 +02:00
const Utils_1 = __webpack_require__(/*! ../../modules/Utils */ "./src/modules/Utils.ts");
let TextInputModules;
class TextInput extends React.PureComponent {
constructor(props) {
super(props);
2020-06-16 15:51:21 +02:00
props = TextInput.normalizeProps(props);
this.state = props;
2020-06-16 15:51:21 +02:00
console.log(this.state);
this.onChange = this.onChange.bind(this);
this.onFocus = this.onFocus.bind(this);
this.onBlur = this.onBlur.bind(this);
}
static normalizeProps(props) {
2020-06-16 15:51:21 +02:00
props = Object.create(props);
if (!props)
props = {};
if (!props.name || typeof props.name !== "string")
props.name = "";
if (!props.size || !["default", "mini"].includes(props.size))
props.size = "default";
if (!props.disabled || typeof props.disabled !== "boolean")
props.disabled = false;
if (typeof props.placeholder !== "string")
props.placeholder = "";
if (typeof props.value !== "string")
props.value = "";
if (typeof props.error !== "string")
props.error = null;
if (props.maxLength && typeof props.maxLength !== "number")
props.maxLength = 999;
if (typeof props.className !== "string")
props.className = "";
if (typeof props.inputClassName !== "string")
props.inputClassName = "";
if (typeof props.id !== "string")
props.id = null;
if (typeof props.onChange !== "function")
props.onChange = noop_1.default;
if (typeof props.onFocus !== "function")
props.onFocus = noop_1.default;
if (typeof props.onBlur !== "function")
props.onBlur = noop_1.default;
2020-06-16 15:51:21 +02:00
let levels = [props];
while (Utils_1.default.getNestedProps(props, levels.map(e => "__proto__").join("."))) {
levels.push(Utils_1.default.getNestedProps(props, levels.map(e => "__proto__").join(".")));
}
let finals = Object.assign({}, ...levels);
return finals;
}
get modules() {
return TextInputModules || (TextInputModules = [
WebpackLoader_1.default.find(e => e.default && e.default.displayName === "TextInput").default
]);
}
onChange(value, name) {
this.hasSet = false;
this.state.onChange(value, name, this);
if (this.hasSet)
return; // prevent event if the onChange has changed the value.
this.setState({
value
});
this.forceUpdate();
}
onFocus(ev, name) {
this.state.onFocus(ev, name, this);
}
onBlur(ev, name) {
this.state.onBlur(ev, name, this);
}
render() {
let [TextAreaComponent] = this.modules;
let props = TextInput.normalizeProps(this.state || this.props);
if (!this.state) {
2020-06-16 15:51:21 +02:00
this.state = props;
}
2020-06-16 15:51:21 +02:00
console.log(props);
return React.createElement(TextAreaComponent, Object.assign({}, props, { onChange: this.onChange, onFocus: this.onFocus, onBlur: this.onBlur }));
}
get value() {
return this.state.value;
}
setValue(value) {
this.setState({
value: value
});
this.forceUpdate();
this.hasSet = true;
}
}
exports.default = TextInput;
2020-06-10 16:16:33 +02:00
/***/ }),
/***/ "./src/index.ts":
/*!**********************!*\
!*** ./src/index.ts ***!
\**********************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const WebpackLoader_1 = __webpack_require__(/*! ./modules/WebpackLoader */ "./src/modules/WebpackLoader.ts");
const components_1 = __webpack_require__(/*! ./components/components */ "./src/components/components.ts");
const uuid_1 = __webpack_require__(/*! ./modules/uuid */ "./src/modules/uuid.ts");
2020-06-16 15:51:21 +02:00
const Utils_1 = __webpack_require__(/*! ./modules/Utils */ "./src/modules/Utils.ts");
2020-06-10 16:16:33 +02:00
const LightcordApi = {
WebpackLoader: WebpackLoader_1.default,
Components: components_1.default,
2020-06-16 15:51:21 +02:00
uuid: uuid_1.default,
Utils: Utils_1.default
2020-06-10 16:16:33 +02:00
};
exports.default = LightcordApi;
Object.assign(window.Lightcord.Api, LightcordApi);
2020-06-16 15:51:21 +02:00
/***/ }),
/***/ "./src/modules/PluginUtilities.ts":
/*!****************************************!*\
!*** ./src/modules/PluginUtilities.ts ***!
\****************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const components_1 = __webpack_require__(/*! ../components/components */ "./src/components/components.ts");
const Utils_1 = __webpack_require__(/*! ./Utils */ "./src/modules/Utils.ts");
const uuid_1 = __webpack_require__(/*! ./uuid */ "./src/modules/uuid.ts");
const TextInput_1 = __webpack_require__(/*! ../components/inputs/TextInput */ "./src/components/inputs/TextInput.tsx");
exports.default = new class PluginUtilities {
constructor() { }
renderSettings(settings) {
let items = this.renderSettingsToReact(settings);
let elem = React.createElement("div", { key: uuid_1.default() }, items);
return Utils_1.default.ReactToHTMLElement(elem);
}
renderSettingsToReact(settings) {
let items = [];
settings.forEach(item => {
console.log(item);
if (typeof item !== "object")
return items.push(item);
if (item.props && "children" in item.props) {
if (!Array.isArray(item.props.children))
item.props.children = [item.props.children];
item.props.children = this.renderSettingsToReact(item.props.children);
}
if (!item.props)
item.props = {};
item.props.key = uuid_1.default();
let component = Utils_1.default.getNestedProps(components_1.default, item.component);
if (!component) {
let warning = new TextInput_1.default({
value: `Warning: No component was found for: "${item.component}". Please correct your code.`,
disabled: true,
error: `Warning: No component was found for: "${item.component}". Please correct your code.`
}).render();
items.push(warning);
return;
}
items.push(React.createElement(component, Object.create(item.props)));
});
return items;
}
};
/***/ }),
/***/ "./src/modules/Utils.ts":
/*!******************************!*\
!*** ./src/modules/Utils.ts ***!
\******************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const ReactDOM = __webpack_require__(/*! react-dom */ "./src/alias/react-dom.ts");
const PluginUtilities_1 = __webpack_require__(/*! ./PluginUtilities */ "./src/modules/PluginUtilities.ts");
exports.default = new class Utils {
constructor() { }
ReactToHTMLElement(ReactElement) {
const element = document.createElement("div");
ReactDOM.render(ReactElement, element);
return element;
}
get PluginUtils() { return PluginUtilities_1.default; }
getNestedProps(obj, path) {
let segments = path.split(".");
for (let seg of segments) {
obj = obj && (seg in obj) ? obj[seg] : undefined;
}
return obj;
}
};
2020-06-10 16:16:33 +02:00
/***/ }),
/***/ "./src/modules/WebpackLoader.ts":
/*!**************************************!*\
!*** ./src/modules/WebpackLoader.ts ***!
\**************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const BDModules = window.BDModules;
exports.default = new class WebpackLoader {
constructor() { }
get(id) {
return BDModules.get(id);
}
find(filter) {
return BDModules.get(filter)[0];
}
findByUniqueProperties(props) {
return BDModules.get((mod) => {
if (mod.__esModule && ("default" in mod)) {
let doesMatch = true;
for (let prop of props) {
if (!Object.prototype.hasOwnProperty.call(mod.default, prop))
doesMatch = false;
}
if (doesMatch)
return true;
}
for (let prop of props) {
if (!Object.prototype.hasOwnProperty.call(mod, prop))
return false;
}
return true;
})[0];
}
filter(filter) {
return BDModules.get(filter);
}
filterByUniqueProperties(props) {
return BDModules.get((mod) => {
if (mod.__esModule && ("default" in mod)) {
let doesMatch = true;
for (let prop of props) {
if (!Object.prototype.hasOwnProperty.call(mod.default, prop))
doesMatch = false;
}
if (doesMatch)
return true;
}
for (let prop of props) {
if (!Object.prototype.hasOwnProperty.call(mod, prop))
return false;
}
return true;
});
}
};
/***/ }),
/***/ "./src/modules/noop.ts":
/*!*****************************!*\
!*** ./src/modules/noop.ts ***!
\*****************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
function NOOP() { }
exports.default = NOOP;
/***/ }),
/***/ "./src/modules/uuid.ts":
/*!*****************************!*\
!*** ./src/modules/uuid.ts ***!
\*****************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const uuidv1 = __webpack_require__(/*! uuid/v1 */ "uuid/v1");
const uuidv4 = __webpack_require__(/*! uuid/v4 */ "uuid/v4");
let uuid = Object.assign(function () {
return uuidv4();
}, { v1: () => uuidv1(), v4: () => uuidv4() });
exports.default = uuid;
/***/ }),
/***/ "uuid/v1":
/*!**************************!*\
!*** external "uuid/v1" ***!
\**************************/
/*! no static exports found */
/***/ (function(module, exports) {
module.exports = require("uuid/v1");
/***/ }),
/***/ "uuid/v4":
/*!**************************!*\
!*** external "uuid/v4" ***!
\**************************/
/*! no static exports found */
/***/ (function(module, exports) {
module.exports = require("uuid/v4");
2020-06-10 16:16:33 +02:00
/***/ })
/******/ });
2020-06-16 15:51:21 +02:00
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIndlYnBhY2s6Ly9MaWdodGNvcmRBcGkvd2VicGFjay9ib290c3RyYXAiLCJ3ZWJwYWNrOi8vTGlnaHRjb3JkQXBpLy4vc3JjL2FsaWFzL3JlYWN0LWRvbS50cyIsIndlYnBhY2s6Ly9MaWdodGNvcmRBcGkvLi9zcmMvY29tcG9uZW50cy9jb21wb25lbnRzLnRzIiwid2VicGFjazovL0xpZ2h0Y29yZEFwaS8uL3NyYy9jb21wb25lbnRzL2dlbmVyYWwvU2V0dGluZ3NUaXRsZS50c3giLCJ3ZWJwYWNrOi8vTGlnaHRjb3JkQXBpLy4vc3JjL2NvbXBvbmVudHMvZ2VuZXJhbC9UaXRsZS50c3giLCJ3ZWJwYWNrOi8vTGlnaHRjb3JkQXBpLy4vc3JjL2NvbXBvbmVudHMvaW5wdXRzL0J1dHRvbi50c3giLCJ3ZWJwYWNrOi8vTGlnaHRjb3JkQXBpLy4vc3JjL2NvbXBvbmVudHMvaW5wdXRzL0Ryb3Bkb3duLnRzeCIsIndlYnBhY2s6Ly9MaWdodGNvcmRBcGkvLi9zcmMvY29tcG9uZW50cy9pbnB1dHMvUmFkaW9Hcm91cC50c3giLCJ3ZWJwYWNrOi8vTGlnaHRjb3JkQXBpLy4vc3JjL2NvbXBvbmVudHMvaW5wdXRzL1N3aXRjaC50c3giLCJ3ZWJwYWNrOi8vTGlnaHRjb3JkQXBpLy4vc3JjL2NvbXBvbmVudHMvaW5wdXRzL1RleHRBcmV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