1 | 'use strict';
|
2 |
|
3 | Object.defineProperty(exports, '__esModule', { value: true });
|
4 |
|
5 | const index = require('./index-a0a08b2a.js');
|
6 | const ionicGlobal = require('./ionic-global-06f21c1a.js');
|
7 | const helpers = require('./helpers-d381ec4d.js');
|
8 | const theme = require('./theme-30b7a575.js');
|
9 |
|
10 | const searchbarIosCss = ".sc-ion-searchbar-ios-h{--placeholder-color:initial;--placeholder-font-style:initial;--placeholder-font-weight:initial;--placeholder-opacity:.5;-moz-osx-font-smoothing:grayscale;-webkit-font-smoothing:antialiased;display:-ms-flexbox;display:flex;position:relative;-ms-flex-align:center;align-items:center;width:100%;color:var(--color);font-family:var(--ion-font-family, inherit);-webkit-box-sizing:border-box;box-sizing:border-box}.ion-color.sc-ion-searchbar-ios-h{color:var(--ion-color-contrast)}.ion-color.sc-ion-searchbar-ios-h .searchbar-input.sc-ion-searchbar-ios{background:var(--ion-color-base)}.ion-color.sc-ion-searchbar-ios-h .searchbar-clear-button.sc-ion-searchbar-ios,.ion-color.sc-ion-searchbar-ios-h .searchbar-cancel-button.sc-ion-searchbar-ios,.ion-color.sc-ion-searchbar-ios-h .searchbar-search-icon.sc-ion-searchbar-ios{color:inherit}.searchbar-search-icon.sc-ion-searchbar-ios{color:var(--icon-color);pointer-events:none}.searchbar-input-container.sc-ion-searchbar-ios{display:block;position:relative;-ms-flex-negative:1;flex-shrink:1;width:100%}.searchbar-input.sc-ion-searchbar-ios{font-family:inherit;font-size:inherit;font-style:inherit;font-weight:inherit;letter-spacing:inherit;text-decoration:inherit;text-indent:inherit;text-overflow:inherit;text-transform:inherit;text-align:inherit;white-space:inherit;color:inherit;border-radius:var(--border-radius);display:block;width:100%;border:0;outline:none;background:var(--background);font-family:inherit;-webkit-box-shadow:var(--box-shadow);box-shadow:var(--box-shadow);-webkit-box-sizing:border-box;box-sizing:border-box;-webkit-appearance:none;-moz-appearance:none;appearance:none}.searchbar-input.sc-ion-searchbar-ios::-webkit-input-placeholder{color:var(--placeholder-color);font-family:inherit;font-style:var(--placeholder-font-style);font-weight:var(--placeholder-font-weight);opacity:var(--placeholder-opacity)}.searchbar-input.sc-ion-searchbar-ios::-moz-placeholder{color:var(--placeholder-color);font-family:inherit;font-style:var(--placeholder-font-style);font-weight:var(--placeholder-font-weight);opacity:var(--placeholder-opacity)}.searchbar-input.sc-ion-searchbar-ios:-ms-input-placeholder{color:var(--placeholder-color);font-family:inherit;font-style:var(--placeholder-font-style);font-weight:var(--placeholder-font-weight);opacity:var(--placeholder-opacity)}.searchbar-input.sc-ion-searchbar-ios::-ms-input-placeholder{color:var(--placeholder-color);font-family:inherit;font-style:var(--placeholder-font-style);font-weight:var(--placeholder-font-weight);opacity:var(--placeholder-opacity)}.searchbar-input.sc-ion-searchbar-ios::placeholder{color:var(--placeholder-color);font-family:inherit;font-style:var(--placeholder-font-style);font-weight:var(--placeholder-font-weight);opacity:var(--placeholder-opacity)}.searchbar-input.sc-ion-searchbar-ios::-webkit-search-cancel-button,.searchbar-input.sc-ion-searchbar-ios::-ms-clear{display:none}.searchbar-cancel-button.sc-ion-searchbar-ios{margin-left:0;margin-right:0;margin-top:0;margin-bottom:0;display:none;height:100%;border:0;outline:none;color:var(--cancel-button-color);cursor:pointer;-webkit-appearance:none;-moz-appearance:none;appearance:none}.searchbar-cancel-button.sc-ion-searchbar-ios>div.sc-ion-searchbar-ios{display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center;-ms-flex-pack:center;justify-content:center;width:100%;height:100%}.searchbar-clear-button.sc-ion-searchbar-ios{margin-left:0;margin-right:0;margin-top:0;margin-bottom:0;padding-left:0;padding-right:0;padding-top:0;padding-bottom:0;display:none;min-height:0;outline:none;color:var(--clear-button-color);-webkit-appearance:none;-moz-appearance:none;appearance:none}.searchbar-has-value.searchbar-should-show-clear.sc-ion-searchbar-ios-h .searchbar-clear-button.sc-ion-searchbar-ios{display:block}.searchbar-disabled.sc-ion-searchbar-ios-h{cursor:default;opacity:0.4;pointer-events:none}.sc-ion-searchbar-ios-h{--background:rgba(var(--ion-text-color-rgb, 0, 0, 0), 0.07);--border-radius:10px;--box-shadow:none;--cancel-button-color:var(--ion-color-primary, #3880ff);--clear-button-color:var(--ion-color-step-600, #666666);--color:var(--ion-text-color, #000);--icon-color:var(--ion-color-step-600, #666666);padding-left:12px;padding-right:12px;padding-top:12px;padding-bottom:12px;height:60px;contain:strict}@supports ((-webkit-margin-start: 0) or (margin-inline-start: 0)) or (-webkit-margin-start: 0){.sc-ion-searchbar-ios-h{padding-left:unset;padding-right:unset;-webkit-padding-start:12px;padding-inline-start:12px;-webkit-padding-end:12px;padding-inline-end:12px}}.searchbar-input-container.sc-ion-searchbar-ios{height:36px}.searchbar-search-icon.sc-ion-searchbar-ios{margin-left:calc(50% - 60px);left:5px;top:0;position:absolute;width:22px;height:100%;contain:strict}@supports ((-webkit-margin-start: 0) or (margin-inline-start: 0)) or (-webkit-margin-start: 0){.searchbar-search-icon.sc-ion-searchbar-ios{margin-left:unset;-webkit-margin-start:calc(50% - 60px);margin-inline-start:calc(50% - 60px)}}[dir=rtl].sc-ion-searchbar-ios .searchbar-search-icon.sc-ion-searchbar-ios,[dir=rtl].sc-ion-searchbar-ios-h .searchbar-search-icon.sc-ion-searchbar-ios,[dir=rtl] .sc-ion-searchbar-ios-h .searchbar-search-icon.sc-ion-searchbar-ios{left:unset;right:unset;right:5px}.searchbar-input.sc-ion-searchbar-ios{padding-left:28px;padding-right:28px;padding-top:0;padding-bottom:0;height:100%;font-size:17px;font-weight:400;contain:strict}@supports ((-webkit-margin-start: 0) or (margin-inline-start: 0)) or (-webkit-margin-start: 0){.searchbar-input.sc-ion-searchbar-ios{padding-left:unset;padding-right:unset;-webkit-padding-start:28px;padding-inline-start:28px;-webkit-padding-end:28px;padding-inline-end:28px}}.searchbar-clear-button.sc-ion-searchbar-ios{right:0;top:0;background-position:center;position:absolute;width:30px;height:100%;border:0;background-color:transparent}[dir=rtl].sc-ion-searchbar-ios .searchbar-clear-button.sc-ion-searchbar-ios,[dir=rtl].sc-ion-searchbar-ios-h .searchbar-clear-button.sc-ion-searchbar-ios,[dir=rtl] .sc-ion-searchbar-ios-h .searchbar-clear-button.sc-ion-searchbar-ios{left:unset;right:unset;left:0}.searchbar-clear-icon.sc-ion-searchbar-ios{width:18px;height:100%}.searchbar-cancel-button.sc-ion-searchbar-ios{padding-left:8px;padding-right:0;padding-top:0;padding-bottom:0;-ms-flex-negative:0;flex-shrink:0;background-color:transparent;font-size:16px}@supports ((-webkit-margin-start: 0) or (margin-inline-start: 0)) or (-webkit-margin-start: 0){.searchbar-cancel-button.sc-ion-searchbar-ios{padding-left:unset;padding-right:unset;-webkit-padding-start:8px;padding-inline-start:8px;-webkit-padding-end:0;padding-inline-end:0}}.searchbar-left-aligned.sc-ion-searchbar-ios-h .searchbar-search-icon.sc-ion-searchbar-ios{margin-left:0}@supports ((-webkit-margin-start: 0) or (margin-inline-start: 0)) or (-webkit-margin-start: 0){.searchbar-left-aligned.sc-ion-searchbar-ios-h .searchbar-search-icon.sc-ion-searchbar-ios{margin-left:unset;-webkit-margin-start:0;margin-inline-start:0}}.searchbar-left-aligned.sc-ion-searchbar-ios-h .searchbar-input.sc-ion-searchbar-ios{padding-left:30px}@supports ((-webkit-margin-start: 0) or (margin-inline-start: 0)) or (-webkit-margin-start: 0){.searchbar-left-aligned.sc-ion-searchbar-ios-h .searchbar-input.sc-ion-searchbar-ios{padding-left:unset;-webkit-padding-start:30px;padding-inline-start:30px}}.searchbar-has-focus.sc-ion-searchbar-ios-h .searchbar-cancel-button.sc-ion-searchbar-ios,.searchbar-should-show-cancel.sc-ion-searchbar-ios-h .searchbar-cancel-button.sc-ion-searchbar-ios,.searchbar-animated.sc-ion-searchbar-ios-h .searchbar-cancel-button.sc-ion-searchbar-ios{display:block}.searchbar-animated.sc-ion-searchbar-ios-h .searchbar-search-icon.sc-ion-searchbar-ios,.searchbar-animated.sc-ion-searchbar-ios-h .searchbar-input.sc-ion-searchbar-ios{-webkit-transition:all 300ms ease;transition:all 300ms ease}.searchbar-animated.searchbar-has-focus.sc-ion-searchbar-ios-h .searchbar-cancel-button.sc-ion-searchbar-ios,.searchbar-animated.searchbar-should-show-cancel.sc-ion-searchbar-ios-h .searchbar-cancel-button.sc-ion-searchbar-ios{opacity:1;pointer-events:auto}.searchbar-animated.sc-ion-searchbar-ios-h .searchbar-cancel-button.sc-ion-searchbar-ios{margin-right:-100%;-webkit-transform:translate3d(0, 0, 0);transform:translate3d(0, 0, 0);-webkit-transition:all 300ms ease;transition:all 300ms ease;opacity:0;pointer-events:none}@supports ((-webkit-margin-start: 0) or (margin-inline-start: 0)) or (-webkit-margin-start: 0){.searchbar-animated.sc-ion-searchbar-ios-h .searchbar-cancel-button.sc-ion-searchbar-ios{margin-right:unset;-webkit-margin-end:-100%;margin-inline-end:-100%}}.searchbar-no-animate.sc-ion-searchbar-ios-h .searchbar-search-icon.sc-ion-searchbar-ios,.searchbar-no-animate.sc-ion-searchbar-ios-h .searchbar-input.sc-ion-searchbar-ios,.searchbar-no-animate.sc-ion-searchbar-ios-h .searchbar-cancel-button.sc-ion-searchbar-ios{-webkit-transition-duration:0ms;transition-duration:0ms}.ion-color.sc-ion-searchbar-ios-h .searchbar-cancel-button.sc-ion-searchbar-ios{color:var(--ion-color-base)}@media (any-hover: hover){.ion-color.sc-ion-searchbar-ios-h .searchbar-cancel-button.sc-ion-searchbar-ios:hover{color:var(--ion-color-tint)}}ion-toolbar.sc-ion-searchbar-ios-h,ion-toolbar .sc-ion-searchbar-ios-h{padding-top:1px;padding-bottom:15px;height:52px}ion-toolbar.ion-color.sc-ion-searchbar-ios-h:not(.ion-color),ion-toolbar.ion-color .sc-ion-searchbar-ios-h:not(.ion-color){color:inherit}ion-toolbar.ion-color.sc-ion-searchbar-ios-h:not(.ion-color) .searchbar-cancel-button.sc-ion-searchbar-ios,ion-toolbar.ion-color .sc-ion-searchbar-ios-h:not(.ion-color) .searchbar-cancel-button.sc-ion-searchbar-ios{color:currentColor}ion-toolbar.ion-color.sc-ion-searchbar-ios-h .searchbar-search-icon.sc-ion-searchbar-ios,ion-toolbar.ion-color .sc-ion-searchbar-ios-h .searchbar-search-icon.sc-ion-searchbar-ios{color:currentColor;opacity:0.5}ion-toolbar.ion-color.sc-ion-searchbar-ios-h:not(.ion-color) .searchbar-input.sc-ion-searchbar-ios,ion-toolbar.ion-color .sc-ion-searchbar-ios-h:not(.ion-color) .searchbar-input.sc-ion-searchbar-ios{background:rgba(var(--ion-color-contrast-rgb), 0.07);color:currentColor}ion-toolbar.ion-color.sc-ion-searchbar-ios-h:not(.ion-color) .searchbar-clear-button.sc-ion-searchbar-ios,ion-toolbar.ion-color .sc-ion-searchbar-ios-h:not(.ion-color) .searchbar-clear-button.sc-ion-searchbar-ios{color:currentColor;opacity:0.5}";
|
11 |
|
12 | const searchbarMdCss = ".sc-ion-searchbar-md-h{--placeholder-color:initial;--placeholder-font-style:initial;--placeholder-font-weight:initial;--placeholder-opacity:.5;-moz-osx-font-smoothing:grayscale;-webkit-font-smoothing:antialiased;display:-ms-flexbox;display:flex;position:relative;-ms-flex-align:center;align-items:center;width:100%;color:var(--color);font-family:var(--ion-font-family, inherit);-webkit-box-sizing:border-box;box-sizing:border-box}.ion-color.sc-ion-searchbar-md-h{color:var(--ion-color-contrast)}.ion-color.sc-ion-searchbar-md-h .searchbar-input.sc-ion-searchbar-md{background:var(--ion-color-base)}.ion-color.sc-ion-searchbar-md-h .searchbar-clear-button.sc-ion-searchbar-md,.ion-color.sc-ion-searchbar-md-h .searchbar-cancel-button.sc-ion-searchbar-md,.ion-color.sc-ion-searchbar-md-h .searchbar-search-icon.sc-ion-searchbar-md{color:inherit}.searchbar-search-icon.sc-ion-searchbar-md{color:var(--icon-color);pointer-events:none}.searchbar-input-container.sc-ion-searchbar-md{display:block;position:relative;-ms-flex-negative:1;flex-shrink:1;width:100%}.searchbar-input.sc-ion-searchbar-md{font-family:inherit;font-size:inherit;font-style:inherit;font-weight:inherit;letter-spacing:inherit;text-decoration:inherit;text-indent:inherit;text-overflow:inherit;text-transform:inherit;text-align:inherit;white-space:inherit;color:inherit;border-radius:var(--border-radius);display:block;width:100%;border:0;outline:none;background:var(--background);font-family:inherit;-webkit-box-shadow:var(--box-shadow);box-shadow:var(--box-shadow);-webkit-box-sizing:border-box;box-sizing:border-box;-webkit-appearance:none;-moz-appearance:none;appearance:none}.searchbar-input.sc-ion-searchbar-md::-webkit-input-placeholder{color:var(--placeholder-color);font-family:inherit;font-style:var(--placeholder-font-style);font-weight:var(--placeholder-font-weight);opacity:var(--placeholder-opacity)}.searchbar-input.sc-ion-searchbar-md::-moz-placeholder{color:var(--placeholder-color);font-family:inherit;font-style:var(--placeholder-font-style);font-weight:var(--placeholder-font-weight);opacity:var(--placeholder-opacity)}.searchbar-input.sc-ion-searchbar-md:-ms-input-placeholder{color:var(--placeholder-color);font-family:inherit;font-style:var(--placeholder-font-style);font-weight:var(--placeholder-font-weight);opacity:var(--placeholder-opacity)}.searchbar-input.sc-ion-searchbar-md::-ms-input-placeholder{color:var(--placeholder-color);font-family:inherit;font-style:var(--placeholder-font-style);font-weight:var(--placeholder-font-weight);opacity:var(--placeholder-opacity)}.searchbar-input.sc-ion-searchbar-md::placeholder{color:var(--placeholder-color);font-family:inherit;font-style:var(--placeholder-font-style);font-weight:var(--placeholder-font-weight);opacity:var(--placeholder-opacity)}.searchbar-input.sc-ion-searchbar-md::-webkit-search-cancel-button,.searchbar-input.sc-ion-searchbar-md::-ms-clear{display:none}.searchbar-cancel-button.sc-ion-searchbar-md{margin-left:0;margin-right:0;margin-top:0;margin-bottom:0;display:none;height:100%;border:0;outline:none;color:var(--cancel-button-color);cursor:pointer;-webkit-appearance:none;-moz-appearance:none;appearance:none}.searchbar-cancel-button.sc-ion-searchbar-md>div.sc-ion-searchbar-md{display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center;-ms-flex-pack:center;justify-content:center;width:100%;height:100%}.searchbar-clear-button.sc-ion-searchbar-md{margin-left:0;margin-right:0;margin-top:0;margin-bottom:0;padding-left:0;padding-right:0;padding-top:0;padding-bottom:0;display:none;min-height:0;outline:none;color:var(--clear-button-color);-webkit-appearance:none;-moz-appearance:none;appearance:none}.searchbar-has-value.searchbar-should-show-clear.sc-ion-searchbar-md-h .searchbar-clear-button.sc-ion-searchbar-md{display:block}.searchbar-disabled.sc-ion-searchbar-md-h{cursor:default;opacity:0.4;pointer-events:none}.sc-ion-searchbar-md-h{--background:var(--ion-background-color, #fff);--border-radius:2px;--box-shadow:0 2px 2px 0 rgba(0, 0, 0, 0.14), 0 3px 1px -2px rgba(0, 0, 0, 0.2), 0 1px 5px 0 rgba(0, 0, 0, 0.12);--cancel-button-color:var(--ion-color-step-900, #1a1a1a);--clear-button-color:initial;--color:var(--ion-color-step-850, #262626);--icon-color:var(--ion-color-step-600, #666666);padding-left:8px;padding-right:8px;padding-top:8px;padding-bottom:8px;background:inherit}@supports ((-webkit-margin-start: 0) or (margin-inline-start: 0)) or (-webkit-margin-start: 0){.sc-ion-searchbar-md-h{padding-left:unset;padding-right:unset;-webkit-padding-start:8px;padding-inline-start:8px;-webkit-padding-end:8px;padding-inline-end:8px}}.searchbar-search-icon.sc-ion-searchbar-md{left:16px;top:11px;width:21px;height:21px}[dir=rtl].sc-ion-searchbar-md .searchbar-search-icon.sc-ion-searchbar-md,[dir=rtl].sc-ion-searchbar-md-h .searchbar-search-icon.sc-ion-searchbar-md,[dir=rtl] .sc-ion-searchbar-md-h .searchbar-search-icon.sc-ion-searchbar-md{left:unset;right:unset;right:16px}.searchbar-cancel-button.sc-ion-searchbar-md{left:5px;top:0;background-color:transparent;font-size:1.6em}[dir=rtl].sc-ion-searchbar-md .searchbar-cancel-button.sc-ion-searchbar-md,[dir=rtl].sc-ion-searchbar-md-h .searchbar-cancel-button.sc-ion-searchbar-md,[dir=rtl] .sc-ion-searchbar-md-h .searchbar-cancel-button.sc-ion-searchbar-md{left:unset;right:unset;right:5px}.searchbar-search-icon.sc-ion-searchbar-md,.searchbar-cancel-button.sc-ion-searchbar-md{position:absolute}.searchbar-search-icon.ion-activated.sc-ion-searchbar-md,.searchbar-cancel-button.ion-activated.sc-ion-searchbar-md{background-color:transparent}.searchbar-input.sc-ion-searchbar-md{padding-left:55px;padding-right:55px;padding-top:6px;padding-bottom:6px;background-position:left 8px center;height:auto;font-size:16px;font-weight:400;line-height:30px}@supports ((-webkit-margin-start: 0) or (margin-inline-start: 0)) or (-webkit-margin-start: 0){.searchbar-input.sc-ion-searchbar-md{padding-left:unset;padding-right:unset;-webkit-padding-start:55px;padding-inline-start:55px;-webkit-padding-end:55px;padding-inline-end:55px}}[dir=rtl].sc-ion-searchbar-md .searchbar-input.sc-ion-searchbar-md,[dir=rtl].sc-ion-searchbar-md-h .searchbar-input.sc-ion-searchbar-md,[dir=rtl] .sc-ion-searchbar-md-h .searchbar-input.sc-ion-searchbar-md{background-position:right 8px center}.searchbar-clear-button.sc-ion-searchbar-md{right:13px;top:0;padding-left:0;padding-right:0;padding-top:0;padding-bottom:0;position:absolute;height:100%;border:0;background-color:transparent}[dir=rtl].sc-ion-searchbar-md .searchbar-clear-button.sc-ion-searchbar-md,[dir=rtl].sc-ion-searchbar-md-h .searchbar-clear-button.sc-ion-searchbar-md,[dir=rtl] .sc-ion-searchbar-md-h .searchbar-clear-button.sc-ion-searchbar-md{left:unset;right:unset;left:13px}.searchbar-clear-button.ion-activated.sc-ion-searchbar-md{background-color:transparent}.searchbar-clear-icon.sc-ion-searchbar-md{width:22px;height:100%}.searchbar-has-focus.sc-ion-searchbar-md-h .searchbar-search-icon.sc-ion-searchbar-md{display:block}.searchbar-has-focus.sc-ion-searchbar-md-h .searchbar-cancel-button.sc-ion-searchbar-md,.searchbar-should-show-cancel.sc-ion-searchbar-md-h .searchbar-cancel-button.sc-ion-searchbar-md{display:block}.searchbar-has-focus.sc-ion-searchbar-md-h .searchbar-cancel-button.sc-ion-searchbar-md+.searchbar-search-icon.sc-ion-searchbar-md,.searchbar-should-show-cancel.sc-ion-searchbar-md-h .searchbar-cancel-button.sc-ion-searchbar-md+.searchbar-search-icon.sc-ion-searchbar-md{display:none}ion-toolbar.sc-ion-searchbar-md-h,ion-toolbar .sc-ion-searchbar-md-h{padding-left:7px;padding-right:7px;padding-top:3px;padding-bottom:3px}@supports ((-webkit-margin-start: 0) or (margin-inline-start: 0)) or (-webkit-margin-start: 0){ion-toolbar.sc-ion-searchbar-md-h,ion-toolbar .sc-ion-searchbar-md-h{padding-left:unset;padding-right:unset;-webkit-padding-start:7px;padding-inline-start:7px;-webkit-padding-end:7px;padding-inline-end:7px}}";
|
13 |
|
14 | const Searchbar = class {
|
15 | constructor(hostRef) {
|
16 | index.registerInstance(this, hostRef);
|
17 | this.ionInput = index.createEvent(this, "ionInput", 7);
|
18 | this.ionChange = index.createEvent(this, "ionChange", 7);
|
19 | this.ionCancel = index.createEvent(this, "ionCancel", 7);
|
20 | this.ionClear = index.createEvent(this, "ionClear", 7);
|
21 | this.ionBlur = index.createEvent(this, "ionBlur", 7);
|
22 | this.ionFocus = index.createEvent(this, "ionFocus", 7);
|
23 | this.ionStyle = index.createEvent(this, "ionStyle", 7);
|
24 | this.isCancelVisible = false;
|
25 | this.shouldAlignLeft = true;
|
26 | this.focused = false;
|
27 | this.noAnimate = true;
|
28 | |
29 |
|
30 |
|
31 | this.animated = false;
|
32 | |
33 |
|
34 |
|
35 | this.autocomplete = 'off';
|
36 | |
37 |
|
38 |
|
39 | this.autocorrect = 'off';
|
40 | |
41 |
|
42 |
|
43 |
|
44 | this.cancelButtonIcon = ionicGlobal.config.get('backButtonIcon', 'arrow-back-sharp');
|
45 | |
46 |
|
47 |
|
48 | this.cancelButtonText = 'Cancel';
|
49 | |
50 |
|
51 |
|
52 | this.debounce = 250;
|
53 | |
54 |
|
55 |
|
56 | this.disabled = false;
|
57 | |
58 |
|
59 |
|
60 |
|
61 |
|
62 |
|
63 |
|
64 |
|
65 |
|
66 | this.placeholder = 'Search';
|
67 | |
68 |
|
69 |
|
70 |
|
71 |
|
72 |
|
73 |
|
74 | this.showCancelButton = 'never';
|
75 | |
76 |
|
77 |
|
78 |
|
79 |
|
80 |
|
81 |
|
82 |
|
83 | this.showClearButton = 'focus';
|
84 | |
85 |
|
86 |
|
87 | this.spellcheck = false;
|
88 | |
89 |
|
90 |
|
91 | this.type = 'search';
|
92 | |
93 |
|
94 |
|
95 | this.value = '';
|
96 | |
97 |
|
98 |
|
99 | this.onClearInput = (ev, shouldFocus) => {
|
100 | this.ionClear.emit();
|
101 | if (ev) {
|
102 | ev.preventDefault();
|
103 | ev.stopPropagation();
|
104 | }
|
105 |
|
106 |
|
107 | setTimeout(() => {
|
108 | const value = this.getValue();
|
109 | if (value !== '') {
|
110 | this.value = '';
|
111 | this.ionInput.emit();
|
112 | |
113 |
|
114 |
|
115 |
|
116 |
|
117 |
|
118 | if (shouldFocus && !this.focused) {
|
119 | this.setFocus();
|
120 | }
|
121 | }
|
122 | }, 16 * 4);
|
123 | };
|
124 | |
125 |
|
126 |
|
127 |
|
128 |
|
129 | this.onCancelSearchbar = (ev) => {
|
130 | if (ev) {
|
131 | ev.preventDefault();
|
132 | ev.stopPropagation();
|
133 | }
|
134 | this.ionCancel.emit();
|
135 | this.onClearInput();
|
136 | if (this.nativeInput) {
|
137 | this.nativeInput.blur();
|
138 | }
|
139 | };
|
140 | |
141 |
|
142 |
|
143 | this.onInput = (ev) => {
|
144 | const input = ev.target;
|
145 | if (input) {
|
146 | this.value = input.value;
|
147 | }
|
148 | this.ionInput.emit(ev);
|
149 | };
|
150 | |
151 |
|
152 |
|
153 |
|
154 | this.onBlur = () => {
|
155 | this.focused = false;
|
156 | this.ionBlur.emit();
|
157 | this.positionElements();
|
158 | };
|
159 | |
160 |
|
161 |
|
162 | this.onFocus = () => {
|
163 | this.focused = true;
|
164 | this.ionFocus.emit();
|
165 | this.positionElements();
|
166 | };
|
167 | }
|
168 | debounceChanged() {
|
169 | this.ionChange = helpers.debounceEvent(this.ionChange, this.debounce);
|
170 | }
|
171 | valueChanged() {
|
172 | const inputEl = this.nativeInput;
|
173 | const value = this.getValue();
|
174 | if (inputEl && inputEl.value !== value) {
|
175 | inputEl.value = value;
|
176 | }
|
177 | this.ionChange.emit({ value });
|
178 | }
|
179 | showCancelButtonChanged() {
|
180 | requestAnimationFrame(() => {
|
181 | this.positionElements();
|
182 | index.forceUpdate(this);
|
183 | });
|
184 | }
|
185 | connectedCallback() {
|
186 | this.emitStyle();
|
187 | }
|
188 | componentDidLoad() {
|
189 | this.positionElements();
|
190 | this.debounceChanged();
|
191 | setTimeout(() => {
|
192 | this.noAnimate = false;
|
193 | }, 300);
|
194 | }
|
195 | emitStyle() {
|
196 | this.ionStyle.emit({
|
197 | 'searchbar': true
|
198 | });
|
199 | }
|
200 | |
201 |
|
202 |
|
203 |
|
204 | async setFocus() {
|
205 | if (this.nativeInput) {
|
206 | this.nativeInput.focus();
|
207 | }
|
208 | }
|
209 | |
210 |
|
211 |
|
212 | getInputElement() {
|
213 | return Promise.resolve(this.nativeInput);
|
214 | }
|
215 | |
216 |
|
217 |
|
218 |
|
219 | positionElements() {
|
220 | const value = this.getValue();
|
221 | const prevAlignLeft = this.shouldAlignLeft;
|
222 | const mode = ionicGlobal.getIonMode(this);
|
223 | const shouldAlignLeft = (!this.animated || value.trim() !== '' || !!this.focused);
|
224 | this.shouldAlignLeft = shouldAlignLeft;
|
225 | if (mode !== 'ios') {
|
226 | return;
|
227 | }
|
228 | if (prevAlignLeft !== shouldAlignLeft) {
|
229 | this.positionPlaceholder();
|
230 | }
|
231 | if (this.animated) {
|
232 | this.positionCancelButton();
|
233 | }
|
234 | }
|
235 | |
236 |
|
237 |
|
238 | positionPlaceholder() {
|
239 | const inputEl = this.nativeInput;
|
240 | if (!inputEl) {
|
241 | return;
|
242 | }
|
243 | const isRTL = document.dir === 'rtl';
|
244 | const iconEl = (this.el.shadowRoot || this.el).querySelector('.searchbar-search-icon');
|
245 | if (this.shouldAlignLeft) {
|
246 | inputEl.removeAttribute('style');
|
247 | iconEl.removeAttribute('style');
|
248 | }
|
249 | else {
|
250 |
|
251 | const doc = document;
|
252 | const tempSpan = doc.createElement('span');
|
253 | tempSpan.innerText = this.placeholder || '';
|
254 | doc.body.appendChild(tempSpan);
|
255 |
|
256 | helpers.raf(() => {
|
257 | const textWidth = tempSpan.offsetWidth;
|
258 | tempSpan.remove();
|
259 |
|
260 | const inputLeft = 'calc(50% - ' + (textWidth / 2) + 'px)';
|
261 |
|
262 | const iconLeft = 'calc(50% - ' + ((textWidth / 2) + 30) + 'px)';
|
263 |
|
264 | if (isRTL) {
|
265 | inputEl.style.paddingRight = inputLeft;
|
266 | iconEl.style.marginRight = iconLeft;
|
267 | }
|
268 | else {
|
269 | inputEl.style.paddingLeft = inputLeft;
|
270 | iconEl.style.marginLeft = iconLeft;
|
271 | }
|
272 | });
|
273 | }
|
274 | }
|
275 | |
276 |
|
277 |
|
278 | positionCancelButton() {
|
279 | const isRTL = document.dir === 'rtl';
|
280 | const cancelButton = (this.el.shadowRoot || this.el).querySelector('.searchbar-cancel-button');
|
281 | const shouldShowCancel = this.shouldShowCancelButton();
|
282 | if (cancelButton && shouldShowCancel !== this.isCancelVisible) {
|
283 | const cancelStyle = cancelButton.style;
|
284 | this.isCancelVisible = shouldShowCancel;
|
285 | if (shouldShowCancel) {
|
286 | if (isRTL) {
|
287 | cancelStyle.marginLeft = '0';
|
288 | }
|
289 | else {
|
290 | cancelStyle.marginRight = '0';
|
291 | }
|
292 | }
|
293 | else {
|
294 | const offset = cancelButton.offsetWidth;
|
295 | if (offset > 0) {
|
296 | if (isRTL) {
|
297 | cancelStyle.marginLeft = -offset + 'px';
|
298 | }
|
299 | else {
|
300 | cancelStyle.marginRight = -offset + 'px';
|
301 | }
|
302 | }
|
303 | }
|
304 | }
|
305 | }
|
306 | getValue() {
|
307 | return this.value || '';
|
308 | }
|
309 | hasValue() {
|
310 | return this.getValue() !== '';
|
311 | }
|
312 | |
313 |
|
314 |
|
315 |
|
316 |
|
317 |
|
318 | shouldShowCancelButton() {
|
319 | if ((this.showCancelButton === 'never') || (this.showCancelButton === 'focus' && !this.focused)) {
|
320 | return false;
|
321 | }
|
322 | return true;
|
323 | }
|
324 | |
325 |
|
326 |
|
327 |
|
328 |
|
329 |
|
330 | shouldShowClearButton() {
|
331 | if ((this.showClearButton === 'never') || (this.showClearButton === 'focus' && !this.focused)) {
|
332 | return false;
|
333 | }
|
334 | return true;
|
335 | }
|
336 | render() {
|
337 | const { cancelButtonText } = this;
|
338 | const animated = this.animated && ionicGlobal.config.getBoolean('animated', true);
|
339 | const mode = ionicGlobal.getIonMode(this);
|
340 | const clearIcon = this.clearIcon || (mode === 'ios' ? 'close-circle' : 'close-sharp');
|
341 | const searchIcon = this.searchIcon || (mode === 'ios' ? 'search-outline' : 'search-sharp');
|
342 | const shouldShowCancelButton = this.shouldShowCancelButton();
|
343 | const cancelButton = (this.showCancelButton !== 'never') && (index.h("button", { "aria-label": cancelButtonText, "aria-hidden": shouldShowCancelButton ? undefined : 'true', type: "button", tabIndex: mode === 'ios' && !shouldShowCancelButton ? -1 : undefined, onMouseDown: this.onCancelSearchbar, onTouchStart: this.onCancelSearchbar, class: "searchbar-cancel-button" }, index.h("div", { "aria-hidden": "true" }, mode === 'md'
|
344 | ? index.h("ion-icon", { "aria-hidden": "true", mode: mode, icon: this.cancelButtonIcon, lazy: false })
|
345 | : cancelButtonText)));
|
346 | return (index.h(index.Host, { role: "search", "aria-disabled": this.disabled ? 'true' : null, class: theme.createColorClasses(this.color, {
|
347 | [mode]: true,
|
348 | 'searchbar-animated': animated,
|
349 | 'searchbar-disabled': this.disabled,
|
350 | 'searchbar-no-animate': animated && this.noAnimate,
|
351 | 'searchbar-has-value': this.hasValue(),
|
352 | 'searchbar-left-aligned': this.shouldAlignLeft,
|
353 | 'searchbar-has-focus': this.focused,
|
354 | 'searchbar-should-show-clear': this.shouldShowClearButton(),
|
355 | 'searchbar-should-show-cancel': this.shouldShowCancelButton()
|
356 | }) }, index.h("div", { class: "searchbar-input-container" }, index.h("input", { "aria-label": "search text", disabled: this.disabled, ref: el => this.nativeInput = el, class: "searchbar-input", inputMode: this.inputmode, enterKeyHint: this.enterkeyhint, onInput: this.onInput, onBlur: this.onBlur, onFocus: this.onFocus, placeholder: this.placeholder, type: this.type, value: this.getValue(), autoComplete: this.autocomplete, autoCorrect: this.autocorrect, spellcheck: this.spellcheck }), mode === 'md' && cancelButton, index.h("ion-icon", { "aria-hidden": "true", mode: mode, icon: searchIcon, lazy: false, class: "searchbar-search-icon" }), index.h("button", { "aria-label": "reset", type: "button", "no-blur": true, class: "searchbar-clear-button", onMouseDown: ev => this.onClearInput(ev, true), onTouchStart: ev => this.onClearInput(ev, true) }, index.h("ion-icon", { "aria-hidden": "true", mode: mode, icon: clearIcon, lazy: false, class: "searchbar-clear-icon" }))), mode === 'ios' && cancelButton));
|
357 | }
|
358 | get el() { return index.getElement(this); }
|
359 | static get watchers() { return {
|
360 | "debounce": ["debounceChanged"],
|
361 | "value": ["valueChanged"],
|
362 | "showCancelButton": ["showCancelButtonChanged"]
|
363 | }; }
|
364 | };
|
365 | Searchbar.style = {
|
366 | ios: searchbarIosCss,
|
367 | md: searchbarMdCss
|
368 | };
|
369 |
|
370 | exports.ion_searchbar = Searchbar;
|