Skip to content
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

feat(select): Hugely simplify HTML select definitions #225

Open
wants to merge 5 commits into
base: v0.10.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const exampleTemplate = `
#lang>

<sui-select-option *ngFor="let l of lang.availableOptions"
[value]="l"></sui-select-option>
[option]="l"></sui-select-option>
</sui-select>
</div>
<div class="ui segment">
Expand All @@ -26,9 +26,9 @@ const exampleTemplate = `
</div>
<div class="ui segment">
<sui-select class="fluid selection">
<sui-select-option value="Option 1"></sui-select-option>
<sui-select-option value="Option 2"></sui-select-option>
<sui-select-option value="Option 3"></sui-select-option>
<sui-select-option option="Option 1"></sui-select-option>
<sui-select-option option="Option 2"></sui-select-option>
<sui-select-option option="Option 3"></sui-select-option>
</sui-select>
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion demo/src/app/pages/development/test/test.page.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@
<demo-page-content>
<h2 class="ui dividing header">Examples</h2>
<div class="ui segment">

<sui-select [options]="[1,2,3]"></sui-select>
</div>
</demo-page-content>
2 changes: 1 addition & 1 deletion demo/src/app/pages/modules/datepicker/datepicker.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const exampleStandardTemplate = `
<div class="field">
<label>Datepicker Mode</label>
<sui-select class="selection" [(ngModel)]="mode" [options]="datepickerModes" #modes>
<sui-select-option *ngFor="let m of modes.availableOptions" [value]="m"></sui-select-option>
<sui-select-option *ngFor="let m of modes.filteredOptions" [option]="m"></sui-select-option>
</sui-select>
</div>
<div class="field">
Expand Down
2 changes: 1 addition & 1 deletion demo/src/app/pages/modules/modal/modal.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ const exampleComponentTemplate = `
<div class="field">
<label>Modal Size:</label>
<sui-select class="selection" [(ngModel)]="size" [options]="availableSizes" #sizes>
<sui-select-option *ngFor="let s of sizes.availableOptions" [value]="s"></sui-select-option>
<sui-select-option *ngFor="let s of sizes.filteredOptions" [option]="s"></sui-select-option>
</sui-select>
</div>
<button class="ui primary button" (click)="open()">Confirm?</button>
Expand Down
2 changes: 1 addition & 1 deletion demo/src/app/pages/modules/popup/popup.page.html
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ <h4 class="ui header">Placement</h4>
<example-popup-placement class="ui cards" [position]="position"></example-popup-placement>
<br>
<sui-select class="selection" [(ngModel)]="position" [options]="placements" [isSearchable]="true" #placementSelect>
<sui-select-option *ngFor="let p of placementSelect.availableOptions" [value]="p"></sui-select-option>
<sui-select-option *ngFor="let p of placementSelect.filteredOptions" [option]="p"></sui-select-option>
</sui-select>
</div>
</demo-example>
Expand Down
36 changes: 13 additions & 23 deletions demo/src/app/pages/modules/select/select.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@ const exampleStandardTemplate = `
[isSearchable]="searchable"
[isDisabled]="disabled"
#select>
<sui-select-option *ngFor="let option of select.filteredOptions"
[value]="option">
</sui-select-option>
</sui-select>
</div>
<div class="ui segment">
Expand All @@ -27,9 +24,6 @@ const exampleStandardTemplate = `
[isDisabled]="disabled"
[hasLabels]="!hideLabels"
#multiSelect>
<sui-select-option *ngFor="let option of multiSelect.filteredOptions"
[value]="option">
</sui-select-option>
</sui-multi-select>
<br><br>
<sui-checkbox [(ngModel)]="hideLabels">Hide labels?</sui-checkbox>
Expand All @@ -52,10 +46,10 @@ const exampleVariationsTemplate = `
<div class="ui segment">
<p><strong>Basic</strong></p>
<sui-select placeholder="Choose">
<sui-select-option value="Option 1"></sui-select-option>
<sui-select-option value="Option 2"></sui-select-option>
<sui-select-option value="Option 3"></sui-select-option>
<sui-select-option value="Option 4"></sui-select-option>
<sui-select-option option="Option 1"></sui-select-option>
<sui-select-option option="Option 2"></sui-select-option>
<sui-select-option option="Option 3"></sui-select-option>
<sui-select-option option="Option 4"></sui-select-option>
</sui-select>
</div>
<div class="ui segment">
Expand All @@ -66,9 +60,9 @@ const exampleVariationsTemplate = `
Trending repos
<sui-select class="inline" [(ngModel)]="selectedRange">
<div class="header">Adjust time span</div>
<sui-select-option value="today"></sui-select-option>
<sui-select-option value="this week"></sui-select-option>
<sui-select-option value="this month"></sui-select-option>
<sui-select-option option="today"></sui-select-option>
<sui-select-option option="this week"></sui-select-option>
<sui-select-option option="this month"></sui-select-option>
</sui-select>
</div>
</h4>
Expand All @@ -85,7 +79,6 @@ const exampleVariationsTemplate = `
<i class="tags icon"></i>
Filter by tag
</div>
<sui-select-option *ngFor="let o of filterSelect.filteredOptions" [value]="o"></sui-select-option>
</sui-select>
</div>
</div>
Expand All @@ -108,7 +101,7 @@ const exampleInMenuSearchTemplate = `
Options
</div>
<div class="scrolling menu">
<sui-select-option *ngFor="let o of select.filteredOptions" [value]="o"></sui-select-option>
<sui-select-options></sui-select-options>
</div>
</sui-multi-select>
`;
Expand All @@ -128,7 +121,6 @@ const exampleTemplateTemplate = `
[optionTemplate]="optionTemplate"
[isSearchable]="true"
#templated>
<sui-select-option *ngFor="let o of templated.filteredOptions" [value]="o"></sui-select-option>
</sui-select>
</div>
<div class="ui segment">
Expand All @@ -138,7 +130,6 @@ const exampleTemplateTemplate = `
[options]="options"
[optionFormatter]="formatter"
#formatted>
<sui-select-option *ngFor="let o of formatted.filteredOptions" [value]="o"></sui-select-option>
</sui-select>
</div>
<div class="ui segment">
Expand All @@ -152,10 +143,9 @@ const exampleSearchLookupTemplate = `
[(ngModel)]="selectedOption"
[optionsLookup]="optionsLookup"
labelField="name"
valueField="id"
optionField="id"
[isSearchable]="true"
#searchSelect>
<sui-select-option *ngFor="let o of searchSelect.filteredOptions" [value]="o"></sui-select-option>
</sui-select>
<div class="ui segment">
<p>Currently selected: {{ selectedOption | json }}</p>
Expand Down Expand Up @@ -257,7 +247,7 @@ export class SelectPage {
},
{
name: "localeOverrides",
type: "RecursivePartial<ISearchLocaleValues>",
type: "RecursivePartial<ISelectLocaleValues>",
description: "Overrides the values from the localization service."
}
],
Expand Down Expand Up @@ -374,7 +364,7 @@ export class SelectPage {
},
{
name: "localeOverrides",
type: "Partial<ISearchLocaleValues>",
type: "Partial<ISelectLocaleValues>",
description: "Overrides the values from the localization service."
}
],
Expand All @@ -395,9 +385,9 @@ export class SelectPage {
selector: "<sui-select-option>",
properties: [
{
name: "value",
name: "option",
type: "T",
description: "Sets the value of the option.",
description: "Sets the option the component represents.",
required: true
}
]
Expand Down
2 changes: 1 addition & 1 deletion demo/src/app/pages/modules/transition/transition.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const exampleStandardTemplate = `
<img src="https://goo.gl/VUcnwx" class="ui image" [suiTransition]="transitionController">
</div>
<sui-select class="selection" [(ngModel)]="transitionName" [options]="transitions" [isSearchable]="true" #animSelect>
<sui-select-option *ngFor="let a of animSelect.availableOptions" [value]="a"></sui-select-option>
<sui-select-option *ngFor="let a of animSelect.filteredOptions" [option]="a"></sui-select-option>
</sui-select>
<button class="ui button" (click)="animate(transitionName)">Animate</button>
`;
Expand Down
36 changes: 18 additions & 18 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
"element-closest": "^2.0.2",
"extend": "^3.0.1",
"popper.js": "~1.10.6",
"rxjs": "^5.0.1"
"rxjs": "^5.4.2"
},
"devDependencies": {
"@angular/common": "^4.3.1",
Expand Down
4 changes: 2 additions & 2 deletions src/misc/util/services/component-factory.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ export class SuiComponentFactory {
}

// Inserts the component into the specified view container.
public attachToView<T>(componentRef:ComponentRef<T>, viewContainer:ViewContainerRef):void {
viewContainer.insert(componentRef.hostView, 0);
public attachToView<T>(componentRef:ComponentRef<T>, viewContainer:ViewContainerRef, index:number = 0):void {
viewContainer.insert(componentRef.hostView, index);
}

// Inserts the component in the root application node.
Expand Down
Loading