themelia-ui 3.1.0 → 3.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/.agents/skills/themelia-ui/SKILL.md +38 -9
- package/.agents/skills/themelia-ui/manifest.json +23 -0
- package/.agents/skills/themelia-ui/references/api-compatibility.md +3 -2
- package/.agents/skills/themelia-ui/references/blocks.md +123 -0
- package/.agents/skills/themelia-ui/references/composition-ladder.md +8 -8
- package/.agents/skills/themelia-ui/references/composition.md +98 -1
- package/.agents/skills/themelia-ui/references/forms.md +23 -3
- package/.agents/skills/themelia-ui/references/framework-wiring.md +34 -6
- package/.agents/skills/themelia-ui/references/i18n.md +4 -2
- package/.agents/skills/themelia-ui/references/imports.md +1 -1
- package/.agents/skills/themelia-ui/references/installation.md +5 -4
- package/.agents/skills/themelia-ui/references/migration.md +22 -2
- package/.agents/skills/themelia-ui/references/provider-and-scoping.md +27 -9
- package/.agents/skills/themelia-ui/references/reference-workflows.md +43 -0
- package/.agents/skills/themelia-ui/references/structure-and-spacing.md +147 -0
- package/.agents/skills/themelia-ui/references/theming.md +6 -2
- package/.agents/skills/themelia-ui/references/troubleshooting.md +28 -5
- package/.agents/skills/themelia-ui/references/verification.md +58 -2
- package/CHANGELOG.md +25 -0
- package/README.md +3 -0
- package/dist/{alert-dialog-Bmo1YrTm.js → alert-dialog-Cg2HhuBe.js} +1 -1
- package/dist/base/alert-dialog.js +1 -1
- package/dist/base/cards.js +1 -1
- package/dist/base/choice-inputs.js +1 -1
- package/dist/base/combobox.js +1 -1
- package/dist/base/command.js +1 -1
- package/dist/base/date-pickers.js +1 -1
- package/dist/base/dialog.js +1 -1
- package/dist/base/display.js +1 -1
- package/dist/base/forms-numeric.js +1 -1
- package/dist/base/forms.js +1 -1
- package/dist/base/item.js +1 -1
- package/dist/base/navigation.js +1 -1
- package/dist/base/otp-input.js +1 -1
- package/dist/base/overlay.js +1 -1
- package/dist/base/popover-menu.js +1 -1
- package/dist/base/repeaters.js +1 -1
- package/dist/base/sheet.js +1 -1
- package/dist/base/sidebar.js +1 -1
- package/dist/base/skeleton.js +1 -1
- package/dist/base/structure.js +1 -1
- package/dist/base/timeline.js +1 -1
- package/dist/base/upload.js +1 -1
- package/dist/base/value-inputs.js +1 -1
- package/dist/blocks/admin/access.js +2 -2
- package/dist/blocks/admin/commerce.js +9 -9
- package/dist/blocks/analytics.js +3 -3
- package/dist/blocks/onboarding.js +1 -1
- package/dist/blocks/timelines.js +1 -1
- package/dist/{cards-DdiICdMM.js → cards-Ddhz43Bz.js} +2 -2
- package/dist/{choice-inputs-CCw-0gD6.js → choice-inputs-NwRxvmZN.js} +2 -2
- package/dist/combobox-519ubijc.js +292 -0
- package/dist/{command-CnB_IZSo.js → command-JjApYFds.js} +2 -2
- package/dist/{comments-C6Y_ddMt.js → comments-CCQ2QRaU.js} +4 -4
- package/dist/components/base/display/icon-badge.d.ts +2 -2
- package/dist/components/base/forms/form-field.d.ts +2 -2
- package/dist/components/base/structure/bleed.d.ts +1 -0
- package/dist/components/base/structure/grid.d.ts +8 -2
- package/dist/components/base/structure/split.d.ts +1 -0
- package/dist/components/features/combobox/fetching-combobox.d.ts +2 -1
- package/dist/components/features/combobox/resource-combobox.d.ts +3 -0
- package/dist/components/features/combobox/use-suggestions.d.ts +7 -0
- package/dist/css/structure.css +1 -1
- package/dist/{date-pickers-C2HgjpFU.js → date-pickers-BwCwKIVM.js} +1 -1
- package/dist/{dialog-0nRFg5Zs.js → dialog-CAnwRNrm.js} +1 -1
- package/dist/{display-BGN834xV.js → display-a7AoX_u7.js} +1 -1
- package/dist/features/actions.js +1 -1
- package/dist/features/activities.js +3 -3
- package/dist/features/ai-chat.js +2 -2
- package/dist/features/combobox.js +285 -273
- package/dist/features/comments.js +1 -1
- package/dist/features/data-view.js +5 -5
- package/dist/features/event-calendar.js +3 -3
- package/dist/features/filters.js +1 -1
- package/dist/features/global-search.js +4 -4
- package/dist/features/map.js +2 -2
- package/dist/features/media-library.js +8 -8
- package/dist/features/mentions.js +1 -1
- package/dist/features/overlays.js +1 -1
- package/dist/features/products.js +9 -9
- package/dist/features/resource-assignment.js +3 -3
- package/dist/features/resource.js +3 -3
- package/dist/features/schema-form.js +6 -6
- package/dist/features/sync.js +2 -2
- package/dist/features/table.js +1 -1
- package/dist/features/theme-tweaker.js +10 -10
- package/dist/{filters-geLuSlFL.js → filters-BhsTkWpZ.js} +9 -9
- package/dist/{forms-NxbJK4Mh.js → forms-C0WeNPFF.js} +1 -1
- package/dist/{forms-numeric-C6NMdj6G.js → forms-numeric-IwQ1ltNf.js} +1 -1
- package/dist/hooks/use-native-dialog.d.ts +1 -1
- package/dist/{item-CuUJyETl.js → item-M2pmpWXh.js} +1 -1
- package/dist/layout/app-shell.js +1 -1
- package/dist/layout/auth.js +1 -1
- package/dist/layout/header.js +3 -3
- package/dist/layout/navigation.js +1 -1
- package/dist/layout/page.js +2 -2
- package/dist/layout/settings.js +2 -2
- package/dist/layout/sidebar.js +10 -6
- package/dist/layout/workspace.js +3 -3
- package/dist/lib/ui-provider/ui-scope.d.ts +1 -1
- package/dist/{mentions-oeYNv_j1.js → mentions-BOxbigwp.js} +2 -2
- package/dist/{navigation-BTX5Ti0Z.js → navigation-Bgu7Vc0M.js} +2 -2
- package/dist/{navigation-WYKjDhZq.js → navigation-DiYACqpE.js} +2 -2
- package/dist/{overlay-C8RAgi2_.js → overlay-BuQOl8aP.js} +5 -5
- package/dist/{overlays-9BxwFTou.js → overlays-1sULyytH.js} +5 -5
- package/dist/{popover-menu-DcLeiw9r.js → popover-menu-QXgQeWeG.js} +1 -1
- package/dist/{repeaters-DfptvbGA.js → repeaters-CeH20dvr.js} +4 -4
- package/dist/{sheet-D-DVZH_b.js → sheet-CJ1-OAla.js} +1 -1
- package/dist/{sidebar-DXQOy_Cb.js → sidebar-D8uGqxio.js} +4 -4
- package/dist/{skeleton-CubvHel9.js → skeleton-BTKNKTdj.js} +1 -1
- package/dist/{structure-B9Y5NkP_.js → structure-CynEZ-OY.js} +1 -2
- package/dist/style.css +1 -1
- package/dist/styles/TOKENS.md +4 -3
- package/dist/{table-DT_20ity.js → table-B7dtIFUx.js} +4 -4
- package/dist/{timeline-BRZbSdhf.js → timeline-BR_jNgvz.js} +1 -1
- package/dist/{timelines-DczZKW5p.js → timelines-DXG1BfIN.js} +1 -1
- package/dist/{upload-C_6mlbfl.js → upload-CYuoJykZ.js} +1 -1
- package/dist/{value-inputs-CnO6RZeT.js → value-inputs-ng8aVJJZ.js} +4 -4
- package/docs/README.md +11 -1
- package/docs/build/browser-composition-fixture.ts +28 -0
- package/docs/build/recipes.md +398 -1
- package/docs/generated/component-index.json +1993 -862
- package/docs/generated/components/base--display.md +2 -2
- package/docs/generated/components/base--forms.md +72 -1
- package/docs/generated/components/base--structure.md +56 -5
- package/docs/generated/components/base--typography.md +38 -0
- package/docs/generated/components/blocks--admin--access.md +10 -0
- package/docs/generated/components/blocks--analytics.md +44 -0
- package/docs/generated/components/features--combobox.md +67 -0
- package/docs/generated/components/features--data-view.md +59 -3
- package/docs/generated/components/features--filters.md +10 -0
- package/docs/generated/components/features--media-library.md +68 -0
- package/docs/generated/components/features--overlays.md +54 -0
- package/docs/generated/components/features--rich-text-editor.md +38 -0
- package/docs/generated/components/layout--app-shell.md +31 -0
- package/docs/generated/components/layout--containers.md +40 -0
- package/docs/generated/components/layout--page.md +30 -1
- package/docs/generated/components/layout--sidebar.md +41 -0
- package/docs/generated/components/ui-provider.md +1 -1
- package/docs/generated/composition-ladder.md +8 -8
- package/docs/generated/consumer-contract.json +5736 -0
- package/docs/generated/imports.md +1 -1
- package/docs/generated/recipes.json +171 -1
- package/docs/generated/workflows/communications-overview/analytics/communications-reference.tsx +19 -0
- package/docs/generated/workflows/index.json +691 -0
- package/docs/generated/workflows/media-picking/media-library/media-picking-reference.tsx +63 -0
- package/docs/generated/workflows/media-picking/media-library/reference-data.ts +3 -0
- package/docs/generated/workflows/multi-section-form/form-workflow/multi-section-reference.tsx +46 -0
- package/docs/generated/workflows/nested-action-flow/action-overlays/nested-action-reference.tsx +39 -0
- package/docs/generated/workflows/record-detail/page-layout/record-detail-reference.tsx +24 -0
- package/docs/generated/workflows/resource-index/data-view/resource-index-reference.tsx +51 -0
- package/docs/generated/workflows/scoped-resource-selection/combobox/scoped-resource-reference.tsx +50 -0
- package/docs/generated/workflows/website-content-editor/media-library/reference-data.ts +3 -0
- package/docs/generated/workflows/website-content-editor/rich-text-editor/website-content-reference.tsx +33 -0
- package/docs/generated/workflows/workspace-navigation/app-shell/workspace-navigation-reference.tsx +26 -0
- package/docs/learn/api-compatibility.md +3 -2
- package/docs/learn/blocks.md +123 -0
- package/docs/learn/composition.md +98 -1
- package/docs/learn/forms.md +23 -3
- package/docs/learn/framework-wiring.md +34 -6
- package/docs/learn/i18n.md +4 -2
- package/docs/learn/installation.md +5 -4
- package/docs/learn/migration.md +22 -2
- package/docs/learn/provider-and-scoping.md +27 -9
- package/docs/learn/reference-workflows.md +43 -0
- package/docs/learn/structure-and-spacing.md +147 -0
- package/docs/learn/theming.md +6 -2
- package/docs/learn/troubleshooting.md +28 -5
- package/docs/learn/verification.md +58 -2
- package/package.json +4 -1
- package/scripts/consumer/codemod.mjs +3 -24
- package/scripts/consumer/contract-reader.mjs +42 -0
- package/scripts/consumer/css-scan.mjs +51 -0
- package/scripts/consumer/diagnose.mjs +136 -0
- package/scripts/consumer/find-component.mjs +28 -13
- package/scripts/consumer/install-skill.mjs +93 -11
- package/src/styles/TOKENS.md +4 -3
- package/dist/combobox-Byu8N-Oe.js +0 -274
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { useEffect, useMemo, useState } from "react"
|
|
2
|
+
import { Button } from "themelia-ui/base/buttons"
|
|
3
|
+
import { Stack } from "themelia-ui/base/structure"
|
|
4
|
+
import { Text } from "themelia-ui/base/typography"
|
|
5
|
+
import { MediaLibraryDialog, type MediaLibraryItem, type MediaLibraryFetcher } from "themelia-ui/features/media-library"
|
|
6
|
+
|
|
7
|
+
import { SAMPLE_MEDIA } from "./reference-data"
|
|
8
|
+
|
|
9
|
+
export default function MediaPickingReference() {
|
|
10
|
+
const [open, setOpen] = useState(false)
|
|
11
|
+
const [scope, setScope] = useState("site")
|
|
12
|
+
const [fail, setFail] = useState(false)
|
|
13
|
+
const [selected, setSelected] = useState<string[]>(["unavailable-id"])
|
|
14
|
+
const [pickerDraft, setPickerDraft] = useState(selected)
|
|
15
|
+
const [resolved, setResolved] = useState<{ scope: string; ids: string[]; items: MediaLibraryItem[] }>()
|
|
16
|
+
const [page, setPage] = useState(0)
|
|
17
|
+
const [query, setQuery] = useState("")
|
|
18
|
+
const [pending, setPending] = useState(true)
|
|
19
|
+
const [hasNext, setHasNext] = useState(false)
|
|
20
|
+
// A saved id is resolved separately from the current browser page, with scope access applied.
|
|
21
|
+
useEffect(() => {
|
|
22
|
+
const controller = new AbortController()
|
|
23
|
+
const timer = setTimeout(() => {
|
|
24
|
+
if (!controller.signal.aborted) setResolved({ scope, ids: selected, items: SAMPLE_MEDIA.filter(item => selected.includes(item.id) && item.collection === scope) })
|
|
25
|
+
}, 150)
|
|
26
|
+
return () => { controller.abort(); clearTimeout(timer) }
|
|
27
|
+
}, [selected, scope])
|
|
28
|
+
const chosen = resolved?.scope === scope && resolved.ids === selected ? resolved.items : []
|
|
29
|
+
const unavailable = resolved?.scope === scope && resolved.ids === selected && chosen.length < selected.length
|
|
30
|
+
const changeOpen = (next: boolean) => {
|
|
31
|
+
if (next) setPickerDraft(selected)
|
|
32
|
+
setOpen(next)
|
|
33
|
+
}
|
|
34
|
+
const fetcher = useMemo<MediaLibraryFetcher>(() => async ({ query: search, signal }) => {
|
|
35
|
+
setPending(true)
|
|
36
|
+
try {
|
|
37
|
+
await new Promise(resolve => setTimeout(resolve, 200))
|
|
38
|
+
if (signal?.aborted) throw new DOMException("Aborted", "AbortError")
|
|
39
|
+
if (fail) throw new Error("Media lookup unavailable")
|
|
40
|
+
const matches = SAMPLE_MEDIA.filter(item => item.collection === scope && item.name.toLowerCase().includes(search.toLowerCase()))
|
|
41
|
+
const window = matches.slice(page, page + 2)
|
|
42
|
+
setHasNext(window.length > 1)
|
|
43
|
+
return { items: window.slice(0, 1) }
|
|
44
|
+
} finally { if (!signal?.aborted) setPending(false) }
|
|
45
|
+
}, [scope, fail, page])
|
|
46
|
+
return <Stack>
|
|
47
|
+
{unavailable && <Text role="alert">The saved asset is unavailable. Choose a replacement; the draft id is retained until then.</Text>}
|
|
48
|
+
<Stack direction="horizontal" gap="sm" wrap>
|
|
49
|
+
<MediaLibraryDialog open={open} trigger={<Button>Choose reference media</Button>} onOpenChange={changeOpen} fetcher={fetcher} value={pickerDraft} onValueChange={setPickerDraft} query={query} onQueryChange={next => { setQuery(next); setPage(0); setPending(true) }} selectionMode="single" allowUpload={false}
|
|
50
|
+
strings={{ showingCount: shown => `${shown} loaded on this page; total unknown` }}
|
|
51
|
+
slots={{ footer: <Stack direction="horizontal" gap="sm" wrap align="center">
|
|
52
|
+
<Text>Media page {page + 1}; total unknown</Text>
|
|
53
|
+
<Button disabled={pending || page === 0} onClick={() => { setPage(value => value - 1); setPending(true) }}>Previous media page</Button>
|
|
54
|
+
<Button disabled={pending || !hasNext} onClick={() => { setPage(value => value + 1); setPending(true) }}>Next media page</Button>
|
|
55
|
+
</Stack> }}
|
|
56
|
+
onConfirm={(items, ids) => { setSelected(ids); setResolved({ scope, ids, items }); setOpen(false) }} />
|
|
57
|
+
<Button tone="neutral" appearance="outline" onClick={() => setSelected(["image-2"])}>Load saved media draft</Button>
|
|
58
|
+
<Button tone="neutral" appearance="outline" onClick={() => { setScope(value => value === "site" ? "other" : "site"); setPage(0); setPending(true) }}>Switch media scope</Button>
|
|
59
|
+
<Button tone="neutral" appearance="outline" onClick={() => { setFail(value => !value); setPending(true) }}>Toggle media failure</Button>
|
|
60
|
+
</Stack>
|
|
61
|
+
<Text role="status">{chosen.length ? `Hydrated selection: ${chosen.map(item => `${item.name} — ${item.alt}`).join(", ")}` : `Saved draft ids: ${selected.join(", ")}`}</Text>
|
|
62
|
+
</Stack>
|
|
63
|
+
}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { MediaLibraryItem } from "themelia-ui/features/media-library"
|
|
2
|
+
|
|
3
|
+
export const SAMPLE_MEDIA: MediaLibraryItem[] = [{ id: "image-1", name: "Garden exterior", type: "image", alt: "A garden with a stone path", collection: "site", public: true }, { id: "image-2", name: "Meeting room", type: "image", alt: "A meeting room with daylight", collection: "site", public: true }]
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { useRef, useState } from "react"
|
|
2
|
+
import { Card } from "themelia-ui/base/cards"
|
|
3
|
+
import { ContentBlock } from "themelia-ui/base/display"
|
|
4
|
+
import { FieldGroup, FormField, FormSection, FormActionsBar, SubmitStateButton } from "themelia-ui/base/forms"
|
|
5
|
+
import { Stack } from "themelia-ui/base/structure"
|
|
6
|
+
import { Input } from "themelia-ui/base/text-inputs"
|
|
7
|
+
import { Text } from "themelia-ui/base/typography"
|
|
8
|
+
import { useFormFieldBinding, useStateFormControl, type FormControl } from "themelia-ui/forms"
|
|
9
|
+
|
|
10
|
+
type Draft = { firstName: string; lastName: string; company: string }
|
|
11
|
+
function BoundField({ control, name, label, error }: { control: FormControl<Draft>; name: keyof Draft; label: string; error?: string }) {
|
|
12
|
+
const field = useFormFieldBinding<string, Draft>({ control, name })
|
|
13
|
+
return <FormField label={label} error={error} hint={name === "company" ? "The name shown on invoices." : undefined}><Input required value={field.value ?? ""} onChange={event => field.onValueChange(event.target.value)} onBlur={field.onBlur} /></FormField>
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export default function MultiSectionReference() {
|
|
17
|
+
const control = useStateFormControl<Draft>({ firstName: "Alex", lastName: "Example", company: "Example team" })
|
|
18
|
+
const [pending, setPending] = useState(false)
|
|
19
|
+
const [error, setError] = useState<string>()
|
|
20
|
+
const [rootError, setRootError] = useState<string>()
|
|
21
|
+
const [saved, setSaved] = useState(0)
|
|
22
|
+
const running = useRef(false)
|
|
23
|
+
return <Stack>
|
|
24
|
+
<Card title="Account details" description="One outer surface, editable sections with retained region insets.">
|
|
25
|
+
<form onSubmit={async event => {
|
|
26
|
+
event.preventDefault(); if (running.current) return
|
|
27
|
+
running.current = true; setPending(true); setError(undefined); setRootError(undefined)
|
|
28
|
+
try {
|
|
29
|
+
await new Promise(resolve => setTimeout(resolve, 250))
|
|
30
|
+
if (control.values.company === "offline") throw new Error("Request failed. Your values remain here.")
|
|
31
|
+
if (control.values.company.length < 3) { setError("Company must have at least three characters."); return }
|
|
32
|
+
setSaved(count => count + 1)
|
|
33
|
+
} catch (failure) { setRootError((failure as Error).message) }
|
|
34
|
+
finally { running.current = false; setPending(false) }
|
|
35
|
+
}}>
|
|
36
|
+
<Stack gap="none">
|
|
37
|
+
{rootError && <Text role="alert" type="error">{rootError}</Text>}
|
|
38
|
+
<FormSection surface="flat" title="Contact"><FieldGroup legend="Legal name" disabled={pending}><BoundField control={control} name="firstName" label="First name" /><BoundField control={control} name="lastName" label="Last name" /></FieldGroup></FormSection>
|
|
39
|
+
<FormSection surface="flat" title="Billing"><fieldset disabled={pending} style={{ border: 0, padding: 0, margin: 0 }}><BoundField control={control} name="company" label="Company" error={error} /></fieldset></FormSection>
|
|
40
|
+
<FormActionsBar leading={<Text role="status">Successful submissions {saved}</Text>}><SubmitStateButton type="submit" state={pending ? "submitting" : "idle"} strings={{ idle: "Save account" }} /></FormActionsBar>
|
|
41
|
+
</Stack>
|
|
42
|
+
</form>
|
|
43
|
+
</Card>
|
|
44
|
+
<Card title="Preferences" description="A sibling subject owns its own surface."><ContentBlock surface="plain" title="Delivery instructions"><Text>Use ContentBlock for supporting prose; FieldGroup supplies fieldset semantics for related controls.</Text></ContentBlock></Card>
|
|
45
|
+
</Stack>
|
|
46
|
+
}
|
package/docs/generated/workflows/nested-action-flow/action-overlays/nested-action-reference.tsx
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { useRef, useState } from "react"
|
|
2
|
+
import { Button } from "themelia-ui/base/buttons"
|
|
3
|
+
import { FormField } from "themelia-ui/base/forms"
|
|
4
|
+
import { Stack } from "themelia-ui/base/structure"
|
|
5
|
+
import { Input } from "themelia-ui/base/text-inputs"
|
|
6
|
+
import { Text } from "themelia-ui/base/typography"
|
|
7
|
+
import { ActionDialog } from "themelia-ui/features/overlays"
|
|
8
|
+
|
|
9
|
+
export default function NestedActionReference() {
|
|
10
|
+
const [open, setOpen] = useState(false)
|
|
11
|
+
const [child, setChild] = useState(false)
|
|
12
|
+
const [name, setName] = useState("Draft record")
|
|
13
|
+
const [error, setError] = useState<string>()
|
|
14
|
+
const [saved, setSaved] = useState(0)
|
|
15
|
+
const session = useRef(0)
|
|
16
|
+
const changeOpen = (next: boolean) => { session.current++; setOpen(next); setChild(false) }
|
|
17
|
+
return <Stack>
|
|
18
|
+
<ActionDialog open={open} trigger={<Button>Inspect draft</Button>} onOpenChange={changeOpen} title="Record inspector" description="The draft remains here after cancellation, validation failure or transport failure." showConfirm={false}>
|
|
19
|
+
<Stack>
|
|
20
|
+
<FormField label="Record name" error={error} hint="Use at least three characters. Use offline to simulate a rejected request."><Input value={name} onChange={event => setName(event.target.value)} /></FormField>
|
|
21
|
+
<ActionDialog open={child} trigger={<Button>Review save</Button>} onOpenChange={setChild} title="Save this draft?" description="A resolved response can contain validation errors. Closure follows business success." closeOnAsyncComplete={false}
|
|
22
|
+
alertMessage={error} onError={() => setError("Could not save; your draft is still here.")}
|
|
23
|
+
onAsyncConfirm={async () => {
|
|
24
|
+
const attempt = session.current
|
|
25
|
+
await new Promise(resolve => setTimeout(resolve, 300))
|
|
26
|
+
if (attempt !== session.current) return
|
|
27
|
+
if (name === "offline") throw new Error("Unavailable")
|
|
28
|
+
if (name.trim().length < 3) { setError("Enter at least three characters."); return }
|
|
29
|
+
setError(undefined); setSaved(count => count + 1); changeOpen(false)
|
|
30
|
+
}}>
|
|
31
|
+
<Text>{name}</Text>
|
|
32
|
+
</ActionDialog>
|
|
33
|
+
{/* A native form can instead use formId: its submit handler owns validation and closure. */}
|
|
34
|
+
<Text size="xs" type="secondary">Confirmation {child ? "open" : "closed"}</Text>
|
|
35
|
+
</Stack>
|
|
36
|
+
</ActionDialog>
|
|
37
|
+
<Text role="status">Successful saves {saved}</Text>
|
|
38
|
+
</Stack>
|
|
39
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { useState } from "react"
|
|
2
|
+
import { Button } from "themelia-ui/base/buttons"
|
|
3
|
+
import { Card, CardContent, CardHeader } from "themelia-ui/base/cards"
|
|
4
|
+
import { ContentBlock, MetadataList } from "themelia-ui/base/display"
|
|
5
|
+
import { Stack } from "themelia-ui/base/structure"
|
|
6
|
+
import { Text } from "themelia-ui/base/typography"
|
|
7
|
+
import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from "themelia-ui/base/table"
|
|
8
|
+
import { Page } from "themelia-ui/layout/page"
|
|
9
|
+
|
|
10
|
+
export default function RecordDetailReference() {
|
|
11
|
+
const [activity, setActivity] = useState("No commands yet")
|
|
12
|
+
return <Page header={{ title: "Record R-104", description: "A record with independent subjects and related records.", actions: <Button onClick={() => setActivity("Route command: export R-104")}>Export record</Button> }}>
|
|
13
|
+
<Stack>
|
|
14
|
+
<Card title="Identity" titleLevel={2} headerAction={<Button tone="neutral" appearance="outline" onClick={() => setActivity("Identity command: edit R-104")}>Edit identity</Button>}>
|
|
15
|
+
<MetadataList items={[{ id: "owner", label: "Owner", value: "Example team" }, { id: "state", label: "State", value: "Active" }]} />
|
|
16
|
+
<ContentBlock title="Notes" surface="plain"><Text>A long description belongs to prose, while the name and status above are facts. Commands stay beside the subject they affect. Repeated records can each have their own headings without repeating the route heading.</Text></ContentBlock>
|
|
17
|
+
</Card>
|
|
18
|
+
<Card><CardHeader title="Related records" titleLevel={2} description="The header is composed from parts; omit Card title props when supplying it." /><CardContent>
|
|
19
|
+
<Table aria-label="Related records"><TableHeader><TableRow><TableHead>Record</TableHead><TableHead>Relationship</TableHead></TableRow></TableHeader><TableBody><TableRow><TableCell>R-105</TableCell><TableCell>Follow-up</TableCell></TableRow></TableBody></Table>
|
|
20
|
+
</CardContent></Card>
|
|
21
|
+
<Text role="status">{activity}</Text>
|
|
22
|
+
</Stack>
|
|
23
|
+
</Page>
|
|
24
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { useEffect, useRef, useState } from "react"
|
|
2
|
+
import { Button } from "themelia-ui/base/buttons"
|
|
3
|
+
import { Stack } from "themelia-ui/base/structure"
|
|
4
|
+
import { Heading, Text } from "themelia-ui/base/typography"
|
|
5
|
+
import { DataView, type DataViewProps } from "themelia-ui/features/data-view"
|
|
6
|
+
import { FilterType, type ActiveFilter, type FilterConfig } from "themelia-ui/features/filters"
|
|
7
|
+
|
|
8
|
+
type RecordRow = { id: string; name: string; status: string; searchTerms: string }
|
|
9
|
+
const RECORDS: RecordRow[] = Array.from({ length: 6 }, (_, index) => ({ id: `r${index + 1}`, name: `Resource ${index + 1}`, status: index % 2 ? "Closed" : "Open", searchTerms: "hidden reference term" }))
|
|
10
|
+
const COLUMNS: DataViewProps<RecordRow>["columns"] = [{ accessorKey: "name", header: "Resource" }, { accessorKey: "status", header: "Status" }]
|
|
11
|
+
const FILTERS: FilterConfig[] = [{ key: "search", label: "Search hidden metadata and resource names", type: FilterType.SEARCH }, { key: "status", label: "Publication and review status with a long translated label", type: FilterType.SELECT, options: [{ value: "Open", label: "Open" }, { value: "Closed", label: "Closed" }] }]
|
|
12
|
+
|
|
13
|
+
export default function ResourceIndexReference() {
|
|
14
|
+
const [filters, setFilters] = useState<ActiveFilter[]>([])
|
|
15
|
+
const [page, setPage] = useState(0)
|
|
16
|
+
const [rows, setRows] = useState<RecordRow[]>([])
|
|
17
|
+
const [hasNext, setHasNext] = useState(false)
|
|
18
|
+
const [pending, setPending] = useState(true)
|
|
19
|
+
const [error, setError] = useState<string>()
|
|
20
|
+
const [refresh, setRefresh] = useState(0)
|
|
21
|
+
const [selection, setSelection] = useState<Record<string, true>>({})
|
|
22
|
+
const [answeredQuery, setAnsweredQuery] = useState("")
|
|
23
|
+
const [commands, setCommands] = useState("")
|
|
24
|
+
const failNext = useRef(false)
|
|
25
|
+
useEffect(() => {
|
|
26
|
+
let active = true
|
|
27
|
+
async function load() {
|
|
28
|
+
setPending(true); setError(undefined)
|
|
29
|
+
await new Promise(resolve => setTimeout(resolve, 250))
|
|
30
|
+
if (!active) return
|
|
31
|
+
if (failNext.current) { failNext.current = false; setError("Refresh failed. Previous rows remain available."); setPending(false); return }
|
|
32
|
+
const search = filters.find(filter => filter.key === "search")?.value[0]?.toLowerCase() ?? ""
|
|
33
|
+
const status = filters.find(filter => filter.key === "status")?.value[0]
|
|
34
|
+
const matches = RECORDS.filter(row => `${row.name} ${row.searchTerms}`.toLowerCase().includes(search) && (!status || row.status === status))
|
|
35
|
+
setAnsweredQuery(search); setRows(matches.slice(page * 2, page * 2 + 2)); setHasNext(matches.length > page * 2 + 2); setPending(false)
|
|
36
|
+
}
|
|
37
|
+
void load()
|
|
38
|
+
return () => { active = false }
|
|
39
|
+
}, [filters, page, refresh])
|
|
40
|
+
return <div style={{ width: "100%", minWidth: 0, maxWidth: "48rem" }}>
|
|
41
|
+
<Stack>
|
|
42
|
+
<Heading level={3}>Resource index</Heading>
|
|
43
|
+
<Text type="secondary">Server matching includes fields absent from the visible columns. Totals are unknown; selection applies to the current page.</Text>
|
|
44
|
+
{error && <Text role="alert" type="error">{error}</Text>}
|
|
45
|
+
<DataView data={rows} columns={COLUMNS} filtering={{ filters: FILTERS, activeFilters: filters, onFilterChange: next => { setFilters(next); setPage(0); setSelection({}) }, filterRows: ({ data }) => [...data], isFiltering: pending }}
|
|
46
|
+
table={{ enableColumnVisibility: true, enableRowSelection: true, getRowId: row => row.id, rowSelection: selection, onRowSelectionChange: setSelection, bulkActions: ({ selectedRows }) => <Button onClick={() => setCommands(`Selected-page command: ${selectedRows.map(row => row.id).join(", ")}`)}>Archive selected page rows</Button> }}
|
|
47
|
+
slots={{ topbarEnd: <Stack direction="horizontal" gap="sm" wrap><Button tone="neutral" appearance="outline" disabled={pending} onClick={() => setRefresh(count => count + 1)}>Refresh</Button><Button tone="neutral" appearance="outline" onClick={() => { failNext.current = true; setRefresh(count => count + 1) }}>Fail next refresh</Button><Button tone="neutral" appearance="outline" onClick={() => setCommands(`Export current page: ${rows.map(row => row.id).join(", ")}`)}>Export page</Button></Stack>, footer: <Stack direction="horizontal" wrap align="center"><Text>Total unknown; page {page + 1}</Text><Button disabled={pending || page === 0} onClick={() => { setPage(value => value - 1); setSelection({}) }}>Previous page</Button><Button disabled={pending || !hasNext} onClick={() => { setPage(value => value + 1); setSelection({}) }}>Next page</Button></Stack> }} />
|
|
48
|
+
<Text role="status">{pending ? "Loading page" : `${rows.length} rows supplied by server; matched ${answeredQuery || "all"}`}{commands && `; ${commands}`}</Text>
|
|
49
|
+
</Stack>
|
|
50
|
+
</div>
|
|
51
|
+
}
|
package/docs/generated/workflows/scoped-resource-selection/combobox/scoped-resource-reference.tsx
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { useState } from "react"
|
|
2
|
+
import { Button } from "themelia-ui/base/buttons"
|
|
3
|
+
import { FormField } from "themelia-ui/base/forms"
|
|
4
|
+
import { Overlay, OverlayTrigger, OverlayContent, OverlayHeader, OverlayTitle, OverlayDescription, OverlayBody } from "themelia-ui/base/overlay"
|
|
5
|
+
import { Stack } from "themelia-ui/base/structure"
|
|
6
|
+
import { Text } from "themelia-ui/base/typography"
|
|
7
|
+
import { ResourceCombobox } from "themelia-ui/features/combobox"
|
|
8
|
+
|
|
9
|
+
type Resource = { id: string; label: string }
|
|
10
|
+
type Mode = "results" | "pending" | "empty" | "error"
|
|
11
|
+
|
|
12
|
+
export default function ScopedResourceReference() {
|
|
13
|
+
const [scope, setScope] = useState("A")
|
|
14
|
+
const [mode, setMode] = useState<Mode>("results")
|
|
15
|
+
const [query, setQuery] = useState("")
|
|
16
|
+
const [value, setValue] = useState<Resource | null>({ id: "A-1", label: "A project" })
|
|
17
|
+
const [selections, setSelections] = useState(0)
|
|
18
|
+
const [submissions, setSubmissions] = useState(0)
|
|
19
|
+
const [completions, setCompletions] = useState(0)
|
|
20
|
+
return <Overlay>
|
|
21
|
+
<OverlayTrigger render={<Button />}>Choose scoped resource</OverlayTrigger>
|
|
22
|
+
<OverlayContent>
|
|
23
|
+
<OverlayHeader><OverlayTitle>Assign resource</OverlayTitle><OverlayDescription>Lookup validity belongs to a workspace. The application decides whether a selected resource remains valid.</OverlayDescription></OverlayHeader>
|
|
24
|
+
<OverlayBody>
|
|
25
|
+
<form onSubmit={event => { event.preventDefault(); setSubmissions(count => count + 1) }}>
|
|
26
|
+
<Stack>
|
|
27
|
+
<Stack direction="horizontal" gap="sm" wrap>
|
|
28
|
+
{["A", "B"].map(key => <Button key={key} tone="neutral" appearance="outline" onClick={() => { setScope(key); setValue(null) }}>Workspace {key}</Button>)}
|
|
29
|
+
</Stack>
|
|
30
|
+
<Stack direction="horizontal" gap="sm" wrap>
|
|
31
|
+
{(["results", "pending", "empty", "error"] as const).map(key => <Button key={key} tone="neutral" appearance="ghost" onClick={() => setMode(key)}>{key}</Button>)}
|
|
32
|
+
</Stack>
|
|
33
|
+
<FormField label="Resource" hint={`Searching workspace ${scope}`}>
|
|
34
|
+
<ResourceCombobox<Resource> scopeKey={`${scope}:${mode}`} value={value} onValueChange={next => { setValue(next); setSelections(count => count + 1) }} searchValue={query} onSearchValueChange={setQuery} debounceMs={100} getKey={item => item.id} getLabel={item => item.label}
|
|
35
|
+
fetcher={async ({ query: search, signal }) => {
|
|
36
|
+
// The mock deliberately ignores abort; the picker must suppress its late answer.
|
|
37
|
+
void signal
|
|
38
|
+
await new Promise(resolve => setTimeout(resolve, mode === "pending" ? 2400 : scope === "A" ? 600 : 80))
|
|
39
|
+
if (mode === "error") throw new Error("Lookup unavailable")
|
|
40
|
+
return mode === "empty" || (search && !"project".includes(search.toLowerCase())) ? [] : [{ id: `${scope}-1`, label: `${scope} project` }]
|
|
41
|
+
}} onAfterFetch={() => setCompletions(count => count + 1)} />
|
|
42
|
+
</FormField>
|
|
43
|
+
<Button type="submit">Assign</Button>
|
|
44
|
+
<Text role="status">Selections {selections}; submissions {submissions}; completions {completions}</Text>
|
|
45
|
+
</Stack>
|
|
46
|
+
</form>
|
|
47
|
+
</OverlayBody>
|
|
48
|
+
</OverlayContent>
|
|
49
|
+
</Overlay>
|
|
50
|
+
}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { MediaLibraryItem } from "themelia-ui/features/media-library"
|
|
2
|
+
|
|
3
|
+
export const SAMPLE_MEDIA: MediaLibraryItem[] = [{ id: "image-1", name: "Garden exterior", type: "image", alt: "A garden with a stone path", collection: "site", public: true }, { id: "image-2", name: "Meeting room", type: "image", alt: "A meeting room with daylight", collection: "site", public: true }]
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { useState } from "react"
|
|
2
|
+
import { Button } from "themelia-ui/base/buttons"
|
|
3
|
+
import { Card } from "themelia-ui/base/cards"
|
|
4
|
+
import { PillRadioGroup } from "themelia-ui/base/choice-inputs"
|
|
5
|
+
import { FormField } from "themelia-ui/base/forms"
|
|
6
|
+
import { Stack } from "themelia-ui/base/structure"
|
|
7
|
+
import { Input } from "themelia-ui/base/text-inputs"
|
|
8
|
+
import { RichText, Text } from "themelia-ui/base/typography"
|
|
9
|
+
import { MediaLibraryDialog, type MediaLibraryItem } from "themelia-ui/features/media-library"
|
|
10
|
+
import { RichTextEditor } from "themelia-ui/features/rich-text-editor"
|
|
11
|
+
import { SAMPLE_MEDIA } from "../media-library/reference-data"
|
|
12
|
+
|
|
13
|
+
export default function WebsiteContentReference() {
|
|
14
|
+
const [locale, setLocale] = useState("en")
|
|
15
|
+
const [drafts, setDrafts] = useState<Record<string, string>>({ en: "<p>Welcome to our workspace.</p>", ar: "<p>مرحباً بكم</p>" })
|
|
16
|
+
const [mediaOpen, setMediaOpen] = useState(false)
|
|
17
|
+
const [image, setImage] = useState<MediaLibraryItem>()
|
|
18
|
+
const [alt, setAlt] = useState("")
|
|
19
|
+
const [failed, setFailed] = useState(true)
|
|
20
|
+
const [pending, setPending] = useState(false)
|
|
21
|
+
const [message, setMessage] = useState("Drafts are local until saved")
|
|
22
|
+
return <Card title="Website content" description="Each locale owns a retained draft. Preview sanitizes HTML; the application also validates and sanitizes persisted content.">
|
|
23
|
+
<Stack>
|
|
24
|
+
<PillRadioGroup aria-label="Content locale" name="reference-content-locale" value={locale} onValueChange={value => value && setLocale(value)} options={[{ value: "en", label: "English" }, { value: "ar", label: "العربية" }]} />
|
|
25
|
+
<div dir={locale === "ar" ? "rtl" : "ltr"}><RichTextEditor value={drafts[locale] ?? ""} onValueChange={html => setDrafts(current => ({ ...current, [locale]: html }))} /></div>
|
|
26
|
+
<MediaLibraryDialog open={mediaOpen} trigger={<Button tone="neutral" appearance="outline">Choose hero media</Button>} onOpenChange={setMediaOpen} items={SAMPLE_MEDIA} selectionMode="single" confirmOnSelect allowUpload={false} onConfirm={items => { const item = items[0]; setImage(item); setAlt(item?.alt ?? ""); setMediaOpen(false) }} />
|
|
27
|
+
{image && <FormField label="Hero image alternative text" hint={image.name}><Input value={alt} onChange={event => setAlt(event.target.value)} /></FormField>}
|
|
28
|
+
<Stack direction="horizontal" wrap gap="sm"><Button disabled={pending} onClick={async () => { if (pending) return; setPending(true); await new Promise(resolve => setTimeout(resolve, 250)); setMessage(failed ? "Save failed. All locale drafts and image text remain here." : "Mock website save completed"); setPending(false) }}>Save website content</Button><Button tone="neutral" appearance="outline" onClick={() => setFailed(value => !value)}>Toggle save failure</Button></Stack>
|
|
29
|
+
<Text role="status">{message}</Text>
|
|
30
|
+
<RichText html={drafts[locale] ?? ""} />
|
|
31
|
+
</Stack>
|
|
32
|
+
</Card>
|
|
33
|
+
}
|
package/docs/generated/workflows/workspace-navigation/app-shell/workspace-navigation-reference.tsx
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { useState } from "react"
|
|
2
|
+
import { Text } from "themelia-ui/base/typography"
|
|
3
|
+
import { TopbarSidebarLayout } from "themelia-ui/layout/app-shell"
|
|
4
|
+
import { AppSidebar, type LinkRenderer } from "themelia-ui/layout/sidebar"
|
|
5
|
+
|
|
6
|
+
export default function WorkspaceNavigationReference() {
|
|
7
|
+
const [route, setRoute] = useState("/a/overview")
|
|
8
|
+
const [navigations, setNavigations] = useState(0)
|
|
9
|
+
const workspace = route.startsWith("/b/") ? "B" : "A"
|
|
10
|
+
const renderLink: LinkRenderer = ({ href, children, external, active, disabled, onClick, ...props }) => {
|
|
11
|
+
void active
|
|
12
|
+
if (disabled || !href) return <span {...props}>{children}</span>
|
|
13
|
+
return <a {...props} href={href} target={props.target ?? (external ? "_blank" : undefined)} rel={props.rel ?? (external ? "noopener noreferrer" : undefined)} onClick={event => {
|
|
14
|
+
onClick?.(event)
|
|
15
|
+
if (event.defaultPrevented || external || event.button !== 0 || event.metaKey || event.ctrlKey || event.shiftKey || event.altKey) return
|
|
16
|
+
event.preventDefault(); setRoute(href); setNavigations(count => count + 1)
|
|
17
|
+
}}>{children}</a>
|
|
18
|
+
}
|
|
19
|
+
return <div style={{ width: "100%", height: "28rem", minWidth: 0 }}>
|
|
20
|
+
<TopbarSidebarLayout contained contentRender={<div />} logo="Reference workspace" sidebarProviderProps={{ persist: false, keyboardShortcut: false }} sidebar={<AppSidebar logo={`Workspace ${workspace}`} renderLink={renderLink} currentUrl={route}
|
|
21
|
+
workspaceLinks={[{ label: "Workspace A home", url: "/a/overview", external: false }, { label: "Workspace B home", url: "/b/overview", external: false }, { label: "External workspace", url: "https://example.com" }]}
|
|
22
|
+
navigationGroups={{ "": [{ label: `${workspace} overview`, href: `/${workspace.toLowerCase()}/overview` }, { label: `${workspace} settings`, href: `/${workspace.toLowerCase()}/settings` }] }} />}>
|
|
23
|
+
<Text role="status">Workspace {workspace}; route {route}; navigations {navigations}</Text>
|
|
24
|
+
</TopbarSidebarLayout>
|
|
25
|
+
</div>
|
|
26
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# API compatibility
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Exact package subpaths, exported names, callable signatures, and
|
|
4
4
|
exported props/type members are compatibility surfaces. Public global theme tokens, documented
|
|
5
5
|
`data-slot` and BEM hooks, and the `strings` contracts are also consumer contracts.
|
|
6
6
|
|
|
@@ -15,7 +15,8 @@ exported props/type members are compatibility surfaces. Public global theme toke
|
|
|
15
15
|
| a documented default changes | behavioural change; release notes required |
|
|
16
16
|
| component token or hashed CSS Module name changes | internal unless documented as an extension point |
|
|
17
17
|
|
|
18
|
-
3.1
|
|
18
|
+
3.1 includes breaking changes despite its minor version number: it removes obsolete aliases
|
|
19
|
+
and adapters. Removed names do not stay available solely for an
|
|
19
20
|
upgrade window. A breaking release records the replacement in the migration reference and
|
|
20
21
|
the changelog; consumers pin the old version until they are ready to update.
|
|
21
22
|
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
# Choosing and composing blocks
|
|
2
|
+
|
|
3
|
+
A structural block arranges regions; a subject block renders a recognizable job such as
|
|
4
|
+
metrics, onboarding or an order summary. Use [Structure and spacing](./structure-and-spacing.md)
|
|
5
|
+
for page geometry, surfaces and gaps. Start with a ready subject block when its vocabulary
|
|
6
|
+
fits the product, then use its documented props, callbacks or parts. The application keeps
|
|
7
|
+
data, permission checks, routing, mutation and persistence.
|
|
8
|
+
|
|
9
|
+
## Published subject modules
|
|
10
|
+
|
|
11
|
+
| Job | Exact subpath and examples | Application owns | Optional peers |
|
|
12
|
+
| --- | --- | --- | --- |
|
|
13
|
+
| Quantities, changes and plots | `themelia-ui/blocks/analytics`: MetricGrid, Metric, MetricComparison, ChartCard, ActivityHeatmap | Measures, period, comparison meaning, loading/errors and metric actions | `recharts`, for the module even when the adopted block has no plot |
|
|
14
|
+
| Setup tasks completed over time | `themelia-ui/blocks/onboarding`: Checklist | Step status, content, submission and persistence | None |
|
|
15
|
+
| Milestones, changelog or linear progress | `themelia-ui/blocks/timelines`: MilestonesTimeline, ChangelogTimeline, Steps, StepsBar | Sequence, status, dates and navigation | None |
|
|
16
|
+
| Permissions and credential management | `themelia-ui/blocks/admin/access`: RolePermissions, CredentialList, SensitiveAction | Authorization, actual secrets, deletion confirmation and mutations | None |
|
|
17
|
+
| Orders, invoices, inventory and payment summaries | `themelia-ui/blocks/admin/commerce`: OrderSummary, InvoiceLineItems, InventorySection, PaymentTimeline | Commerce records, calculation policy, commands and transport | None |
|
|
18
|
+
|
|
19
|
+
These are modules, not broad barrels: there is no `themelia-ui/blocks` import. General and
|
|
20
|
+
admin profiles come from the same installation. Admin is presentation vocabulary rather
|
|
21
|
+
than an authorization layer; importing an admin block does not protect its actions or data.
|
|
22
|
+
The generated [import table](../generated/imports.md) is authoritative for optional peers.
|
|
23
|
+
Do not assume a symbol is peer-free because its own UI looks simple.
|
|
24
|
+
|
|
25
|
+
Open the selected API before JSX: [analytics](../generated/components/blocks--analytics.md),
|
|
26
|
+
[onboarding](../generated/components/blocks--onboarding.md),
|
|
27
|
+
[timelines](../generated/components/blocks--timelines.md),
|
|
28
|
+
[admin access](../generated/components/blocks--admin--access.md), or
|
|
29
|
+
[admin commerce](../generated/components/blocks--admin--commerce.md).
|
|
30
|
+
They list exact record shapes, defaults, strings, dependencies and preview recipes.
|
|
31
|
+
|
|
32
|
+
## Facts versus quantities
|
|
33
|
+
|
|
34
|
+
MetadataList owns label/value facts such as owner, status, address or a date. A numeric
|
|
35
|
+
identifier is still a fact. MetricGrid/Metric own measures such as delivered messages,
|
|
36
|
+
revenue or a conversion rate, with optional comparison and trend. Put prose facts beside
|
|
37
|
+
quantities rather than turning every value into a metric tile.
|
|
38
|
+
|
|
39
|
+
```tsx compile
|
|
40
|
+
import { ContentBlock, MetadataList } from "themelia-ui/base/display"
|
|
41
|
+
import { Stack } from "themelia-ui/base/structure"
|
|
42
|
+
import { MetricGrid, type MetricData } from "themelia-ui/blocks/analytics"
|
|
43
|
+
import { Page } from "themelia-ui/layout/page"
|
|
44
|
+
|
|
45
|
+
const metrics: MetricData[] = [
|
|
46
|
+
{ id: "delivered", label: "Delivered", value: 248 },
|
|
47
|
+
{ id: "opened", label: "Opened", value: null, subtitle: "Tracking unavailable" },
|
|
48
|
+
]
|
|
49
|
+
|
|
50
|
+
export function DeliveryOverview() {
|
|
51
|
+
return <Page header={{ title: "Delivery overview", description: "Current campaign" }}>
|
|
52
|
+
<Stack>
|
|
53
|
+
<MetricGrid metrics={metrics} variant="card" />
|
|
54
|
+
<ContentBlock title="Campaign details">
|
|
55
|
+
<MetadataList items={[
|
|
56
|
+
{ id: "owner", label: "Owner", value: "Alex" },
|
|
57
|
+
{ id: "status", label: "Status", value: "Sending" },
|
|
58
|
+
]} />
|
|
59
|
+
</ContentBlock>
|
|
60
|
+
</Stack>
|
|
61
|
+
</Page>
|
|
62
|
+
}
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
Use `null` for an unavailable MetricData value; zero means a measured zero. MetricGrid's
|
|
66
|
+
loading contract is for initial loading. For error or refresh behavior, inspect the adopted
|
|
67
|
+
component's exact API rather than assuming every analytics block accepts the same props.
|
|
68
|
+
The [communications workflow](./reference-workflows.md) demonstrates retained figures,
|
|
69
|
+
failure feedback, retry, unknown tracking and a separate facts region.
|
|
70
|
+
|
|
71
|
+
## Compose without duplicating owners
|
|
72
|
+
|
|
73
|
+
Inspect whether a block already owns its title, surface, controls and responsive layout
|
|
74
|
+
before surrounding it with another Card or Grid. MetricGrid already arranges tiles;
|
|
75
|
+
ChartCard already owns its chart frame; FormSection already owns an editable section's
|
|
76
|
+
header and inset. Use a sibling surface for an independent subject and ContentBlock for
|
|
77
|
+
supporting prose inside one. [Composition](./composition.md#decide-the-owners-before-jsx)
|
|
78
|
+
describes the owners in detail.
|
|
79
|
+
|
|
80
|
+
Keep default typography and spacing with those owners. Do not invent `size`, `padding`,
|
|
81
|
+
`error` or `strings` props by analogy with another block. Use a documented slot or render
|
|
82
|
+
prop for one region; use public parts or an application composition when the arrangement
|
|
83
|
+
must differ. No block needs every extension seam. The [composition ladder](../generated/composition-ladder.md)
|
|
84
|
+
is a discovery aid; the selected API remains the contract.
|
|
85
|
+
|
|
86
|
+
## Compose your own subject
|
|
87
|
+
|
|
88
|
+
When the ready block's vocabulary cannot express the product, start from its public
|
|
89
|
+
lower-tier recipe rather than copying internals. The live block pages include these
|
|
90
|
+
compose-your-own examples; their source is also embedded in
|
|
91
|
+
[recipes.json](../generated/recipes.json) under the exact id below and in the
|
|
92
|
+
[recipe book](../build/recipes.md). The recipe imports identify the adopted modules and
|
|
93
|
+
their peer requirements; they do not require importing the corresponding ready block.
|
|
94
|
+
|
|
95
|
+
| Subject | Recipe id | Public building blocks |
|
|
96
|
+
| --- | --- | --- |
|
|
97
|
+
| A custom measure | `analytics-blueprint` | Card, Stack, Money, Badge, Sparkline |
|
|
98
|
+
| Setup checklist | `blocks-checklist-blueprint` | Progress, Accordion, IconBadge, Text, Button |
|
|
99
|
+
| Release timeline | `blocks-changelog-blueprint` | Timeline, MonoValue, Badge |
|
|
100
|
+
| Role/permission summary | `blocks-roles-blueprint` | Table, Badge, VisuallyHidden |
|
|
101
|
+
| Custom order summary | `cart-summary-blueprint` | Card, MetadataList, Money, Button, toast |
|
|
102
|
+
|
|
103
|
+
For example, retrieve the exact checklist source from the installed package:
|
|
104
|
+
|
|
105
|
+
```bash
|
|
106
|
+
node <<'NODE'
|
|
107
|
+
const fs = require('node:fs')
|
|
108
|
+
const { recipes } = JSON.parse(fs.readFileSync('node_modules/themelia-ui/docs/generated/recipes.json', 'utf8'))
|
|
109
|
+
const recipe = recipes.find(item => item.id === 'blocks-checklist-blueprint')
|
|
110
|
+
if (!recipe) throw new Error('Recipe missing from this installed version')
|
|
111
|
+
process.stdout.write(recipe.code)
|
|
112
|
+
NODE
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
These examples establish presentation seams, with fixed sample data and mock callbacks.
|
|
116
|
+
Keep the application's real permission model, calculations and completion state in its
|
|
117
|
+
own component. Use the [complete workflows](./reference-workflows.md) when the task needs
|
|
118
|
+
submission, lookup, selection or retained-draft behavior beyond a presentation recipe.
|
|
119
|
+
|
|
120
|
+
For translated copy, use the selected module's typed strings and exported defaults. Product
|
|
121
|
+
labels and record content remain application copy. Test permissions, loading/empty/error
|
|
122
|
+
states, long labels, keyboard interaction, RTL and the adopted density in the real route;
|
|
123
|
+
the package's previews do not establish application acceptance.
|
|
@@ -20,6 +20,10 @@ ready-made surface does not express the job.
|
|
|
20
20
|
compose both; neither may import a block. The complete generated graph is in
|
|
21
21
|
[Profiles](../generated/profiles.md).
|
|
22
22
|
|
|
23
|
+
For structural blocks, spacing roles and responsive widths, use
|
|
24
|
+
[Structure and spacing](./structure-and-spacing.md). For ready analytics, onboarding,
|
|
25
|
+
timeline and admin presentations, use [Choosing blocks](./blocks.md).
|
|
26
|
+
|
|
23
27
|
## The composition ladder
|
|
24
28
|
|
|
25
29
|
Use the lowest rung that solves the real requirement:
|
|
@@ -142,6 +146,13 @@ The invoice example above is the canonical shape: `Page` for route geometry,
|
|
|
142
146
|
`MetadataList` and primitives for facts, then domain callbacks on package actions. Keep the
|
|
143
147
|
record type out of the package.
|
|
144
148
|
|
|
149
|
+
When the task also fits the standard loading, empty, error and retry presentation, use
|
|
150
|
+
`ResourceShowShell` or `ResourceIndexShell` from `features/resource`. Those shells already
|
|
151
|
+
own a header, body and state replacement; do not duplicate that route header by wrapping
|
|
152
|
+
them in another Page. Page remains appropriate for a custom record arrangement where the
|
|
153
|
+
application already owns lifecycle feedback. Read the
|
|
154
|
+
[resource API](../generated/components/features--resource.md) for state and slot contracts.
|
|
155
|
+
|
|
145
156
|
### Form
|
|
146
157
|
|
|
147
158
|
```tsx fragment — validation, field values, submit mutation, and product copy remain in the app
|
|
@@ -191,7 +202,7 @@ documentation tree whose vocabulary is not settings.
|
|
|
191
202
|
|
|
192
203
|
Look up a specific task with the offline finder. Exact symbols take priority; `--explain`
|
|
193
204
|
shows matched components, selection reasons and direct API anchors. `--json` exposes the
|
|
194
|
-
same records for tools. Guidance marked `
|
|
205
|
+
same records for tools. Guidance marked `module` is a fallback, not a component-specific
|
|
195
206
|
recommendation. An empty result means refine the query or inspect the catalogue, not invent
|
|
196
207
|
an export.
|
|
197
208
|
|
|
@@ -314,6 +325,92 @@ Only use states the selected module exposes; the API reference is authoritative.
|
|
|
314
325
|
complete examples above type-check against the built package, but their application
|
|
315
326
|
callbacks are illustrative: verify persistence and browser behaviour in your app.
|
|
316
327
|
|
|
328
|
+
## Decide the owners before JSX
|
|
329
|
+
|
|
330
|
+
| Owner | Insets and type | Name and command scope | Parent responsibility |
|
|
331
|
+
| --- | --- | --- | --- |
|
|
332
|
+
| `Page` | Route geometry; header owns heading type | One route heading; route commands | Data, routing and independent subjects |
|
|
333
|
+
| `Card` / parts | Surface and content inset; header owns title/description | A bounded subject; commands for that subject | Arrange sibling subjects, choose heading level |
|
|
334
|
+
| `ContentBlock` | Title/content gap; `plain` has no inset, decorated surfaces add one | Supporting content within a subject | Decide whether another independent surface is warranted |
|
|
335
|
+
| `MetadataList` / values | Fact layout; labels and semantic value formatting | Read-only facts, not editable labels | Permission-filtered records and value descriptors |
|
|
336
|
+
| Analytics blocks | Quantity hierarchy and responsive metric arrangement | Measures and their period; metric actions | Query, unknown quantities and interpretation |
|
|
337
|
+
| `FormSection` | Section inset and heading; `flat` retains its padding | Editable region title; section-specific actions | Form, values, validation and completion |
|
|
338
|
+
| `FieldGroup` | Related control arrangement and support line | Fieldset/legend for a group; children retain distinct labels | Group disabled state and validation policy |
|
|
339
|
+
| `FormField` / binding | Label and support typography, control association | One editable field | Value, mutation and explicit name/ARIA overrides |
|
|
340
|
+
| `Stack` / `Grid` | Shared gaps; no new typography owner | Passive arrangement | Choose whether child insets already supply separation |
|
|
341
|
+
| `DataView` | Filter/table shell and responsive filter presentation | Resource-browser commands | Transport, page totals and selection lifetime |
|
|
342
|
+
| `DataTable` | Tabular interaction and table geometry | Column/row names and row commands | Filters, surrounding surface and server transport |
|
|
343
|
+
| `FilterLayout` / slots | Responsive controls and sheet | Filter controls only | Shared filter state; put export/create in action slots |
|
|
344
|
+
|
|
345
|
+
`surface="flat"` changes decoration, not the inset contract. Several flat FormSections
|
|
346
|
+
inside CardContent accumulate the card content inset and each section's inset. Use the
|
|
347
|
+
ready Card body when that separation is useful; use parts when you need a different region
|
|
348
|
+
arrangement. `Stack gap="none"` is appropriate when adjacent sections already own their
|
|
349
|
+
vertical separation. Do not compensate by assigning private padding variables or local type.
|
|
350
|
+
|
|
351
|
+
These are fragments; the [complete workflows](./reference-workflows.md) include state,
|
|
352
|
+
helpers and submission behavior.
|
|
353
|
+
|
|
354
|
+
```tsx fragment — fields and subject data come from the application
|
|
355
|
+
<Card title="Account details">
|
|
356
|
+
<Stack gap="none">
|
|
357
|
+
<FormSection surface="flat" title="Contact">{contactFields}</FormSection>
|
|
358
|
+
<FormSection surface="flat" title="Billing">{billingFields}</FormSection>
|
|
359
|
+
</Stack>
|
|
360
|
+
</Card>
|
|
361
|
+
```
|
|
362
|
+
|
|
363
|
+
```tsx fragment — parts expose the same owners; table rows and columns are application data
|
|
364
|
+
<Card>
|
|
365
|
+
<CardHeader title="Related records" titleLevel={2} />
|
|
366
|
+
<CardContent><DataTable data={rows} columns={columns} /></CardContent>
|
|
367
|
+
</Card>
|
|
368
|
+
```
|
|
369
|
+
|
|
370
|
+
Use sibling Cards for independent subjects. Use ContentBlock inside a Card for supporting
|
|
371
|
+
prose. Repeating the route heading as each Card title adds no new subject. Repeating a
|
|
372
|
+
FormField label in a nested DisplayLabel creates competing names; supply the field label
|
|
373
|
+
once and let FormField associate it. A FieldGroup legend names the group, so its children's
|
|
374
|
+
labels should identify their distinct values. Labels on different records may repeat.
|
|
375
|
+
|
|
376
|
+
```tsx fragment — each subject supplies its own application-owned facts
|
|
377
|
+
<Grid columns={{ base: 1, md: 2 }}>
|
|
378
|
+
<Card title="Contact"><MetadataList items={contactFacts} /></Card>
|
|
379
|
+
<Card title="Billing"><MetadataList items={billingFacts} /></Card>
|
|
380
|
+
</Grid>
|
|
381
|
+
```
|
|
382
|
+
|
|
383
|
+
Grid owns separation between the sibling subjects and their responsive columns. Each Card
|
|
384
|
+
owns its header and body inset. For a resource browser, DataView already owns the filter/table
|
|
385
|
+
frame: put a Heading and supporting Text beside that frame instead of wrapping it in another
|
|
386
|
+
Card. The [resource workflow](./reference-workflows.md) demonstrates a constrained parent;
|
|
387
|
+
the detail workflow demonstrates a secondary table within an independent titled subject.
|
|
388
|
+
|
|
389
|
+
Keep a record's command beside that record, a page command in the page header, and a
|
|
390
|
+
selected-row command in the table's bulk-action seam. Filter toolbars communicate query
|
|
391
|
+
state; export and create belong in the action slots. Applications decide destructive policy,
|
|
392
|
+
field-per-row arrangements and permission boundaries.
|
|
393
|
+
|
|
394
|
+
For server filtering, use `filtering.filterRows: ({ data }) => [...data]` when the server
|
|
395
|
+
already matched the page. DataView's default filtering is local and can remove valid server
|
|
396
|
+
matches whose search fields are absent from the visible columns. Use an app-owned cursor
|
|
397
|
+
footer when totals are unknown; never invent a page count. Drop to DataTable when the app
|
|
398
|
+
already owns the browser shell, filters and command placement.
|
|
399
|
+
|
|
400
|
+
Selector variants serve different lifecycles: SuggestionsCombobox uses the generic lookup
|
|
401
|
+
hook; AsyncCombobox accepts application-owned results; ResourceCombobox owns the ready
|
|
402
|
+
single-resource fetching presentation. Use `scopeKey` on SuggestionsCombobox or ResourceCombobox when workspace or permission context changes without a
|
|
403
|
+
query change. It invalidates lookup results, not the controlled selection. The application
|
|
404
|
+
clears a value that is invalid in the new context.
|
|
405
|
+
|
|
406
|
+
```bash
|
|
407
|
+
node node_modules/themelia-ui/scripts/consumer/find-component.mjs "editable section" --context=existing-surface --context=editable --explain
|
|
408
|
+
node node_modules/themelia-ui/scripts/consumer/find-component.mjs "resource selector" --context=changing-scope --json
|
|
409
|
+
```
|
|
410
|
+
|
|
411
|
+
Context matches are positive evidence. Uncurated exports remain visible with unknown
|
|
412
|
+
context coverage; they do not become recommendations by omission.
|
|
413
|
+
|
|
317
414
|
## When to wrap, compose, or contribute
|
|
318
415
|
|
|
319
416
|
- **Wrap** when the product needs a stable local name or defaults around one module.
|