@pagix/checkbox
v0.1.0
Published
Anvilkit Puck-native checkbox component.
Readme
@pagix/checkbox
A Puck-native form component scaffold generated for anvilkit-components.
Install
pnpm add @pagix/checkbox @anvilkit/ui @puckeditor/coreUsage
import type { Config } from "@puckeditor/core";
import {
Checkbox,
componentConfig,
defaultProps,
type CheckboxProps,
} from "@pagix/checkbox";
const config: Config<{
Checkbox: CheckboxProps;
}> = {
components: {
Checkbox: componentConfig,
},
};
const data = {
root: {},
content: [
{
type: "Checkbox",
props: {
id: "checkbox-1",
...defaultProps,
},
},
],
};
export function Example() {
return <Checkbox label="Checkbox" name="checkbox" placeholder="Enter a value" />;
}Authoring surface (PLAN-0025 §6 / PLAN-0027)
src/config.ts declares metadata.anvilkit.editor (no version field — the
contract is structural) with a
styleTargets map. Every declared target id is stamped on a real element via
anvilTargetAttrs(id, '<target>') (the root uses anvilRootAttrs(id)), in
every render branch and in every mode — edit mode may change affordances, never
the target structure. Extend the map only together with the matching stamp and
the checkbox.targets.<targetId> label in all four catalogs.
Two authored props ride the same targets:
classNames?: Record<string, string>— Tailwind passthrough per target id, merged after the base classes so authored classes win. A class only takes effect if the host page's compiled CSS contains it.animation?: { preset, durationMs?, delayMs?, easing? }— entrance preset applied to the root throughanimationAttrs(); the keyframes live insrc/styles.cssbehind@media (prefers-reduced-motion: no-preference).
Neither is stamped into defaultProps. The hidden appearance/interactions/
bindings carriers come from ...authoringFields; src/authoring.ts is a
verbatim per-package copy locked by the workspace authoring-contract suite.
