diff --git a/resource/interface/client/input.lua b/resource/interface/client/input.lua index 75144b8f3..bb6f32b20 100644 --- a/resource/interface/client/input.lua +++ b/resource/interface/client/input.lua @@ -16,10 +16,14 @@ local input ---@field step? number ---@field description? string +---@class InputDialogOptionsProps +---@field allowCancel? boolean + ---@param heading string ---@param rows string[] | InputDialogRowProps[] +---@param options InputDialogOptionsProps[] ---@return string[] | number[] | boolean[] | nil -function lib.inputDialog(heading, rows) +function lib.inputDialog(heading, rows, options) if input then return end input = promise.new() @@ -35,7 +39,8 @@ function lib.inputDialog(heading, rows) action = 'openDialog', data = { heading = heading, - rows = rows + rows = rows, + options = options } }) diff --git a/web/src/features/dialog/InputDialog.tsx b/web/src/features/dialog/InputDialog.tsx index 17b9cd341..ae3a000a5 100644 --- a/web/src/features/dialog/InputDialog.tsx +++ b/web/src/features/dialog/InputDialog.tsx @@ -15,6 +15,9 @@ import ColorField from './components/fields/color'; export interface InputProps { heading: string; rows: Array; + options?: { + allowCancel?: boolean; + }; } export type FormValues = { @@ -80,6 +83,7 @@ const InputDialog: React.FC = () => { opened={visible} onClose={handleClose} centered + closeOnEscape={fields.options?.allowCancel !== false} closeOnClickOutside={false} size="xs" styles={{ title: { textAlign: 'center', width: '100%', fontSize: 18 } }} @@ -117,7 +121,13 @@ const InputDialog: React.FC = () => { ); })} -