Skip to main content

Edit Attribute Selection Block

EditAttributeSelection is a controlled checkbox-selection form block built on MUI.

Installation​

npm install @nodeblocks/frontend-edit-attribute-selection-block

What You Need​

ItemWhy it matters
dataControlled form state. Selected values live in data.attributes.
onDataChangeReceives the next data snapshot plus metadata for the changed path.
optionsCheckbox choices rendered by the default list. This prop is required in the component source.
labels (optional)Copy for the title, subtitle, field name, and submit button.
errors (optional)Forwarded to the block context for custom flows.
layout (optional)Controls checkbox arrangement: one-column or grid.
children (optional)Use compound components or block override rendering.
Controlled component

EditAttributeSelection does not own form state. Keep data in your app and pass updates back through onDataChange. The expected shape is data.attributes: [{ key, value }].

Code Examples​

Live Editor
function Example() {
  const defaultData = { attributes: [] };
  const [data, setData] = React.useState(defaultData);

  const options = [
    { key: 'role', value: 'frontend', label: 'ãƒ•ãƒ­ãƒŗãƒˆã‚¨ãƒŗãƒ‰ã‚¨ãƒŗã‚¸ãƒ‹ã‚ĸ' },
    { key: 'role', value: 'backend', label: 'ãƒãƒƒã‚¯ã‚¨ãƒŗãƒ‰ã‚¨ãƒŗã‚¸ãƒ‹ã‚ĸ' },
    { key: 'role', value: 'devops', label: 'フãƒĢ゚ã‚ŋãƒƒã‚¯ã‚¨ãƒŗã‚¸ãƒ‹ã‚ĸ' },
    { key: 'role', value: 'security', label: 'デãƒŧã‚ŋベãƒŧã‚šã‚¨ãƒŗã‚¸ãƒ‹ã‚ĸ' },
  ];

  return (
    <EditAttributeSelection
      data={data}
      options={options}
      labels={{
        editAttributeSelectionTitle: 'čˇį¨Ž',
        subtitle: 'ごč‡ĒčēĢãŽčˇį¨Žã‚’é¸æŠžã—ãĻください',
        fieldName: 'åŊšå‰˛',
        submitButton: 'äŋå­˜',
      }}
      layout="grid"
      onDataChange={(nextData) => {
        setData(nextData);
      }}
    />
  );
}
Result
Loading...

Important Props​

Core Props​

PropTypeRequiredDefaultDescription
dataEditAttributeSelectionFormData ({ attributes: { key: string; value: string }[] })Yes-Controlled form state.
onDataChange(data: EditAttributeSelectionFormData, meta: { name: string; value: unknown; cause: one of input, change, blur, clear, reset, programmatic; event?: React.SyntheticEvent }) => voidYes-Called whenever a field changes. meta.name uses bracket notation paths.
errors{ [fieldPath: string]: string | string[] }NoundefinedField-level errors forwarded into the block context for custom flows.

Content Props​

PropTypeRequiredDefaultDescription
labels{ editAttributeSelectionTitle?: React.ReactNode; subtitle?: React.ReactNode; fieldName?: React.ReactNode; submitButton?: React.ReactNode }NoundefinedCopy for the root title, subtitle, field name, and submit button.
optionsEditAttributeSelectionOption[] ({ key: string; value: string; label: string }[])Yes-Checkbox options rendered by CheckboxList.

Layout and Composition Props​

PropTypeRequiredDefaultDescription
layout'one-column' | 'grid'No'one-column'Controls how the default checkbox list is arranged.
childrenBlocksOverride<typeof defaultBlocks, CustomBlocks>NoundefinedPass JSX compound components or a function that returns blocks and blockOrder. The root renders Title, Subtitle, FieldName, CheckboxList, and SubmitButton by default.

Inherited props come from StackProps<'form'> with children replaced by the block override API, so standard form/container props such as onSubmit, id, className, and sx are available.

Default UI Blocks​

BlockBuilt onNotes
EditAttributeSelectionStackRoot form shell with component="form".
TitleTypographyvariant="h4", component="h2", centered. Uses labels.editAttributeSelectionTitle by default.
SubtitleTypographyvariant="body2" with bold text. Uses labels.subtitle by default.
FieldNameTypographyvariant="body2" with bold text. Uses labels.fieldName by default.
CheckboxListStack + CheckboxFieldRenders the options array as checkboxes. layout="grid" uses a responsive grid: 2 columns on xs, 3 on sm, 4 on md.
SubmitButtonButtonvariant="contained", size="large", fullWidth, type="submit". Defaults to äŋå­˜.

Extra field primitives​

PrimitiveMain PropsInheritsBuilt onNotes
CheckboxFieldname, value, label, controlFormControlLabelProps with control optionalFormControlLabel + CheckboxToggles a single { key, value } entry in data.attributes. Available for custom flows, but not rendered by the stock layout.

TypeScript​

export type EditAttributeSelectionFormData = {
attributes: {
key: string;
value: string;
}[];
};

export type EditAttributeSelectionOption = {
key: string;
value: string;
label: string;
};