@adula/ui 2.1.0 → 2.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +14 -3
- package/build/attachment-preview.json +21 -0
- package/build/calendar.json +1 -1
- package/build/checkbox.json +1 -1
- package/build/command.json +1 -1
- package/build/confirm-action.json +3 -2
- package/build/data-table.json +7 -2
- package/build/dialog.json +3 -2
- package/build/dropdown-menu.json +1 -1
- package/build/form.json +1 -1
- package/build/hijri-calendar.json +1 -1
- package/build/label.json +1 -1
- package/build/list-filters.json +34 -0
- package/build/manifest.json +105 -75
- package/build/messages.json +21 -0
- package/build/pagination.json +3 -2
- package/build/popover.json +1 -1
- package/build/radio-group.json +1 -1
- package/build/record-collaboration.json +3 -2
- package/build/record-print.json +24 -0
- package/build/record-workflows.json +1 -1
- package/build/resource-actions.json +3 -2
- package/build/resource-bulk.json +27 -0
- package/build/resource-dashboard.json +27 -0
- package/build/resource-field.json +6 -2
- package/build/resource-form.json +3 -2
- package/build/resource-import.json +5 -2
- package/build/resource-page.json +3 -2
- package/build/resource-show.json +4 -2
- package/build/resource-surface.json +3 -2
- package/build/resource-value.json +10 -2
- package/build/select.json +1 -1
- package/build/separator.json +1 -1
- package/build/sheet.json +1 -1
- package/build/sonner.json +1 -1
- package/build/switch.json +1 -1
- package/build/table.json +1 -1
- package/build/tabs.json +1 -1
- package/build/tooltip.json +1 -1
- package/package.json +5 -2
|
@@ -3,14 +3,15 @@
|
|
|
3
3
|
"type": "registry:ui",
|
|
4
4
|
"registryDependencies": [
|
|
5
5
|
"button",
|
|
6
|
-
"dialog"
|
|
6
|
+
"dialog",
|
|
7
|
+
"messages"
|
|
7
8
|
],
|
|
8
9
|
"dependencies": [],
|
|
9
10
|
"files": [
|
|
10
11
|
{
|
|
11
12
|
"path": "registry/ui/resource-surface.tsx",
|
|
12
13
|
"type": "registry:ui",
|
|
13
|
-
"content": "import { useEffect, useRef, useState, type ReactNode } from 'react'\nimport { router } from '@inertiajs/react'\nimport { Link } from '@adonisjs/inertia/react'\nimport axios from 'axios'\nimport { Button } from '~/components/ui/button'\nimport {\n Dialog,\n DialogContent,\n DialogDescription,\n DialogHeader,\n DialogTitle,\n} from '~/components/ui/dialog'\n\nexport type ResourcePresentation = 'dialog' | 'page'\n\nconst LIST_RETURN = 'adula:list-return'\ntype ListReturn = { href: string; scroll: number; record: string }\n\n/**\n * Remembers the list view (query and scroll) before a record opens from it, so closing the\n * record dialog returns to that view. DataTable calls it; page overrides that link to records\n * from their own list can call it too.\n */\nexport function rememberListView(record: string) {\n try {\n sessionStorage.setItem(\n LIST_RETURN,\n JSON.stringify({\n href: window.location.pathname + window.location.search,\n scroll: window.scrollY,\n record,\n } satisfies ListReturn)\n )\n } catch {\n // Storage can be unavailable (private mode); closing then falls back to backHref.\n }\n}\n\nfunction listReturn(backHref: string): ListReturn | null {\n try {\n const saved = JSON.parse(sessionStorage.getItem(LIST_RETURN) ?? 'null') as ListReturn | null\n const path = (href: string) => new URL(href, window.location.origin).pathname\n if (saved && typeof saved.href === 'string' && path(saved.href) === path(backHref)) return saved\n } catch {\n // Ignore unreadable entries.\n }\n return null\n}\n\n/**\n * A record opened over the list it belongs to (#31): the list stays mounted, keeps its\n * query, loaded pages and scroll, and the URL names the record so it can be shared or\n * reloaded as a standalone page.\n */\nexport type RecordOverlay = {\n /** The record's view or edit form, as served by GET /resources/:resource/:id/view. */\n view: unknown\n /** The list URL to return to. */\n list: string\n /** The record that opened the dialog, for focus return. */\n record: string\n /** Set after a save or action, so closing refreshes the list rows. */\n changed?: boolean\n}\ntype OverlayPage = Record<string, unknown> & { overlay?: RecordOverlay }\n\n/**\n * Opens a record in a dialog over the current generic list without leaving it. Page\n * overrides can call it for their own rows. Resources with their own record pages, and\n * failures, fall back to a normal visit.\n */\nexport async function openRecord(\n resource: string,\n id: string | number,\n mode: 'show' | 'edit' = 'show',\n options: { replace?: boolean; changed?: boolean } = {}\n) {\n const href = `/resources/${resource}/${id}${mode === 'edit' ? '/edit' : ''}`\n let data: { view: unknown; childrenData?: unknown; activity?: unknown }\n try {\n const response = await axios.get(`/resources/${resource}/${id}/view`, {\n params: mode === 'edit' ? { mode } : {},\n headers: { Accept: 'application/json' },\n })\n data = response.data\n } catch {\n router.visit(href)\n return\n }\n const list = window.location.pathname + window.location.search\n const visit = options.replace ? router.replace.bind(router) : router.push.bind(router)\n visit({\n url: href,\n props: (current: OverlayPage) => ({\n ...current,\n childrenData: data.childrenData,\n activity: data.activity,\n overlay: {\n view: data.view,\n list: options.replace ? (current.overlay?.list ?? list) : list,\n record: options.replace ? (current.overlay?.record ?? href) : href,\n changed: Boolean(options.changed || (options.replace && current.overlay?.changed)),\n },\n }),\n preserveState: true,\n preserveScroll: true,\n })\n}\n\n/** Closes a record dialog opened by openRecord and returns to its list, refreshed if changed. */\nexport function closeRecord(overlay: RecordOverlay) {\n if (overlay.changed) {\n // Replace the record's history entry, so Back does not reopen a record that changed.\n router.visit(overlay.list, {\n replace: true,\n preserveScroll: true,\n onSuccess: () => restoreFocus(overlay.record),\n })\n return\n }\n router.replace({\n url: overlay.list,\n props: (current: OverlayPage) => {\n const { overlay: _closed, childrenData: _children, activity: _activity, ...rest } = current\n return rest\n },\n preserveState: true,\n preserveScroll: true,\n onSuccess: () => restoreFocus(overlay.record),\n })\n}\n\n/** Return focus to the control that opened the record, else to the page heading without a ring. */\nfunction restoreFocus(record: string | undefined) {\n const trigger = record\n ? document.querySelector<HTMLElement>(`main a[href=\"${CSS.escape(record)}\"]`)\n : null\n const target = trigger ?? document.querySelector<HTMLElement>('main h1')\n if (!trigger && target) {\n target.setAttribute('tabindex', '-1')\n target.classList.add('outline-none')\n }\n target?.focus({ preventScroll: true })\n}\n\n/** Forms and record details are modal unless the user requests a page override. */\nexport function ResourceSurface({\n title,\n description,\n backHref,\n presentation = 'dialog',\n mode,\n onClose,\n children,\n}: {\n title: string\n description: string\n backHref: string\n presentation?: ResourcePresentation\n mode?: 'view' | 'edit'\n /** Replaces the default return visit, for dialogs opened over a mounted list. */\n onClose?: () => void\n children: ReactNode\n}) {\n const [open, setOpen] = useState(true)\n const closeTimer = useRef<ReturnType<typeof setTimeout> | undefined>(undefined)\n useEffect(() => () => clearTimeout(closeTimer.current), [])\n if (presentation === 'page')\n return (\n <section dir
|
|
14
|
+
"content": "import { useEffect, useRef, useState, type ReactNode } from 'react'\nimport { router } from '@inertiajs/react'\nimport { Link } from '@adonisjs/inertia/react'\nimport axios from 'axios'\nimport { Button } from '~/components/ui/button'\nimport {\n Dialog,\n DialogContent,\n DialogDescription,\n DialogHeader,\n DialogTitle,\n} from '~/components/ui/dialog'\nimport { useMessages } from '~/components/ui/messages'\n\nexport type ResourcePresentation = 'dialog' | 'page'\n\nconst LIST_RETURN = 'adula:list-return'\ntype ListReturn = { href: string; scroll: number; record: string }\n\n/**\n * Remembers the list view (query and scroll) before a record opens from it, so closing the\n * record dialog returns to that view. DataTable calls it; page overrides that link to records\n * from their own list can call it too.\n */\nexport function rememberListView(record: string) {\n try {\n sessionStorage.setItem(\n LIST_RETURN,\n JSON.stringify({\n href: window.location.pathname + window.location.search,\n scroll: window.scrollY,\n record,\n } satisfies ListReturn)\n )\n } catch {\n // Storage can be unavailable (private mode); closing then falls back to backHref.\n }\n}\n\nfunction listReturn(backHref: string): ListReturn | null {\n try {\n const saved = JSON.parse(sessionStorage.getItem(LIST_RETURN) ?? 'null') as ListReturn | null\n const path = (href: string) => new URL(href, window.location.origin).pathname\n if (saved && typeof saved.href === 'string' && path(saved.href) === path(backHref)) return saved\n } catch {\n // Ignore unreadable entries.\n }\n return null\n}\n\n/**\n * A record opened over the list it belongs to (#31): the list stays mounted, keeps its\n * query, loaded pages and scroll, and the URL names the record so it can be shared or\n * reloaded as a standalone page.\n */\nexport type RecordOverlay = {\n /** The record's view or edit form, as served by GET /resources/:resource/:id/view. */\n view: unknown\n /** The list URL to return to. */\n list: string\n /** The record that opened the dialog, for focus return. */\n record: string\n /** Set after a save or action, so closing refreshes the list rows. */\n changed?: boolean\n}\ntype OverlayPage = Record<string, unknown> & { overlay?: RecordOverlay }\n\n/**\n * Opens a record in a dialog over the current generic list without leaving it. Page\n * overrides can call it for their own rows. Resources with their own record pages, and\n * failures, fall back to a normal visit.\n */\nexport async function openRecord(\n resource: string,\n id: string | number,\n mode: 'show' | 'edit' = 'show',\n options: { replace?: boolean; changed?: boolean } = {}\n) {\n const href = `/resources/${resource}/${id}${mode === 'edit' ? '/edit' : ''}`\n let data: { view: unknown; childrenData?: unknown; activity?: unknown }\n try {\n const response = await axios.get(`/resources/${resource}/${id}/view`, {\n params: mode === 'edit' ? { mode } : {},\n headers: { Accept: 'application/json' },\n })\n data = response.data\n } catch {\n router.visit(href)\n return\n }\n const list = window.location.pathname + window.location.search\n const visit = options.replace ? router.replace.bind(router) : router.push.bind(router)\n visit({\n url: href,\n props: (current: OverlayPage) => ({\n ...current,\n childrenData: data.childrenData,\n activity: data.activity,\n overlay: {\n view: data.view,\n list: options.replace ? (current.overlay?.list ?? list) : list,\n record: options.replace ? (current.overlay?.record ?? href) : href,\n changed: Boolean(options.changed || (options.replace && current.overlay?.changed)),\n },\n }),\n preserveState: true,\n preserveScroll: true,\n })\n}\n\n/** Closes a record dialog opened by openRecord and returns to its list, refreshed if changed. */\nexport function closeRecord(overlay: RecordOverlay) {\n if (overlay.changed) {\n // Replace the record's history entry, so Back does not reopen a record that changed.\n router.visit(overlay.list, {\n replace: true,\n preserveScroll: true,\n onSuccess: () => restoreFocus(overlay.record),\n })\n return\n }\n router.replace({\n url: overlay.list,\n props: (current: OverlayPage) => {\n const { overlay: _closed, childrenData: _children, activity: _activity, ...rest } = current\n return rest\n },\n preserveState: true,\n preserveScroll: true,\n onSuccess: () => restoreFocus(overlay.record),\n })\n}\n\n/** Return focus to the control that opened the record, else to the page heading without a ring. */\nfunction restoreFocus(record: string | undefined) {\n const trigger = record\n ? document.querySelector<HTMLElement>(`main a[href=\"${CSS.escape(record)}\"]`)\n : null\n const target = trigger ?? document.querySelector<HTMLElement>('main h1')\n if (!trigger && target) {\n target.setAttribute('tabindex', '-1')\n target.classList.add('outline-none')\n }\n target?.focus({ preventScroll: true })\n}\n\n/** Forms and record details are modal unless the user requests a page override. */\nexport function ResourceSurface({\n title,\n description,\n backHref,\n presentation = 'dialog',\n mode,\n onClose,\n children,\n}: {\n title: string\n description: string\n backHref: string\n presentation?: ResourcePresentation\n mode?: 'view' | 'edit'\n /** Replaces the default return visit, for dialogs opened over a mounted list. */\n onClose?: () => void\n children: ReactNode\n}) {\n const { t, dir } = useMessages()\n const [open, setOpen] = useState(true)\n const closeTimer = useRef<ReturnType<typeof setTimeout> | undefined>(undefined)\n useEffect(() => () => clearTimeout(closeTimer.current), [])\n if (presentation === 'page')\n return (\n <section dir={dir} className=\"space-y-6\">\n <Button variant=\"outline\" asChild>\n <Link href={backHref}>{t('العودة إلى القائمة')}</Link>\n </Button>\n <header>\n <h1 className=\"text-3xl font-semibold\">{title}</h1>\n <p className=\"mt-3 text-sm text-muted-foreground\">{description}</p>\n </header>\n {children}\n </section>\n )\n\n return (\n <Dialog\n mode={mode}\n open={open}\n onOpenChange={(open) => {\n if (!open) {\n setOpen(false)\n closeTimer.current = setTimeout(\n () => {\n if (onClose) return onClose()\n // Return to the list view the record was opened from: same query and scroll.\n const saved = listReturn(backHref)\n router.visit(saved?.href ?? backHref, {\n onSuccess: () => {\n if (saved) window.scrollTo(0, saved.scroll)\n // A direct route has no mounted DialogTrigger to restore focus to.\n restoreFocus(saved?.record)\n },\n })\n },\n window.matchMedia('(prefers-reduced-motion: reduce)').matches ? 0 : 160\n )\n }\n }}\n >\n <DialogContent\n dir={dir}\n className=\"flex max-h-[calc(100dvh-2rem)] w-[calc(100vw-2rem)] flex-col gap-0 overflow-hidden p-0 sm:max-w-5xl\"\n >\n <DialogHeader className=\"shrink-0 border-b px-6 py-5 pe-12 text-start\">\n <DialogTitle>{title}</DialogTitle>\n <DialogDescription>{description}</DialogDescription>\n </DialogHeader>\n <div className=\"min-h-0 overflow-y-auto overscroll-contain p-4 sm:p-6\">{children}</div>\n </DialogContent>\n </Dialog>\n )\n}\n",
|
|
14
15
|
"target": "inertia/components/ui/resource-surface.tsx"
|
|
15
16
|
}
|
|
16
17
|
],
|
|
@@ -3,8 +3,10 @@
|
|
|
3
3
|
"type": "registry:ui",
|
|
4
4
|
"registryDependencies": [
|
|
5
5
|
"badge",
|
|
6
|
+
"attachment-preview",
|
|
6
7
|
"calendar-date",
|
|
7
|
-
"ui-preferences"
|
|
8
|
+
"ui-preferences",
|
|
9
|
+
"messages"
|
|
8
10
|
],
|
|
9
11
|
"dependencies": [
|
|
10
12
|
"lucide-react@1.47.0"
|
|
@@ -13,8 +15,14 @@
|
|
|
13
15
|
{
|
|
14
16
|
"path": "registry/ui/resource-value.tsx",
|
|
15
17
|
"type": "registry:ui",
|
|
16
|
-
"content": "import type { ReactNode } from 'react'\nimport { Paperclip } from 'lucide-react'\nimport type { CalendarPreference, ResourceField, SerializedRecord } from 'adula'\nimport { calendarDisplay, calendarIso } from '~/components/ui/calendar_date'\nimport { useUiPreferences } from '~/components/ui/ui-preferences'\nimport { Badge } from '~/components/ui/badge'\n\nexport type Option = { value: string; label: string }\nexport type LookupOptions = Record<string, Option[]>\nexport type AttachmentValue = {\n id: number\n name: string\n size: number\n mimeType: string\n url: string\n}\n\n/** Project-owned copy: change the label once here for another currency. */\nexport const CURRENCY_LABEL = 'ر.س'\nconst locale = 'ar-u-nu-latn'\nconst integerFormat = new Intl.NumberFormat(locale)\nconst sizeFormat = new Intl.NumberFormat(locale, { maximumFractionDigits: 1 })\nconst meta = new Set(['id', 'version', 'docStatus', 'orgUnitId'])\n\nexport function toLatinDigits(raw: string) {\n return raw\n .replace(/[٠-٩]/g, (digit) => String('٠١٢٣٤٥٦٧٨٩'.indexOf(digit)))\n .replace(/[۰-۹]/g, (digit) => String('۰۱۲۳۴۵۶۷۸۹'.indexOf(digit)))\n .replaceAll('٫', '.')\n .replaceAll('٬', '')\n .replaceAll(',', '')\n .trim()\n}\n\nfunction minorUnits(value: unknown) {\n if (value === null || value === undefined || value === '') return null\n try {\n return BigInt(String(value))\n } catch {\n return null\n }\n}\n\nexport function moneyInput(value: unknown) {\n const minor = minorUnits(value)\n if (minor === null) return ''\n const abs = minor < 0n ? -minor : minor\n return `${minor < 0n ? '-' : ''}${abs / 100n}.${String(abs % 100n).padStart(2, '0')}`\n}\n\nexport function moneyDisplay(value: unknown) {\n const minor = minorUnits(value)\n if (minor === null) return ''\n const abs = minor < 0n ? -minor : minor\n return `${minor < 0n ? '-' : ''}${integerFormat.format(abs / 100n)}.${String(abs % 100n).padStart(2, '0')}`\n}\n\nexport function parseMoney(raw: string) {\n const value = toLatinDigits(raw)\n if (!/^-?\\d+(\\.\\d{1,2})?$/.test(value)) throw new Error('أدخل مبلغاً بخانتين عشريتين كحد أقصى')\n const [whole, cents = ''] = value.replace('-', '').split('.')\n return String(\n (BigInt(whole) * 100n + BigInt(cents.padEnd(2, '0'))) * (value.startsWith('-') ? -1n : 1n)\n )\n}\n\nexport function isAttachment(value: unknown): value is AttachmentValue {\n return (\n typeof value === 'object' &&\n value !== null &&\n 'id' in value &&\n 'name' in value &&\n typeof (value as { url?: unknown }).url === 'string'\n )\n}\n\nexport function fileSize(bytes: number) {\n if (bytes < 1024) return `${integerFormat.format(bytes)} بايت`\n if (bytes < 1024 * 1024) return `${sizeFormat.format(bytes / 1024)} ك.ب`\n return `${sizeFormat.format(bytes / (1024 * 1024))} م.ب`\n}\n\nexport function formatDate(value: unknown, calendar: CalendarPreference = 'gregory') {\n return calendarDisplay(value, calendar)\n}\n\nexport function formatDatetime(value: unknown, calendar: CalendarPreference = 'gregory') {\n return calendarDisplay(value, calendar, true)\n}\n\n/**\n * A related record is labelled by the title the server computed from the resource's\n * `title` fields (`_title`, #47). Older servers send none; then the first readable string\n * of the record is used.\n */\nexport function relationLabel(row: SerializedRecord | undefined, fallback: unknown) {\n if (row && '_title' in row)\n return typeof row._title === 'string' && row._title\n ? row._title\n : fallback === null || fallback === undefined\n ? '—'\n : `#${fallback}`\n const label =\n row &&\n Object.entries(row).find(([key, entry]) => !meta.has(key) && typeof entry === 'string' && entry)\n return label\n ? String(label[1])\n : fallback === null || fallback === undefined\n ? '—'\n : `#${fallback}`\n}\n\nexport function inputValue(field: ResourceField, value: unknown) {\n if (value === null || value === undefined) return ''\n if (field.type === 'money') return moneyInput(value)\n if (field.type === 'json') return JSON.stringify(value, null, 2)\n if (field.type === 'attachment') return isAttachment(value) ? String(value.id) : String(value)\n if (field.type === 'datetime') {\n const date = new Date(String(value))\n if (Number.isNaN(date.getTime())) return ''\n return new Date(date.getTime() - date.getTimezoneOffset() * 60000).toISOString().slice(0, 16)\n }\n if (field.type === 'date') return String(value).slice(0, 10)\n return String(value)\n}\n\n/** Converts a control's string state into the JSON the resource route validates. */\nexport function parseValue(field: ResourceField, raw: string): unknown {\n if (raw === '') return null\n switch (field.type) {\n case 'money':\n return parseMoney(raw)\n case 'boolean':\n return raw === 'true'\n case 'integer': {\n const value = Number(toLatinDigits(raw))\n if (!Number.isInteger(value)) throw new Error('أدخل عدداً صحيحاً')\n return value\n }\n case 'belongsTo':\n case 'user':\n case 'attachment':\n return Number(raw)\n case 'json':\n try {\n return JSON.parse(raw)\n } catch {\n throw new Error('أدخل بيانات JSON صحيحة')\n }\n case 'date': {\n return raw.startsWith('hijri:')\n ? calendarIso(raw.slice(6), 'islamic-umalqura')\n : calendarIso(raw, 'gregory')\n }\n case 'datetime': {\n const [day, time] = raw.split('T')\n const isoDay = day.startsWith('hijri:')\n ? calendarIso(day.slice(6), 'islamic-umalqura')\n : calendarIso(day, 'gregory')\n const date = new Date(`${isoDay}T${time}`)\n if (Number.isNaN(date.getTime())) throw new Error('أدخل تاريخاً ووقتاً صحيحين')\n return date.toISOString()\n }\n default:\n return raw\n }\n}\n\nexport function displayValue(\n field: ResourceField,\n row: SerializedRecord,\n related: Record<string, SerializedRecord[]> = {},\n lookups: LookupOptions = {},\n calendar: CalendarPreference = 'gregory'\n) {\n const value = row[field.key]\n if (value === null || value === undefined || value === '') return '—'\n switch (field.type) {\n case 'money':\n return `${moneyDisplay(value)} ${CURRENCY_LABEL}`\n case 'boolean':\n return value ? 'نعم' : 'لا'\n case 'integer':\n return typeof value === 'number' ? integerFormat.format(value) : String(value)\n case 'belongsTo':\n case 'user':\n return relationLabel(\n related[field.key]?.find((item) => String(item.id) === String(value)),\n value\n )\n case 'lookup':\n return (\n lookups[field.key]?.find((option) => option.value === String(value))?.label ?? String(value)\n )\n case 'json':\n return JSON.stringify(value)\n case 'attachment':\n return isAttachment(value) ? value.name : 'مرفق'\n case 'date':\n return formatDate(value, calendar)\n case 'datetime':\n return formatDatetime(value, calendar)\n default:\n return String(value)\n }\n}\n\n/** Prefix formula-like and leading-control values before quoting CSV cells. */\nexport function csvCell(value: string) {\n const safe = /^[\\s\u0000-\u001f]*[=+@-]|^[\\t\\r\\n]/.test(value) ? `'${value}` : value\n return `\"${safe.replaceAll('\"', '\"\"')}\"`\n}\n\nexport function ResourceValue({\n field,\n row,\n related,\n lookups,\n}: {\n field: ResourceField\n row: SerializedRecord\n related?: Record<string, SerializedRecord[]>\n lookups?: LookupOptions\n}): ReactNode {\n const { calendar } = useUiPreferences()\n const value = row[field.key]\n if (value === null || value === undefined || value === '')\n return <span className=\"text-muted-foreground\">—</span>\n if (field.type === 'attachment' && isAttachment(value))\n return (\n <a\n href={value.url}\n download={value.name}\n className=\"inline-flex items-center gap-2 text-primary underline-offset-4 hover:underline\"\n >\n <Paperclip size={14} />\n {value.name}\n <span className=\"text-xs text-muted-foreground\">({fileSize(value.size)})</span>\n </a>\n )\n if (field.type === 'boolean')\n return <Badge variant={value ? 'default' : 'secondary'}>{value ? 'نعم' : 'لا'}</Badge>\n if (field.type === 'money')\n return (\n <span className=\"tabular-nums\" dir=\"ltr\">\n {moneyDisplay(value)}{' '}\n <span className=\"text-xs text-muted-foreground\">{CURRENCY_LABEL}</span>\n </span>\n )\n if (field.type === 'json')\n return (\n <pre dir=\"ltr\" className=\"max-h-64 overflow-auto rounded-md bg-muted p-3 text-xs\">\n {JSON.stringify(value, null, 2)}\n </pre>\n )\n if (field.type === 'integer')\n return (\n <span className=\"tabular-nums\" dir=\"ltr\">\n {displayValue(field, row, related, lookups, calendar)}\n </span>\n )\n // Arabic dates carry Arabic month names and time markers; isolate them instead of forcing LTR.\n if (field.type === 'date' || field.type === 'datetime')\n return <bdi className=\"tabular-nums\">{displayValue(field, row, related, lookups, calendar)}</bdi>\n return <>{displayValue(field, row, related, lookups, calendar)}</>\n}\n",
|
|
18
|
+
"content": "import type { ReactNode } from 'react'\nimport { Paperclip } from 'lucide-react'\nimport type { CalendarPreference, ResourceField, SerializedRecord } from 'adula'\nimport { calendarDisplay, calendarIso } from '~/components/ui/calendar_date'\nimport { useUiPreferences } from '~/components/ui/ui-preferences'\nimport { arabicText, useMessages, type Translate } from '~/components/ui/messages'\nimport { Badge } from '~/components/ui/badge'\nimport { AttachmentPreviewButton } from '~/components/ui/attachment-preview'\nimport {\n decimalDisplay,\n decimalInput,\n decimalScale,\n emailHref,\n listInput,\n listValue,\n orderedSelection,\n parseDecimal,\n phoneHref,\n safeUrl,\n toLatinDigits,\n} from '~/components/ui/field_values'\n\nexport { toLatinDigits } from '~/components/ui/field_values'\n\nexport type Option = { value: string; label: string }\nexport type LookupOptions = Record<string, Option[]>\nexport type AttachmentValue = {\n id: number\n name: string\n size: number\n mimeType: string\n url: string\n /** Inline preview kind for allow-listed images, PDF and text (ADR 047); others download. */\n preview?: 'image' | 'pdf' | 'text' | null\n}\n\n/**\n * Project-owned copy: change the label once here for another currency. It is shown through\n * `t()`, so a translated interface can map it (ui.value.currency).\n */\nexport const CURRENCY_LABEL = 'ر.س'\nconst locale = 'ar-u-nu-latn'\nconst integerFormat = new Intl.NumberFormat(locale)\nconst sizeFormat = new Intl.NumberFormat(locale, { maximumFractionDigits: 1 })\nconst meta = new Set(['id', 'version', 'docStatus', 'orgUnitId'])\n\n/** The percent sign after a percent value; translated interfaces map it (ui.value.percent). */\nexport const PERCENT_LABEL = '٪'\nconst multiValued = new Set(['multiSelect', 'manyToMany'])\n\n/** Option label of an enum or multiSelect value in the interface language. */\nexport function optionLabel(field: ResourceField, value: string, language = 'ar') {\n if (field.type !== 'enum' && field.type !== 'multiSelect') return value\n const option = field.options.find((entry) => entry.value === value)\n return option ? option.label[language] || option.label.ar : value\n}\n\n/** Localized options of an enum or multiSelect field, in definition order. */\nexport function fieldOptions(field: ResourceField, language = 'ar'): Option[] {\n if (field.type !== 'enum' && field.type !== 'multiSelect') return []\n return field.options.map((option) => ({\n value: option.value,\n label: option.label[language] || option.label.ar,\n }))\n}\n\n/** Linked records of a manyToMany value: id and title, #id when the reader cannot view it. */\nexport function linkedTitles(\n field: ResourceField,\n value: unknown,\n related: Record<string, SerializedRecord[]> = {}\n) {\n if (!Array.isArray(value)) return []\n return value.map((id) => ({\n id: String(id),\n title: relationLabel(\n related[field.key]?.find((item) => String(item.id) === String(id)),\n id\n ),\n }))\n}\n\nfunction minorUnits(value: unknown) {\n if (value === null || value === undefined || value === '') return null\n try {\n return BigInt(String(value))\n } catch {\n return null\n }\n}\n\nexport function moneyInput(value: unknown) {\n const minor = minorUnits(value)\n if (minor === null) return ''\n const abs = minor < 0n ? -minor : minor\n return `${minor < 0n ? '-' : ''}${abs / 100n}.${String(abs % 100n).padStart(2, '0')}`\n}\n\nexport function moneyDisplay(value: unknown) {\n const minor = minorUnits(value)\n if (minor === null) return ''\n const abs = minor < 0n ? -minor : minor\n return `${minor < 0n ? '-' : ''}${integerFormat.format(abs / 100n)}.${String(abs % 100n).padStart(2, '0')}`\n}\n\nexport function parseMoney(raw: string) {\n const value = toLatinDigits(raw)\n if (!/^-?\\d+(\\.\\d{1,2})?$/.test(value)) throw new Error('أدخل مبلغاً بخانتين عشريتين كحد أقصى')\n const [whole, cents = ''] = value.replace('-', '').split('.')\n return String(\n (BigInt(whole) * 100n + BigInt(cents.padEnd(2, '0'))) * (value.startsWith('-') ? -1n : 1n)\n )\n}\n\nexport function isAttachment(value: unknown): value is AttachmentValue {\n return (\n typeof value === 'object' &&\n value !== null &&\n 'id' in value &&\n 'name' in value &&\n typeof (value as { url?: unknown }).url === 'string'\n )\n}\n\n/** Whether an attachment field holds several files (an ordered array of summaries). */\nexport function isMultipleAttachment(field: ResourceField) {\n return field.type === 'attachment' && field.multiple === true\n}\n\n/** The files of a multiple attachment value, in their stored order. */\nexport function attachmentList(value: unknown): AttachmentValue[] {\n return Array.isArray(value) ? value.filter(isAttachment) : []\n}\n\nexport function fileSize(bytes: number, t: Translate = arabicText) {\n if (bytes < 1024) return t('{size} بايت', { size: integerFormat.format(bytes) })\n if (bytes < 1024 * 1024) return t('{size} ك.ب', { size: sizeFormat.format(bytes / 1024) })\n return t('{size} م.ب', { size: sizeFormat.format(bytes / (1024 * 1024)) })\n}\n\nexport function formatDate(value: unknown, calendar: CalendarPreference = 'gregory') {\n return calendarDisplay(value, calendar)\n}\n\nexport function formatDatetime(value: unknown, calendar: CalendarPreference = 'gregory') {\n return calendarDisplay(value, calendar, true)\n}\n\n/**\n * A related record is labelled by the title the server computed from the resource's\n * `title` fields (`_title`, #47). Older servers send none; then the first readable string\n * of the record is used.\n */\nexport function relationLabel(row: SerializedRecord | undefined, fallback: unknown) {\n if (row && '_title' in row)\n return typeof row._title === 'string' && row._title\n ? row._title\n : fallback === null || fallback === undefined\n ? '—'\n : `#${fallback}`\n const label =\n row &&\n Object.entries(row).find(([key, entry]) => !meta.has(key) && typeof entry === 'string' && entry)\n return label\n ? String(label[1])\n : fallback === null || fallback === undefined\n ? '—'\n : `#${fallback}`\n}\n\nexport function inputValue(field: ResourceField, value: unknown) {\n if (value === null || value === undefined) return ''\n if (field.type === 'money') return moneyInput(value)\n if (field.type === 'decimal' || field.type === 'percent')\n return decimalInput(value, decimalScale(field))\n if (multiValued.has(field.type)) return listInput(value)\n if (field.type === 'json') return JSON.stringify(value, null, 2)\n // Several files are edited as the JSON array of their ids, in order.\n if (isMultipleAttachment(field))\n return Array.isArray(value)\n ? listInput(value.map((entry) => (isAttachment(entry) ? entry.id : entry)))\n : ''\n if (field.type === 'attachment') return isAttachment(value) ? String(value.id) : String(value)\n if (field.type === 'datetime') {\n const date = new Date(String(value))\n if (Number.isNaN(date.getTime())) return ''\n return new Date(date.getTime() - date.getTimezoneOffset() * 60000).toISOString().slice(0, 16)\n }\n if (field.type === 'date') return String(value).slice(0, 10)\n return String(value)\n}\n\n/**\n * Converts a control's string state into the JSON the resource route validates. Errors carry\n * the Arabic interface text; callers show them through `t(error.message)`.\n */\nexport function parseValue(field: ResourceField, raw: string): unknown {\n // Multi-value fields always submit an array, so clearing them is explicit.\n if (field.type === 'multiSelect') return orderedSelection(field.options, listValue(raw))\n if (field.type === 'manyToMany' || isMultipleAttachment(field)) return listValue(raw).map(Number)\n if (raw === '') return null\n switch (field.type) {\n case 'decimal':\n case 'percent':\n return parseDecimal(raw, decimalScale(field))\n case 'email':\n case 'url':\n case 'phone':\n return raw.trim()\n case 'money':\n return parseMoney(raw)\n case 'boolean':\n return raw === 'true'\n case 'integer': {\n const value = Number(toLatinDigits(raw))\n if (!Number.isInteger(value)) throw new Error('أدخل عدداً صحيحاً')\n return value\n }\n case 'belongsTo':\n case 'user':\n case 'attachment':\n return Number(raw)\n case 'json':\n try {\n return JSON.parse(raw)\n } catch {\n throw new Error('أدخل بيانات JSON صحيحة')\n }\n case 'date': {\n return raw.startsWith('hijri:')\n ? calendarIso(raw.slice(6), 'islamic-umalqura')\n : calendarIso(raw, 'gregory')\n }\n case 'datetime': {\n const [day, time] = raw.split('T')\n const isoDay = day.startsWith('hijri:')\n ? calendarIso(day.slice(6), 'islamic-umalqura')\n : calendarIso(day, 'gregory')\n const date = new Date(`${isoDay}T${time}`)\n if (Number.isNaN(date.getTime())) throw new Error('أدخل تاريخاً ووقتاً صحيحين')\n return date.toISOString()\n }\n default:\n return raw\n }\n}\n\nexport function displayValue(\n field: ResourceField,\n row: SerializedRecord,\n related: Record<string, SerializedRecord[]> = {},\n lookups: LookupOptions = {},\n calendar: CalendarPreference = 'gregory',\n t: Translate = arabicText,\n language = 'ar'\n) {\n const value = row[field.key]\n if (value === null || value === undefined || value === '') return '—'\n if (Array.isArray(value) && !value.length) return '—'\n switch (field.type) {\n case 'decimal':\n return decimalDisplay(value, decimalScale(field), language)\n case 'percent':\n return `${decimalDisplay(value, decimalScale(field), language)}${t(PERCENT_LABEL)}`\n case 'enum':\n return optionLabel(field, String(value), language)\n case 'multiSelect':\n return Array.isArray(value)\n ? value.map((entry) => optionLabel(field, String(entry), language)).join('، ')\n : String(value)\n case 'manyToMany':\n return linkedTitles(field, value, related)\n .map((entry) => entry.title)\n .join('، ')\n case 'money':\n return `${moneyDisplay(value)} ${t(CURRENCY_LABEL)}`\n case 'boolean':\n return value ? t('نعم') : t('لا')\n case 'integer':\n return typeof value === 'number' ? integerFormat.format(value) : String(value)\n case 'belongsTo':\n case 'user':\n return relationLabel(\n related[field.key]?.find((item) => String(item.id) === String(value)),\n value\n )\n case 'lookup':\n return (\n lookups[field.key]?.find((option) => option.value === String(value))?.label ?? String(value)\n )\n case 'json':\n return JSON.stringify(value)\n case 'attachment':\n if (Array.isArray(value))\n return attachmentList(value)\n .map((entry) => entry.name)\n .join('، ')\n return isAttachment(value) ? value.name : t('مرفق')\n case 'date':\n return formatDate(value, calendar)\n case 'datetime':\n return formatDatetime(value, calendar)\n default:\n return String(value)\n }\n}\n\n/** Prefix formula-like and leading-control values before quoting CSV cells. */\nexport function csvCell(value: string) {\n const safe = /^[\\s\u0000-\u001f]*[=+@-]|^[\\t\\r\\n]/.test(value) ? `'${value}` : value\n return `\"${safe.replaceAll('\"', '\"\"')}\"`\n}\n\n/** A downloadable file with its size and, for previewable types, a preview button. */\nfunction AttachmentLink({ file }: { file: AttachmentValue }) {\n const { t } = useMessages()\n return (\n <>\n <a\n href={file.url}\n download={file.name}\n className=\"inline-flex items-center gap-2 text-primary underline-offset-4 hover:underline\"\n >\n <Paperclip size={14} />\n {file.name}\n <span className=\"text-xs text-muted-foreground\">({fileSize(file.size, t)})</span>\n </a>\n <AttachmentPreviewButton file={file} />\n </>\n )\n}\n\nexport function ResourceValue({\n field,\n row,\n related,\n lookups,\n}: {\n field: ResourceField\n row: SerializedRecord\n related?: Record<string, SerializedRecord[]>\n lookups?: LookupOptions\n}): ReactNode {\n const { calendar } = useUiPreferences()\n const { t, locale } = useMessages()\n const value = row[field.key]\n if (value === null || value === undefined || value === '' || (Array.isArray(value) && !value.length))\n return <span className=\"text-muted-foreground\">—</span>\n if (field.type === 'decimal' || field.type === 'percent')\n return (\n <span className=\"tabular-nums\" dir=\"ltr\">\n {decimalDisplay(value, decimalScale(field), locale)}\n {field.type === 'percent' && (\n <span className=\"text-muted-foreground\">{t(PERCENT_LABEL)}</span>\n )}\n </span>\n )\n // A string with `format` renders like the dedicated type.\n const kind = field.type === 'string' ? field.format : field.type\n if (kind === 'email' || kind === 'phone' || kind === 'url') {\n const href =\n kind === 'email' ? emailHref(value) : kind === 'phone' ? phoneHref(value) : safeUrl(value)\n if (!href) return <bdi dir=\"ltr\">{String(value)}</bdi>\n return (\n <a\n href={href}\n dir=\"ltr\"\n className=\"break-all text-primary underline-offset-4 hover:underline\"\n {...(kind === 'url' ? { target: '_blank', rel: 'noopener noreferrer' } : {})}\n >\n {String(value)}\n </a>\n )\n }\n if (field.type === 'multiSelect' && Array.isArray(value))\n return (\n <span className=\"flex flex-wrap gap-1\">\n {value.map((entry) => (\n <Badge key={String(entry)} variant=\"secondary\" className=\"font-normal\">\n {optionLabel(field, String(entry), locale)}\n </Badge>\n ))}\n </span>\n )\n if (field.type === 'manyToMany')\n return (\n <span className=\"flex flex-wrap gap-1\">\n {linkedTitles(field, value, related).map((entry) => (\n <Badge key={entry.id} variant=\"outline\" className=\"font-normal\">\n {entry.title}\n </Badge>\n ))}\n </span>\n )\n if (field.type === 'attachment' && Array.isArray(value))\n return (\n <ul className=\"space-y-1\">\n {attachmentList(value).map((file) => (\n <li key={file.id} className=\"flex flex-wrap items-center gap-1\">\n <AttachmentLink file={file} />\n </li>\n ))}\n </ul>\n )\n if (field.type === 'attachment' && isAttachment(value))\n return (\n <span className=\"inline-flex flex-wrap items-center gap-1\">\n <AttachmentLink file={value} />\n </span>\n )\n if (field.type === 'boolean')\n return <Badge variant={value ? 'default' : 'secondary'}>{value ? t('نعم') : t('لا')}</Badge>\n if (field.type === 'money')\n return (\n <span className=\"tabular-nums\" dir=\"ltr\">\n {moneyDisplay(value)}{' '}\n <span className=\"text-xs text-muted-foreground\">{t(CURRENCY_LABEL)}</span>\n </span>\n )\n if (field.type === 'json')\n return (\n <pre dir=\"ltr\" className=\"max-h-64 overflow-auto rounded-md bg-muted p-3 text-xs\">\n {JSON.stringify(value, null, 2)}\n </pre>\n )\n if (field.type === 'integer')\n return (\n <span className=\"tabular-nums\" dir=\"ltr\">\n {displayValue(field, row, related, lookups, calendar, t, locale)}\n </span>\n )\n // Arabic dates carry Arabic month names and time markers; isolate them instead of forcing LTR.\n if (field.type === 'date' || field.type === 'datetime')\n return <bdi className=\"tabular-nums\">{displayValue(field, row, related, lookups, calendar, t, locale)}</bdi>\n return <>{displayValue(field, row, related, lookups, calendar, t, locale)}</>\n}\n",
|
|
17
19
|
"target": "inertia/components/ui/resource-value.tsx"
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
"path": "registry/ui/field_values.ts",
|
|
23
|
+
"type": "registry:ui",
|
|
24
|
+
"content": "import type { ResourceField } from 'adula'\n\n/**\n * Pure value helpers of the generated forms and values (decimal, percent, multi-value\n * fields, visibleWhen and safe links). They have no React or alias imports, so they are\n * shared by resource-field, resource-form and resource-value and tested directly.\n */\n\ntype Scalar = string | number | boolean | null\n\n/**\n * Arabic-Indic and Persian digits and the Arabic decimal separator to Latin. Commas (and the\n * Arabic thousands mark) are removed only when they group whole thousands, as in «1,234.5»;\n * any other comma, such as «1,5», stays and makes the number invalid instead of 15.\n */\nexport function toLatinDigits(raw: string) {\n const value = raw\n .replace(/[٠-٩]/g, (digit) => String('٠١٢٣٤٥٦٧٨٩'.indexOf(digit)))\n .replace(/[۰-۹]/g, (digit) => String('۰۱۲۳۴۵۶۷۸۹'.indexOf(digit)))\n .replaceAll('٫', '.')\n .replaceAll('٬', ',')\n .trim()\n return /^-?\\d{1,3}(,\\d{3})+(\\.\\d*)?$/.test(value) ? value.replaceAll(',', '') : value\n}\n\n/** Fractional digits of a decimal or percent field (the server default is 2). */\nexport function decimalScale(field: ResourceField) {\n return (field.type === 'decimal' || field.type === 'percent') && field.scale !== undefined\n ? field.scale\n : 2\n}\n\n/**\n * Typed decimal text to the canonical wire string with exactly `scale` digits, for example\n * «١٢٫٥» → \"12.50\". Errors carry the Arabic interface text.\n */\nexport function parseDecimal(raw: string, scale: number) {\n const value = toLatinDigits(raw)\n const match = /^(-?)(\\d*)(?:\\.(\\d*))?$/.exec(value)\n if (!match || (match[2] === '' && !match[3])) throw new Error('أدخل رقماً عشرياً صحيحاً')\n const [, sign, whole, fraction = ''] = match\n const significant = fraction.replace(/0+$/, '')\n if (significant.length > scale) throw new Error('عدد المنازل العشرية أكثر من المسموح')\n const integer = whole.replace(/^0+(?=\\d)/, '') || '0'\n const digits = scale ? `.${fraction.slice(0, scale).padEnd(scale, '0')}` : ''\n const canonical = `${integer}${digits}`\n return /^0(\\.0*)?$/.test(canonical) ? canonical : `${sign}${canonical}`\n}\n\n/** The input text of a stored decimal: the canonical string, or '' when empty. */\nexport function decimalInput(value: unknown, scale: number) {\n if (value === null || value === undefined || value === '') return ''\n try {\n return parseDecimal(String(value), scale)\n } catch {\n return String(value)\n }\n}\n\n/**\n * A decimal string formatted with the interface language and Latin digits. The string is\n * formatted exactly (no float rounding), so numeric(18, 2) values keep every digit.\n */\nexport function decimalDisplay(value: unknown, scale: number, language = 'ar') {\n if (value === null || value === undefined || value === '') return ''\n const format = new Intl.NumberFormat(`${language}-u-nu-latn`, {\n minimumFractionDigits: scale,\n maximumFractionDigits: scale,\n })\n // Intl formats numeric strings as exact decimals; the lib typing only names numbers.\n return format.format(String(value) as unknown as number)\n}\n\n/** Multi-value controls keep a JSON array of strings in the string form state. */\nexport function listValue(raw: string): string[] {\n if (!raw) return []\n try {\n const parsed: unknown = JSON.parse(raw)\n return Array.isArray(parsed) ? parsed.map(String) : []\n } catch {\n return []\n }\n}\n\nexport function listInput(values: unknown): string {\n if (!Array.isArray(values) || !values.length) return ''\n return JSON.stringify([...new Set(values.map(String))])\n}\n\n/** Selected option values in the definition's option order, as the server stores them. */\nexport function orderedSelection(options: readonly { value: string }[], selected: string[]) {\n const chosen = new Set(selected)\n return options.map((option) => option.value).filter((value) => chosen.has(value))\n}\n\n/**\n * Whether a field applies to the current form values (its `visibleWhen`). Every named\n * sibling must equal the value or one of the listed values; a multiSelect sibling must\n * contain it; `null` matches an empty sibling (no selection for a multiSelect). Both sides\n * compare canonically, as the server does (see canonicalValue). Use hiddenFields() for a\n * whole form: it also hides fields whose sibling is hidden.\n */\nexport function fieldApplies(\n field: Pick<ResourceField, 'visibleWhen'>,\n values: Record<string, string>,\n siblings: Readonly<Record<string, SiblingShape>> = {}\n) {\n if (!field.visibleWhen) return true\n return Object.entries(field.visibleWhen).every(([key, expected]) => {\n const sibling = siblings[key]\n const raw = values[key] ?? ''\n const accepted: Scalar[] = Array.isArray(expected) ? expected : [expected]\n if (sibling?.type === 'multiSelect' || sibling?.type === 'manyToMany') {\n const current = listValue(raw)\n return accepted.some((entry) =>\n entry === null ? current.length === 0 : current.includes(String(entry))\n )\n }\n const current = canonicalValue(raw, sibling)\n return accepted.some((entry) =>\n entry === null ? raw.trim() === '' : canonicalValue(String(entry), sibling) === current\n )\n })\n}\n\n/**\n * The fields that do not apply, resolved to a fixed point like the server's\n * applyVisibility: a hidden field counts as empty while its dependants are evaluated, so\n * in a chain C → B → A hiding A also hides B and then C.\n */\nexport function hiddenFields(\n fields: readonly (Pick<ResourceField, 'key' | 'visibleWhen'> & SiblingShape)[],\n values: Record<string, string>\n) {\n const siblings = siblingShapes(fields)\n const hidden = new Set<string>()\n // The same passes as the server: a field is cleared as soon as it is hidden.\n const current = { ...values }\n for (let pass = 0; pass <= fields.length; pass++) {\n let changed = false\n for (const field of fields) {\n if (hidden.has(field.key) || fieldApplies(field, current, siblings)) continue\n hidden.add(field.key)\n current[field.key] = ''\n changed = true\n }\n if (!changed) break\n }\n return hidden\n}\n\n/** What fieldApplies needs to know about a sibling field. */\nexport type SiblingShape = { type: string; scale?: number; format?: string }\n\n/** The comparison shape of every field, by key. */\nexport function siblingShapes(fields: readonly (SiblingShape & { key: string })[]) {\n return Object.fromEntries(\n fields.map((field) => [\n field.key,\n { type: field.type, scale: field.scale, format: field.format } satisfies SiblingShape,\n ])\n ) as Record<string, SiblingShape>\n}\n\n/**\n * The stored form of a sibling value, mirroring the server's normalization: e-mail trimmed\n * and lower-cased, phone with Latin digits and no separators (a leading + kept), URL\n * trimmed, decimal/percent at the sibling's scale («12.5» equals \"12.50\"), integers without\n * leading zeros, string fields trimmed (the server's validator trims them). Text is\n * compared as typed (the server does not trim it).\n */\nexport function canonicalValue(raw: string, sibling?: SiblingShape) {\n if (!sibling || raw.trim() === '') return raw\n const format = sibling.type === 'string' ? sibling.format : sibling.type\n if (format === 'email') return raw.trim().toLowerCase()\n if (format === 'phone') return toLatinDigits(raw.trim()).replace(/[\\s\\-().]/g, '')\n if (format === 'url' || sibling.type === 'string') return raw.trim()\n if (sibling.type === 'decimal' || sibling.type === 'percent') {\n try {\n return parseDecimal(raw, sibling.scale ?? 2)\n } catch {\n return raw.trim()\n }\n }\n if (sibling.type === 'integer') {\n const digits = toLatinDigits(raw)\n return /^-?\\d+$/.test(digits) ? String(BigInt(digits)) : raw.trim()\n }\n return raw\n}\n\n/** An absolute http(s) URL safe to link, or null (javascript:, data: and relative are refused). */\nexport function safeUrl(value: unknown) {\n if (typeof value !== 'string' || !/^https?:\\/\\//i.test(value.trim())) return null\n try {\n const url = new URL(value.trim())\n return url.protocol === 'http:' || url.protocol === 'https:' ? url.href : null\n } catch {\n return null\n }\n}\n\n/** A tel: link for a stored `+?digits` phone; other text gets no link. */\nexport function phoneHref(value: unknown) {\n const text = toLatinDigits(String(value ?? '')).replace(/[\\s().-]/g, '')\n return /^\\+?\\d{3,15}$/.test(text) ? `tel:${text}` : null\n}\n\n/** A mailto: link for a plain address; anything with spaces or several @ gets no link. */\nexport function emailHref(value: unknown) {\n const text = String(value ?? '').trim()\n return /^[^\\s@?#]+@[^\\s@?#]+$/.test(text) ? `mailto:${text}` : null\n}\n",
|
|
25
|
+
"target": "inertia/components/ui/field_values.ts"
|
|
18
26
|
}
|
|
19
27
|
],
|
|
20
28
|
"$schema": "https://ui.shadcn.com/schema/registry-item.json"
|
package/build/select.json
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
{
|
|
10
10
|
"path": "registry/ui/select.tsx",
|
|
11
11
|
"type": "registry:ui",
|
|
12
|
-
"content": "
|
|
12
|
+
"content": "import * as React from \"react\"\nimport { cn } from \"cn\"\nimport { CheckIcon, ChevronDownIcon, ChevronUpIcon } from \"lucide-react\"\nimport { Select as SelectPrimitive } from \"radix-ui\"\n\nfunction Select({\n ...props\n}: React.ComponentProps<typeof SelectPrimitive.Root>) {\n return <SelectPrimitive.Root dir=\"rtl\" data-slot=\"select\" {...props} />\n}\n\nfunction SelectGroup({\n ...props\n}: React.ComponentProps<typeof SelectPrimitive.Group>) {\n return <SelectPrimitive.Group data-slot=\"select-group\" {...props} />\n}\n\nfunction SelectValue({\n ...props\n}: React.ComponentProps<typeof SelectPrimitive.Value>) {\n return <SelectPrimitive.Value data-slot=\"select-value\" {...props} />\n}\n\nfunction SelectTrigger({\n className,\n size = \"default\",\n children,\n ...props\n}: React.ComponentProps<typeof SelectPrimitive.Trigger> & {\n size?: \"sm\" | \"default\"\n}) {\n return (\n <SelectPrimitive.Trigger\n data-slot=\"select-trigger\"\n data-size={size}\n className={cn(\n \"flex w-fit items-center justify-between gap-2 rounded-md border border-input bg-transparent px-3 py-2 text-sm whitespace-nowrap shadow-xs transition-[color,box-shadow] outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 data-[placeholder]:text-muted-foreground data-[size=default]:h-9 data-[size=sm]:h-8 *:data-[slot=select-value]:line-clamp-1 *:data-[slot=select-value]:flex *:data-[slot=select-value]:items-center *:data-[slot=select-value]:gap-2 dark:bg-input/30 dark:hover:bg-input/50 dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 [&_svg:not([class*='text-'])]:text-muted-foreground\",\n className\n )}\n {...props}\n >\n {children}\n <SelectPrimitive.Icon asChild>\n <ChevronDownIcon className=\"size-4 opacity-50\" />\n </SelectPrimitive.Icon>\n </SelectPrimitive.Trigger>\n )\n}\n\nfunction SelectContent({\n className,\n children,\n position = \"item-aligned\",\n align = \"center\",\n ...props\n}: React.ComponentProps<typeof SelectPrimitive.Content>) {\n return (\n <SelectPrimitive.Portal>\n <SelectPrimitive.Content\n data-slot=\"select-content\"\n className={cn(\n \"relative z-50 max-h-(--radix-select-content-available-height) min-w-[8rem] origin-(--radix-select-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-md border bg-popover text-popover-foreground shadow-md data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95\",\n position === \"popper\" &&\n \"data-[side=bottom]:translate-y-1 ltr:data-[side=left]:-translate-x-1 rtl:data-[side=left]:translate-x-1 ltr:data-[side=right]:translate-x-1 rtl:data-[side=right]:-translate-x-1 data-[side=top]:-translate-y-1\",\n className\n )}\n position={position}\n align={align}\n {...props}\n >\n <SelectScrollUpButton />\n <SelectPrimitive.Viewport\n className={cn(\n \"p-1\",\n position === \"popper\" &&\n \"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)] scroll-my-1\"\n )}\n >\n {children}\n </SelectPrimitive.Viewport>\n <SelectScrollDownButton />\n </SelectPrimitive.Content>\n </SelectPrimitive.Portal>\n )\n}\n\nfunction SelectLabel({\n className,\n ...props\n}: React.ComponentProps<typeof SelectPrimitive.Label>) {\n return (\n <SelectPrimitive.Label\n data-slot=\"select-label\"\n className={cn(\"px-2 py-1.5 text-xs text-muted-foreground\", className)}\n {...props}\n />\n )\n}\n\nfunction SelectItem({\n className,\n children,\n ...props\n}: React.ComponentProps<typeof SelectPrimitive.Item>) {\n return (\n <SelectPrimitive.Item\n data-slot=\"select-item\"\n className={cn(\n \"relative flex w-full cursor-default items-center gap-2 rounded-sm py-1.5 pe-8 ps-2 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 [&_svg:not([class*='text-'])]:text-muted-foreground *:[span]:last:flex *:[span]:last:items-center *:[span]:last:gap-2\",\n className\n )}\n {...props}\n >\n <span\n data-slot=\"select-item-indicator\"\n className=\"absolute end-2 flex size-3.5 items-center justify-center\"\n >\n <SelectPrimitive.ItemIndicator>\n <CheckIcon className=\"size-4\" />\n </SelectPrimitive.ItemIndicator>\n </span>\n <SelectPrimitive.ItemText>{children}</SelectPrimitive.ItemText>\n </SelectPrimitive.Item>\n )\n}\n\nfunction SelectSeparator({\n className,\n ...props\n}: React.ComponentProps<typeof SelectPrimitive.Separator>) {\n return (\n <SelectPrimitive.Separator\n data-slot=\"select-separator\"\n className={cn(\"pointer-events-none -mx-1 my-1 h-px bg-border\", className)}\n {...props}\n />\n )\n}\n\nfunction SelectScrollUpButton({\n className,\n ...props\n}: React.ComponentProps<typeof SelectPrimitive.ScrollUpButton>) {\n return (\n <SelectPrimitive.ScrollUpButton\n data-slot=\"select-scroll-up-button\"\n className={cn(\n \"flex cursor-default items-center justify-center py-1\",\n className\n )}\n {...props}\n >\n <ChevronUpIcon className=\"size-4\" />\n </SelectPrimitive.ScrollUpButton>\n )\n}\n\nfunction SelectScrollDownButton({\n className,\n ...props\n}: React.ComponentProps<typeof SelectPrimitive.ScrollDownButton>) {\n return (\n <SelectPrimitive.ScrollDownButton\n data-slot=\"select-scroll-down-button\"\n className={cn(\n \"flex cursor-default items-center justify-center py-1\",\n className\n )}\n {...props}\n >\n <ChevronDownIcon className=\"size-4\" />\n </SelectPrimitive.ScrollDownButton>\n )\n}\n\nexport {\n Select,\n SelectContent,\n SelectGroup,\n SelectItem,\n SelectLabel,\n SelectScrollDownButton,\n SelectScrollUpButton,\n SelectSeparator,\n SelectTrigger,\n SelectValue,\n}\n",
|
|
13
13
|
"target": "inertia/components/ui/select.tsx"
|
|
14
14
|
}
|
|
15
15
|
],
|
package/build/separator.json
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
{
|
|
10
10
|
"path": "registry/ui/separator.tsx",
|
|
11
11
|
"type": "registry:ui",
|
|
12
|
-
"content": "
|
|
12
|
+
"content": "import * as React from \"react\"\nimport { cn } from \"cn\"\nimport { Separator as SeparatorPrimitive } from \"radix-ui\"\n\nfunction Separator({\n className,\n orientation = \"horizontal\",\n decorative = true,\n ...props\n}: React.ComponentProps<typeof SeparatorPrimitive.Root>) {\n return (\n <SeparatorPrimitive.Root\n data-slot=\"separator\"\n decorative={decorative}\n orientation={orientation}\n className={cn(\n \"shrink-0 bg-border data-[orientation=horizontal]:h-px data-[orientation=horizontal]:w-full data-[orientation=vertical]:h-full data-[orientation=vertical]:w-px\",\n className\n )}\n {...props}\n />\n )\n}\n\nexport { Separator }\n",
|
|
13
13
|
"target": "inertia/components/ui/separator.tsx"
|
|
14
14
|
}
|
|
15
15
|
],
|
package/build/sheet.json
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
{
|
|
10
10
|
"path": "registry/ui/sheet.tsx",
|
|
11
11
|
"type": "registry:ui",
|
|
12
|
-
"content": "
|
|
12
|
+
"content": "import * as React from \"react\"\nimport { cn } from \"cn\"\nimport { XIcon } from \"lucide-react\"\nimport { Dialog as SheetPrimitive } from \"radix-ui\"\n\nfunction Sheet({ ...props }: React.ComponentProps<typeof SheetPrimitive.Root>) {\n return <SheetPrimitive.Root data-slot=\"sheet\" {...props} />\n}\n\nfunction SheetTrigger({\n ...props\n}: React.ComponentProps<typeof SheetPrimitive.Trigger>) {\n return <SheetPrimitive.Trigger data-slot=\"sheet-trigger\" {...props} />\n}\n\nfunction SheetClose({\n ...props\n}: React.ComponentProps<typeof SheetPrimitive.Close>) {\n return <SheetPrimitive.Close data-slot=\"sheet-close\" {...props} />\n}\n\nfunction SheetPortal({\n ...props\n}: React.ComponentProps<typeof SheetPrimitive.Portal>) {\n return <SheetPrimitive.Portal data-slot=\"sheet-portal\" {...props} />\n}\n\nfunction SheetOverlay({\n className,\n ...props\n}: React.ComponentProps<typeof SheetPrimitive.Overlay>) {\n return (\n <SheetPrimitive.Overlay\n data-slot=\"sheet-overlay\"\n className={cn(\n \"fixed inset-0 z-50 bg-black/50 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:animate-in data-[state=open]:fade-in-0\",\n className\n )}\n {...props}\n />\n )\n}\n\nfunction SheetContent({\n className,\n children,\n side = \"right\",\n showCloseButton = true,\n ...props\n}: React.ComponentProps<typeof SheetPrimitive.Content> & {\n side?: \"top\" | \"right\" | \"bottom\" | \"left\"\n showCloseButton?: boolean\n}) {\n return (\n <SheetPortal>\n <SheetOverlay />\n <SheetPrimitive.Content\n data-slot=\"sheet-content\"\n className={cn(\n \"fixed z-50 flex flex-col gap-4 bg-background shadow-lg transition ease-in-out data-[state=closed]:animate-out data-[state=closed]:duration-300 data-[state=open]:animate-in data-[state=open]:duration-500\",\n side === \"right\" &&\n \"inset-y-0 end-0 h-full w-3/4 border-s data-[state=closed]:slide-out-to-right data-[state=open]:slide-in-from-right sm:max-w-sm\",\n side === \"left\" &&\n \"inset-y-0 start-0 h-full w-3/4 border-e data-[state=closed]:slide-out-to-left data-[state=open]:slide-in-from-left sm:max-w-sm\",\n side === \"top\" &&\n \"inset-x-0 top-0 h-auto border-b data-[state=closed]:slide-out-to-top data-[state=open]:slide-in-from-top\",\n side === \"bottom\" &&\n \"inset-x-0 bottom-0 h-auto border-t data-[state=closed]:slide-out-to-bottom data-[state=open]:slide-in-from-bottom\",\n className\n )}\n {...props}\n >\n {children}\n {showCloseButton && (\n <SheetPrimitive.Close className=\"absolute top-4 end-4 rounded-xs opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:ring-2 focus:ring-ring focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none data-[state=open]:bg-secondary\">\n <XIcon className=\"size-4\" />\n <span className=\"sr-only\">إغلاق</span>\n </SheetPrimitive.Close>\n )}\n </SheetPrimitive.Content>\n </SheetPortal>\n )\n}\n\nfunction SheetHeader({ className, ...props }: React.ComponentProps<\"div\">) {\n return (\n <div\n data-slot=\"sheet-header\"\n className={cn(\"flex flex-col gap-1.5 p-4\", className)}\n {...props}\n />\n )\n}\n\nfunction SheetFooter({ className, ...props }: React.ComponentProps<\"div\">) {\n return (\n <div\n data-slot=\"sheet-footer\"\n className={cn(\"mt-auto flex flex-col gap-2 p-4\", className)}\n {...props}\n />\n )\n}\n\nfunction SheetTitle({\n className,\n ...props\n}: React.ComponentProps<typeof SheetPrimitive.Title>) {\n return (\n <SheetPrimitive.Title\n data-slot=\"sheet-title\"\n className={cn(\"font-semibold text-foreground\", className)}\n {...props}\n />\n )\n}\n\nfunction SheetDescription({\n className,\n ...props\n}: React.ComponentProps<typeof SheetPrimitive.Description>) {\n return (\n <SheetPrimitive.Description\n data-slot=\"sheet-description\"\n className={cn(\"text-sm text-muted-foreground\", className)}\n {...props}\n />\n )\n}\n\nexport {\n Sheet,\n SheetTrigger,\n SheetClose,\n SheetContent,\n SheetHeader,\n SheetFooter,\n SheetTitle,\n SheetDescription,\n}\n",
|
|
13
13
|
"target": "inertia/components/ui/sheet.tsx"
|
|
14
14
|
}
|
|
15
15
|
],
|
package/build/sonner.json
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
{
|
|
9
9
|
"path": "registry/ui/sonner.tsx",
|
|
10
10
|
"type": "registry:ui",
|
|
11
|
-
"content": "
|
|
11
|
+
"content": "import {\n CircleCheckIcon,\n InfoIcon,\n Loader2Icon,\n OctagonXIcon,\n TriangleAlertIcon,\n} from \"lucide-react\"\nimport { Toaster as Sonner, type ToasterProps } from \"sonner\"\n\nconst Toaster = ({ ...props }: ToasterProps) => {\n\n return (\n <Sonner\n theme=\"light\"\n dir=\"rtl\"\n className=\"toaster group\"\n icons={{\n success: <CircleCheckIcon className=\"size-4\" />,\n info: <InfoIcon className=\"size-4\" />,\n warning: <TriangleAlertIcon className=\"size-4\" />,\n error: <OctagonXIcon className=\"size-4\" />,\n loading: <Loader2Icon className=\"size-4 animate-spin\" />,\n }}\n style={\n {\n \"--normal-bg\": \"var(--popover)\",\n \"--normal-text\": \"var(--popover-foreground)\",\n \"--normal-border\": \"var(--border)\",\n \"--border-radius\": \"var(--radius)\",\n } as React.CSSProperties\n }\n {...props}\n />\n )\n}\n\nexport { Toaster }\n",
|
|
12
12
|
"target": "inertia/components/ui/sonner.tsx"
|
|
13
13
|
}
|
|
14
14
|
],
|
package/build/switch.json
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
{
|
|
10
10
|
"path": "registry/ui/switch.tsx",
|
|
11
11
|
"type": "registry:ui",
|
|
12
|
-
"content": "
|
|
12
|
+
"content": "import * as React from \"react\"\nimport { cn } from \"cn\"\nimport { Switch as SwitchPrimitive } from \"radix-ui\"\n\nfunction Switch({\n className,\n size = \"default\",\n ...props\n}: React.ComponentProps<typeof SwitchPrimitive.Root> & {\n size?: \"sm\" | \"default\"\n}) {\n return (\n <SwitchPrimitive.Root\n data-slot=\"switch\"\n data-size={size}\n className={cn(\n \"peer group/switch inline-flex shrink-0 items-center rounded-full border border-transparent shadow-xs transition-all outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 data-[size=default]:h-[1.15rem] data-[size=default]:w-8 data-[size=sm]:h-3.5 data-[size=sm]:w-6 data-[state=checked]:bg-primary data-[state=unchecked]:bg-input dark:data-[state=unchecked]:bg-input/80\",\n className\n )}\n {...props}\n >\n <SwitchPrimitive.Thumb\n data-slot=\"switch-thumb\"\n className={cn(\n \"pointer-events-none block rounded-full bg-background ring-0 transition-transform group-data-[size=default]/switch:size-4 group-data-[size=sm]/switch:size-3 ltr:data-[state=checked]:translate-x-[calc(100%-2px)] rtl:data-[state=checked]:-translate-x-[calc(100%-2px)] ltr:data-[state=unchecked]:translate-x-0 rtl:data-[state=unchecked]:-translate-x-0 dark:data-[state=checked]:bg-primary-foreground dark:data-[state=unchecked]:bg-foreground\"\n )}\n />\n </SwitchPrimitive.Root>\n )\n}\n\nexport { Switch }\n",
|
|
13
13
|
"target": "inertia/components/ui/switch.tsx"
|
|
14
14
|
}
|
|
15
15
|
],
|
package/build/table.json
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
{
|
|
9
9
|
"path": "registry/ui/table.tsx",
|
|
10
10
|
"type": "registry:ui",
|
|
11
|
-
"content": "
|
|
11
|
+
"content": "import * as React from \"react\"\nimport { cn } from \"cn\"\n\nfunction Table({ className, ...props }: React.ComponentProps<\"table\">) {\n return (\n <div\n data-slot=\"table-container\"\n className=\"relative w-full overflow-x-auto\"\n >\n <table\n data-slot=\"table\"\n className={cn(\"w-full caption-bottom text-sm\", className)}\n {...props}\n />\n </div>\n )\n}\n\nfunction TableHeader({ className, ...props }: React.ComponentProps<\"thead\">) {\n return (\n <thead\n data-slot=\"table-header\"\n className={cn(\"[&_tr]:border-b\", className)}\n {...props}\n />\n )\n}\n\nfunction TableBody({ className, ...props }: React.ComponentProps<\"tbody\">) {\n return (\n <tbody\n data-slot=\"table-body\"\n className={cn(\"[&_tr:last-child]:border-0\", className)}\n {...props}\n />\n )\n}\n\nfunction TableFooter({ className, ...props }: React.ComponentProps<\"tfoot\">) {\n return (\n <tfoot\n data-slot=\"table-footer\"\n className={cn(\n \"border-t bg-muted/50 font-medium [&>tr]:last:border-b-0\",\n className\n )}\n {...props}\n />\n )\n}\n\nfunction TableRow({ className, ...props }: React.ComponentProps<\"tr\">) {\n return (\n <tr\n data-slot=\"table-row\"\n className={cn(\n \"border-b transition-colors hover:bg-muted/50 has-aria-expanded:bg-muted/50 data-[state=selected]:bg-muted\",\n className\n )}\n {...props}\n />\n )\n}\n\nfunction TableHead({ className, ...props }: React.ComponentProps<\"th\">) {\n return (\n <th\n data-slot=\"table-head\"\n className={cn(\n \"h-10 px-2 text-start align-middle font-medium whitespace-nowrap text-foreground [&:has([role=checkbox])]:pe-0 [&>[role=checkbox]]:translate-y-[2px]\",\n className\n )}\n {...props}\n />\n )\n}\n\nfunction TableCell({ className, ...props }: React.ComponentProps<\"td\">) {\n return (\n <td\n data-slot=\"table-cell\"\n className={cn(\n \"p-2 align-middle whitespace-nowrap [&:has([role=checkbox])]:pe-0 [&>[role=checkbox]]:translate-y-[2px]\",\n className\n )}\n {...props}\n />\n )\n}\n\nfunction TableCaption({\n className,\n ...props\n}: React.ComponentProps<\"caption\">) {\n return (\n <caption\n data-slot=\"table-caption\"\n className={cn(\"mt-4 text-sm text-muted-foreground\", className)}\n {...props}\n />\n )\n}\n\nexport {\n Table,\n TableHeader,\n TableBody,\n TableFooter,\n TableHead,\n TableRow,\n TableCell,\n TableCaption,\n}\n",
|
|
12
12
|
"target": "inertia/components/ui/table.tsx"
|
|
13
13
|
}
|
|
14
14
|
],
|
package/build/tabs.json
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
{
|
|
11
11
|
"path": "registry/ui/tabs.tsx",
|
|
12
12
|
"type": "registry:ui",
|
|
13
|
-
"content": "
|
|
13
|
+
"content": "import * as React from \"react\"\nimport { cva, type VariantProps } from \"class-variance-authority\"\nimport { cn } from \"cn\"\nimport { Tabs as TabsPrimitive } from \"radix-ui\"\n\nfunction Tabs({\n className,\n orientation = \"horizontal\",\n ...props\n}: React.ComponentProps<typeof TabsPrimitive.Root>) {\n return (\n <TabsPrimitive.Root dir=\"rtl\"\n data-slot=\"tabs\"\n data-orientation={orientation}\n orientation={orientation}\n className={cn(\n \"group/tabs flex gap-2 data-[orientation=horizontal]:flex-col\",\n className\n )}\n {...props}\n />\n )\n}\n\nconst tabsListVariants = cva(\n \"group/tabs-list inline-flex w-fit items-center justify-center rounded-lg p-[3px] text-muted-foreground group-data-[orientation=horizontal]/tabs:h-9 group-data-[orientation=vertical]/tabs:h-fit group-data-[orientation=vertical]/tabs:flex-col data-[variant=line]:rounded-none\",\n {\n variants: {\n variant: {\n default: \"bg-muted\",\n line: \"gap-1 bg-transparent\",\n },\n },\n defaultVariants: {\n variant: \"default\",\n },\n }\n)\n\nfunction TabsList({\n className,\n variant = \"default\",\n ...props\n}: React.ComponentProps<typeof TabsPrimitive.List> &\n VariantProps<typeof tabsListVariants>) {\n return (\n <TabsPrimitive.List\n data-slot=\"tabs-list\"\n data-variant={variant}\n className={cn(tabsListVariants({ variant }), className)}\n {...props}\n />\n )\n}\n\nfunction TabsTrigger({\n className,\n ...props\n}: React.ComponentProps<typeof TabsPrimitive.Trigger>) {\n return (\n <TabsPrimitive.Trigger\n data-slot=\"tabs-trigger\"\n className={cn(\n \"relative inline-flex h-[calc(100%-1px)] flex-1 items-center justify-center gap-1.5 rounded-md border border-transparent px-2 py-1 text-sm font-medium whitespace-nowrap text-foreground/60 transition-all group-data-[orientation=vertical]/tabs:w-full group-data-[orientation=vertical]/tabs:justify-start hover:text-foreground focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-1 focus-visible:outline-ring disabled:pointer-events-none disabled:opacity-50 group-data-[variant=default]/tabs-list:data-[state=active]:shadow-sm group-data-[variant=line]/tabs-list:data-[state=active]:shadow-none dark:text-muted-foreground dark:hover:text-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4\",\n \"group-data-[variant=line]/tabs-list:bg-transparent group-data-[variant=line]/tabs-list:data-[state=active]:bg-transparent dark:group-data-[variant=line]/tabs-list:data-[state=active]:border-transparent dark:group-data-[variant=line]/tabs-list:data-[state=active]:bg-transparent\",\n \"data-[state=active]:bg-background data-[state=active]:text-foreground dark:data-[state=active]:border-input dark:data-[state=active]:bg-input/30 dark:data-[state=active]:text-foreground\",\n \"after:absolute after:bg-foreground after:opacity-0 after:transition-opacity group-data-[orientation=horizontal]/tabs:after:inset-x-0 group-data-[orientation=horizontal]/tabs:after:bottom-[-5px] group-data-[orientation=horizontal]/tabs:after:h-0.5 group-data-[orientation=vertical]/tabs:after:inset-y-0 group-data-[orientation=vertical]/tabs:after:-end-1 group-data-[orientation=vertical]/tabs:after:w-0.5 group-data-[variant=line]/tabs-list:data-[state=active]:after:opacity-100\",\n className\n )}\n {...props}\n />\n )\n}\n\nfunction TabsContent({\n className,\n ...props\n}: React.ComponentProps<typeof TabsPrimitive.Content>) {\n return (\n <TabsPrimitive.Content\n data-slot=\"tabs-content\"\n className={cn(\"flex-1 outline-none\", className)}\n {...props}\n />\n )\n}\n\nexport { Tabs, TabsList, TabsTrigger, TabsContent, tabsListVariants }\n",
|
|
14
14
|
"target": "inertia/components/ui/tabs.tsx"
|
|
15
15
|
}
|
|
16
16
|
],
|
package/build/tooltip.json
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
{
|
|
10
10
|
"path": "registry/ui/tooltip.tsx",
|
|
11
11
|
"type": "registry:ui",
|
|
12
|
-
"content": "
|
|
12
|
+
"content": "import * as React from \"react\"\nimport { cn } from \"cn\"\nimport { Tooltip as TooltipPrimitive } from \"radix-ui\"\n\nfunction TooltipProvider({\n delayDuration = 0,\n ...props\n}: React.ComponentProps<typeof TooltipPrimitive.Provider>) {\n return (\n <TooltipPrimitive.Provider\n data-slot=\"tooltip-provider\"\n delayDuration={delayDuration}\n {...props}\n />\n )\n}\n\nfunction Tooltip({\n ...props\n}: React.ComponentProps<typeof TooltipPrimitive.Root>) {\n return <TooltipPrimitive.Root data-slot=\"tooltip\" {...props} />\n}\n\nfunction TooltipTrigger({\n ...props\n}: React.ComponentProps<typeof TooltipPrimitive.Trigger>) {\n return <TooltipPrimitive.Trigger data-slot=\"tooltip-trigger\" {...props} />\n}\n\nfunction TooltipContent({\n className,\n sideOffset = 0,\n children,\n ...props\n}: React.ComponentProps<typeof TooltipPrimitive.Content>) {\n return (\n <TooltipPrimitive.Portal>\n <TooltipPrimitive.Content\n data-slot=\"tooltip-content\"\n sideOffset={sideOffset}\n className={cn(\n \"z-50 w-fit origin-(--radix-tooltip-content-transform-origin) animate-in rounded-md bg-foreground px-3 py-1.5 text-xs text-balance text-background fade-in-0 zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95\",\n className\n )}\n {...props}\n >\n {children}\n <TooltipPrimitive.Arrow className=\"z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px] bg-foreground fill-foreground\" />\n </TooltipPrimitive.Content>\n </TooltipPrimitive.Portal>\n )\n}\n\nexport { Tooltip, TooltipTrigger, TooltipContent, TooltipProvider }\n",
|
|
13
13
|
"target": "inertia/components/ui/tooltip.tsx"
|
|
14
14
|
}
|
|
15
15
|
],
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adula/ui",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.2.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"description": "Arabic RTL shadcn registry copied into AdonisJS applications",
|
|
@@ -15,6 +15,9 @@
|
|
|
15
15
|
"./package.json": "./package.json",
|
|
16
16
|
"./registry/*": "./build/*.json"
|
|
17
17
|
},
|
|
18
|
+
"devDependencies": {
|
|
19
|
+
"shadcn": "4.21.0"
|
|
20
|
+
},
|
|
18
21
|
"publishConfig": {
|
|
19
22
|
"access": "public",
|
|
20
23
|
"provenance": true
|
|
@@ -42,6 +45,6 @@
|
|
|
42
45
|
],
|
|
43
46
|
"scripts": {
|
|
44
47
|
"test": "node --test tests/*.test.mjs",
|
|
45
|
-
"build": "node ../../scripts/
|
|
48
|
+
"build": "node ../../scripts/ui-registry.mjs build"
|
|
46
49
|
}
|
|
47
50
|
}
|