datagrok-api
Advanced tools
Comparing version 0.89.23 to 0.89.24
@@ -19,3 +19,3 @@ import * as _chem from './src/chem.js'; | ||
export {time, timeAsync, Utils, LruCache} from './src/utils.js'; | ||
export {JsEntityMeta, EntityMetaDartProxy} from './ui'; | ||
export {ObjectHandler, EntityMetaDartProxy} from './ui'; | ||
@@ -22,0 +22,0 @@ export let chem = _chem; |
{ | ||
"name": "datagrok-api", | ||
"version": "0.89.23", | ||
"version": "0.89.24", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "dependencies": { |
@@ -175,3 +175,4 @@ export const enum AGG { | ||
AUTO_CHOICES = '.auto-choices', | ||
ID = '.id' | ||
ID = '.id', | ||
COLOR_CODING_CONDITIONAL = 'color-coding-conditional' | ||
} | ||
@@ -178,0 +179,0 @@ |
@@ -199,3 +199,4 @@ /** | ||
AUTO_CHOICES: '.auto-choices', | ||
ID: '.id' | ||
ID: '.id', | ||
COLOR_CODING_CONDITIONAL: 'color-coding-conditional' | ||
} | ||
@@ -202,0 +203,0 @@ |
@@ -928,2 +928,12 @@ import * as rxjs from 'rxjs'; | ||
/** Adds calculated column. | ||
* @param {string} name | ||
* @param {string} expression | ||
* @param {ColumnType} type | ||
* @param {bool} treatAsString | ||
* @returns {Column} */ | ||
addNewCalculated(name, expression, type = null, treatAsString = null) { | ||
return new Promise((resolve, reject) => toJs(grok_ColumnList_AddNewCalculated(this.d, name, expression, type, treatAsString, (c) => resolve(c), (e) => reject(e)))); | ||
} | ||
/** Adds a string column | ||
@@ -930,0 +940,0 @@ * @param {string} name |
@@ -675,3 +675,6 @@ import {TYPE} from "./const"; | ||
super(d); | ||
if (d instanceof String) this.webRoot = d; | ||
if (typeof d === 'string' || d instanceof String) { | ||
this.webRoot = d; | ||
this.d = null; | ||
} | ||
this.version = ""; | ||
@@ -678,0 +681,0 @@ } |
@@ -237,3 +237,3 @@ /** | ||
* */ | ||
export class JsEntityMeta { | ||
export class ObjectHandler { | ||
@@ -243,3 +243,3 @@ /** Type of the object that this meta handles. */ | ||
static register(meta: JsEntityMeta): void | ||
static register(meta: ObjectHandler): void | ||
@@ -246,0 +246,0 @@ /** |
49
ui.js
@@ -75,10 +75,13 @@ /** | ||
/** @returns {HTMLCanvasElement} */ | ||
export function canvas(height = null, width = null) { | ||
/** @returns {HTMLCanvasElement} | ||
* @param {number} height | ||
* @param {number} width | ||
* */ | ||
export function canvas(width = null, height = null) { | ||
let result = element("CANVAS"); | ||
if (height == null && width == null) { | ||
if (height != null && width != null) { | ||
$(result).height(height); | ||
$(result).width(width); | ||
$(result).prop('height', `${height}px`); | ||
$(result).prop('width', `${width}px`); | ||
$(result).prop('height', `${height}`); | ||
$(result).prop('width', `${width}`); | ||
} | ||
@@ -211,2 +214,8 @@ return result; | ||
export function renderInline(x) { | ||
let handler = ObjectHandler.forEntity(x); | ||
return handler == null ? render(x) : handler.renderMarkup(x); | ||
} | ||
/** Renders inline text, calling [renderMarkup] for each non-HTMLElement | ||
@@ -216,3 +225,3 @@ * @param {object[]} objects | ||
export function inlineText(objects) { | ||
return span(objects.map((item) => render(item))); | ||
return span(objects.map((item) => renderInline(item))); | ||
} | ||
@@ -565,8 +574,14 @@ | ||
/** | ||
* Override this class, and {@link register} an instance to integrate the platform with custom | ||
* types and objects. | ||
* Override the corresponding methods, and {@link register} an instance to | ||
* let Datagrok know how to handle objects of the specified type. | ||
* | ||
* {@link isApplicable} is used to associate an object with the handler. | ||
* When handling an object x, the platform uses the first registered handler that | ||
* claims that it is applicable to that object. | ||
* | ||
* TODO: search, destructuring to properties | ||
* | ||
* Samples: {@link https://public.datagrok.ai/js/samples/ui/meta/meta} | ||
* */ | ||
export class JsEntityMeta { | ||
export class ObjectHandler { | ||
@@ -650,3 +665,3 @@ /** Type of the object that this meta handles. */ | ||
/** Registers entity handler. | ||
* @param {JsEntityMeta} meta */ | ||
* @param {ObjectHandler} meta */ | ||
static register(meta) { | ||
@@ -659,3 +674,3 @@ grok_Meta_Register(meta); | ||
/** @returns {JsEntityMeta[]} */ | ||
/** @returns {ObjectHandler[]} */ | ||
static list() { | ||
@@ -667,3 +682,3 @@ return toJs(grok_Meta_List()); | ||
* @param {Object} x | ||
* @returns {JsEntityMeta} | ||
* @returns {ObjectHandler} | ||
* */ | ||
@@ -689,3 +704,3 @@ static forEntity(x) { | ||
export class EntityMetaDartProxy extends JsEntityMeta { | ||
export class EntityMetaDartProxy extends ObjectHandler { | ||
constructor(d) { | ||
@@ -698,3 +713,3 @@ super(); | ||
isApplicable(x) { return grok_Meta_IsApplicable(this.d, toDart(x)); } | ||
getCaption(x) { return grok_Meta_Get_Name(this.d); }; | ||
getCaption(x) { return grok_Meta_Get_Name(this.d, x); }; | ||
@@ -794,2 +809,8 @@ renderIcon(x, context = null) { return grok_Meta_RenderIcon(x); } | ||
export function narrowForm(children = [], options = null) { | ||
let d = form(children, options); | ||
$(d).addClass('ui-form-condensed'); | ||
return d; | ||
} | ||
export function buttonsInput(children = []) { | ||
@@ -796,0 +817,0 @@ if (!Array.isArray(children)) |
379813
11066