VibeFox JS UI — डेमो
त्वरित आरंभ
Plain HTML
त्वरित आरंभ का ऑर्डर फ़ॉर्म: खोजने योग्य एक सेलेक्ट, एक तारीख पिकर जो बीती तारीखों की अनुमति नहीं देता, और एक बटन जो टोस्ट दिखाता है। सेलेक्ट खोलें, फ़िल्टर करने के लिए टाइप करें, एक तारीख चुनें और Order पर क्लिक करें।
document.getElementById('app').innerHTML =
'<form id="order" style="display: grid; gap: 6px; max-width: 320px">' +
'<label for="country">Country</label><div id="country"></div>' +
'<label for="date">Delivery date</label><div id="date"></div>' +
'<div id="send" style="margin-top: 8px"></div>' +
'</form>';
const { createSelect, createDatePicker, createButton, createToast } = VibeFoxJSUi;
createSelect('#country', {
options: [{ value: 'de', label: 'Germany' }, { value: 'fr', label: 'France' }, { value: 'it', label: 'Italy' }, { value: 'es', label: 'Spain' }],
searchable: true,
});
createDatePicker('#date', { min: new Date() });
const toast = createToast(document.body, { position: 'bottom-right' });
createButton('#send', { label: 'Order', on: { click: () => toast.success('Order sent') } });मूल अवधारणाएँ
इवेंट
हर इवेंट हैंडलर एक पेलोड ऑब्जेक्ट प्राप्त करता है। स्लाइडर खींचें या तीर कुंजियों का उपयोग करें: valueChange मान बदलते समय आता है, slideEnd तब जब थंब छोड़ा जाता है।
const output = document.createElement('pre');
output.style.cssText = 'margin: 12px 0 0; min-height: 3em; font: 12px/1.5 ui-monospace, Consolas, monospace; white-space: pre-wrap';
document.getElementById('app').after(output);
const app = document.getElementById('app');
app.style.maxWidth = '420px';
const slider = VibeFoxJSUi.createSlider('#app', { min: 0, max: 100, value: 20, label: 'Volume', tooltip: true });
const lines = [];
const write = (text) => { lines.unshift(text); output.textContent = lines.slice(0, 5).join('\n'); };
slider.on('valueChange', (e) => write('valueChange ' + e.value));
slider.on('slideEnd', (e) => write('slideEnd ' + e.value));
write('ready — drag the slider');स्टेट स्नैपशॉट
getState() वह लौटाता है जो उपयोगकर्ता ने बदला, setState() उसे बहाल करता है। कोई टैब चुनें या किसी टैब को दूसरी जगह खींचें, Save state पर क्लिक करें, टैब फिर से बदलें और Restore state पर क्लिक करें।
function addButtons(buttons) {
const bar = document.createElement('div');
bar.id = 'bar';
bar.style.cssText = 'display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px';
for (const [label, click, variant] of buttons) {
VibeFoxJSUi.createButton(bar.appendChild(document.createElement('span')), { label, variant: variant || 'secondary', on: { click } });
}
document.getElementById('app').before(bar);
}
const output = document.createElement('pre');
output.style.cssText = 'margin: 12px 0 0; min-height: 3em; font: 12px/1.5 ui-monospace, Consolas, monospace; white-space: pre-wrap';
document.getElementById('app').after(output);
const tabs = VibeFoxJSUi.createTabs('#app', {
reorder: true,
tabs: [
{ id: 'a', label: 'Overview', content: 'The first tab.' },
{ id: 'b', label: 'Details', content: 'The second tab.' },
{ id: 'c', label: 'History', content: 'The third tab.' },
],
});
let saved = null;
addButtons([
['Save state', () => { saved = tabs.getState(); output.textContent = 'saved ' + JSON.stringify(saved); }],
['Restore state', () => { if (saved) tabs.setState(saved); output.textContent = 'restored ' + JSON.stringify(tabs.getState()); }],
]);कंटेंट
टैब का कंटेंट (डायलॉग, पैनल, टाइल, कार्ड …) एक HTML स्ट्रिंग, एक DOM नोड या एक फ़ंक्शन होता है, जो एलिमेंट को भरता है। तीनों टैब इनमें से हर प्रकार का एक-एक दिखाते हैं।
const list = document.createElement('ul');
for (const item of ['A DOM node', 'made with createElement']) list.appendChild(document.createElement('li')).textContent = item;
VibeFoxJSUi.createTabs('#app', {
tabs: [
{ id: 'html', label: 'HTML string', content: '<p>An <b>HTML</b> string of your page.</p>' },
{ id: 'node', label: 'DOM node', content: list },
{ id: 'fn', label: 'Renderer', content: (host) => { host.textContent = 'Filled by a function at ' + new Date().toLocaleTimeString(); } },
],
});बटन
Button
वैरिएंट, आइकन और निष्क्रिय (disabled) बटन। Save पर क्लिक करें: जब (सिम्युलेटेड) काम चलता है, तब यह स्पिनर दिखाता है।
const app = document.getElementById('app');
app.style.cssText = 'display: flex; flex-wrap: wrap; gap: 8px; align-items: center';
const add = (options) => VibeFoxJSUi.createButton(app.appendChild(document.createElement('span')), options);
for (const variant of ['primary', 'secondary', 'danger', 'outline', 'ghost']) add({ label: variant[0].toUpperCase() + variant.slice(1), variant });
add({ label: 'Next', iconRight: 'chevron-right', variant: 'outline' });
add({ label: 'Disabled', disabled: true });
const save = add({ label: 'Save', icon: 'check' });
save.on('click', async () => {
save.setLoading(true);
await new Promise((resolve) => setTimeout(resolve, 1000));
save.setLoading(false);
});ButtonGroup and SplitButton
एकल-चयन वाला समूह (संरेखण), टॉगल बटनों का बहु-चयन वाला समूह और मेनू वाला एक स्प्लिट बटन। बटनों पर क्लिक करें और Send के तीर पर भी।
const app = document.getElementById('app');
app.style.cssText = 'display: grid; gap: 12px; justify-items: start';
app.innerHTML =
'<div id="align"></div>' +
'<div id="format"></div>' +
'<div id="send"></div>';
const output = document.createElement('pre');
output.style.cssText = 'margin: 12px 0 0; min-height: 3em; font: 12px/1.5 ui-monospace, Consolas, monospace; white-space: pre-wrap';
document.getElementById('app').after(output);
const align = VibeFoxJSUi.createButtonGroup('#align', { label: 'Alignment', selection: 'single', required: true, value: 'left',
items: [{ id: 'left', icon: 'align-start', title: 'Left' }, { id: 'center', icon: 'align-center', title: 'Center' }, { id: 'right', icon: 'align-end', title: 'Right' }] });
const format = VibeFoxJSUi.createButtonGroup('#format', { label: 'Format', selection: 'multiple',
items: [{ id: 'bold', icon: 'bold', title: 'Bold' }, { id: 'italic', icon: 'italic', title: 'Italic' }, { id: 'underline', icon: 'underline', title: 'Underline' }] });
const send = VibeFoxJSUi.createSplitButton('#send', { label: 'Send', items: [{ id: 'later', label: 'Send later' }, { id: 'draft', label: 'Save draft' }] });
align.on('valueChange', (e) => { output.textContent = 'alignment: ' + e.value; });
format.on('valueChange', (e) => { output.textContent = 'format: ' + JSON.stringify(e.value); });
send.on('click', () => { output.textContent = 'Send'; });
send.on('itemClick', (e) => { output.textContent = 'menu: ' + e.item.id; });फ़ॉर्म कंट्रोल
Input and NumberInput
मास्क वाला फ़ोन फ़ील्ड, साफ़ किया जा सकने वाला ई-मेल फ़ील्ड और दो नंबर इनपुट। Phone में अंक टाइप करें और Quantity में तीर कुंजियों का उपयोग करें।
const app = document.getElementById('app');
app.style.cssText = 'display: grid; gap: 14px; max-width: 420px';
app.innerHTML =
'<div><label for="phone">Phone</label><div id="phone"></div></div>' +
'<div><label for="email">E-mail</label><div id="email"></div></div>' +
'<div><label for="qty">Quantity</label><div id="qty"></div></div>' +
'<div><label for="price">Price</label><div id="price"></div></div>';
const output = document.createElement('pre');
output.style.cssText = 'margin: 12px 0 0; min-height: 3em; font: 12px/1.5 ui-monospace, Consolas, monospace; white-space: pre-wrap';
document.getElementById('app').after(output);
const phone = VibeFoxJSUi.createInput('#phone', { mask: '+9 (999) 999-99-99', placeholder: '+1 (555) 123-45-67' });
const email = VibeFoxJSUi.createInput('#email', { type: 'email', clearable: true, value: '[email protected]', prefix: '@' });
const qty = VibeFoxJSUi.createNumberInput('#qty', { value: 1, min: 1, max: 99, step: 1 });
const price = VibeFoxJSUi.createNumberInput('#price', { value: 9.5, min: 0, step: 0.5, precision: 2 });
for (const field of [phone, email, qty, price]) field.on('valueChange', () => {
output.textContent = 'phone ' + phone.getValue() + ', e-mail ' + email.getValue() + ', quantity ' + qty.getValue() + ', price ' + price.getValue();
});Select
खोज, समूह और टैग (पहले दो टैग, फिर "+N") वाला मल्टिपल सेलेक्ट, और एक साधारण सिंगल सेलेक्ट। सूचियाँ खोलें और फ़िल्टर करने के लिए टाइप करें।
const app = document.getElementById('app');
app.style.cssText = 'display: grid; gap: 14px; max-width: 420px';
app.innerHTML =
'<div><label for="tags">Languages</label><div id="tags"></div></div>' +
'<div><label for="size">Size</label><div id="size"></div></div>';
const tags = VibeFoxJSUi.createSelect('#tags', {
multiple: true, searchable: true, clearable: true, maxTagCount: 2,
options: [
{ value: 'js', label: 'JavaScript', group: 'Web' }, { value: 'ts', label: 'TypeScript', group: 'Web' }, { value: 'css', label: 'CSS', group: 'Web' },
{ value: 'go', label: 'Go', group: 'Server' }, { value: 'rust', label: 'Rust', group: 'Server' }, { value: 'cobol', label: 'COBOL', group: 'Server', disabled: true },
],
});
tags.setValue(['js', 'go', 'rust']);
VibeFoxJSUi.createSelect('#size', { placeholder: 'Pick a size',
options: [{ value: 's', label: 'Small' }, { value: 'm', label: 'Medium' }, { value: 'l', label: 'Large' }] });AutoComplete
पहला फ़ील्ड एसिंक्रोनस स्रोत से सुझाव लोड करता है (आपके सर्वर की जगह लेने वाला नमूना, देरी के साथ); दूसरा एक स्थिर सूची को फ़ज़ी तरीके से फ़िल्टर करता है और कई मान चिप्स में रखता है। City में "ber" या "pa", Fruits में "apl" टाइप करें।
const app = document.getElementById('app');
app.style.cssText = 'display: grid; gap: 14px; max-width: 420px';
app.innerHTML =
'<div><label for="city">City</label><div id="city"></div></div>' +
'<div><label for="fruit">Fruits</label><div id="fruit"></div></div>';
const CITIES = ['Amsterdam', 'Athens', 'Barcelona', 'Berlin', 'Bern', 'Bratislava', 'Brussels', 'Budapest', 'Lisbon', 'London', 'Madrid', 'Oslo', 'Paris', 'Prague', 'Rome', 'Vienna', 'Warsaw'];
// stand-in for fetch('/api/cities?q=…'): answers after 300 ms
const source = async (query, { signal }) => {
await new Promise((resolve) => setTimeout(resolve, 300));
if (signal.aborted) return [];
return CITIES.filter((name) => name.toLowerCase().includes(query.toLowerCase())).map((name, id) => ({ id, name }));
};
VibeFoxJSUi.createAutoComplete('#city', { source, minLength: 2, delay: 200, textField: 'name', keyField: 'id', placeholder: 'Type 2 letters' });
VibeFoxJSUi.createAutoComplete('#fruit', { data: ['Apple', 'Apricot', 'Banana', 'Cherry', 'Grape', 'Mango', 'Pineapple'], filter: 'fuzzy', multiple: true });Checkbox, Switch, RadioGroup, Segmented
चालू/बंद और कई में से एक चुनने वाले कंट्रोल; नीचे की पंक्ति उनके मान दिखाती है। उन पर क्लिक करें या Space और तीर कुंजियों का उपयोग करें।
const app = document.getElementById('app');
app.style.cssText = 'display: grid; gap: 12px; justify-items: start';
app.innerHTML =
'<div id="agree"></div>' +
'<div id="mixed"></div>' +
'<div id="notify"></div>' +
'<div id="plan"></div>' +
'<div id="view"></div>';
const output = document.createElement('pre');
output.style.cssText = 'margin: 12px 0 0; min-height: 3em; font: 12px/1.5 ui-monospace, Consolas, monospace; white-space: pre-wrap';
document.getElementById('app').after(output);
const agree = VibeFoxJSUi.createCheckbox('#agree', { label: 'I agree' });
const mixed = VibeFoxJSUi.createCheckbox('#mixed', { label: 'Some items selected', indeterminate: true });
const notify = VibeFoxJSUi.createSwitch('#notify', { label: 'Notifications', checked: true });
const plan = VibeFoxJSUi.createRadioGroup('#plan', { label: 'Plan', inline: true, value: 'm',
options: [{ value: 'm', label: 'Monthly' }, { value: 'y', label: 'Yearly' }, { value: 'l', label: 'Lifetime', disabled: true }] });
const view = VibeFoxJSUi.createSegmented('#view', { label: 'View', value: 'list',
items: [{ value: 'list', label: 'List', icon: 'list' }, { value: 'grid', label: 'Grid', icon: 'grid' }, { value: 'board', label: 'Board' }] });
const show = () => { output.textContent = 'agree ' + agree.getChecked() + ', notifications ' + notify.getChecked() + ', plan ' + plan.getValue() + ', view ' + view.getValue(); };
for (const control of [agree, mixed, notify, plan, view]) control.on('valueChange', show);
show();Slider and Rating
दो थंब और टूलटिप वाला रेंज स्लाइडर, एक सिंगल स्लाइडर, और आधे स्टार व लेबल वाली रेटिंग। थंब खींचें, स्टार पर होवर करें।
const app = document.getElementById('app');
app.style.cssText = 'display: grid; gap: 14px; max-width: 420px';
app.innerHTML =
'<div><label for="price">Price</label><div id="price"></div></div>' +
'<div><label for="volume">Volume</label><div id="volume"></div></div>' +
'<div><label for="stars">Rating</label><div id="stars"></div></div>' +
'<div><label for="hearts">Likes</label><div id="hearts"></div></div>';
const output = document.createElement('pre');
output.style.cssText = 'margin: 12px 0 0; min-height: 3em; font: 12px/1.5 ui-monospace, Consolas, monospace; white-space: pre-wrap';
document.getElementById('app').after(output);
const price = VibeFoxJSUi.createSlider('#price', { min: 0, max: 500, step: 10, value: [50, 300], tooltip: true });
const volume = VibeFoxJSUi.createSlider('#volume', { min: 0, max: 100, value: 60 });
const stars = VibeFoxJSUi.createRating('#stars', { value: 3.5, max: 5, step: 0.5, labels: ['Bad', 'Poor', 'OK', 'Good', 'Great'] });
VibeFoxJSUi.createRating('#hearts', { value: 2, max: 5, icon: 'heart' });
const show = () => { output.textContent = 'price ' + price.getValue().join(' – ') + ', volume ' + volume.getValue() + ', rating ' + stars.getValue(); };
for (const control of [price, volume, stars]) control.on('valueChange', show);
show();OTP input
तीन-तीन अंकों के दो समूहों में एक बार का कोड (वन-टाइम कोड)। 6-अंकों का कोड टाइप करें या पेस्ट करें: जब हर सेल भर जाती है, तब complete ट्रिगर होता है।
const output = document.createElement('pre');
output.style.cssText = 'margin: 12px 0 0; min-height: 3em; font: 12px/1.5 ui-monospace, Consolas, monospace; white-space: pre-wrap';
document.getElementById('app').after(output);
const code = VibeFoxJSUi.createOTPInput('#app', { label: 'Confirmation code', length: 6, type: 'numeric', groups: [3, 3] });
code.on('valueChange', (e) => { output.textContent = 'value ' + e.value; });
code.on('complete', (e) => { output.textContent = 'complete: ' + e.value; });नेटिव फ़ॉर्म में फ़ॉर्म फ़ील्ड
सादे <form> के अंदर VibeFox JS कंट्रोल: खाली आवश्यक फ़ील्ड के साथ Submit उनके संदेश दिखाता है और पहले फ़ील्ड पर फ़ोकस करता है; मान्य फ़ॉर्म नीचे अपना FormData दिखाता है। Reset प्रारंभिक मान बहाल करता है।
const output = document.createElement('pre');
output.style.cssText = 'margin: 12px 0 0; min-height: 3em; font: 12px/1.5 ui-monospace, Consolas, monospace; white-space: pre-wrap';
document.getElementById('app').after(output);
document.getElementById('app').innerHTML =
'<form id="order" style="display: grid; gap: 12px; max-width: 420px">' +
'<div><label for="name">Name</label><div id="name"></div></div>' +
'<div><label for="qty">Quantity</label><div id="qty"></div></div>' +
'<div><label for="country">Country</label><div id="country"></div></div>' +
'<div><label for="day">Delivery date</label><div id="day"></div></div>' +
'<div id="gift"></div>' +
'<div><label for="score">Your rating</label><div id="score"></div></div>' +
'<div id="buttons" style="display: flex; gap: 8px"></div>' +
'</form>';
const form = document.getElementById('order');
VibeFoxJSUi.createInput('#name', { name: 'name', required: true });
VibeFoxJSUi.createNumberInput('#qty', { name: 'qty', value: 2, min: 1 });
VibeFoxJSUi.createSelect('#country', { name: 'country', required: true,
options: [{ value: 'de', label: 'Germany' }, { value: 'fr', label: 'France' }] });
VibeFoxJSUi.createDatePicker('#day', { name: 'day', required: true });
VibeFoxJSUi.createCheckbox('#gift', { label: 'Gift wrap', name: 'gift', checked: true });
VibeFoxJSUi.createRating('#score', { name: 'score', required: true });
const buttons = document.getElementById('buttons');
VibeFoxJSUi.createButton(buttons.appendChild(document.createElement('span')), { label: 'Submit', on: { click: () => form.requestSubmit() } });
VibeFoxJSUi.createButton(buttons.appendChild(document.createElement('span')), { label: 'Reset', variant: 'secondary', on: { click: () => { form.reset(); output.textContent = 'reset'; } } });
form.addEventListener('submit', (e) => {
e.preventDefault(); // the demo shows the data instead of sending it
output.textContent = 'FormData:\n' + [...new FormData(form)].map(([key, value]) => key + ' = ' + value).join('\n');
});
form.addEventListener('invalid', () => { output.textContent = 'not sent: fill in the required fields'; }, true);तारीख, समय और रंग पिकर
तारीख की रेंज, तारीख के साथ समय, 30 मिनट के चरणों वाला समय और पारदर्शिता वाला रंग। हर पिकर खोलें; कैलेंडर तीर कुंजियों और PageUp / PageDown के साथ काम करते हैं।
const app = document.getElementById('app');
app.style.cssText = 'display: grid; gap: 14px; max-width: 420px';
app.innerHTML =
'<div><label for="stay">Stay</label><div id="stay"></div></div>' +
'<div><label for="meet">Meeting</label><div id="meet"></div></div>' +
'<div><label for="start">Start</label><div id="start"></div></div>' +
'<div><label for="color">Brand color</label><div id="color"></div></div>';
const output = document.createElement('pre');
output.style.cssText = 'margin: 12px 0 0; min-height: 3em; font: 12px/1.5 ui-monospace, Consolas, monospace; white-space: pre-wrap';
document.getElementById('app').after(output);
const stay = VibeFoxJSUi.createDatePicker('#stay', { range: true, format: 'DD.MM.YYYY', firstDay: 1 });
stay.setValue(['2026-07-01', '2026-07-14']);
const meet = VibeFoxJSUi.createDateTimePicker('#meet', { step: 15, hour12: false, value: '2026-11-03T10:30' });
const start = VibeFoxJSUi.createTimePicker('#start', { min: '08:00', max: '18:00', step: 30, value: '09:00' });
const color = VibeFoxJSUi.createColorPicker('#color', { value: '#2563eb', format: 'hex', alpha: true });
const show = () => { output.textContent = 'state of stay ' + JSON.stringify(stay.getState()) + '\nstate of meeting ' + JSON.stringify(meet.getState()) + '\nstart ' + start.getValue() + ', color ' + color.getValue(); };
for (const picker of [stay, meet, start, color]) picker.on('valueChange', show);
show();सूचियाँ और ट्री
ListView and ListBox
चेक बॉक्स वाला लिस्ट बॉक्स (एक आइटम निष्क्रिय) और एक सूची जिसका क्रम बदला जा सकता है: कोई आइटम खींचें, Alt+ArrowUp / ArrowDown दबाएँ, या आइटम का Move हैंडल खोलें, जिसमें मूव मेनू है।
const app = document.getElementById('app');
app.style.cssText = 'display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px';
app.innerHTML =
'<div><label for="people">Assignees</label><div id="people"></div></div>' +
'<div><label for="tasks">Priorities</label><div id="tasks"></div></div>';
const output = document.createElement('pre');
output.style.cssText = 'margin: 12px 0 0; min-height: 3em; font: 12px/1.5 ui-monospace, Consolas, monospace; white-space: pre-wrap';
document.getElementById('app').after(output);
const people = VibeFoxJSUi.createListBox('#people', {
selection: 'multiple', checkboxes: true, keyField: 'id', textField: 'name', height: 200,
data: [{ id: 1, name: 'Ann' }, { id: 2, name: 'Bob' }, { id: 3, name: 'Cleo', off: true }, { id: 4, name: 'Dan' }, { id: 5, name: 'Eve' }],
disabledField: 'off',
});
people.setValue([1, 2]);
const tasks = VibeFoxJSUi.createListView('#tasks', { draggable: true, height: 200,
data: ['Write docs', 'Fix login', 'Review PR', 'Release 1.2', 'Plan sprint'] });
people.on('valueChange', (e) => { output.textContent = 'assignees ' + JSON.stringify(e.value); });
tasks.on('itemMove', (e) => { output.textContent = 'moved ' + e.from + ' → ' + e.to + (e.reason ? ' (' + e.reason + ')' : ''); });TransferList
दिखाए जाने वाले कॉलम चुनें: बटनों, डबल क्लिक या ड्रैग से सूचियों के बीच आइटम ले जाएँ, चुने हुए आइटमों का क्रम बदलें; अधिकतम चार चुने जा सकते हैं।
const output = document.createElement('pre');
output.style.cssText = 'margin: 12px 0 0; min-height: 3em; font: 12px/1.5 ui-monospace, Consolas, monospace; white-space: pre-wrap';
document.getElementById('app').after(output);
const columns = VibeFoxJSUi.createTransferList('#app', { titles: ['Available', 'Shown'], reorder: true, draggable: true, search: true, max: 4, height: 200,
data: ['Name', 'Email', 'Phone', 'City', 'Company', 'Country', 'Created'], value: ['Name', 'Email'] });
columns.on('valueChange', (e) => { output.textContent = 'shown: ' + e.value.join(', '); });
columns.transfer('City', 'target');Tree
ट्री जिसमें ट्राई-स्टेट चेक बॉक्स, खोज और लेज़ी चाइल्ड हैं (फ़ोल्डर lib थोड़ी देर बाद अपनी फ़ाइलें लोड करता है, जैसे सर्वर से)। lib खोलें, आइटम चेक करें, खोज बॉक्स में टाइप करें।
const output = document.createElement('pre');
output.style.cssText = 'margin: 12px 0 0; min-height: 3em; font: 12px/1.5 ui-monospace, Consolas, monospace; white-space: pre-wrap';
document.getElementById('app').after(output);
const tree = VibeFoxJSUi.createTree('#app', {
label: 'Folders', checkboxes: true, search: true,
data: [
{ id: 'src', label: 'src', expanded: true, children: [
{ id: 'app', label: 'app.js' },
{ id: 'lib', label: 'lib', lazy: true },
{ id: 'css', label: 'styles', children: [{ id: 'main', label: 'main.css' }, { id: 'print', label: 'print.css' }] },
] },
{ id: 'docs', label: 'docs', children: [{ id: 'readme', label: 'README.md' }] },
],
// stand-in for a server request: the children of a lazy node
load: async (node) => {
await new Promise((resolve) => setTimeout(resolve, 400));
return [{ id: node.id + '/util', label: 'util.js' }, { id: node.id + '/dom', label: 'dom.js' }];
},
});
tree.setChecked('app', true);
tree.on('checkChange', () => { output.textContent = 'checked: ' + tree.getChecked().join(', '); });फ़ॉर्म और फ़ाइल अपलोड
Form
नियमों वाले फ़ील्ड विवरण से बना फ़ॉर्म। खाली फ़ील्ड के साथ Register पर क्लिक करें, त्रुटियाँ देखने के लिए; मान्य फ़ॉर्म नीचे अपना मान और अपने फ़ॉर्म एलिमेंट का FormData दिखाता है।
const output = document.createElement('pre');
output.style.cssText = 'margin: 12px 0 0; min-height: 3em; font: 12px/1.5 ui-monospace, Consolas, monospace; white-space: pre-wrap';
document.getElementById('app').after(output);
const form = VibeFoxJSUi.createForm('#app', {
fields: [
{ name: 'email', label: 'Email', type: 'input', props: { type: 'email' }, rules: [{ required: true }, { pattern: '^[^@]+@[^@]+$', message: 'Not an email' }] },
{ name: 'age', label: 'Age', type: 'number', rules: [{ required: true }, { min: 18, message: 'Adults only' }] },
{ name: 'plan', label: 'Plan', type: 'segmented', props: { items: ['Free', 'Pro', 'Team'] } },
{ name: 'start', label: 'Start date', type: 'date' },
{ name: 'terms', label: 'I accept the terms', type: 'checkbox', rules: [{ required: true, message: 'Please accept the terms' }] },
],
value: { plan: 'Free' }, layout: 'horizontal', validateOn: 'change', submitLabel: 'Register', resetLabel: 'Reset',
});
form.on('submit', (e) => {
const data = new FormData(document.querySelector('#app form'));
output.textContent = 'value: ' + JSON.stringify(e.value) + '\nFormData: ' + [...data].map(([key, value]) => key + '=' + value).join(', ');
});
form.on('validate', (e) => { if (!e.valid) output.textContent = 'fix the errors above'; });FileUpload
प्रोग्रेस, रद्द करने और दोबारा कोशिश के साथ चंक्स में अपलोड। यहाँ ट्रांसपोर्ट आपके सर्वर की जगह लेने वाला नमूना है (कुछ भी पेज से बाहर नहीं जाता): फ़ाइलें बॉक्स पर ड्रॉप करें, या Add sample files पर क्लिक करें (तीसरी फ़ाइल बहुत बड़ी है और अस्वीकार हो जाती है)।
function addButtons(buttons) {
const bar = document.createElement('div');
bar.id = 'bar';
bar.style.cssText = 'display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px';
for (const [label, click, variant] of buttons) {
VibeFoxJSUi.createButton(bar.appendChild(document.createElement('span')), { label, variant: variant || 'secondary', on: { click } });
}
document.getElementById('app').before(bar);
}
const output = document.createElement('pre');
output.style.cssText = 'margin: 12px 0 0; min-height: 3em; font: 12px/1.5 ui-monospace, Consolas, monospace; white-space: pre-wrap';
document.getElementById('app').after(output);
// stand-in for your server: "uploads" each chunk in about a second and reports the progress
const fakeServer = async (ctx) => {
for (let step = 1; step <= 10; step++) {
await new Promise((resolve) => setTimeout(resolve, 100));
if (ctx.signal.aborted) throw new Error('aborted');
ctx.onProgress(ctx.chunk.size * step / 10);
}
return { id: ctx.uploadId, chunk: ctx.index + 1 + '/' + ctx.count };
};
const files = VibeFoxJSUi.createFileUpload('#app', {
transport: fakeServer, chunkSize: 256 * 1024, retries: 2, concurrency: 2,
multiple: true, maxFileSize: 1e6, maxFiles: 5, accept: '.txt,.csv,image/*', autoUpload: true, label: 'Attachments',
});
const sample = (name, size) => new File(['x'.repeat(size)], name, { type: 'text/plain' });
addButtons([['Add sample files', () => files.addFiles([sample('report.txt', 600000), sample('notes.txt', 40000), sample('video-dump.txt', 1500000)])]]);
files.on('uploadComplete', (e) => { output.textContent += e.file.name + ' uploaded ' + JSON.stringify(e.response) + '\n'; });
files.on('fileReject', (e) => { output.textContent += e.file.name + ' rejected: ' + e.message + '\n'; });नेविगेशन
Tabs and Accordion
बंद किए जा सकने वाले टैब, जिनका क्रम बदला जा सकता है (कोई टैब खींचें या उसका मूव हैंडल इस्तेमाल करें), और एक एकॉर्डियन, जिसमें कई सेक्शन एक साथ खुले रह सकते हैं। टैब को उसके क्रॉस से या Delete कुंजी से बंद करें।
const app = document.getElementById('app');
app.style.cssText = 'display: grid; gap: 20px';
app.innerHTML =
'<div id="tabs"></div>' +
'<div id="faq"></div>';
const tabs = VibeFoxJSUi.createTabs('#tabs', { label: 'Document', closable: true, reorder: true,
tabs: [
{ id: 'a', label: 'Overview', content: '<p>Text of the overview.</p>' },
{ id: 'b', label: 'Details', content: (host) => { host.textContent = 'Rendered by a function.'; } },
{ id: 'd', label: 'Locked', content: 'Not available', disabled: true, closable: false },
] });
tabs.addTab({ id: 'c', label: 'History', content: 'Change log' }, { activate: true });
const faq = VibeFoxJSUi.createAccordion('#faq', { multiple: true, headingLevel: 3,
items: [
{ id: 'q1', title: 'How long is the shipping?', content: '3–5 working days.' },
{ id: 'q2', title: 'Can I return an item?', content: 'Yes, within 30 days.' },
{ id: 'q3', title: 'Do you ship abroad?', content: 'To every EU country.' },
] });
faq.expand('q1');Menu and Toolbar
ड्रॉपडाउन मेनू जिसमें एक चेक आइटम, डिवाइडर और सबमेनू है; वही मेनू धूसर बॉक्स के कॉन्टेक्स्ट मेनू के रूप में भी है (राइट क्लिक या Shift+F10), और टॉगल बटनों वाला टूलबार। नीचे की पंक्ति क्लिक दिखाती है।
const app = document.getElementById('app');
app.style.cssText = 'display: grid; gap: 12px; justify-items: start';
app.innerHTML =
'<div id="tools"></div>' +
'<div id="open"></div>' +
'<div id="area"></div>';
const output = document.createElement('pre');
output.style.cssText = 'margin: 12px 0 0; min-height: 3em; font: 12px/1.5 ui-monospace, Consolas, monospace; white-space: pre-wrap';
document.getElementById('app').after(output);
document.getElementById('area').style.cssText = 'width: 260px; padding: 24px; background: #f1f5f9; border-radius: 6px; text-align: center';
document.getElementById('area').textContent = 'Right-click here';
document.getElementById('area').tabIndex = 0;
const menu = VibeFoxJSUi.createMenu(document.body, { label: 'Actions', items: [
{ id: 'copy', label: 'Copy', shortcut: 'Ctrl+C', icon: 'copy' },
{ id: 'cut', label: 'Cut', shortcut: 'Ctrl+X', icon: 'scissors' },
{ id: 'wrap', label: 'Word wrap', checked: true },
{ divider: true },
{ id: 'export', label: 'Export', children: [{ id: 'pdf', label: 'PDF' }, { id: 'csv', label: 'CSV' }] },
{ id: 'delete', label: 'Delete', icon: 'trash', disabled: true },
] });
VibeFoxJSUi.createButton('#open', { label: 'Actions', iconRight: 'chevron-down', variant: 'outline' });
menu.attachTrigger('#open button');
menu.attachContext('#area');
menu.on('itemClick', (e) => { output.textContent = 'menu: ' + e.path.join(' › '); });
const bar = VibeFoxJSUi.createToolbar('#tools', { label: 'Formatting', items: [
{ type: 'toggle', id: 'bold', icon: 'bold', label: 'Bold' },
{ type: 'toggle', id: 'italic', icon: 'italic', label: 'Italic' },
{ type: 'separator' },
{ type: 'button', id: 'undo', icon: 'undo', tooltip: 'Undo' },
{ type: 'button', id: 'redo', icon: 'redo', tooltip: 'Redo' },
{ type: 'spacer' },
{ type: 'custom', render: (host) => { host.textContent = 'Saved'; } },
] });
bar.on('toggleChange', (e) => { output.textContent = 'toolbar: ' + e.id + ' ' + (e.pressed ? 'on' : 'off'); });
bar.on('itemClick', (e) => { output.textContent = 'toolbar: ' + e.id; });Breadcrumb and Pagination
ब्रेडक्रम्ब जो बहुत सारे आइटम होने पर बीच के आइटम समेट देता है, और पेजिनेशन जिसमें पेज का आकार और कुल संख्या है। पेज पर क्लिक करें और पेज का आकार बदलें।
const app = document.getElementById('app');
app.style.cssText = 'display: grid; gap: 20px';
app.innerHTML =
'<div id="path"></div>' +
'<div id="pages"></div>';
const output = document.createElement('pre');
output.style.cssText = 'margin: 12px 0 0; min-height: 3em; font: 12px/1.5 ui-monospace, Consolas, monospace; white-space: pre-wrap';
document.getElementById('app').after(output);
VibeFoxJSUi.createBreadcrumb('#path', { maxItems: 4, items: [
{ id: 'home', label: 'Home', href: '#' }, { id: 'docs', label: 'Docs', href: '#' }, { id: 'lib', label: 'Libraries', href: '#' },
{ id: 'ui', label: 'VibeFox JS UI', href: '#' }, { id: 'nav', label: 'Navigation' },
] });
const pages = VibeFoxJSUi.createPagination('#pages', { total: 240, pageSize: 20, page: 3, pageSizes: [10, 20, 50], showTotal: true });
pages.on('pageChange', (e) => { output.textContent = 'page ' + e.page + ', ' + e.pageSize + ' per page'; });Stepper and Wizard
एक विज़ार्ड जिसका पहला चरण आगे बढ़ने से पहले अपना फ़ील्ड जाँचता है: खाली नाम के साथ Next पर क्लिक करें और त्रुटि देखें। दूसरा चरण वैकल्पिक है; Finish परिणाम दिखाता है।
const output = document.createElement('pre');
output.style.cssText = 'margin: 12px 0 0; min-height: 3em; font: 12px/1.5 ui-monospace, Consolas, monospace; white-space: pre-wrap';
document.getElementById('app').after(output);
const name = document.createElement('div');
const wizard = VibeFoxJSUi.createWizard('#app', { linear: true, steps: [
{ id: 'account', title: 'Account', description: 'Your name', content: name, validate: () => nameInput.getValue().trim() !== '' || 'Enter your name' },
{ id: 'address', title: 'Address', optional: true, content: '<p>The address can be added later.</p>' },
{ id: 'done', title: 'Confirm', content: (host) => { host.textContent = 'Check and click Finish.'; } },
] });
const nameInput = VibeFoxJSUi.createInput(name, { label: 'Name', placeholder: 'Your name' });
wizard.on('stepChange', (e) => { output.textContent = 'step: ' + wizard.getActive(); });
wizard.on('finish', () => { output.textContent = 'finished for ' + nameInput.getValue(); });CommandPalette
कमांड की खोजने योग्य सूची। Open palette पर क्लिक करें (या उदाहरण के भीतर Ctrl+K / Cmd+K दबाएँ), "dark" या "new" टाइप करें और Enter दबाएँ; हाल के कमांड सबसे पहले आते हैं।
function addButtons(buttons) {
const bar = document.createElement('div');
bar.id = 'bar';
bar.style.cssText = 'display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px';
for (const [label, click, variant] of buttons) {
VibeFoxJSUi.createButton(bar.appendChild(document.createElement('span')), { label, variant: variant || 'secondary', on: { click } });
}
document.getElementById('app').before(bar);
}
const output = document.createElement('pre');
output.style.cssText = 'margin: 12px 0 0; min-height: 3em; font: 12px/1.5 ui-monospace, Consolas, monospace; white-space: pre-wrap';
document.getElementById('app').after(output);
const palette = VibeFoxJSUi.createCommandPalette(document.body, { hotkey: 'mod+k', commands: [
{ id: 'new', title: 'New document', category: 'File', shortcut: 'Ctrl+N', icon: 'file', handler: () => { output.textContent = 'new document'; } },
{ id: 'open', title: 'Open…', category: 'File', shortcut: 'Ctrl+O', icon: 'folder', handler: () => { output.textContent = 'open'; } },
{ id: 'dark', title: 'Dark theme', category: 'View', keywords: ['night', 'theme'], handler: () => VibeFoxJSUi.setTheme('dark') },
{ id: 'light', title: 'Light theme', category: 'View', keywords: ['day', 'theme'], handler: () => VibeFoxJSUi.setTheme('light') },
{ id: 'find', title: 'Find in files', category: 'Edit', shortcut: 'Ctrl+Shift+F', icon: 'search', handler: () => { output.textContent = 'find'; } },
] });
palette.on('commandRun', (e) => { output.textContent = 'run: ' + e.command.id; });
addButtons([['Open palette', () => palette.open(), 'primary']]);डायलॉग और ओवरले
Dialog
बटनों वाला मोडल डायलॉग, और गैर-मोडल विंडो: दो खोलें, हेडर से खींचें, कोनों से आकार बदलें, अधिकतम या न्यूनतम करें; विंडो मेनू बटन उन्हें बिना खींचे भी ले जाता है।
function addButtons(buttons) {
const bar = document.createElement('div');
bar.id = 'bar';
bar.style.cssText = 'display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px';
for (const [label, click, variant] of buttons) {
VibeFoxJSUi.createButton(bar.appendChild(document.createElement('span')), { label, variant: variant || 'secondary', on: { click } });
}
document.getElementById('app').before(bar);
}
const output = document.createElement('pre');
output.style.cssText = 'margin: 12px 0 0; min-height: 3em; font: 12px/1.5 ui-monospace, Consolas, monospace; white-space: pre-wrap';
document.getElementById('app').after(output);
let count = 0;
addButtons([
['Delete file…', () => {
const dlg = VibeFoxJSUi.createDialog(document.body, {
title: 'Delete file?', content: '<p>report.pdf will be deleted. This cannot be undone.</p>', width: 340,
buttons: [{ id: 'cancel', label: 'Cancel', variant: 'secondary' }, { id: 'ok', label: 'Delete', variant: 'danger' }],
});
dlg.on('buttonClick', (e) => { output.textContent = 'clicked ' + e.id; dlg.close(); });
}, 'danger'],
['Open window', () => {
count++;
VibeFoxJSUi.createDialog(document.body, { title: 'Properties ' + count, modal: false, resizable: true, maximizable: true, minimizable: true,
width: 280, height: 160, x: 20 + count * 30, y: 50 + count * 20, content: '<p>Window ' + count + '. Drag me by the header.</p>' });
}],
]);Drawer
एक पैनल जो किनारे से सरककर आता है। इसे बाएँ, दाएँ या नीचे से खोलें; Esc या बैकड्रॉप पर क्लिक इसे बंद करता है।
function addButtons(buttons) {
const bar = document.createElement('div');
bar.id = 'bar';
bar.style.cssText = 'display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px';
for (const [label, click, variant] of buttons) {
VibeFoxJSUi.createButton(bar.appendChild(document.createElement('span')), { label, variant: variant || 'secondary', on: { click } });
}
document.getElementById('app').before(bar);
}
const drawers = {};
for (const side of ['left', 'right', 'bottom']) {
drawers[side] = VibeFoxJSUi.createDrawer(document.body, { side, size: side === 'bottom' ? 160 : 's', title: 'Filters (' + side + ')',
content: '<p>Filter controls go here.</p>', openOnInit: false });
}
addButtons([['Left', () => drawers.left.open()], ['Right', () => drawers.right.open()], ['Bottom', () => drawers.bottom.open()]]);Toast
कोने में सूचनाएँ: चार प्रकार, जिनमें से एक एक्शन वाला है जो इस्तेमाल होने तक रहता है, और एक ऐसा जो प्रॉमिस को ट्रैक करता है (लोडिंग, फिर पूरा)। अधिकतम तीन दिखाई जाती हैं, बाकी इंतज़ार करती हैं।
function addButtons(buttons) {
const bar = document.createElement('div');
bar.id = 'bar';
bar.style.cssText = 'display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px';
for (const [label, click, variant] of buttons) {
VibeFoxJSUi.createButton(bar.appendChild(document.createElement('span')), { label, variant: variant || 'secondary', on: { click } });
}
document.getElementById('app').before(bar);
}
const output = document.createElement('pre');
output.style.cssText = 'margin: 12px 0 0; min-height: 3em; font: 12px/1.5 ui-monospace, Consolas, monospace; white-space: pre-wrap';
document.getElementById('app').after(output);
const toast = VibeFoxJSUi.createToast(document.body, { position: 'bottom-right', duration: 4000, max: 3 });
toast.on('actionClick', (e) => { output.textContent = 'action ' + e.action; toast.hide(e.id); });
addButtons([
['Info', () => toast.info('A new version is available')],
['Success', () => toast.success('Saved')],
['Warning', () => toast.warning('The disk is almost full')],
['Error', () => toast.error('Could not connect')],
['With action', () => toast.show({ type: 'warning', title: 'Offline', message: 'Changes are kept locally.', duration: 0, actions: [{ id: 'retry', label: 'Retry' }] })],
['Promise', () => toast.promise(new Promise((resolve) => setTimeout(resolve, 1500)), { loading: 'Uploading…', success: 'Uploaded', error: 'Upload failed' })],
]);Tooltip and Popover
टूलटिप होवर और कीबोर्ड फ़ोकस पर दिखता है; शीर्षक और समृद्ध कंटेंट वाला पॉपओवर क्लिक पर खुलता है। Help पर होवर करें या टैब से वहाँ जाएँ, फिर Order 42 पर क्लिक करें।
const app = document.getElementById('app');
app.style.cssText = 'display: flex; gap: 12px';
app.innerHTML = '<span id="help"></span><span id="order"></span>';
VibeFoxJSUi.createButton('#help', { label: 'Help', variant: 'outline' });
const tip = VibeFoxJSUi.createTooltip('#help button', { content: 'Opens the manual', placement: 'bottom' });
VibeFoxJSUi.createButton('#order', { label: 'Order 42', variant: 'secondary' });
const pop = VibeFoxJSUi.createPopover('#order button', { title: 'Order 42', placement: 'bottom',
content: '<p>3 items, 120 EUR</p><p>Delivery on Monday</p>' });Tour
ऑनबोर्डिंग टूर: हर लक्ष्य पर स्पॉटलाइट और चरण कार्ड। Start tour पर क्लिक करें और Next या तीर कुंजियों से चरणों में आगे बढ़ें।
function addButtons(buttons) {
const bar = document.createElement('div');
bar.id = 'bar';
bar.style.cssText = 'display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px';
for (const [label, click, variant] of buttons) {
VibeFoxJSUi.createButton(bar.appendChild(document.createElement('span')), { label, variant: variant || 'secondary', on: { click } });
}
document.getElementById('app').before(bar);
}
const app = document.getElementById('app');
app.style.cssText = 'display: flex; gap: 8px';
app.innerHTML = '<span id="new"></span><span id="share"></span><span id="export"></span>';
VibeFoxJSUi.createButton('#new', { label: 'New', icon: 'plus' });
VibeFoxJSUi.createButton('#share', { label: 'Share', variant: 'secondary' });
VibeFoxJSUi.createButton('#export', { label: 'Export', icon: 'download', variant: 'outline' });
const tour = VibeFoxJSUi.createTour(document.body, { steps: [
{ target: '#new', title: 'Create', content: 'Start a new document here.', placement: 'bottom' },
{ target: '#share', title: 'Share', content: 'Invite your team.', placement: 'bottom' },
{ target: '#export', title: 'Export', content: 'Download as PDF or Excel.', placement: 'bottom' },
] });
addButtons([['Start tour', () => tour.start(), 'primary']]);लेआउट
Splitter
खींचे जा सकने वाले विभाजकों वाले तीन पैन; पहला अपने विभाजक पर डबल क्लिक से समेटा जाता है। विभाजक पर क्लिक उसका मूव मेनू खोलता है, फ़ोकस किए गए विभाजक को तीर कुंजियाँ हिलाती हैं।
const output = document.createElement('pre');
output.style.cssText = 'margin: 12px 0 0; min-height: 3em; font: 12px/1.5 ui-monospace, Consolas, monospace; white-space: pre-wrap';
document.getElementById('app').after(output);
const box = (text) => '<div style="padding: 12px; height: 100%; box-sizing: border-box; background: #f8fafc">' + text + '</div>';
const app = document.getElementById('app');
app.style.height = '240px';
const split = VibeFoxJSUi.createSplitter('#app', { direction: 'horizontal', panes: [
{ content: box('Navigation'), size: 25, min: 100, collapsible: true },
{ content: box('Editor'), size: 50 },
{ content: box('Preview'), size: 25, min: 100 },
] });
split.on('paneResize', (e) => { output.textContent = 'sizes ' + e.sizes.map((s) => Math.round(s) + '%').join(' / '); });DockLayout
IDE की तरह ज़ोन में पैनल। किसी पैनल का टैब दूसरे ज़ोन में खींचें, या टैब का मूव हैंडल खोलें (या Alt+तीर दबाएँ), ताकि उसे बाएँ, ऊपर, केंद्र, नीचे या दाएँ डॉक करें।
const output = document.createElement('pre');
output.style.cssText = 'margin: 12px 0 0; min-height: 3em; font: 12px/1.5 ui-monospace, Consolas, monospace; white-space: pre-wrap';
document.getElementById('app').after(output);
const app = document.getElementById('app');
app.style.height = '360px';
const dock = VibeFoxJSUi.createDockLayout('#app', { zoneSizes: { left: 180, bottom: 110, right: 180 }, panels: [
{ id: 'files', title: 'Files', zone: 'left', content: '<ul><li>index.html</li><li>main.js</li><li>style.css</li></ul>' },
{ id: 'code', title: 'main.js', zone: 'center', content: '<pre>console.log("hello");</pre>', closable: true },
{ id: 'readme', title: 'README.md', zone: 'center', content: '<p>Read me</p>', closable: true },
{ id: 'log', title: 'Console', zone: 'bottom', content: 'Output' },
{ id: 'props', title: 'Properties', zone: 'right', content: 'Width 960' },
] });
dock.on('panelMove', (e) => { output.textContent = 'moved ' + e.id + ' to ' + e.zone; });TileLayout
डैशबोर्ड ग्रिड: टाइल को उसके हेडर से खींचें, कोने से आकार बदलें, या मूव मेनू (move, wider, narrower …) के लिए ग्रिप पर क्लिक करें। Ctrl+Z बदलाव वापस लेता है; संकरी चौड़ाई पर टाइलों के कॉलम कम हो जाते हैं।
const output = document.createElement('pre');
output.style.cssText = 'margin: 12px 0 0; min-height: 3em; font: 12px/1.5 ui-monospace, Consolas, monospace; white-space: pre-wrap';
document.getElementById('app').after(output);
const tiles = VibeFoxJSUi.createTileLayout('#app', {
columns: 12, breakpoints: { 0: 4, 600: 8, 900: 12 }, rowHeight: 60,
tiles: [
{ id: 'sales', title: 'Sales', x: 0, y: 0, w: 6, h: 3, content: 'Chart' },
{ id: 'kpi', title: 'KPI', x: 6, y: 0, w: 3, h: 2, minW: 2, content: '<b style="font-size: 28px">42</b>' },
{ id: 'news', title: 'News', x: 9, y: 0, w: 3, h: 4, collapsible: true, content: 'Text' },
{ id: 'tasks', title: 'Tasks', x: 6, y: 2, w: 3, h: 2, closable: true, content: '3 open' },
],
});
tiles.on('layoutChange', (e) => { output.textContent = e.reason + ': ' + e.layout.map((t) => t.id + ' ' + t.x + ',' + t.y + ' ' + t.w + '×' + t.h).join('; '); });डेटा दिखाना
Card
चित्र, शीर्षक, टेक्स्ट और एक्शन वाले कार्ड: एलिवेटेड, आउटलाइन वाला और लिंक वाला कार्ड। Book पर क्लिक करें।
const output = document.createElement('pre');
output.style.cssText = 'margin: 12px 0 0; min-height: 3em; font: 12px/1.5 ui-monospace, Consolas, monospace; white-space: pre-wrap';
document.getElementById('app').after(output);
const app = document.getElementById('app');
app.style.cssText = 'display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px';
// a picture made in the code (your image URL goes here)
const picture = (from, to) => 'data:image/svg+xml,' + encodeURIComponent('<svg xmlns="http://www.w3.org/2000/svg" width="320" height="160">' +
'<defs><linearGradient id="g" x2="1" y2="1"><stop offset="0" stop-color="' + from + '"/><stop offset="1" stop-color="' + to + '"/></linearGradient></defs>' +
'<rect width="320" height="160" fill="url(#g)"/><path d="M0 160 L110 60 L170 120 L230 70 L320 160Z" fill="#ffffff55"/></svg>');
const card = (options) => VibeFoxJSUi.createCard(app.appendChild(document.createElement('div')), options);
const lodge = card({ title: 'Mountain lodge', subtitle: 'From 120 EUR', media: picture('#0ea5e9', '#1e3a8a'), mediaAlt: 'Mountains',
content: '<p>Quiet place near the lake.</p>', variant: 'elevated', actions: [{ id: 'book', label: 'Book', variant: 'primary' }, { id: 'save', label: 'Save', variant: 'ghost' }] });
card({ title: 'City flat', subtitle: 'From 90 EUR', media: picture('#f97316', '#be123c'), mediaAlt: 'City', content: '<p>Five minutes to the old town.</p>', variant: 'outlined' });
card({ title: 'All offers', content: '<p>The whole card is a link.</p>', href: '#offers', footer: '24 places' });
lodge.on('action', (e) => { output.textContent = 'action ' + e.id; });Avatar, Chip, Badge
इनिशियल वाले अवतार, स्टेटस और "+2" समूह; फ़िल्टर चिप्स जिन्हें चुना और हटाया जा सकता है; बटन पर गिनती वाले और बिंदु के रूप में बैज।
const app = document.getElementById('app');
app.style.cssText = 'display: grid; gap: 16px; justify-items: start';
app.innerHTML =
'<div id="avatars"></div>' +
'<div id="group"></div>' +
'<div id="chips"></div>' +
'<div id="badges"></div>';
const output = document.createElement('pre');
output.style.cssText = 'margin: 12px 0 0; min-height: 3em; font: 12px/1.5 ui-monospace, Consolas, monospace; white-space: pre-wrap';
document.getElementById('app').after(output);
document.getElementById('avatars').style.cssText = 'display: flex; gap: 8px; align-items: center';
for (const [name, size, status] of [['Ann Lee', 'xs'], ['Bob Stone', 's', 'online'], ['Cleo Park', 'm', 'busy'], ['Dan Roe', 'l', 'away'], ['Eve', 'xl']]) {
VibeFoxJSUi.createAvatar(document.getElementById('avatars').appendChild(document.createElement('span')), { name, size, status });
}
VibeFoxJSUi.createAvatarGroup('#group', { max: 3, items: ['Ann Lee', 'Bob Stone', { name: 'Cleo', status: 'online' }, 'Dan', 'Eve'] });
const filters = VibeFoxJSUi.createChipGroup('#chips', { label: 'Filters', selection: 'multiple', removable: true,
items: ['Open', 'Urgent', { id: 'me', label: 'Mine', icon: 'user' }, 'This week'] });
filters.on('itemRemove', (e) => { output.textContent = 'removed ' + (e.item.label || e.item.id); });
filters.on('valueChange', (e) => { output.textContent = 'selected ' + JSON.stringify(e.value); });
const badges = document.getElementById('badges');
badges.style.cssText = 'display: flex; gap: 24px; align-items: center; padding-top: 8px';
badges.innerHTML = '<span id="inbox"></span><span id="chat"></span>';
VibeFoxJSUi.createButton('#inbox', { label: 'Inbox', variant: 'secondary' });
// the badges sit on the corner of the buttons (attached to their mount elements)
const inbox = VibeFoxJSUi.createBadge('#inbox', { count: 7, max: 99, type: 'error', attached: true });
VibeFoxJSUi.createButton('#chat', { label: 'Chat', variant: 'secondary' });
VibeFoxJSUi.createBadge('#chat', { dot: true, type: 'success', attached: true });
inbox.setCount(12);Progress, Spinner, Skeleton
एक प्रोग्रेस बार, स्पिनर और स्केलेटन प्लेसहोल्डर। Load पर क्लिक करें: बार भरता है, फिर स्केलेटन की जगह कंटेंट आता है।
function addButtons(buttons) {
const bar = document.createElement('div');
bar.id = 'bar';
bar.style.cssText = 'display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px';
for (const [label, click, variant] of buttons) {
VibeFoxJSUi.createButton(bar.appendChild(document.createElement('span')), { label, variant: variant || 'secondary', on: { click } });
}
document.getElementById('app').before(bar);
}
const app = document.getElementById('app');
app.style.cssText = 'display: grid; gap: 14px; max-width: 420px';
app.innerHTML =
'<div id="progress"></div>' +
'<div id="spinners"></div>' +
'<div id="skeleton"></div>';
document.getElementById('spinners').style.cssText = 'display: flex; gap: 24px; align-items: center';
const bar = VibeFoxJSUi.createProgressBar('#progress', { value: 30, max: 100, label: true, striped: true });
VibeFoxJSUi.createSpinner(document.getElementById('spinners').appendChild(document.createElement('span')), { size: 'l', label: 'Loading' });
VibeFoxJSUi.createSpinner(document.getElementById('spinners').appendChild(document.createElement('span')), { size: 'l', shape: 'dots', label: 'Loading orders…', showLabel: true });
const skeleton = VibeFoxJSUi.createSkeleton('#skeleton', { rows: 3, avatar: true, animated: true, widths: ['60%', '90%', '40%'] });
addButtons([['Load', () => {
let value = 0;
const timer = setInterval(() => {
value += 10;
bar.setValue(value);
if (value < 100) return;
clearInterval(timer);
skeleton.destroy();
document.getElementById('skeleton').innerHTML = '<b>Ann Lee</b><p>The content is loaded.</p>';
}, 150);
}, 'primary']]);Carousel
तीर, इंडिकेटर, स्वाइप और लूप वाले स्लाइड; चौड़ाई के अनुसार एक, दो या तीन स्लाइड एक साथ। तीर, बिंदु या तीर कुंजियों का उपयोग करें।
const colors = ['#0ea5e9', '#22c55e', '#f59e0b', '#ef4444', '#8b5cf6', '#14b8a6'];
const slides = VibeFoxJSUi.createCarousel('#app', { label: 'Products', loop: true, perView: { 0: 1, 600: 2, 900: 3 }, perMove: 1,
items: colors.map((color, i) => ({ content: '<div style="height: 140px; display: grid; place-items: center; border-radius: 8px; color: #fff; font: 600 22px system-ui; background: ' + color + '">Slide ' + (i + 1) + '</div>' })) });
slides.goTo(1);Kanban
WIP सीमा 2 वाला बोर्ड (In progress पर), लेबल, असाइनी, नियत तिथियाँ और प्रगति। कार्ड कॉलमों के बीच खींचें, या किसी कार्ड का छोटा मूव हैंडल खोलकर उसका "Move" मेनू देखें; खोज और त्वरित जोड़ का उपयोग करें, Ctrl+Z किसी मूव को वापस लेता है।
const output = document.createElement('pre');
output.style.cssText = 'margin: 12px 0 0; min-height: 3em; font: 12px/1.5 ui-monospace, Consolas, monospace; white-space: pre-wrap';
document.getElementById('app').after(output);
const board = VibeFoxJSUi.createKanban('#app', {
columns: [{ id: 'todo', title: 'To do' }, { id: 'doing', title: 'In progress', limit: 2 }, { id: 'done', title: 'Done' }],
cards: [
{ id: 1, column: 'todo', title: 'Write docs', labels: [{ text: 'docs', color: 'info' }], assignees: ['Ann Lee'], due: '2026-11-10' },
{ id: 2, column: 'todo', title: 'Design the logo', labels: ['design'], assignees: ['Cleo Park'] },
{ id: 3, column: 'doing', title: 'Fix login', labels: [{ text: 'bug', color: 'danger' }], progress: 40, assignees: ['Bob Stone'] },
{ id: 4, column: 'doing', title: 'Payment page', progress: 70, due: '2026-11-05' },
{ id: 5, column: 'done', title: 'Set up CI', labels: ['devops'] },
],
wipStrict: true, toolbar: true, quickAdd: true,
});
board.on('cardMove', (e) => { output.textContent = 'moved card ' + e.card.id + ' to ' + e.to.column + ' (' + e.reason + ')'; });
board.on('wipExceed', (e) => { output.textContent = 'the column ' + e.column + ' is full'; });चैट और AI प्रॉम्प्ट
Chat
Markdown, अवतार और रिएक्शन वाले संदेश, सुझाव और टाइपिंग इंडिकेटर। एक संदेश भेजें: दूसरी ओर की जगह लेने वाला नमूना "टाइप" करता है और जवाब देता है। जवाब देने, रिएक्शन देने और कॉपी करने के लिए किसी संदेश पर होवर करें।
const app = document.getElementById('app');
app.style.height = '420px';
const chat = VibeFoxJSUi.createChat('#app', {
user: { id: 'me', name: 'Me' },
users: [{ id: 'ann', name: 'Ann Lee', status: 'online' }],
messages: [
{ id: 1, author: 'ann', text: 'Hi! Did you see **the report**?', time: Date.now() - 3600000 },
{ id: 2, author: 'me', text: 'Not yet, sending it to the printer.', time: Date.now() - 3500000, reactions: { '👍': ['ann'] } },
{ id: 3, author: 'ann', text: 'The numbers are in `Q3.xlsx`:\n- sales +12%\n- costs -3%', time: Date.now() - 60000 },
],
suggestions: ['Thanks!', 'I will check it'],
});
// stand-in for the other side: types for a second, then answers
chat.on('send', (e) => {
setTimeout(() => chat.setTyping(['ann']), 300);
setTimeout(() => { chat.setTyping([]); chat.addMessage({ author: 'ann', text: 'You wrote: *' + e.message.text + '*' }); }, 1500);
});AI Prompt
एक असिस्टेंट के साथ चैट, जिसका जवाब शब्द-दर-शब्द स्ट्रीम होता है। यहाँ request फ़ंक्शन आपके मॉडल की जगह लेने वाला नमूना है (कुछ भी कहीं नहीं भेजा जाता)। कोई सुझाव क्लिक करें या कुछ पूछें; Stop जवाब रोक देता है।
const app = document.getElementById('app');
app.style.height = '420px';
// stand-in for your model: an async generator that streams the answer word by word
async function* fakeModel(prompt, ctx) {
const answer = 'You asked: "' + prompt + '". This is a **streamed** answer from a stand-in model. ' +
'Your request function can return a string, an async iterable, a ReadableStream or a Response of your server.';
for (const word of answer.split(' ')) {
if (ctx.signal.aborted) return;
await new Promise((resolve) => setTimeout(resolve, 60));
yield word + ' ';
}
}
const ai = VibeFoxJSUi.createAIPrompt('#app', {
assistant: { name: 'Assistant' },
suggestions: ['Summarize my week', 'Draft an e-mail'],
request: (prompt, ctx) => fakeModel(prompt, ctx),
retry: true,
});फ़ाइल मैनेजर
इन-मेमोरी एडैप्टर पर एक एक्सप्लोरर (आपका बैकएंड वहाँ जाता है): ट्री में फ़ोल्डर खोलें, details / tiles के बीच बदलें, क्रमबद्ध करें, खोजें, नाम बदलें (F2), कॉपी और पेस्ट करें, फ़ाइलों को फ़ोल्डरों पर खींचें, मेनू के लिए राइट-क्लिक करें।
const fm = VibeFoxJSUi.createFileManager('#app', {
adapter: VibeFoxJSUi.createMemoryFileAdapter([
{ name: 'Documents', children: [
{ name: 'report.pdf', size: 120000 }, { name: 'notes.txt', content: 'Hello from the notes' }, { name: 'budget.xlsx', size: 48000 },
{ name: 'Contracts', children: [{ name: 'lease.pdf', size: 230000 }] },
] },
{ name: 'Images', children: [{ name: 'logo.svg', size: 3200 }, { name: 'team.jpg', size: 840000 }] },
{ name: 'readme.md', content: '# Read me' },
]),
view: 'details', tree: true, preview: true, height: 400,
});
fm.navigate('/Documents');क्वेरी बिल्डर
AND / OR समूहों वाली शर्तें; नीचे पैरामीटर वाला SQL, पढ़ने योग्य टेक्स्ट और एक छोटी टेबल की मेल खाने वाली पंक्तियाँ हैं। नियम या समूह जोड़ें, फ़ील्ड या ऑपरेटर बदलें।
const output = document.createElement('pre');
output.style.cssText = 'margin: 12px 0 0; min-height: 3em; font: 12px/1.5 ui-monospace, Consolas, monospace; white-space: pre-wrap';
document.getElementById('app').after(output);
const rows = [
{ name: 'Ann', score: 70, city: 'Berlin', active: true }, { name: 'Bob', score: 45, city: 'Paris', active: true },
{ name: 'Cleo', score: 88, city: 'Berlin', active: false }, { name: 'Dan', score: 52, city: 'Rome', active: true },
];
const qb = VibeFoxJSUi.createQueryBuilder('#app', {
fields: [
{ field: 'name', label: 'Name', type: 'text' },
{ field: 'score', label: 'Score', type: 'number' },
{ field: 'city', label: 'City', type: 'list', options: ['Berlin', 'Paris', 'Rome'] },
{ field: 'active', label: 'Active', type: 'boolean' },
],
value: { op: 'and', rules: [{ field: 'score', op: '>=', value: 50 }, { field: 'city', op: 'in', values: ['Berlin', 'Rome'] }] },
});
const show = () => {
const { sql, params } = qb.toSQL({ params: true });
output.textContent = 'SQL: ' + sql + '\nparams: ' + JSON.stringify(params) + '\ntext: ' + qb.toText() +
'\nrows: ' + rows.filter(qb.getPredicate()).map((r) => r.name).join(', ');
};
qb.on('valueChange', show);
show();स्प्रेडशीट
फ़ॉर्मूला, नंबर फ़ॉर्मेट और स्टाइल वाली शीट, फ़ॉर्मूला बार और टूलबार। Units में एक नंबर बदलें और कुल योग उसके साथ बदलते देखें; अपना फ़ंक्शन इस्तेमाल करने के लिए किसी सेल में =TAX(D4) टाइप करें।
const sheet = VibeFoxJSUi.createSpreadsheet('#app', {
data: { sheets: [{ name: 'Sales', rows: [
['Month', 'Units', 'Price', 'Total'],
['Jan', 10, 2.5, '=B2*C2'],
['Feb', 14, 2.5, '=B3*C3'],
['Mar', 9, 2.75, '=B4*C4'],
], styles: { 'A1:D1': { bold: true, fill: '#e0f2fe' }, 'C2:D5': { numFmt: '#,##0.00' } }, colWidths: { A: 100 } }, { name: 'Notes', rows: [['See Sales']] }] },
functions: { TAX: (x) => x * 0.2 },
rows: 12, cols: 6,
});
sheet.setCell('A5', 'Total');
sheet.setCell('D5', '=SUM(D2:D4)');
sheet.setStyle('A5:D5', { bold: true, fill: '#fef3c7' });इमेज एडिटर
कोड में बनाई गई एक तस्वीर के साथ एडिटर: क्रॉप, घुमाना, पलटना, फ़िल्टर और एनोटेशन, अनडू के साथ। टूलबार में कोई टूल चुनें, तीर या टेक्स्ट जोड़ें, कोई फ़िल्टर आज़माएँ।
// a picture made in the code (your image, URL, File or Blob goes here)
const canvas = document.createElement('canvas');
canvas.width = 640; canvas.height = 400;
const g = canvas.getContext('2d');
const sky = g.createLinearGradient(0, 0, 0, 400);
sky.addColorStop(0, '#38bdf8'); sky.addColorStop(1, '#e0f2fe');
g.fillStyle = sky; g.fillRect(0, 0, 640, 400);
g.fillStyle = '#facc15'; g.beginPath(); g.arc(500, 90, 45, 0, Math.PI * 2); g.fill();
g.fillStyle = '#166534'; g.beginPath(); g.moveTo(0, 400); g.lineTo(200, 170); g.lineTo(360, 330); g.lineTo(470, 220); g.lineTo(640, 400); g.fill();
const editor = VibeFoxJSUi.createImageEditor('#app', { src: canvas, history: true, format: 'image/png' });
editor.addShape({ type: 'text', x: 30, y: 30, text: 'Draft', size: 36, color: '#dc2626' });सिग्नेचर पैड और बारकोड
SignaturePad
माउस, पेन या उंगली से हस्ताक्षर करें (रेखा गति के अनुसार चलती है); अनडू, रीडू और क्लियर टूलबार में हैं। Export PNG और SVG का आकार दिखाता है।
function addButtons(buttons) {
const bar = document.createElement('div');
bar.id = 'bar';
bar.style.cssText = 'display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px';
for (const [label, click, variant] of buttons) {
VibeFoxJSUi.createButton(bar.appendChild(document.createElement('span')), { label, variant: variant || 'secondary', on: { click } });
}
document.getElementById('app').before(bar);
}
const output = document.createElement('pre');
output.style.cssText = 'margin: 12px 0 0; min-height: 3em; font: 12px/1.5 ui-monospace, Consolas, monospace; white-space: pre-wrap';
document.getElementById('app').after(output);
document.getElementById('app').style.maxWidth = '480px';
const sign = VibeFoxJSUi.createSignaturePad('#app', { label: 'Signature', penWidth: 2.5, velocity: 0.6, guide: true });
sign.setValue({ width: 300, height: 120, strokes: [{ points: [[20, 80, 1], [60, 40, 1], [90, 85, 1], [130, 45, 1], [170, 90, 1], [220, 60, 1]] }] });
addButtons([['Export', () => {
if (sign.isEmpty()) { output.textContent = 'empty'; return; }
output.textContent = 'PNG data URL ' + sign.toDataURL('image/png', { trim: true }).length + ' chars, SVG ' + sign.toSVG().length + ' chars';
}]]);
sign.on('strokeEnd', () => { output.textContent = 'stroke added'; });QR कोड और बारकोड
QR कोड, Data Matrix, EAN-13 और Code 128, ब्राउज़र में बने (Node में भी)। QR कोड बदलने के लिए फ़ील्ड में टाइप करें।
const app = document.getElementById('app');
app.style.cssText = 'display: grid; gap: 16px';
app.innerHTML =
'<div><label for="text">QR text</label><div id="text"></div></div>' +
'<div id="codes"></div>';
document.getElementById('codes').style.cssText = 'display: flex; flex-wrap: wrap; gap: 24px; align-items: flex-end';
const place = () => document.getElementById('codes').appendChild(document.createElement('div'));
const qr = VibeFoxJSUi.createQRCode(place(), { value: 'https://example.com/ticket/42', ecLevel: 'M', moduleSize: 4, label: 'Ticket link' });
VibeFoxJSUi.createBarcode(place(), { type: 'datamatrix', value: 'ORDER-42', moduleSize: 5, label: 'Order code' });
VibeFoxJSUi.createBarcode(place(), { type: 'ean13', value: '400638133393', text: true, height: 60, label: 'EAN-13' });
VibeFoxJSUi.createBarcode(place(), { type: 'code128', value: 'VFJS-UI-2026', text: true, height: 60, label: 'Code 128' });
const text = VibeFoxJSUi.createInput('#text', { value: 'https://example.com/ticket/42' });
text.on('valueChange', (e) => qr.setValue(e.value || ' '));थीम और स्टाइलिंग
Themes
हर थीम में वही कंट्रोल: तीन अंतर्निहित थीम और vibefox-js-themes.css का पैक। सूची से कोई थीम चुनें।
const app = document.getElementById('app');
app.style.cssText = 'display: grid; gap: 12px';
app.innerHTML =
'<div><label for="theme">Theme</label><div id="theme"></div></div>' +
'<div id="demo"></div>';
const demo = document.getElementById('demo');
demo.style.cssText = 'display: grid; gap: 12px; padding: 16px; border-radius: 8px; background: var(--vfjs-bg); color: var(--vfjs-fg)';
demo.innerHTML = '<div id="t-buttons" style="display: flex; gap: 8px"></div><div id="t-input"></div><div id="t-switch"></div><div id="t-tabs"></div><div id="t-slider"></div>';
VibeFoxJSUi.createButton(document.getElementById('t-buttons').appendChild(document.createElement('span')), { label: 'Primary' });
VibeFoxJSUi.createButton(document.getElementById('t-buttons').appendChild(document.createElement('span')), { label: 'Secondary', variant: 'secondary' });
VibeFoxJSUi.createInput('#t-input', { label: 'Name', value: 'Ann Lee' });
VibeFoxJSUi.createSwitch('#t-switch', { label: 'Notifications', checked: true });
VibeFoxJSUi.createTabs('#t-tabs', { tabs: [{ id: 'a', label: 'Overview', content: 'Text' }, { id: 'b', label: 'Details', content: 'More' }] });
VibeFoxJSUi.createSlider('#t-slider', { label: 'Volume', value: 40 });
const names = ['light', 'dark', 'high-contrast', 'high-contrast-light', 'paper', 'paper-dark', 'glass', 'glass-dark', 'classic', 'classic-dark',
'ocean', 'ocean-dark', 'forest', 'forest-dark', 'sunset', 'sunset-dark', 'graphite', 'graphite-dark'];
const theme = VibeFoxJSUi.createSelect('#theme', { value: 'light', options: names.map((name) => ({ value: name, label: name })) });
theme.on('valueChange', (e) => VibeFoxJSUi.setTheme(e.value, demo));CSS वेरिएबल
हर रंग और आकार एक CSS वेरिएबल है। एक एक्सेंट रंग और कोने की त्रिज्या चुनें: एक CSS नियम नीचे के बॉक्स पर --vfjs-accent और --vfjs-radius सेट करता है, और अंदर का हर कंट्रोल उसका पालन करता है।
const app = document.getElementById('app');
app.style.cssText = 'display: grid; gap: 14px; max-width: 420px';
app.innerHTML =
'<div><label for="accent">Accent color</label><div id="accent"></div></div>' +
'<div><label for="radius">Corner radius</label><div id="radius"></div></div>' +
'<div id="demo"></div>';
const demo = document.getElementById('demo');
demo.style.cssText = 'display: grid; gap: 12px; padding-top: 8px';
demo.innerHTML = '<div id="v-button"></div><div id="v-select"></div><div id="v-check"></div><div id="v-slider"></div>';
VibeFoxJSUi.createButton('#v-button', { label: 'Save', icon: 'check' });
VibeFoxJSUi.createSelect('#v-select', { label: 'Plan', value: 'pro', options: [{ value: 'free', label: 'Free' }, { value: 'pro', label: 'Pro' }] });
VibeFoxJSUi.createCheckbox('#v-check', { label: 'Remember me', checked: true });
VibeFoxJSUi.createSlider('#v-slider', { label: 'Level', value: 60 });
const accent = VibeFoxJSUi.createColorPicker('#accent', { value: '#0f766e', swatches: ['#2563eb', '#0f766e', '#c026d3', '#ea580c', '#1f2937'] });
const radius = VibeFoxJSUi.createSlider('#radius', { min: 0, max: 16, value: 4, tooltip: true });
// the variables go on the box: every component inside follows
const rule = document.head.appendChild(document.createElement('style'));
const apply = () => { rule.textContent = '#demo { --vfjs-accent: ' + accent.getValue() + '; --vfjs-radius: ' + radius.getValue() + 'px; }'; };
accent.on('valueChange', apply);
radius.on('valueChange', apply);
apply();वेरिएंट और आकार
filled, outline और ghost लुक, s, m और l आकारों में, जिन्हें कंटेनर पर एक बार data-vfjs-ui-variant / data-vfjs-ui-size से सेट किया जाता है।
const app = document.getElementById('app');
app.style.cssText = 'display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px';
for (const variant of ['filled', 'outline', 'ghost']) {
for (const size of ['s', 'm', 'l']) {
const box = app.appendChild(document.createElement('div'));
box.setAttribute('data-vfjs-ui-variant', variant);
box.setAttribute('data-vfjs-ui-size', size);
box.style.cssText = 'display: grid; gap: 6px; align-content: start';
box.appendChild(document.createElement('b')).textContent = variant + ' / ' + size;
VibeFoxJSUi.createInput(box.appendChild(document.createElement('div')), { label: 'Name', placeholder: 'Name' });
VibeFoxJSUi.createSelect(box.appendChild(document.createElement('div')), { label: 'Plan', value: 'pro', options: [{ value: 'pro', label: 'Pro' }, { value: 'free', label: 'Free' }] });
VibeFoxJSUi.createButton(box.appendChild(document.createElement('div')), { label: 'Button' });
}
}घनत्व और आकार
कंटेनर का घनत्व बदलें: उसके अंदर हर कंट्रोल की ऊँचाई और पैडिंग उसका पालन करती है। आकार की इकाई --vfjs-size-unit सब कुछ एक साथ स्केल करती है।
const app = document.getElementById('app');
app.style.cssText = 'display: grid; gap: 14px; max-width: 420px';
app.innerHTML =
'<div><label for="density">Density</label><div id="density"></div></div>' +
'<div><label for="unit">Size unit</label><div id="unit"></div></div>' +
'<div id="demo"></div>';
const demo = document.getElementById('demo');
demo.style.cssText = 'display: grid; gap: 10px';
demo.innerHTML = '<div id="d-input"></div><div id="d-list"></div><div id="d-button"></div>';
VibeFoxJSUi.createInput('#d-input', { label: 'Search', prefix: 'search', placeholder: 'Search' });
VibeFoxJSUi.createListBox('#d-list', { label: 'Items', data: ['First', 'Second', 'Third'], value: 'Second' });
VibeFoxJSUi.createButton('#d-button', { label: 'Apply' });
const density = VibeFoxJSUi.createSegmented('#density', { value: 'normal', items: ['compact', 'normal', 'comfortable'] });
density.on('valueChange', (e) => demo.setAttribute('data-vfjs-density', e.value));
const unit = VibeFoxJSUi.createSlider('#unit', { min: 0.8, max: 1.3, step: 0.05, value: 1, tooltip: true });
unit.on('valueChange', (e) => demo.style.setProperty('--vfjs-size-unit', e.value + 'px'));आपकी अपनी CSS
लाइब्रेरी के नियम vfjs कैस्केड लेयर में हैं, इसलिए पेज की सादी CSS बिना !important के जीतती है: यहाँ प्राथमिक बटन बड़े अक्षरों में और दबे हुए टॉगल बटनों का टेक्स्ट मोटा दिखता है।
const style = document.createElement('style');
style.textContent = '.vfjs-ui-btn--primary { text-transform: uppercase; letter-spacing: .04em; }' +
' .vfjs-ui-btn--pressed { font-weight: 700; }';
document.head.appendChild(style);
const app = document.getElementById('app');
app.style.cssText = 'display: flex; flex-wrap: wrap; gap: 12px; align-items: center';
VibeFoxJSUi.createButton(app.appendChild(document.createElement('span')), { label: 'Save' });
VibeFoxJSUi.createButton(app.appendChild(document.createElement('span')), { label: 'Cancel', variant: 'secondary' });
VibeFoxJSUi.createButtonGroup(app.appendChild(document.createElement('span')), { label: 'Period', selection: 'single', value: 'week',
items: [{ id: 'day', label: 'Day' }, { id: 'week', label: 'Week' }, { id: 'month', label: 'Month' }] });स्थानीयकरण और RTL
भाषाएँ
अंग्रेज़ी अंतर्निहित है, रूसी भाषा पैक vibefox-js-ui.ru.js से आती है जो लाइब्रेरी के बाद लोड होता है। पेज की भाषा बदलें: कैलेंडर, सेलेक्ट, पेजिनेशन और अपलोड बॉक्स उसी भाषा में फिर से रेंडर होते हैं।
const app = document.getElementById('app');
app.style.cssText = 'display: grid; gap: 14px; justify-items: start';
app.innerHTML =
'<div id="lang"></div>' +
'<div id="select"></div>' +
'<div id="pages"></div>' +
'<div id="calendar"></div>';
const lang = VibeFoxJSUi.createSegmented('#lang', { label: 'Language', value: 'en', items: [{ value: 'en', label: 'English' }, { value: 'ru', label: 'Русский' }] });
lang.on('valueChange', (e) => VibeFoxJSUi.setLocale(e.value));
VibeFoxJSUi.createSelect('#select', { options: [{ value: 1, label: 'One' }, { value: 2, label: 'Two' }] });
VibeFoxJSUi.createPagination('#pages', { total: 120, pageSize: 20, showTotal: true });
VibeFoxJSUi.createDatePicker('#calendar', { inline: true, value: '2026-11-03' });नई भाषा जोड़ना
addLocale() कुछ कुंजियों के लिए जर्मन स्ट्रिंग जोड़ता है; जो कुंजियाँ नहीं दी गईं, वे अंग्रेज़ी पर वापस जाती हैं। सेलेक्ट और पेजिनेशन लोकेल de का उपयोग करते हैं।
VibeFoxJSUi.addLocale('de', {
'ui.select.placeholder': 'Auswählen…',
'ui.select.searchPlaceholder': 'Suchen…',
'ui.select.empty': 'Nichts gefunden',
'ui.pagination.total': '{total} Einträge',
'ui.pagination.perPage': '/ Seite',
'ui.pagination.prev': 'Vorherige Seite',
'ui.pagination.next': 'Nächste Seite',
});
const app = document.getElementById('app');
app.style.cssText = 'display: grid; gap: 14px; justify-items: start';
app.innerHTML =
'<div id="select"></div>' +
'<div id="pages"></div>';
VibeFoxJSUi.createSelect('#select', { locale: 'de', searchable: true, options: [{ value: 1, label: 'Eins' }, { value: 2, label: 'Zwei' }] });
VibeFoxJSUi.createPagination('#pages', { locale: 'de', total: 120, pageSize: 20, pageSizes: [10, 20, 50], showTotal: true });राइट-टू-लेफ़्ट
rtl: true के साथ कंपोनेंट दाएँ से बाएँ लगाए जाते हैं और तीर कुंजियाँ पढ़ने के क्रम का पालन करती हैं। दिशा बदलें।
const app = document.getElementById('app');
app.style.cssText = 'display: grid; gap: 14px';
app.innerHTML =
'<div id="dir"></div>' +
'<div id="path"></div>' +
'<div id="tabs"></div>' +
'<div id="slider"></div>' +
'<div id="input"></div>';
const parts = [
VibeFoxJSUi.createBreadcrumb('#path', { items: [{ label: 'Home', href: '#' }, { label: 'Docs', href: '#' }, { label: 'UI' }] }),
VibeFoxJSUi.createTabs('#tabs', { tabs: [{ id: 'a', label: 'First', content: 'The first tab' }, { id: 'b', label: 'Second', content: 'The second tab' }, { id: 'c', label: 'Third', content: 'The third tab' }] }),
VibeFoxJSUi.createSlider('#slider', { label: 'Volume', value: 30 }),
VibeFoxJSUi.createInput('#input', { label: 'Search', prefix: 'search', clearable: true, value: 'text' }),
];
const dir = VibeFoxJSUi.createSegmented('#dir', { label: 'Direction', value: 'rtl', items: [{ value: 'ltr', label: 'Left to right' }, { value: 'rtl', label: 'Right to left' }] });
const apply = (value) => { for (const part of parts) part.setOptions({ rtl: value === 'rtl' }); };
dir.on('valueChange', (e) => apply(e.value));
apply('rtl');एक्सेसिबिलिटी
ड्रैग किए बिना ड्रैग और ड्रॉप
जो कुछ भी खींचा जा सकता है, उसका "Move…" मेनू भी है। किसी आइटम पर फ़ोकस करें और Shift+F10 दबाएँ, उस पर राइट-क्लिक करें, या उसका छोटा मूव हैंडल क्लिक करें: कार्य को ऊपर, नीचे या दूसरी सूची में ले जाएँ।
const app = document.getElementById('app');
app.style.cssText = 'display: grid; grid-template-columns: 1fr 1fr; gap: 16px';
app.innerHTML =
'<div><label for="todo">To do</label><div id="todo"></div></div>' +
'<div><label for="done">Done</label><div id="done"></div></div>';
const output = document.createElement('pre');
output.style.cssText = 'margin: 12px 0 0; min-height: 3em; font: 12px/1.5 ui-monospace, Consolas, monospace; white-space: pre-wrap';
document.getElementById('app').after(output);
const todo = VibeFoxJSUi.createListView('#todo', { draggable: true, dragGroup: 'tasks', height: 190,
data: ['Write docs', 'Fix login', 'Review PR', 'Plan sprint'] });
const done = VibeFoxJSUi.createListView('#done', { draggable: true, dragGroup: 'tasks', height: 190,
data: ['Set up CI', 'Design the logo'] });
for (const list of [todo, done]) list.on('itemMove', (e) => { output.textContent = 'moved ' + JSON.stringify(e.items || e.item || e.from) + ' (' + (e.reason || 'drag') + ')'; });अन्य VibeFox JS लाइब्रेरी के साथ उपयोग
link() से कंपोनेंट जोड़ना
VibeFox JS UI का एक क्वेरी बिल्डर VibeFox JS Grid की एक टेबल को फ़िल्टर करता है (दोनों लाइब्रेरी पेज पर): link() शर्तों के हर बदलाव को grid.setFilterModel() तक पहुँचाता है। कोई शर्त बदलें और पंक्तियाँ देखें।
const app = document.getElementById('app');
app.innerHTML = '<div id="qb"></div><div id="grid" style="margin-top: 12px"></div>';
const qb = VibeFoxJSUi.createQueryBuilder('#qb', {
fields: [
{ field: 'name', label: 'Name', type: 'text' },
{ field: 'city', label: 'City', type: 'list', options: ['Berlin', 'Paris', 'Rome'] },
{ field: 'score', label: 'Score', type: 'number' },
],
value: { op: 'and', rules: [{ field: 'score', op: '>=', value: 50 }] },
});
const grid = VibeFoxJSGrid.createGrid('#grid', {
height: 220,
columns: [{ field: 'name', header: 'Name' }, { field: 'city', header: 'City' }, { field: 'score', header: 'Score', type: 'number' }],
data: [
{ name: 'Ann', city: 'Berlin', score: 70 }, { name: 'Bob', city: 'Paris', score: 45 }, { name: 'Cleo', city: 'Berlin', score: 88 },
{ name: 'Dan', city: 'Rome', score: 52 }, { name: 'Eve', city: 'Paris', score: 91 }, { name: 'Finn', city: 'Rome', score: 30 },
],
});
grid.setFilterModel(qb.getFilterModel());
const unlink = VibeFoxJSUi.link(qb, 'filterChange', grid, 'setFilterModel', (e) => e.filterModel);AI टूल
कोड में मॉडल की जगह लेने वाले फ़ंक्शन के साथ टूल लूप (आपका मॉडल वहाँ जाता है): मॉडल टूल sheet_set_range माँगता है, और शीट में कुल योग की पंक्ति लिखी जाती है, फिर sheet_format_range उसे बोल्ड कर देता है। Ask पर क्लिक करें।
function addButtons(buttons) {
const bar = document.createElement('div');
bar.id = 'bar';
bar.style.cssText = 'display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px';
for (const [label, click, variant] of buttons) {
VibeFoxJSUi.createButton(bar.appendChild(document.createElement('span')), { label, variant: variant || 'secondary', on: { click } });
}
document.getElementById('app').before(bar);
}
const output = document.createElement('pre');
output.style.cssText = 'margin: 12px 0 0; min-height: 3em; font: 12px/1.5 ui-monospace, Consolas, monospace; white-space: pre-wrap';
document.getElementById('app').after(output);
const app = document.getElementById('app');
app.style.height = '260px';
const sheet = VibeFoxJSUi.createSpreadsheet('#app', { toolbar: false, data: { sheets: [{ name: 'Sales', rows: [['Month', 'Units'], ['Jan', 10], ['Feb', 14], ['Mar', 9]] }] } });
const kit = VibeFoxJSUi.createToolKit({ budget: sheet });
// stand-in for your model: first it calls the tools, then it answers with text
const model = async (request) => {
if (request.messages.at(-1).role === 'tool') return { text: 'Added a total row under the units.' };
return { toolCalls: [
{ id: 'c1', name: 'budget_sheet_set_range', arguments: { range: 'A5:B5', values: [['Total', '=SUM(B2:B4)']] } },
{ id: 'c2', name: 'budget_sheet_format_range', arguments: { range: 'A5:B5', style: { bold: true, fill: '#fef3c7' } } },
] };
};
addButtons([['Ask', async () => {
const answer = await kit.ask('Add a total row under the units', { model });
output.textContent = 'tools: ' + kit.tools().map((t) => t.name).join(', ') + '\ncalls: ' + answer.calls.map((c) => c.name + (c.result.ok ? ' ok' : ' error ' + c.result.error)).join(', ') + '\nmodel: ' + answer.text;
}, 'primary']]);