المكوّنات · تسجيل منشأة بالسجل التجاري
تسجيل منشأة بالسجل التجاري
يتحقّق من السجل التجاري والرقم الضريبي معًا
12 تصاميم من هذه العائلة
<div class="sg sgb">
<h5 data-ar="تسجيل منشأة" data-en="Register a business">تسجيل منشأة</h5>
<label><span data-ar="اسم المنشأة" data-en="Business name">اسم المنشأة</span>
<input class="nm" type="text" placeholder="مؤسّسة الأفق التجارية"><span class="err"></span></label>
<label><span data-ar="رقم السجل التجاري" data-en="CR number">رقم السجل التجاري</span>
<input class="cr" type="text" inputmode="numeric" placeholder="1010XXXXXX" dir="ltr">
<span class="err"></span></label>
<label><span data-ar="الرقم الضريبي" data-en="VAT number">الرقم الضريبي</span>
<input class="vt" type="text" inputmode="numeric" placeholder="3XXXXXXXXXXXXX3" dir="ltr">
<span class="err"></span></label>
<button class="go" data-ar="تسجيل" data-en="Register">تسجيل</button>
</div>
/* pt-scoped */
/* signup-business — منشأة تجارية */
.sgb{width:100%;height:100%;display:flex;flex-direction:column;
font-size:10px;color:var(--pt-text-secondary);overflow:hidden}
.sgb h5{margin:0;font-size:11px;color:var(--pt-text-primary);font-weight:600}
.sgb .sub{margin:0;font-size:8.5px;color:var(--pt-text-muted)}
.sgb label{display:flex;flex-direction:column;gap:3px}
.sgb label > span{font-size:8.5px;color:var(--pt-text-muted)}
.sgb input, .sgb select{width:100%;font:inherit;font-size:9.5px;
color:var(--pt-text-primary);outline:none}
.sgb input::placeholder{color:var(--pt-text-muted)}
.sgb .err{font-size:8px;color:var(--pt-color-danger-400);min-height:0}
.sgb .ok{color:var(--pt-accent)}
.sgb button{font:inherit;cursor:pointer}
.sgb button:focus-visible, .sgb input:focus-visible{outline:2px solid var(--pt-focus-ring);
outline-offset:1px}
/* شخصية: نموذج رسمي — حقول واسعة، حدود واضحة، انحناء صغير */
.sgb{padding:10px;gap:6px;justify-content:center;
border:1px solid var(--pt-border-strong);border-radius:var(--pt-radius-sm);
background:var(--pt-surface)}
.sgb input{padding:6px 9px;border-radius:var(--pt-radius-sm);
border:1px solid var(--pt-border-default);background:var(--pt-bg-inset);
font-variant-numeric:tabular-nums;letter-spacing:.03em}
.sgb input[aria-invalid=true]{border-color:var(--pt-color-danger-400)}
.sgb input[aria-invalid=false]{border-color:color-mix(in srgb,var(--pt-accent) 55%,transparent)}
.sgb .go{margin-top:2px;padding:7px;border-radius:var(--pt-radius-sm);border:0;
background:var(--pt-accent);color:var(--pt-color-ink-900);font-size:9.5px;font-weight:600}
.sgb .go:disabled{opacity:.45;cursor:not-allowed}
/* يعمل داخل إطار معزول — لا يعتمد على شيء خارجه */
/* pt-remount — يعاد التركيب عند تبديل اللغة */
(function () {
var host = document.querySelector('.sgb');
if (!host) return;
var snapshot = host.innerHTML;
var timers = [];
var ac = null;
/* الجسم كما كتبه المولِّد. يستقبل بدائل مظلَّلة لـ root وdocument
والمؤقّتات، فينظّف نفسه دون أن يعرف أنه قابل لإعادة التركيب. */
function run(root, document, setTimeout, setInterval) {
/* الخطأ يظهر بعد مغادرة الحقل لا مع كل حرف: القراءة أثناء الكتابة
تُشعر المستخدم بالفشل قبل أن ينتهي من الإدخال. */
function bind(input, check, msg) {
var box = input.closest('label') || input.parentElement;
var err = box.querySelector('.err') || box.parentElement.querySelector('.err');
var touched = false;
function paint() {
var good = check(input.value);
input.setAttribute('aria-invalid', String(touched && !good));
if (err) err.textContent = touched && !good ? msg : '';
return good;
}
input.addEventListener('blur', function () { touched = true; paint(); });
input.addEventListener('input', function () { if (touched) paint(); });
return paint;
}
var nm = root.querySelector('.nm'), cr = root.querySelector('.cr'), vt = root.querySelector('.vt');
var go = root.querySelector('.go');
function digits(v) {
return String(v).replace(/[\u0660-\u0669]/g, function (d) { return d.charCodeAt(0) - 0x0660; })
.replace(/\D/g, '');
}
/* السجل التجاري: عشر خانات تبدأ بـ 1 أو 2 أو 4 أو 5 أو 7 حسب نوع المنشأة.
الرقم الضريبي: خمس عشرة خانة تبدأ بـ 3 وتنتهي بـ 3. */
var okName = function (v) { return v.trim().length >= 3; };
var okCr = function (v) { return /^[12457]\d{9}$/.test(digits(v)); };
var okVat = function (v) { return /^3\d{13}3$/.test(digits(v)); };
bind(nm, okName, 'الاسم قصير جدًّا');
bind(cr, okCr, 'عشر خانات تبدأ بـ 1 أو 2 أو 4 أو 5 أو 7');
bind(vt, okVat, 'خمس عشرة خانة تبدأ بـ 3 وتنتهي بـ 3');
function refresh() {
go.disabled = !(okName(nm.value) && okCr(cr.value) && okVat(vt.value));
}
[nm, cr, vt].forEach(function (el) { el.addEventListener('input', refresh); });
[cr, vt].forEach(function (el) {
el.addEventListener('blur', function () { el.value = digits(el.value); refresh(); });
});
refresh();
}
function mount() {
ac = new AbortController();
var real = window.document;
/* وسيط يمرّر كل شيء إلى المستند الحقيقي، ويعلّق كل مستمع بإشارة
تُقطع عند إعادة التركيب — فلا يبقى مستمع من نسخة ماتت. */
var doc = new Proxy(real, {
get: function (t, k) {
if (k === 'addEventListener') {
return function (type, fn, opts) {
var o = (opts && typeof opts === 'object') ? Object.assign({}, opts)
: { capture: !!opts };
o.signal = ac.signal;
return t.addEventListener(type, fn, o);
};
}
var v = t[k];
return typeof v === 'function' ? v.bind(t) : v;
}
});
function track(fn) {
return function (f, ms) { var id = fn(f, ms); timers.push(id); return id; };
}
run(host, doc, track(window.setTimeout.bind(window)),
track(window.setInterval.bind(window)));
}
function unmount() {
if (ac) ac.abort();
// المعرّفان يتشاركان فضاءً واحدًا في المتصفّح، فالإلغاء المزدوج آمن
timers.forEach(function (id) { window.clearTimeout(id); window.clearInterval(id); });
timers = [];
host.innerHTML = snapshot;
}
mount();
addEventListener('pt-lang', function () { unmount(); mount(); });
})();
# Business Sign-up with CR Number
**Role:** You are an Arabic-first UI designer and front-end engineer. Read the whole
specification before writing a single line, then follow it literally. If two requirements
conflict, favour usability over visual effect.
**Goal:** Business Sign-up with CR Number — Validates the commercial registration and the VAT number together
**Why this component matters:** Saudi CR numbers are ten digits starting with 1, 2, 4, 5 or 7; VAT numbers are fifteen digits starting and ending with 3. Checking length alone lets obviously invalid records into the database.
**Direction:** Genuine RTL — not a mirrored Latin layout. Use logical properties
(`margin-inline-start`, `padding-inline`, `inset-inline-start`, `text-align: start`),
never physical ones (`margin-left`, `left`). The layout must flip with `dir` on its own,
with no duplicated rules.
**Typography:** Cairo for Arabic, IBM Plex Sans for Latin. Arabic line-height must be
`0.18` higher than the Latin equivalent — dots, hamzas and maddas need more vertical room.
Arabic font-size runs `1.06×` the Latin size at the same optical weight.
**Numerals:** Western digits in both languages (`1,234.50`). Only the currency changes:
`ر.س` **after** the number in Arabic, `$` **before** it in English. Jordanian dinar
uses **three** decimal places, not two.
**Colors:** Dark mode — background `#0D142B` · surfaces `#211F54` · borders `#545C91` · text `#918FC2`.
Accent `#ADA9E8` must never exceed 8% of the screen area.
**Language:** Bilingual — every string carries both Arabic and English, and the layout
flips with `dir` automatically.
**States:** `default` · `hover` · `focus` · `active` · `disabled` · `loading` · `error`.
Do not design the resting state alone.
**Accessibility:** Contrast ratio at least `4.5:1`, complete keyboard navigation,
visible focus rings, and honour `prefers-reduced-motion`.
**Output:** Clean HTML and CSS in two separate files. No frameworks, no libraries,
no external dependencies.
**Important:** This component has no equivalent in any global library. Do not imitate a
Latin pattern and translate its labels — build it from Gulf market requirements directly.