@gramio/keyboards
Advanced tools
Comparing version 0.0.1 to 0.0.2
@@ -1,23 +0,3 @@ | ||
import type { TelegramKeyboardButtonPollType, TelegramKeyboardButtonRequestChat, TelegramKeyboardButtonRequestUsers, TelegramReplyKeyboardMarkup } from "@gramio/types"; | ||
import "reflect-metadata"; | ||
export declare class Keyboard { | ||
private rows; | ||
private currentRow; | ||
isOneTime: boolean; | ||
isPersistent: boolean; | ||
isResized: boolean; | ||
placeholderValue: string | undefined; | ||
text(text: string): this; | ||
requestUsers(text: string, requestId: number, options: Omit<TelegramKeyboardButtonRequestUsers, "request_id">): this; | ||
requestChat(text: string, requestId: number, options?: Omit<TelegramKeyboardButtonRequestChat, "request_id">): this; | ||
requestContact(text: string): this; | ||
requestLocation(text: string): this; | ||
requestPoll(text: string, type?: TelegramKeyboardButtonPollType["type"]): this; | ||
webApp(text: string, url: string): this; | ||
oneTime(isEnabled?: boolean): this; | ||
persistent(isEnabled?: boolean): this; | ||
placeholder(value?: string): this; | ||
resized(isEnabled?: boolean): this; | ||
private addButton; | ||
toJSON(): TelegramReplyKeyboardMarkup; | ||
} | ||
export * from "./keyboard"; | ||
export * from "./inline-keyboard"; |
"use strict"; | ||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { | ||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; | ||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); | ||
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; | ||
return c > 3 && r && Object.defineProperty(target, key, r), r; | ||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
var desc = Object.getOwnPropertyDescriptor(m, k); | ||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { | ||
desc = { enumerable: true, get: function() { return m[k]; } }; | ||
} | ||
Object.defineProperty(o, k2, desc); | ||
}) : (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
o[k2] = m[k]; | ||
})); | ||
var __exportStar = (this && this.__exportStar) || function(m, exports) { | ||
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p); | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.Keyboard = void 0; | ||
const inspectable_1 = require("inspectable"); | ||
require("reflect-metadata"); | ||
let Keyboard = class Keyboard { | ||
rows = []; | ||
currentRow = []; | ||
isOneTime = false; | ||
isPersistent = false; | ||
isResized = false; | ||
placeholderValue = undefined; | ||
text(text) { | ||
this.addButton({ text }); | ||
return this; | ||
} | ||
requestUsers(text, requestId, options) { | ||
this.addButton({ | ||
text, | ||
request_users: { | ||
...options, | ||
request_id: requestId, | ||
}, | ||
}); | ||
return this; | ||
} | ||
requestChat(text, requestId, options) { | ||
this.addButton({ | ||
text, | ||
request_chat: { | ||
// [INFO] Why not false by default? | ||
chat_is_channel: false, | ||
...options, | ||
request_id: requestId, | ||
}, | ||
}); | ||
return this; | ||
} | ||
requestContact(text) { | ||
this.addButton({ | ||
text, | ||
request_contact: true, | ||
}); | ||
return this; | ||
} | ||
requestLocation(text) { | ||
this.addButton({ | ||
text, | ||
request_location: true, | ||
}); | ||
return this; | ||
} | ||
requestPoll(text, type) { | ||
this.addButton({ | ||
text, | ||
request_poll: { | ||
type, | ||
}, | ||
}); | ||
return this; | ||
} | ||
webApp(text, url) { | ||
this.addButton({ | ||
text, | ||
web_app: { | ||
url, | ||
}, | ||
}); | ||
return this; | ||
} | ||
oneTime(isEnabled = true) { | ||
this.isOneTime = isEnabled; | ||
return this; | ||
} | ||
persistent(isEnabled = true) { | ||
this.isPersistent = isEnabled; | ||
return this; | ||
} | ||
placeholder(value) { | ||
this.placeholderValue = value; | ||
return this; | ||
} | ||
resized(isEnabled = true) { | ||
this.isResized = isEnabled; | ||
return this; | ||
} | ||
addButton(button) { | ||
this.currentRow.push(button); | ||
} | ||
toJSON() { | ||
return { | ||
keyboard: this.rows.concat(this.currentRow), | ||
one_time_keyboard: this.isOneTime, | ||
is_persistent: this.isPersistent, | ||
input_field_placeholder: this.placeholderValue, | ||
resize_keyboard: this.isResized, | ||
}; | ||
} | ||
}; | ||
exports.Keyboard = Keyboard; | ||
exports.Keyboard = Keyboard = __decorate([ | ||
(0, inspectable_1.Inspectable)({ | ||
serialize: (keyboard) => keyboard.toJSON(), | ||
}) | ||
], Keyboard); | ||
__exportStar(require("./keyboard"), exports); | ||
__exportStar(require("./inline-keyboard"), exports); |
{ | ||
"name": "@gramio/keyboards", | ||
"private": false, | ||
"version": "0.0.1", | ||
"version": "0.0.2", | ||
"main": "dist/index.js", | ||
@@ -16,3 +15,3 @@ "keywords": [ | ||
"devDependencies": { | ||
"@gramio/types": "^7.0.6", | ||
"@gramio/types": "^7.0.7", | ||
"@types/bun": "latest", | ||
@@ -22,5 +21,5 @@ "inspectable": "^2.1.0" | ||
"peerDependencies": { | ||
"@gramio/types": "^7.0.6", | ||
"@gramio/types": "^7.0.7", | ||
"inspectable": "^2.1.0", | ||
"typescript": "^5.0.0", | ||
"typescript": "^5.3.3", | ||
"reflect-metadata": "^0.2.1" | ||
@@ -27,0 +26,0 @@ }, |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
26524
12
597
1