UNPKG

scriptable-testlab

Version:

A lightweight, efficient tool designed to manage and update scripts for Scriptable.

252 lines 6.02 kB
var __defProp = Object.defineProperty; var __getOwnPropDesc = Object.getOwnPropertyDescriptor; var __getOwnPropNames = Object.getOwnPropertyNames; var __hasOwnProp = Object.prototype.hasOwnProperty; var __export = (target, all) => { for (var name in all) __defProp(target, name, { get: all[name], enumerable: true }); }; var __copyProps = (to, from, except, desc) => { if (from && typeof from === "object" || typeof from === "function") { for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); } return to; }; var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); var ui_table_cell_exports = {}; __export(ui_table_cell_exports, { MockUITableCell: () => MockUITableCell }); module.exports = __toCommonJS(ui_table_cell_exports); var import_scriptable_abstract = require("scriptable-abstract"); var import_image = require("../../media/image"); const DEFAULT_ON_TAP = () => { }; class MockUITableCell extends import_scriptable_abstract.AbsUITableCell { constructor() { super({ title: "", subtitle: null, titleColor: null, subtitleColor: null, titleFont: null, subtitleFont: null, widthWeight: 1, image: null, dismissOnTap: true, onTap: DEFAULT_ON_TAP, alignment: "left" }); } /** * Title text of the cell */ get title() { return this.state.title; } /** * Sets the title text of the cell */ set title(value) { if (typeof value !== "string") { throw new Error("Title must be a string"); } this.setState({ title: value }); } /** * Subtitle text of the cell */ get subtitle() { return this.state.subtitle; } /** * Sets the subtitle text of the cell */ set subtitle(value) { if (value !== null && typeof value !== "string") { throw new Error("Subtitle must be a string or null"); } this.setState({ subtitle: value }); } /** * Color of the title text */ get titleColor() { return this.state.titleColor; } /** * Sets the color of the title text */ set titleColor(value) { if (!value) { throw new Error("Title color cannot be null"); } this.setState({ titleColor: value }); } /** * Color of the subtitle text */ get subtitleColor() { return this.state.subtitleColor; } /** * Sets the color of the subtitle text */ set subtitleColor(value) { if (!value) { throw new Error("Subtitle color cannot be null"); } this.setState({ subtitleColor: value }); } /** * Font of the title text */ get titleFont() { return this.state.titleFont; } /** * Sets the font of the title text */ set titleFont(value) { if (!value) { throw new Error("Title font cannot be null"); } this.setState({ titleFont: value }); } /** * Font of the subtitle text */ get subtitleFont() { return this.state.subtitleFont; } /** * Sets the font of the subtitle text */ set subtitleFont(value) { if (!value) { throw new Error("Subtitle font cannot be null"); } this.setState({ subtitleFont: value }); } /** * Width weight of the cell */ get widthWeight() { return this.state.widthWeight; } /** * Sets the width weight of the cell */ set widthWeight(value) { if (typeof value !== "number" || value <= 0) { throw new Error("Width weight must be a positive number"); } this.setState({ widthWeight: value }); } /** * Image of the cell */ get image() { return this.state.image; } /** * Sets the image of the cell */ set image(value) { if (!value) { throw new Error("Image cannot be null"); } this.setState({ image: value }); } /** * Whether to dismiss the table when the cell is tapped */ get dismissOnTap() { return this.state.dismissOnTap; } /** * Sets whether to dismiss the table when the cell is tapped */ set dismissOnTap(value) { if (typeof value !== "boolean") { throw new Error("DismissOnTap must be a boolean"); } this.setState({ dismissOnTap: value }); } /** * Function to call when the cell is tapped */ get onTap() { return this.state.onTap; } /** * Sets the function to call when the cell is tapped */ set onTap(value) { if (typeof value !== "function") { throw new Error("OnTap must be a function"); } this.setState({ onTap: value }); } /** * Left aligns the content of the cell */ leftAligned() { this.setState({ alignment: "left" }); } /** * Right aligns the content of the cell */ rightAligned() { this.setState({ alignment: "right" }); } /** * Center aligns the content of the cell */ centerAligned() { this.setState({ alignment: "center" }); } static text(title, subtitle) { const cell = new MockUITableCell(); if (title !== void 0) { cell.title = title; } if (subtitle !== void 0) { cell.subtitle = subtitle; } return cell; } static image(image) { if (!image) { throw new Error("Image cannot be null"); } const cell = new MockUITableCell(); cell.image = image; return cell; } static imageAtURL(url) { if (!url) { throw new Error("URL cannot be empty"); } const cell = new MockUITableCell(); const image = import_image.MockImage.fromFile(url); cell.image = image; return cell; } static button(title) { if (!title) { throw new Error("Button title cannot be empty"); } const cell = new MockUITableCell(); cell.title = title; cell.centerAligned(); return cell; } } // Annotate the CommonJS export names for ESM import in node: 0 && (module.exports = { MockUITableCell }); //# sourceMappingURL=ui-table-cell.js.map