import { html, ref, repeat } from '@microsoft/fast-element';
import { type Meta, renderComponent, type StoryArgs, type StoryObj } from '../helpers.stories.js';
import { colorStatusSuccessBackground3 } from '../theme/design-tokens.js';
import { getStorybookHelpers } from '../../.storybook/wc-toolkit-helpers.js';
import type { Field as FluentField } from './field.js';
import { LabelPosition } from './field.options.js';
type Story = StoryObj;
const { argTypes } = getStorybookHelpers('fluent-field');
const SuccessIcon = html.partial(/* html */ `
`);
export const storyTemplate = html>`
${story => story.labelSlottedContent?.()} ${story => story.inputSlottedContent?.()}
${story => story.messageSlottedContent?.()}
`;
const textInputLink = 'Text Input';
const textAreaLink = 'Text Area';
const storyDescription = `
The ${textInputLink} and ${textAreaLink} components have a specific implementation with \`\` that differs from other form controls to ensure proper accessibility support.
**For Text Input and Text Area:**
- The label must be passed as a child element (not using the field's label slot)
- This implementation is required for accessibility features like zoom text and voice over to work correctly
- A previous issue where the aria-hidden attribute prevented zoom text functionality on the field label has been resolved
**For Other Form Controls (checkbox, radio, etc.):**
- The label should be placed in the field's label slot using \`slot="label"\`
- This is the standard implementation pattern for most form controls
This distinction ensures that text-based inputs maintain proper accessibility while other controls follow the standard slotting pattern.
`;
export default {
title: 'Components/Field',
render: renderComponent(storyTemplate),
excludeStories: ['storyTemplate'],
parameters: {
docs: {
description: {
component: storyDescription,
},
},
},
args: {
label: {
text: 'Example field',
},
message: {
message: 'This is a success message',
icon: () => html`${SuccessIcon}`,
},
labelSlottedContent: () => html``,
inputSlottedContent: () => html``,
labelPosition: LabelPosition.above,
},
argTypes,
} as Meta;
export const Default: Story = {};
export const LabelPositions: Story = {
render: renderComponent(html>`
${repeat(
story => story.storyItems,
html`