/* ! * (c) Copyright 2026 Palantir Technologies Inc. All rights reserved. */ import type { Meta, StoryObj } from "@storybook/react-vite"; import { DashedPaddedContainer, storybookLayoutDecorator, StoryLabel } from "@storybook-common"; import { Flex } from "@blueprintjs/labs"; import { Intent } from "../../common"; import { EditableText } from "./editableText"; const disabledArgs = ["customInputAttributes", "elementRef", "contentId"] as const satisfies ReadonlyArray< keyof React.ComponentProps >; const meta: Meta = { title: "Core/EditableText", component: EditableText, decorators: [storybookLayoutDecorator], args: { placeholder: "Click to Edit", disabled: false, multiline: false, selectAllOnFocus: false, confirmOnEnterKey: false, }, argTypes: { intent: { control: "select", options: Object.values(Intent), }, disabled: { control: "boolean", }, multiline: { control: "boolean", }, selectAllOnFocus: { control: "boolean", }, confirmOnEnterKey: { control: "boolean", }, placeholder: { control: "text", }, onCancel: { table: { disable: true } }, onChange: { table: { disable: true } }, onConfirm: { table: { disable: true } }, onEdit: { table: { disable: true } }, className: { table: { disable: true } }, alwaysRenderInput: { table: { disable: true } }, defaultValue: { table: { disable: true } }, isEditing: { table: { disable: true } }, maxLength: { table: { disable: true } }, minWidth: { table: { disable: true } }, maxLines: { table: { disable: true } }, minLines: { table: { disable: true } }, value: { table: { disable: true } }, type: { table: { disable: true } }, ...disabledArgs.reduce( (acc, argName) => { acc[argName] = { table: { disable: true } }; return acc; }, {} as Record<(typeof disabledArgs)[number], { table: { disable: boolean } }>, ), }, } satisfies Meta; export default meta; type Story = StoryObj; /** * A basic editable text field with default styling. */ export const Default: Story = { args: { placeholder: "Click to Edit", }, }; /** * Use the `intent` prop to apply semantic color to the editable text. */ export const IntentExample: Story = { name: "Intent", argTypes: { intent: { table: { disable: true } }, }, render: args => ( {Object.values(Intent).map(intent => ( ))} ), }; /** * EditableText supports `disabled` state where editing is prevented. */ export const StateExample: Story = { name: "State", argTypes: { disabled: { table: { disable: true } }, }, render: args => ( ), }; /** * Enabling the `multiline` prop transforms EditableText into a `