入力ダイアログ
入力ダイアログウィンドウでは、入力フィールドを設定してユーザーからデータを受け取ることができます。
lib.inputDialog
Lua
lib.inputDialog(heading, rows, options)- を見出しにした:
string - 列:
string[]またはtable(array)- タイプだ:
'input'または'number'または'checkbox'または'select'または'slider'または'color'または'multi-select'または'date'または'date-range'または'time'または'textarea'
- タイプだ:
- オプションは?
table(object)- allowCancel:
boolean- false の場合、ユーザーは送信するまで入力ダイアログをキャンセルして閉じることができません。
- 定義されていない場合、ユーザーは入力ダイアログをキャンセルして閉じることができる。
- サイズは?
"xs"|"sm"|"md"|"lg"|"xl";
- allowCancel:
フィールドタイプのプロパティ
-
入力
- のラベルが貼られている:
string - という記述がある:
string - プレースホルダー?
string - アイコンは?
string - 必要ですか?
boolean - 無効ですか?
boolean - デフォルト?
string - パスワード?
boolean - 分?
number - マックス?
number
- のラベルが貼られている:
-
番号
- のラベルが貼られている:
string - という記述がある:
string - プレースホルダー?
string - アイコンは?
string - 必要ですか?
boolean - 無効ですか?
boolean - デフォルト?
number - 分?
number - マックス?
number - 精度?
number - ステップ?
number
- のラベルが貼られている:
-
チェックボックス
- のラベルが貼られている:
string - チェックした?
boolean - 無効ですか?
boolean - 必要ですか?
boolean
- のラベルが貼られている:
-
セレクトとマルチセレクト
- のラベルが貼られている:
string - のオプションがある:
table(array)- 値である:
string - ラベル?
string
- 値である:
- という記述がある:
string - プレースホルダー?
string - アイコンは?
string - 必要ですか?
boolean - 無効ですか?
boolean - デフォルト?
string|tableのみmulti-select)- デフォルト・オプションの値。
- クリア可能か?
boolean - 検索可能か?
boolean - maxSelectedValues?
numberのみmulti-select)- 選択できるオプションの最大数。
- のラベルが貼られている:
-
スライダー
- のラベルが貼られている:
string - プレースホルダー?
string - アイコンは?
string - 必要ですか?
boolean - 無効ですか?
boolean - デフォルト?
number - 分?
number - マックス?
number - ステップ?
number
- のラベルが貼られている:
-
カラー
- のラベルが貼られている:
string - という記述がある:
string - プレースホルダー?
string - アイコンは?
string - 必要ですか?
boolean - 無効ですか?
boolean - デフォルト?
string - フォーマット?
'hex'|'hexa'|'rgb'|'rgba'|'hsl'|'hsla';
- のラベルが貼られている:
-
日付
- のラベルが貼られている:
string - という記述がある:
string - アイコンは?
string - 必要ですか?
boolean - 無効ですか?
boolean - デフォルト?
stringまたはtrue- デフォルトは現在の日付
- フォーマット?
string- フィールドに表示する日付フォーマット
- returnString?
boolean- 日付を文字列で返します。
DD/MM/YYYYしかし、もしformatが定義されていれば、それを使う。
- 日付を文字列で返します。
- クリア可能か?
boolean - 分?
string- “01/01/2000”
- マックス?
string- “12/12/2023”
- のラベルが貼られている:
-
日付範囲
- のラベルが貼られている:
string - という記述がある:
string - アイコンは?
string - 必要ですか?
boolean - 無効ですか?
boolean - デフォルト?
[string, string] - フォーマット?
string- フィールドに表示する日付フォーマット
- returnString?
boolean- 日付を文字列で返します。
DD/MM/YYYYしかし、もしformatが定義されていれば、それを使う。
- 日付を文字列で返します。
- クリア可能か?
boolean
- のラベルが貼られている:
-
時間
- のラベルが貼られている:
string - という記述がある:
string - アイコンは?
string - 必要ですか?
boolean - 無効ですか?
boolean - デフォルト?
string - フォーマット?
'12'または'24' - クリア可能か?
boolean
- のラベルが貼られている:
-
テキストエリア
- のラベルが貼られている:
string - という記述がある:
string - プレースホルダー?
string - アイコンは?
string - 必要ですか?
boolean - 無効ですか?
boolean - デフォルト?
number - 分?
number- テキストエリアの最小行数。
- マックス?
number- テキストエリアの最大行数。これを超えるとオーバーフローする。
- オートサイズ?
boolean- true を指定すると、テキストエリアは最大行数に達するまでコンテンツと共に成長する。
- minLength?
number - maxLength?
number
- のラベルが貼られている:
コールバックデータはプロミスベースであり、ユーザーがデータを送信するかポップアップを終了するまでスレッドは実行を継続しない。
返されるデータはテーブル(配列)で、インデックスはダイアログに送られる行を表します。1(0)、3 番目のフィールドのデータが欲しい場合は、インデックス3(2などなど…。
などのフィールドタイプdate,date-rangeそしてtime設定された値のunixタイムスタンプを返す。
lib.closeInputDialog
アクティブな入力ダイアログを強制的に閉じ、その戻り値をnil.
Lua
lib.closeInputDialog()使用例
ベーシック
Lua
local input = lib.inputDialog('Basic dialog', {'First row', 'Second row'})
if not input then return end
print(json.encode(input), input[1], input[2])
上級
Lua
local input = lib.inputDialog('Dialog title', {
{type = 'input', label = 'Text input', description = 'Some input description', required = true, min = 4, max = 16},
{type = 'number', label = 'Number input', description = 'Some number description', icon = 'hashtag'},
{type = 'checkbox', label = 'Simple checkbox'},
{type = 'color', label = 'Colour input', default = '#eb4034'},
{type = 'date', label = 'Date input', icon = {'far', 'calendar'}, default = true, format = "DD/MM/YYYY"}
})
print(json.encode(input))
-- Getting rgb values from colour picker
local rgb = lib.math.torgba(input[4])
-- Transforming date timestamp to a readable format with Lua's os library (server-only)
local timestamp = math.floor(input[5] / 1000)
local date = os.date('%Y-%m-%d %H:%M:%S', timestamp)
Last updated on