# Prompt Nui `[Client]`

A library to manage NUI-based prompts. This module allows you to create and manage prompt groups with customizable prompts, key bindings, key hold durations, pagination, and visibility controls.

:::tip

- **Keyboard Keys Mapping:** You can find the complete list of valid key inputs, including special and function keys, in the [Keyboard keys mapping](../../raw-keys/client#keyboard-keys-mapping) section of the Raw Keys module.
- **Keyboard Layouts:** To learn more about switching between QWERTY and AZERTY layouts, see the [Setting Keyboard Layout](../../raw-keys/client#setting-keyboard-layout) section of the Raw Keys module.
  :::

## JO Functions

### jo.promptNui.createGroup()

Creates a new prompt group with a specified title and optional position. <br>

#### Syntax

```lua
jo.promptNui.createGroup(title, position)
```

#### Parameters

`title` : _string|boolean_
> The title for the new prompt group. Set to `false` to have no title
>

`position` : _string_ `[Optional]`
> The screen position for the group. <br> Allowed values are : `"bottom-right"`,`"center-right"`,`"top-right"`,`"bottom-left"`,`"center-left"`,`"top-left"` <br> default : `"bottom-right"`
>

#### Return Value

Type : _[GroupClass](#groupclass-methods)_

> A new instance of a prompt group.

---

### jo.promptNui.isCompleted()

Checks whether a specified key has been held for the required duration to trigger an action.<br>Optionally ensures that the key does not trigger repeatedly unless explicitly allowed. <br>

#### Syntax

```lua
jo.promptNui.isCompleted(group, key, fireMultipleTimes)
```

#### Parameters

`group` : _[GroupClass](#groupclass-methods)|string_
> The prompt group to validate against. Retrocompatible: can be the key string.
>

`key` : _string|boolean|nil_
> The key identifier to check. Retrocompatible: can be `fireMultipleTimes`.
>

`fireMultipleTimes` : _boolean|nil_ `[Optional]`
> If true, allows the key to trigger multiple times<br> defaults to `false`.
>

#### Return Value

Type : _boolean_

> True if the key press is complete and valid, otherwise `false`.

---

### jo.promptNui.isDisplayed()

#### Syntax

```lua
jo.promptNui.isDisplayed()
```

## GroupClass Methods

### GroupClass:addPrompt()

Adds a new prompt to the group on a specified page. <br>Creates or initializes pages as necessary, assigns the prompt's position, and returns the new prompt. <br>

#### Syntax

```lua
GroupClass:addPrompt(key, label, holdTime, page, price)
```

#### Parameters

`key` : _string_
> A key string for the prompt.
>

`label` : _string_
> The descriptive label for the prompt.
>

`holdTime` : _number|boolean_
> Duration to hold the key before the prompt triggers. <br> Set it to `false` if no hold time is required
>

`page` : _number_ `[Optional]`
> The page number to add the prompt to<br> defaults to 1.
>

`price` : _table|integer|number|boolean_ `[Optional]`
> The price to display next to the prompt label. Uses the shared pricing structure <br> defaults to false.
>

#### Return Value

Type : _[PromptClass](#promptclass-methods)_

> The newly created prompt object.

---

### GroupClass:addSeparator()

Adds a visual separator to the group on a specified page. <br>

#### Syntax

```lua
GroupClass:addSeparator(page)
```

#### Parameters

`page` : _number_ `[Optional]`
> The page number to add the separator to<br> defaults to 1.
>

---

### GroupClass:display()

Displays the prompt group on the NUI interface and sets up key listeners for the active page. If the group has multiple pages, it also configures pagination using the nextPageKey. <br>

#### Syntax

```lua
GroupClass:display(page)
```

#### Parameters

`page` : _number_ `[Optional]`
> The page number to display<br> defaults to the group's current page.
>

---

### GroupClass:forceDisplay()

#### Syntax

```lua
GroupClass:forceDisplay()
```

---

### GroupClass:forceHide()

#### Syntax

```lua
GroupClass:forceHide()
```

---

### GroupClass:hide()

Hides the prompt group from the NUI interface and removes its active key listeners. <br>

#### Syntax

```lua
GroupClass:hide()
```

---

### GroupClass:isVisible()

Returns whether the group is currently visible. <br>

#### Syntax

```lua
GroupClass:isVisible()
```

#### Return Value

Type : _boolean_

> `true` if the group is visible, `false` otherwise

---

### GroupClass:new()

#### Syntax

```lua
GroupClass:new()
```

---

### GroupClass:refreshNUI()

Refreshes the NUI interface for the group by updating a specified property. This update is only sent if the group is currently visible. <br>

#### Syntax

```lua
GroupClass:refreshNUI(property)
```

#### Parameters

`property` : _string_
> The group property to update (e.g., "title", "position",..).
>

---

### GroupClass:setNextPageKey()

Sets the key used for navigating to the next page of prompts. <br>

#### Syntax

```lua
GroupClass:setNextPageKey(key)
```

#### Parameters

`key` : _string_
> The key string to be used for pagination.
>

---

### GroupClass:setPosition()

Sets the display position for the prompt group. <br>

#### Syntax

```lua
GroupClass:setPosition(position)
```

#### Parameters

`position` : _string_
> The screen position for the group. <br> Allowed values are : `"bottom-right"`,`"center-right"`,`"top-right"`,`"bottom-left"`,`"center-left"`,`"top-left"`
>

---

### GroupClass:setSuppressNativePrompts()

Configures which native RedM prompt types are suppressed while this group is displayed. <br>
Call without an argument or with `true` to suppress the default types 1 through 12. <br>
Pass `false` or an empty table to suppress none, or an integer array to suppress only those types. <br>

#### Syntax

```lua
GroupClass:setSuppressNativePrompts(value)
```

#### Parameters

`value` : _boolean|integer[]_ `[Optional]`

---

### GroupClass:setTitle()

Sets the title for the prompt group. <br>

#### Syntax

```lua
GroupClass:setTitle(title)
```

#### Parameters

`title` : _string_
> The title to assign to the group.
>

## PromptClass Methods

### PromptClass:getLabel()

Get the label text for the prompt. <br>

#### Syntax

```lua
PromptClass:getLabel()
```

#### Return Value

Type : _string_

> The text label assigned to the prompt.

---

### PromptClass:isVisible()

Returns whether the prompt is currently visible. <br>

#### Syntax

```lua
PromptClass:isVisible()
```

#### Return Value

Type : _boolean_

> `true` if the prompt is visible, `false` otherwise

---

### PromptClass:new()

#### Syntax

```lua
PromptClass:new()
```

---

### PromptClass:refreshNUI()

Refreshes the NUI interface for a prompt, updating a specific property. This update is only performed if the prompt belongs to the currently visible group. <br>

#### Syntax

```lua
PromptClass:refreshNUI(property)
```

#### Parameters

`property` : _string_
> The property name to update (e.g., "label", "disabled").
>

---

### PromptClass:setEnabled()

Enables or disables the prompt and updates its associated key listeners. <br>

#### Syntax

```lua
PromptClass:setEnabled(enabled)
```

#### Parameters

`enabled` : _boolean_
> `true` to enable the prompt, `false` to disable it.
>

---

### PromptClass:setHoldTime()

Sets the key hold duration for the prompt. <br>

#### Syntax

```lua
PromptClass:setHoldTime(holdTime)
```

#### Parameters

`holdTime` : _number|boolean_
> Duration (in milliseconds) the key must be held before activation; `false` if not applicable.
>

---

### PromptClass:setKeyboardKeys()

Configures the keyboard keys for the prompt. Ensures that the keys are stored in a table, converting a single key to uppercase if needed. <br>

#### Syntax

```lua
PromptClass:setKeyboardKeys(keyboardKeys)
```

#### Parameters

`keyboardKeys` : _table|string_
> A table of key strings or a single key string.
>

---

### PromptClass:setLabel()

Sets the label text for the prompt. <br>

#### Syntax

```lua
PromptClass:setLabel(label)
```

#### Parameters

`label` : _string_
> The text label to assign to the prompt.
>

---

### PromptClass:setPrice()

Sets the prompt price and formats it with the shared pricing structure. <br>

#### Syntax

```lua
PromptClass:setPrice(price)
```

#### Parameters

`price` : _table|integer|number|boolean|nil_
> The prompt price. Set it to `false` if no price is required
>

---

### PromptClass:setVisible()

Sets the visibility of the prompt and updates its enabled state accordingly. <br>

#### Syntax

```lua
PromptClass:setVisible(visible)
```

#### Parameters

`visible` : _boolean_
> `true` to show the prompt, `false` to hide it.
>
