2022-01-20 12:19:37 +01:00
|
|
|
import { Helpers } from "@budibase/bbui"
|
2020-11-16 19:05:17 +01:00
|
|
|
import { BaseStructure } from "./BaseStructure"
|
|
|
|
|
|
|
|
export class Component extends BaseStructure {
|
2024-08-19 12:44:09 +02:00
|
|
|
constructor(name, _id = Helpers.uuid()) {
|
2020-11-16 19:05:17 +01:00
|
|
|
super(false)
|
|
|
|
this._children = []
|
|
|
|
this._json = {
|
2024-08-19 12:44:09 +02:00
|
|
|
_id,
|
2020-11-16 19:05:17 +01:00
|
|
|
_component: name,
|
|
|
|
_styles: {
|
|
|
|
normal: {},
|
|
|
|
hover: {},
|
|
|
|
active: {},
|
|
|
|
selected: {},
|
|
|
|
},
|
|
|
|
_instanceName: "",
|
|
|
|
_children: [],
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
normalStyle(styling) {
|
|
|
|
this._json._styles.normal = styling
|
|
|
|
return this
|
|
|
|
}
|
|
|
|
|
|
|
|
hoverStyle(styling) {
|
|
|
|
this._json._styles.hover = styling
|
|
|
|
return this
|
|
|
|
}
|
|
|
|
|
2021-02-09 15:01:54 +01:00
|
|
|
customStyle(styling) {
|
|
|
|
this._json._styles.custom = styling
|
|
|
|
return this
|
|
|
|
}
|
|
|
|
|
2021-02-02 15:32:58 +01:00
|
|
|
instanceName(name) {
|
|
|
|
this._json._instanceName = name
|
2020-11-16 19:05:17 +01:00
|
|
|
return this
|
|
|
|
}
|
|
|
|
|
2021-02-02 15:32:58 +01:00
|
|
|
// Shorthand for custom props "type"
|
|
|
|
type(type) {
|
|
|
|
this._json.type = type
|
|
|
|
return this
|
|
|
|
}
|
|
|
|
|
|
|
|
// Shorthand for custom props "text"
|
|
|
|
text(text) {
|
|
|
|
this._json.text = text
|
2020-11-16 19:05:17 +01:00
|
|
|
return this
|
|
|
|
}
|
2024-08-19 12:44:09 +02:00
|
|
|
|
|
|
|
getId() {
|
|
|
|
return this._json._id
|
|
|
|
}
|
2024-08-20 15:58:07 +02:00
|
|
|
|
|
|
|
gridDesktopColSpan(start, end) {
|
|
|
|
this._json._styles.normal["--grid-desktop-col-start"] = start
|
|
|
|
this._json._styles.normal["--grid-desktop-col-end"] = end
|
|
|
|
return this
|
|
|
|
}
|
|
|
|
|
|
|
|
gridDesktopRowSpan(start, end) {
|
|
|
|
this._json._styles.normal["--grid-desktop-row-start"] = start
|
|
|
|
this._json._styles.normal["--grid-desktop-row-end"] = end
|
|
|
|
return this
|
|
|
|
}
|
|
|
|
|
|
|
|
gridMobileColSpan(start, end) {
|
|
|
|
this._json._styles.normal["--grid-mobile-col-start"] = start
|
|
|
|
this._json._styles.normal["--grid-mobile-col-end"] = end
|
|
|
|
return this
|
|
|
|
}
|
|
|
|
|
|
|
|
gridMobileRowSpan(start, end) {
|
|
|
|
this._json._styles.normal["--grid-mobile-row-start"] = start
|
|
|
|
this._json._styles.normal["--grid-mobile-row-end"] = end
|
|
|
|
return this
|
|
|
|
}
|
2020-11-16 19:05:17 +01:00
|
|
|
}
|