diff --git a/packages/core/package.json b/packages/core/package.json index 1d01b33e64..7ed57a9a18 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -10,11 +10,11 @@ "README.md" ], "dependencies": { - "@stencil/core": "^0.0.4-11" + "@stencil/core": "0.0.4-14" }, "devDependencies": { - "@stencil/dev-server": "^0.0.14", - "@stencil/utils": "^0.0.4" + "@stencil/dev-server": "latest", + "@stencil/utils": "latest" }, "scripts": { "build": "stencil build", diff --git a/packages/core/src/components/select/option.tsx b/packages/core/src/components/select/option.tsx new file mode 100644 index 0000000000..19e2e544fc --- /dev/null +++ b/packages/core/src/components/select/option.tsx @@ -0,0 +1,16 @@ +import { Component } from '@stencil/core'; + + +@Component({ + tag: 'ion-option', + host: { + theme: 'option' + } +}) +export class option { + + render() { + return
; + } + +} \ No newline at end of file diff --git a/packages/core/src/components/select/select.ios.scss b/packages/core/src/components/select/select.ios.scss new file mode 100644 index 0000000000..be13730339 --- /dev/null +++ b/packages/core/src/components/select/select.ios.scss @@ -0,0 +1,56 @@ +@import "../../themes/ionic.globals.ios"; +@import "./select"; + +// iOS Select +// -------------------------------------------------- + +/// @prop - Padding top of the select +$select-ios-padding-top: $item-ios-padding-top !default; + +/// @prop - Padding end of the select +$select-ios-padding-end: ($item-ios-padding-end / 2) !default; + +/// @prop - Padding bottom of the select +$select-ios-padding-bottom: $item-ios-padding-bottom !default; + +/// @prop - Padding start of the select +$select-ios-padding-start: $item-ios-padding-start !default; + +/// @prop - Color of the select icon +$select-ios-icon-color: #999 !default; + +/// @prop - Color of the select placeholder +$select-ios-placeholder-color: $select-ios-icon-color !default; + + +.select-ios { + @include padding($select-ios-padding-top, $select-ios-padding-end, $select-ios-padding-bottom, $select-ios-padding-start); +} + +.select-ios .select-placeholder { + color: $select-ios-placeholder-color; +} + +.select-ios .select-icon { + position: relative; + + width: 12px; + height: 18px; +} + +.select-ios .select-icon .select-icon-inner { + @include position(50%, null, null, 5px); + @include margin(-2px, null, null, null); + + position: absolute; + + width: 0; + height: 0; + + border-top: 5px solid; + border-right: 5px solid transparent; + border-left: 5px solid transparent; + color: $select-ios-icon-color; + + pointer-events: none; +} diff --git a/packages/core/src/components/select/select.md.scss b/packages/core/src/components/select/select.md.scss new file mode 100644 index 0000000000..ea2f6f2468 --- /dev/null +++ b/packages/core/src/components/select/select.md.scss @@ -0,0 +1,60 @@ +@import "../../themes/ionic.globals.md"; +@import "./select"; + +// Material Design Select +// -------------------------------------------------- + +/// @prop - Padding top of the select +$select-md-padding-top: $item-md-padding-top !default; + +/// @prop - Padding end of the select +$select-md-padding-end: ($item-md-padding-end / 2) !default; + +/// @prop - Padding bottom of the select +$select-md-padding-bottom: $item-md-padding-bottom !default; + +/// @prop - Padding start of the select +$select-md-padding-start: $item-md-padding-start !default; + +/// @prop - Color of the select icon +$select-md-icon-color: #999 !default; + +/// @prop - Color of the select placeholder +$select-md-placeholder-color: $select-md-icon-color !default; + + +.select-md { + @include padding($select-md-padding-top, $select-md-padding-end, $select-md-padding-bottom, $select-md-padding-start); +} + +.select-md .select-placeholder { + color: $select-md-placeholder-color; +} + +.select-md .item-select ion-label { + @include margin-horizontal(0, null); +} + +.select-md .select-icon { + position: relative; + + width: 12px; + height: 19px; +} + +.select-md .select-icon .select-icon-inner { + @include position(50%, null, null, 5px); + @include margin(-3px, null, null, null); + + position: absolute; + + width: 0; + height: 0; + + border-top: 5px solid; + border-right: 5px solid transparent; + border-left: 5px solid transparent; + color: $select-md-icon-color; + + pointer-events: none; +} diff --git a/packages/core/src/components/select/select.scss b/packages/core/src/components/select/select.scss new file mode 100644 index 0000000000..dcd429f952 --- /dev/null +++ b/packages/core/src/components/select/select.scss @@ -0,0 +1,56 @@ +@import "../../themes/ionic.globals"; + +// Select +// -------------------------------------------------- + +/// @prop - Margin top of the select popover list +$select-popover-list-margin-top: -1px !default; + +/// @prop - Margin end of the select popover list +$select-popover-list-margin-end: 0 !default; + +/// @prop - Margin bottom of the select popover list +$select-popover-list-margin-bottom: -1px !default; + +/// @prop - Margin start of the select popover list +$select-popover-list-margin-start: 0 !default; + + +ion-select { + display: flex; + overflow: hidden; + + max-width: 45%; +} + +.select-text { + overflow: hidden; + + flex: 1; + + min-width: 16px; + + font-size: inherit; + text-overflow: ellipsis; + white-space: nowrap; +} + +.item-multiple-inputs ion-select { + position: relative; +} + +.select-disabled, +.item-select-disabled ion-label { + opacity: .4; + + pointer-events: none; +} + +.select-popover ion-list { + @include margin($select-popover-list-margin-top, $select-popover-list-margin-end, $select-popover-list-margin-bottom, $select-popover-list-margin-start); +} + +// TODO remove +.select .option { + display: none; +} \ No newline at end of file diff --git a/packages/core/src/components/select/select.tsx b/packages/core/src/components/select/select.tsx new file mode 100644 index 0000000000..ab4760bd46 --- /dev/null +++ b/packages/core/src/components/select/select.tsx @@ -0,0 +1,365 @@ +import { Component, CssClassMap, Event, EventEmitter, Prop } from '@stencil/core'; + + +@Component({ + tag: 'ion-select', + styleUrls: { + ios: 'select.ios.scss', + md: 'select.md.scss', + wp: 'select.wp.scss' + }, + host: { + theme: 'select' + } +}) +export class Select { + text: any; + id: any; + labelId: any; + + /** + * @input {boolean} If true, the user cannot interact with this element. Defaults to `false`. + */ + @Prop() disabled: boolean = false; + + /** + * @input {string} The text to display on the cancel button. Default: `Cancel`. + */ + @Prop() cancelText: string = 'Cancel'; + + /** + * @input {string} The text to display on the ok button. Default: `OK`. + */ + @Prop() okText: string = 'OK'; + + /** + * @input {string} The text to display when the select is empty. + */ + @Prop() placeholder: string; + + /** + * @input {any} Any additional options that the `alert` or `action-sheet` interface can take. + * See the [AlertController API docs](../../alert/AlertController/#create) and the + * [ActionSheetController API docs](../../action-sheet/ActionSheetController/#create) for the + * create options for each interface. + */ + @Prop() selectOptions: any = {}; + + /** + * @input {string} The interface the select should use: `action-sheet`, `popover` or `alert`. Default: `alert`. + */ + @Prop() interface: string = ''; + + /** + * @input {string} The text to display instead of the selected option's value. + */ + @Prop() selectedText: string; + + /** + * @input {boolean} If true, the element can accept multiple values. + */ + @Prop() multiple: boolean; + + /** + * @output {EventEmitter} Emitted when the selection is cancelled. + */ + @Event() ionCancel: EventEmitter; + + + hostData() { + return { + class: { + 'select-disabled': this.disabled + } + }; + } + + render() { + let addPlaceholderClass = false + + let selectText = this.selectedText || this.text; + if (!selectText && this.placeholder) { + selectText = this.placeholder; + addPlaceholderClass = true; + } + + const selectTextClasses: CssClassMap = { + 'select-text': true, + 'select-placeholder': addPlaceholderClass + }; + + return [ + // add placeholder class +
{ selectText }
, +
+
+
, + + ]; + } + +} + +// export class Select extends BaseInput implements OnDestroy { + +// _options: QueryList