@lion/ui 0.7.4 → 0.7.5

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 (59) hide show
  1. package/components/form/src/LionForm.js +11 -2
  2. package/components/form/test/lion-form.test.js +21 -2
  3. package/custom-elements.json +30 -30
  4. package/dist-types/components/form/src/LionForm.d.ts.map +1 -1
  5. package/dist-types/components/form/test/lion-form.test.d.ts.map +1 -1
  6. package/dist-types/tsconfig.tsbuildinfo +1 -1
  7. package/docs/components/checkbox-group/overview.md +2 -2
  8. package/docs/components/collapsible/overview.md +1 -1
  9. package/docs/components/combobox/overview.md +1 -1
  10. package/docs/components/combobox/use-cases.md +1 -1
  11. package/docs/components/dialog/overview.md +1 -1
  12. package/docs/components/fieldset/overview.md +5 -5
  13. package/docs/components/form/overview.md +3 -3
  14. package/docs/components/icon/use-cases.md +1 -1
  15. package/docs/components/input/overview.md +1 -1
  16. package/docs/components/input-amount/overview.md +3 -3
  17. package/docs/components/input-date/overview.md +3 -3
  18. package/docs/components/input-datepicker/overview.md +5 -5
  19. package/docs/components/input-email/overview.md +2 -2
  20. package/docs/components/input-file/overview.md +1 -1
  21. package/docs/components/input-iban/overview.md +2 -2
  22. package/docs/components/input-range/overview.md +2 -2
  23. package/docs/components/input-stepper/overview.md +1 -1
  24. package/docs/components/input-tel/overview.md +1 -1
  25. package/docs/components/input-tel/use-cases.md +6 -6
  26. package/docs/components/input-tel-dropdown/overview.md +1 -1
  27. package/docs/components/listbox/use-cases.md +1 -1
  28. package/docs/components/radio-group/overview.md +3 -3
  29. package/docs/components/select/use-cases.md +1 -1
  30. package/docs/components/select-rich/use-cases.md +1 -1
  31. package/docs/components/tabs/examples.md +1 -1
  32. package/docs/fundamentals/index.md +4 -4
  33. package/docs/fundamentals/node-tools/providence-analytics/LocalConfiguration.md +1 -1
  34. package/docs/fundamentals/node-tools/providence-analytics/QueryResult.md +1 -1
  35. package/docs/fundamentals/node-tools/providence-analytics/analyzer.md +1 -1
  36. package/docs/fundamentals/node-tools/providence-analytics/dashboard.md +1 -1
  37. package/docs/fundamentals/node-tools/providence-analytics/overview.md +3 -3
  38. package/docs/fundamentals/node-tools/publish-docs/overview.md +3 -3
  39. package/docs/fundamentals/node-tools/rocket-preset-extend-lion-docs/overview.md +2 -2
  40. package/docs/fundamentals/rationales/accessibility.md +1 -1
  41. package/docs/fundamentals/systems/core/SlotMixin.md +1 -1
  42. package/docs/fundamentals/systems/core/overview.md +1 -1
  43. package/docs/fundamentals/systems/form/formatting-and-parsing.md +4 -4
  44. package/docs/fundamentals/systems/form/model-value.md +1 -1
  45. package/docs/fundamentals/systems/form/overview.md +28 -28
  46. package/docs/fundamentals/systems/form/validate.md +2 -2
  47. package/docs/fundamentals/systems/localize/overview.md +4 -4
  48. package/docs/fundamentals/systems/overlays/configuration.md +2 -2
  49. package/docs/fundamentals/systems/overlays/overview.md +5 -5
  50. package/docs/fundamentals/systems/overlays/use-cases.md +2 -2
  51. package/docs/fundamentals/tools/helpers/overview.md +1 -1
  52. package/docs/fundamentals/tools/singleton-manager/overview.md +4 -4
  53. package/docs/guides/how-to/create-a-custom-field.md +5 -5
  54. package/docs/guides/how-to/create-a-form.md +4 -4
  55. package/docs/guides/how-to/extend-a-native-input.md +2 -2
  56. package/docs/guides/index.md +8 -8
  57. package/docs/guides/principles/index.md +5 -5
  58. package/docs/guides/principles/styling.md +1 -1
  59. package/package.json +1 -1
@@ -10,6 +10,15 @@ const throwFormNodeError = () => {
10
10
  );
11
11
  };
12
12
 
13
+ /**
14
+ * @param {FormRegistrarHost} formEl
15
+ * @returns {boolean}
16
+ */
17
+ function hasFocusableChildren(formEl) {
18
+ // this implies all children have the same type (either all of them are focusable or none of them are)
19
+ return formEl.formElements?.some(child => child._focusableNode);
20
+ }
21
+
13
22
  /**
14
23
  * LionForm: form wrapper providing extra features and integration with lion-field elements.
15
24
  *
@@ -63,7 +72,7 @@ export class LionForm extends LionFieldset {
63
72
  this.dispatchEvent(new Event('submit', { bubbles: true }));
64
73
 
65
74
  if (this.hasFeedbackFor?.includes('error')) {
66
- this._setFocusOnFirstErroneousFormElement(this);
75
+ this._setFocusOnFirstErroneousFormElement(/** @type { * & FormRegistrarHost } */ (this));
67
76
  }
68
77
  }
69
78
 
@@ -95,7 +104,7 @@ export class LionForm extends LionFieldset {
95
104
  element.formElements.find(child => child.hasFeedbackFor.includes('error')) ||
96
105
  element.formElements[0];
97
106
 
98
- if (firstFormElWithError.formElements?.length > 0) {
107
+ if (hasFocusableChildren(firstFormElWithError)) {
99
108
  this._setFocusOnFirstErroneousFormElement(firstFormElWithError);
100
109
  } else {
101
110
  firstFormElWithError._focusableNode.focus();
@@ -3,7 +3,8 @@ import '@lion/ui/define/lion-fieldset.js';
3
3
  import { LionField, Required } from '@lion/ui/form-core.js';
4
4
  import '@lion/ui/define/lion-field.js';
5
5
  import '@lion/ui/define/lion-validation-feedback.js';
6
-
6
+ import '@lion/ui/define/lion-listbox.js';
7
+ import '@lion/ui/define/lion-option.js';
7
8
  import '@lion/ui/define/lion-form.js';
8
9
  import {
9
10
  aTimeout,
@@ -223,7 +224,7 @@ describe('<lion-form>', () => {
223
224
  expect(document.activeElement).to.equal(el.formElements[1]._inputNode);
224
225
  });
225
226
 
226
- it('sets focus on submit to the first erroneous form element with a fieldset', async () => {
227
+ it('sets focus on submit to the first erroneous form element within a fieldset', async () => {
227
228
  const el = await fixture(html`
228
229
  <lion-form>
229
230
  <form>
@@ -266,4 +267,22 @@ describe('<lion-form>', () => {
266
267
  // @ts-ignore [allow-protected] in test
267
268
  expect(document.activeElement).to.equal(fieldset.formElements[0]._inputNode);
268
269
  });
270
+
271
+ it('sets focus on submit to the first form element within a erroneous listbox', async () => {
272
+ const el = await fixture(html`
273
+ <lion-form>
274
+ <form>
275
+ <lion-listbox name="name" .validators="${[new Required()]}">
276
+ <lion-option value="a">a</lion-option>
277
+ <lion-option value="b">b</lion-option>
278
+ </lion-listbox>
279
+ <button type="submit">submit</button>
280
+ </form>
281
+ </lion-form>
282
+ `);
283
+ const button = /** @type {HTMLButtonElement} */ (el.querySelector('button'));
284
+ button.click();
285
+ const listboxEl = el.formElements[0];
286
+ expect(document.activeElement).to.equal(listboxEl._inputNode);
287
+ });
269
288
  });
@@ -2100,36 +2100,6 @@
2100
2100
  }
2101
2101
  ]
2102
2102
  },
2103
- {
2104
- "kind": "javascript-module",
2105
- "path": "exports/define-helpers/sb-action-logger.js",
2106
- "declarations": [],
2107
- "exports": [
2108
- {
2109
- "kind": "custom-element-definition",
2110
- "name": "sb-action-logger",
2111
- "declaration": {
2112
- "name": "SbActionLogger",
2113
- "module": "/exports/helpers.js"
2114
- }
2115
- }
2116
- ]
2117
- },
2118
- {
2119
- "kind": "javascript-module",
2120
- "path": "exports/define-helpers/sb-locale-switcher.js",
2121
- "declarations": [],
2122
- "exports": [
2123
- {
2124
- "kind": "custom-element-definition",
2125
- "name": "sb-locale-switcher",
2126
- "declaration": {
2127
- "name": "SbLocaleSwitcher",
2128
- "module": "/exports/helpers.js"
2129
- }
2130
- }
2131
- ]
2132
- },
2133
2103
  {
2134
2104
  "kind": "javascript-module",
2135
2105
  "path": "exports/define/lion-accordion.js",
@@ -2820,6 +2790,36 @@
2820
2790
  }
2821
2791
  ]
2822
2792
  },
2793
+ {
2794
+ "kind": "javascript-module",
2795
+ "path": "exports/define-helpers/sb-action-logger.js",
2796
+ "declarations": [],
2797
+ "exports": [
2798
+ {
2799
+ "kind": "custom-element-definition",
2800
+ "name": "sb-action-logger",
2801
+ "declaration": {
2802
+ "name": "SbActionLogger",
2803
+ "module": "/exports/helpers.js"
2804
+ }
2805
+ }
2806
+ ]
2807
+ },
2808
+ {
2809
+ "kind": "javascript-module",
2810
+ "path": "exports/define-helpers/sb-locale-switcher.js",
2811
+ "declarations": [],
2812
+ "exports": [
2813
+ {
2814
+ "kind": "custom-element-definition",
2815
+ "name": "sb-locale-switcher",
2816
+ "declaration": {
2817
+ "name": "SbLocaleSwitcher",
2818
+ "module": "/exports/helpers.js"
2819
+ }
2820
+ }
2821
+ ]
2822
+ },
2823
2823
  {
2824
2824
  "kind": "javascript-module",
2825
2825
  "path": "components/accordion/src/LionAccordion.js",
@@ -1 +1 @@
1
- {"version":3,"file":"LionForm.d.ts","sourceRoot":"","sources":["../../../../components/form/src/LionForm.js"],"names":[],"mappings":"AAYA;;;;GAIG;AAEH;IAoCE;;;OAGG;IACH,sBAHW,KAAK,QAYf;IAUD;;;OAGG;IACH,qBAHW,KAAK,QAQf;IA3DD,0BAMC;IAOD,iCAEC;IAED,eAQC;IAiBD,cAMC;IAaD;;;OAGG;IACH,wDAHW,iBAAiB,QAa3B;IAED,eAAe;IACf,oCAGC;IAED,eAAe;IACf,oCAGC;CACF;gCAhHY,OAAO,+DAA+D,EAAE,iBAAiB"}
1
+ {"version":3,"file":"LionForm.d.ts","sourceRoot":"","sources":["../../../../components/form/src/LionForm.js"],"names":[],"mappings":"AAqBA;;;;GAIG;AAEH;IAoCE;;;OAGG;IACH,sBAHW,KAAK,QAYf;IAUD;;;OAGG;IACH,qBAHW,KAAK,QAQf;IA3DD,0BAMC;IAOD,iCAEC;IAED,eAQC;IAiBD,cAMC;IAaD;;;OAGG;IACH,wDAHW,iBAAiB,QAa3B;IAED,eAAe;IACf,oCAGC;IAED,eAAe;IACf,oCAGC;CACF;gCAzHY,OAAO,+DAA+D,EAAE,iBAAiB"}
@@ -1 +1 @@
1
- {"version":3,"file":"lion-form.test.d.ts","sourceRoot":"","sources":["../../../../components/form/test/lion-form.test.js"],"names":[],"mappings":"uBAmBa,OAAO,oBAAoB,EAAE,QAAQ;6BACrC,OAAO,KAAK,EAAE,cAAc"}
1
+ {"version":3,"file":"lion-form.test.d.ts","sourceRoot":"","sources":["../../../../components/form/test/lion-form.test.js"],"names":[],"mappings":"uBAoBa,OAAO,oBAAoB,EAAE,QAAQ;6BACrC,OAAO,KAAK,EAAE,cAAc"}