UNPKG

@gooddata/react-components

Version:

GoodData.UI - A powerful JavaScript library for building analytical applications

68 lines 3.53 kB
"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 (b.hasOwnProperty(p)) d[p] = b[p]; }; return extendStatics(d, b); }; return function (d, b) { extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); Object.defineProperty(exports, "__esModule", { value: true }); // (C) 2020 GoodData Corporation var React = require("react"); var react_intl_1 = require("react-intl"); var FormatTemplatesDropdown_1 = require("./formatTemplatesDropdown/FormatTemplatesDropdown"); var SyntaxHighlightingInput_1 = require("../../simple/SyntaxHighlightingInput"); var formattingRules = { start: [ { regex: /"(?:[^\\]|\\.)*?"/, token: "string" }, { regex: /(?:black|blue|cyan|green|magenta|red|yellow|white)\b/i, token: "keyword" }, { regex: /(backgroundColor|color)(=)([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})/i, token: ["variable-4", null, "keyword"], }, { regex: /(<|>|=|>=|<=)(-?)(\d*(\.|,)?\d+|Null)/i, token: ["variable-5", "variable-5", "variable-5"], }, { regex: /\/\/.*/, token: "comment" }, { regex: /\/(?:[^\\]|\\.)*?\//, token: "variable-3" }, { regex: /\/\*/, token: "comment", next: "comment" }, { regex: /[\{\[\(]/, indent: true, token: "variable-brackets" }, { regex: /[\}\]\)]/, dedent: true, token: "variable-brackets" }, { regex: /[a-z$][\w$]*/, token: "variable" }, { regex: /<</, token: "meta", mode: { spec: "xml", end: />>/ } }, ], comment: [{ regex: /.*?\*\//, token: "comment", next: "start" }, { regex: /.*/, token: "comment" }], meta: { dontIndentStates: ["comment"], lineComment: "//", }, }; var FormatInput = /** @class */ (function (_super) { __extends(FormatInput, _super); function FormatInput() { var _this = _super !== null && _super.apply(this, arguments) || this; _this.handleInputChange = function (value) { _this.props.onFormatChange(value); }; return _this; } FormatInput.prototype.render = function () { var _a = this.props, format = _a.format, onFormatChange = _a.onFormatChange, separators = _a.separators, templates = _a.templates, intl = _a.intl; return (React.createElement("div", { className: "gd-measure-custom-format-dialog-section" }, React.createElement("div", { className: "gd-measure-custom-format-dialog-section-title" }, React.createElement("span", null, intl.formatMessage({ id: "measureNumberCustomFormatDialog.definition" })), templates && (React.createElement(FormatTemplatesDropdown_1.FormatTemplatesDropdown, { onChange: onFormatChange, separators: separators, templates: templates }))), React.createElement(SyntaxHighlightingInput_1.SyntaxHighlightingInput, { value: format, formatting: formattingRules, onChange: this.handleInputChange, className: "s-custom-format-input" }))); }; return FormatInput; }(React.PureComponent)); var FormatInputWithIntl = react_intl_1.injectIntl(FormatInput); exports.default = FormatInputWithIntl; //# sourceMappingURL=FormatInput.js.map