Added more agent skills

This commit is contained in:
2026-10-13 19:07:03 +02:00
parent 0ccc7e5064
commit 80d8b7102c
80 changed files with 2802 additions and 390 deletions
@@ -0,0 +1,39 @@
'use client'
import { useRowLabel } from '@payloadcms/ui'
export type RowLabelProps = {
/** Shown with the row number when every path is empty, e.g. "Button" → "Button 02". */
fallback?: string
/** Dot paths inside the row, tried in order — the first non-empty text wins. */
fields?: string[]
}
const at = (obj: unknown, path: string): unknown =>
path.split('.').reduce<unknown>((o, k) => (o && typeof o === 'object' ? (o as Record<string, unknown>)[k] : undefined), obj)
const toText = (v: unknown): string => {
if (typeof v === 'string') {return v.trim()}
if (typeof v === 'number') {return String(v)}
// populated relationship / upload → its title, name, filename or alt
if (v && typeof v === 'object') {
for (const k of ['title', 'name', 'label', 'alt', 'filename']) {
const t = (v as Record<string, unknown>)[k]
if (typeof t === 'string' && t.trim()) {return t.trim()}
}
}
return ''
}
/**
* Array row title in the admin panel: shows the row's own content ("Contact us",
* "Fast delivery") instead of "Item 01", so an editor finds the right row
* without expanding every one. Wire it with `rowLabel()`.
*/
export function RowLabel({ fallback = 'Item', fields = ['heading', 'title', 'label', 'link.label', 'name'] }: RowLabelProps) {
const { data, rowNumber } = useRowLabel<Record<string, unknown>>()
for (const f of fields) {
const text = toText(at(data, f))
if (text) {return <span>{text.length > 60 ? `${text.slice(0, 57)}…` : text}</span>}
}
return <span>{`${fallback} ${String((rowNumber ?? 0) + 1).padStart(2, '0')}`}</span>
}
+2
View File
@@ -0,0 +1,2 @@
export { rowLabel } from './rowLabel.js'
export type { RowLabelProps } from './RowLabelComponent.js'
+15
View File
@@ -0,0 +1,15 @@
import type { RowLabelProps } from './RowLabelComponent.js'
/**
* Readable array rows in the panel. Spread into an array field's `admin.components`:
*
* { name: 'items', type: 'array', labels: { singular: 'Feature', plural: 'Features' },
* admin: { initCollapsed: true, components: rowLabel(['heading'], 'Feature') }, fields: [...] }
*
* Rows then read "Fast delivery", "24/7 support"… instead of "Feature 01, Feature 02".
* After adding it to a project: `pnpm payload generate:importmap`.
*/
export function rowLabel(fields: string | string[], fallback = 'Item') {
const clientProps: RowLabelProps = { fields: Array.isArray(fields) ? fields : [fields], fallback }
return { RowLabel: { path: '@intecion/ipal-kit/admin#RowLabel', clientProps } }
}