@aurodesignsystem-dev/auro-formkit 0.0.0-pr649.6 → 0.0.0-pr657.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.
@@ -5,6 +5,7 @@ import { valueAlertExample } from "../apiExamples/valueAlert.js";
5
5
  import { inDialogExample } from '../apiExamples/inDialog';
6
6
  import { resetStateExample } from "../apiExamples/resetState";
7
7
  import { auroMenuLoadingExample } from "../apiExamples/loading";
8
+ import { valueTextExample } from '../apiExamples/valueText.js';
8
9
 
9
10
  /* eslint-disable jsdoc/require-jsdoc, no-magic-numbers, no-param-reassign */
10
11
  import { AuroSelect } from '../src/auro-select.js';
@@ -24,6 +25,7 @@ export function initExamples(initCount) {
24
25
  inDialogExample();
25
26
  resetStateExample();
26
27
  auroMenuLoadingExample();
28
+ valueTextExample();
27
29
  } catch (err) {
28
30
  if (initCount <= 20) {
29
31
  // setTimeout handles issue where content is sometimes loaded after the functions get called
@@ -48,11 +48,11 @@ The auro-select element is a wrapper for auro-dropdown and auro-menu to create a
48
48
 
49
49
  ## Events
50
50
 
51
- | Event | Type | Description |
52
- |-----------------------------|--------------------|--------------------------------------------------|
53
- | `auroFormElement-validated` | | Notifies that the `validity` and `errorMessage` values have changed. |
54
- | `auroSelect-valueSet` | `CustomEvent<any>` | Notifies that the component has a new value set. |
55
- | [input](#input) | `CustomEvent<any>` | Notifies every time the value prop of the element is changed. |
51
+ | Event | Type | Description |
52
+ |-----------------------------|--------------------------------------------------|--------------------------------------------------|
53
+ | `auroFormElement-validated` | | Notifies that the `validity` and `errorMessage` values have changed. |
54
+ | `auroSelect-valueSet` | `CustomEvent<any>` | Notifies that the component has a new value set. |
55
+ | [input](#input) | `CustomEvent<{ optionSelected: any; value: any; }>` | Notifies every time the value prop of the element is changed. The updated `value` and `optionSelected` will be deleiverd in `detail` object. |
56
56
 
57
57
  ## Slots
58
58
 
@@ -62,7 +62,8 @@ The auro-select element is a wrapper for auro-dropdown and auro-menu to create a
62
62
  | `bib.fullscreen.headline` | Defines the headline to display above menu-options |
63
63
  | [helpText](#helpText) | Defines the content of the helpText. |
64
64
  | [label](#label) | Defines the content of the label. |
65
- | [placeholder](#placeholder) | Defines the content of the placeholder to be shown when there is no value |
65
+ | [placeholder](#placeholder) | Defines the content of the placeholder to be shown when there is no value |
66
+ | [valueText](#valueText) | Dropdown value text display. |
66
67
 
67
68
  ## CSS Shadow Parts
68
69
 
@@ -1033,6 +1034,63 @@ export function auroMenuLoadingExample() {
1033
1034
  <!-- AURO-GENERATED-CONTENT:END -->
1034
1035
  </auro-accordion>
1035
1036
 
1037
+ ### valueText <a name="valueText"></a>
1038
+ The label for selected option can be customized using `valueText` slot.
1039
+ This slot can be manipulated on `input` event which deleivers new value and selected `auro-menuoption` element in `detail` object.
1040
+
1041
+ <div class="exampleWrapper">
1042
+ <!-- AURO-GENERATED-CONTENT:START (FILE:src=./../apiExamples/valueText.html) -->
1043
+ <!-- The below content is automatically added from ./../apiExamples/valueText.html -->
1044
+ <auro-select id="valueTextExample" autocomplete="address-level1">
1045
+ <span slot="bib.fullscreen.headline">Select Your Gender</span>
1046
+ <span slot="label">Gender</span>
1047
+ <span slot="valueText"></span>
1048
+ <auro-menu>
1049
+ <auro-menuoption value="m" data-display="Male">M - Male</auro-menuoption>
1050
+ <auro-menuoption value="f" data-display="Female">F - Female</auro-menuoption>
1051
+ <auro-menuoption value="x" data-display="Unspecified">X - Unspecified</auro-menuoption>
1052
+ <auro-menuoption value="u" data-display="Undisclosed">U - Undisclosed</auro-menuoption>
1053
+ </auro-menu>
1054
+ </auro-select>
1055
+ <!-- AURO-GENERATED-CONTENT:END -->
1056
+ </div>
1057
+ <auro-accordion alignRight>
1058
+ <span slot="trigger">See code</span>
1059
+ <!-- AURO-GENERATED-CONTENT:START (CODE:src=./../apiExamples/valueText.js) -->
1060
+ <!-- The below code snippet is automatically added from ./../apiExamples/valueText.js -->
1061
+
1062
+ ```js
1063
+ export function valueTextExample() {
1064
+ const onValueTextSelectInput = (e) => {
1065
+ const valueText = e.target.querySelector("[slot=valueText]");
1066
+
1067
+ valueText.textContent = e.detail.optionSelected.dataset.display;
1068
+ };
1069
+
1070
+ const select = document.querySelector("#valueTextExample");
1071
+ select.addEventListener('input', onValueTextSelectInput);
1072
+ }
1073
+ ```
1074
+ <!-- AURO-GENERATED-CONTENT:END -->
1075
+ <!-- AURO-GENERATED-CONTENT:START (CODE:src=./../apiExamples/valueText.html) -->
1076
+ <!-- The below code snippet is automatically added from ./../apiExamples/valueText.html -->
1077
+
1078
+ ```html
1079
+ <auro-select id="valueTextExample" autocomplete="address-level1">
1080
+ <span slot="bib.fullscreen.headline">Select Your Gender</span>
1081
+ <span slot="label">Gender</span>
1082
+ <span slot="valueText"></span>
1083
+ <auro-menu>
1084
+ <auro-menuoption value="m" data-display="Male">M - Male</auro-menuoption>
1085
+ <auro-menuoption value="f" data-display="Female">F - Female</auro-menuoption>
1086
+ <auro-menuoption value="x" data-display="Unspecified">X - Unspecified</auro-menuoption>
1087
+ <auro-menuoption value="u" data-display="Undisclosed">U - Undisclosed</auro-menuoption>
1088
+ </auro-menu>
1089
+ </auro-select>
1090
+ ```
1091
+ <!-- AURO-GENERATED-CONTENT:END -->
1092
+ </auro-accordion>
1093
+
1036
1094
  ### Customized bib position
1037
1095
  The bib position can be customized with `placement`, `offset`, `flip`, `autoPlacement` attributes.
1038
1096
 
@@ -90,6 +90,17 @@ function auroMenuLoadingExample() {
90
90
  });
91
91
  }
92
92
 
93
+ function valueTextExample() {
94
+ const onValueTextSelectInput = (e) => {
95
+ const valueText = e.target.querySelector("[slot=valueText]");
96
+
97
+ valueText.textContent = e.detail.optionSelected.dataset.display;
98
+ };
99
+
100
+ const select = document.querySelector("#valueTextExample");
101
+ select.addEventListener('input', onValueTextSelectInput);
102
+ }
103
+
93
104
  /**
94
105
  * @license
95
106
  * Copyright 2019 Google LLC
@@ -5537,8 +5548,9 @@ var styleCss$3 = i$5`:focus:not(:focus-visible){outline:3px solid transparent}.u
5537
5548
  * @slot label - Defines the content of the label.
5538
5549
  * @slot helpText - Defines the content of the helpText.
5539
5550
  * @slot placeholder - Defines the content of the placeholder to be shown when there is no value
5551
+ * @slot valueText - Dropdown value text display.
5540
5552
  * @event auroSelect-valueSet - Notifies that the component has a new value set.
5541
- * @event input - Notifies every time the value prop of the element is changed.
5553
+ * @event input - Notifies every time the value prop of the element is changed. The updated `value` and `optionSelected` will be deleiverd in `detail` object.
5542
5554
  * @event auroFormElement-validated - Notifies that the `validity` and `errorMessage` values have changed.
5543
5555
  * @csspart helpText - Apply CSS to the help text.
5544
5556
  */
@@ -5880,12 +5892,8 @@ class AuroSelect extends i$2 {
5880
5892
  updateDisplayedValue() {
5881
5893
  const triggerContentEl = this.dropdown.querySelector('#triggerFocus');
5882
5894
 
5883
- // Clear everything except placeholder
5884
- const placeholder = triggerContentEl.querySelector('#placeholder');
5885
- triggerContentEl.innerHTML = '';
5886
- if (placeholder) {
5887
- triggerContentEl.appendChild(placeholder);
5888
- }
5895
+ const valueText = triggerContentEl.querySelector("#valueText");
5896
+ valueText.textContent = '';
5889
5897
 
5890
5898
  // Handle selected options
5891
5899
  if (this.optionSelected) {
@@ -5898,9 +5906,7 @@ class AuroSelect extends i$2 {
5898
5906
  displayText = this.optionSelected.textContent;
5899
5907
  }
5900
5908
 
5901
- const span = document.createElement('span');
5902
- span.textContent = displayText;
5903
- triggerContentEl.appendChild(span);
5909
+ valueText.textContent = displayText;
5904
5910
  }
5905
5911
 
5906
5912
  this.dropdown.requestUpdate();
@@ -6229,6 +6235,10 @@ class AuroSelect extends i$2 {
6229
6235
  bubbles: true,
6230
6236
  cancelable: true,
6231
6237
  composed: true,
6238
+ detail: {
6239
+ optionSelected: this.optionSelected,
6240
+ value: this.value
6241
+ }
6232
6242
  }));
6233
6243
  }
6234
6244
 
@@ -6357,7 +6367,13 @@ class AuroSelect extends i$2 {
6357
6367
  ?noFlip="${this.noFlip}"
6358
6368
  part="dropdown">
6359
6369
  <span slot="trigger" aria-haspopup="true" id="triggerFocus">
6360
- <span id="placeholder" class="${e(placeholderClass)}"><slot name="placeholder"></slot></span>
6370
+ <span id="placeholder"
6371
+ class="${e(placeholderClass)}"
6372
+ ?aria-hidden="${this.optionSelected && this.optionSelected.length ? 'true' : false}"
6373
+ >
6374
+ <slot name="placeholder"></slot>
6375
+ </span>
6376
+ <slot name="valueText" id="valueText"></slot>
6361
6377
  </span>
6362
6378
 
6363
6379
  <div class="menuWrapper">
@@ -7650,6 +7666,7 @@ function initExamples(initCount) {
7650
7666
  inDialogExample();
7651
7667
  resetStateExample();
7652
7668
  auroMenuLoadingExample();
7669
+ valueTextExample();
7653
7670
  } catch (err) {
7654
7671
  if (initCount <= 20) {
7655
7672
  // setTimeout handles issue where content is sometimes loaded after the functions get called
@@ -5445,8 +5445,9 @@ var styleCss$3 = i$5`:focus:not(:focus-visible){outline:3px solid transparent}.u
5445
5445
  * @slot label - Defines the content of the label.
5446
5446
  * @slot helpText - Defines the content of the helpText.
5447
5447
  * @slot placeholder - Defines the content of the placeholder to be shown when there is no value
5448
+ * @slot valueText - Dropdown value text display.
5448
5449
  * @event auroSelect-valueSet - Notifies that the component has a new value set.
5449
- * @event input - Notifies every time the value prop of the element is changed.
5450
+ * @event input - Notifies every time the value prop of the element is changed. The updated `value` and `optionSelected` will be deleiverd in `detail` object.
5450
5451
  * @event auroFormElement-validated - Notifies that the `validity` and `errorMessage` values have changed.
5451
5452
  * @csspart helpText - Apply CSS to the help text.
5452
5453
  */
@@ -5788,12 +5789,8 @@ class AuroSelect extends i$2 {
5788
5789
  updateDisplayedValue() {
5789
5790
  const triggerContentEl = this.dropdown.querySelector('#triggerFocus');
5790
5791
 
5791
- // Clear everything except placeholder
5792
- const placeholder = triggerContentEl.querySelector('#placeholder');
5793
- triggerContentEl.innerHTML = '';
5794
- if (placeholder) {
5795
- triggerContentEl.appendChild(placeholder);
5796
- }
5792
+ const valueText = triggerContentEl.querySelector("#valueText");
5793
+ valueText.textContent = '';
5797
5794
 
5798
5795
  // Handle selected options
5799
5796
  if (this.optionSelected) {
@@ -5806,9 +5803,7 @@ class AuroSelect extends i$2 {
5806
5803
  displayText = this.optionSelected.textContent;
5807
5804
  }
5808
5805
 
5809
- const span = document.createElement('span');
5810
- span.textContent = displayText;
5811
- triggerContentEl.appendChild(span);
5806
+ valueText.textContent = displayText;
5812
5807
  }
5813
5808
 
5814
5809
  this.dropdown.requestUpdate();
@@ -6137,6 +6132,10 @@ class AuroSelect extends i$2 {
6137
6132
  bubbles: true,
6138
6133
  cancelable: true,
6139
6134
  composed: true,
6135
+ detail: {
6136
+ optionSelected: this.optionSelected,
6137
+ value: this.value
6138
+ }
6140
6139
  }));
6141
6140
  }
6142
6141
 
@@ -6265,7 +6264,13 @@ class AuroSelect extends i$2 {
6265
6264
  ?noFlip="${this.noFlip}"
6266
6265
  part="dropdown">
6267
6266
  <span slot="trigger" aria-haspopup="true" id="triggerFocus">
6268
- <span id="placeholder" class="${e(placeholderClass)}"><slot name="placeholder"></slot></span>
6267
+ <span id="placeholder"
6268
+ class="${e(placeholderClass)}"
6269
+ ?aria-hidden="${this.optionSelected && this.optionSelected.length ? 'true' : false}"
6270
+ >
6271
+ <slot name="placeholder"></slot>
6272
+ </span>
6273
+ <slot name="valueText" id="valueText"></slot>
6269
6274
  </span>
6270
6275
 
6271
6276
  <div class="menuWrapper">
@@ -6,8 +6,9 @@
6
6
  * @slot label - Defines the content of the label.
7
7
  * @slot helpText - Defines the content of the helpText.
8
8
  * @slot placeholder - Defines the content of the placeholder to be shown when there is no value
9
+ * @slot valueText - Dropdown value text display.
9
10
  * @event auroSelect-valueSet - Notifies that the component has a new value set.
10
- * @event input - Notifies every time the value prop of the element is changed.
11
+ * @event input - Notifies every time the value prop of the element is changed. The updated `value` and `optionSelected` will be deleiverd in `detail` object.
11
12
  * @event auroFormElement-validated - Notifies that the `validity` and `errorMessage` values have changed.
12
13
  * @csspart helpText - Apply CSS to the help text.
13
14
  */
@@ -5399,8 +5399,9 @@ var styleCss = css`:focus:not(:focus-visible){outline:3px solid transparent}.uti
5399
5399
  * @slot label - Defines the content of the label.
5400
5400
  * @slot helpText - Defines the content of the helpText.
5401
5401
  * @slot placeholder - Defines the content of the placeholder to be shown when there is no value
5402
+ * @slot valueText - Dropdown value text display.
5402
5403
  * @event auroSelect-valueSet - Notifies that the component has a new value set.
5403
- * @event input - Notifies every time the value prop of the element is changed.
5404
+ * @event input - Notifies every time the value prop of the element is changed. The updated `value` and `optionSelected` will be deleiverd in `detail` object.
5404
5405
  * @event auroFormElement-validated - Notifies that the `validity` and `errorMessage` values have changed.
5405
5406
  * @csspart helpText - Apply CSS to the help text.
5406
5407
  */
@@ -5742,12 +5743,8 @@ class AuroSelect extends LitElement {
5742
5743
  updateDisplayedValue() {
5743
5744
  const triggerContentEl = this.dropdown.querySelector('#triggerFocus');
5744
5745
 
5745
- // Clear everything except placeholder
5746
- const placeholder = triggerContentEl.querySelector('#placeholder');
5747
- triggerContentEl.innerHTML = '';
5748
- if (placeholder) {
5749
- triggerContentEl.appendChild(placeholder);
5750
- }
5746
+ const valueText = triggerContentEl.querySelector("#valueText");
5747
+ valueText.textContent = '';
5751
5748
 
5752
5749
  // Handle selected options
5753
5750
  if (this.optionSelected) {
@@ -5760,9 +5757,7 @@ class AuroSelect extends LitElement {
5760
5757
  displayText = this.optionSelected.textContent;
5761
5758
  }
5762
5759
 
5763
- const span = document.createElement('span');
5764
- span.textContent = displayText;
5765
- triggerContentEl.appendChild(span);
5760
+ valueText.textContent = displayText;
5766
5761
  }
5767
5762
 
5768
5763
  this.dropdown.requestUpdate();
@@ -6091,6 +6086,10 @@ class AuroSelect extends LitElement {
6091
6086
  bubbles: true,
6092
6087
  cancelable: true,
6093
6088
  composed: true,
6089
+ detail: {
6090
+ optionSelected: this.optionSelected,
6091
+ value: this.value
6092
+ }
6094
6093
  }));
6095
6094
  }
6096
6095
 
@@ -6219,7 +6218,13 @@ class AuroSelect extends LitElement {
6219
6218
  ?noFlip="${this.noFlip}"
6220
6219
  part="dropdown">
6221
6220
  <span slot="trigger" aria-haspopup="true" id="triggerFocus">
6222
- <span id="placeholder" class="${classMap(placeholderClass)}"><slot name="placeholder"></slot></span>
6221
+ <span id="placeholder"
6222
+ class="${classMap(placeholderClass)}"
6223
+ ?aria-hidden="${this.optionSelected && this.optionSelected.length ? 'true' : false}"
6224
+ >
6225
+ <slot name="placeholder"></slot>
6226
+ </span>
6227
+ <slot name="valueText" id="valueText"></slot>
6223
6228
  </span>
6224
6229
 
6225
6230
  <div class="menuWrapper">
@@ -5399,8 +5399,9 @@ var styleCss = css`:focus:not(:focus-visible){outline:3px solid transparent}.uti
5399
5399
  * @slot label - Defines the content of the label.
5400
5400
  * @slot helpText - Defines the content of the helpText.
5401
5401
  * @slot placeholder - Defines the content of the placeholder to be shown when there is no value
5402
+ * @slot valueText - Dropdown value text display.
5402
5403
  * @event auroSelect-valueSet - Notifies that the component has a new value set.
5403
- * @event input - Notifies every time the value prop of the element is changed.
5404
+ * @event input - Notifies every time the value prop of the element is changed. The updated `value` and `optionSelected` will be deleiverd in `detail` object.
5404
5405
  * @event auroFormElement-validated - Notifies that the `validity` and `errorMessage` values have changed.
5405
5406
  * @csspart helpText - Apply CSS to the help text.
5406
5407
  */
@@ -5742,12 +5743,8 @@ class AuroSelect extends LitElement {
5742
5743
  updateDisplayedValue() {
5743
5744
  const triggerContentEl = this.dropdown.querySelector('#triggerFocus');
5744
5745
 
5745
- // Clear everything except placeholder
5746
- const placeholder = triggerContentEl.querySelector('#placeholder');
5747
- triggerContentEl.innerHTML = '';
5748
- if (placeholder) {
5749
- triggerContentEl.appendChild(placeholder);
5750
- }
5746
+ const valueText = triggerContentEl.querySelector("#valueText");
5747
+ valueText.textContent = '';
5751
5748
 
5752
5749
  // Handle selected options
5753
5750
  if (this.optionSelected) {
@@ -5760,9 +5757,7 @@ class AuroSelect extends LitElement {
5760
5757
  displayText = this.optionSelected.textContent;
5761
5758
  }
5762
5759
 
5763
- const span = document.createElement('span');
5764
- span.textContent = displayText;
5765
- triggerContentEl.appendChild(span);
5760
+ valueText.textContent = displayText;
5766
5761
  }
5767
5762
 
5768
5763
  this.dropdown.requestUpdate();
@@ -6091,6 +6086,10 @@ class AuroSelect extends LitElement {
6091
6086
  bubbles: true,
6092
6087
  cancelable: true,
6093
6088
  composed: true,
6089
+ detail: {
6090
+ optionSelected: this.optionSelected,
6091
+ value: this.value
6092
+ }
6094
6093
  }));
6095
6094
  }
6096
6095
 
@@ -6219,7 +6218,13 @@ class AuroSelect extends LitElement {
6219
6218
  ?noFlip="${this.noFlip}"
6220
6219
  part="dropdown">
6221
6220
  <span slot="trigger" aria-haspopup="true" id="triggerFocus">
6222
- <span id="placeholder" class="${classMap(placeholderClass)}"><slot name="placeholder"></slot></span>
6221
+ <span id="placeholder"
6222
+ class="${classMap(placeholderClass)}"
6223
+ ?aria-hidden="${this.optionSelected && this.optionSelected.length ? 'true' : false}"
6224
+ >
6225
+ <slot name="placeholder"></slot>
6226
+ </span>
6227
+ <slot name="valueText" id="valueText"></slot>
6223
6228
  </span>
6224
6229
 
6225
6230
  <div class="menuWrapper">
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aurodesignsystem-dev/auro-formkit",
3
- "version": "0.0.0-pr649.6",
3
+ "version": "0.0.0-pr657.0",
4
4
  "description": "A collection of web components used to build forms.",
5
5
  "homepage": "https://github.com/AlaskaAirlines/auro-formkit#readme",
6
6
  "bugs": {