mirror of
https://github.com/CommunityOx/ox_lib.git
synced 2026-08-19 07:56:02 +01:00
feat(web/input): allowCancel option
This commit is contained in:
@@ -16,10 +16,14 @@ local input
|
|||||||
---@field step? number
|
---@field step? number
|
||||||
---@field description? string
|
---@field description? string
|
||||||
|
|
||||||
|
---@class InputDialogOptionsProps
|
||||||
|
---@field allowCancel? boolean
|
||||||
|
|
||||||
---@param heading string
|
---@param heading string
|
||||||
---@param rows string[] | InputDialogRowProps[]
|
---@param rows string[] | InputDialogRowProps[]
|
||||||
|
---@param options InputDialogOptionsProps[]
|
||||||
---@return string[] | number[] | boolean[] | nil
|
---@return string[] | number[] | boolean[] | nil
|
||||||
function lib.inputDialog(heading, rows)
|
function lib.inputDialog(heading, rows, options)
|
||||||
if input then return end
|
if input then return end
|
||||||
input = promise.new()
|
input = promise.new()
|
||||||
|
|
||||||
@@ -35,7 +39,8 @@ function lib.inputDialog(heading, rows)
|
|||||||
action = 'openDialog',
|
action = 'openDialog',
|
||||||
data = {
|
data = {
|
||||||
heading = heading,
|
heading = heading,
|
||||||
rows = rows
|
rows = rows,
|
||||||
|
options = options
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@@ -15,6 +15,9 @@ import ColorField from './components/fields/color';
|
|||||||
export interface InputProps {
|
export interface InputProps {
|
||||||
heading: string;
|
heading: string;
|
||||||
rows: Array<IInput | ICheckbox | ISelect | INumber | ISlider | IColorInput>;
|
rows: Array<IInput | ICheckbox | ISelect | INumber | ISlider | IColorInput>;
|
||||||
|
options?: {
|
||||||
|
allowCancel?: boolean;
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
export type FormValues = {
|
export type FormValues = {
|
||||||
@@ -80,6 +83,7 @@ const InputDialog: React.FC = () => {
|
|||||||
opened={visible}
|
opened={visible}
|
||||||
onClose={handleClose}
|
onClose={handleClose}
|
||||||
centered
|
centered
|
||||||
|
closeOnEscape={fields.options?.allowCancel !== false}
|
||||||
closeOnClickOutside={false}
|
closeOnClickOutside={false}
|
||||||
size="xs"
|
size="xs"
|
||||||
styles={{ title: { textAlign: 'center', width: '100%', fontSize: 18 } }}
|
styles={{ title: { textAlign: 'center', width: '100%', fontSize: 18 } }}
|
||||||
@@ -117,7 +121,13 @@ const InputDialog: React.FC = () => {
|
|||||||
);
|
);
|
||||||
})}
|
})}
|
||||||
<Group position="right" spacing={10}>
|
<Group position="right" spacing={10}>
|
||||||
<Button uppercase variant="default" onClick={handleClose} mr={3}>
|
<Button
|
||||||
|
uppercase
|
||||||
|
variant="default"
|
||||||
|
onClick={handleClose}
|
||||||
|
mr={3}
|
||||||
|
disabled={fields.options?.allowCancel === false}
|
||||||
|
>
|
||||||
{locale.ui.cancel}
|
{locale.ui.cancel}
|
||||||
</Button>
|
</Button>
|
||||||
<Button uppercase variant="light" type="submit">
|
<Button uppercase variant="light" type="submit">
|
||||||
|
|||||||
Reference in New Issue
Block a user