INtex WebComponents and their usage
INtex Web Components Documentation
A guide to using the custom web components for building powerful user interfaces within the INtex Projekt X framework.
IntexUI - Global UI Controller
The global intex object provides methods for common UI tasks like dialogs, toasts, and loading indicators. It is available on every page where intexui.js is included.
intex.confirm()
Displays a modal confirmation dialog. It returns a Promise that resolves to true if the user confirms, or false if they cancel.
| Parameter | Type | Description |
|---|---|---|
message | string | The main text to display in the dialog. |
options | object | (Optional) An object with configuration properties. |
| options.title | string | The dialog title. Default: "Information". |
| options.btnOk | string | Text for the confirmation button. Default: "OK". |
| options.btnCancel | string | Text for the cancel button. Default: "Cancel". |
| options.color | string | A hex color for the header and OK button. Default: Accent color. |
| options.icon | string | A Font Awesome icon class (e.g., 'fa-trash-can'). |
| options.width | string | The maximum width of the modal (e.g., '600px'). |
| options.preConfirm | function | An async function that runs before confirming. If it returns false, the dialog remains open. |
Example: Simple Confirmation
if (await intex.confirm("Are you sure you want to proceed?")) {
// User clicked "OK"
console.log("Action confirmed.");
}
Example: Delete Confirmation
const confirmed = await intex.confirm(
"This will permanently delete the record.",
{
title: "Delete Record",
btnOk: "Yes, delete",
color: "#dc3545", // Red for danger
icon: "fa-triangle-exclamation"
}
);
if (confirmed) { /* ... */ }
intex.toast()
Shows a short-lived notification message (toast) at the top-right of the screen.
| Parameter | Type | Description |
|---|---|---|
message | string | The text to display. |
type | string | (Optional) The style of the toast: 'success', 'danger', 'warning', or 'info'. Default: 'success'. |
delay | number | (Optional) Duration in milliseconds before the toast fades. Default: 5000. |
Example
intex.toast("Record saved successfully!", "success");
intex.toast("Could not connect to server.", "danger");
intex.showLoading()
Displays or hides a full-screen loading overlay.
Example
// Show the loader
intex.showLoading(true, "Processing data...");
// Hide the loader after some work is done
setTimeout(() => {
intex.showLoading(false);
}, 2000);
<intex-datepicker>
A modern, theme-aware date and datetime picker component.
Attributes
| Attribute | Description | Example |
|---|---|---|
value | The current value in ISO format (YYYY-MM-DD or YYYY-MM-DD HH:mm). | value="2024-12-31 14:30" |
mode | Set to 'date' or 'datetime'. Default is 'date'. | mode="datetime" |
lang | Language for localization ('de' or 'en'). Default: 'de'. | lang="en" |
accent-color | Overrides the default accent color with a specific hex value. | accent-color="#e67e22" |
Events
The component dispatches a change event when a new date or time is selected. The new value is available in event.detail.
Usage Example
For form submissions, it's best practice to pair the datepicker with a hidden input that stores the ISO-formatted value.
<!-- In your form -->
<div class="mb-3">
<label for="my-date-picker" class="form-label">Appointment Date</label>
<!-- The component for the user -->
<intex-datepicker id="my-date-picker" mode="datetime" value="2024-08-15 10:00"></intex-datepicker>
<!-- The hidden input that gets submitted -->
<input type="hidden" name="appointment_date" id="my-date-value" value="2024-08-15 10:00">
</div>
<script>
const picker = document.getElementById('my-date-picker');
const hiddenInput = document.getElementById('my-date-value');
picker.addEventListener('change', (event) => {
hiddenInput.value = event.detail;
});
</script>
<intex-dropzone>
A drag-and-drop file upload component that integrates seamlessly with standard forms.
Important: This component works by wrapping a standard <input type="file">, which you must place inside it in your HTML. This ensures native form submission compatibility.
Attributes
| Attribute | Description |
|---|---|
label | The main label text displayed above the dropzone. |
name | The name for the file input, used in form submission. |
accept | A string defining the file types the file input should accept (e.g., 'image/*, .pdf'). |
current-file-url | URL to an already uploaded file to display it. |
current-file-name | Display name for the current file. |
max-size | Maximum file size in megabytes (e.g., '5'). Default: 5. |
max-files | Maximum number of files allowed. Default: 1. |
required | Makes the file input a required field in the form. |
disabled | Disables the component. |
error | Displays an error message below the component. |
Usage Example
The component requires a standard file input and a hidden input for the delete flag inside its light DOM.
<!-- Example for a new upload -->
<intex-dropzone label="Upload Profile Picture" name="profile_pic" accept="image/png, image/jpeg">
<!-- This input is controlled by the component -->
<input type="file" name="profile_pic">
</intex-dropzone>
<!-- Example with an existing file -->
<intex-dropzone
label="Contract Document"
name="contract_file"
current-file-url="/files/contract.pdf"
current-file-name="Contract_2024.pdf">
<!-- The file input for a new upload -->
<input type="file" name="contract_file">
<!-- Hidden input to signal deletion on the server -->
<input type="hidden" name="delete_file_contract" value="0">
</intex-dropzone>
<script>
// Script to connect the delete checkbox to the hidden input
document.querySelector('intex-dropzone[name="contract_file"]').addEventListener('delete-change', (e) => {
const hiddenInput = document.querySelector('input[name="delete_file_contract"]');
if (hiddenInput) {
hiddenInput.value = e.detail ? '1' : '0';
}
});
</script>
<intex-editor>
A lightweight, theme-aware WYSIWYG editor.
Important: The editor's content is not part of the standard form submission. You must use JavaScript to sync its content with a hidden <textarea>.
Attributes
| Attribute | Description |
|---|---|
config | Defines the toolbar complexity: 'light', 'normal', or 'pro'. Default: 'normal'. |
placeholders | A JSON string of an array of objects ([{label: "User", value: "{user.name}"}]) to populate the placeholder dropdown. |
username | The current user's name, used for the 'Insert Username' context menu action. |
lang | Language for tooltips ('de' or 'en'). Default: 'de'. |
Properties & Events
- Property:
.value: Get or set the editor's HTML content programmatically. - Event:
input: Fires whenever the content inside the editor changes.
Usage Example
Always pair the editor with a textarea to ensure the content is submitted with the form.
<div class="mb-3">
<label class="form-label">Product Description</label>
<!-- The hidden textarea that gets submitted -->
<textarea name="description" id="description-source" class="d-none">
<p>Initial <b>HTML</b> content.</p>
</textarea>
<!-- The editor component for the user -->
<intex-editor id="description-editor" config="pro"></intex-editor>
</div>
<script>
const editor = document.getElementById('description-editor');
const source = document.getElementById('description-source');
// 1. Set initial value from textarea
editor.value = source.value;
// 2. Sync editor content back to textarea on change
editor.addEventListener('input', () => {
source.value = editor.value;
});
</script>