-
Notifications
You must be signed in to change notification settings - Fork 159
feat(input-group): change default type from 'line' to 'box' #17340
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
3d45414
Initial plan
Copilot a0aeffe
feat(input-group): change default type from 'line' to 'box'
Copilot cf7cbad
chore(*): restore package-lock.json to original state
Copilot 42d2801
fix(*): update migration version from 21.2.3 to 22.0.0
Copilot 07c38cf
docs(select): update JSDoc for type input to reflect box default
Copilot ba38259
Update projects/igniteui-angular/select/src/select/select.component.ts
kdinev File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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
117 changes: 117 additions & 0 deletions
117
projects/igniteui-angular/migrations/update-22_0_0/index.spec.ts
This file contains hidden or 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,117 @@ | ||
| import * as path from 'path'; | ||
|
|
||
| import { SchematicTestRunner, UnitTestTree } from '@angular-devkit/schematics/testing/index.js'; | ||
| import { setupTestTree } from '../common/setup.spec'; | ||
|
|
||
| const version = '22.0.0'; | ||
|
|
||
| describe(`Update to ${version}`, () => { | ||
| let appTree: UnitTestTree; | ||
| const schematicRunner = new SchematicTestRunner('ig-migrate', path.join(__dirname, '../migration-collection.json')); | ||
|
|
||
| beforeEach(() => { | ||
| appTree = setupTestTree(); | ||
| }); | ||
|
|
||
| const migrationName = 'migration-57'; | ||
|
|
||
| it('should add type="line" to igx-input-group without explicit type', async () => { | ||
| appTree.create( | ||
| `/testSrc/appPrefix/component/test.component.html`, | ||
| `<igx-input-group><input igxInput></igx-input-group>` | ||
| ); | ||
|
|
||
| const tree = await schematicRunner.runSchematic(migrationName, {}, appTree); | ||
|
|
||
| expect(tree.readContent('/testSrc/appPrefix/component/test.component.html')) | ||
| .toEqual(`<igx-input-group type="line"><input igxInput></igx-input-group>`); | ||
| }); | ||
|
|
||
| it('should add type="line" to igx-select without explicit type', async () => { | ||
| appTree.create( | ||
| `/testSrc/appPrefix/component/test.component.html`, | ||
| `<igx-select><igx-select-item>Option</igx-select-item></igx-select>` | ||
| ); | ||
|
|
||
| const tree = await schematicRunner.runSchematic(migrationName, {}, appTree); | ||
|
|
||
| expect(tree.readContent('/testSrc/appPrefix/component/test.component.html')) | ||
| .toEqual(`<igx-select type="line"><igx-select-item>Option</igx-select-item></igx-select>`); | ||
| }); | ||
|
|
||
| it('should add type="line" to igx-date-picker without explicit type', async () => { | ||
| appTree.create( | ||
| `/testSrc/appPrefix/component/test.component.html`, | ||
| `<igx-date-picker></igx-date-picker>` | ||
| ); | ||
|
|
||
| const tree = await schematicRunner.runSchematic(migrationName, {}, appTree); | ||
|
|
||
| expect(tree.readContent('/testSrc/appPrefix/component/test.component.html')) | ||
| .toEqual(`<igx-date-picker type="line"></igx-date-picker>`); | ||
| }); | ||
|
|
||
| it('should add type="line" to igx-date-range-picker without explicit type', async () => { | ||
| appTree.create( | ||
| `/testSrc/appPrefix/component/test.component.html`, | ||
| `<igx-date-range-picker></igx-date-range-picker>` | ||
| ); | ||
|
|
||
| const tree = await schematicRunner.runSchematic(migrationName, {}, appTree); | ||
|
|
||
| expect(tree.readContent('/testSrc/appPrefix/component/test.component.html')) | ||
| .toEqual(`<igx-date-range-picker type="line"></igx-date-range-picker>`); | ||
| }); | ||
|
|
||
| it('should add type="line" to igx-time-picker without explicit type', async () => { | ||
| appTree.create( | ||
| `/testSrc/appPrefix/component/test.component.html`, | ||
| `<igx-time-picker></igx-time-picker>` | ||
| ); | ||
|
|
||
| const tree = await schematicRunner.runSchematic(migrationName, {}, appTree); | ||
|
|
||
| expect(tree.readContent('/testSrc/appPrefix/component/test.component.html')) | ||
| .toEqual(`<igx-time-picker type="line"></igx-time-picker>`); | ||
| }); | ||
|
|
||
| it('should NOT modify igx-input-group that already has type attribute', async () => { | ||
| appTree.create( | ||
| `/testSrc/appPrefix/component/test.component.html`, | ||
| `<igx-input-group type="box"><input igxInput></igx-input-group>` | ||
| ); | ||
|
|
||
| const tree = await schematicRunner.runSchematic(migrationName, {}, appTree); | ||
|
|
||
| expect(tree.readContent('/testSrc/appPrefix/component/test.component.html')) | ||
| .toEqual(`<igx-input-group type="box"><input igxInput></igx-input-group>`); | ||
| }); | ||
|
|
||
| it('should NOT modify igx-input-group that already has [type] binding', async () => { | ||
| appTree.create( | ||
| `/testSrc/appPrefix/component/test.component.html`, | ||
| `<igx-input-group [type]="myType"><input igxInput></igx-input-group>` | ||
| ); | ||
|
|
||
| const tree = await schematicRunner.runSchematic(migrationName, {}, appTree); | ||
|
|
||
| expect(tree.readContent('/testSrc/appPrefix/component/test.component.html')) | ||
| .toEqual(`<igx-input-group [type]="myType"><input igxInput></igx-input-group>`); | ||
| }); | ||
|
|
||
| it('should handle multiple components in the same template', async () => { | ||
| appTree.create( | ||
| `/testSrc/appPrefix/component/test.component.html`, | ||
| `<igx-input-group><input igxInput></igx-input-group> | ||
| <igx-select></igx-select> | ||
| <igx-input-group type="border"><input igxInput></igx-input-group>` | ||
| ); | ||
|
|
||
| const tree = await schematicRunner.runSchematic(migrationName, {}, appTree); | ||
|
|
||
| expect(tree.readContent('/testSrc/appPrefix/component/test.component.html')) | ||
| .toEqual(`<igx-input-group type="line"><input igxInput></igx-input-group> | ||
| <igx-select type="line"></igx-select> | ||
| <igx-input-group type="border"><input igxInput></igx-input-group>`); | ||
| }); | ||
| }); |
76 changes: 76 additions & 0 deletions
76
projects/igniteui-angular/migrations/update-22_0_0/index.ts
This file contains hidden or 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,76 @@ | ||
| import type { Rule, SchematicContext, Tree } from '@angular-devkit/schematics'; | ||
| import { UpdateChanges } from '../common/UpdateChanges'; | ||
| import { | ||
| FileChange, | ||
| findElementNodes, | ||
| getSourceOffset, | ||
| hasAttribute, | ||
| parseFile | ||
| } from '../common/util'; | ||
|
|
||
| const version = '22.0.0'; | ||
|
|
||
| export default (): Rule => async (host: Tree, context: SchematicContext) => { | ||
| context.logger.info( | ||
| `Applying migration for Ignite UI for Angular to version ${version}` | ||
| ); | ||
|
|
||
| const { HtmlParser, Element } = await import('@angular/compiler'); | ||
|
|
||
| const update = new UpdateChanges(__dirname, host, context); | ||
| const changes = new Map<string, FileChange[]>(); | ||
| const parser = new HtmlParser(); | ||
|
|
||
| const applyChanges = () => { | ||
| for (const [path, fileChanges] of changes.entries()) { | ||
| let content = host.read(path)!.toString(); | ||
| fileChanges | ||
| .sort((a, b) => b.position - a.position) | ||
| .forEach((c) => { | ||
| content = c.apply(content); | ||
| }); | ||
| host.overwrite(path, content); | ||
| } | ||
| }; | ||
|
|
||
| const addChange = (path: string, change: FileChange) => { | ||
| if (!changes.has(path)) { | ||
| changes.set(path, []); | ||
| } | ||
| changes.get(path)!.push(change); | ||
| }; | ||
|
|
||
| // All form components that default to 'line' prior to this version | ||
| const TAGS = [ | ||
| 'igx-input-group', | ||
| 'igx-select', | ||
| 'igx-date-picker', | ||
| 'igx-date-range-picker', | ||
| 'igx-time-picker' | ||
| ]; | ||
|
|
||
| const TYPE_ATTRS = ['type', '[type]']; | ||
|
|
||
| for (const path of update.templateFiles) { | ||
| const root = parseFile(parser, host, path); | ||
| const nodes = findElementNodes(root, TAGS); | ||
|
|
||
| for (const node of nodes) { | ||
| if (!(node instanceof Element)) continue; | ||
|
|
||
| // Skip if the element already has an explicit type binding | ||
| if (hasAttribute(node, TYPE_ATTRS)) continue; | ||
|
|
||
| const offset = getSourceOffset(node); | ||
| const file = offset.file; | ||
|
|
||
| // Insert type="line" right after the tag name in the start tag | ||
| // e.g., <igx-input-group → <igx-input-group type="line" | ||
| const tagNameEnd = offset.startTag.start + 1 + node.name.length; | ||
| addChange(file.url, new FileChange(tagNameEnd, ' type="line"')); | ||
| } | ||
| } | ||
|
|
||
| applyChanges(); | ||
| update.applyChanges(); | ||
| }; |
This file contains hidden or 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 hidden or 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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in 80e41ca — updated the JSDoc to state "Defaults to
boxif no input-group type is set" instead of referencing the oldlinedefault.