Repository navigation
Description
What: useCollator — Returns the locale-aware comparator to use for custom sorting; it is recreated when the provider locale or an option changes.
A good example shows: A Table of people whose Name column holds names with accents and mixed case (for example "Émile", "emma", "Zoë", "Ana"). Clicking the column header sorts it with the collator's compare function, so accented and lowercase names land where a reader expects, ignoring case. A locale switch (for example English vs Swedish) shows the order change.
Where:
- Hook source:
packages/core/src/i18n/useCollator.ts - Hook doc:
packages/core/src/i18n/useCollator.doc.mjs - Example blocks:
packages/cli/assets/templates/blocks/components/(add a<Name>.tsx+<Name>.doc.mjspair, for example underI18n/). Existing hook examples to copy the shape from:Theme/useThemeHookUsageandPopover/PopoverHookUsage.
Acceptance criteria:
-
A template block names
useCollatorinexampleFor(oralsoExampleFor) and renders in the Examples section of the hook's docsite page. -
The hook visibly drives the behavior: removing the hook call breaks what the example shows. Minimal code; no unrelated UI or styling.
-
Meets the rule
architecture:knowledge-contractsINV28 (docs/architecture/knowledge-contracts.md), quoted here:INV28 — Every public hook has a minimal, runnable example that
demonstrates it. A public hook is a hook that a package's committed API
report lists. Its documentation includes at least one realistic, runnable
example: a live template block that names the hook as its example target
(exampleFor, oralsoExampleForwhen the block also serves another page).
The example:- shows the hook inside a component solving the use case its docs state;
- imports the package's own code only through its public entry points;
- covers the hook's main parameters and return values;
- passes the docs build;
- gets its visible behavior from the hook itself, so removing the hook breaks
what the example shows; and - is minimal: only the code needed to show the use case, with no unrelated UI
or styling.
How a docs page selects and orders its example blocks belongs to
architecture:template-authoring. A public hook without a conforming example
is a docs gap, tracked as an issue in the repository's issue queue (DEC-16).
Good first issue: start with CONTRIBUTING.md. For orientation, run astryx docs and astryx component --list from the repo root (the CLI is node packages/cli/clients/cli/bin/astryx.mjs). The hook's own tests next to its source show how it is called.
Filed by an AI agent on behalf of the maintainer, as part of a docs-coverage sweep.
Activity
docs(useCollator): add a locale-aware name sort example block (meta#9510