2020-10-02 15:10:00 +00:00
|
|
|
var dispose = require('../lib/dispose');
|
2023-09-21 16:57:58 +00:00
|
|
|
const {theme} = require('app/client/ui2018/cssVars');
|
2022-03-31 13:33:37 +00:00
|
|
|
const {CellStyle} = require('app/client/widgets/CellStyle');
|
|
|
|
const {dom} = require('grainjs');
|
2020-10-02 15:10:00 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* AbstractWidget - The base of the inheritance tree for widgets.
|
|
|
|
* @param {Function} field - The RowModel for this view field.
|
2023-09-21 16:57:58 +00:00
|
|
|
* @param {string|undefined} options.defaultTextColor - CSS value of the default
|
|
|
|
* text color for the widget. Defaults to the current theme's cell fg color.
|
|
|
|
*
|
2020-10-02 15:10:00 +00:00
|
|
|
*/
|
2021-03-02 12:27:08 +00:00
|
|
|
function AbstractWidget(field, opts = {}) {
|
2020-10-02 15:10:00 +00:00
|
|
|
this.field = field;
|
|
|
|
this.options = field.widgetOptionsJson;
|
2021-12-15 22:31:53 +00:00
|
|
|
this.valueFormatter = this.field.visibleColFormatter;
|
2023-09-21 16:57:58 +00:00
|
|
|
this.defaultTextColor = opts.defaultTextColor ?? theme.cellFg.toString();
|
2020-10-02 15:10:00 +00:00
|
|
|
}
|
|
|
|
dispose.makeDisposable(AbstractWidget);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Builds the DOM showing configuration buttons and fields in the sidebar.
|
|
|
|
*/
|
2024-05-29 21:55:21 +00:00
|
|
|
AbstractWidget.prototype.buildConfigDom = function(_gristDoc) {
|
2020-10-02 15:10:00 +00:00
|
|
|
throw new Error("Not Implemented");
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Builds the transform prompt config DOM in the few cases where it is necessary.
|
|
|
|
* Child classes need not override this function if they do not require transform config options.
|
|
|
|
*/
|
2024-05-29 21:55:21 +00:00
|
|
|
AbstractWidget.prototype.buildTransformConfigDom = function(_gristDoc) {
|
2020-10-02 15:10:00 +00:00
|
|
|
return null;
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Builds the data cell DOM.
|
|
|
|
* @param {DataRowModel} row - The rowModel object.
|
|
|
|
*/
|
|
|
|
AbstractWidget.prototype.buildDom = function(row) {
|
|
|
|
throw new Error("Not Implemented");
|
|
|
|
};
|
|
|
|
|
2022-03-31 13:33:37 +00:00
|
|
|
AbstractWidget.prototype.buildColorConfigDom = function(gristDoc) {
|
|
|
|
return dom.create(CellStyle, this.field, gristDoc, this.defaultTextColor);
|
2020-10-02 15:10:00 +00:00
|
|
|
};
|
|
|
|
|
2024-02-14 21:18:09 +00:00
|
|
|
AbstractWidget.prototype.buildFormConfigDom = function() {
|
|
|
|
return null;
|
|
|
|
};
|
|
|
|
|
|
|
|
AbstractWidget.prototype.buildFormTransformConfigDom = function() {
|
|
|
|
return null;
|
|
|
|
};
|
|
|
|
|
2020-10-02 15:10:00 +00:00
|
|
|
module.exports = AbstractWidget;
|