Skip to content

Commit 086a046

Browse files
chore: Add metrics for attribute editor properties (#3438)
1 parent 053e032 commit 086a046

File tree

4 files changed

+17
-4
lines changed

4 files changed

+17
-4
lines changed

src/__tests__/snapshot-tests/__snapshots__/documenter.test.ts.snap

+1
Original file line numberDiff line numberDiff line change
@@ -2045,6 +2045,7 @@ The event \`detail\` contains the index of the corresponding item.",
20452045
"type": "string",
20462046
},
20472047
{
2048+
"defaultValue": "'normal'",
20482049
"description": "Specifies the variant to use for the add button. By default a normal button is used.
20492050
Use \`inline-link\` when using an attribute editor nested inside complex attribute editing
20502051
with expandable sections.",

src/attribute-editor/index.tsx

+12-2
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,24 @@ import InternalAttributeEditor from './internal';
99

1010
const AttributeEditor = React.forwardRef(
1111
<T,>(
12-
{ items = [], isItemRemovable = () => true, ...props }: AttributeEditorProps<T>,
12+
{ items = [], addButtonVariant = 'normal', isItemRemovable = () => true, ...props }: AttributeEditorProps<T>,
1313
ref: React.Ref<AttributeEditorProps.Ref>
1414
) => {
15-
const baseComponentProps = useBaseComponent('AttributeEditor');
15+
const baseComponentProps = useBaseComponent('AttributeEditor', {
16+
props: {
17+
addButtonVariant: addButtonVariant,
18+
},
19+
metadata: {
20+
definitionItems: props.definition?.length ?? null,
21+
hasGridLayout: !!props.gridLayout,
22+
hasCustomRowActions: !!props.customRowActions,
23+
},
24+
});
1625
return (
1726
<InternalAttributeEditor
1827
items={items}
1928
isItemRemovable={isItemRemovable}
29+
addButtonVariant={addButtonVariant}
2030
{...props}
2131
{...baseComponentProps}
2232
ref={ref}

src/attribute-editor/internal.tsx

+3-2
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ import { getGridTemplateColumns } from './utils';
2222

2323
import styles from './styles.css.js';
2424

25-
type InternalAttributeEditorProps<T> = SomeRequired<AttributeEditorProps<T>, 'items'> & InternalBaseComponentProps;
25+
type InternalAttributeEditorProps<T> = SomeRequired<AttributeEditorProps<T>, 'items' | 'addButtonVariant'> &
26+
InternalBaseComponentProps;
2627

2728
const InternalAttributeEditor = React.forwardRef(
2829
<T,>(
@@ -35,7 +36,7 @@ const InternalAttributeEditor = React.forwardRef(
3536
isItemRemovable = () => true,
3637
empty,
3738
addButtonText,
38-
addButtonVariant = 'normal',
39+
addButtonVariant,
3940
removeButtonText,
4041
removeButtonAriaLabel,
4142
customRowActions,

src/tag-editor/index.tsx

+1
Original file line numberDiff line numberDiff line change
@@ -305,6 +305,7 @@ const TagEditor = React.forwardRef(
305305
removeButtonText={i18nStrings?.removeButton}
306306
disableAddButton={remainingTags <= 0}
307307
empty={i18n('i18nStrings.emptyTags', i18nStrings?.emptyTags)}
308+
addButtonVariant="normal"
308309
additionalInfo={
309310
remainingTags < 0 ? (
310311
<FormFieldError errorIconAriaLabel={i18nStrings?.errorIconAriaLabel}>

0 commit comments

Comments
 (0)