VibeFox JS UI — عرض توضيحي
البدء السريع
HTML بسيط
نموذج الطلب في البدء السريع: حقل Select قابل للبحث، ومنتقي تاريخ لا يسمح بالتواريخ الماضية، وزر يعرض Toast. افتح القائمة واكتب للتصفية، واختر تاريخاً، ثم انقر على 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') } });المفاهيم الأساسية
الأحداث
يتلقّى كل معالج أحداث كائن بيانات واحداً. اسحب الـ Slider أو استخدم مفاتيح الأسهم: يأتي الحدث 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()); }],
]);المحتوى
محتوى علامة التبويب (Dialog، أو لوحة، أو Tile، أو Card …) هو سلسلة نصية بصيغة 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
الأنماط والأيقونات وزر معطَّل. انقر على Save: يظهر Spinner أثناء تنفيذ العملية (المحاكاة).
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
قائمة Select متعددة الاختيار مع بحث ومجموعات ووسوم (وسمان ثم "+N")، وقائمة Select بسيطة من اختيار واحد. افتح القوائم واكتب للتصفية.
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
يحمّل الحقل الأول الاقتراحات من مصدر غير متزامن (بديل عن خادمك، مع تأخير)؛ ويصفّي الحقل الثاني قائمة ثابتة بمطابقة تقريبية ويحتفظ بعدة قيم كـ Chip. اكتب "ber" أو "pa" في City، و"apl" في Fruits.
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
Slider نطاقي بمقبضين مع تلميحات Tooltip، وSlider واحد، و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; });حقول النماذج داخل النماذج الأصلية
عناصر VibeFox JS داخل <form> عادي: يعرض 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
علامات تبويب قابلة للإغلاق وإعادة الترتيب (اسحب علامة التبويب أو استخدم مقبض النقل الخاص بها)، وعنصر 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
Breadcrumb يطوي العناصر الوسطى عندما تكثر، و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
معالج 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
حوار 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
إشعارات في الزاوية: أربعة أنواع، أحدها يحتوي على إجراء ويبقى ظاهراً حتى يُستخدم، وآخر يتبع Promise (تحميل، ثم اكتمال). يُعرض ثلاثة كحد أقصى، وتنتظر البقية.
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
يظهر Tooltip عند تمرير المؤشر فوق العنصر وعند التركيز بلوحة المفاتيح؛ ويُفتح Popover بعنوان ومحتوى غني عند النقر. مرّر المؤشر أو انتقل بمفتاح Tab إلى 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
جولة تعريفية (Onboarding): تسليط الضوء على كل هدف مع بطاقة خطوة. انقر على 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
شبكة للوحة معلومات: اسحب Tile من ترويسته، وغيّر حجمه من الزاوية، أو انقر على المقبض لقائمة النقل (move، wider، narrower …). يتراجع Ctrl+Z عن التغيير؛ وعند العرض الضيق تحصل الـ Tiles على أعمدة أقل.
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
عناصر Avatar بالأحرف الأولى وحالة ومجموعة "+2"؛ ورقائق Chip للتصفية يمكن تحديدها وإزالتها؛ وشارات Badge بعدد على زر وكنقطة.
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
شريط تقدّم، وSpinner، وعنصر نائب Skeleton. انقر على Load: يمتلئ الشريط، ثم يُستبدل Skeleton بالمحتوى.
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'; });الدردشة وموجّه الذكاء الاصطناعي
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,
});مدير الملفات
مستكشف فوق محوّل في الذاكرة (مكان الواجهة الخلفية الخاصة بك): افتح المجلدات في الشجرة، وبدّل بين عرض التفاصيل والبلاطات، ورتّب، وابحث، وأعد التسمية (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 || ' '));السمات والأنماط
السمات
العناصر نفسها في كل سمة: السمات الثلاث المدمجة وحزمة 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 الخاصة بك
قواعد المكتبة موجودة في طبقة cascade باسم 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 التي تُحمَّل بعد المكتبة. بدّل لغة الصفحة: يُعاد رسم التقويم وSelect والترقيم ومربع الرفع بهذه اللغة.
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() يضيف نصوصاً ألمانية لبعض المفاتيح؛ والمفاتيح التي لم تُحدَّد تعود إلى الإنجليزية. تستخدم Select والترقيم اللغة 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);أدوات الذكاء الاصطناعي
حلقة الأدوات مع دالة نموذج بديلة في الشيفرة (هنا يأتي نموذجك): يطلب الأداة 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']]);