@scouterna/ui-webc 2.2.7 → 3.1.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 (116) hide show
  1. package/dist/cjs/{index-DpSUh0CA.js → index-BPpKjjvS.js} +51 -1
  2. package/dist/cjs/{inputMixin-BEUFwoun.js → inputMixin-D0IzcaXz.js} +27 -14
  3. package/dist/cjs/loader.cjs.js +2 -2
  4. package/dist/cjs/scout-app-bar.cjs.entry.js +1 -1
  5. package/dist/cjs/scout-bottom-bar-item.cjs.entry.js +1 -1
  6. package/dist/cjs/scout-bottom-bar.cjs.entry.js +1 -1
  7. package/dist/cjs/scout-button.cjs.entry.js +1 -1
  8. package/dist/cjs/scout-card.cjs.entry.js +1 -1
  9. package/dist/cjs/scout-checkbox_2.cjs.entry.js +16 -4
  10. package/dist/cjs/scout-divider.cjs.entry.js +1 -1
  11. package/dist/cjs/scout-field.cjs.entry.js +2 -2
  12. package/dist/cjs/scout-input.cjs.entry.js +9 -3
  13. package/dist/cjs/scout-link.cjs.entry.js +1 -1
  14. package/dist/cjs/scout-list-view-item.cjs.entry.js +1 -1
  15. package/dist/cjs/scout-list-view-subheader.cjs.entry.js +1 -1
  16. package/dist/cjs/scout-list-view.cjs.entry.js +1 -1
  17. package/dist/cjs/scout-loader.cjs.entry.js +1 -1
  18. package/dist/cjs/scout-select.cjs.entry.js +10 -4
  19. package/dist/cjs/scout-stack.cjs.entry.js +1 -1
  20. package/dist/cjs/scout-switch.cjs.entry.js +9 -3
  21. package/dist/cjs/scout-tabs-tab.cjs.entry.js +18 -0
  22. package/dist/cjs/scout-tabs.cjs.entry.js +74 -0
  23. package/dist/cjs/ui-webc.cjs.js +2 -2
  24. package/dist/collection/collection-manifest.json +3 -1
  25. package/dist/collection/components/field/field.js +2 -2
  26. package/dist/collection/components/select/select.js +1 -1
  27. package/dist/collection/components/tabs/tabs.css +17 -0
  28. package/dist/collection/components/tabs/tabs.js +142 -0
  29. package/dist/collection/components/tabs-tab/tabs-tab.css +44 -0
  30. package/dist/collection/components/tabs-tab/tabs-tab.js +19 -0
  31. package/dist/collection/mixins/inputMixin.js +63 -22
  32. package/dist/components/index.js +1 -1
  33. package/dist/components/p-B72iGJNe.js +1 -0
  34. package/dist/components/{p-CmHrcz9s.js → p-CXXyN7aY.js} +1 -1
  35. package/dist/components/p-DxVqa2PR.js +1 -0
  36. package/dist/components/p-Qv5q0SGa.js +1 -0
  37. package/dist/components/scout-app-bar.js +1 -1
  38. package/dist/components/scout-bottom-bar-item.js +1 -1
  39. package/dist/components/scout-bottom-bar.js +1 -1
  40. package/dist/components/scout-button.js +1 -1
  41. package/dist/components/scout-card.js +1 -1
  42. package/dist/components/scout-checkbox.js +1 -1
  43. package/dist/components/scout-divider.js +1 -1
  44. package/dist/components/scout-field.js +1 -1
  45. package/dist/components/scout-input.js +1 -1
  46. package/dist/components/scout-link.js +1 -1
  47. package/dist/components/scout-list-view-item.js +1 -1
  48. package/dist/components/scout-list-view-subheader.js +1 -1
  49. package/dist/components/scout-list-view.js +1 -1
  50. package/dist/components/scout-loader.js +1 -1
  51. package/dist/components/scout-radio-button.js +1 -1
  52. package/dist/components/scout-select.js +1 -1
  53. package/dist/components/scout-stack.js +1 -1
  54. package/dist/components/scout-switch.js +1 -1
  55. package/dist/components/scout-tabs-tab.d.ts +11 -0
  56. package/dist/components/scout-tabs-tab.js +1 -0
  57. package/dist/components/scout-tabs.d.ts +11 -0
  58. package/dist/components/scout-tabs.js +1 -0
  59. package/dist/custom-elements.json +231 -42
  60. package/dist/esm/{index-xD2pOo_x.js → index-CBq_WkdR.js} +51 -1
  61. package/dist/esm/{inputMixin-BuDdNX3m.js → inputMixin-CArDsEiI.js} +27 -14
  62. package/dist/esm/loader.js +3 -3
  63. package/dist/esm/scout-app-bar.entry.js +1 -1
  64. package/dist/esm/scout-bottom-bar-item.entry.js +1 -1
  65. package/dist/esm/scout-bottom-bar.entry.js +1 -1
  66. package/dist/esm/scout-button.entry.js +1 -1
  67. package/dist/esm/scout-card.entry.js +1 -1
  68. package/dist/esm/scout-checkbox_2.entry.js +16 -4
  69. package/dist/esm/scout-divider.entry.js +1 -1
  70. package/dist/esm/scout-field.entry.js +2 -2
  71. package/dist/esm/scout-input.entry.js +9 -3
  72. package/dist/esm/scout-link.entry.js +1 -1
  73. package/dist/esm/scout-list-view-item.entry.js +1 -1
  74. package/dist/esm/scout-list-view-subheader.entry.js +1 -1
  75. package/dist/esm/scout-list-view.entry.js +1 -1
  76. package/dist/esm/scout-loader.entry.js +1 -1
  77. package/dist/esm/scout-select.entry.js +10 -4
  78. package/dist/esm/scout-stack.entry.js +1 -1
  79. package/dist/esm/scout-switch.entry.js +9 -3
  80. package/dist/esm/scout-tabs-tab.entry.js +16 -0
  81. package/dist/esm/scout-tabs.entry.js +72 -0
  82. package/dist/esm/ui-webc.js +3 -3
  83. package/dist/types/components/tabs/tabs.d.ts +31 -0
  84. package/dist/types/components/tabs-tab/tabs-tab.d.ts +3 -0
  85. package/dist/types/components.d.ts +183 -30
  86. package/dist/ui-webc/p-0e444b1f.entry.js +1 -0
  87. package/dist/ui-webc/p-189879c2.entry.js +1 -0
  88. package/dist/ui-webc/p-60cd6c7e.entry.js +1 -0
  89. package/dist/ui-webc/{p-8da4cdaa.entry.js → p-6287efe7.entry.js} +1 -1
  90. package/dist/ui-webc/{p-bf96d820.entry.js → p-6825e415.entry.js} +1 -1
  91. package/dist/ui-webc/p-6xDaXBJm.js +1 -0
  92. package/dist/ui-webc/{p-186ee2d2.entry.js → p-78126f74.entry.js} +1 -1
  93. package/dist/ui-webc/{p-cdce9596.entry.js → p-8f5965aa.entry.js} +1 -1
  94. package/dist/ui-webc/{p-xD2pOo_x.js → p-CBq_WkdR.js} +2 -2
  95. package/dist/ui-webc/p-a153023c.entry.js +1 -0
  96. package/dist/ui-webc/{p-94f1aa41.entry.js → p-a2c09e05.entry.js} +1 -1
  97. package/dist/ui-webc/{p-802ce20c.entry.js → p-b699617e.entry.js} +1 -1
  98. package/dist/ui-webc/p-c0696c1f.entry.js +1 -0
  99. package/dist/ui-webc/{p-f3ff75c8.entry.js → p-c4f7cfa2.entry.js} +1 -1
  100. package/dist/ui-webc/{p-594f0ba6.entry.js → p-cdc127de.entry.js} +1 -1
  101. package/dist/ui-webc/p-db40c987.entry.js +1 -0
  102. package/dist/ui-webc/{p-66f2d080.entry.js → p-ef34d84c.entry.js} +1 -1
  103. package/dist/ui-webc/{p-db9e3e2d.entry.js → p-f799b2d8.entry.js} +1 -1
  104. package/dist/ui-webc/{p-d7430470.entry.js → p-f8099e5b.entry.js} +1 -1
  105. package/dist/ui-webc/{p-eaec31f1.entry.js → p-f8a4ef3d.entry.js} +1 -1
  106. package/dist/ui-webc/{p-5b96b509.entry.js → p-ff537388.entry.js} +1 -1
  107. package/dist/ui-webc/ui-webc.esm.js +1 -1
  108. package/package.json +2 -2
  109. package/dist/components/p-CTivgs5a.js +0 -1
  110. package/dist/components/p-R-tzZ3cs.js +0 -1
  111. package/dist/components/p-vLvmwbzB.js +0 -1
  112. package/dist/ui-webc/p-061e3457.entry.js +0 -1
  113. package/dist/ui-webc/p-0dd7cda5.entry.js +0 -1
  114. package/dist/ui-webc/p-24ccd3fc.entry.js +0 -1
  115. package/dist/ui-webc/p-BuuT2Uz3.js +0 -1
  116. package/dist/ui-webc/p-a92dd367.entry.js +0 -1
@@ -0,0 +1,74 @@
1
+ 'use strict';
2
+
3
+ var index = require('./index-BPpKjjvS.js');
4
+
5
+ const tabsCss = () => `:host{position:relative;width:100%;display:flex;height:var(--spacing-12);--tabs-indicator-height:2px}.indicator{position:absolute;bottom:0;left:0;width:0;height:var(--tabs-indicator-height);background-color:var(--color-background-brand-base);transition:all 0.3s ease}`;
6
+
7
+ const ScoutTabs = class {
8
+ constructor(hostRef) {
9
+ index.registerInstance(this, hostRef);
10
+ this.scoutChange = index.createEvent(this, "scoutChange");
11
+ }
12
+ get el() { return index.getElement(this); }
13
+ /**
14
+ * Zero-based index of the currently active tab.
15
+ */
16
+ value = 0;
17
+ /**
18
+ * Emitted when the active tab changes as a result of a user click.
19
+ * The `value` in the event detail is the zero-based index of the newly selected tab.
20
+ */
21
+ scoutChange;
22
+ widths = [];
23
+ lefts = [];
24
+ render() {
25
+ return (index.h(index.Host, { key: 'dffbae0bba3543f50cbe7046bad52c7bdff7ba55' }, index.h("slot", { key: 'cad95b2ae6c8b2bc659bfa6510c0b193d2e08dd9' }), this.getIndicator()));
26
+ }
27
+ componentDidLoad() {
28
+ this.updateChildrenClasses();
29
+ this.calculateIndicatorSizes();
30
+ }
31
+ getIndicator() {
32
+ const width = this.widths[this.value] || 0;
33
+ const left = this.lefts[this.value] || 0;
34
+ const indicatorStyle = {
35
+ width: `${width}px`,
36
+ transform: `translateX(${left}px)`,
37
+ };
38
+ return index.h("div", { "aria-hidden": "true", class: "indicator", style: indicatorStyle });
39
+ }
40
+ handleClick(event) {
41
+ const target = event.target;
42
+ const tabs = Array.from(this.el.children);
43
+ const clickedIndex = tabs.indexOf(target);
44
+ if (clickedIndex !== -1 && clickedIndex !== this.value) {
45
+ this.scoutChange.emit({ value: clickedIndex });
46
+ }
47
+ }
48
+ updateChildrenClasses() {
49
+ Array.from(this.el.children).forEach((child, index) => {
50
+ const tab = child;
51
+ if (index === this.value) {
52
+ tab.setAttribute("data-active", "true");
53
+ }
54
+ else {
55
+ tab.removeAttribute("data-active");
56
+ }
57
+ });
58
+ }
59
+ calculateIndicatorSizes() {
60
+ this.widths = Array.from(this.el.children).map((child) => child.offsetWidth);
61
+ this.lefts = this.widths.map((_, index) => this.widths.slice(0, index).reduce((acc, w) => acc + w, 0));
62
+ }
63
+ static get delegatesFocus() { return true; }
64
+ static get watchers() { return {
65
+ "value": [{
66
+ "updateChildrenClasses": 0
67
+ }, {
68
+ "calculateIndicatorSizes": 0
69
+ }]
70
+ }; }
71
+ };
72
+ ScoutTabs.style = tabsCss();
73
+
74
+ exports.scout_tabs = ScoutTabs;
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var index = require('./index-DpSUh0CA.js');
3
+ var index = require('./index-BPpKjjvS.js');
4
4
 
5
5
  var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
6
6
  /*
@@ -18,7 +18,7 @@ var patchBrowser = () => {
18
18
 
19
19
  patchBrowser().then(async (options) => {
20
20
  await index.globalScripts();
21
- return index.bootstrapLazy([["scout-list-view-item.cjs",[[529,"scout-list-view-item",{"icon":[1],"primary":[1],"secondary":[1],"type":[1],"href":[1],"target":[1],"rel":[1],"name":[1],"value":[1],"checked":[4],"disabled":[4]}]]],["scout-app-bar.cjs",[[785,"scout-app-bar",{"titleText":[1,"title-text"]}]]],["scout-bottom-bar.cjs",[[273,"scout-bottom-bar"]]],["scout-bottom-bar-item.cjs",[[529,"scout-bottom-bar-item",{"type":[1],"href":[1],"target":[1],"rel":[1],"icon":[1],"label":[1],"active":[4]}]]],["scout-button.cjs",[[772,"scout-button",{"type":[1],"href":[1],"target":[1],"rel":[1],"size":[1],"variant":[1],"icon":[1],"iconPosition":[1,"icon-position"],"iconOnly":[4,"icon-only"]}]]],["scout-card.cjs",[[273,"scout-card"]]],["scout-divider.cjs",[[17,"scout-divider"]]],["scout-field.cjs",[[774,"scout-field",{"label":[1],"helpText":[1,"help-text"],"inputId":[32],"errorText":[32],"errorHidden":[32]},[[0,"_scoutFieldId","catchFieldId"],[0,"_scoutValidate","handleValidation"],[0,"scoutBlur","showError"],[0,"_scoutInvalid","showError"]]]]],["scout-input.cjs",[[514,"scout-input",{"validate":[16],"size":[1],"variant":[1],"type":[1],"inputmode":[1],"pattern":[1],"value":[1],"name":[1],"disabled":[4],"placeholder":[1],"ariaId":[32]}]]],["scout-link.cjs",[[529,"scout-link",{"href":[1],"label":[1],"rel":[1],"linkAriaLabel":[1,"link-aria-label"],"type":[1],"target":[1]}]]],["scout-list-view.cjs",[[273,"scout-list-view",null,[[0,"scoutChecked","onScoutChecked"]]]]],["scout-list-view-subheader.cjs",[[529,"scout-list-view-subheader",{"text":[1],"headingLevel":[1,"heading-level"]}]]],["scout-loader.cjs",[[513,"scout-loader",{"text":[1],"size":[1]}]]],["scout-select.cjs",[[774,"scout-select",{"validate":[16],"value":[1],"disabled":[4],"name":[1],"ariaId":[32]}]]],["scout-stack.cjs",[[785,"scout-stack",{"direction":[1],"gapSize":[1,"gap-size"]}]]],["scout-switch.cjs",[[529,"scout-switch",{"validate":[16],"toggled":[4],"disabled":[4],"ariaLabelledby":[1,"aria-labelledby"],"label":[1],"ariaId":[32]}]]],["scout-checkbox_2.cjs",[[514,"scout-checkbox",{"validate":[16],"checked":[4],"disabled":[4],"ariaLabelledby":[1,"aria-labelledby"],"label":[1],"value":[1],"name":[1],"ariaId":[32]}],[514,"scout-radio-button",{"validate":[16],"checked":[4],"disabled":[4],"ariaLabelledby":[1,"aria-labelledby"],"label":[1],"value":[1],"name":[1],"ariaId":[32]}]]]], options);
21
+ return index.bootstrapLazy([["scout-list-view-item.cjs",[[529,"scout-list-view-item",{"icon":[1],"primary":[1],"secondary":[1],"type":[1],"href":[1],"target":[1],"rel":[1],"name":[1],"value":[1],"checked":[4],"disabled":[4]}]]],["scout-app-bar.cjs",[[785,"scout-app-bar",{"titleText":[1,"title-text"]}]]],["scout-bottom-bar.cjs",[[273,"scout-bottom-bar"]]],["scout-bottom-bar-item.cjs",[[529,"scout-bottom-bar-item",{"type":[1],"href":[1],"target":[1],"rel":[1],"icon":[1],"label":[1],"active":[4]}]]],["scout-button.cjs",[[772,"scout-button",{"type":[1],"href":[1],"target":[1],"rel":[1],"size":[1],"variant":[1],"icon":[1],"iconPosition":[1,"icon-position"],"iconOnly":[4,"icon-only"]}]]],["scout-card.cjs",[[273,"scout-card"]]],["scout-divider.cjs",[[17,"scout-divider"]]],["scout-field.cjs",[[774,"scout-field",{"label":[1],"helpText":[1,"help-text"],"inputId":[32],"errorText":[32],"errorHidden":[32]},[[0,"_scoutFieldId","catchFieldId"],[0,"_scoutValidityChanged","handleValidation"],[0,"scoutBlur","showError"],[0,"_scoutInvalid","showError"]]]]],["scout-input.cjs",[[514,"scout-input",{"validity":[1],"size":[1],"variant":[1],"type":[1],"inputmode":[1],"pattern":[1],"value":[1],"name":[1],"disabled":[4],"placeholder":[1],"ariaId":[32]},null,{"validity":[{"runValidation":0}]}]]],["scout-link.cjs",[[529,"scout-link",{"href":[1],"label":[1],"rel":[1],"linkAriaLabel":[1,"link-aria-label"],"type":[1],"target":[1]}]]],["scout-list-view.cjs",[[273,"scout-list-view",null,[[0,"scoutChecked","onScoutChecked"]]]]],["scout-list-view-subheader.cjs",[[529,"scout-list-view-subheader",{"text":[1],"headingLevel":[1,"heading-level"]}]]],["scout-loader.cjs",[[513,"scout-loader",{"text":[1],"size":[1]}]]],["scout-select.cjs",[[774,"scout-select",{"validity":[1],"value":[1],"disabled":[4],"name":[1],"ariaId":[32]},null,{"validity":[{"runValidation":0}]}]]],["scout-stack.cjs",[[785,"scout-stack",{"direction":[1],"gapSize":[1,"gap-size"]}]]],["scout-switch.cjs",[[529,"scout-switch",{"validity":[1],"toggled":[4],"disabled":[4],"ariaLabelledby":[1,"aria-labelledby"],"label":[1],"ariaId":[32]},null,{"validity":[{"runValidation":0}]}]]],["scout-tabs.cjs",[[785,"scout-tabs",{"value":[2],"widths":[32],"lefts":[32]},[[2,"click","handleClick"]],{"value":[{"updateChildrenClasses":0},{"calculateIndicatorSizes":0}]}]]],["scout-tabs-tab.cjs",[[273,"scout-tabs-tab"]]],["scout-checkbox_2.cjs",[[514,"scout-checkbox",{"validity":[1],"checked":[4],"disabled":[4],"ariaLabelledby":[1,"aria-labelledby"],"label":[1],"value":[1],"name":[1],"ariaId":[32]},null,{"validity":[{"runValidation":0}]}],[514,"scout-radio-button",{"validity":[1],"checked":[4],"disabled":[4],"ariaLabelledby":[1,"aria-labelledby"],"label":[1],"value":[1],"name":[1],"ariaId":[32]},null,{"validity":[{"runValidation":0}]}]]]], options);
22
22
  });
23
23
 
24
24
  exports.setNonce = index.setNonce;
@@ -17,7 +17,9 @@
17
17
  "components/radio-button/radio-button.js",
18
18
  "components/select/select.js",
19
19
  "components/stack/stack.js",
20
- "components/switch/switch.js"
20
+ "components/switch/switch.js",
21
+ "components/tabs/tabs.js",
22
+ "components/tabs-tab/tabs-tab.js"
21
23
  ],
22
24
  "compiler": {
23
25
  "name": "@stencil/core",
@@ -35,7 +35,7 @@ export class ScoutField {
35
35
  this.errorHidden = false;
36
36
  }
37
37
  render() {
38
- return (h("div", { key: 'e7539abfb11fac14a5ffd87cfb1a70dd9c41cca7', class: "field" }, h("label", { key: 'c4501be15aafbb2d6e3c447c5893aa2510e20b89', htmlFor: this.inputId, class: "label" }, this.label), h("slot", { key: '5806c8d41926245074fb395b08226272a2432d96' }), h("p", { key: 'f1a36881c2ce2f8485d31e8faac452c9c2423d74', class: "error-text", "aria-live": "polite" }, !this.errorHidden && this.errorText), this.helpText && h("p", { key: '0d9ea374551b527d085ef33595fdee27e80d08fb', class: "help-text" }, this.helpText)));
38
+ return (h("div", { key: 'b2b20acd9c1e41294bfbb8ce7e450e23142c5606', class: "field" }, h("label", { key: '7b375df7d5a5e4bbe44ae963775c58a6c27b5479', htmlFor: this.inputId, class: "label" }, this.label), h("slot", { key: 'c5783c044aa82977cd21a56df4f838af95bc0bf3' }), h("p", { key: '38df5a4f28432e046bb95fed66d6c1972e1d7adc', class: "error-text", "aria-live": "polite" }, !this.errorHidden && this.errorText), this.helpText && h("p", { key: '1f84da3fad92b45ac1cf3b8d1fad75276b7f8359', class: "help-text" }, this.helpText)));
39
39
  }
40
40
  static get is() { return "scout-field"; }
41
41
  static get encapsulation() { return "scoped"; }
@@ -107,7 +107,7 @@ export class ScoutField {
107
107
  "capture": false,
108
108
  "passive": false
109
109
  }, {
110
- "name": "_scoutValidate",
110
+ "name": "_scoutValidityChanged",
111
111
  "method": "handleValidation",
112
112
  "target": undefined,
113
113
  "capture": false,
@@ -21,7 +21,7 @@ export class ScoutSelect extends Mixin(inputMixin) {
21
21
  disabled = false;
22
22
  name;
23
23
  render() {
24
- return (h("div", { key: '12bf95188935ab6b11101c829970800199b53e9a', class: "select-wrapper" }, h("select", { key: '1c373cc25f6de17b7139baab0af69fd23adf3b85', id: this.ariaId, name: this.name, class: "select", disabled: this.disabled, onChange: () => this.onInput(), onBlur: () => this.onBlur(), onInvalid: () => this.onInvalid() }, h("slot", { key: '99f4430d6433e96c95651acba4ff0068235d1cb8' })), h("span", { key: '4f36424bd7395db03ea9caf10751cd570fc06853', class: "select-icon", style: { "--icon-chevron": `url(${chevronIcon})` }, "aria-hidden": "true" })));
24
+ return (h("div", { key: '12bf95188935ab6b11101c829970800199b53e9a', class: "select-wrapper" }, h("select", { key: '23b78d816a0f95c659ce2d97fadd7e7ca413c521', ref: (el) => this.setInputRef(el), id: this.ariaId, name: this.name, class: "select", disabled: this.disabled, onChange: () => this.onInput(), onBlur: () => this.onBlur(), onInvalid: () => this.onInvalid() }, h("slot", { key: '652f8938b7bc8c32e2a2976e024e36a07afc8f5a' })), h("span", { key: 'f2e2dd4d5266145c6a854a3e5610c887d7e1e259', class: "select-icon", style: { "--icon-chevron": `url(${chevronIcon})` }, "aria-hidden": "true" })));
25
25
  }
26
26
  static get is() { return "scout-select"; }
27
27
  static get encapsulation() { return "scoped"; }
@@ -0,0 +1,17 @@
1
+ :host {
2
+ position: relative;
3
+ width: 100%;
4
+ display: flex;
5
+ height: var(--spacing-12);
6
+ --tabs-indicator-height: 2px;
7
+ }
8
+
9
+ .indicator {
10
+ position: absolute;
11
+ bottom: 0;
12
+ left: 0;
13
+ width: 0;
14
+ height: var(--tabs-indicator-height);
15
+ background-color: var(--color-background-brand-base);
16
+ transition: all 0.3s ease;
17
+ }
@@ -0,0 +1,142 @@
1
+ import { Host, h, } from "@stencil/core";
2
+ /**
3
+ * The tabs component is used to create a tabbed interface. It manages the state
4
+ * of which tab is active and displays an indicator under the active tab. Use
5
+ * `ScoutTabsTab` components to define the individual tabs.
6
+ *
7
+ * Currently there is no support for navigational tabs. Navigation has to be
8
+ * handled programmatically for now.
9
+ */
10
+ export class ScoutTabs {
11
+ el;
12
+ /**
13
+ * Zero-based index of the currently active tab.
14
+ */
15
+ value = 0;
16
+ /**
17
+ * Emitted when the active tab changes as a result of a user click.
18
+ * The `value` in the event detail is the zero-based index of the newly selected tab.
19
+ */
20
+ scoutChange;
21
+ widths = [];
22
+ lefts = [];
23
+ render() {
24
+ return (h(Host, { key: 'dffbae0bba3543f50cbe7046bad52c7bdff7ba55' }, h("slot", { key: 'cad95b2ae6c8b2bc659bfa6510c0b193d2e08dd9' }), this.getIndicator()));
25
+ }
26
+ componentDidLoad() {
27
+ this.updateChildrenClasses();
28
+ this.calculateIndicatorSizes();
29
+ }
30
+ getIndicator() {
31
+ const width = this.widths[this.value] || 0;
32
+ const left = this.lefts[this.value] || 0;
33
+ const indicatorStyle = {
34
+ width: `${width}px`,
35
+ transform: `translateX(${left}px)`,
36
+ };
37
+ return h("div", { "aria-hidden": "true", class: "indicator", style: indicatorStyle });
38
+ }
39
+ handleClick(event) {
40
+ const target = event.target;
41
+ const tabs = Array.from(this.el.children);
42
+ const clickedIndex = tabs.indexOf(target);
43
+ if (clickedIndex !== -1 && clickedIndex !== this.value) {
44
+ this.scoutChange.emit({ value: clickedIndex });
45
+ }
46
+ }
47
+ updateChildrenClasses() {
48
+ Array.from(this.el.children).forEach((child, index) => {
49
+ const tab = child;
50
+ if (index === this.value) {
51
+ tab.setAttribute("data-active", "true");
52
+ }
53
+ else {
54
+ tab.removeAttribute("data-active");
55
+ }
56
+ });
57
+ }
58
+ calculateIndicatorSizes() {
59
+ this.widths = Array.from(this.el.children).map((child) => child.offsetWidth);
60
+ this.lefts = this.widths.map((_, index) => this.widths.slice(0, index).reduce((acc, w) => acc + w, 0));
61
+ }
62
+ static get is() { return "scout-tabs"; }
63
+ static get encapsulation() { return "shadow"; }
64
+ static get delegatesFocus() { return true; }
65
+ static get originalStyleUrls() {
66
+ return {
67
+ "$": ["tabs.css"]
68
+ };
69
+ }
70
+ static get styleUrls() {
71
+ return {
72
+ "$": ["tabs.css"]
73
+ };
74
+ }
75
+ static get properties() {
76
+ return {
77
+ "value": {
78
+ "type": "number",
79
+ "mutable": false,
80
+ "complexType": {
81
+ "original": "number",
82
+ "resolved": "number",
83
+ "references": {}
84
+ },
85
+ "required": false,
86
+ "optional": false,
87
+ "docs": {
88
+ "tags": [],
89
+ "text": "Zero-based index of the currently active tab."
90
+ },
91
+ "getter": false,
92
+ "setter": false,
93
+ "reflect": false,
94
+ "attribute": "value",
95
+ "defaultValue": "0"
96
+ }
97
+ };
98
+ }
99
+ static get states() {
100
+ return {
101
+ "widths": {},
102
+ "lefts": {}
103
+ };
104
+ }
105
+ static get events() {
106
+ return [{
107
+ "method": "scoutChange",
108
+ "name": "scoutChange",
109
+ "bubbles": true,
110
+ "cancelable": true,
111
+ "composed": true,
112
+ "docs": {
113
+ "tags": [],
114
+ "text": "Emitted when the active tab changes as a result of a user click.\nThe `value` in the event detail is the zero-based index of the newly selected tab."
115
+ },
116
+ "complexType": {
117
+ "original": "{ value: number }",
118
+ "resolved": "{ value: number; }",
119
+ "references": {}
120
+ }
121
+ }];
122
+ }
123
+ static get elementRef() { return "el"; }
124
+ static get watchers() {
125
+ return [{
126
+ "propName": "value",
127
+ "methodName": "updateChildrenClasses"
128
+ }, {
129
+ "propName": "value",
130
+ "methodName": "calculateIndicatorSizes"
131
+ }];
132
+ }
133
+ static get listeners() {
134
+ return [{
135
+ "name": "click",
136
+ "method": "handleClick",
137
+ "target": undefined,
138
+ "capture": true,
139
+ "passive": false
140
+ }];
141
+ }
142
+ }
@@ -0,0 +1,44 @@
1
+ :host {
2
+ flex: 1;
3
+ display: block;
4
+ width: auto;
5
+ }
6
+
7
+ .button-native {
8
+ position: relative;
9
+ display: block;
10
+ width: 100%;
11
+ height: 100%;
12
+ color: var(--color-gray-600);
13
+ background-color: transparent;
14
+ border: none;
15
+ cursor: pointer;
16
+ padding: var(--spacing-1) var(--spacing-1)
17
+ calc(var(--spacing-1) + var(--tabs-indicator-height)) var(--spacing-1);
18
+ font-weight: 500;
19
+ text-transform: uppercase;
20
+ font-size: 0.875rem;
21
+ letter-spacing: 0.04em;
22
+ }
23
+
24
+ .inner-container {
25
+ display: flex;
26
+ justify-content: center;
27
+ align-items: center;
28
+ width: 100%;
29
+ height: 100%;
30
+ border-radius: var(--spacing-2);
31
+ background-color: transparent;
32
+ }
33
+
34
+ .button-native:hover {
35
+ color: var(--color-text-base);
36
+ }
37
+
38
+ .button-native:hover .inner-container {
39
+ background-color: var(--color-background-brand-subtle-hovered);
40
+ }
41
+
42
+ :host([data-active]) .button-native {
43
+ color: var(--color-text-base);
44
+ }
@@ -0,0 +1,19 @@
1
+ import { h } from "@stencil/core";
2
+ export class ScoutTabsTab {
3
+ render() {
4
+ return (h("button", { key: '59f92f5a3d9b5a022a78d9adc7756bda10b68be3', class: "button-native", type: "button" }, h("div", { key: '96fc99711da308360451041dd44e21391c08d6eb', class: "inner-container" }, h("slot", { key: '83234bf67c2605179c7d80febbc6d0fbff730670' }))));
5
+ }
6
+ static get is() { return "scout-tabs-tab"; }
7
+ static get encapsulation() { return "shadow"; }
8
+ static get delegatesFocus() { return true; }
9
+ static get originalStyleUrls() {
10
+ return {
11
+ "$": ["tabs-tab.css"]
12
+ };
13
+ }
14
+ static get styleUrls() {
15
+ return {
16
+ "$": ["tabs-tab.css"]
17
+ };
18
+ }
19
+ }
@@ -4,17 +4,28 @@ export const inputMixin = (Base) => {
4
4
  super();
5
5
  }
6
6
  /**
7
- * Custom validation function run on top of the implicit validation performed
8
- * by the browser. Return a string with the validation message to mark the
9
- * input as invalid, or null to mark it as valid.
7
+ * Custom validation message. If set, the input is considered invalid by the
8
+ * browser, and if wrapped by a field component, the message is displayed.
9
+ * If not set, the input is considered valid.
10
+ */
11
+ validity;
12
+ /**
13
+ * Event emitted when the input value changes. If you want to do custom
14
+ * validation, use the `scoutValidate` event instead to ensure forms are
15
+ * blocked by the browser when invalid.
10
16
  */
11
- validate;
12
17
  scoutInputChange;
13
18
  scoutBlur;
19
+ /**
20
+ * Event emitted when the input needs to be validated. This is where you
21
+ * implement your custom validation. Set any possible validation message
22
+ * using the `validity` prop.
23
+ */
24
+ scoutValidate;
14
25
  /**
15
26
  * Internal event used for form field validation.
16
27
  */
17
- _scoutValidate;
28
+ _scoutValidityChanged;
18
29
  /**
19
30
  * Internal event used for form field validation.
20
31
  */
@@ -30,10 +41,10 @@ export const inputMixin = (Base) => {
30
41
  this._scoutFieldId.emit(this.ariaId);
31
42
  }
32
43
  componentDidLoad() {
33
- this.runValidation();
44
+ this.emitValidityEvent();
34
45
  }
35
46
  onInput() {
36
- this.runValidation();
47
+ this.emitValidityEvent();
37
48
  this.scoutInputChange.emit({
38
49
  value: this.inputElement.value,
39
50
  element: this.inputElement,
@@ -45,35 +56,39 @@ export const inputMixin = (Base) => {
45
56
  onInvalid() {
46
57
  this._scoutInvalid.emit();
47
58
  }
59
+ emitValidityEvent() {
60
+ this.scoutValidate.emit({
61
+ value: this.inputElement.value,
62
+ element: this.inputElement,
63
+ });
64
+ }
48
65
  runValidation() {
49
- if (!this.validate) {
50
- return;
51
- }
52
- const validationMessage = this.validate(this.inputElement.value);
53
- this.inputElement.setCustomValidity(validationMessage ?? "");
54
- this._scoutValidate.emit({ element: this.inputElement });
66
+ this.inputElement.setCustomValidity(this.validity ?? "");
67
+ this._scoutValidityChanged.emit({ element: this.inputElement });
55
68
  }
56
69
  setInputRef(el) {
57
70
  this.inputElement = el;
58
71
  }
59
72
  static get properties() {
60
73
  return {
61
- "validate": {
62
- "type": "unknown",
74
+ "validity": {
75
+ "type": "string",
63
76
  "mutable": false,
64
77
  "complexType": {
65
- "original": "(value: string) => string | null",
66
- "resolved": "(value: string) => string",
78
+ "original": "string",
79
+ "resolved": "string",
67
80
  "references": {}
68
81
  },
69
82
  "required": false,
70
83
  "optional": true,
71
84
  "docs": {
72
85
  "tags": [],
73
- "text": "Custom validation function run on top of the implicit validation performed\nby the browser. Return a string with the validation message to mark the\ninput as invalid, or null to mark it as valid."
86
+ "text": "Custom validation message. If set, the input is considered invalid by the\nbrowser, and if wrapped by a field component, the message is displayed.\nIf not set, the input is considered valid."
74
87
  },
75
88
  "getter": false,
76
- "setter": false
89
+ "setter": false,
90
+ "reflect": false,
91
+ "attribute": "validity"
77
92
  }
78
93
  };
79
94
  }
@@ -91,7 +106,7 @@ export const inputMixin = (Base) => {
91
106
  "composed": true,
92
107
  "docs": {
93
108
  "tags": [],
94
- "text": ""
109
+ "text": "Event emitted when the input value changes. If you want to do custom\nvalidation, use the `scoutValidate` event instead to ensure forms are\nblocked by the browser when invalid."
95
110
  },
96
111
  "complexType": {
97
112
  "original": "{\n value: string;\n element: HTMLElement;\n }",
@@ -119,8 +134,28 @@ export const inputMixin = (Base) => {
119
134
  "references": {}
120
135
  }
121
136
  }, {
122
- "method": "_scoutValidate",
123
- "name": "_scoutValidate",
137
+ "method": "scoutValidate",
138
+ "name": "scoutValidate",
139
+ "bubbles": true,
140
+ "cancelable": true,
141
+ "composed": true,
142
+ "docs": {
143
+ "tags": [],
144
+ "text": "Event emitted when the input needs to be validated. This is where you\nimplement your custom validation. Set any possible validation message\nusing the `validity` prop."
145
+ },
146
+ "complexType": {
147
+ "original": "{\n value: string;\n element: HTMLElement;\n }",
148
+ "resolved": "{ value: string; element: HTMLElement; }",
149
+ "references": {
150
+ "HTMLElement": {
151
+ "location": "global",
152
+ "id": "global::HTMLElement"
153
+ }
154
+ }
155
+ }
156
+ }, {
157
+ "method": "_scoutValidityChanged",
158
+ "name": "_scoutValidityChanged",
124
159
  "bubbles": true,
125
160
  "cancelable": true,
126
161
  "composed": true,
@@ -170,6 +205,12 @@ export const inputMixin = (Base) => {
170
205
  }
171
206
  }];
172
207
  }
208
+ static get watchers() {
209
+ return [{
210
+ "propName": "validity",
211
+ "methodName": "runValidation"
212
+ }];
213
+ }
173
214
  }
174
215
  return InputMixin;
175
216
  };
@@ -1 +1 @@
1
- export{g as getAssetPath,r as render,s as setAssetPath,a as setNonce,b as setPlatformOptions}from"./p-CmHrcz9s.js";function t(s,t,e){return(s||"")+(t?" "+t:"")+(e?" "+e:"")}export{t as format}
1
+ export{g as getAssetPath,r as render,s as setAssetPath,a as setNonce,b as setPlatformOptions}from"./p-CXXyN7aY.js";function t(s,t,e){return(s||"")+(t?" "+t:"")+(e?" "+e:"")}export{t as format}
@@ -0,0 +1 @@
1
+ import{p as o,M as a,c as t,h as e,t as r}from"./p-CXXyN7aY.js";import{i as s}from"./p-DxVqa2PR.js";const i=o(class extends(a(s)){constructor(o){super(!1),!1!==o&&this.__registerHost(),this.scoutInputChange=t(this,"scoutInputChange"),this.scoutBlur=t(this,"scoutBlur"),this.scoutValidate=t(this,"scoutValidate"),this._scoutValidityChanged=t(this,"_scoutValidityChanged"),this._scoutInvalid=t(this,"_scoutInvalid"),this._scoutFieldId=t(this,"_scoutFieldId"),this.scoutChecked=t(this,"scoutChecked")}checked=!1;disabled=!1;ariaLabelledby;label;value;name;scoutChecked;onChange(o){const a=o.target;this.scoutChecked.emit({checked:a.checked,element:a})}render(){return e(this.label?.length?"label":"div",{key:"22df090dcbf2f2b4b14b7cad8d34500295045f70"},e("input",{key:"3bcc5022fa6202fd1fe733c1a8430f7ed1a54cf4",ref:o=>this.setInputRef(o),id:this.ariaId,type:"radio",value:this.value,name:this.name,class:"radio","aria-labelledby":this.ariaLabelledby,"aria-disabled":this.disabled,disabled:this.disabled,checked:this.checked,onChange:o=>{this.onInput(),this.onChange(o)},onBlur:()=>this.onBlur(),onInvalid:()=>this.onInvalid()}),this.label)}static get watchers(){return{validity:[{runValidation:0}]}}static get style(){return'.radio.sc-scout-radio-button{width:var(--spacing-6);height:var(--spacing-6);-moz-appearance:none;appearance:none;-webkit-appearance:none;display:flex;align-content:center;justify-content:center;border-radius:100%;background-color:var(--color-white);border:2px solid var(--color-gray-300);position:relative}@media (hover: hover){.radio.sc-scout-radio-button:hover{border:2px solid var(--color-gray-400);box-shadow:inset 0px 0px 5px 5px var(--color-background-brand-subtle-hovered);cursor:pointer}}.radio.sc-scout-radio-button:active{background-color:var(--color-background-brand-subtle-pressed)}@media (hover: hover){.radio.sc-scout-radio-button:checked:hover{border-color:var(--color-background-brand-hovered);box-shadow:none}.radio.sc-scout-radio-button:checked:hover::before{background-color:var(--color-background-brand-hovered)}}.radio.sc-scout-radio-button:checked{border-color:var(--color-background-brand-base)}.radio.sc-scout-radio-button::after{content:"";position:absolute;width:var(--spacing-10);height:var(--spacing-10);top:50%;left:50%;transform:translate(-50%, -50%)}.radio.sc-scout-radio-button:checked::before{content:"";background-color:var(--color-background-brand-base);width:var(--spacing-4);height:var(--spacing-4);position:absolute;top:50%;left:50%;transform:translate(-50%, -50%);border-radius:100%}.radio.sc-scout-radio-button:disabled{pointer-events:none;background-color:var(--color-gray-100);border-color:var(--color-gray-100)}label.sc-scout-radio-button{display:flex;align-items:center;gap:var(--spacing-2);font:var(--type-label-base);color:var(--color-text-base)}'}},[514,"scout-radio-button",{validity:[1],checked:[4],disabled:[4],ariaLabelledby:[1,"aria-labelledby"],label:[1],value:[1],name:[1],ariaId:[32]},void 0,{validity:[{runValidation:0}]}]);function c(){"undefined"!=typeof customElements&&["scout-radio-button"].forEach((o=>{"scout-radio-button"===o&&(customElements.get(r(o))||customElements.define(r(o),i))}))}export{i as S,c as d}