@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
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "list-filters",
|
|
3
|
+
"type": "registry:ui",
|
|
4
|
+
"registryDependencies": [
|
|
5
|
+
"badge",
|
|
6
|
+
"button",
|
|
7
|
+
"checkbox",
|
|
8
|
+
"command",
|
|
9
|
+
"input",
|
|
10
|
+
"popover",
|
|
11
|
+
"resource-field",
|
|
12
|
+
"resource-value",
|
|
13
|
+
"messages"
|
|
14
|
+
],
|
|
15
|
+
"dependencies": [
|
|
16
|
+
"axios@1.19.0",
|
|
17
|
+
"lucide-react@1.47.0"
|
|
18
|
+
],
|
|
19
|
+
"files": [
|
|
20
|
+
{
|
|
21
|
+
"path": "registry/ui/list-filters.tsx",
|
|
22
|
+
"type": "registry:ui",
|
|
23
|
+
"content": "import { useEffect, useId, useRef, useState, type KeyboardEvent } from 'react'\nimport axios from 'axios'\nimport { ChevronDown, X } from 'lucide-react'\nimport type { CalendarPreference, ResourceField, ResourceList, SerializedRecord } from 'adula'\nimport { Badge } from '~/components/ui/badge'\nimport { Button } from '~/components/ui/button'\nimport { Checkbox } from '~/components/ui/checkbox'\nimport {\n Command,\n CommandEmpty,\n CommandGroup,\n CommandInput,\n CommandItem,\n CommandList,\n} from '~/components/ui/command'\nimport { Input } from '~/components/ui/input'\nimport { Popover, PopoverContent, PopoverTrigger } from '~/components/ui/popover'\nimport { FieldControl } from '~/components/ui/resource-field'\nimport { useMessages, type Translate } from '~/components/ui/messages'\nimport {\n CURRENCY_LABEL,\n PERCENT_LABEL,\n fieldOptions,\n formatDate,\n formatDatetime,\n inputValue,\n moneyDisplay,\n optionLabel,\n parseValue,\n relationLabel,\n type Option,\n} from '~/components/ui/resource-value'\nimport { decimalDisplay, decimalScale } from '~/components/ui/field_values'\nimport {\n FILTER_IN_LIMIT,\n choiceFilter,\n chosenValues,\n filterAllowed,\n filterMode,\n inclusiveDatetime,\n normalizeFilter,\n singleChoice,\n type FieldFilter,\n} from '~/components/ui/list_query'\n\n/** Labels of chosen related records, remembered so chips stay readable after a reload. */\nexport type FilterLabels = Record<string, Record<string, string>>\n\n/**\n * A bound or value as the user reads it: lookup or option label, record title, formatted\n * date, amount, decimal or percent.\n */\nexport function filterValueLabel(\n field: ResourceField,\n value: string,\n context: {\n options?: Option[]\n related?: SerializedRecord[]\n labels?: Record<string, string>\n calendar: CalendarPreference\n t: Translate\n /** The interface language of option labels and number formats; Arabic by default. */\n language?: string\n }\n) {\n const language = context.language ?? 'ar'\n switch (field.type) {\n case 'lookup':\n return context.options?.find((option) => option.value === value)?.label ?? value\n case 'enum':\n case 'multiSelect':\n return optionLabel(field, value, language)\n case 'boolean':\n return value === 'true' ? context.t('نعم') : context.t('لا')\n case 'belongsTo':\n case 'user':\n case 'manyToMany': {\n const row = context.related?.find((item) => String(item.id) === value)\n return context.labels?.[value] ?? (row ? relationLabel(row, value) : `#${value}`)\n }\n case 'money':\n return `${moneyDisplay(value)} ${context.t(CURRENCY_LABEL)}`\n case 'decimal':\n return decimalDisplay(value, decimalScale(field), language)\n case 'percent':\n return `${decimalDisplay(value, decimalScale(field), language)}${context.t(PERCENT_LABEL)}`\n case 'date':\n return formatDate(value, context.calendar)\n case 'datetime':\n return formatDatetime(value, context.calendar)\n default:\n return value\n }\n}\n\n/** The chip text of one active filter, without the field label. */\nexport function describeFilter(filter: FieldFilter, value: (raw: string) => string, t: Translate) {\n switch (filter.op) {\n case 'eq':\n return value(filter.value)\n case 'in':\n return filter.values.map(value).join(t('، '))\n case 'range':\n if (filter.gte && filter.lte)\n return t('من {from} إلى {to}', {\n from: value(filter.gte),\n to: value(filter.lte),\n })\n return filter.gte\n ? t('من {from}', { from: value(filter.gte) })\n : t('إلى {to}', { to: value(filter.lte ?? '') })\n case 'empty':\n return filter.empty ? t('فارغ') : t('غير فارغ')\n }\n}\n\n/**\n * One field's filter: «أيٌّ من» for lookups, options, text and related records, «يحتوي على»\n * one option or linked record for multiSelect and manyToMany, «من / إلى» for numbers,\n * amounts, decimals, percents and dates, نعم/لا for booleans and «فارغ / غير فارغ» for\n * every field. Changes stay a draft until «تطبيق».\n */\nexport function FilterControl({\n resource,\n field,\n filter,\n options,\n related,\n labels,\n onRemember,\n onApply,\n}: {\n resource: string\n field: ResourceField\n filter?: FieldFilter\n options?: Option[]\n related?: SerializedRecord[]\n labels?: Record<string, string>\n onRemember?: (choices: Option[]) => void\n onApply: (filter: FieldFilter | null) => void\n}) {\n const { t, label, locale } = useMessages()\n const [open, setOpen] = useState(false)\n const [draft, setDraft] = useState<FieldFilter | null>(filter ?? null)\n const [error, setError] = useState('')\n const mode = filterMode(field.type)\n const name = label(field.label)\n const id = `filter-${field.key}`\n const count = filter?.op === 'in' ? filter.values.length : filter ? 1 : 0\n const apply = (next: FieldFilter | null) => {\n setError('')\n if (next?.op === 'in' && next.values.length > FILTER_IN_LIMIT) {\n setError(t('يمكن اختيار {count} قيمة كحد أقصى.', { count: FILTER_IN_LIMIT }))\n return\n }\n if (next && !filterAllowed(field.type, next)) {\n setError(t('لا يدعم هذا الحقل هذا النوع من التصفية.'))\n return\n }\n setOpen(false)\n onApply(normalizeFilter(next))\n }\n const empty = draft?.op === 'empty' ? draft.empty : null\n return (\n <Popover\n open={open}\n onOpenChange={(next) => {\n setOpen(next)\n if (next) {\n setDraft(filter ?? null)\n setError('')\n }\n }}\n >\n <PopoverTrigger asChild>\n <Button\n id={id}\n type=\"button\"\n variant=\"outline\"\n size=\"sm\"\n aria-label={t('تصفية {field}', { field: name })}\n className={`h-9 gap-2 text-xs font-normal ${filter ? 'border-primary/60' : ''}`}\n >\n {name}\n {count > 0 && (\n <Badge variant=\"secondary\" className=\"h-5 px-1.5 tabular-nums\">\n {count}\n </Badge>\n )}\n <ChevronDown className=\"opacity-50\" />\n </Button>\n </PopoverTrigger>\n <PopoverContent className=\"w-72 p-0\" align=\"start\">\n <div className=\"border-b px-3 py-2 text-xs font-medium\">\n {t('تصفية {field}', { field: name })}\n </div>\n <div className=\"p-3\">\n {mode === 'boolean' ? (\n <div role=\"group\" aria-label={name} className=\"flex gap-2\">\n {(['true', 'false'] as const).map((value) => {\n const on = draft?.op === 'eq' && draft.value === value\n return (\n <Button\n key={value}\n type=\"button\"\n size=\"sm\"\n variant={on ? 'default' : 'outline'}\n aria-pressed={on}\n className=\"flex-1\"\n onClick={() => setDraft(on ? null : { op: 'eq', value })}\n >\n {value === 'true' ? t('نعم') : t('لا')}\n </Button>\n )\n })}\n </div>\n ) : mode === 'range' ? (\n <RangeInputs\n field={field}\n filter={draft?.op === 'range' ? draft : undefined}\n onChange={(next) => setDraft(next)}\n onError={setError}\n />\n ) : mode === 'choice' && LISTED.has(field.type) ? (\n <ChoiceList\n resource={resource}\n field={field}\n values={chosenValues(draft ?? undefined)}\n options={\n field.type === 'enum' || field.type === 'multiSelect'\n ? fieldOptions(field, locale)\n : options\n }\n related={related}\n labels={labels}\n onRemember={onRemember}\n onChange={(values) => setDraft(choiceFilter(field.type, values))}\n />\n ) : mode === 'choice' ? (\n <TextValues\n name={name}\n values={chosenValues(draft ?? undefined)}\n onChange={(values) => setDraft({ op: 'in', values })}\n />\n ) : (\n <Input\n aria-label={t('قيمة {field}', { field: name })}\n className=\"h-9 text-xs\"\n value={draft?.op === 'eq' ? draft.value : ''}\n onChange={(event) => setDraft({ op: 'eq', value: event.target.value })}\n onKeyDown={(event) => {\n if (event.key === 'Enter') {\n event.preventDefault()\n apply(draft)\n }\n }}\n />\n )}\n <div\n role=\"group\"\n aria-label={t('القيم الفارغة')}\n className=\"mt-3 flex gap-2 border-t pt-3\"\n >\n {[true, false].map((value) => (\n <Button\n key={String(value)}\n type=\"button\"\n size=\"sm\"\n variant={empty === value ? 'secondary' : 'ghost'}\n aria-pressed={empty === value}\n className=\"h-7 flex-1 text-xs\"\n onClick={() => setDraft(empty === value ? null : { op: 'empty', empty: value })}\n >\n {value ? t('فارغ') : t('غير فارغ')}\n </Button>\n ))}\n </div>\n {error && (\n <p role=\"alert\" className=\"mt-2 text-xs text-destructive\">\n {error}\n </p>\n )}\n </div>\n <div className=\"flex justify-between gap-2 border-t px-3 py-2\">\n <Button type=\"button\" variant=\"ghost\" size=\"sm\" onClick={() => apply(null)}>\n {t('إزالة التصفية')}\n </Button>\n <Button type=\"button\" size=\"sm\" onClick={() => apply(draft)}>\n {t('تطبيق')}\n </Button>\n </div>\n </PopoverContent>\n </Popover>\n )\n}\n\n/** Choice fields whose values come from a list: lookups, options or related records. */\nconst LISTED = new Set(['lookup', 'enum', 'multiSelect', 'belongsTo', 'user', 'manyToMany'])\n/** Related records searched through the target resource's list route. */\nconst REMOTE = new Set(['belongsTo', 'user', 'manyToMany'])\n\n/**\n * Inclusive bounds; dates use the field's own control, so the calendar preference applies.\n * Numbers accept Arabic-Indic digits and the Arabic decimal separator (parseValue).\n */\nfunction RangeInputs({\n field,\n filter,\n onChange,\n onError,\n}: {\n field: ResourceField\n filter?: FieldFilter & { op: 'range' }\n onChange: (filter: FieldFilter | null) => void\n onError: (message: string) => void\n}) {\n const { t, label } = useMessages()\n const [text, setText] = useState({\n gte: filter?.gte ? inputValue(field, filter.gte) : '',\n lte: filter?.lte ? inputValue(field, filter.lte) : '',\n })\n const bound = (raw: string, side: 'gte' | 'lte') => {\n const parsed = parseValue(field, field.type === 'datetime' ? inclusiveDatetime(raw, side) : raw)\n return parsed === null || parsed === undefined ? undefined : String(parsed)\n }\n const change = (side: 'gte' | 'lte', raw: string) => {\n const next = { ...text, [side]: raw }\n setText(next)\n try {\n onError('')\n onChange({ op: 'range', gte: bound(next.gte, 'gte'), lte: bound(next.lte, 'lte') })\n } catch (error) {\n // Keep partial input; the previous valid bounds stay in the draft.\n onError(error instanceof Error ? t(error.message) : t('قيمة غير صالحة'))\n }\n }\n const name = label(field.label)\n const dated = field.type === 'date' || field.type === 'datetime'\n return (\n <div className=\"grid gap-3\">\n {(['gte', 'lte'] as const).map((side) => {\n const caption = side === 'gte' ? t('من') : t('إلى')\n const id = `filter-${field.key}-${side}`\n return (\n <label key={side} htmlFor={id} className=\"grid gap-1 text-xs text-muted-foreground\">\n {caption}\n {dated ? (\n <FieldControl\n field={field}\n id={id}\n value={text[side]}\n label={t('{bound} · {field}', { bound: caption, field: name })}\n onChange={(raw) => change(side, raw)}\n />\n ) : (\n <Input\n id={id}\n dir=\"ltr\"\n inputMode={field.type === 'integer' ? 'numeric' : 'decimal'}\n className=\"h-9 text-xs tabular-nums\"\n value={text[side]}\n onChange={(event) => change(side, event.target.value)}\n />\n )}\n </label>\n )\n })}\n </div>\n )\n}\n\n/**\n * «أيٌّ من»: lookup or field options, or related records searched through the server. A\n * multiSelect or manyToMany filter is «يحتوي على» one option or record.\n */\nfunction ChoiceList({\n resource,\n field,\n values,\n options,\n related = [],\n labels = {},\n onRemember,\n onChange,\n}: {\n resource: string\n field: ResourceField\n values: string[]\n options?: Option[]\n related?: SerializedRecord[]\n labels?: Record<string, string>\n onRemember?: (choices: Option[]) => void\n onChange: (values: string[]) => void\n}) {\n const { t, label } = useMessages()\n const remote = REMOTE.has(field.type)\n const single = singleChoice(field.type)\n const [term, setTerm] = useState('')\n const [found, setFound] = useState<Option[] | null>(null)\n const [busy, setBusy] = useState(false)\n const timer = useRef<ReturnType<typeof setTimeout>>(undefined)\n const listId = useId()\n const load = async (search: string) => {\n setBusy(true)\n try {\n let choices: Option[]\n if (field.type === 'user') {\n const users = await axios.get<{ data: Option[] }>(\n `/resources/${resource}/options/${field.key}`,\n {\n params: { purpose: 'filter', ...(search ? { search } : {}) },\n headers: { Accept: 'application/json' },\n }\n )\n choices = users.data.data\n } else {\n const target = (field as ResourceField & { resource?: string }).resource\n const response = await axios.get<ResourceList>(`/resources/${target}`, {\n params: {\n limit: 50,\n estimate: 'false',\n ...(search ? { search } : {}),\n },\n headers: { Accept: 'application/json' },\n })\n choices = response.data.data.map((row) => ({\n value: String(row.id),\n label: relationLabel(row, row.id),\n }))\n }\n setFound(choices)\n onRemember?.(choices)\n } catch {\n setFound([])\n } finally {\n setBusy(false)\n }\n }\n // The list mounts when the popover opens; related records load once per opening.\n const first = useRef(load)\n useEffect(() => {\n if (remote) void first.current('')\n }, [remote])\n const known = new Map<string, string>()\n for (const row of related) known.set(String(row.id), relationLabel(row, row.id))\n for (const [value, text] of Object.entries(labels)) known.set(value, text)\n const base = remote ? (found ?? []) : (options ?? [])\n // Chosen values stay listed even when the current search does not return them.\n const listed = [\n ...values\n .filter((value) => !base.some((option) => option.value === value))\n .map((value) => ({ value, label: known.get(value) ?? `#${value}` })),\n ...base.filter((option) => String(option.value) !== ''),\n ]\n const toggle = (value: string) =>\n onChange(\n values.includes(value) ? values.filter((entry) => entry !== value) : [...values, value]\n )\n return (\n <div className=\"grid gap-2\">\n <span className=\"text-xs text-muted-foreground\">\n {single ? t('يحتوي على') : t('أيٌّ من')}\n </span>\n <Command shouldFilter={!remote} className=\"rounded-md border\">\n <CommandInput\n placeholder={remote ? t('ابحث في السجلات المرتبطة') : t('ابحث في الخيارات')}\n aria-label={t('البحث في {field}', { field: label(field.label) })}\n value={term}\n onValueChange={(next) => {\n setTerm(next)\n if (!remote) return\n clearTimeout(timer.current)\n timer.current = setTimeout(() => void load(next), 300)\n }}\n />\n <CommandList id={listId} className=\"max-h-56\">\n <CommandEmpty>{busy ? t('جارٍ البحث...') : t('لا توجد خيارات مطابقة')}</CommandEmpty>\n <CommandGroup>\n {listed.map((option) => {\n const on = values.includes(option.value)\n return (\n <CommandItem\n key={option.value}\n value={remote ? option.value : `${option.label} ${option.value}`}\n aria-checked={on}\n onSelect={() => toggle(option.value)}\n >\n <Checkbox\n checked={on}\n tabIndex={-1}\n aria-hidden\n className=\"pointer-events-none\"\n />\n <span className=\"truncate\">{option.label}</span>\n </CommandItem>\n )\n })}\n </CommandGroup>\n </CommandList>\n </Command>\n </div>\n )\n}\n\n/** «أيٌّ من» for free text: Enter adds a value; each value is removable. */\nfunction TextValues({\n name,\n values,\n onChange,\n}: {\n name: string\n values: string[]\n onChange: (values: string[]) => void\n}) {\n const { t } = useMessages()\n const [text, setText] = useState('')\n const add = (event: KeyboardEvent<HTMLInputElement>) => {\n if (event.key !== 'Enter') return\n event.preventDefault()\n const value = text.trim()\n if (value && !values.includes(value)) onChange([...values, value])\n setText('')\n }\n return (\n <div className=\"grid gap-2\">\n <span className=\"text-xs text-muted-foreground\">{t('أيٌّ من')}</span>\n <Input\n aria-label={t('قيمة {field}', { field: name })}\n className=\"h-9 text-xs\"\n value={text}\n placeholder={t('اكتب قيمة ثم اضغط Enter')}\n onChange={(event) => setText(event.target.value)}\n onKeyDown={add}\n />\n {values.length > 0 && (\n <ul className=\"flex flex-wrap gap-1\">\n {values.map((value) => (\n <li key={value}>\n <Badge variant=\"secondary\" className=\"gap-1 font-normal\">\n {value}\n <button\n type=\"button\"\n aria-label={t('إزالة {value}', { value })}\n className=\"text-muted-foreground hover:text-foreground\"\n onClick={() => onChange(values.filter((entry) => entry !== value))}\n >\n <X size={12} />\n </button>\n </Badge>\n </li>\n ))}\n </ul>\n )}\n </div>\n )\n}\n",
|
|
24
|
+
"target": "inertia/components/ui/list-filters.tsx"
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
"path": "registry/ui/list_query.ts",
|
|
28
|
+
"type": "registry:ui",
|
|
29
|
+
"content": "export const FILTER_IN_LIMIT = 50\nexport const BULK_LIMIT = 100\n/*\n * List query helpers shared by the data table (ADR 046): operator filters in the URL,\n * saved-view round trips, the server export link and server error messages. Pure and\n * import-free so the registry tests run it directly.\n */\n\n/** One active filter of a field; `eq` is the scalar equality the list always accepted. */\nexport type FieldFilter =\n | { op: 'eq'; value: string }\n | { op: 'in'; values: string[] }\n | { op: 'range'; gte?: string; lte?: string }\n | { op: 'empty'; empty: boolean }\n\n/** The shape a saved view stores for one field: a scalar or one operator object. */\nexport type SavedFilterValue =\n | string\n | number\n | boolean\n | null\n | { in: (string | number)[] }\n | { gte?: string | number; lte?: string | number }\n | { empty: boolean }\n\n/** How the filter control of a field type behaves. */\nexport type FilterMode = 'choice' | 'range' | 'boolean' | 'text'\n\nconst CHOICE = new Set([\n 'lookup',\n 'enum',\n 'belongsTo',\n 'user',\n 'string',\n 'text',\n 'email',\n 'phone',\n 'url',\n 'multiSelect',\n 'manyToMany',\n])\nconst RANGE = new Set(['integer', 'money', 'decimal', 'percent', 'date', 'datetime'])\n/** Several values per record: the server matches one member (equality) or emptiness only. */\nconst MEMBER = new Set(['multiSelect', 'manyToMany'])\n\nexport function filterMode(type: string): FilterMode {\n if (type === 'boolean') return 'boolean'\n if (RANGE.has(type)) return 'range'\n if (CHOICE.has(type)) return 'choice'\n return 'text'\n}\n\n/** Whether a choice filter picks one member (multiSelect, manyToMany) instead of «أيٌّ من». */\nexport function singleChoice(type: string) {\n return MEMBER.has(type)\n}\n\n/**\n * The draft of a choice control: «أيٌّ من» is `in`; a member filter keeps only the latest\n * choice as equality, since the server accepts no `in` for several-valued fields.\n */\nexport function choiceFilter(type: string, values: string[]): FieldFilter | null {\n const chosen = values.filter(Boolean)\n if (!singleChoice(type)) return { op: 'in', values: chosen }\n const last = chosen.at(-1)\n return last ? { op: 'eq', value: last } : null\n}\n\n/**\n * Whether the filter controls emit this operator for the field type, each one the server\n * accepts (ADR 046): `in` for choices except member fields, ranges for numbers and dates,\n * equality and emptiness for every type.\n */\nexport function filterAllowed(type: string, filter: FieldFilter) {\n switch (filter.op) {\n case 'eq':\n case 'empty':\n return true\n case 'in':\n return filterMode(type) === 'choice' && !singleChoice(type)\n case 'range':\n return filterMode(type) === 'range'\n }\n}\n\nconst prefix = (key: string) => `filters[${key}]`\n\n/** Reads the filters of the given field keys from the list URL. */\nexport function readFilters(params: URLSearchParams, keys: string[]) {\n const filters: Record<string, FieldFilter> = {}\n for (const key of keys) {\n const base = prefix(key)\n const empty = params.get(`${base}[empty]`)\n const list = params.getAll(`${base}[in][]`)\n const joined = params.get(`${base}[in]`)\n const gte = params.get(`${base}[gte]`)\n const lte = params.get(`${base}[lte]`)\n const value = params.get(base)\n if (empty === 'true' || empty === 'false')\n filters[key] = { op: 'empty', empty: empty === 'true' }\n else if (list.length || joined) {\n const values = (list.length ? list : joined!.split(','))\n .map((entry) => entry.trim())\n .filter(Boolean)\n if (values.length) filters[key] = { op: 'in', values }\n } else if (gte || lte)\n filters[key] = {\n op: 'range',\n ...(gte ? { gte } : {}),\n ...(lte ? { lte } : {}),\n }\n else if (value) filters[key] = { op: 'eq', value }\n }\n return filters\n}\n\n/** Removes every parameter of one field's filter, whatever its operator. */\nexport function clearFilter(params: URLSearchParams, key: string) {\n const base = prefix(key)\n for (const name of [...params.keys()])\n if (name === base || name.startsWith(`${base}[`)) params.delete(name)\n}\n\n/**\n * Writes one field's filter. A single choice stays plain equality; several are\n * `[in]=a,b`, or repeated `[in][]` when a value itself contains a comma.\n */\nexport function writeFilter(params: URLSearchParams, key: string, filter: FieldFilter | null) {\n clearFilter(params, key)\n if (!filter) return\n const base = prefix(key)\n switch (filter.op) {\n case 'eq':\n if (filter.value) params.set(base, filter.value)\n return\n case 'in': {\n const values = [...new Set(filter.values.filter(Boolean))]\n if (values.length === 1) params.set(base, values[0])\n else if (values.some((value) => value.includes(',')))\n for (const value of values) params.append(`${base}[in][]`, value)\n else if (values.length) params.set(`${base}[in]`, values.join(','))\n return\n }\n case 'range':\n if (filter.gte) params.set(`${base}[gte]`, filter.gte)\n if (filter.lte) params.set(`${base}[lte]`, filter.lte)\n return\n case 'empty':\n params.set(`${base}[empty]`, String(filter.empty))\n }\n}\n\n/** A filter with nothing to apply (no values, no bounds) is no filter. */\nexport function normalizeFilter(filter: FieldFilter | null): FieldFilter | null {\n if (!filter) return null\n if (filter.op === 'eq') return filter.value ? filter : null\n if (filter.op === 'in') {\n const values = [...new Set(filter.values.filter(Boolean))]\n if (!values.length) return null\n return values.length === 1 ? { op: 'eq', value: values[0] } : { op: 'in', values }\n }\n if (filter.op === 'range') {\n if (!filter.gte && !filter.lte) return null\n return {\n op: 'range',\n ...(filter.gte ? { gte: filter.gte } : {}),\n ...(filter.lte ? { lte: filter.lte } : {}),\n }\n }\n return filter\n}\n\n/** The values a choice control shows as selected. */\nexport function chosenValues(filter: FieldFilter | undefined) {\n if (!filter) return []\n if (filter.op === 'eq') return [filter.value]\n if (filter.op === 'in') return filter.values\n return []\n}\n\nexport function toSavedFilter(filter: FieldFilter): SavedFilterValue {\n switch (filter.op) {\n case 'eq':\n return filter.value\n case 'in':\n return { in: filter.values }\n case 'range':\n return {\n ...(filter.gte ? { gte: filter.gte } : {}),\n ...(filter.lte ? { lte: filter.lte } : {}),\n }\n case 'empty':\n return { empty: filter.empty }\n }\n}\n\n/** Reads a stored saved-view value; anything unrecognised is dropped (null). */\nexport function fromSavedFilter(value: unknown): FieldFilter | null {\n if (value === null || value === undefined || value === '') return null\n if (['string', 'number', 'boolean'].includes(typeof value))\n return { op: 'eq', value: String(value) }\n if (typeof value !== 'object' || Array.isArray(value)) return null\n const entry = value as Record<string, unknown>\n if ('empty' in entry) {\n const empty = entry.empty\n if (empty === true || empty === 'true') return { op: 'empty', empty: true }\n if (empty === false || empty === 'false') return { op: 'empty', empty: false }\n return null\n }\n if ('in' in entry) {\n const list = Array.isArray(entry.in)\n ? entry.in\n : typeof entry.in === 'string'\n ? entry.in.split(',')\n : []\n return normalizeFilter({\n op: 'in',\n values: list.map((item) => String(item).trim()),\n })\n }\n if ('gte' in entry || 'lte' in entry) {\n const bound = (operand: unknown) =>\n operand === null || operand === undefined || operand === '' ? undefined : String(operand)\n return normalizeFilter({\n op: 'range',\n gte: bound(entry.gte),\n lte: bound(entry.lte),\n })\n }\n return null\n}\n\n/** `GET /resources/:name/export` with the list's query (search, filters, tag, sort) but no cursor. */\nexport function exportHref(resource: string, params: URLSearchParams) {\n const query = new URLSearchParams(params)\n query.delete('cursor')\n query.delete('limit')\n const suffix = query.toString()\n return `/resources/${resource}/export${suffix ? `?${suffix}` : ''}`\n}\n\n/** The `error.message` of an AdulaJS JSON error body (object, JSON text or nothing). */\nexport function serverMessage(data: unknown): string | null {\n let body = data\n if (typeof body === 'string') {\n try {\n body = JSON.parse(body)\n } catch {\n return null\n }\n }\n const message = (body as { error?: { message?: unknown } } | null)?.error?.message\n return typeof message === 'string' && message ? message : null\n}\n\n/** Selection helpers for bulk actions; ids are the string keys the table uses. */\nexport function toggleSelection(selected: Set<string>, id: string, on: boolean) {\n const next = new Set(selected)\n if (on) next.add(id)\n else next.delete(id)\n return next\n}\n\nexport function selectionState(selected: Set<string>, ids: string[]): boolean | 'indeterminate' {\n const count = ids.filter((id) => selected.has(id)).length\n if (!count) return false\n return count === ids.length ? true : 'indeterminate'\n}\n\n/** The bulk request body: numeric ids and the loaded rows' versions keyed by id. */\nexport function bulkPayload(\n action: string,\n ids: string[],\n rows: { id?: unknown; version?: unknown }[]\n) {\n const versions: Record<string, unknown> = {}\n const wanted = new Set(ids)\n for (const row of rows)\n if (wanted.has(String(row.id)) && row.version !== undefined && row.version !== null)\n versions[String(row.id)] = row.version\n return { action, ids: ids.map(Number), versions }\n}\n\n/**\n * A datetime range bound as typed (`YYYY-MM-DD` or `YYYY-MM-DDTHH:mm`, optionally `hijri:`)\n * made inclusive: «من» starts at the beginning of the chosen day or minute, «إلى» ends at\n * its last millisecond, so filtering «إلى ١ أكتوبر» keeps records of 1 October.\n */\nexport function inclusiveDatetime(raw: string, side: 'gte' | 'lte') {\n const value = raw.trim()\n if (!value) return value\n const [day, time] = value.split('T')\n if (!time) return `${day}T${side === 'gte' ? '00:00:00.000' : '23:59:59.999'}`\n if (/^\\d{2}:\\d{2}$/.test(time)) return `${day}T${time}${side === 'gte' ? ':00.000' : ':59.999'}`\n return value\n}\n",
|
|
30
|
+
"target": "inertia/components/ui/list_query.ts"
|
|
31
|
+
}
|
|
32
|
+
],
|
|
33
|
+
"$schema": "https://ui.shadcn.com/schema/registry-item.json"
|
|
34
|
+
}
|
package/build/manifest.json
CHANGED
|
@@ -1,216 +1,246 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "2.
|
|
3
|
-
"adulaCompatibility": "2.
|
|
2
|
+
"version": "2.2.0",
|
|
3
|
+
"adulaCompatibility": "2.2",
|
|
4
4
|
"items": [
|
|
5
5
|
{
|
|
6
6
|
"name": "button",
|
|
7
|
-
"version": "2.
|
|
7
|
+
"version": "2.2.0",
|
|
8
8
|
"hash": "cf1a045e41f5029fe9a8e3f3513a142dbe6550d6ffbe560b652a0aed1bb76f94"
|
|
9
9
|
},
|
|
10
10
|
{
|
|
11
11
|
"name": "input",
|
|
12
|
-
"version": "2.
|
|
12
|
+
"version": "2.2.0",
|
|
13
13
|
"hash": "5a398efe048aff90155d858e63290dee2b7ad31c060936ac5bfce5ecf691e022"
|
|
14
14
|
},
|
|
15
15
|
{
|
|
16
16
|
"name": "textarea",
|
|
17
|
-
"version": "2.
|
|
17
|
+
"version": "2.2.0",
|
|
18
18
|
"hash": "f0f615a9112e64ccb0d580d9325558c97750c24bcce933211acd2fa01c24b008"
|
|
19
19
|
},
|
|
20
20
|
{
|
|
21
21
|
"name": "select",
|
|
22
|
-
"version": "2.
|
|
23
|
-
"hash": "
|
|
22
|
+
"version": "2.2.0",
|
|
23
|
+
"hash": "18ee21eba11ffcff5ae395c7b3b6d98f46fb16c7ebfe9524702698ce3d28d2a8"
|
|
24
24
|
},
|
|
25
25
|
{
|
|
26
26
|
"name": "checkbox",
|
|
27
|
-
"version": "2.
|
|
28
|
-
"hash": "
|
|
27
|
+
"version": "2.2.0",
|
|
28
|
+
"hash": "cca8adce36cf2ec1ee0a931e94fde84b2cf99c5161aa0cdb64bfab9ddeeaccf2"
|
|
29
29
|
},
|
|
30
30
|
{
|
|
31
31
|
"name": "switch",
|
|
32
|
-
"version": "2.
|
|
33
|
-
"hash": "
|
|
32
|
+
"version": "2.2.0",
|
|
33
|
+
"hash": "e7c66890e466ce01de637cfbebd61e9419125d15455649026363402967424e58"
|
|
34
34
|
},
|
|
35
35
|
{
|
|
36
36
|
"name": "radio-group",
|
|
37
|
-
"version": "2.
|
|
38
|
-
"hash": "
|
|
37
|
+
"version": "2.2.0",
|
|
38
|
+
"hash": "812401f01905afba206becc0925a65ae74b55c94f355602051106f093d2d18e3"
|
|
39
39
|
},
|
|
40
40
|
{
|
|
41
41
|
"name": "table",
|
|
42
|
-
"version": "2.
|
|
43
|
-
"hash": "
|
|
42
|
+
"version": "2.2.0",
|
|
43
|
+
"hash": "b2510151b64e672f358deac23046e7f2a43ec6d8835006577ac93a05a4d30ac0"
|
|
44
44
|
},
|
|
45
45
|
{
|
|
46
46
|
"name": "form",
|
|
47
|
-
"version": "2.
|
|
48
|
-
"hash": "
|
|
47
|
+
"version": "2.2.0",
|
|
48
|
+
"hash": "dd62ca3716c521cba34e96bc85f9193165ca6ed7905b90d53b7be891515a304d"
|
|
49
49
|
},
|
|
50
50
|
{
|
|
51
51
|
"name": "label",
|
|
52
|
-
"version": "2.
|
|
53
|
-
"hash": "
|
|
52
|
+
"version": "2.2.0",
|
|
53
|
+
"hash": "011da9573b00b89c2209a30a17d400f9bc1bb77b25d1547f496a7a1bc9dd5093"
|
|
54
54
|
},
|
|
55
55
|
{
|
|
56
56
|
"name": "dialog",
|
|
57
|
-
"version": "2.
|
|
58
|
-
"hash": "
|
|
57
|
+
"version": "2.2.0",
|
|
58
|
+
"hash": "88a2bd1b5790bd79118bf99f2a8e6a65587da4cd1440fb14534ea3271098e6f3"
|
|
59
59
|
},
|
|
60
60
|
{
|
|
61
61
|
"name": "sheet",
|
|
62
|
-
"version": "2.
|
|
63
|
-
"hash": "
|
|
62
|
+
"version": "2.2.0",
|
|
63
|
+
"hash": "779c0787c8f32ea1c23046b31f75a631a1358c02e6737def284920469676bc68"
|
|
64
64
|
},
|
|
65
65
|
{
|
|
66
66
|
"name": "dropdown-menu",
|
|
67
|
-
"version": "2.
|
|
68
|
-
"hash": "
|
|
67
|
+
"version": "2.2.0",
|
|
68
|
+
"hash": "7b5ed94e71634435d99ea48e4dda3009f9d82f5ad7ecb14219156d729048660e"
|
|
69
69
|
},
|
|
70
70
|
{
|
|
71
71
|
"name": "popover",
|
|
72
|
-
"version": "2.
|
|
73
|
-
"hash": "
|
|
72
|
+
"version": "2.2.0",
|
|
73
|
+
"hash": "f6dc0a30f9054e5aab39b210f85f4a59e119ac6059290298e3e9ea4000266e05"
|
|
74
74
|
},
|
|
75
75
|
{
|
|
76
76
|
"name": "command",
|
|
77
|
-
"version": "2.
|
|
78
|
-
"hash": "
|
|
77
|
+
"version": "2.2.0",
|
|
78
|
+
"hash": "23a8649d95107efb19c88f4673c8465ee1260eb4ef2761129e20809ce36875ab"
|
|
79
79
|
},
|
|
80
80
|
{
|
|
81
81
|
"name": "calendar",
|
|
82
|
-
"version": "2.
|
|
83
|
-
"hash": "
|
|
82
|
+
"version": "2.2.0",
|
|
83
|
+
"hash": "146fe26176aaae0f6607d4a511bffa12ce530f4e70057821dbc54d463f04028e"
|
|
84
84
|
},
|
|
85
85
|
{
|
|
86
86
|
"name": "badge",
|
|
87
|
-
"version": "2.
|
|
87
|
+
"version": "2.2.0",
|
|
88
88
|
"hash": "08a668f461549c6edf7da629899d59373e7cae5686d1533fd5d451fbf7c2e33e"
|
|
89
89
|
},
|
|
90
90
|
{
|
|
91
91
|
"name": "card",
|
|
92
|
-
"version": "2.
|
|
92
|
+
"version": "2.2.0",
|
|
93
93
|
"hash": "0c7ac44916cc64285da5d8734fd34896a72cabecada2119b68f7f04ac6995b9a"
|
|
94
94
|
},
|
|
95
95
|
{
|
|
96
96
|
"name": "tabs",
|
|
97
|
-
"version": "2.
|
|
98
|
-
"hash": "
|
|
97
|
+
"version": "2.2.0",
|
|
98
|
+
"hash": "2307f8addf83b0ec102fda7f8c25957f0bf3a6f800790faed74969880ee4ce51"
|
|
99
99
|
},
|
|
100
100
|
{
|
|
101
101
|
"name": "sonner",
|
|
102
|
-
"version": "2.
|
|
103
|
-
"hash": "
|
|
102
|
+
"version": "2.2.0",
|
|
103
|
+
"hash": "bab1201bf8abbc1316ab0bb6140443e4451e92026b0a2fbd27b90323fdb6ff14"
|
|
104
104
|
},
|
|
105
105
|
{
|
|
106
106
|
"name": "skeleton",
|
|
107
|
-
"version": "2.
|
|
107
|
+
"version": "2.2.0",
|
|
108
108
|
"hash": "8dd2b789d3a4b70fb62a99922ef48ee7a0d23a7cda09b00cc1df49c8c29fac90"
|
|
109
109
|
},
|
|
110
110
|
{
|
|
111
111
|
"name": "pagination",
|
|
112
|
-
"version": "2.
|
|
113
|
-
"hash": "
|
|
112
|
+
"version": "2.2.0",
|
|
113
|
+
"hash": "c04e4d0e0f037136ed30cc2602ce2122e3ae65a866eb04b4ae26f218b58303d4"
|
|
114
114
|
},
|
|
115
115
|
{
|
|
116
116
|
"name": "tooltip",
|
|
117
|
-
"version": "2.
|
|
118
|
-
"hash": "
|
|
117
|
+
"version": "2.2.0",
|
|
118
|
+
"hash": "ba7a2b3d666f1848b063585c25bb87f16d2b46891f23ee0727992a63ba310540"
|
|
119
119
|
},
|
|
120
120
|
{
|
|
121
121
|
"name": "separator",
|
|
122
|
-
"version": "2.
|
|
123
|
-
"hash": "
|
|
122
|
+
"version": "2.2.0",
|
|
123
|
+
"hash": "12f949bd09fa730831cc500e15f2b3556779e1c840da70a57febae9580fed5f6"
|
|
124
124
|
},
|
|
125
125
|
{
|
|
126
126
|
"name": "alert",
|
|
127
|
-
"version": "2.
|
|
127
|
+
"version": "2.2.0",
|
|
128
128
|
"hash": "17940923e71122bb30d830c569e36e3886109cbfdfb405fd3954774fed1f0ead"
|
|
129
129
|
},
|
|
130
130
|
{
|
|
131
131
|
"name": "can",
|
|
132
|
-
"version": "2.
|
|
132
|
+
"version": "2.2.0",
|
|
133
133
|
"hash": "325cc32dac417e6001146ff59ba45b0c2231b672c92cebf389eaff378b82120c"
|
|
134
134
|
},
|
|
135
|
+
{
|
|
136
|
+
"name": "attachment-preview",
|
|
137
|
+
"version": "2.2.0",
|
|
138
|
+
"hash": "03caa15802b1f213b6257cc7529ae8447ff29baa6e528b264ba99d768a2420fe"
|
|
139
|
+
},
|
|
135
140
|
{
|
|
136
141
|
"name": "resource-value",
|
|
137
|
-
"version": "2.
|
|
138
|
-
"hash": "
|
|
142
|
+
"version": "2.2.0",
|
|
143
|
+
"hash": "b02159f7714492f5ec139e2413c2a5d4e543303cfceeb9f87e50144cc48d8ae1"
|
|
139
144
|
},
|
|
140
145
|
{
|
|
141
146
|
"name": "resource-field",
|
|
142
|
-
"version": "2.
|
|
143
|
-
"hash": "
|
|
147
|
+
"version": "2.2.0",
|
|
148
|
+
"hash": "177b2a326ea8b93fe73399f1aa272d51885d3b741b779f36b9e095ac21b17c82"
|
|
144
149
|
},
|
|
145
150
|
{
|
|
146
151
|
"name": "data-table",
|
|
147
|
-
"version": "2.
|
|
148
|
-
"hash": "
|
|
152
|
+
"version": "2.2.0",
|
|
153
|
+
"hash": "05c457d3c3e1357c61814be816090c3aa55f8e5a3813ab09dd403f3dacef1897"
|
|
149
154
|
},
|
|
150
155
|
{
|
|
151
156
|
"name": "resource-form",
|
|
152
|
-
"version": "2.
|
|
153
|
-
"hash": "
|
|
157
|
+
"version": "2.2.0",
|
|
158
|
+
"hash": "b5119cffcf45d5a01f3366be64cc5bea86bd18bb32e63bd49d3229e9dda2bbcb"
|
|
154
159
|
},
|
|
155
160
|
{
|
|
156
161
|
"name": "record-collaboration",
|
|
157
|
-
"version": "2.
|
|
158
|
-
"hash": "
|
|
162
|
+
"version": "2.2.0",
|
|
163
|
+
"hash": "6213c1b08634d3c083b314d3aa96ba04dca7ec6fdc82f4e5df0feb6c34345ad6"
|
|
159
164
|
},
|
|
160
165
|
{
|
|
161
166
|
"name": "record-assignments",
|
|
162
|
-
"version": "2.
|
|
167
|
+
"version": "2.2.0",
|
|
163
168
|
"hash": "3e19c7c033e80ed91952a33a23d604455874fe97e4d5b2a0012fcb1d6c30ec8c"
|
|
164
169
|
},
|
|
165
170
|
{
|
|
166
171
|
"name": "record-workflows",
|
|
167
|
-
"version": "2.
|
|
168
|
-
"hash": "
|
|
172
|
+
"version": "2.2.0",
|
|
173
|
+
"hash": "0be80ba205e6330ca1bae176a5ed6ec0d604c24a1ae8cb877929368637cea358"
|
|
174
|
+
},
|
|
175
|
+
{
|
|
176
|
+
"name": "record-print",
|
|
177
|
+
"version": "2.2.0",
|
|
178
|
+
"hash": "20caed486c5330f371e08e796f2c2b8196bc3da416ef571cdcf9041c57589159"
|
|
169
179
|
},
|
|
170
180
|
{
|
|
171
181
|
"name": "resource-show",
|
|
172
|
-
"version": "2.
|
|
173
|
-
"hash": "
|
|
182
|
+
"version": "2.2.0",
|
|
183
|
+
"hash": "cfd58be5deb67cd697188daf31a5085d9d4d214913443c9bb7fb663e7bc18d1f"
|
|
174
184
|
},
|
|
175
185
|
{
|
|
176
186
|
"name": "resource-import",
|
|
177
|
-
"version": "2.
|
|
178
|
-
"hash": "
|
|
187
|
+
"version": "2.2.0",
|
|
188
|
+
"hash": "68b6f4aa4e58ef82755aa58a9adcf699a8938c553a0d9e145d807b368f06ae9a"
|
|
179
189
|
},
|
|
180
190
|
{
|
|
181
191
|
"name": "resource-page",
|
|
182
|
-
"version": "2.
|
|
183
|
-
"hash": "
|
|
192
|
+
"version": "2.2.0",
|
|
193
|
+
"hash": "861e632166031bf99461e33d32f781e8e3ecd609924b54819f458234ce488b0a"
|
|
184
194
|
},
|
|
185
195
|
{
|
|
186
196
|
"name": "resource-actions",
|
|
187
|
-
"version": "2.
|
|
188
|
-
"hash": "
|
|
197
|
+
"version": "2.2.0",
|
|
198
|
+
"hash": "7ed22117ab7b826e73363d2856f0b7790a1daee42bdc6c29fe2155dbdc061934"
|
|
189
199
|
},
|
|
190
200
|
{
|
|
191
201
|
"name": "resource-surface",
|
|
192
|
-
"version": "2.
|
|
193
|
-
"hash": "
|
|
202
|
+
"version": "2.2.0",
|
|
203
|
+
"hash": "1b5cc33c23055f876c0edb8bd83fcd24622e756ac3d3e124452e297343e86c27"
|
|
194
204
|
},
|
|
195
205
|
{
|
|
196
206
|
"name": "ui-preferences",
|
|
197
|
-
"version": "2.
|
|
207
|
+
"version": "2.2.0",
|
|
198
208
|
"hash": "c5430a68726b1b01dd1259481fac4cd60ddfdd6cd986dc2c6fe63cc35e2d5cdb"
|
|
199
209
|
},
|
|
200
210
|
{
|
|
201
211
|
"name": "calendar-date",
|
|
202
|
-
"version": "2.
|
|
212
|
+
"version": "2.2.0",
|
|
203
213
|
"hash": "f166217803da3ae1beac2662f8c5528ea52c96b1fb4891dfc19b71090b345ff2"
|
|
204
214
|
},
|
|
215
|
+
{
|
|
216
|
+
"name": "messages",
|
|
217
|
+
"version": "2.2.0",
|
|
218
|
+
"hash": "bc1b8cfaa9cf2667e576b927b7b0cc4dd75de2555b1ad0b9bf73316d55fc3990"
|
|
219
|
+
},
|
|
205
220
|
{
|
|
206
221
|
"name": "hijri-calendar",
|
|
207
|
-
"version": "2.
|
|
208
|
-
"hash": "
|
|
222
|
+
"version": "2.2.0",
|
|
223
|
+
"hash": "45821450e1dc1e2418326b4fca36d4e1980a2ac08a096e92775b6bfc017cd16f"
|
|
209
224
|
},
|
|
210
225
|
{
|
|
211
226
|
"name": "confirm-action",
|
|
212
|
-
"version": "2.
|
|
213
|
-
"hash": "
|
|
227
|
+
"version": "2.2.0",
|
|
228
|
+
"hash": "b707040fc28ffd69902eb9f19b80aeb415b73f66cdfeff50c98c27f8cdc64bf8"
|
|
229
|
+
},
|
|
230
|
+
{
|
|
231
|
+
"name": "list-filters",
|
|
232
|
+
"version": "2.2.0",
|
|
233
|
+
"hash": "2d301d2ced7119c6be1cad65b64f6878b6d6ca4f09828251509cbf1552cfe29e"
|
|
234
|
+
},
|
|
235
|
+
{
|
|
236
|
+
"name": "resource-bulk",
|
|
237
|
+
"version": "2.2.0",
|
|
238
|
+
"hash": "f89781b2bfbbe9fb436a0b6ef4bc1cf310f2466f0041c2a05b7364545ed1a1b6"
|
|
239
|
+
},
|
|
240
|
+
{
|
|
241
|
+
"name": "resource-dashboard",
|
|
242
|
+
"version": "2.2.0",
|
|
243
|
+
"hash": "fc900f9934f9b6c27a2cc259141cb1d7dc57382c90e9342ea8e044d910af188e"
|
|
214
244
|
}
|
|
215
245
|
],
|
|
216
246
|
"dependencies": {
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "messages",
|
|
3
|
+
"type": "registry:ui",
|
|
4
|
+
"registryDependencies": [],
|
|
5
|
+
"dependencies": [],
|
|
6
|
+
"files": [
|
|
7
|
+
{
|
|
8
|
+
"path": "registry/ui/messages.ts",
|
|
9
|
+
"type": "registry:ui",
|
|
10
|
+
"content": "import { usePage } from '@inertiajs/react'\nimport { useMemo } from 'react'\nimport {\n createTranslator,\n localizedLabel,\n type InterfaceDirection,\n type InterfaceLanguage,\n type LocalizedLabel,\n} from '~/components/ui/message_format'\n\nexport {\n arabicText,\n createTranslator,\n interpolate,\n localizedLabel,\n type InterfaceDirection,\n type InterfaceLanguage,\n type LocalizedLabel,\n type MessageParams,\n type Translate,\n} from '~/components/ui/message_format'\n\ntype MessageProps = {\n locale?: string\n dir?: InterfaceDirection\n languages?: InterfaceLanguage[]\n messages?: Record<string, string>\n}\n\nconst none: Record<string, string> = {}\nconst arabicOnly: InterfaceLanguage[] = [{ code: 'ar', name: 'العربية', dir: 'rtl' }]\n\n/**\n * Interface text for the current user: `t('نص عربي', params)` and `label(field.label)`.\n * A consumer that does not share `locale`, `dir` and `messages` keeps rendering Arabic.\n */\nexport function useMessages() {\n const props = usePage<MessageProps>().props\n const locale = props.locale ?? 'ar'\n const dir = props.dir ?? 'rtl'\n const messages = props.messages ?? none\n return useMemo(\n () => ({\n locale,\n dir,\n t: createTranslator(messages),\n label: (value: LocalizedLabel) => localizedLabel(value, locale),\n }),\n [locale, dir, messages]\n )\n}\n\n/** The enabled interface languages, Arabic first; one entry when only Arabic is enabled. */\nexport function useLanguages(): InterfaceLanguage[] {\n return usePage<MessageProps>().props.languages ?? arabicOnly\n}\n",
|
|
11
|
+
"target": "inertia/components/ui/messages.ts"
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
"path": "registry/ui/message_format.ts",
|
|
15
|
+
"type": "registry:ui",
|
|
16
|
+
"content": "export type InterfaceDirection = 'rtl' | 'ltr'\nexport type InterfaceLanguage = { code: string; name: string; dir: InterfaceDirection }\n/** A resource or field label: Arabic is required, every other language is optional. */\nexport type LocalizedLabel = { ar: string; [language: string]: string | undefined }\nexport type MessageParams = Record<string, string | number>\nexport type Translate = (arabic: string, params?: MessageParams) => string\n\nconst none: Record<string, string> = {}\n\n/** Replaces `{name}` placeholders; an unknown placeholder is kept as written. */\nexport function interpolate(template: string, params?: MessageParams) {\n if (!params) return template\n return template.replace(/\\{(\\w+)\\}/g, (match, name: string) =>\n Object.hasOwn(params, name) ? String(params[name]) : match\n )\n}\n\n/**\n * Arabic is the base language: the interface text is the lookup key and is shown\n * unchanged when no translation exists (always the case for Arabic users).\n */\nexport function createTranslator(messages: Record<string, string> = none): Translate {\n return (arabic, params) =>\n interpolate(Object.hasOwn(messages, arabic) ? messages[arabic] : arabic, params)\n}\n\n/** The Arabic text with its placeholders filled, for helpers called outside components. */\nexport const arabicText: Translate = createTranslator()\n\n/** `label.<locale>` when present, otherwise the required Arabic label. */\nexport function localizedLabel(label: LocalizedLabel, locale: string) {\n return label[locale] || label.ar\n}\n",
|
|
17
|
+
"target": "inertia/components/ui/message_format.ts"
|
|
18
|
+
}
|
|
19
|
+
],
|
|
20
|
+
"$schema": "https://ui.shadcn.com/schema/registry-item.json"
|
|
21
|
+
}
|
package/build/pagination.json
CHANGED
|
@@ -5,13 +5,14 @@
|
|
|
5
5
|
"lucide-react@1.47.0"
|
|
6
6
|
],
|
|
7
7
|
"registryDependencies": [
|
|
8
|
-
"button"
|
|
8
|
+
"button",
|
|
9
|
+
"messages"
|
|
9
10
|
],
|
|
10
11
|
"files": [
|
|
11
12
|
{
|
|
12
13
|
"path": "registry/ui/pagination.tsx",
|
|
13
14
|
"type": "registry:ui",
|
|
14
|
-
"content": "import * as React from \"react\"\nimport { cn } from \"cn\"\nimport {\n ChevronLeftIcon,\n ChevronRightIcon,\n MoreHorizontalIcon,\n} from \"lucide-react\"\n\nimport { buttonVariants, type Button } from \"~/components/ui/button\"\n\nfunction Pagination({ className, ...props }: React.ComponentProps<\"nav\">) {\n return (\n <nav\n role=\"navigation\"\n aria-label
|
|
15
|
+
"content": "import * as React from \"react\"\nimport { cn } from \"cn\"\nimport {\n ChevronLeftIcon,\n ChevronRightIcon,\n MoreHorizontalIcon,\n} from \"lucide-react\"\n\nimport { buttonVariants, type Button } from \"~/components/ui/button\"\nimport { useMessages } from \"~/components/ui/messages\"\n\nfunction Pagination({ className, ...props }: React.ComponentProps<\"nav\">) {\n const { t } = useMessages()\n return (\n <nav\n role=\"navigation\"\n aria-label={t(\"التنقل بين الصفحات\")}\n data-slot=\"التنقل بين الصفحات\"\n className={cn(\"mx-auto flex w-full justify-center\", className)}\n {...props}\n />\n )\n}\n\nfunction PaginationContent({\n className,\n ...props\n}: React.ComponentProps<\"ul\">) {\n return (\n <ul\n data-slot=\"pagination-content\"\n className={cn(\"flex flex-row items-center gap-1\", className)}\n {...props}\n />\n )\n}\n\nfunction PaginationItem({ ...props }: React.ComponentProps<\"li\">) {\n return <li data-slot=\"pagination-item\" {...props} />\n}\n\ntype PaginationLinkProps = {\n isActive?: boolean\n} & Pick<React.ComponentProps<typeof Button>, \"size\"> &\n React.ComponentProps<\"a\">\n\nfunction PaginationLink({\n className,\n isActive,\n size = \"icon\",\n ...props\n}: PaginationLinkProps) {\n return (\n <a\n aria-current={isActive ? \"page\" : undefined}\n data-slot=\"pagination-link\"\n data-active={isActive}\n className={cn(\n buttonVariants({\n variant: isActive ? \"outline\" : \"ghost\",\n size,\n }),\n className\n )}\n {...props}\n />\n )\n}\n\nfunction PaginationPrevious({\n className,\n ...props\n}: React.ComponentProps<typeof PaginationLink>) {\n const { t } = useMessages()\n return (\n <PaginationLink\n aria-label={t(\"الصفحة السابقة\")}\n size=\"default\"\n className={cn(\"gap-1 px-2.5 sm:ps-2.5\", className)}\n {...props}\n >\n <ChevronLeftIcon className=\"rtl:rotate-180\" />\n <span className=\"hidden sm:block\">{t(\"السابق\")}</span>\n </PaginationLink>\n )\n}\n\nfunction PaginationNext({\n className,\n ...props\n}: React.ComponentProps<typeof PaginationLink>) {\n const { t } = useMessages()\n return (\n <PaginationLink\n aria-label={t(\"الصفحة التالية\")}\n size=\"default\"\n className={cn(\"gap-1 px-2.5 sm:pe-2.5\", className)}\n {...props}\n >\n <span className=\"hidden sm:block\">{t(\"التالي\")}</span>\n <ChevronRightIcon className=\"rtl:rotate-180\" />\n </PaginationLink>\n )\n}\n\nfunction PaginationEllipsis({\n className,\n ...props\n}: React.ComponentProps<\"span\">) {\n const { t } = useMessages()\n return (\n <span\n aria-hidden\n data-slot=\"pagination-ellipsis\"\n className={cn(\"flex size-9 items-center justify-center\", className)}\n {...props}\n >\n <MoreHorizontalIcon className=\"size-4\" />\n <span className=\"sr-only\">{t(\"صفحات أخرى\")}</span>\n </span>\n )\n}\n\nexport {\n Pagination,\n PaginationContent,\n PaginationLink,\n PaginationItem,\n PaginationPrevious,\n PaginationNext,\n PaginationEllipsis,\n}\n",
|
|
15
16
|
"target": "inertia/components/ui/pagination.tsx"
|
|
16
17
|
}
|
|
17
18
|
],
|
package/build/popover.json
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
{
|
|
10
10
|
"path": "registry/ui/popover.tsx",
|
|
11
11
|
"type": "registry:ui",
|
|
12
|
-
"content": "
|
|
12
|
+
"content": "import * as React from \"react\"\nimport { cn } from \"cn\"\nimport { Popover as PopoverPrimitive } from \"radix-ui\"\n\nfunction Popover({\n ...props\n}: React.ComponentProps<typeof PopoverPrimitive.Root>) {\n return <PopoverPrimitive.Root data-slot=\"popover\" {...props} />\n}\n\nfunction PopoverTrigger({\n ...props\n}: React.ComponentProps<typeof PopoverPrimitive.Trigger>) {\n return <PopoverPrimitive.Trigger data-slot=\"popover-trigger\" {...props} />\n}\n\nfunction PopoverContent({\n className,\n align = \"center\",\n sideOffset = 4,\n ...props\n}: React.ComponentProps<typeof PopoverPrimitive.Content>) {\n return (\n <PopoverPrimitive.Portal>\n <PopoverPrimitive.Content\n data-slot=\"popover-content\"\n align={align}\n sideOffset={sideOffset}\n className={cn(\n \"z-50 w-72 origin-(--radix-popover-content-transform-origin) rounded-md border bg-popover p-4 text-popover-foreground shadow-md outline-hidden 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 className\n )}\n {...props}\n />\n </PopoverPrimitive.Portal>\n )\n}\n\nfunction PopoverAnchor({\n ...props\n}: React.ComponentProps<typeof PopoverPrimitive.Anchor>) {\n return <PopoverPrimitive.Anchor data-slot=\"popover-anchor\" {...props} />\n}\n\nfunction PopoverHeader({ className, ...props }: React.ComponentProps<\"div\">) {\n return (\n <div\n data-slot=\"popover-header\"\n className={cn(\"flex flex-col gap-1 text-sm\", className)}\n {...props}\n />\n )\n}\n\nfunction PopoverTitle({ className, ...props }: React.ComponentProps<\"h2\">) {\n return (\n <div\n data-slot=\"popover-title\"\n className={cn(\"font-medium\", className)}\n {...props}\n />\n )\n}\n\nfunction PopoverDescription({\n className,\n ...props\n}: React.ComponentProps<\"p\">) {\n return (\n <p\n data-slot=\"popover-description\"\n className={cn(\"text-muted-foreground\", className)}\n {...props}\n />\n )\n}\n\nexport {\n Popover,\n PopoverTrigger,\n PopoverContent,\n PopoverAnchor,\n PopoverHeader,\n PopoverTitle,\n PopoverDescription,\n}\n",
|
|
13
13
|
"target": "inertia/components/ui/popover.tsx"
|
|
14
14
|
}
|
|
15
15
|
],
|
package/build/radio-group.json
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
{
|
|
10
10
|
"path": "registry/ui/radio-group.tsx",
|
|
11
11
|
"type": "registry:ui",
|
|
12
|
-
"content": "
|
|
12
|
+
"content": "import * as React from \"react\"\nimport { cn } from \"cn\"\nimport { CircleIcon } from \"lucide-react\"\nimport { RadioGroup as RadioGroupPrimitive } from \"radix-ui\"\n\nfunction RadioGroup({\n className,\n ...props\n}: React.ComponentProps<typeof RadioGroupPrimitive.Root>) {\n return (\n <RadioGroupPrimitive.Root dir=\"rtl\"\n data-slot=\"radio-group\"\n className={cn(\"grid gap-3\", className)}\n {...props}\n />\n )\n}\n\nfunction RadioGroupItem({\n className,\n ...props\n}: React.ComponentProps<typeof RadioGroupPrimitive.Item>) {\n return (\n <RadioGroupPrimitive.Item\n data-slot=\"radio-group-item\"\n className={cn(\n \"aspect-square size-4 shrink-0 rounded-full border border-input text-primary 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 dark:bg-input/30 dark:aria-invalid:ring-destructive/40\",\n className\n )}\n {...props}\n >\n <RadioGroupPrimitive.Indicator\n data-slot=\"radio-group-indicator\"\n className=\"relative flex items-center justify-center\"\n >\n <CircleIcon className=\"absolute top-1/2 start-1/2 size-2 ltr:-translate-x-1/2 rtl:translate-x-1/2 -translate-y-1/2 fill-primary\" />\n </RadioGroupPrimitive.Indicator>\n </RadioGroupPrimitive.Item>\n )\n}\n\nexport { RadioGroup, RadioGroupItem }\n",
|
|
13
13
|
"target": "inertia/components/ui/radio-group.tsx"
|
|
14
14
|
}
|
|
15
15
|
],
|