@getflip/swirl-components 0.38.3 → 0.39.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.
Files changed (33) hide show
  1. package/components.json +30 -3
  2. package/dist/cjs/loader.cjs.js +1 -1
  3. package/dist/cjs/swirl-components.cjs.js +1 -1
  4. package/dist/cjs/swirl-form-control.cjs.entry.js +5 -4
  5. package/dist/cjs/swirl-modal.cjs.entry.js +1165 -7
  6. package/dist/cjs/swirl-text-input.cjs.entry.js +1 -1
  7. package/dist/collection/assets/pdfjs/pdf.worker.min.js +1 -1
  8. package/dist/collection/collection-manifest.json +1 -1
  9. package/dist/collection/components/swirl-form-control/swirl-form-control.css +31 -0
  10. package/dist/collection/components/swirl-form-control/swirl-form-control.js +27 -3
  11. package/dist/collection/components/swirl-modal/swirl-modal.js +28 -8
  12. package/dist/collection/components/swirl-text-input/swirl-text-input.js +1 -1
  13. package/dist/components/assets/pdfjs/pdf.worker.min.js +1 -1
  14. package/dist/components/swirl-form-control.js +6 -4
  15. package/dist/components/swirl-modal.js +1167 -9
  16. package/dist/components/swirl-text-input2.js +1 -1
  17. package/dist/esm/loader.js +1 -1
  18. package/dist/esm/swirl-components.js +1 -1
  19. package/dist/esm/swirl-form-control.entry.js +5 -4
  20. package/dist/esm/swirl-modal.entry.js +1166 -8
  21. package/dist/esm/swirl-text-input.entry.js +1 -1
  22. package/dist/swirl-components/p-9d64ed48.entry.js +1 -0
  23. package/dist/swirl-components/p-a7db763e.entry.js +1 -0
  24. package/dist/swirl-components/p-e08f253d.entry.js +10 -0
  25. package/dist/swirl-components/swirl-components.esm.js +1 -1
  26. package/dist/types/components/swirl-form-control/swirl-form-control.d.ts +2 -0
  27. package/dist/types/components/swirl-modal/swirl-modal.d.ts +4 -1
  28. package/dist/types/components.d.ts +4 -0
  29. package/package.json +1 -1
  30. package/vscode-data.json +12 -0
  31. package/dist/swirl-components/p-0cb23149.entry.js +0 -1
  32. package/dist/swirl-components/p-4f7f5e02.entry.js +0 -1
  33. package/dist/swirl-components/p-66782dbd.entry.js +0 -1
@@ -18,6 +18,7 @@
18
18
  "./components/swirl-description-list-item/swirl-description-list-item.js",
19
19
  "./components/swirl-dialog/swirl-dialog.js",
20
20
  "./components/swirl-file-viewer/viewers/swirl-file-viewer-pdf/swirl-file-viewer-pdf.js",
21
+ "./components/swirl-form-control/swirl-form-control.js",
21
22
  "./components/swirl-form-group/swirl-form-group.js",
22
23
  "./components/swirl-heading/swirl-heading.js",
23
24
  "./components/swirl-inline-error/swirl-inline-error.js",
@@ -61,7 +62,6 @@
61
62
  "./components/swirl-file-viewer/viewers/swirl-file-viewer-image/swirl-file-viewer-image.js",
62
63
  "./components/swirl-file-viewer/viewers/swirl-file-viewer-text/swirl-file-viewer-text.js",
63
64
  "./components/swirl-file-viewer/viewers/swirl-file-viewer-video/swirl-file-viewer-video.js",
64
- "./components/swirl-form-control/swirl-form-control.js",
65
65
  "./components/swirl-icon/icons/swirl-icon-add-photo.js",
66
66
  "./components/swirl-icon/icons/swirl-icon-add.js",
67
67
  "./components/swirl-icon/icons/swirl-icon-admin-panel-settings.js",
@@ -59,6 +59,37 @@
59
59
  }
60
60
  }
61
61
 
62
+ .form-control--label-position-outside {
63
+ padding-top: calc(var(--s-line-height-sm) + var(--s-space-4));
64
+ }
65
+
66
+ .form-control--label-position-outside .form-control__label {
67
+ min-height: calc(2.375rem + 2 * var(--s-border-width-default));
68
+ padding: var(--s-space-8) var(--s-space-12);
69
+ gap: var(--s-space-2);
70
+ }
71
+
72
+ @media (min-width: 992px) and (max-width: 1439px) and (hover: hover),(min-width: 1440px) {
73
+
74
+ .form-control--label-position-outside .form-control__label {
75
+ min-height: calc(2.25rem + 2 * var(--s-border-width-default))
76
+ }
77
+ }
78
+
79
+ .form-control--label-position-outside .form-control__label-text,
80
+ .form-control--label-position-outside:not(.form-control--has-value):not(.form-control--has-focus):not(.form-control--is-select)
81
+ .form-control__label-text,
82
+ .form-control--label-position-outside:not(.form-control--has-value).form-control--is-select
83
+ .form-control__label-text {
84
+ bottom: calc(100% + var(--s-space-4));
85
+ left: 0;
86
+ color: var(--s-text-default);
87
+ font-size: var(--s-font-size-sm);
88
+ font-weight: var(--s-font-weight-medium);
89
+ transform: none;
90
+ opacity: 1;
91
+ }
92
+
62
93
  .form-control--invalid.form-control--has-focus:not(.form-control--disabled) .form-control__label {
63
94
  border-color: var(--s-border-critical);
64
95
  box-shadow: 0 0 0 var(--s-border-width-default) var(--s-border-critical);
@@ -28,6 +28,7 @@ export class SwirlFormControl {
28
28
  this.inline = undefined;
29
29
  this.invalid = undefined;
30
30
  this.label = undefined;
31
+ this.labelPosition = "inside";
31
32
  this.hasFocus = undefined;
32
33
  this.inputValue = undefined;
33
34
  }
@@ -62,7 +63,7 @@ export class SwirlFormControl {
62
63
  if (!Boolean(this.inputEl)) {
63
64
  return;
64
65
  }
65
- if (this.inline) {
66
+ if (this.inline || this.labelPosition === "outside") {
66
67
  this.inputEl.setAttribute("inline", "true");
67
68
  }
68
69
  else {
@@ -103,11 +104,11 @@ export class SwirlFormControl {
103
104
  ? this.inputValue.length > 0
104
105
  : Boolean(this.inputValue);
105
106
  const isSelect = this.inputEl.tagName === "SWIRL-SELECT";
106
- const className = classnames("form-control", {
107
+ const className = classnames("form-control", `form-control--label-position-${this.labelPosition}`, {
107
108
  "form-control--disabled": this.disabled,
108
- "form-control--inline": this.inline,
109
109
  "form-control--has-focus": this.hasFocus,
110
110
  "form-control--has-value": hasValue,
111
+ "form-control--inline": this.inline,
111
112
  "form-control--invalid": this.invalid,
112
113
  "form-control--is-select": isSelect,
113
114
  });
@@ -228,6 +229,29 @@ export class SwirlFormControl {
228
229
  },
229
230
  "attribute": "label",
230
231
  "reflect": false
232
+ },
233
+ "labelPosition": {
234
+ "type": "string",
235
+ "mutable": false,
236
+ "complexType": {
237
+ "original": "SwirlFormControlLabelPosition",
238
+ "resolved": "\"inside\" | \"outside\"",
239
+ "references": {
240
+ "SwirlFormControlLabelPosition": {
241
+ "location": "local",
242
+ "path": "/home/runner/work/swirl/swirl/packages/swirl-components/src/components/swirl-form-control/swirl-form-control.tsx"
243
+ }
244
+ }
245
+ },
246
+ "required": false,
247
+ "optional": true,
248
+ "docs": {
249
+ "tags": [],
250
+ "text": ""
251
+ },
252
+ "attribute": "label-position",
253
+ "reflect": false,
254
+ "defaultValue": "\"inside\""
231
255
  }
232
256
  };
233
257
  }
@@ -1,6 +1,6 @@
1
1
  import { h, Host, } from "@stencil/core";
2
- import A11yDialog from "a11y-dialog";
3
2
  import { disableBodyScroll, enableBodyScroll } from "body-scroll-lock";
3
+ import * as focusTrap from "focus-trap";
4
4
  import classnames from "classnames";
5
5
  /**
6
6
  * slot - Modal contents
@@ -51,6 +51,7 @@ export class SwirlModal {
51
51
  this.padded = true;
52
52
  this.primaryActionLabel = undefined;
53
53
  this.secondaryActionLabel = undefined;
54
+ this.isOpen = false;
54
55
  this.closing = false;
55
56
  this.hasCustomHeader = undefined;
56
57
  this.scrollable = false;
@@ -58,22 +59,34 @@ export class SwirlModal {
58
59
  this.scrolledDown = false;
59
60
  }
60
61
  componentDidLoad() {
61
- this.modal = new A11yDialog(this.modalEl);
62
+ this.focusTrap = focusTrap.createFocusTrap(this.modalEl, {
63
+ tabbableOptions: { getShadowRoot: (node) => node.shadowRoot },
64
+ });
62
65
  this.determineScrollStatus();
63
66
  }
64
67
  disconnectedCallback() {
65
- var _a;
66
- (_a = this.modal) === null || _a === void 0 ? void 0 : _a.destroy();
68
+ this.focusTrap.deactivate();
67
69
  this.unlockBodyScroll();
68
70
  }
69
71
  onWindowResize() {
70
72
  this.determineScrollStatus();
71
73
  }
74
+ watchIsOpen() {
75
+ if (this.isOpen) {
76
+ // wait for animation
77
+ setTimeout(() => {
78
+ this.focusTrap.activate();
79
+ }, 200);
80
+ }
81
+ else {
82
+ this.focusTrap.deactivate();
83
+ }
84
+ }
72
85
  /**
73
86
  * Open the modal.
74
87
  */
75
88
  async open() {
76
- this.modal.show();
89
+ this.isOpen = true;
77
90
  this.modalOpen.emit();
78
91
  this.lockBodyScroll();
79
92
  this.determineScrollStatus();
@@ -88,7 +101,7 @@ export class SwirlModal {
88
101
  this.closing = true;
89
102
  this.unlockBodyScroll();
90
103
  setTimeout(() => {
91
- this.modal.hide();
104
+ this.isOpen = false;
92
105
  this.modalClose.emit();
93
106
  this.closing = false;
94
107
  }, 150);
@@ -109,10 +122,9 @@ export class SwirlModal {
109
122
  "modal--scrolled": this.scrolled,
110
123
  "modal--scrolled-down": this.scrolledDown,
111
124
  });
112
- return (h(Host, null, h("section", { "aria-hidden": "true", "aria-label": this.label, class: className, id: "modal", onKeyDown: this.onKeyDown, ref: (el) => (this.modalEl = el) }, h("div", { class: "modal__backdrop", onClick: this.onBackdropClick }), h("div", { class: "modal__body", role: "document", style: { maxWidth: this.maxWidth } }, !this.hideCloseButton && (h("swirl-button", { class: "modal__close-button", hideLabel: true, icon: "<swirl-icon-close></swirl-icon-close>", label: this.closeButtonLabel, onClick: this.onCloseButtonClick })), h("header", { class: "modal__custom-header" }, h("slot", { name: "custom-header", onSlotchange: this.onCustomHeaderSlotChange, ref: (el) => (this.customHeaderSlot = el) })), !this.hideLabel && (h("header", { class: "modal__header" }, h("swirl-heading", { as: "h2", class: "modal__heading", level: 3, text: this.label }))), h("div", { class: "modal__content", onScroll: this.determineScrollStatus, ref: (el) => (this.scrollContainer = el) }, h("slot", null)), showControls && (h("footer", { class: "modal__controls" }, h("swirl-button-group", { wrap: true }, this.secondaryActionLabel && (h("swirl-button", { label: this.secondaryActionLabel, onClick: this.onSecondaryAction })), this.primaryActionLabel && (h("swirl-button", { intent: "primary", label: this.primaryActionLabel, onClick: this.onPrimaryAction, variant: "flat" })))))))));
125
+ return (h(Host, null, h("section", { "aria-hidden": String(!this.isOpen), "aria-label": this.label, "aria-modal": "true", class: className, onKeyDown: this.onKeyDown, role: "dialog", ref: (el) => (this.modalEl = el) }, h("div", { class: "modal__backdrop", onClick: this.onBackdropClick }), h("div", { class: "modal__body", style: { maxWidth: this.maxWidth } }, !this.hideCloseButton && (h("swirl-button", { class: "modal__close-button", hideLabel: true, icon: "<swirl-icon-close></swirl-icon-close>", label: this.closeButtonLabel, onClick: this.onCloseButtonClick })), h("header", { class: "modal__custom-header" }, h("slot", { name: "custom-header", onSlotchange: this.onCustomHeaderSlotChange, ref: (el) => (this.customHeaderSlot = el) })), !this.hideLabel && (h("header", { class: "modal__header" }, h("swirl-heading", { as: "h2", class: "modal__heading", level: 3, text: this.label }))), h("div", { class: "modal__content", onScroll: this.determineScrollStatus, ref: (el) => (this.scrollContainer = el) }, h("slot", null)), showControls && (h("footer", { class: "modal__controls" }, h("swirl-button-group", { wrap: true }, this.secondaryActionLabel && (h("swirl-button", { label: this.secondaryActionLabel, onClick: this.onSecondaryAction })), this.primaryActionLabel && (h("swirl-button", { intent: "primary", label: this.primaryActionLabel, onClick: this.onPrimaryAction, variant: "flat" })))))))));
113
126
  }
114
127
  static get is() { return "swirl-modal"; }
115
- static get encapsulation() { return "shadow"; }
116
128
  static get originalStyleUrls() {
117
129
  return {
118
130
  "$": ["swirl-modal.css"]
@@ -267,6 +279,7 @@ export class SwirlModal {
267
279
  }
268
280
  static get states() {
269
281
  return {
282
+ "isOpen": {},
270
283
  "closing": {},
271
284
  "hasCustomHeader": {},
272
285
  "scrollable": {},
@@ -381,6 +394,13 @@ export class SwirlModal {
381
394
  }
382
395
  };
383
396
  }
397
+ static get elementRef() { return "el"; }
398
+ static get watchers() {
399
+ return [{
400
+ "propName": "isOpen",
401
+ "methodName": "watchIsOpen"
402
+ }];
403
+ }
384
404
  static get listeners() {
385
405
  return [{
386
406
  "name": "resize",
@@ -154,7 +154,7 @@ export class SwirlTextInput {
154
154
  "text-input--inline": this.inline,
155
155
  "text-input--show-password": this.type === "password" && this.showPassword,
156
156
  });
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, 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}` : "")))));
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}` : "")))));
158
158
  }
159
159
  static get is() { return "swirl-text-input"; }
160
160
  static get encapsulation() { return "scoped"; }