-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create nimble-mapping-empty component (#2077)
# Pull Request ## 🤨 Rationale As part of #1992, we decided to create a `nimble-mapping-empty` component that would allow a cell to render as blank for a given mapping while still having text provided for use in group rows. This PR creates that component within `nimble-components`. Support for Blazor and Angular will be added in a subsequent PR. ## 👩💻 Implementation - Create `nimble-mapping-empty` component - Add support for the component in the mapping column - Update tests ## 🧪 Testing - Extended the unit tests for the mapping column to include tests for empty mappings - Add empty mapping to the matrix test for the mapping column ## ✅ Checklist <!--- Review the list and put an x in the boxes that apply or ~~strike through~~ around items that don't (along with an explanation). --> - [ ] I have updated the project documentation to reflect my changes or determined no changes are needed.
- Loading branch information
1 parent
8234266
commit 090b724
Showing
15 changed files
with
298 additions
and
45 deletions.
There are no files selected for viewing
7 changes: 7 additions & 0 deletions
7
change/@ni-nimble-components-cde0ca9f-1259-4049-ae46-ead5829d5151.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"type": "minor", | ||
"comment": "Create empty mapping element and support it in the icon column", | ||
"packageName": "@ni/nimble-components", | ||
"email": "20542556+mollykreis@users.noreply.github.com", | ||
"dependentChangeType": "patch" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import { DesignSystem } from '@microsoft/fast-foundation'; | ||
import { attr } from '@microsoft/fast-element'; | ||
import { Mapping } from '../base'; | ||
import { template } from '../base/template'; | ||
import type { MappingKey } from '../base/types'; | ||
|
||
declare global { | ||
interface HTMLElementTagNameMap { | ||
'nimble-mapping-empty': MappingEmpty; | ||
} | ||
} | ||
|
||
/** | ||
* Maps data values to text. | ||
* One or more may be added as children of a nimble-table-column-mapping element. The | ||
* mapping displays an empty cell and text-only group rows. | ||
*/ | ||
export class MappingEmpty extends Mapping<MappingKey> { | ||
@attr() | ||
public text?: string; | ||
} | ||
|
||
const emptyMapping = MappingEmpty.compose({ | ||
baseName: 'mapping-empty', | ||
template | ||
}); | ||
DesignSystem.getOrCreate().withPrefix('nimble').register(emptyMapping()); | ||
export const mappingEmptyTag = 'nimble-mapping-empty'; |
13 changes: 13 additions & 0 deletions
13
packages/nimble-components/src/mapping/empty/tests/mapping-empty.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { MappingEmpty, mappingEmptyTag } from '..'; | ||
|
||
describe('Empty Mapping', () => { | ||
it('should export its tag', () => { | ||
expect(mappingEmptyTag).toBe('nimble-mapping-empty'); | ||
}); | ||
|
||
it('can construct an element instance', () => { | ||
expect(document.createElement('nimble-mapping-empty')).toBeInstanceOf( | ||
MappingEmpty | ||
); | ||
}); | ||
}); |
6 changes: 6 additions & 0 deletions
6
packages/nimble-components/src/table-column/enum-base/models/mapping-empty-config.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import { MappingConfig } from './mapping-config'; | ||
|
||
/** | ||
* Mapping configuration corresponding to an empty mapping | ||
*/ | ||
export class MappingEmptyConfig extends MappingConfig {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.