@sparkle-learning/core 0.0.54 → 0.0.56

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (110) hide show
  1. package/dist/cjs/{PrivateRoute-e2047db2.js → PrivateRoute-f97245ce.js} +2 -2
  2. package/dist/cjs/{appdata.service-d28cf2d6.js → appdata.service-c8d71e05.js} +1 -1
  3. package/dist/cjs/assignment.service-690fb59c.js +19 -0
  4. package/dist/cjs/{facilitator.service-0b9f6ac7.js → facilitator.service-ff0e1659.js} +1 -1
  5. package/dist/cjs/{feed.service-6df9382f.js → feed.service-8eca4de6.js} +1 -1
  6. package/dist/cjs/header-mobile-collapse_61.cjs.entry.js +9 -9
  7. package/dist/cjs/{httpService-d8a5b474.js → httpService-d2e7bf8f.js} +1 -1
  8. package/dist/cjs/index.cjs.js +3 -3
  9. package/dist/cjs/{ion-action-sheet_4.cjs.entry.js → ion-action-sheet_7.cjs.entry.js} +728 -0
  10. package/dist/cjs/loader.cjs.js +1 -1
  11. package/dist/cjs/{media.service-2bc73d37.js → media.service-8a1b9bc5.js} +1 -1
  12. package/dist/cjs/{signalR.service-0d5da1d3.js → signalR.service-bd6b42f9.js} +1 -1
  13. package/dist/cjs/sparkle-assignment.cjs.entry.js +90 -5
  14. package/dist/cjs/sparkle-core.cjs.js +1 -1
  15. package/dist/cjs/sparkle-discussion-questions_2.cjs.entry.js +2 -2
  16. package/dist/cjs/sparkle-facilitator-notes-form.cjs.entry.js +3 -3
  17. package/dist/cjs/sparkle-feed-post.cjs.entry.js +116 -0
  18. package/dist/cjs/sparkle-feedback.cjs.entry.js +3 -3
  19. package/dist/cjs/sparkle-file-upload.cjs.entry.js +53 -0
  20. package/dist/cjs/sparkle-goal-form.cjs.entry.js +4 -4
  21. package/dist/cjs/sparkle-input.cjs.entry.js +56 -0
  22. package/dist/cjs/sparkle-video-player.cjs.entry.js +22 -0
  23. package/dist/cjs/{student.service-d8ec2551.js → student.service-7e5385be.js} +1 -1
  24. package/dist/cjs/{token.service-bfb0089b.js → token.service-7a41953d.js} +11 -0
  25. package/dist/collection/collection-manifest.json +3 -0
  26. package/dist/collection/components/sparkle-assignment/sparkle-assignment.css +27 -0
  27. package/dist/collection/components/sparkle-assignment/sparkle-assignment.js +141 -7
  28. package/dist/collection/components/sparkle-feed-post/sparkle-feed-post.js +2 -10
  29. package/dist/collection/components/sparkle-file-upload/sparkle-file-upload.css +0 -0
  30. package/dist/collection/components/sparkle-file-upload/sparkle-file-upload.js +105 -0
  31. package/dist/collection/components/sparkle-input/sparkle-input.css +0 -0
  32. package/dist/collection/components/sparkle-input/sparkle-input.js +212 -0
  33. package/dist/collection/components/sparkle-video-player/sparkle-video-player.css +0 -0
  34. package/dist/collection/components/sparkle-video-player/sparkle-video-player.js +92 -0
  35. package/dist/collection/services/token.service.js +11 -0
  36. package/dist/esm/{PrivateRoute-c6e80d5d.js → PrivateRoute-90ac95b8.js} +2 -2
  37. package/dist/esm/{appdata.service-d1058e00.js → appdata.service-2e84e167.js} +1 -1
  38. package/dist/esm/assignment.service-8d31f141.js +17 -0
  39. package/dist/esm/{facilitator.service-53e05a01.js → facilitator.service-18c47bdf.js} +1 -1
  40. package/dist/esm/{feed.service-8385ad7a.js → feed.service-b4f3cae4.js} +1 -1
  41. package/dist/esm/header-mobile-collapse_61.entry.js +10 -10
  42. package/dist/esm/{httpService-db476835.js → httpService-7986aeed.js} +2 -2
  43. package/dist/esm/index.js +4 -4
  44. package/dist/esm/{ion-action-sheet_4.entry.js → ion-action-sheet_7.entry.js} +729 -4
  45. package/dist/esm/ion-loading.entry.js +1 -1
  46. package/dist/esm/ion-menu.entry.js +1 -1
  47. package/dist/esm/ion-modal.entry.js +1 -1
  48. package/dist/esm/ion-picker.entry.js +1 -1
  49. package/dist/esm/ion-toast.entry.js +1 -1
  50. package/dist/esm/loader.js +1 -1
  51. package/dist/esm/{media.service-b68cbfff.js → media.service-6e90bc41.js} +1 -1
  52. package/dist/esm/{overlays-3b4dca92.js → overlays-4233a39d.js} +1 -1
  53. package/dist/esm/{signalR.service-4a2d5a92.js → signalR.service-c33fba50.js} +1 -1
  54. package/dist/esm/sparkle-assignment.entry.js +91 -6
  55. package/dist/esm/sparkle-core.js +1 -1
  56. package/dist/esm/sparkle-discussion-questions_2.entry.js +2 -2
  57. package/dist/esm/sparkle-facilitator-notes-form.entry.js +4 -4
  58. package/dist/esm/sparkle-feed-post.entry.js +112 -0
  59. package/dist/esm/sparkle-feedback.entry.js +4 -4
  60. package/dist/esm/sparkle-file-upload.entry.js +49 -0
  61. package/dist/esm/sparkle-goal-form.entry.js +5 -5
  62. package/dist/esm/sparkle-input.entry.js +52 -0
  63. package/dist/esm/sparkle-video-player.entry.js +18 -0
  64. package/dist/esm/{student.service-6457aaa0.js → student.service-08af124f.js} +1 -1
  65. package/dist/esm/{token.service-20f1a256.js → token.service-71a5d33f.js} +11 -0
  66. package/dist/sparkle-core/index.esm.js +1 -1
  67. package/dist/sparkle-core/p-08420531.entry.js +1 -0
  68. package/dist/sparkle-core/p-08cca80d.entry.js +1 -0
  69. package/dist/sparkle-core/p-0e8e539f.entry.js +1 -0
  70. package/dist/sparkle-core/{p-11ac00b0.js → p-1adc98f6.js} +1 -1
  71. package/dist/sparkle-core/{p-71720d6e.entry.js → p-38c842d5.entry.js} +1 -1
  72. package/dist/sparkle-core/{p-38f707fb.js → p-39a31e43.js} +1 -1
  73. package/dist/sparkle-core/{p-6a1fc0af.entry.js → p-3daf2915.entry.js} +1 -1
  74. package/dist/sparkle-core/{p-dcff298d.entry.js → p-42ed7d5f.entry.js} +1 -1
  75. package/dist/sparkle-core/{p-6fab3a4b.js → p-4b4a8703.js} +1 -1
  76. package/dist/sparkle-core/{p-98f7780c.entry.js → p-4d1cfcbe.entry.js} +1 -1
  77. package/dist/sparkle-core/p-4fba3e4c.js +1 -0
  78. package/dist/sparkle-core/{p-54dd894f.entry.js → p-6bde0192.entry.js} +1 -1
  79. package/dist/sparkle-core/{p-6faa194c.entry.js → p-6d2f4093.entry.js} +1 -1
  80. package/dist/sparkle-core/{p-ed9de327.js → p-7dae0f0e.js} +1 -1
  81. package/dist/sparkle-core/p-973fe404.entry.js +22 -0
  82. package/dist/sparkle-core/{p-967a2ed7.js → p-b06e2bef.js} +1 -1
  83. package/dist/sparkle-core/{p-e863bf1d.entry.js → p-b6fec622.entry.js} +1 -1
  84. package/dist/sparkle-core/{p-630a4fa0.js → p-b8d71ff4.js} +1 -1
  85. package/dist/sparkle-core/p-c7e21070.entry.js +1 -0
  86. package/dist/sparkle-core/{p-17b6b07e.js → p-c9f753a4.js} +1 -1
  87. package/dist/sparkle-core/{p-d51f30ca.js → p-da391f3f.js} +1 -1
  88. package/dist/sparkle-core/{p-38fa5987.js → p-e0cad1bb.js} +1 -1
  89. package/dist/sparkle-core/{p-ce4b22f7.entry.js → p-f196c124.entry.js} +1 -1
  90. package/dist/sparkle-core/p-f47fe1fe.entry.js +1 -0
  91. package/dist/sparkle-core/{p-e50c8b04.entry.js → p-f714f77a.entry.js} +1 -1
  92. package/dist/sparkle-core/{p-377b04c2.entry.js → p-ff080f82.entry.js} +1 -1
  93. package/dist/sparkle-core/{p-2ff67662.js → p-ff7a8a71.js} +1 -1
  94. package/dist/sparkle-core/sparkle-core.esm.js +1 -1
  95. package/dist/types/components/sparkle-assignment/sparkle-assignment.d.ts +11 -1
  96. package/dist/types/components/sparkle-feed-post/sparkle-feed-post.d.ts +1 -1
  97. package/dist/types/components/sparkle-file-upload/sparkle-file-upload.d.ts +15 -0
  98. package/dist/types/components/sparkle-input/sparkle-input.d.ts +23 -0
  99. package/dist/types/components/sparkle-video-player/sparkle-video-player.d.ts +7 -0
  100. package/dist/types/components.d.ts +83 -0
  101. package/dist/types/services/token.service.d.ts +1 -0
  102. package/package.json +1 -1
  103. package/dist/cjs/ion-select_3.cjs.entry.js +0 -627
  104. package/dist/cjs/ion-textarea.cjs.entry.js +0 -248
  105. package/dist/esm/ion-select_3.entry.js +0 -621
  106. package/dist/esm/ion-textarea.entry.js +0 -244
  107. package/dist/sparkle-core/p-0f1c5899.entry.js +0 -18
  108. package/dist/sparkle-core/p-33a7151d.entry.js +0 -1
  109. package/dist/sparkle-core/p-641bfc92.entry.js +0 -1
  110. package/dist/sparkle-core/p-ca907214.entry.js +0 -4
@@ -2,12 +2,12 @@ import { w as writeTask, r as registerInstance, i as createEvent, j as readTask,
2
2
  import { g as getIonMode, a as isPlatform } from './ionic-global-4903e23e.js';
3
3
  import { c as hapticSelectionEnd, a as hapticSelectionStart, b as hapticSelectionChanged } from './haptic-522f76f2.js';
4
4
  import { createGesture } from './index-21661af2.js';
5
- import { B as BACKDROP, i as isCancel, b as present, p as prepareOverlay, d as dismiss, e as eventMethod, s as safeCall, j as focusFirstDescendant } from './overlays-3b4dca92.js';
6
- import { g as getClassMap } from './theme-7ef00c83.js';
5
+ import { B as BACKDROP, i as isCancel, b as present, p as prepareOverlay, d as dismiss, e as eventMethod, s as safeCall, f as focusFirstDescendant, h as popoverController, j as actionSheetController, a as alertController } from './overlays-4233a39d.js';
6
+ import { g as getClassMap, h as hostContext, c as createColorClasses } from './theme-7ef00c83.js';
7
7
  import { c as createAnimation } from './animation-12377cb3.js';
8
8
  import { s as sanitizeDOMString } from './index-be6112f8.js';
9
9
  import { C as CoreDelegate, a as attachComponent, d as detachComponent } from './framework-delegate-3e634a5c.js';
10
- import { l as raf, g as getElementRoot, a as addEventListener } from './helpers-bf0e23d6.js';
10
+ import { l as raf, g as getElementRoot, a as addEventListener, f as focusElement, k as findItemLabel, b as getAriaLabel, d as renderHiddenInput, e as debounceEvent, i as inheritAriaAttributes, j as inheritAttributes } from './helpers-bf0e23d6.js';
11
11
  import { d as deepReady } from './index-2b84cad2.js';
12
12
  import './gesture-controller-7be18351.js';
13
13
  import './hardware-back-button-fa04d6e9.js';
@@ -2109,6 +2109,493 @@ Popover.style = {
2109
2109
  md: popoverMdCss
2110
2110
  };
2111
2111
 
2112
+ /*!
2113
+ * (C) Ionic http://ionicframework.com - MIT License
2114
+ */
2115
+ const watchForOptions = (containerEl, tagName, onChange) => {
2116
+ if (typeof MutationObserver === 'undefined') {
2117
+ return;
2118
+ }
2119
+ const mutation = new MutationObserver((mutationList) => {
2120
+ onChange(getSelectedOption(mutationList, tagName));
2121
+ });
2122
+ mutation.observe(containerEl, {
2123
+ childList: true,
2124
+ subtree: true,
2125
+ });
2126
+ return mutation;
2127
+ };
2128
+ const getSelectedOption = (mutationList, tagName) => {
2129
+ let newOption;
2130
+ mutationList.forEach((mut) => {
2131
+ // eslint-disable-next-line @typescript-eslint/prefer-for-of
2132
+ for (let i = 0; i < mut.addedNodes.length; i++) {
2133
+ newOption = findCheckedOption(mut.addedNodes[i], tagName) || newOption;
2134
+ }
2135
+ });
2136
+ return newOption;
2137
+ };
2138
+ const findCheckedOption = (el, tagName) => {
2139
+ if (el.nodeType !== 1) {
2140
+ return undefined;
2141
+ }
2142
+ const options = el.tagName === tagName.toUpperCase() ? [el] : Array.from(el.querySelectorAll(tagName));
2143
+ return options.find((o) => o.value === el.value);
2144
+ };
2145
+
2146
+ const selectIosCss = ":host{--placeholder-color:currentColor;--placeholder-opacity:0.33;padding-left:var(--padding-start);padding-right:var(--padding-end);padding-top:var(--padding-top);padding-bottom:var(--padding-bottom);display:flex;position:relative;align-items:center;font-family:var(--ion-font-family, inherit);overflow:hidden;z-index:2}@supports (margin-inline-start: 0) or (-webkit-margin-start: 0){:host{padding-left:unset;padding-right:unset;-webkit-padding-start:var(--padding-start);padding-inline-start:var(--padding-start);-webkit-padding-end:var(--padding-end);padding-inline-end:var(--padding-end)}}:host(.in-item){position:static;max-width:45%}:host(.select-disabled){opacity:0.4;pointer-events:none}:host(.ion-focused) button{border:2px solid #5e9ed6}.select-placeholder{color:var(--placeholder-color);opacity:var(--placeholder-opacity)}label{left:0;top:0;margin-left:0;margin-right:0;margin-top:0;margin-bottom:0;position:absolute;width:100%;height:100%;border:0;background:transparent;cursor:pointer;appearance:none;outline:none;display:flex;align-items:center;opacity:0}[dir=rtl] label,:host-context([dir=rtl]) label{left:unset;right:unset;right:0}label::-moz-focus-inner{border:0}button{position:absolute;top:0;left:0;right:0;bottom:0;width:100%;height:100%;margin:0;padding:0;border:0;outline:0;clip:rect(0 0 0 0);opacity:0;overflow:hidden;-webkit-appearance:none;-moz-appearance:none}.select-icon{position:relative}.select-text{flex:1;min-width:16px;font-size:inherit;text-overflow:ellipsis;white-space:nowrap;overflow:hidden}.select-icon-inner{left:5px;top:50%;margin-top:-2px;position:absolute;width:0;height:0;border-top:5px solid;border-right:5px solid transparent;border-left:5px solid transparent;color:currentColor;pointer-events:none}[dir=rtl] .select-icon-inner,:host-context([dir=rtl]) .select-icon-inner{left:unset;right:unset;right:5px}:host{--padding-top:10px;--padding-end:10px;--padding-bottom:10px;--padding-start:20px}.select-icon{width:12px;height:18px;opacity:0.33}";
2147
+
2148
+ const selectMdCss = ":host{--placeholder-color:currentColor;--placeholder-opacity:0.33;padding-left:var(--padding-start);padding-right:var(--padding-end);padding-top:var(--padding-top);padding-bottom:var(--padding-bottom);display:flex;position:relative;align-items:center;font-family:var(--ion-font-family, inherit);overflow:hidden;z-index:2}@supports (margin-inline-start: 0) or (-webkit-margin-start: 0){:host{padding-left:unset;padding-right:unset;-webkit-padding-start:var(--padding-start);padding-inline-start:var(--padding-start);-webkit-padding-end:var(--padding-end);padding-inline-end:var(--padding-end)}}:host(.in-item){position:static;max-width:45%}:host(.select-disabled){opacity:0.4;pointer-events:none}:host(.ion-focused) button{border:2px solid #5e9ed6}.select-placeholder{color:var(--placeholder-color);opacity:var(--placeholder-opacity)}label{left:0;top:0;margin-left:0;margin-right:0;margin-top:0;margin-bottom:0;position:absolute;width:100%;height:100%;border:0;background:transparent;cursor:pointer;appearance:none;outline:none;display:flex;align-items:center;opacity:0}[dir=rtl] label,:host-context([dir=rtl]) label{left:unset;right:unset;right:0}label::-moz-focus-inner{border:0}button{position:absolute;top:0;left:0;right:0;bottom:0;width:100%;height:100%;margin:0;padding:0;border:0;outline:0;clip:rect(0 0 0 0);opacity:0;overflow:hidden;-webkit-appearance:none;-moz-appearance:none}.select-icon{position:relative}.select-text{flex:1;min-width:16px;font-size:inherit;text-overflow:ellipsis;white-space:nowrap;overflow:hidden}.select-icon-inner{left:5px;top:50%;margin-top:-2px;position:absolute;width:0;height:0;border-top:5px solid;border-right:5px solid transparent;border-left:5px solid transparent;color:currentColor;pointer-events:none}[dir=rtl] .select-icon-inner,:host-context([dir=rtl]) .select-icon-inner{left:unset;right:unset;right:5px}:host{--padding-top:10px;--padding-end:0;--padding-bottom:10px;--padding-start:16px}.select-icon{width:19px;height:19px;transition:transform 0.15s cubic-bezier(0.4, 0, 0.2, 1);opacity:0.55}:host-context(.item-label-stacked) .select-icon,:host-context(.item-label-floating:not(.item-fill-outline)) .select-icon,:host-context(.item-label-floating.item-fill-outline){transform:translate3d(0, -9px, 0)}:host-context(.item-has-focus) .select-icon{transform:rotate(180deg)}:host-context(.item-has-focus.item-label-stacked) .select-icon,:host-context(.item-has-focus.item-label-floating:not(.item-fill-outline)) .select-icon{transform:translate3d(0, -9px, 0) rotate(180deg)}:host-context(ion-item.ion-focused) .select-icon,:host-context(.item-has-focus) .select-icon{color:var(--highlight-color-focused);opacity:1}";
2149
+
2150
+ const Select = class {
2151
+ constructor(hostRef) {
2152
+ registerInstance(this, hostRef);
2153
+ this.ionChange = createEvent(this, "ionChange", 7);
2154
+ this.ionCancel = createEvent(this, "ionCancel", 7);
2155
+ this.ionDismiss = createEvent(this, "ionDismiss", 7);
2156
+ this.ionFocus = createEvent(this, "ionFocus", 7);
2157
+ this.ionBlur = createEvent(this, "ionBlur", 7);
2158
+ this.ionStyle = createEvent(this, "ionStyle", 7);
2159
+ this.inputId = `ion-sel-${selectIds++}`;
2160
+ this.didInit = false;
2161
+ this.isExpanded = false;
2162
+ /**
2163
+ * If `true`, the user cannot interact with the select.
2164
+ */
2165
+ this.disabled = false;
2166
+ /**
2167
+ * The text to display on the cancel button.
2168
+ */
2169
+ this.cancelText = 'Cancel';
2170
+ /**
2171
+ * The text to display on the ok button.
2172
+ */
2173
+ this.okText = 'OK';
2174
+ /**
2175
+ * The name of the control, which is submitted with the form data.
2176
+ */
2177
+ this.name = this.inputId;
2178
+ /**
2179
+ * If `true`, the select can accept multiple values.
2180
+ */
2181
+ this.multiple = false;
2182
+ /**
2183
+ * The interface the select should use: `action-sheet`, `popover` or `alert`.
2184
+ */
2185
+ this.interface = 'alert';
2186
+ /**
2187
+ * Any additional options that the `alert`, `action-sheet` or `popover` interface
2188
+ * can take. See the [ion-alert docs](./alert), the
2189
+ * [ion-action-sheet docs](./action-sheet) and the
2190
+ * [ion-popover docs](./popover) for the
2191
+ * create options for each interface.
2192
+ *
2193
+ * Note: `interfaceOptions` will not override `inputs` or `buttons` with the `alert` interface.
2194
+ */
2195
+ this.interfaceOptions = {};
2196
+ this.onClick = (ev) => {
2197
+ this.setFocus();
2198
+ this.open(ev);
2199
+ };
2200
+ this.onFocus = () => {
2201
+ this.ionFocus.emit();
2202
+ };
2203
+ this.onBlur = () => {
2204
+ this.ionBlur.emit();
2205
+ };
2206
+ }
2207
+ styleChanged() {
2208
+ this.emitStyle();
2209
+ }
2210
+ valueChanged() {
2211
+ this.emitStyle();
2212
+ // TODO: FW-1160 - Remove the `didInit` property when ionChange behavior is changed in v7.
2213
+ if (this.didInit) {
2214
+ this.ionChange.emit({
2215
+ value: this.value,
2216
+ });
2217
+ }
2218
+ }
2219
+ async connectedCallback() {
2220
+ this.updateOverlayOptions();
2221
+ this.emitStyle();
2222
+ this.mutationO = watchForOptions(this.el, 'ion-select-option', async () => {
2223
+ this.updateOverlayOptions();
2224
+ });
2225
+ }
2226
+ disconnectedCallback() {
2227
+ if (this.mutationO) {
2228
+ this.mutationO.disconnect();
2229
+ this.mutationO = undefined;
2230
+ }
2231
+ }
2232
+ componentDidLoad() {
2233
+ this.didInit = true;
2234
+ }
2235
+ /**
2236
+ * Open the select overlay. The overlay is either an alert, action sheet, or popover,
2237
+ * depending on the `interface` property on the `ion-select`.
2238
+ *
2239
+ * @param event The user interface event that called the open.
2240
+ */
2241
+ async open(event) {
2242
+ if (this.disabled || this.isExpanded) {
2243
+ return undefined;
2244
+ }
2245
+ this.isExpanded = true;
2246
+ const overlay = (this.overlay = await this.createOverlay(event));
2247
+ overlay.onDidDismiss().then(() => {
2248
+ this.overlay = undefined;
2249
+ this.isExpanded = false;
2250
+ this.ionDismiss.emit();
2251
+ this.setFocus();
2252
+ });
2253
+ await overlay.present();
2254
+ // focus selected option for popovers
2255
+ if (this.interface === 'popover') {
2256
+ let indexOfSelected = this.childOpts.map((o) => o.value).indexOf(this.value);
2257
+ indexOfSelected = indexOfSelected > -1 ? indexOfSelected : 0; // default to first option if nothing selected
2258
+ const selectedEl = overlay.querySelector(`.select-interface-option:nth-child(${indexOfSelected + 1})`);
2259
+ if (selectedEl) {
2260
+ focusElement(selectedEl);
2261
+ }
2262
+ }
2263
+ return overlay;
2264
+ }
2265
+ createOverlay(ev) {
2266
+ let selectInterface = this.interface;
2267
+ if (selectInterface === 'action-sheet' && this.multiple) {
2268
+ console.warn(`Select interface cannot be "${selectInterface}" with a multi-value select. Using the "alert" interface instead.`);
2269
+ selectInterface = 'alert';
2270
+ }
2271
+ if (selectInterface === 'popover' && !ev) {
2272
+ console.warn(`Select interface cannot be a "${selectInterface}" without passing an event. Using the "alert" interface instead.`);
2273
+ selectInterface = 'alert';
2274
+ }
2275
+ if (selectInterface === 'action-sheet') {
2276
+ return this.openActionSheet();
2277
+ }
2278
+ if (selectInterface === 'popover') {
2279
+ return this.openPopover(ev);
2280
+ }
2281
+ return this.openAlert();
2282
+ }
2283
+ updateOverlayOptions() {
2284
+ const overlay = this.overlay;
2285
+ if (!overlay) {
2286
+ return;
2287
+ }
2288
+ const childOpts = this.childOpts;
2289
+ const value = this.value;
2290
+ switch (this.interface) {
2291
+ case 'action-sheet':
2292
+ overlay.buttons = this.createActionSheetButtons(childOpts, value);
2293
+ break;
2294
+ case 'popover':
2295
+ const popover = overlay.querySelector('ion-select-popover');
2296
+ if (popover) {
2297
+ popover.options = this.createPopoverOptions(childOpts, value);
2298
+ }
2299
+ break;
2300
+ case 'alert':
2301
+ const inputType = this.multiple ? 'checkbox' : 'radio';
2302
+ overlay.inputs = this.createAlertInputs(childOpts, inputType, value);
2303
+ break;
2304
+ }
2305
+ }
2306
+ createActionSheetButtons(data, selectValue) {
2307
+ const actionSheetButtons = data.map((option) => {
2308
+ const value = getOptionValue(option);
2309
+ // Remove hydrated before copying over classes
2310
+ const copyClasses = Array.from(option.classList)
2311
+ .filter((cls) => cls !== 'hydrated')
2312
+ .join(' ');
2313
+ const optClass = `${OPTION_CLASS} ${copyClasses}`;
2314
+ return {
2315
+ role: isOptionSelected(selectValue, value, this.compareWith) ? 'selected' : '',
2316
+ text: option.textContent,
2317
+ cssClass: optClass,
2318
+ handler: () => {
2319
+ this.value = value;
2320
+ },
2321
+ };
2322
+ });
2323
+ // Add "cancel" button
2324
+ actionSheetButtons.push({
2325
+ text: this.cancelText,
2326
+ role: 'cancel',
2327
+ handler: () => {
2328
+ this.ionCancel.emit();
2329
+ },
2330
+ });
2331
+ return actionSheetButtons;
2332
+ }
2333
+ createAlertInputs(data, inputType, selectValue) {
2334
+ const alertInputs = data.map((option) => {
2335
+ const value = getOptionValue(option);
2336
+ // Remove hydrated before copying over classes
2337
+ const copyClasses = Array.from(option.classList)
2338
+ .filter((cls) => cls !== 'hydrated')
2339
+ .join(' ');
2340
+ const optClass = `${OPTION_CLASS} ${copyClasses}`;
2341
+ return {
2342
+ type: inputType,
2343
+ cssClass: optClass,
2344
+ label: option.textContent || '',
2345
+ value,
2346
+ checked: isOptionSelected(selectValue, value, this.compareWith),
2347
+ disabled: option.disabled,
2348
+ };
2349
+ });
2350
+ return alertInputs;
2351
+ }
2352
+ createPopoverOptions(data, selectValue) {
2353
+ const popoverOptions = data.map((option) => {
2354
+ const value = getOptionValue(option);
2355
+ // Remove hydrated before copying over classes
2356
+ const copyClasses = Array.from(option.classList)
2357
+ .filter((cls) => cls !== 'hydrated')
2358
+ .join(' ');
2359
+ const optClass = `${OPTION_CLASS} ${copyClasses}`;
2360
+ return {
2361
+ text: option.textContent || '',
2362
+ cssClass: optClass,
2363
+ value,
2364
+ checked: isOptionSelected(selectValue, value, this.compareWith),
2365
+ disabled: option.disabled,
2366
+ handler: (selected) => {
2367
+ this.value = selected;
2368
+ if (!this.multiple) {
2369
+ this.close();
2370
+ }
2371
+ },
2372
+ };
2373
+ });
2374
+ return popoverOptions;
2375
+ }
2376
+ async openPopover(ev) {
2377
+ const interfaceOptions = this.interfaceOptions;
2378
+ const mode = getIonMode(this);
2379
+ const showBackdrop = mode === 'md' ? false : true;
2380
+ const multiple = this.multiple;
2381
+ const value = this.value;
2382
+ let event = ev;
2383
+ let size = 'auto';
2384
+ const item = this.el.closest('ion-item');
2385
+ // If the select is inside of an item containing a floating
2386
+ // or stacked label then the popover should take up the
2387
+ // full width of the item when it presents
2388
+ if (item && (item.classList.contains('item-label-floating') || item.classList.contains('item-label-stacked'))) {
2389
+ event = Object.assign(Object.assign({}, ev), { detail: {
2390
+ ionShadowTarget: item,
2391
+ } });
2392
+ size = 'cover';
2393
+ }
2394
+ const popoverOpts = Object.assign(Object.assign({ mode,
2395
+ event, alignment: 'center', size,
2396
+ showBackdrop }, interfaceOptions), { component: 'ion-select-popover', cssClass: ['select-popover', interfaceOptions.cssClass], componentProps: {
2397
+ header: interfaceOptions.header,
2398
+ subHeader: interfaceOptions.subHeader,
2399
+ message: interfaceOptions.message,
2400
+ multiple,
2401
+ value,
2402
+ options: this.createPopoverOptions(this.childOpts, value),
2403
+ } });
2404
+ return popoverController.create(popoverOpts);
2405
+ }
2406
+ async openActionSheet() {
2407
+ const mode = getIonMode(this);
2408
+ const interfaceOptions = this.interfaceOptions;
2409
+ const actionSheetOpts = Object.assign(Object.assign({ mode }, interfaceOptions), { buttons: this.createActionSheetButtons(this.childOpts, this.value), cssClass: ['select-action-sheet', interfaceOptions.cssClass] });
2410
+ return actionSheetController.create(actionSheetOpts);
2411
+ }
2412
+ async openAlert() {
2413
+ const label = this.getLabel();
2414
+ const labelText = label ? label.textContent : null;
2415
+ const interfaceOptions = this.interfaceOptions;
2416
+ const inputType = this.multiple ? 'checkbox' : 'radio';
2417
+ const mode = getIonMode(this);
2418
+ const alertOpts = Object.assign(Object.assign({ mode }, interfaceOptions), { header: interfaceOptions.header ? interfaceOptions.header : labelText, inputs: this.createAlertInputs(this.childOpts, inputType, this.value), buttons: [
2419
+ {
2420
+ text: this.cancelText,
2421
+ role: 'cancel',
2422
+ handler: () => {
2423
+ this.ionCancel.emit();
2424
+ },
2425
+ },
2426
+ {
2427
+ text: this.okText,
2428
+ handler: (selectedValues) => {
2429
+ this.value = selectedValues;
2430
+ },
2431
+ },
2432
+ ], cssClass: [
2433
+ 'select-alert',
2434
+ interfaceOptions.cssClass,
2435
+ this.multiple ? 'multiple-select-alert' : 'single-select-alert',
2436
+ ] });
2437
+ return alertController.create(alertOpts);
2438
+ }
2439
+ /**
2440
+ * Close the select interface.
2441
+ */
2442
+ close() {
2443
+ // TODO check !this.overlay || !this.isFocus()
2444
+ if (!this.overlay) {
2445
+ return Promise.resolve(false);
2446
+ }
2447
+ return this.overlay.dismiss();
2448
+ }
2449
+ getLabel() {
2450
+ return findItemLabel(this.el);
2451
+ }
2452
+ hasValue() {
2453
+ return this.getText() !== '';
2454
+ }
2455
+ get childOpts() {
2456
+ return Array.from(this.el.querySelectorAll('ion-select-option'));
2457
+ }
2458
+ getText() {
2459
+ const selectedText = this.selectedText;
2460
+ if (selectedText != null && selectedText !== '') {
2461
+ return selectedText;
2462
+ }
2463
+ return generateText(this.childOpts, this.value, this.compareWith);
2464
+ }
2465
+ setFocus() {
2466
+ if (this.focusEl) {
2467
+ this.focusEl.focus();
2468
+ }
2469
+ }
2470
+ emitStyle() {
2471
+ this.ionStyle.emit({
2472
+ interactive: true,
2473
+ 'interactive-disabled': this.disabled,
2474
+ select: true,
2475
+ 'select-disabled': this.disabled,
2476
+ 'has-placeholder': this.placeholder !== undefined,
2477
+ 'has-value': this.hasValue(),
2478
+ 'has-focus': this.isExpanded,
2479
+ });
2480
+ }
2481
+ render() {
2482
+ const { disabled, el, inputId, isExpanded, name, placeholder, value } = this;
2483
+ const mode = getIonMode(this);
2484
+ const { labelText, labelId } = getAriaLabel(el, inputId);
2485
+ renderHiddenInput(true, el, name, parseValue(value), disabled);
2486
+ const displayValue = this.getText();
2487
+ let addPlaceholderClass = false;
2488
+ let selectText = displayValue;
2489
+ if (selectText === '' && placeholder !== undefined) {
2490
+ selectText = placeholder;
2491
+ addPlaceholderClass = true;
2492
+ }
2493
+ const selectTextClasses = {
2494
+ 'select-text': true,
2495
+ 'select-placeholder': addPlaceholderClass,
2496
+ };
2497
+ const textPart = addPlaceholderClass ? 'placeholder' : 'text';
2498
+ // If there is a label then we need to concatenate it with the
2499
+ // current value (or placeholder) and a comma so it separates
2500
+ // nicely when the screen reader announces it, otherwise just
2501
+ // announce the value / placeholder
2502
+ const displayLabel = labelText !== undefined ? (selectText !== '' ? `${selectText}, ${labelText}` : labelText) : selectText;
2503
+ return (h(Host, { onClick: this.onClick, role: "button", "aria-haspopup": "listbox", "aria-disabled": disabled ? 'true' : null, "aria-label": displayLabel, class: {
2504
+ [mode]: true,
2505
+ 'in-item': hostContext('ion-item', el),
2506
+ 'select-disabled': disabled,
2507
+ 'select-expanded': isExpanded,
2508
+ } }, h("div", { "aria-hidden": "true", class: selectTextClasses, part: textPart }, selectText), h("div", { class: "select-icon", role: "presentation", part: "icon" }, h("div", { class: "select-icon-inner" })), h("label", { id: labelId }, displayLabel), h("button", { type: "button", disabled: disabled, id: inputId, "aria-labelledby": labelId, "aria-haspopup": "listbox", "aria-expanded": `${isExpanded}`, onFocus: this.onFocus, onBlur: this.onBlur, ref: (focusEl) => (this.focusEl = focusEl) })));
2509
+ }
2510
+ get el() { return getElement(this); }
2511
+ static get watchers() { return {
2512
+ "disabled": ["styleChanged"],
2513
+ "placeholder": ["styleChanged"],
2514
+ "isExpanded": ["styleChanged"],
2515
+ "value": ["valueChanged"]
2516
+ }; }
2517
+ };
2518
+ const isOptionSelected = (currentValue, compareValue, compareWith) => {
2519
+ if (currentValue === undefined) {
2520
+ return false;
2521
+ }
2522
+ if (Array.isArray(currentValue)) {
2523
+ return currentValue.some((val) => compareOptions(val, compareValue, compareWith));
2524
+ }
2525
+ else {
2526
+ return compareOptions(currentValue, compareValue, compareWith);
2527
+ }
2528
+ };
2529
+ const getOptionValue = (el) => {
2530
+ const value = el.value;
2531
+ return value === undefined ? el.textContent || '' : value;
2532
+ };
2533
+ const parseValue = (value) => {
2534
+ if (value == null) {
2535
+ return undefined;
2536
+ }
2537
+ if (Array.isArray(value)) {
2538
+ return value.join(',');
2539
+ }
2540
+ return value.toString();
2541
+ };
2542
+ const compareOptions = (currentValue, compareValue, compareWith) => {
2543
+ if (typeof compareWith === 'function') {
2544
+ return compareWith(currentValue, compareValue);
2545
+ }
2546
+ else if (typeof compareWith === 'string') {
2547
+ return currentValue[compareWith] === compareValue[compareWith];
2548
+ }
2549
+ else {
2550
+ return Array.isArray(compareValue) ? compareValue.includes(currentValue) : currentValue === compareValue;
2551
+ }
2552
+ };
2553
+ const generateText = (opts, value, compareWith) => {
2554
+ if (value === undefined) {
2555
+ return '';
2556
+ }
2557
+ if (Array.isArray(value)) {
2558
+ return value
2559
+ .map((v) => textForValue(opts, v, compareWith))
2560
+ .filter((opt) => opt !== null)
2561
+ .join(', ');
2562
+ }
2563
+ else {
2564
+ return textForValue(opts, value, compareWith) || '';
2565
+ }
2566
+ };
2567
+ const textForValue = (opts, value, compareWith) => {
2568
+ const selectOpt = opts.find((opt) => {
2569
+ return compareOptions(getOptionValue(opt), value, compareWith);
2570
+ });
2571
+ return selectOpt ? selectOpt.textContent : null;
2572
+ };
2573
+ let selectIds = 0;
2574
+ const OPTION_CLASS = 'select-interface-option';
2575
+ Select.style = {
2576
+ ios: selectIosCss,
2577
+ md: selectMdCss
2578
+ };
2579
+
2580
+ const selectOptionCss = ":host{display:none}";
2581
+
2582
+ const SelectOption = class {
2583
+ constructor(hostRef) {
2584
+ registerInstance(this, hostRef);
2585
+ this.inputId = `ion-selopt-${selectOptionIds++}`;
2586
+ /**
2587
+ * If `true`, the user cannot interact with the select option. This property does not apply when `interface="action-sheet"` as `ion-action-sheet` does not allow for disabled buttons.
2588
+ */
2589
+ this.disabled = false;
2590
+ }
2591
+ render() {
2592
+ return h(Host, { role: "option", id: this.inputId, class: getIonMode(this) });
2593
+ }
2594
+ get el() { return getElement(this); }
2595
+ };
2596
+ let selectOptionIds = 0;
2597
+ SelectOption.style = selectOptionCss;
2598
+
2112
2599
  const selectPopoverIosCss = ".sc-ion-select-popover-ios-h ion-list.sc-ion-select-popover-ios{margin-left:0;margin-right:0;margin-top:0;margin-bottom:0}ion-list-header.sc-ion-select-popover-ios,ion-label.sc-ion-select-popover-ios{margin-left:0;margin-right:0;margin-top:0;margin-bottom:0}";
2113
2600
 
2114
2601
  const selectPopoverMdCss = ".sc-ion-select-popover-md-h ion-list.sc-ion-select-popover-md{margin-left:0;margin-right:0;margin-top:0;margin-bottom:0}ion-list-header.sc-ion-select-popover-md,ion-label.sc-ion-select-popover-md{margin-left:0;margin-right:0;margin-top:0;margin-bottom:0}ion-list.sc-ion-select-popover-md ion-radio.sc-ion-select-popover-md{opacity:0}ion-item.sc-ion-select-popover-md{--inner-border-width:0}.item-radio-checked.sc-ion-select-popover-md{--background:rgba(var(--ion-color-primary-rgb, 56, 128, 255), 0.08);--background-focused:var(--ion-color-primary, #3880ff);--background-focused-opacity:0.2;--background-hover:var(--ion-color-primary, #3880ff);--background-hover-opacity:0.12}.item-checkbox-checked.sc-ion-select-popover-md{--background-activated:var(--ion-item-color, var(--ion-text-color, #000));--background-focused:var(--ion-item-color, var(--ion-text-color, #000));--background-hover:var(--ion-item-color, var(--ion-text-color, #000));--color:var(--ion-color-primary, #3880ff)}";
@@ -2197,4 +2684,242 @@ SelectPopover.style = {
2197
2684
  md: selectPopoverMdCss
2198
2685
  };
2199
2686
 
2200
- export { ActionSheet as ion_action_sheet, Alert as ion_alert, Popover as ion_popover, SelectPopover as ion_select_popover };
2687
+ const textareaIosCss = ".sc-ion-textarea-ios-h{--background:initial;--color:initial;--placeholder-color:initial;--placeholder-font-style:initial;--placeholder-font-weight:initial;--placeholder-opacity:0.5;--padding-top:0;--padding-end:0;--padding-bottom:0;--padding-start:0;--border-radius:0;display:block;position:relative;flex:1;width:100%;background:var(--background);color:var(--color);font-family:var(--ion-font-family, inherit);white-space:pre-wrap;z-index:2;box-sizing:border-box}.ion-color.sc-ion-textarea-ios-h{background:initial}.ion-color.sc-ion-textarea-ios-h{color:var(--ion-color-base)}ion-item.sc-ion-textarea-ios-h,ion-item .sc-ion-textarea-ios-h{align-self:baseline}ion-item.sc-ion-textarea-ios-h:not(.item-label),ion-item:not(.item-label) .sc-ion-textarea-ios-h{--padding-start:0}.textarea-wrapper.sc-ion-textarea-ios{display:grid;min-width:inherit;max-width:inherit;min-height:inherit;max-height:inherit}.textarea-wrapper.sc-ion-textarea-ios::after{white-space:pre-wrap;content:attr(data-replicated-value) \" \";visibility:hidden}.native-textarea.sc-ion-textarea-ios,.textarea-wrapper.sc-ion-textarea-ios::after{padding-left:var(--padding-start);padding-right:var(--padding-end);padding-top:var(--padding-top);padding-bottom:var(--padding-bottom);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;grid-area:1/1/2/2}@supports (margin-inline-start: 0) or (-webkit-margin-start: 0){.native-textarea.sc-ion-textarea-ios,.textarea-wrapper.sc-ion-textarea-ios::after{padding-left:unset;padding-right:unset;-webkit-padding-start:var(--padding-start);padding-inline-start:var(--padding-start);-webkit-padding-end:var(--padding-end);padding-inline-end:var(--padding-end)}}.native-textarea.sc-ion-textarea-ios{border-radius:var(--border-radius);margin-left:0;margin-right:0;margin-top:0;margin-bottom:0;display:block;width:100%;max-width:100%;max-height:100%;border:0;outline:none;background:transparent;box-sizing:border-box;resize:none;appearance:none;overflow:hidden}.native-textarea.sc-ion-textarea-ios::placeholder{padding-left:0;padding-right:0;padding-top:0;padding-bottom:0;color:var(--placeholder-color);font-family:inherit;font-style:var(--placeholder-font-style);font-weight:var(--placeholder-font-weight);opacity:var(--placeholder-opacity)}.native-textarea[disabled].sc-ion-textarea-ios{opacity:0.4}.cloned-input.sc-ion-textarea-ios{left:0;top:0;position:absolute;pointer-events:none}[dir=rtl].sc-ion-textarea-ios .cloned-input.sc-ion-textarea-ios,[dir=rtl].sc-ion-textarea-ios-h .cloned-input.sc-ion-textarea-ios,[dir=rtl] .sc-ion-textarea-ios-h .cloned-input.sc-ion-textarea-ios{left:unset;right:unset;right:0}[auto-grow].sc-ion-textarea-ios-h .cloned-input.sc-ion-textarea-ios{height:100%}.item-label-floating.item-has-placeholder.sc-ion-textarea-ios-h:not(.item-has-value),.item-label-floating.item-has-placeholder:not(.item-has-value) .sc-ion-textarea-ios-h{opacity:0}.item-label-floating.item-has-placeholder.sc-ion-textarea-ios-h:not(.item-has-value).item-has-focus,.item-label-floating.item-has-placeholder:not(.item-has-value).item-has-focus .sc-ion-textarea-ios-h{transition:opacity 0.15s cubic-bezier(0.4, 0, 0.2, 1);opacity:1}.sc-ion-textarea-ios-h{--padding-top:10px;--padding-end:10px;--padding-bottom:10px;--padding-start:0;font-size:inherit}.item-label-stacked.sc-ion-textarea-ios-h,.item-label-stacked .sc-ion-textarea-ios-h,.item-label-floating.sc-ion-textarea-ios-h,.item-label-floating .sc-ion-textarea-ios-h{--padding-top:8px;--padding-bottom:8px;--padding-start:0px}";
2688
+
2689
+ const textareaMdCss = ".sc-ion-textarea-md-h{--background:initial;--color:initial;--placeholder-color:initial;--placeholder-font-style:initial;--placeholder-font-weight:initial;--placeholder-opacity:0.5;--padding-top:0;--padding-end:0;--padding-bottom:0;--padding-start:0;--border-radius:0;display:block;position:relative;flex:1;width:100%;background:var(--background);color:var(--color);font-family:var(--ion-font-family, inherit);white-space:pre-wrap;z-index:2;box-sizing:border-box}.ion-color.sc-ion-textarea-md-h{background:initial}.ion-color.sc-ion-textarea-md-h{color:var(--ion-color-base)}ion-item.sc-ion-textarea-md-h,ion-item .sc-ion-textarea-md-h{align-self:baseline}ion-item.sc-ion-textarea-md-h:not(.item-label),ion-item:not(.item-label) .sc-ion-textarea-md-h{--padding-start:0}.textarea-wrapper.sc-ion-textarea-md{display:grid;min-width:inherit;max-width:inherit;min-height:inherit;max-height:inherit}.textarea-wrapper.sc-ion-textarea-md::after{white-space:pre-wrap;content:attr(data-replicated-value) \" \";visibility:hidden}.native-textarea.sc-ion-textarea-md,.textarea-wrapper.sc-ion-textarea-md::after{padding-left:var(--padding-start);padding-right:var(--padding-end);padding-top:var(--padding-top);padding-bottom:var(--padding-bottom);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;grid-area:1/1/2/2}@supports (margin-inline-start: 0) or (-webkit-margin-start: 0){.native-textarea.sc-ion-textarea-md,.textarea-wrapper.sc-ion-textarea-md::after{padding-left:unset;padding-right:unset;-webkit-padding-start:var(--padding-start);padding-inline-start:var(--padding-start);-webkit-padding-end:var(--padding-end);padding-inline-end:var(--padding-end)}}.native-textarea.sc-ion-textarea-md{border-radius:var(--border-radius);margin-left:0;margin-right:0;margin-top:0;margin-bottom:0;display:block;width:100%;max-width:100%;max-height:100%;border:0;outline:none;background:transparent;box-sizing:border-box;resize:none;appearance:none;overflow:hidden}.native-textarea.sc-ion-textarea-md::placeholder{padding-left:0;padding-right:0;padding-top:0;padding-bottom:0;color:var(--placeholder-color);font-family:inherit;font-style:var(--placeholder-font-style);font-weight:var(--placeholder-font-weight);opacity:var(--placeholder-opacity)}.native-textarea[disabled].sc-ion-textarea-md{opacity:0.4}.cloned-input.sc-ion-textarea-md{left:0;top:0;position:absolute;pointer-events:none}[dir=rtl].sc-ion-textarea-md .cloned-input.sc-ion-textarea-md,[dir=rtl].sc-ion-textarea-md-h .cloned-input.sc-ion-textarea-md,[dir=rtl] .sc-ion-textarea-md-h .cloned-input.sc-ion-textarea-md{left:unset;right:unset;right:0}[auto-grow].sc-ion-textarea-md-h .cloned-input.sc-ion-textarea-md{height:100%}.item-label-floating.item-has-placeholder.sc-ion-textarea-md-h:not(.item-has-value),.item-label-floating.item-has-placeholder:not(.item-has-value) .sc-ion-textarea-md-h{opacity:0}.item-label-floating.item-has-placeholder.sc-ion-textarea-md-h:not(.item-has-value).item-has-focus,.item-label-floating.item-has-placeholder:not(.item-has-value).item-has-focus .sc-ion-textarea-md-h{transition:opacity 0.15s cubic-bezier(0.4, 0, 0.2, 1);opacity:1}.sc-ion-textarea-md-h{--padding-top:10px;--padding-end:0;--padding-bottom:11px;--padding-start:8px;margin-left:0;margin-right:0;margin-top:8px;margin-bottom:0;font-size:inherit}.item-label-stacked.sc-ion-textarea-md-h,.item-label-stacked .sc-ion-textarea-md-h,.item-label-floating.sc-ion-textarea-md-h,.item-label-floating .sc-ion-textarea-md-h{--padding-top:8px;--padding-bottom:8px;--padding-start:0}";
2690
+
2691
+ const Textarea = class {
2692
+ constructor(hostRef) {
2693
+ registerInstance(this, hostRef);
2694
+ this.ionChange = createEvent(this, "ionChange", 7);
2695
+ this.ionInput = createEvent(this, "ionInput", 7);
2696
+ this.ionStyle = createEvent(this, "ionStyle", 7);
2697
+ this.ionBlur = createEvent(this, "ionBlur", 7);
2698
+ this.ionFocus = createEvent(this, "ionFocus", 7);
2699
+ this.inputId = `ion-textarea-${textareaIds++}`;
2700
+ this.didBlurAfterEdit = false;
2701
+ this.inheritedAttributes = {};
2702
+ /**
2703
+ * This is required for a WebKit bug which requires us to
2704
+ * blur and focus an input to properly focus the input in
2705
+ * an item with delegatesFocus. It will no longer be needed
2706
+ * with iOS 14.
2707
+ *
2708
+ * @internal
2709
+ */
2710
+ this.fireFocusEvents = true;
2711
+ this.hasFocus = false;
2712
+ /**
2713
+ * Indicates whether and how the text value should be automatically capitalized as it is entered/edited by the user.
2714
+ * Available options: `"off"`, `"none"`, `"on"`, `"sentences"`, `"words"`, `"characters"`.
2715
+ */
2716
+ this.autocapitalize = 'none';
2717
+ /**
2718
+ * This Boolean attribute lets you specify that a form control should have input focus when the page loads.
2719
+ */
2720
+ this.autofocus = false;
2721
+ /**
2722
+ * If `true`, the value will be cleared after focus upon edit. Defaults to `true` when `type` is `"password"`, `false` for all other types.
2723
+ */
2724
+ this.clearOnEdit = false;
2725
+ /**
2726
+ * Set the amount of time, in milliseconds, to wait to trigger the `ionChange` event after each keystroke. This also impacts form bindings such as `ngModel` or `v-model`.
2727
+ */
2728
+ this.debounce = 0;
2729
+ /**
2730
+ * If `true`, the user cannot interact with the textarea.
2731
+ */
2732
+ this.disabled = false;
2733
+ /**
2734
+ * The name of the control, which is submitted with the form data.
2735
+ */
2736
+ this.name = this.inputId;
2737
+ /**
2738
+ * If `true`, the user cannot modify the value.
2739
+ */
2740
+ this.readonly = false;
2741
+ /**
2742
+ * If `true`, the user must fill in a value before submitting a form.
2743
+ */
2744
+ this.required = false;
2745
+ /**
2746
+ * If `true`, the element will have its spelling and grammar checked.
2747
+ */
2748
+ this.spellcheck = false;
2749
+ /**
2750
+ * If `true`, the textarea container will grow and shrink based
2751
+ * on the contents of the textarea.
2752
+ */
2753
+ this.autoGrow = false;
2754
+ /**
2755
+ * The value of the textarea.
2756
+ */
2757
+ this.value = '';
2758
+ this.onInput = (ev) => {
2759
+ if (this.nativeInput) {
2760
+ this.value = this.nativeInput.value;
2761
+ }
2762
+ this.emitStyle();
2763
+ this.ionInput.emit(ev);
2764
+ };
2765
+ this.onFocus = (ev) => {
2766
+ this.hasFocus = true;
2767
+ this.focusChange();
2768
+ if (this.fireFocusEvents) {
2769
+ this.ionFocus.emit(ev);
2770
+ }
2771
+ };
2772
+ this.onBlur = (ev) => {
2773
+ this.hasFocus = false;
2774
+ this.focusChange();
2775
+ if (this.fireFocusEvents) {
2776
+ this.ionBlur.emit(ev);
2777
+ }
2778
+ };
2779
+ this.onKeyDown = () => {
2780
+ this.checkClearOnEdit();
2781
+ };
2782
+ }
2783
+ debounceChanged() {
2784
+ this.ionChange = debounceEvent(this.ionChange, this.debounce);
2785
+ }
2786
+ disabledChanged() {
2787
+ this.emitStyle();
2788
+ }
2789
+ /**
2790
+ * Update the native input element when the value changes
2791
+ */
2792
+ valueChanged() {
2793
+ const nativeInput = this.nativeInput;
2794
+ const value = this.getValue();
2795
+ if (nativeInput && nativeInput.value !== value) {
2796
+ nativeInput.value = value;
2797
+ }
2798
+ this.runAutoGrow();
2799
+ this.emitStyle();
2800
+ this.ionChange.emit({ value });
2801
+ }
2802
+ connectedCallback() {
2803
+ this.emitStyle();
2804
+ this.debounceChanged();
2805
+ {
2806
+ document.dispatchEvent(new CustomEvent('ionInputDidLoad', {
2807
+ detail: this.el,
2808
+ }));
2809
+ }
2810
+ }
2811
+ disconnectedCallback() {
2812
+ {
2813
+ document.dispatchEvent(new CustomEvent('ionInputDidUnload', {
2814
+ detail: this.el,
2815
+ }));
2816
+ }
2817
+ }
2818
+ componentWillLoad() {
2819
+ this.inheritedAttributes = Object.assign(Object.assign({}, inheritAriaAttributes(this.el)), inheritAttributes(this.el, ['title']));
2820
+ }
2821
+ componentDidLoad() {
2822
+ this.runAutoGrow();
2823
+ }
2824
+ /**
2825
+ * Sets focus on the native `textarea` in `ion-textarea`. Use this method instead of the global
2826
+ * `textarea.focus()`.
2827
+ */
2828
+ async setFocus() {
2829
+ if (this.nativeInput) {
2830
+ this.nativeInput.focus();
2831
+ }
2832
+ }
2833
+ /**
2834
+ * Sets blur on the native `textarea` in `ion-textarea`. Use this method instead of the global
2835
+ * `textarea.blur()`.
2836
+ * @internal
2837
+ */
2838
+ async setBlur() {
2839
+ if (this.nativeInput) {
2840
+ this.nativeInput.blur();
2841
+ }
2842
+ }
2843
+ /**
2844
+ * Returns the native `<textarea>` element used under the hood.
2845
+ */
2846
+ getInputElement() {
2847
+ return Promise.resolve(this.nativeInput);
2848
+ }
2849
+ emitStyle() {
2850
+ this.ionStyle.emit({
2851
+ interactive: true,
2852
+ textarea: true,
2853
+ input: true,
2854
+ 'interactive-disabled': this.disabled,
2855
+ 'has-placeholder': this.placeholder !== undefined,
2856
+ 'has-value': this.hasValue(),
2857
+ 'has-focus': this.hasFocus,
2858
+ });
2859
+ }
2860
+ runAutoGrow() {
2861
+ if (this.nativeInput && this.autoGrow) {
2862
+ writeTask(() => {
2863
+ var _a;
2864
+ if (this.textareaWrapper) {
2865
+ // Replicated value is an attribute to be used in the stylesheet
2866
+ // to set the inner contents of a pseudo element.
2867
+ this.textareaWrapper.dataset.replicatedValue = (_a = this.value) !== null && _a !== void 0 ? _a : '';
2868
+ }
2869
+ });
2870
+ }
2871
+ }
2872
+ /**
2873
+ * Check if we need to clear the text input if clearOnEdit is enabled
2874
+ */
2875
+ checkClearOnEdit() {
2876
+ if (!this.clearOnEdit) {
2877
+ return;
2878
+ }
2879
+ // Did the input value change after it was blurred and edited?
2880
+ if (this.didBlurAfterEdit && this.hasValue()) {
2881
+ // Clear the input
2882
+ this.value = '';
2883
+ }
2884
+ // Reset the flag
2885
+ this.didBlurAfterEdit = false;
2886
+ }
2887
+ focusChange() {
2888
+ // If clearOnEdit is enabled and the input blurred but has a value, set a flag
2889
+ if (this.clearOnEdit && !this.hasFocus && this.hasValue()) {
2890
+ this.didBlurAfterEdit = true;
2891
+ }
2892
+ this.emitStyle();
2893
+ }
2894
+ hasValue() {
2895
+ return this.getValue() !== '';
2896
+ }
2897
+ getValue() {
2898
+ return this.value || '';
2899
+ }
2900
+ render() {
2901
+ const mode = getIonMode(this);
2902
+ const value = this.getValue();
2903
+ const labelId = this.inputId + '-lbl';
2904
+ const label = findItemLabel(this.el);
2905
+ if (label) {
2906
+ label.id = labelId;
2907
+ }
2908
+ return (h(Host, { "aria-disabled": this.disabled ? 'true' : null, class: createColorClasses(this.color, {
2909
+ [mode]: true,
2910
+ }) }, h("div", { class: "textarea-wrapper", ref: (el) => (this.textareaWrapper = el) }, h("textarea", Object.assign({ class: "native-textarea", "aria-labelledby": label ? labelId : null, ref: (el) => (this.nativeInput = el), autoCapitalize: this.autocapitalize, autoFocus: this.autofocus, enterKeyHint: this.enterkeyhint, inputMode: this.inputmode, disabled: this.disabled, maxLength: this.maxlength, minLength: this.minlength, name: this.name, placeholder: this.placeholder || '', readOnly: this.readonly, required: this.required, spellcheck: this.spellcheck, cols: this.cols, rows: this.rows, wrap: this.wrap, onInput: this.onInput, onBlur: this.onBlur, onFocus: this.onFocus, onKeyDown: this.onKeyDown }, this.inheritedAttributes), value))));
2911
+ }
2912
+ get el() { return getElement(this); }
2913
+ static get watchers() { return {
2914
+ "debounce": ["debounceChanged"],
2915
+ "disabled": ["disabledChanged"],
2916
+ "value": ["valueChanged"]
2917
+ }; }
2918
+ };
2919
+ let textareaIds = 0;
2920
+ Textarea.style = {
2921
+ ios: textareaIosCss,
2922
+ md: textareaMdCss
2923
+ };
2924
+
2925
+ export { ActionSheet as ion_action_sheet, Alert as ion_alert, Popover as ion_popover, Select as ion_select, SelectOption as ion_select_option, SelectPopover as ion_select_popover, Textarea as ion_textarea };