ionic2-city-picker
Advanced tools
Comparing version 0.0.3 to 0.0.4
@@ -21,8 +21,29 @@ import { AfterContentInit, EventEmitter, OnDestroy } from '@angular/core'; | ||
_regionCol: number; | ||
/** | ||
* @private | ||
*/ | ||
id: string; | ||
/** | ||
* @input {string} The text to display on the picker's cancel button. Default: `Cancel`. | ||
*/ | ||
cancelText: string; | ||
/** | ||
* @input {string} The text to display on the picker's "Done" button. Default: `Done`. | ||
*/ | ||
doneText: string; | ||
/** | ||
* @input {CityPickerColumn} city data | ||
*/ | ||
citiesData: CityPickerColumn[]; | ||
/** | ||
* @input {string} separate | ||
*/ | ||
separator: string; | ||
/** | ||
* @output {any} Emitted when the city selection has changed. | ||
*/ | ||
ionChange: EventEmitter<any>; | ||
/** | ||
* @output {any} Emitted when the city selection was cancelled. | ||
*/ | ||
ionCancel: EventEmitter<any>; | ||
@@ -32,19 +53,70 @@ constructor(_form: Form, _item: Item, _pickerCtrl: PickerController); | ||
_keyup(): void; | ||
/** | ||
* @private | ||
*/ | ||
open(): void; | ||
/** | ||
* @private | ||
*/ | ||
generate(picker: any): void; | ||
/** | ||
* @private | ||
*/ | ||
validate(picker: any): void; | ||
/** | ||
* @private | ||
*/ | ||
divyColumns(picker: any): void; | ||
/** | ||
* @private | ||
*/ | ||
setValue(newData: any): void; | ||
/** | ||
* @private | ||
*/ | ||
getValue(): string; | ||
/** | ||
* @private | ||
*/ | ||
checkHasValue(inputValue: any): void; | ||
/** | ||
* @private | ||
*/ | ||
updateText(): void; | ||
/** | ||
* @input {boolean} Whether or not the multi picker component is disabled. Default `false`. | ||
*/ | ||
disabled: boolean; | ||
/** | ||
* @private | ||
*/ | ||
writeValue(val: any): void; | ||
/** | ||
* @private | ||
*/ | ||
ngAfterContentInit(): void; | ||
/** | ||
* @private | ||
*/ | ||
registerOnChange(fn: Function): void; | ||
/** | ||
* @private | ||
*/ | ||
registerOnTouched(fn: any): void; | ||
/** | ||
* @private | ||
*/ | ||
onChange(val: any): void; | ||
/** | ||
* @private | ||
*/ | ||
onTouched(): void; | ||
/** | ||
* @private | ||
*/ | ||
ngOnDestroy(): void; | ||
/** | ||
* @private | ||
*/ | ||
getString(newData: any): string; | ||
} |
@@ -1,23 +0,10 @@ | ||
"use strict"; | ||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { | ||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; | ||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); | ||
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; | ||
return c > 3 && r && Object.defineProperty(target, key, r), r; | ||
}; | ||
var __metadata = (this && this.__metadata) || function (k, v) { | ||
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); | ||
}; | ||
var __param = (this && this.__param) || function (paramIndex, decorator) { | ||
return function (target, key) { decorator(target, key, paramIndex); } | ||
}; | ||
var core_1 = require("@angular/core"); | ||
var forms_1 = require("@angular/forms"); | ||
var ionic_angular_1 = require("ionic-angular"); | ||
exports.CITY_PICKER_VALUE_ACCESSOR = { | ||
provide: forms_1.NG_VALUE_ACCESSOR, | ||
useExisting: core_1.forwardRef(function () { return CityPicker; }), | ||
import { Component, EventEmitter, forwardRef, HostListener, Input, Optional, Output, ViewEncapsulation } from '@angular/core'; | ||
import { NG_VALUE_ACCESSOR } from '@angular/forms'; | ||
import { PickerController, Form, Item } from 'ionic-angular'; | ||
export var CITY_PICKER_VALUE_ACCESSOR = { | ||
provide: NG_VALUE_ACCESSOR, | ||
useExisting: forwardRef(function () { return CityPicker; }), | ||
multi: true | ||
}; | ||
var CityPicker = (function () { | ||
export var CityPicker = (function () { | ||
function CityPicker(_form, _item, _pickerCtrl) { | ||
@@ -34,8 +21,26 @@ this._form = _form; | ||
this._regionCol = 0; | ||
/** | ||
* @input {string} The text to display on the picker's cancel button. Default: `Cancel`. | ||
*/ | ||
this.cancelText = 'Cancel'; | ||
/** | ||
* @input {string} The text to display on the picker's "Done" button. Default: `Done`. | ||
*/ | ||
this.doneText = 'Done'; | ||
/** | ||
* @input {CityPickerColumn} city data | ||
*/ | ||
this.citiesData = []; | ||
/** | ||
* @input {string} separate | ||
*/ | ||
this.separator = ' '; | ||
this.ionChange = new core_1.EventEmitter(); | ||
this.ionCancel = new core_1.EventEmitter(); | ||
/** | ||
* @output {any} Emitted when the city selection has changed. | ||
*/ | ||
this.ionChange = new EventEmitter(); | ||
/** | ||
* @output {any} Emitted when the city selection was cancelled. | ||
*/ | ||
this.ionCancel = new EventEmitter(); | ||
this._form.register(this); | ||
@@ -51,2 +56,3 @@ if (_item) { | ||
if (ev.detail === 0) { | ||
// do not continue if the click event came from a form submit | ||
return; | ||
@@ -63,2 +69,5 @@ } | ||
}; | ||
/** | ||
* @private | ||
*/ | ||
CityPicker.prototype.open = function () { | ||
@@ -100,4 +109,8 @@ var _this = this; | ||
}; | ||
/** | ||
* @private | ||
*/ | ||
CityPicker.prototype.generate = function (picker) { | ||
var values = this._value.toString().split(this.separator); | ||
// Add province data to picker | ||
var provinceCol = { | ||
@@ -111,2 +124,3 @@ name: 'province', | ||
picker.addColumn(provinceCol); | ||
// Add city data to picker | ||
var cityColData = this.citiesData[provinceCol.selectedIndex].children; | ||
@@ -121,2 +135,3 @@ var cityCol = { | ||
picker.addColumn(cityCol); | ||
// Add region data to picker | ||
var regionData = this.citiesData[provinceCol.selectedIndex].children[cityCol.selectedIndex].children; | ||
@@ -133,2 +148,5 @@ var regionColCol = { | ||
}; | ||
/** | ||
* @private | ||
*/ | ||
CityPicker.prototype.validate = function (picker) { | ||
@@ -161,2 +179,5 @@ var _this = this; | ||
}; | ||
/** | ||
* @private | ||
*/ | ||
CityPicker.prototype.divyColumns = function (picker) { | ||
@@ -187,2 +208,5 @@ var pickerColumns = picker.getColumns(); | ||
}; | ||
/** | ||
* @private | ||
*/ | ||
CityPicker.prototype.setValue = function (newData) { | ||
@@ -196,5 +220,11 @@ if (newData === null || newData === undefined) { | ||
}; | ||
/** | ||
* @private | ||
*/ | ||
CityPicker.prototype.getValue = function () { | ||
return this._value; | ||
}; | ||
/** | ||
* @private | ||
*/ | ||
CityPicker.prototype.checkHasValue = function (inputValue) { | ||
@@ -205,2 +235,5 @@ if (this._item) { | ||
}; | ||
/** | ||
* @private | ||
*/ | ||
CityPicker.prototype.updateText = function () { | ||
@@ -210,2 +243,5 @@ this._text = this._value.toString().trim(); | ||
Object.defineProperty(CityPicker.prototype, "disabled", { | ||
/** | ||
* @input {boolean} Whether or not the multi picker component is disabled. Default `false`. | ||
*/ | ||
get: function () { | ||
@@ -221,2 +257,5 @@ return this._disabled; | ||
}); | ||
/** | ||
* @private | ||
*/ | ||
CityPicker.prototype.writeValue = function (val) { | ||
@@ -227,5 +266,11 @@ this.setValue(val); | ||
}; | ||
/** | ||
* @private | ||
*/ | ||
CityPicker.prototype.ngAfterContentInit = function () { | ||
this.updateText(); | ||
}; | ||
/** | ||
* @private | ||
*/ | ||
CityPicker.prototype.registerOnChange = function (fn) { | ||
@@ -242,4 +287,11 @@ var _this = this; | ||
}; | ||
/** | ||
* @private | ||
*/ | ||
CityPicker.prototype.registerOnTouched = function (fn) { this.onTouched = fn; }; | ||
/** | ||
* @private | ||
*/ | ||
CityPicker.prototype.onChange = function (val) { | ||
// onChange used when there is not an formControlName | ||
this.setValue(this.getString(val)); | ||
@@ -250,76 +302,56 @@ this.updateText(); | ||
}; | ||
/** | ||
* @private | ||
*/ | ||
CityPicker.prototype.onTouched = function () { }; | ||
/** | ||
* @private | ||
*/ | ||
CityPicker.prototype.ngOnDestroy = function () { | ||
this._form.deregister(this); | ||
}; | ||
/** | ||
* @private | ||
*/ | ||
CityPicker.prototype.getString = function (newData) { | ||
return "" + newData['province'].text + this.separator + (newData['city'].text || '') + this.separator + (newData['region'].text || ''); | ||
}; | ||
CityPicker.decorators = [ | ||
{ type: Component, args: [{ | ||
selector: 'city-picker', | ||
template: '<div class="city-picker-text">{{_text}}</div>' + | ||
'<button aria-haspopup="true" ' + | ||
'type="button" ' + | ||
'[id]="id" ' + | ||
'ion-button="item-cover" ' + | ||
'[attr.aria-labelledby]="_labelId" ' + | ||
'[attr.aria-disabled]="_disabled" ' + | ||
'class="item-cover">' + | ||
'</button>', | ||
host: { | ||
'[class.city-picker-disabled]': '_disabled' | ||
}, | ||
providers: [CITY_PICKER_VALUE_ACCESSOR], | ||
encapsulation: ViewEncapsulation.None, | ||
},] }, | ||
]; | ||
/** @nocollapse */ | ||
CityPicker.ctorParameters = [ | ||
{ type: Form, }, | ||
{ type: Item, decorators: [{ type: Optional },] }, | ||
{ type: PickerController, decorators: [{ type: Optional },] }, | ||
]; | ||
CityPicker.propDecorators = { | ||
'cancelText': [{ type: Input },], | ||
'doneText': [{ type: Input },], | ||
'citiesData': [{ type: Input },], | ||
'separator': [{ type: Input },], | ||
'ionChange': [{ type: Output },], | ||
'ionCancel': [{ type: Output },], | ||
'_click': [{ type: HostListener, args: ['click', ['$event'],] },], | ||
'_keyup': [{ type: HostListener, args: ['keyup.space',] },], | ||
'disabled': [{ type: Input },], | ||
}; | ||
return CityPicker; | ||
}()); | ||
__decorate([ | ||
core_1.Input(), | ||
__metadata("design:type", String) | ||
], CityPicker.prototype, "cancelText", void 0); | ||
__decorate([ | ||
core_1.Input(), | ||
__metadata("design:type", String) | ||
], CityPicker.prototype, "doneText", void 0); | ||
__decorate([ | ||
core_1.Input(), | ||
__metadata("design:type", Array) | ||
], CityPicker.prototype, "citiesData", void 0); | ||
__decorate([ | ||
core_1.Input(), | ||
__metadata("design:type", String) | ||
], CityPicker.prototype, "separator", void 0); | ||
__decorate([ | ||
core_1.Output(), | ||
__metadata("design:type", typeof (_a = typeof core_1.EventEmitter !== "undefined" && core_1.EventEmitter) === "function" && _a || Object) | ||
], CityPicker.prototype, "ionChange", void 0); | ||
__decorate([ | ||
core_1.Output(), | ||
__metadata("design:type", typeof (_b = typeof core_1.EventEmitter !== "undefined" && core_1.EventEmitter) === "function" && _b || Object) | ||
], CityPicker.prototype, "ionCancel", void 0); | ||
__decorate([ | ||
core_1.HostListener('click', ['$event']), | ||
__metadata("design:type", Function), | ||
__metadata("design:paramtypes", [UIEvent]), | ||
__metadata("design:returntype", void 0) | ||
], CityPicker.prototype, "_click", null); | ||
__decorate([ | ||
core_1.HostListener('keyup.space'), | ||
__metadata("design:type", Function), | ||
__metadata("design:paramtypes", []), | ||
__metadata("design:returntype", void 0) | ||
], CityPicker.prototype, "_keyup", null); | ||
__decorate([ | ||
core_1.Input(), | ||
__metadata("design:type", Object), | ||
__metadata("design:paramtypes", []) | ||
], CityPicker.prototype, "disabled", null); | ||
CityPicker = __decorate([ | ||
core_1.Component({ | ||
selector: 'city-picker', | ||
template: '<div class="city-picker-text">{{_text}}</div>' + | ||
'<button aria-haspopup="true" ' + | ||
'type="button" ' + | ||
'[id]="id" ' + | ||
'ion-button="item-cover" ' + | ||
'[attr.aria-labelledby]="_labelId" ' + | ||
'[attr.aria-disabled]="_disabled" ' + | ||
'class="item-cover">' + | ||
'</button>', | ||
host: { | ||
'[class.city-picker-disabled]': '_disabled' | ||
}, | ||
providers: [exports.CITY_PICKER_VALUE_ACCESSOR], | ||
encapsulation: core_1.ViewEncapsulation.None, | ||
}), | ||
__param(1, core_1.Optional()), | ||
__param(2, core_1.Optional()), | ||
__metadata("design:paramtypes", [typeof (_c = typeof ionic_angular_1.Form !== "undefined" && ionic_angular_1.Form) === "function" && _c || Object, typeof (_d = typeof ionic_angular_1.Item !== "undefined" && ionic_angular_1.Item) === "function" && _d || Object, typeof (_e = typeof ionic_angular_1.PickerController !== "undefined" && ionic_angular_1.PickerController) === "function" && _e || Object]) | ||
], CityPicker); | ||
exports.CityPicker = CityPicker; | ||
var _a, _b, _c, _d, _e; | ||
//# sourceMappingURL=city-picker.js.map |
@@ -0,1 +1,4 @@ | ||
/** | ||
* Created by hsuanlee on 2017/2/7. | ||
*/ | ||
export interface CityPickerColumn { | ||
@@ -2,0 +5,0 @@ name?: string; |
@@ -1,2 +0,4 @@ | ||
"use strict"; | ||
/** | ||
* Created by hsuanlee on 2017/2/7. | ||
*/ | ||
//# sourceMappingURL=city-picker.model.js.map |
@@ -1,33 +0,25 @@ | ||
"use strict"; | ||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { | ||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; | ||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); | ||
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; | ||
return c > 3 && r && Object.defineProperty(target, key, r), r; | ||
}; | ||
var __metadata = (this && this.__metadata) || function (k, v) { | ||
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); | ||
}; | ||
var core_1 = require("@angular/core"); | ||
var common_1 = require("@angular/common"); | ||
var city_picker_1 = require("./city-picker"); | ||
var ionic_angular_1 = require("ionic-angular"); | ||
var CityPickerModule = (function () { | ||
import { NgModule, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core'; | ||
import { BrowserModule } from '@angular/platform-browser'; | ||
import { IonicModule } from 'ionic-angular'; | ||
import { CityPicker } from './city-picker'; | ||
export var CityPickerModule = (function () { | ||
function CityPickerModule() { | ||
} | ||
CityPickerModule.decorators = [ | ||
{ type: NgModule, args: [{ | ||
declarations: [CityPicker], | ||
exports: [CityPicker], | ||
imports: [ | ||
BrowserModule, | ||
IonicModule | ||
], | ||
schemas: [ | ||
CUSTOM_ELEMENTS_SCHEMA, | ||
] | ||
},] }, | ||
]; | ||
/** @nocollapse */ | ||
CityPickerModule.ctorParameters = []; | ||
return CityPickerModule; | ||
}()); | ||
CityPickerModule = __decorate([ | ||
core_1.NgModule({ | ||
imports: [ionic_angular_1.IonicModule, common_1.CommonModule], | ||
declarations: [city_picker_1.CityPicker], | ||
exports: [city_picker_1.CityPicker], | ||
schemas: [ | ||
core_1.CUSTOM_ELEMENTS_SCHEMA, | ||
core_1.NO_ERRORS_SCHEMA | ||
] | ||
}), | ||
__metadata("design:paramtypes", []) | ||
], CityPickerModule); | ||
exports.CityPickerModule = CityPickerModule; | ||
//# sourceMappingURL=city-picker.module.js.map |
{ | ||
"name": "ionic2-city-picker", | ||
"version": "0.0.3", | ||
"version": "0.0.4", | ||
"description": "ionic2 ", | ||
"main": "./dist/index.js", | ||
"typings": "./dist/index.d.ts", | ||
"scripts": { | ||
"ngc": "ngc", | ||
"test": "echo \"Error: no test specified\" && exit 1", | ||
@@ -14,2 +16,17 @@ "build":"tsc" | ||
}, | ||
"devDependencies": { | ||
"@angular/common": "2.2.1", | ||
"@angular/compiler": "2.2.1", | ||
"@angular/compiler-cli": "2.2.1", | ||
"@angular/core": "2.2.1", | ||
"@angular/forms": "2.2.1", | ||
"@angular/http": "2.2.1", | ||
"@angular/platform-browser": "2.2.1", | ||
"@angular/platform-browser-dynamic": "2.2.1", | ||
"@angular/platform-server": "2.2.1", | ||
"ionic-angular": "2.0.0", | ||
"rxjs": "5.0.0-beta.12", | ||
"zone.js": "0.6.26", | ||
"typescript": "2.0.9" | ||
}, | ||
"keywords": [ | ||
@@ -16,0 +33,0 @@ "ionic2", |
@@ -11,3 +11,3 @@ # ionic2-city-picker | ||
## Install | ||
`npm install ion-city-picker --save` | ||
`npm install ionic2-city-picker --save` | ||
@@ -14,0 +14,0 @@ ## Json 下载 |
/** | ||
* Created by hsuanlee on 2017/2/13. | ||
*/ | ||
import { NgModule, CUSTOM_ELEMENTS_SCHEMA,NO_ERRORS_SCHEMA } from '@angular/core'; | ||
import { CommonModule } from '@angular/common'; | ||
import { NgModule, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core'; | ||
import { BrowserModule } from '@angular/platform-browser'; | ||
import { IonicModule } from 'ionic-angular'; | ||
import { CityPicker } from './city-picker'; | ||
import {IonicModule} from "ionic-angular"; | ||
@NgModule({ | ||
imports: [ IonicModule, CommonModule ], | ||
declarations: [ CityPicker], | ||
exports:[CityPicker], | ||
imports: [ | ||
BrowserModule, | ||
IonicModule | ||
], | ||
schemas: [ | ||
CUSTOM_ELEMENTS_SCHEMA, | ||
NO_ERRORS_SCHEMA | ||
] | ||
}) | ||
export class CityPickerModule { } |
@@ -251,6 +251,6 @@ import { AfterContentInit, Component, EventEmitter, forwardRef, HostListener, Input, OnDestroy, Optional, Output, | ||
pickerColumns.forEach((col, i) => { | ||
pickerColumns.forEach((col:any, i:any) => { | ||
columns.push(0); | ||
col.options.forEach(opt => { | ||
col.options.forEach((opt:any) => { | ||
if (opt.text.length > columns[i]) { | ||
@@ -387,3 +387,3 @@ columns[i] = opt.text.length; | ||
*/ | ||
getString(newData) { | ||
getString(newData:any) { | ||
return `${newData['province'].text}${this.separator}${newData['city'].text || ''}${this.separator}${newData['region'].text || ''}`; | ||
@@ -390,0 +390,0 @@ } |
{ | ||
"compilerOptions": { | ||
"noImplicitAny": true, | ||
"declaration": true, | ||
"emitDecoratorMetadata": true, | ||
"experimentalDecorators": true, | ||
"module": "commonjs", | ||
"moduleResolution": "node", | ||
"outDir": "dist", | ||
"removeComments": true, | ||
"sourceMap": true, | ||
"target": "es5" | ||
"module": "es2015", | ||
"target": "es5", | ||
"moduleResolution": "node", | ||
"sourceMap": true, | ||
"declaration": true, | ||
"noImplicitAny": true, | ||
"experimentalDecorators": true, | ||
"lib": ["dom", "es2015"], | ||
"outDir": "./dist" | ||
}, | ||
"files": [ | ||
"src/city-picker.model.ts", | ||
"src/city-picker.module.ts", | ||
"src/city-picker.ts" | ||
], | ||
"exclude": [ | ||
"node_modules" | ||
], | ||
"compileOnSave": false, | ||
"atom": { | ||
"rewriteTsconfig": false | ||
} | ||
"node_modules", | ||
"dist" | ||
], | ||
"angularCompilerOptions": { | ||
"genDir": "aot" | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
49156
24
881
13