1- import { html , repeat } from '@microsoft/fast-element' ;
1+ import { html , ref , repeat } from '@microsoft/fast-element' ;
22import { uniqueId } from '@microsoft/fast-web-utilities' ;
3- import { LabelPosition , ValidationFlags } from '../field/field.options.js' ;
3+ import { LabelPosition } from '../field/field.options.js' ;
44import { type Meta , renderComponent , type StoryArgs , type StoryObj } from '../helpers.stories.js' ;
55import type { Checkbox as FluentCheckbox } from './checkbox.js' ;
66import { CheckboxShape , CheckboxSize } from './checkbox.options.js' ;
@@ -18,6 +18,7 @@ const storyTemplate = html<StoryArgs<FluentCheckbox>>`
1818 shape="${ story => story . shape } "
1919 size="${ story => story . size } "
2020 slot="${ story => story . slot } "
21+ ${ ref ( 'checkbox' ) }
2122 >
2223 ${ story => story . checkedIndicatorContent ?.( ) } ${ story => story . indeterminateIndicatorContent ?.( ) }
2324 </fluent-checkbox>
@@ -123,7 +124,7 @@ export default {
123124export const Default : Story = { } ;
124125
125126export const Checkbox : Story = {
126- render : renderComponent ( storyTemplate ) . bind ( { } ) ,
127+ render : renderComponent ( storyTemplate ) ,
127128 args : {
128129 id : uniqueId ( 'checkbox-' ) ,
129130 } ,
@@ -132,7 +133,7 @@ export const Checkbox: Story = {
132133export const Checked : Story = {
133134 render : renderComponent ( html < StoryArgs < FluentCheckbox >> `
134135 ${ repeat ( story => story . storyContent , html < StoryArgs < FluentCheckbox >> `${ fieldStoryTemplate } <br />` ) }
135- ` ) . bind ( { } ) ,
136+ ` ) ,
136137 args : {
137138 storyContent : [
138139 {
@@ -159,7 +160,7 @@ export const Checked: Story = {
159160export const Indeterminate : Story = {
160161 render : renderComponent ( html < StoryArgs < FluentCheckbox >> `
161162 ${ repeat ( story => story . storyContent , html < StoryArgs < FluentCheckbox >> `${ fieldStoryTemplate } <br />` ) }
162- ` ) . bind ( { } ) ,
163+ ` ) ,
163164 args : {
164165 storyContent : [
165166 {
@@ -186,7 +187,7 @@ export const Indeterminate: Story = {
186187export const Disabled : Story = {
187188 render : renderComponent ( html < StoryArgs < FluentCheckbox >> `
188189 ${ repeat ( story => story . storyContent , html < StoryArgs < FluentCheckbox >> `${ fieldStoryTemplate } <br />` ) }
189- ` ) . bind ( { } ) ,
190+ ` ) ,
190191 args : {
191192 storyContent : [
192193 {
@@ -250,30 +251,33 @@ export const Disabled: Story = {
250251
251252export const Required : Story = {
252253 render : renderComponent ( html < StoryArgs < FluentCheckbox >> `
253- <form style="display: inline-flex; gap: 1em; align-items: baseline">
254+ <form
255+ @reset="${ story => story . successMessage . toggleAttribute ( 'hidden' , true ) } "
256+ @submit="${ story => story . checkbox . checkValidity ( ) && story . successMessage . toggleAttribute ( 'hidden' , false ) } "
257+ style="display: inline-flex; flex-direction: column; gap: 1rem; max-width: 400px;"
258+ >
259+ ${ fieldStoryTemplate }
254260 <div>
255- <fluent-checkbox id="required-fluent-checkbox" required> </fluent-checkbox >
256- <label for="required-fluent-checkbox">Required</label >
261+ <fluent-button type="submit">Submit </fluent-button >
262+ <fluent-button type="reset">Reset</fluent-button >
257263 </div>
258- ${ fieldStoryTemplate }
259- <fluent-button type="submit">Submit</fluent-button>
264+ <fluent-text ${ ref ( 'successMessage' ) } hidden>Form submitted successfully!</fluent-text>
260265 </form>
261- ` ) . bind ( { } ) ,
266+ ` ) ,
262267 args : {
263268 storyContent : storyTemplate ,
264269 slot : 'input' ,
265270 labelPosition : LabelPosition . after ,
266271 id : uniqueId ( 'checkbox-' ) ,
267272 required : true ,
268- label : 'Required' ,
269- messages : [ { message : 'This field is required' , flag : ValidationFlags . valueMissing } ] ,
273+ label : 'Check this to submit the form' ,
270274 } ,
271275} ;
272276
273277export const Large : Story = {
274278 render : renderComponent ( html < StoryArgs < FluentCheckbox >> `
275279 ${ repeat ( story => story . storyContent , html < StoryArgs < FluentCheckbox >> `${ fieldStoryTemplate } <br />` ) }
276- ` ) . bind ( { } ) ,
280+ ` ) ,
277281 args : {
278282 storyContent : [
279283 {
@@ -317,7 +321,7 @@ export const Large: Story = {
317321} ;
318322
319323export const LabelBefore : Story = {
320- render : renderComponent ( fieldStoryTemplate ) . bind ( { } ) ,
324+ render : renderComponent ( fieldStoryTemplate ) ,
321325 args : {
322326 storyContent : storyTemplate ,
323327 id : uniqueId ( 'checkbox-' ) ,
@@ -328,7 +332,7 @@ export const LabelBefore: Story = {
328332} ;
329333
330334export const LabelWrapping : Story = {
331- render : renderComponent ( fieldStoryTemplate ) . bind ( { } ) ,
335+ render : renderComponent ( fieldStoryTemplate ) ,
332336 args : {
333337 storyContent : storyTemplate ,
334338 id : uniqueId ( 'checkbox-' ) ,
@@ -348,7 +352,7 @@ export const LabelWrapping: Story = {
348352export const Circular : Story = {
349353 render : renderComponent ( html < StoryArgs < FluentCheckbox >> `
350354 ${ repeat ( story => story . storyContent , html < StoryArgs < FluentCheckbox >> `${ fieldStoryTemplate } <br />` ) }
351- ` ) . bind ( { } ) ,
355+ ` ) ,
352356 args : {
353357 storyContent : [
354358 {
0 commit comments