@getflip/swirl-components 0.39.1 → 0.40.0

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.
@@ -17,6 +17,10 @@
17
17
  line-height: var(--s-line-height-sm);
18
18
  }
19
19
 
20
+ .text-input--auto-grow .text-input__input {
21
+ max-height: none;
22
+ }
23
+
20
24
  .text-input--clearable,
21
25
  .text-input--type-number,
22
26
  .text-input--type-password {
@@ -68,6 +68,7 @@ export class SwirlTextInput {
68
68
  };
69
69
  this.autoComplete = "on";
70
70
  this.autoFocus = undefined;
71
+ this.autoGrow = undefined;
71
72
  this.autoSelect = undefined;
72
73
  this.clearable = undefined;
73
74
  this.clearButtonLabel = "Clear input";
@@ -113,12 +114,12 @@ export class SwirlTextInput {
113
114
  this.iconSize = smallIcon ? 20 : 24;
114
115
  }
115
116
  adjustInputSize() {
116
- if (this.rows > 1) {
117
+ if (this.rows > 1 || this.autoGrow) {
117
118
  this.inputEl.style.width = "";
118
119
  this.inputEl.style.height = "";
119
120
  this.inputEl.style.height = this.inputEl.scrollHeight / 16 + "rem";
120
121
  }
121
- if (this.rows === 1) {
122
+ if (this.rows === 1 && !this.autoGrow) {
122
123
  this.inputEl.style.height = "";
123
124
  this.inputEl.style.width = "";
124
125
  if (this.type !== "password" && !this.disableDynamicWidth) {
@@ -134,7 +135,7 @@ export class SwirlTextInput {
134
135
  }
135
136
  render() {
136
137
  var _a;
137
- const Tag = this.rows === 1 ? "input" : "textarea";
138
+ const Tag = this.rows === 1 && !this.autoGrow ? "input" : "textarea";
138
139
  const ariaInvalid = this.invalid === true || this.invalid === false
139
140
  ? String(this.invalid)
140
141
  : undefined;
@@ -148,13 +149,14 @@ export class SwirlTextInput {
148
149
  !this.showCharacterCounter;
149
150
  const type = this.type === "password" && this.showPassword ? "text" : this.type;
150
151
  const className = classnames("text-input", `text-input--type-${this.type}`, {
152
+ "text-input--auto-grow": this.autoGrow,
151
153
  "text-input--clearable": this.clearable,
152
154
  "text-input--disabled": this.disabled,
153
155
  "text-input--disable-dynamic-width": this.disableDynamicWidth,
154
156
  "text-input--inline": this.inline,
155
157
  "text-input--show-password": this.type === "password" && this.showPassword,
156
158
  });
157
- return (h(Host, null, h("div", { class: className }, this.prefixLabel && (h("span", { class: "text-input__prefix" }, this.prefixLabel)), h(Tag, { "aria-autocomplete": this.swirlAriaAutocomplete, "aria-controls": this.swirlAriaControls, "aria-describedby": this.swirlAriaDescribedby, "aria-disabled": this.disabled ? "true" : undefined, "aria-expanded": this.swirlAriaExpanded, "aria-invalid": ariaInvalid, autoComplete: this.autoComplete, autoFocus: this.autoFocus, class: "text-input__input", disabled: this.disabled, inputMode: this.mode, maxLength: this.maxLength, max: this.type === "number" ? this.max : undefined, min: this.type === "number" ? this.min : undefined, onBlur: this.onBlur, onFocus: this.onFocus, onInput: this.onInput, onKeyPress: this.onKeyPress, ref: (el) => (this.inputEl = el), required: this.required, role: this.swirlRole, rows: this.rows > 1 ? this.rows : undefined, spellcheck: this.spellCheck, step: this.type === "number" ? this.step : undefined, type: type, value: this.rows === 1 ? this.value : undefined }, this.rows > 1 && this.value), this.suffixLabel && (h("span", { class: "text-input__suffix" }, this.suffixLabel)), showClearButton && (h("button", { "aria-label": this.clearButtonLabel, class: "text-input__clear-button", onClick: this.clear, part: "text-input__clear-button", type: "button" }, h("swirl-icon-cancel", { size: this.iconSize }))), showPasswordToggle && (h("button", { "aria-label": this.passwordToggleLabel, class: "text-input__password-toggle", onClick: this.togglePassword, type: "button" }, this.showPassword ? (h("swirl-icon-visibility-off", { size: this.iconSize })) : (h("swirl-icon-visibility", { size: this.iconSize })))), showStepper && (h("span", { class: "text-input__stepper" }, h("button", { "aria-hidden": "true", class: "text-input__step-button", onClick: this.increaseValue, tabIndex: -1, type: "button" }, h("swirl-icon-expand-less", { size: this.iconSize })), h("button", { "aria-hidden": "true", class: "text-input__step-button", onClick: this.decreaseValue, tabIndex: -1, type: "button" }, h("swirl-icon-expand-more", { size: this.iconSize })))), this.showCharacterCounter && (h("span", { class: "text-input__character-counter" }, ((_a = this.value) === null || _a === void 0 ? void 0 : _a.length) || 0, " ", Boolean(this.maxLength) ? `/ ${this.maxLength}` : "")))));
159
+ return (h(Host, null, h("div", { class: className }, this.prefixLabel && (h("span", { class: "text-input__prefix" }, this.prefixLabel)), h(Tag, { "aria-autocomplete": this.swirlAriaAutocomplete, "aria-controls": this.swirlAriaControls, "aria-describedby": this.swirlAriaDescribedby, "aria-disabled": this.disabled ? "true" : undefined, "aria-expanded": this.swirlAriaExpanded, "aria-invalid": ariaInvalid, autoComplete: this.autoComplete, autoFocus: this.autoFocus, class: "text-input__input", disabled: this.disabled, inputMode: this.mode, maxLength: this.maxLength, max: this.type === "number" ? this.max : undefined, min: this.type === "number" ? this.min : undefined, onBlur: this.onBlur, onFocus: this.onFocus, onInput: this.onInput, onKeyPress: this.onKeyPress, ref: (el) => (this.inputEl = el), required: this.required, role: this.swirlRole, rows: this.rows > 1 ? this.rows : this.autoGrow ? 1 : undefined, spellcheck: this.spellCheck, step: this.type === "number" ? this.step : undefined, type: type, value: this.rows === 1 ? this.value : undefined }, this.rows > 1 && this.value), this.suffixLabel && (h("span", { class: "text-input__suffix" }, this.suffixLabel)), showClearButton && (h("button", { "aria-label": this.clearButtonLabel, class: "text-input__clear-button", onClick: this.clear, part: "text-input__clear-button", type: "button" }, h("swirl-icon-cancel", { size: this.iconSize }))), showPasswordToggle && (h("button", { "aria-label": this.passwordToggleLabel, class: "text-input__password-toggle", onClick: this.togglePassword, type: "button" }, this.showPassword ? (h("swirl-icon-visibility-off", { size: this.iconSize })) : (h("swirl-icon-visibility", { size: this.iconSize })))), showStepper && (h("span", { class: "text-input__stepper" }, h("button", { "aria-hidden": "true", class: "text-input__step-button", onClick: this.increaseValue, tabIndex: -1, type: "button" }, h("swirl-icon-expand-less", { size: this.iconSize })), h("button", { "aria-hidden": "true", class: "text-input__step-button", onClick: this.decreaseValue, tabIndex: -1, type: "button" }, h("swirl-icon-expand-more", { size: this.iconSize })))), this.showCharacterCounter && (h("span", { class: "text-input__character-counter" }, ((_a = this.value) === null || _a === void 0 ? void 0 : _a.length) || 0, " ", Boolean(this.maxLength) ? `/ ${this.maxLength}` : "")))));
158
160
  }
159
161
  static get is() { return "swirl-text-input"; }
160
162
  static get encapsulation() { return "scoped"; }
@@ -205,6 +207,23 @@ export class SwirlTextInput {
205
207
  "attribute": "auto-focus",
206
208
  "reflect": false
207
209
  },
210
+ "autoGrow": {
211
+ "type": "boolean",
212
+ "mutable": false,
213
+ "complexType": {
214
+ "original": "boolean",
215
+ "resolved": "boolean",
216
+ "references": {}
217
+ },
218
+ "required": false,
219
+ "optional": true,
220
+ "docs": {
221
+ "tags": [],
222
+ "text": ""
223
+ },
224
+ "attribute": "auto-grow",
225
+ "reflect": false
226
+ },
208
227
  "autoSelect": {
209
228
  "type": "boolean",
210
229
  "mutable": false,