diff --git a/packages/storybook/.storybook/preview.js b/packages/storybook/.storybook/preview.js index c9a45a56b8..c8039aaba8 100644 --- a/packages/storybook/.storybook/preview.js +++ b/packages/storybook/.storybook/preview.js @@ -105,5 +105,5 @@ configureActions({ depth: 1 }); -// Update the GUID on this line to trigger a turbosnap full rebuild: 354fdf0e-bdb4-4dd9-a6e5-21bf71c6efe6 +// Update the GUID on this line to trigger a turbosnap full rebuild: 354fdf0f-bdb4-4dd9-a6e5-21bf71c6efe6 // See https://www.chromatic.com/docs/turbosnap/#full-rebuilds diff --git a/packages/storybook/src/nimble/mapping/empty/mapping-empty.stories.ts b/packages/storybook/src/nimble/mapping/empty/mapping-empty.stories.ts index a818334157..5a053d9be8 100644 --- a/packages/storybook/src/nimble/mapping/empty/mapping-empty.stories.ts +++ b/packages/storybook/src/nimble/mapping/empty/mapping-empty.stories.ts @@ -1,7 +1,7 @@ import { html } from '@microsoft/fast-element'; import type { Meta, StoryObj } from '@storybook/html'; import { mappingKeyDescription } from '../base/story-helpers'; -import { createUserSelectedThemeStory } from '../../../utilities/storybook'; +import { apiCategory, createUserSelectedThemeStory } from '../../../utilities/storybook'; import { hiddenWrapper } from '../../../utilities/hidden'; const metadata: Meta = { @@ -25,11 +25,13 @@ export const emptyMapping: StoryObj = { argTypes: { key: { control: false, - description: mappingKeyDescription('nothing') + description: mappingKeyDescription('nothing'), + table: { category: apiCategory.attributes }, }, text: { control: false, - description: 'A textual description of the value. This value will be displayed in group rows, but table cells will be empty. This attribute is required.' + description: 'A textual description of the value. This value will be displayed in group rows, but table cells will be empty. This attribute is required.', + table: { category: apiCategory.attributes }, } }, args: {} diff --git a/packages/storybook/src/nimble/mapping/icon/mapping-icon.stories.ts b/packages/storybook/src/nimble/mapping/icon/mapping-icon.stories.ts index 818af643b6..9c1452554a 100644 --- a/packages/storybook/src/nimble/mapping/icon/mapping-icon.stories.ts +++ b/packages/storybook/src/nimble/mapping/icon/mapping-icon.stories.ts @@ -1,7 +1,7 @@ import { html } from '@microsoft/fast-element'; import type { Meta, StoryObj } from '@storybook/html'; import { mappingKeyDescription } from '../base/story-helpers'; -import { createUserSelectedThemeStory } from '../../../utilities/storybook'; +import { apiCategory, createUserSelectedThemeStory } from '../../../utilities/storybook'; import { hiddenWrapper } from '../../../utilities/hidden'; const metadata: Meta = { @@ -23,28 +23,33 @@ export const iconMapping: StoryObj = { argTypes: { key: { description: mappingKeyDescription('the mapped icon'), - control: false + control: false, + table: { category: apiCategory.attributes }, }, icon: { control: false, - description: 'The tag name of the Nimble icon to render, e.g. `nimble-icon-check`.' + description: 'The tag name of the Nimble icon to render, e.g. `nimble-icon-check`.', + table: { category: apiCategory.attributes }, }, severity: { control: false, description: - 'Must be one of the values in the `IconSeverity` enum. Controls the color of the icon.' + 'Must be one of the values in the `IconSeverity` enum. Controls the color of the icon.', + table: { category: apiCategory.attributes }, }, text: { control: false, description: `A textual description of the value. The text will be displayed next to the icon in a cell if \`text-hidden\` is not set, or as the tooltip and accessible name of the icon if \`text-hidden\` is set. The text is also displayed next to the icon - in a group header. This attribute is required.` + in a group header. This attribute is required.`, + table: { category: apiCategory.attributes }, }, textHidden: { control: false, name: 'text-hidden', description: - "When set, the text is hidden within the table's cells. When unset, the text is rendered next to the icon within the cell." + "When set, the text is hidden within the table's cells. When unset, the text is rendered next to the icon within the cell.", + table: { category: apiCategory.attributes }, } }, args: {} diff --git a/packages/storybook/src/nimble/mapping/spinner/mapping-spinner.stories.ts b/packages/storybook/src/nimble/mapping/spinner/mapping-spinner.stories.ts index f07098343a..9476d03dba 100644 --- a/packages/storybook/src/nimble/mapping/spinner/mapping-spinner.stories.ts +++ b/packages/storybook/src/nimble/mapping/spinner/mapping-spinner.stories.ts @@ -1,7 +1,7 @@ import { html } from '@microsoft/fast-element'; import type { Meta, StoryObj } from '@storybook/html'; import { mappingKeyDescription } from '../base/story-helpers'; -import { createUserSelectedThemeStory } from '../../../utilities/storybook'; +import { apiCategory, createUserSelectedThemeStory } from '../../../utilities/storybook'; import { hiddenWrapper } from '../../../utilities/hidden'; const metadata: Meta = { @@ -23,19 +23,22 @@ export const spinnerMapping: StoryObj = { argTypes: { key: { description: mappingKeyDescription('a spinner'), - control: false + control: false, + table: { category: apiCategory.attributes }, }, text: { control: false, description: `A textual description of the value. The text will be displayed next to the spinner in a cell if \`text-hidden\` is not set, or as the tooltip and accessible name of the spinner if \`text-hidden\` is set. The text is also displayed next to the spinner - in a group header. This attribute is required.` + in a group header. This attribute is required.`, + table: { category: apiCategory.attributes }, }, textHidden: { control: false, name: 'text-hidden', description: - "When set, the text is hidden within the table's cells. When unset, the text is rendered next to the spinner within the cell." + "When set, the text is hidden within the table's cells. When unset, the text is rendered next to the spinner within the cell.", + table: { category: apiCategory.attributes }, } }, args: {} diff --git a/packages/storybook/src/nimble/mapping/text/mapping-text.stories.ts b/packages/storybook/src/nimble/mapping/text/mapping-text.stories.ts index ea8d34b752..38a1c62cb7 100644 --- a/packages/storybook/src/nimble/mapping/text/mapping-text.stories.ts +++ b/packages/storybook/src/nimble/mapping/text/mapping-text.stories.ts @@ -1,7 +1,7 @@ import { html } from '@microsoft/fast-element'; import type { Meta, StoryObj } from '@storybook/html'; import { mappingKeyDescription } from '../base/story-helpers'; -import { createUserSelectedThemeStory } from '../../../utilities/storybook'; +import { apiCategory, createUserSelectedThemeStory } from '../../../utilities/storybook'; import { hiddenWrapper } from '../../../utilities/hidden'; const metadata: Meta = { @@ -23,10 +23,12 @@ export const textMapping: StoryObj = { argTypes: { key: { description: mappingKeyDescription('the mapped display text'), - control: false + control: false, + table: { category: apiCategory.attributes }, }, text: { - description: 'The display text.' + description: 'The display text.', + table: { category: apiCategory.attributes }, } }, args: {} diff --git a/packages/storybook/src/nimble/mapping/user/mapping-user.stories.ts b/packages/storybook/src/nimble/mapping/user/mapping-user.stories.ts index 87b3c44f42..3107486c55 100644 --- a/packages/storybook/src/nimble/mapping/user/mapping-user.stories.ts +++ b/packages/storybook/src/nimble/mapping/user/mapping-user.stories.ts @@ -1,6 +1,6 @@ import { html } from '@microsoft/fast-element'; import type { Meta, StoryObj } from '@storybook/html'; -import { createUserSelectedThemeStory } from '../../../utilities/storybook'; +import { apiCategory, createUserSelectedThemeStory } from '../../../utilities/storybook'; import { hiddenWrapper } from '../../../utilities/hidden'; const metadata: Meta = { @@ -21,13 +21,15 @@ export const userMapping: StoryObj = { render: createUserSelectedThemeStory(hiddenWrapper(html``)), argTypes: { key: { - description: 'A key (url) for each user that maps to a user', - control: false + description: 'A URL that uniquely identifies the user, e.g. `user:1234`.', + control: false, + table: { category: apiCategory.attributes }, }, displayName: { name: 'display-name', description: - 'A string which renders the textual representation of user name' + 'The display name to render for the user, e.g. `Oscar Meyer 🌭`.', + table: { category: apiCategory.attributes }, } }, args: {} diff --git a/packages/storybook/src/nimble/table-column/anchor/table-column-anchor.mdx b/packages/storybook/src/nimble/table-column/anchor/table-column-anchor.mdx index 114aada9ff..2038ebfdbd 100644 --- a/packages/storybook/src/nimble/table-column/anchor/table-column-anchor.mdx +++ b/packages/storybook/src/nimble/table-column/anchor/table-column-anchor.mdx @@ -1,6 +1,7 @@ import { Controls, Canvas, Meta, Title } from '@storybook/blocks'; import TargetDocs from '../../patterns/anchor/target-docs.mdx'; import * as tableColumnAnchorStories from './table-column-anchor.stories'; +import ComponentApisLink from '../../../docs/component-apis-link.mdx'; import { tableColumnAnchorTag } from '../../../../../nimble-components/src/table-column/anchor'; import { tableTag } from '../../../../../nimble-components/src/table'; @@ -14,6 +15,7 @@ The column is used to display string fields a ## API + ### Target Configuration diff --git a/packages/storybook/src/nimble/table-column/anchor/table-column-anchor.stories.ts b/packages/storybook/src/nimble/table-column/anchor/table-column-anchor.stories.ts index f9362f28a3..8b63688a83 100644 --- a/packages/storybook/src/nimble/table-column/anchor/table-column-anchor.stories.ts +++ b/packages/storybook/src/nimble/table-column/anchor/table-column-anchor.stories.ts @@ -11,7 +11,7 @@ import { sharedTableArgs, sharedTableArgTypes } from '../base/table-column-stories-utils'; -import { createUserSelectedThemeStory } from '../../../utilities/storybook'; +import { apiCategory, createUserSelectedThemeStory } from '../../../utilities/storybook'; const metadata: Meta = { title: 'Components/Table Column: Anchor', @@ -102,28 +102,33 @@ export const anchorColumn: StoryObj = { description: 'Set this attribute to identify which field in the data record contains the visible text value for each cell in the column. The field values must be of type `string`. If a given row does not define a property with this name, that row will use the url as the label.', options: ['firstName', 'lastName'], - control: { type: 'radio' } + control: { type: 'radio' }, + table: { category: apiCategory.attributes }, }, hrefFieldName: { name: 'href-field-name', description: 'Set this attribute to identify which field in the data record contains the link url for each cell in the column. If the field is not defined in a particular record, that cell will be displayed as plain text instead of a link. The field values must be of type `string`.', - control: false + control: false, + table: { category: apiCategory.attributes }, }, appearance: { options: Object.keys(AnchorAppearance), control: { type: 'radio' }, description: - 'Set to `prominent` to make the anchor appear in a different color than normal text. This has no effect under the Color theme.' + 'Set to `prominent` to make the anchor appear in a different color than normal text. This has no effect under the Color theme.', + table: { category: apiCategory.attributes }, }, underlineHidden: { name: 'underline-hidden', defaultValue: { summary: 'false' }, - description: 'Causes the underline to be hidden except on hover.' + description: 'Causes the underline to be hidden except on hover.', + table: { category: apiCategory.attributes }, }, placeholder: { description: - 'The placeholder text to display when the label and href are both `undefined` or `null` for a record.' + 'The placeholder text to display when the label and href are both `undefined` or `null` for a record.', + table: { category: apiCategory.attributes }, } }, args: { diff --git a/packages/storybook/src/nimble/table-column/base/table-column.mdx b/packages/storybook/src/nimble/table-column/base/table-column.mdx index ab236f23fb..bcadafaab3 100644 --- a/packages/storybook/src/nimble/table-column/base/table-column.mdx +++ b/packages/storybook/src/nimble/table-column/base/table-column.mdx @@ -1,41 +1,49 @@ import { Controls, Canvas, Meta, Title, Description } from '@storybook/blocks'; import * as tableColumnStories from './table-column.stories'; +import ComponentApisLink from '../../../docs/component-apis-link.mdx'; <Description of={tableColumnStories} /> -## Adding columns +## API + +<Controls of={tableColumnStories.api} /> +<ComponentApisLink /> + +## Examples + +### Adding columns <Description of={tableColumnStories.addingColumns} /> <Canvas of={tableColumnStories.addingColumns} /> <Controls of={tableColumnStories.addingColumns} /> -## Setting header content +### Setting header content <Description of={tableColumnStories.headerContent} /> <Canvas of={tableColumnStories.headerContent} /> <Controls of={tableColumnStories.headerContent} /> -## Configuring common attributes +### Hiding -<Description of={tableColumnStories.commonAttributes} /> -<Canvas of={tableColumnStories.commonAttributes} /> -<Controls of={tableColumnStories.commonAttributes} /> +<Description of={tableColumnStories.columnHidden} /> +<Canvas of={tableColumnStories.columnHidden} /> +<Controls of={tableColumnStories.columnHidden} /> -## Sorting +### Sorting <Description of={tableColumnStories.sorting} /> <Canvas of={tableColumnStories.sorting} /> <Controls of={tableColumnStories.sorting} /> -## Grouping +### Grouping <Description of={tableColumnStories.grouping} /> <Canvas of={tableColumnStories.grouping} /> <Controls of={tableColumnStories.grouping} /> -## Column Width +### Column width <Description of={tableColumnStories.width} /> <Canvas of={tableColumnStories.width} /> diff --git a/packages/storybook/src/nimble/table-column/base/table-column.stories.ts b/packages/storybook/src/nimble/table-column/base/table-column.stories.ts index e463532081..0680c82b42 100644 --- a/packages/storybook/src/nimble/table-column/base/table-column.stories.ts +++ b/packages/storybook/src/nimble/table-column/base/table-column.stories.ts @@ -21,7 +21,7 @@ import { sharedTableArgTypes, sharedTableArgs } from './table-column-stories-utils'; -import { createUserSelectedThemeStory } from '../../../utilities/storybook'; +import { apiCategory, createUserSelectedThemeStory } from '../../../utilities/storybook'; const simpleData = [ { @@ -74,7 +74,7 @@ const simpleData = [ ] as const; const overviewText = `This page contains information about configuring the columns of a \`nimble-table\`. -See **Table** for information about configuring the table itself and the **Table Column** specific docs for +See [Table](?path=/docs/components-table--docs) for information about configuring the table itself and the **Table Column** pages for information about specific types of column.`; const metadata: Meta<SharedTableArgs> = { @@ -136,6 +136,96 @@ const metadata: Meta<SharedTableArgs> = { export default metadata; +interface ApiTableArgs extends SharedTableArgs { + content: undefined; + columnHidden: undefined; + columnId: undefined; + actionMenuSlot: undefined; + actionMenuLabel: undefined; + sortDirection: undefined; + sortIndex: undefined; + groupIndex: undefined; + groupingDisabled: undefined; + fractionalWidth: undefined; + minPixelWidth: undefined; +} + +export const api: StoryObj<ApiTableArgs> = { + parameters: { + // Story used by documentation, not needed for visual comparison. + chromatic: { disableSnapshot: true } + }, + argTypes: { + content: { + name: 'default', + description: 'Text or an icon added to the default slot of the column will be placed in the column header. See **Setting header content** for more information.', + table: { category: apiCategory.slots }, + control: false + }, + columnHidden: { + name: 'column-hidden', + description: 'Whether the column is hidden from display. See **Hiding** for more information.', + table: { category: apiCategory.attributes }, + control: false + }, + columnId: { + name: 'column-id', + description: + "Optionally use the `column-id` attribute to uniquely identify a column for features like adding an action menu. If you aren't using features that require a column id you may leave it unset for all columns. If you provide `column-id` for any column within a table then you must provide it for all and they must be unique strings.", + table: { category: apiCategory.attributes }, + control: false + }, + actionMenuSlot: { + name: 'action-menu-slot', + description: 'Configure this column to have an action menu by setting this attribute to the name of a slot in the table that contains the menu.', + table: { category: apiCategory.attributes }, + control: false + }, + actionMenuLabel: { + name: 'action-menu-label', + description: 'Configures the title and accessible label of the action menu button for this column.', + table: { category: apiCategory.attributes }, + control: false + }, + sortDirection: { + name: 'sort-direction', + description: 'The direction to sort the data in the column. See **Sorting** for more information.', + table: { category: apiCategory.attributes }, + control: false + }, + sortIndex: { + name: 'sort-index', + description: 'Specifies the sort precedence of the column within the set of all sorted columns. See **Sorting** for more information.', + table: { category: apiCategory.attributes }, + control: false + }, + groupIndex: { + name: 'group-index', + description: 'Specifies the group precedence of the column within the set of all grouped columns. See **Grouping** for more information.', + table: { category: apiCategory.attributes }, + control: false + }, + groupingDisabled: { + name: 'grouping-disabled', + description: 'Prevents the column from participating in grouping. See **Grouping** for more information.', + table: { category: apiCategory.attributes }, + control: false + }, + fractionalWidth: { + name: 'fractional-width', + description: 'Configures the proportion of the table width that this column should occupy initially. See **Column width** for more information.', + table: { category: apiCategory.attributes }, + control: false + }, + minPixelWidth: { + name: 'min-pixel-width', + description: 'Configures the minimum width that the column can be interactively resized to. See **Column width** for more information.', + table: { category: apiCategory.attributes }, + control: false + }, + } +}; + type ColumnOrderOption = 'FirstName, LastName' | 'LastName, FirstName'; interface ColumnOrderTableArgs extends SharedTableArgs { @@ -270,23 +360,22 @@ export const headerContent: StoryObj<HeaderContentTableArgs> = { } }; -const commonColumnAttributes = 'In addition to the attributes described in other stories there are other attributes available on all column types.'; +const columnHiddenDescription = 'Columns can be added to the table but hidden from display. One use case for this is to sort by a field but not display its value.'; -interface CommonAttributesTableArgs extends SharedTableArgs { +interface ColumnHiddenTableArgs extends SharedTableArgs { columnHidden: boolean; - columnId: string; } -export const commonAttributes: StoryObj<CommonAttributesTableArgs> = { +export const columnHidden: StoryObj<ColumnHiddenTableArgs> = { parameters: { docs: { description: { - story: commonColumnAttributes + story: columnHiddenDescription } } }, // prettier-ignore - render: createUserSelectedThemeStory(html<CommonAttributesTableArgs>` + render: createUserSelectedThemeStory(html<ColumnHiddenTableArgs>` <${tableTag} ${ref('tableRef')} data-unused="${x => x.updateData(x)}" @@ -319,13 +408,8 @@ export const commonAttributes: StoryObj<CommonAttributesTableArgs> = { columnHidden: { name: 'column-hidden', description: - 'Add the `column-hidden` attribute to hide a column from display. One use case for this is to sort by a field but not display its value.' + 'Add the `column-hidden` attribute to hide a column from display.' }, - columnId: { - name: 'column-id', - description: - "Optionally use the `column-id` attribute to uniquely identify a column for features like adding an action menu. If you aren't using features that require a column id you may leave it unset for all columns. If you provide `column-id` for any column within a table then you must provide it for all and they must be unique strings." - } }, args: { columnHidden: false diff --git a/packages/storybook/src/nimble/table-column/date-text/table-column-date-text.mdx b/packages/storybook/src/nimble/table-column/date-text/table-column-date-text.mdx index fa7d123f81..5a971395fe 100644 --- a/packages/storybook/src/nimble/table-column/date-text/table-column-date-text.mdx +++ b/packages/storybook/src/nimble/table-column/date-text/table-column-date-text.mdx @@ -1,6 +1,7 @@ import { Canvas, Meta, Controls, Title } from '@storybook/blocks'; import { NimbleTableColumnDateText } from './table-column-date-text.react'; import * as tableColumnDateTextStories from './table-column-date-text.stories'; +import ComponentApisLink from '../../../docs/component-apis-link.mdx'; import { tableColumnDateTextTag } from '../../../../../nimble-components/src/table-column/date-text'; import { tableTag } from '../../../../../nimble-components/src/table'; import NoNullAndUndefinedBestPractice from '../../patterns/table-column/no-null-and-undefined-best-practice-docs.mdx'; @@ -11,7 +12,11 @@ import NoNullAndUndefinedBestPractice from '../../patterns/table-column/no-null- The <Tag name={tableColumnDateTextTag}/> column is used to display date-time fields as text in the <Tag name={tableTag}/>. The date-time values must be of type `number` and represent the number of milliseconds since January 1, 1970 UTC. This is the representation used by the [JavaScript `Date` type](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date). Dates are formatted in a locale-specific way based on the value of the `lang` token, which can be set via the [nimble-theme-provider](?path=/docs/tokens-theme-provider--docs). <Canvas of={tableColumnDateTextStories.dateTextColumn} /> + +## API + <Controls of={tableColumnDateTextStories.dateTextColumn} /> +<ComponentApisLink /> {/* ## Styling */} diff --git a/packages/storybook/src/nimble/table-column/date-text/table-column-date-text.stories.ts b/packages/storybook/src/nimble/table-column/date-text/table-column-date-text.stories.ts index c1c0d425c9..dae862ffc3 100644 --- a/packages/storybook/src/nimble/table-column/date-text/table-column-date-text.stories.ts +++ b/packages/storybook/src/nimble/table-column/date-text/table-column-date-text.stories.ts @@ -28,7 +28,7 @@ import { sharedTableArgTypes, sharedTableArgs } from '../base/table-column-stories-utils'; -import { createUserSelectedThemeStory } from '../../../utilities/storybook'; +import { apiCategory, checkValidityDescription, createUserSelectedThemeStory } from '../../../utilities/storybook'; const simpleData = [ { @@ -163,44 +163,51 @@ export const dateTextColumn: StoryObj<TextColumnTableArgs> = { name: 'field-name', description: 'Set this attribute to identify which field in the data record should be displayed in each column. The field values must be of type `number` and represent the number of milliseconds since January 1, 1970 UTC. This is the representation used by the `Date` type.', - control: false + control: false, + table: { category: apiCategory.attributes }, }, placeholder: { description: - 'The placeholder text to display when the field value is `undefined` or `null` for a record.' + 'The placeholder text to display when the field value is `undefined` or `null` for a record.', + table: { category: apiCategory.attributes }, }, format: { description: formatDescription, options: Object.keys(DateTextFormat), - control: { type: 'radio' } + control: { type: 'radio' }, + table: { category: apiCategory.attributes }, }, customDateStyle: { name: 'custom-date-style', description: 'Refer to the option [documentation for the `Intl.DateTimeFormat()` constructor](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DateTimeFormat/DateTimeFormat).', options: [undefined, 'full', 'long', 'medium', 'short'], - control: { type: 'radio' } + control: { type: 'radio' }, + table: { category: apiCategory.attributes }, }, customTimeStyle: { name: 'custom-time-style', description: 'Refer to the option [documentation for the `Intl.DateTimeFormat()` constructor](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DateTimeFormat/DateTimeFormat).', options: [undefined, 'full', 'long', 'medium', 'short'], - control: { type: 'radio' } + control: { type: 'radio' }, + table: { category: apiCategory.attributes }, }, customWeekday: { name: 'custom-weekday', description: 'Refer to the option [documentation for the `Intl.DateTimeFormat()` constructor](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DateTimeFormat/DateTimeFormat).', options: [undefined, 'long', 'short', 'narrow'], - control: { type: 'radio' } + control: { type: 'radio' }, + table: { category: apiCategory.attributes }, }, customDay: { name: 'custom-day', description: 'Refer to the option [documentation for the `Intl.DateTimeFormat()` constructor](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DateTimeFormat/DateTimeFormat).', options: [undefined, 'numeric', '2-digit'], - control: { type: 'radio' } + control: { type: 'radio' }, + table: { category: apiCategory.attributes }, }, customMonth: { name: 'custom-month', @@ -214,56 +221,64 @@ export const dateTextColumn: StoryObj<TextColumnTableArgs> = { 'short', 'narrow' ], - control: { type: 'radio' } + control: { type: 'radio' }, + table: { category: apiCategory.attributes }, }, customYear: { name: 'custom-year', description: 'Refer to the option [documentation for the `Intl.DateTimeFormat()` constructor](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DateTimeFormat/DateTimeFormat).', options: [undefined, 'numeric', '2-digit'], - control: { type: 'radio' } + control: { type: 'radio' }, + table: { category: apiCategory.attributes }, }, customEra: { name: 'custom-era', description: 'Refer to the option [documentation for the `Intl.DateTimeFormat()` constructor](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DateTimeFormat/DateTimeFormat).', options: [undefined, 'long', 'short', 'narrow'], - control: { type: 'radio' } + control: { type: 'radio' }, + table: { category: apiCategory.attributes }, }, customHour: { name: 'custom-hour', description: 'Refer to the option [documentation for the `Intl.DateTimeFormat()` constructor](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DateTimeFormat/DateTimeFormat).', options: [undefined, 'numeric', '2-digit'], - control: { type: 'radio' } + control: { type: 'radio' }, + table: { category: apiCategory.attributes }, }, customMinute: { name: 'custom-minute', description: 'Refer to the option [documentation for the `Intl.DateTimeFormat()` constructor](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DateTimeFormat/DateTimeFormat).', options: [undefined, 'numeric', '2-digit'], - control: { type: 'radio' } + control: { type: 'radio' }, + table: { category: apiCategory.attributes }, }, customSecond: { name: 'custom-second', description: 'Refer to the option [documentation for the `Intl.DateTimeFormat()` constructor](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DateTimeFormat/DateTimeFormat).', options: [undefined, 'numeric', '2-digit'], - control: { type: 'radio' } + control: { type: 'radio' }, + table: { category: apiCategory.attributes }, }, customHour12: { name: 'custom-hour12', description: 'Refer to the option [documentation for the `Intl.DateTimeFormat()` constructor](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DateTimeFormat/DateTimeFormat).', options: [undefined, true, false], - control: { type: 'radio' } + control: { type: 'radio' }, + table: { category: apiCategory.attributes }, }, customHourCycle: { name: 'custom-hour-cycle', description: 'Refer to the option [documentation for the `Intl.DateTimeFormat()` constructor](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DateTimeFormat/DateTimeFormat).', options: [undefined, 'h11', 'h12', 'h23', 'h24'], - control: { type: 'radio' } + control: { type: 'radio' }, + table: { category: apiCategory.attributes }, }, customTimeZoneName: { name: 'custom-time-zone-name', @@ -278,7 +293,8 @@ export const dateTextColumn: StoryObj<TextColumnTableArgs> = { 'longGeneric', 'shortGeneric' ], - control: { type: 'radio' } + control: { type: 'radio' }, + table: { category: apiCategory.attributes }, }, customTimeZone: { name: 'custom-time-zone', @@ -291,14 +307,16 @@ export const dateTextColumn: StoryObj<TextColumnTableArgs> = { 'America/New York', 'Europe/Paris' ], - control: { type: 'radio' } + control: { type: 'radio' }, + table: { category: apiCategory.attributes }, }, customDayPeriod: { name: 'custom-day-period', description: 'Refer to the option [documentation for the `Intl.DateTimeFormat()` constructor](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DateTimeFormat/DateTimeFormat).', options: [undefined, 'narrow', 'short', 'long'], - control: { type: 'radio' } + control: { type: 'radio' }, + table: { category: apiCategory.attributes }, }, customCalendar: { name: 'custom-calendar', @@ -312,36 +330,43 @@ export const dateTextColumn: StoryObj<TextColumnTableArgs> = { 'hebrew', 'islamic-civil' ], - control: { type: 'radio' } + control: { type: 'radio' }, + table: { category: apiCategory.attributes }, }, customNumberingSystem: { name: 'custom-numbering-system', description: 'Refer to the option [documentation for the `Intl.DateTimeFormat()` constructor](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DateTimeFormat/DateTimeFormat). The values presented here are not a comprehensive list.', options: [undefined, 'arab', 'fullwide', 'latn', 'tamldec'], - control: { type: 'radio' } + control: { type: 'radio' }, + table: { category: apiCategory.attributes }, }, customFormatMatcher: { name: 'custom-format-matcher', description: 'Refer to the option [documentation for the `Intl.DateTimeFormat()` constructor](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DateTimeFormat/DateTimeFormat).', options: [undefined, 'basic', 'best-fit'], - control: { type: 'radio' } + control: { type: 'radio' }, + table: { category: apiCategory.attributes }, }, customLocaleMatcher: { name: 'custom-locale-matcher', description: 'Refer to the option [documentation for the `Intl.DateTimeFormat()` constructor](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DateTimeFormat/DateTimeFormat).', options: [undefined, 'lookup', 'best-fit'], - control: { type: 'radio' } + control: { type: 'radio' }, + table: { category: apiCategory.attributes }, }, checkValidity: { name: 'checkValidity()', - description: - 'Returns `true` if the column configuration is valid, otherwise `false`.' + description: checkValidityDescription({ componentName: 'date text column' }), + table: { category: apiCategory.methods }, + control: false, }, validity: { - description: validityDescription + description: validityDescription, + table: { category: apiCategory.nonAttributeProperties }, + control: false, } }, args: { diff --git a/packages/storybook/src/nimble/table-column/duration-text/table-column-duration-text.mdx b/packages/storybook/src/nimble/table-column/duration-text/table-column-duration-text.mdx index f99ccef9c3..a91da858f5 100644 --- a/packages/storybook/src/nimble/table-column/duration-text/table-column-duration-text.mdx +++ b/packages/storybook/src/nimble/table-column/duration-text/table-column-duration-text.mdx @@ -1,5 +1,6 @@ import { Controls, Canvas, Meta, Title } from '@storybook/blocks'; import * as tableColumnDurationTextStories from './table-column-duration-text.stories'; +import ComponentApisLink from '../../../docs/component-apis-link.mdx'; import { tableColumnDurationTextTag } from '../../../../../nimble-components/src/table-column/duration-text'; import { tableTag } from '../../../../../nimble-components/src/table'; import NoNullAndUndefinedBestPractice from '../../patterns/table-column/no-null-and-undefined-best-practice-docs.mdx'; @@ -13,7 +14,11 @@ The <Tag name={tableColumnDurationTextTag}/> column is used to display a period of={tableColumnDurationTextStories.durationTextColumn} expanded={false} /> + +## API + <Controls of={tableColumnDurationTextStories.durationTextColumn} /> +<ComponentApisLink /> ## Usage diff --git a/packages/storybook/src/nimble/table-column/duration-text/table-column-duration-text.stories.ts b/packages/storybook/src/nimble/table-column/duration-text/table-column-duration-text.stories.ts index 4216a4b252..ac018b23d3 100644 --- a/packages/storybook/src/nimble/table-column/duration-text/table-column-duration-text.stories.ts +++ b/packages/storybook/src/nimble/table-column/duration-text/table-column-duration-text.stories.ts @@ -10,7 +10,7 @@ import { sharedTableArgTypes, sharedTableArgs } from '../base/table-column-stories-utils'; -import { createUserSelectedThemeStory } from '../../../utilities/storybook'; +import { apiCategory, createUserSelectedThemeStory } from '../../../utilities/storybook'; const simpleData = [ { @@ -95,11 +95,13 @@ export const durationTextColumn: StoryObj<TextColumnTableArgs> = { name: 'field-name', description: 'Set this attribute to identify which field in the data record should be displayed in each column. The field values must be of type `number` and represent a total number of milliseconds.', - control: false + control: false, + table: { category: apiCategory.attributes }, }, placeholder: { description: - 'The placeholder text to display when the field value is `undefined` or `null` for a record.' + 'The placeholder text to display when the field value is `undefined` or `null` for a record.', + table: { category: apiCategory.attributes }, } }, args: { diff --git a/packages/storybook/src/nimble/table-column/mapping/table-column-mapping.mdx b/packages/storybook/src/nimble/table-column/mapping/table-column-mapping.mdx index 68434deb76..e94d0e63c0 100644 --- a/packages/storybook/src/nimble/table-column/mapping/table-column-mapping.mdx +++ b/packages/storybook/src/nimble/table-column/mapping/table-column-mapping.mdx @@ -5,6 +5,7 @@ import * as emptyMappingStories from '../../mapping/empty/mapping-empty.stories' import * as iconMappingStories from '../../mapping/icon/mapping-icon.stories'; import * as spinnerMappingStories from '../../mapping/spinner/mapping-spinner.stories'; import * as textMappingStories from '../../mapping/text/mapping-text.stories'; +import ComponentApisLink from '../../../docs/component-apis-link.mdx'; import { tableColumnMappingTag } from '../../../../../nimble-components/src/table-column/mapping'; import { mappingEmptyTag } from '../../../../../nimble-components/src/mapping/empty'; import { tableTag } from '../../../../../nimble-components/src/table'; @@ -18,37 +19,41 @@ The <Tag name={tableColumnMappingTag}/> renders specific number, boolean, or str <p>{columnOperationBehavior}</p> <Canvas of={tableColumnMappingStories.mappingColumn} /> -<Controls of={tableColumnMappingStories.mappingColumn} /> - -## Usage -### Best Practices +## API -- Provide a mapping for every expected record value. Because grouping is performed on the record value, non-mapped record values can result in multiple groups without group labels. - - To improve grouping behavior of a value that shouldn't be rendered in table cells, use a <Tag name={mappingEmptyTag}/> element to provide text for that value's group row. -- Avoid having multiple values that map to the same text because grouping and sorting is done on the record value rather than the mapped text. - -### Blazor Usage - -When setting a child mapping element's `Key` value to a string, you must wrap it in `@()` so that the compiler treats it as a string, e.g. -`<NimbleMappingIcon Key=@("foo") ...>` +<Controls of={tableColumnMappingStories.mappingColumn} /> +<ComponentApisLink /> -## Icon Mapping +### Icon Mapping <Description of={iconMappingStories} /> <Controls of={iconMappingStories.iconMapping} /> -## Spinner Mapping +### Spinner Mapping <Description of={spinnerMappingStories} /> <Controls of={spinnerMappingStories.spinnerMapping} /> -## Text Mapping +### Text Mapping <Description of={textMappingStories} /> <Controls of={textMappingStories.textMapping} /> -## Empty Mapping +### Empty Mapping <Description of={emptyMappingStories} /> <Controls of={emptyMappingStories.emptyMapping} /> + +## Usage + +### Best Practices + +- Provide a mapping for every expected record value. Because grouping is performed on the record value, non-mapped record values can result in multiple groups without group labels. + - To improve grouping behavior of a value that shouldn't be rendered in table cells, use a <Tag name={mappingEmptyTag}/> element to provide text for that value's group row. +- Avoid having multiple values that map to the same text because grouping and sorting is done on the record value rather than the mapped text. + +### Blazor Usage + +When setting a child mapping element's `Key` value to a string, you must wrap it in `@()` so that the compiler treats it as a string, e.g. +`<NimbleMappingIcon Key=@("foo") ...>` diff --git a/packages/storybook/src/nimble/table-column/mapping/table-column-mapping.stories.ts b/packages/storybook/src/nimble/table-column/mapping/table-column-mapping.stories.ts index 861c13fa45..ea3d3534b2 100644 --- a/packages/storybook/src/nimble/table-column/mapping/table-column-mapping.stories.ts +++ b/packages/storybook/src/nimble/table-column/mapping/table-column-mapping.stories.ts @@ -18,7 +18,7 @@ import { sharedTableArgs } from '../base/table-column-stories-utils'; import { isChromatic } from '../../../utilities/isChromatic'; -import { createUserSelectedThemeStory } from '../../../utilities/storybook'; +import { apiCategory, checkValidityDescription, createUserSelectedThemeStory } from '../../../utilities/storybook'; const simpleData = [ { @@ -71,6 +71,7 @@ interface MappingColumnTableArgs extends SharedTableArgs { widthMode: keyof typeof TableColumnMappingWidthMode; checkValidity: () => void; validity: () => void; + content: undefined; } const widthModeDescription = `When set to \`iconSize\`, the column will have a fixed width that makes the column the appropriate width to render only a single icon in the cell. @@ -124,6 +125,7 @@ export const mappingColumn: StoryObj<MappingColumnTableArgs> = { name: 'field-name', description: "Set this attribute to identify which field in the data record contains the value for each cell in the column. The field values' type must match the type specified by the `key-type` attribute.", + table: { category: apiCategory.attributes }, control: false }, keyType: { @@ -131,21 +133,32 @@ export const mappingColumn: StoryObj<MappingColumnTableArgs> = { control: false, defaultValue: { summary: '"string"' }, description: - 'The data type of the key values used for this column. Must be one of `"string"`, `"number"`, or `"boolean"`. Defaults to `"string"` if unspecified.' + 'The data type of the key values used for this column. Must be one of `"string"`, `"number"`, or `"boolean"`. Defaults to `"string"` if unspecified.', + table: { category: apiCategory.attributes }, }, widthMode: { name: 'width-mode', options: Object.keys(TableColumnMappingWidthMode), control: { type: 'radio' }, - description: widthModeDescription + description: widthModeDescription, + table: { category: apiCategory.attributes }, }, checkValidity: { name: 'checkValidity()', - description: - 'Returns `true` if the column configuration is valid, otherwise `false`.' + description: checkValidityDescription({ componentName: 'mapping column' }), + table: { category: apiCategory.methods }, + control: false }, validity: { - description: validityDescription + description: validityDescription, + table: { category: apiCategory.nonAttributeProperties }, + control: false + }, + content: { + name: 'default', + description: 'One or more mapping elements which specify how to render each possible data value.', + table: { category: apiCategory.slots }, + control: false } }, args: { diff --git a/packages/storybook/src/nimble/table-column/number-text/table-column-number-text.mdx b/packages/storybook/src/nimble/table-column/number-text/table-column-number-text.mdx index 8891609932..f33eddf679 100644 --- a/packages/storybook/src/nimble/table-column/number-text/table-column-number-text.mdx +++ b/packages/storybook/src/nimble/table-column/number-text/table-column-number-text.mdx @@ -5,6 +5,7 @@ import { noNullAndUndefinedBestPractice } from '../base/table-column-stories-utils'; import * as tableColumnNumberTextStories from './table-column-number-text.stories'; +import ComponentApisLink from '../../../docs/component-apis-link.mdx'; import { tableColumnNumberTextTag } from '../../../../../nimble-components/src/table-column/number-text'; import { tableTag } from '../../../../../nimble-components/src/table'; import NoNullAndUndefinedBestPractice from '../../patterns/table-column/no-null-and-undefined-best-practice-docs.mdx'; @@ -18,7 +19,11 @@ based on the value of the `lang` token, which can be set via the [nimble-theme-p <p>{columnOperationBehavior}</p> <Canvas of={tableColumnNumberTextStories.numberTextColumn} /> + +## API + <Controls of={tableColumnNumberTextStories.numberTextColumn} /> +<ComponentApisLink /> {/* ## Styling */} diff --git a/packages/storybook/src/nimble/table-column/number-text/table-column-number-text.stories.ts b/packages/storybook/src/nimble/table-column/number-text/table-column-number-text.stories.ts index f19898ff3e..1d49175f92 100644 --- a/packages/storybook/src/nimble/table-column/number-text/table-column-number-text.stories.ts +++ b/packages/storybook/src/nimble/table-column/number-text/table-column-number-text.stories.ts @@ -15,7 +15,7 @@ import { sharedTableArgTypes, sharedTableArgs } from '../base/table-column-stories-utils'; -import { createUserSelectedThemeStory } from '../../../utilities/storybook'; +import { apiCategory, checkValidityDescription, createUserSelectedThemeStory } from '../../../utilities/storybook'; const simpleData = [ { @@ -186,48 +186,58 @@ export const numberTextColumn: StoryObj<NumberTextColumnTableArgs> = { name: 'field-name', description: 'Set this attribute to identify which field in the data record should be displayed in each column. The field values must be of type `number`.', - control: false + control: false, + table: { category: apiCategory.attributes }, }, placeholder: { description: - 'The placeholder text to display when the field value is `undefined` or `null` for a record.' + 'The placeholder text to display when the field value is `undefined` or `null` for a record.', + table: { category: apiCategory.attributes }, }, format: { description: formatDescription, options: Object.keys(NumberTextFormat), - control: { type: 'radio' } + control: { type: 'radio' }, + table: { category: apiCategory.attributes }, }, alignment: { description: alignmentDescription, options: Object.keys(NumberTextAlignment), - control: { type: 'radio' } + control: { type: 'radio' }, + table: { category: apiCategory.attributes }, }, decimalDigits: { name: 'decimal-digits', description: "The number of decimal places to format values to when the column's `format` is configured to be `decimal`. If neither `decimal-digits` or `decimal-maximum-digits` are set, a default value of `2` is used. `decimal-digits` and `decimal-maximum-digits` cannot both be set at the same time. The value must be in the range 0 - 20 (inclusive).", options: [undefined, 0, 1, 2, 3], - control: { type: 'select' } + control: { type: 'select' }, + table: { category: apiCategory.attributes }, }, decimalMaximumDigits: { name: 'decimal-maximum-digits', description: "The maximum number of decimal places to format values to when the column's `format` is configured to be `decimal`. This differs from `decimal-digits` in that trailing zeros are omitted. `decimal-digits` and `decimal-maximum-digits` cannot both be set at the same time. The value must be in the range 0 - 20 (inclusive).", options: [undefined, 0, 1, 2, 3, 20], - control: { type: 'select' } + control: { type: 'select' }, + table: { category: apiCategory.attributes }, }, unit: { description: unitDescription, options: ['default', 'byte', 'byte (1024)', 'degrees Celsius', 'degrees Fahrenheit', 'volt'], - control: { type: 'radio' } + control: { type: 'radio' }, + table: { category: apiCategory.attributes }, }, checkValidity: { name: 'checkValidity()', - description: - 'Returns `true` if the column configuration is valid, otherwise `false`.' + description: checkValidityDescription({ componentName: 'number text column' }), + control: false, + table: { category: apiCategory.methods }, }, validity: { - description: validityDescription + description: validityDescription, + control: false, + table: { category: apiCategory.nonAttributeProperties }, } }, args: { diff --git a/packages/storybook/src/nimble/table-column/text/table-column-text.mdx b/packages/storybook/src/nimble/table-column/text/table-column-text.mdx index def6b24236..9b778f2c5a 100644 --- a/packages/storybook/src/nimble/table-column/text/table-column-text.mdx +++ b/packages/storybook/src/nimble/table-column/text/table-column-text.mdx @@ -1,6 +1,7 @@ import { Canvas, Meta, Controls, Title } from '@storybook/blocks'; import { NimbleTableColumnText } from './table-column-text.react'; import * as tableColumnTextStories from './table-column-text.stories'; +import ComponentApisLink from '../../../docs/component-apis-link.mdx'; import { tableColumnTextTag } from '../../../../../nimble-components/src/table-column/text'; import { tableTag } from '../../../../../nimble-components/src/table'; import NoNullAndUndefinedBestPractice from '../../patterns/table-column/no-null-and-undefined-best-practice-docs.mdx'; @@ -11,7 +12,11 @@ import NoNullAndUndefinedBestPractice from '../../patterns/table-column/no-null- The <Tag name={tableColumnTextTag}/> column is used to display string fields as text in the <Tag name={tableTag}/>. <Canvas of={tableColumnTextStories.textColumn} /> + +## API + <Controls of={tableColumnTextStories.textColumn} /> +<ComponentApisLink /> {/* ## Styling */} diff --git a/packages/storybook/src/nimble/table-column/text/table-column-text.stories.ts b/packages/storybook/src/nimble/table-column/text/table-column-text.stories.ts index 6af7db88cf..fee7759fe6 100644 --- a/packages/storybook/src/nimble/table-column/text/table-column-text.stories.ts +++ b/packages/storybook/src/nimble/table-column/text/table-column-text.stories.ts @@ -9,7 +9,7 @@ import { sharedTableArgTypes, sharedTableArgs } from '../base/table-column-stories-utils'; -import { createUserSelectedThemeStory } from '../../../utilities/storybook'; +import { apiCategory, createUserSelectedThemeStory } from '../../../utilities/storybook'; const simpleData = [ { @@ -95,11 +95,13 @@ export const textColumn: StoryObj<TextColumnTableArgs> = { description: 'Set this attribute to identify which field in the data record should be displayed in each column. The field values must be of type `string`.', options: ['firstName', 'lastName'], - control: { type: 'radio' } + control: { type: 'radio' }, + table: { category: apiCategory.attributes }, }, placeholder: { description: - 'The placeholder text to display when the field value is `undefined` or `null` for a record.' + 'The placeholder text to display when the field value is `undefined` or `null` for a record.', + table: { category: apiCategory.attributes }, } }, args: { diff --git a/packages/storybook/src/nimble/table/table.mdx b/packages/storybook/src/nimble/table/table.mdx index f2fe197fea..73aab1501a 100644 --- a/packages/storybook/src/nimble/table/table.mdx +++ b/packages/storybook/src/nimble/table/table.mdx @@ -1,17 +1,33 @@ import { Controls, Canvas, Meta, Title } from '@storybook/blocks'; import * as tableStories from './table.stories'; +import ComponentApisLink from '../../docs/component-apis-link.mdx'; import { tableTag } from '../../../../nimble-components/src/table'; <Meta of={tableStories} /> <Title of={tableStories} /> The <Tag name={tableTag}/> is a component that offers a way to render tabular data in a variety of ways in each column. -For information about configuring table columns, see **Table Column Configuration** and **Table Column Types**. +For information about configuring table columns, see [Table Column Configuration](?path=/docs/components-table-column-configuration--docs) +and the **Table Column** pages for individual table column types. <Canvas of={tableStories.table} /> + +## API + <Controls of={tableStories.table} /> +<ComponentApisLink /> + +## Styling + +### Sizing + +The <Tag name={tableTag}/> should be sized explicitly or sized to fill the space of a parent container. The <Tag name={tableTag}/> does not currently support being styled with `height: auto`. The ability to auto size the table is tracked with [issue 1624](https://github.com/ni/nimble/issues/1624). + +{/* ## Usage */} -## Delay-loaded Hierarchy +## Examples + +### Delay-loaded hierarchy In some cases, it may be known that a record has children, but the records for those children are not known. For performance reasons, it may be preferred to load the children on demand when a user expands the parent row. To accomplish this, use the `setRecordHierarchyOptions()` function on the table to set the hierarchy @@ -20,7 +36,7 @@ options associated with records in the data. <Canvas of={tableStories.delayedHierarchy} /> <Controls of={tableStories.delayedHierarchy} /> -### Delay-loaded Hierarchy Usage +#### Using delay-loaded hierarchy The expected usage of the dynamically loaded hierarchy is as follows: @@ -39,7 +55,7 @@ The expected usage of the dynamically loaded hierarchy is as follows: - If loading the data determines that the row doesn't actually have children: 1. Call `setRecordHierarchyOptions` to change the row state to `{ delayedHierarchyState: TableRecordDelayedHierarchyState.none }`. This call must include the current state of any records not in the default state. -### setRecordHierarchyOptions Behavior +#### Behavior of setRecordHierarchyOptions `setRecordHierarchyOptions()` has the following behavior: @@ -49,16 +65,6 @@ The expected usage of the dynamically loaded hierarchy is as follows: - the table will not render delayed hierarchy state (loading or expandable) if the table's `parentIdFieldName` is not configured; however, the options will remain cached within the table if the `parentIdFieldName` becomes `undefined`, and that cached configuration will render in the table if the table's `parentIdFieldName` is changed back to a non-`undefined` value - calling `setData` will clear options associated with IDs that are no longer present in the data -## Styling - -### Sizing - -The <Tag name={tableTag}/> should be sized explicitly or sized to fill the space of a parent container. The <Tag name={tableTag}/> does not currently support being styled with `height: auto`. The ability to auto size the table is tracked with [issue 1624](https://github.com/ni/nimble/issues/1624). - -{/* ## Usage */} - -{/* ## Examples */} - {/* ## Accessibility */} {/* ## Resources */} diff --git a/packages/storybook/src/nimble/table/table.stories.ts b/packages/storybook/src/nimble/table/table.stories.ts index 0bee5c0971..a663b57b92 100644 --- a/packages/storybook/src/nimble/table/table.stories.ts +++ b/packages/storybook/src/nimble/table/table.stories.ts @@ -14,7 +14,7 @@ import { addLabelUseMetadata, type LabelUserArgs } from '../label-provider/base/label-user-stories-utils'; -import { createUserSelectedThemeStory } from '../../utilities/storybook'; +import { apiCategory, checkValidityDescription, createUserSelectedThemeStory } from '../../utilities/storybook'; import { isChromatic } from '../../utilities/isChromatic'; interface BaseTableArgs extends LabelUserArgs { @@ -62,6 +62,14 @@ interface TableArgs extends BaseTableArgs { setSelectedRecordIds: undefined; getSelectedRecordIds: undefined; data: ExampleDataType; + setRecordHierarchyOptions: undefined; + defaultSlot: undefined; + actionMenuSlot: undefined; + actionMenuBeforetoggle: undefined; + actionMenuToggle: undefined; + selectionChange: undefined; + columnConfigurationChange: undefined; + rowExpandToggle: undefined; } const simpleData = [ @@ -205,7 +213,7 @@ const dataSets = { [ExampleDataType.hierarchicalDataSet]: hierarchicalData } as const; -const dataDescription = `To set the data on the table, call \`setData()\` with an array data records. Each record is made up of fields, +const dataDescription = `To set the data on the table, call \`setData()\` with an array of data records. Each record is made up of fields, which are key/value pairs. The key in each pair must be of type \`string\`, which is defined by the type \`TableFieldName\`. The value in each pair must be of type \`string\`, \`number\`, \`boolean\`, \`null\`, or \`undefined\`, which is defined by the type \`TableFieldValue\`. @@ -236,7 +244,7 @@ The attribute is invalid in the following conditions: const parentIdFieldNameDescription = `An optional string attribute that specifies the field name within a row's record to use as a row's parent ID, which, when used in combination with the \`id-field-name\` attribute, will display the table data in a hierarchical fashion. If the attribute is not specified, the -data in the table will always be presented without hierarchy. +data in the table will be presented without hierarchy. To configure hierarchy dynamically instead, see \`setRecordHierarchyOptions()\`. The attribute is invalid in the following conditions: - When this attribute is set, but \`id-field-name\` is unset. This will cause \`validity.idFieldNameNotConfigured\` to be \`true\`. @@ -326,54 +334,101 @@ export const table: StoryObj<TableArgs> = { [ExampleDataType.largeDataSet]: 'Large data set (10k rows)', [ExampleDataType.hierarchicalDataSet]: 'Hierarchical data' } - } + }, + table: { category: apiCategory.methods }, }, selectionMode: { - table: { - defaultValue: { summary: 'none' } - }, + name: 'selection-mode', options: Object.keys(TableRowSelectionMode), description: 'Controls whether the table supports selecting a single row at a time, multiple rows at a time, or no rows. When selection is enabled, `id-field-name` must be specified.', - control: { type: 'radio' } + control: { type: 'radio' }, + table: { category: apiCategory.attributes }, }, getSelectedRecordIds: { name: 'getSelectedRecordIds()', description: 'A function that returns an array of record IDs that represent the selected row(s) in the table.', - control: false + control: false, + table: { category: apiCategory.methods }, }, setSelectedRecordIds: { name: 'setSelectedRecordIds()', description: setSelectedRecordIdsDescription, - control: false + control: false, + table: { category: apiCategory.methods }, }, idFieldName: { name: 'id-field-name', - table: { - defaultValue: { summary: 'undefined' } - }, description: idFieldNameDescription, - control: false + control: false, + table: { category: apiCategory.attributes }, }, parentIdFieldName: { name: 'parent-id-field-name', - table: { - defaultValue: { summary: 'undefined' } - }, description: parentIdFieldNameDescription, - control: false + control: false, + table: { category: apiCategory.attributes }, }, validity: { description: validityDescription, - control: false + control: false, + table: { category: apiCategory.nonAttributeProperties }, }, checkValidity: { name: 'checkValidity()', - description: - 'A function that returns `true` if the configuration of the table is valid and `false` if the configuration of the table is not valid.', - control: false - } + description: checkValidityDescription({ componentName: 'table' }), + control: false, + table: { category: apiCategory.methods }, + }, + setRecordHierarchyOptions: { + name: 'setRecordHierarchyOptions()', + description: 'Used to configure the hierarchy state of rows dynamically. To set static hierarchy, use `parent-id-field-name` instead. See the **Delay-loaded Hierarchy** section for more information.', + control: false, + table: { category: apiCategory.methods }, + }, + defaultSlot: { + name: 'default', + description: 'Configure table columns by adding them as child elements in the default slot. See **Table Column Configuration** for more information.', + control: false, + table: { category: apiCategory.slots }, + }, + actionMenuSlot: { + name: 'Action menus', + description: `To add an action menu to a column, add a \`${menuTag}\` element as a child of the table and set its slot attribute to a custom value. Then configure the column's \`action-menu-slot\` attribute to the same value. You can configure different action menus for multiple columns by giving them unique slot names.`, + control: false, + table: { category: apiCategory.slots }, + }, + actionMenuBeforetoggle: { + name: 'action-menu-beforetoggle', + description: 'Event emitted before an action menu opens or closes. This can be used to populate the menu before it is visible.', + control: false, + table: { category: apiCategory.events }, + }, + actionMenuToggle: { + name: 'action-menu-toggle', + description: 'Event emitted after an action menu opens or closes.', + control: false, + table: { category: apiCategory.events }, + }, + selectionChange: { + name: 'selection-change', + description: 'Event emitted when the user changes which rows are selected.', + control: false, + table: { category: apiCategory.events }, + }, + columnConfigurationChange: { + name: 'column-configuration-change', + description: 'Event emitted when the user changes a column\'s width or sort order.', + control: false, + table: { category: apiCategory.events }, + }, + rowExpandToggle: { + name: 'row-expand-toggle', + description: 'Event emitted when the user expands or collapses a row in a table with hierarchy. This does not emit when group rows are expanded or collapsed.', + control: false, + table: { category: apiCategory.events }, + }, }, args: { data: ExampleDataType.simpleData, diff --git a/packages/storybook/src/utilities/storybook.ts b/packages/storybook/src/utilities/storybook.ts index 733b14a251..84cbc80a15 100644 --- a/packages/storybook/src/utilities/storybook.ts +++ b/packages/storybook/src/utilities/storybook.ts @@ -187,3 +187,5 @@ export const dropdownPositionDescription = (options: { componentName: string }): export const optionsDescription = `The \`${listOptionTag}\` items for the user to select from.`; export const preventDismissDescription = (options: { componentName: string }): string => `Prevents the \`Esc\` key from closing the ${options.componentName}.`; + +export const checkValidityDescription = (options: { componentName: string }): string => `Returns \`true\` if the configuration of the ${options.componentName} is valid, otherwise \`false\`.`;