diff --git a/analysis.json b/analysis.json index 69d26e0..ee360b0 100644 --- a/analysis.json +++ b/analysis.json @@ -6,13 +6,13 @@ "description": "", "summary": "", "sourceRange": { - "file": "src/vaadin-radio-group.html", + "file": "src/vaadin-field.html", "start": { - "line": 294, + "line": 266, "column": 6 }, "end": { - "line": 294, + "line": 266, "column": 42 } }, @@ -816,9 +816,9 @@ ] }, { - "description": "`` is a Polymer element for grouping vaadin-radio-buttons.\n\n```html\n\n Foo\n Bar\n Baz\n\n```\n\n### Styling\n\nThe following shadow DOM parts are available for styling:\n\nPart name | Description\n----------------|----------------\n`label` | The label element\n\nThe following state attributes are available for styling:\n\nAttribute | Description | Part name\n-----------|-------------|------------\n`disabled` | Set when the radio group and its children are disabled. | :host\n`has-label` | Set when the element has a label | :host\n\nSee [ThemableMixin – how to apply styles for shadow parts](https://github.com/vaadin/vaadin-themable-mixin/wiki)", + "description": "`` is a Polymer element for grouping vaadin-radio-buttons.\n\n```html\n\n Foo\n Bar\n Baz\n\n```\n\n### Styling\n\nThe following shadow DOM parts are available for styling:\n\nPart name | Description\n----------------|----------------\n`label` | The label element\n`group-field` | The element that wraps radio-buttons\n\nThe following state attributes are available for styling:\n\nAttribute | Description | Part name\n-----------|-------------|------------\n`disabled` | Set when the radio group and its children are disabled. | :host\n`readonly` | Set to a readonly text field | :host\n`invalid` | Set when the element is invalid | :host\n`has-label` | Set when the element has a label | :host\n\nSee [ThemableMixin – how to apply styles for shadow parts](https://github.com/vaadin/vaadin-themable-mixin/wiki)", "summary": "", - "path": "src/vaadin-field.html", + "path": "src/vaadin-radio-group.html", "properties": [ { "name": "_radioButtons", @@ -827,11 +827,11 @@ "privacy": "protected", "sourceRange": { "start": { - "line": 136, + "line": 214, "column": 8 }, "end": { - "line": 138, + "line": 216, "column": 9 } }, @@ -848,11 +848,11 @@ "privacy": "public", "sourceRange": { "start": { - "line": 67, + "line": 101, "column": 12 }, "end": { - "line": 71, + "line": 105, "column": 13 } }, @@ -863,6 +863,115 @@ } } }, + { + "name": "readonly", + "type": "boolean | null | undefined", + "description": "This attribute indicates that the user cannot modify the value of the control.", + "privacy": "public", + "sourceRange": { + "start": { + "line": 110, + "column": 12 + }, + "end": { + "line": 114, + "column": 13 + } + }, + "metadata": { + "polymer": { + "observer": "\"_readonlyChanged\"", + "attributeType": "Boolean" + } + } + }, + { + "name": "invalid", + "type": "boolean | null | undefined", + "description": "This property is set to true when the value is invalid.", + "privacy": "public", + "sourceRange": { + "start": { + "line": 119, + "column": 12 + }, + "end": { + "line": 124, + "column": 13 + } + }, + "metadata": { + "polymer": { + "notify": true, + "attributeType": "Boolean" + } + }, + "defaultValue": "false" + }, + { + "name": "required", + "type": "boolean | null | undefined", + "description": "Specifies that the user must fill in a value.", + "privacy": "public", + "sourceRange": { + "start": { + "line": 129, + "column": 12 + }, + "end": { + "line": 132, + "column": 13 + } + }, + "metadata": { + "polymer": { + "attributeType": "Boolean" + } + } + }, + { + "name": "errorMessage", + "type": "string | null | undefined", + "description": "Error to show when the input value is invalid.", + "privacy": "public", + "sourceRange": { + "start": { + "line": 137, + "column": 12 + }, + "end": { + "line": 140, + "column": 13 + } + }, + "metadata": { + "polymer": { + "attributeType": "String" + } + }, + "defaultValue": "\"\"" + }, + { + "name": "_errorId", + "type": "string | null | undefined", + "description": "", + "privacy": "protected", + "sourceRange": { + "start": { + "line": 142, + "column": 12 + }, + "end": { + "line": 144, + "column": 13 + } + }, + "metadata": { + "polymer": { + "attributeType": "String" + } + } + }, { "name": "_checkedButton", "type": "Object | null | undefined", @@ -870,11 +979,11 @@ "privacy": "protected", "sourceRange": { "start": { - "line": 73, + "line": 146, "column": 12 }, "end": { - "line": 76, + "line": 149, "column": 13 } }, @@ -892,11 +1001,11 @@ "privacy": "public", "sourceRange": { "start": { - "line": 81, + "line": 154, "column": 12 }, "end": { - "line": 85, + "line": 158, "column": 13 } }, @@ -915,11 +1024,11 @@ "privacy": "public", "sourceRange": { "start": { - "line": 90, + "line": 163, "column": 12 }, "end": { - "line": 94, + "line": 167, "column": 13 } }, @@ -939,11 +1048,11 @@ "privacy": "private", "sourceRange": { "start": { - "line": 101, + "line": 174, "column": 8 }, "end": { - "line": 122, + "line": 195, "column": 9 } }, @@ -959,11 +1068,11 @@ "privacy": "protected", "sourceRange": { "start": { - "line": 124, + "line": 197, "column": 8 }, "end": { - "line": 134, + "line": 212, "column": 9 } }, @@ -979,11 +1088,11 @@ "privacy": "protected", "sourceRange": { "start": { - "line": 140, + "line": 218, "column": 8 }, "end": { - "line": 143, + "line": 221, "column": 9 } }, @@ -1000,11 +1109,11 @@ "privacy": "protected", "sourceRange": { "start": { - "line": 145, + "line": 223, "column": 8 }, "end": { - "line": 149, + "line": 226, "column": 9 } }, @@ -1018,17 +1127,64 @@ "type": "void" } }, + { + "name": "_updateDisableButtons", + "description": "", + "privacy": "protected", + "sourceRange": { + "start": { + "line": 228, + "column": 8 + }, + "end": { + "line": 240, + "column": 9 + } + }, + "metadata": {}, + "params": [], + "return": { + "type": "void" + } + }, + { + "name": "_readonlyChanged", + "description": "", + "privacy": "protected", + "sourceRange": { + "start": { + "line": 242, + "column": 8 + }, + "end": { + "line": 244, + "column": 9 + } + }, + "metadata": {}, + "params": [ + { + "name": "newV" + }, + { + "name": "oldV" + } + ], + "return": { + "type": "void" + } + }, { "name": "_addActiveListeners", "description": "", "privacy": "protected", "sourceRange": { "start": { - "line": 151, + "line": 246, "column": 8 }, "end": { - "line": 171, + "line": 263, "column": 9 } }, @@ -1044,11 +1200,11 @@ "privacy": "protected", "sourceRange": { "start": { - "line": 173, + "line": 265, "column": 8 }, "end": { - "line": 181, + "line": 273, "column": 9 } }, @@ -1071,11 +1227,11 @@ "privacy": "protected", "sourceRange": { "start": { - "line": 183, + "line": 275, "column": 8 }, "end": { - "line": 188, + "line": 280, "column": 9 } }, @@ -1088,11 +1244,11 @@ "privacy": "protected", "sourceRange": { "start": { - "line": 190, + "line": 283, "column": 8 }, "end": { - "line": 192, + "line": 285, "column": 9 } }, @@ -1105,11 +1261,11 @@ "privacy": "protected", "sourceRange": { "start": { - "line": 194, + "line": 287, "column": 8 }, "end": { - "line": 206, + "line": 299, "column": 9 } }, @@ -1129,11 +1285,11 @@ "privacy": "protected", "sourceRange": { "start": { - "line": 208, + "line": 301, "column": 8 }, "end": { - "line": 220, + "line": 313, "column": 9 } }, @@ -1153,11 +1309,11 @@ "privacy": "protected", "sourceRange": { "start": { - "line": 222, + "line": 315, "column": 8 }, "end": { - "line": 226, + "line": 319, "column": 9 } }, @@ -1177,11 +1333,11 @@ "privacy": "protected", "sourceRange": { "start": { - "line": 228, + "line": 321, "column": 8 }, "end": { - "line": 232, + "line": 325, "column": 9 } }, @@ -1201,11 +1357,11 @@ "privacy": "protected", "sourceRange": { "start": { - "line": 234, + "line": 327, "column": 8 }, "end": { - "line": 244, + "line": 343, "column": 9 } }, @@ -1222,17 +1378,58 @@ "type": "void" } }, + { + "name": "validate", + "description": "Returns true if `value` is valid.\n`` uses this to check the validity or all its elements.", + "privacy": "public", + "sourceRange": { + "start": { + "line": 351, + "column": 8 + }, + "end": { + "line": 353, + "column": 9 + } + }, + "metadata": {}, + "params": [], + "return": { + "type": "boolean", + "desc": "True if the value is valid." + } + }, + { + "name": "checkValidity", + "description": "Returns true if the current input value satisfies all constraints (if any)", + "privacy": "public", + "sourceRange": { + "start": { + "line": 359, + "column": 8 + }, + "end": { + "line": 361, + "column": 9 + } + }, + "metadata": {}, + "params": [], + "return": { + "type": "boolean" + } + }, { "name": "_setFocusable", "description": "", "privacy": "protected", "sourceRange": { "start": { - "line": 246, + "line": 363, "column": 8 }, "end": { - "line": 249, + "line": 366, "column": 9 } }, @@ -1252,11 +1449,11 @@ "privacy": "protected", "sourceRange": { "start": { - "line": 251, + "line": 368, "column": 8 }, "end": { - "line": 257, + "line": 374, "column": 9 } }, @@ -1269,6 +1466,60 @@ "return": { "type": "void" } + }, + { + "name": "_getActiveErrorId", + "description": "", + "privacy": "protected", + "sourceRange": { + "start": { + "line": 376, + "column": 8 + }, + "end": { + "line": 378, + "column": 9 + } + }, + "metadata": {}, + "params": [ + { + "name": "invalid" + }, + { + "name": "errorMessage" + }, + { + "name": "errorId" + } + ] + }, + { + "name": "_getErrorMessageAriaHidden", + "description": "", + "privacy": "protected", + "sourceRange": { + "start": { + "line": 380, + "column": 8 + }, + "end": { + "line": 382, + "column": 9 + } + }, + "metadata": {}, + "params": [ + { + "name": "invalid" + }, + { + "name": "errorMessage" + }, + { + "name": "errorId" + } + ] } ], "staticMethods": [ @@ -1359,11 +1610,11 @@ "metadata": {}, "sourceRange": { "start": { - "line": 57, + "line": 91, "column": 6 }, "end": { - "line": 259, + "line": 383, "column": 7 } }, @@ -1376,27 +1627,91 @@ "description": "The current disabled state of the radio group. True if group and all internal radio buttons are disabled.", "sourceRange": { "start": { - "line": 67, + "line": 101, "column": 12 }, "end": { - "line": 71, + "line": 105, + "column": 13 + } + }, + "metadata": {}, + "type": "boolean | null | undefined" + }, + { + "name": "readonly", + "description": "This attribute indicates that the user cannot modify the value of the control.", + "sourceRange": { + "start": { + "line": 110, + "column": 12 + }, + "end": { + "line": 114, + "column": 13 + } + }, + "metadata": {}, + "type": "boolean | null | undefined" + }, + { + "name": "invalid", + "description": "This property is set to true when the value is invalid.", + "sourceRange": { + "start": { + "line": 119, + "column": 12 + }, + "end": { + "line": 124, + "column": 13 + } + }, + "metadata": {}, + "type": "boolean | null | undefined" + }, + { + "name": "required", + "description": "Specifies that the user must fill in a value.", + "sourceRange": { + "start": { + "line": 129, + "column": 12 + }, + "end": { + "line": 132, "column": 13 } }, "metadata": {}, "type": "boolean | null | undefined" }, + { + "name": "error-message", + "description": "Error to show when the input value is invalid.", + "sourceRange": { + "start": { + "line": 137, + "column": 12 + }, + "end": { + "line": 140, + "column": 13 + } + }, + "metadata": {}, + "type": "string | null | undefined" + }, { "name": "label", "description": "String used for the label element.", "sourceRange": { "start": { - "line": 81, + "line": 154, "column": 12 }, "end": { - "line": 85, + "line": 158, "column": 13 } }, @@ -1408,11 +1723,11 @@ "description": "Value of the radio group.", "sourceRange": { "start": { - "line": 90, + "line": 163, "column": 12 }, "end": { - "line": 94, + "line": 167, "column": 13 } }, @@ -1421,6 +1736,12 @@ } ], "events": [ + { + "type": "CustomEvent", + "name": "invalid-changed", + "description": "Fired when the `invalid` property changes.", + "metadata": {} + }, { "type": "CustomEvent", "name": "value-changed", @@ -1438,12 +1759,12 @@ "name": "", "range": { "start": { - "line": 19, - "column": 4 + "line": 42, + "column": 8 }, "end": { - "line": 19, - "column": 27 + "line": 42, + "column": 31 } } } @@ -1454,9 +1775,9 @@ ] }, { - "description": "`` is a Polymer element for grouping vaadin-radio-buttons.\n\n```html\n\n Foo\n Bar\n Baz\n\n```\n\n### Styling\n\nThe following shadow DOM parts are available for styling:\n\nPart name | Description\n----------------|----------------\n`label` | The label element\n`group-field` | The element that wraps radio-buttons\n\nThe following state attributes are available for styling:\n\nAttribute | Description | Part name\n-----------|-------------|------------\n`disabled` | Set when the radio group and its children are disabled. | :host\n`has-label` | Set when the element has a label | :host\n\nSee [ThemableMixin – how to apply styles for shadow parts](https://github.com/vaadin/vaadin-themable-mixin/wiki)", + "description": "`` is a Polymer element for grouping vaadin-radio-buttons.\n\n```html\n\n Foo\n Bar\n Baz\n\n```\n\n### Styling\n\nThe following shadow DOM parts are available for styling:\n\nPart name | Description\n----------------|----------------\n`label` | The label element\n\nThe following state attributes are available for styling:\n\nAttribute | Description | Part name\n-----------|-------------|------------\n`disabled` | Set when the radio group and its children are disabled. | :host\n`has-label` | Set when the element has a label | :host\n\nSee [ThemableMixin – how to apply styles for shadow parts](https://github.com/vaadin/vaadin-themable-mixin/wiki)", "summary": "", - "path": "src/vaadin-radio-group.html", + "path": "src/vaadin-field.html", "properties": [ { "name": "_radioButtons", @@ -1465,11 +1786,11 @@ "privacy": "protected", "sourceRange": { "start": { - "line": 164, + "line": 136, "column": 8 }, "end": { - "line": 166, + "line": 138, "column": 9 } }, @@ -1486,11 +1807,11 @@ "privacy": "public", "sourceRange": { "start": { - "line": 95, + "line": 67, "column": 12 }, "end": { - "line": 99, + "line": 71, "column": 13 } }, @@ -1508,11 +1829,11 @@ "privacy": "protected", "sourceRange": { "start": { - "line": 101, + "line": 73, "column": 12 }, "end": { - "line": 104, + "line": 76, "column": 13 } }, @@ -1530,11 +1851,11 @@ "privacy": "public", "sourceRange": { "start": { - "line": 109, + "line": 81, "column": 12 }, "end": { - "line": 113, + "line": 85, "column": 13 } }, @@ -1553,11 +1874,11 @@ "privacy": "public", "sourceRange": { "start": { - "line": 118, + "line": 90, "column": 12 }, "end": { - "line": 122, + "line": 94, "column": 13 } }, @@ -1577,11 +1898,11 @@ "privacy": "private", "sourceRange": { "start": { - "line": 129, + "line": 101, "column": 8 }, "end": { - "line": 150, + "line": 122, "column": 9 } }, @@ -1597,11 +1918,11 @@ "privacy": "protected", "sourceRange": { "start": { - "line": 152, + "line": 124, "column": 8 }, "end": { - "line": 162, + "line": 134, "column": 9 } }, @@ -1617,11 +1938,11 @@ "privacy": "protected", "sourceRange": { "start": { - "line": 168, + "line": 140, "column": 8 }, "end": { - "line": 171, + "line": 143, "column": 9 } }, @@ -1638,11 +1959,11 @@ "privacy": "protected", "sourceRange": { "start": { - "line": 173, + "line": 145, "column": 8 }, "end": { - "line": 177, + "line": 149, "column": 9 } }, @@ -1662,11 +1983,11 @@ "privacy": "protected", "sourceRange": { "start": { - "line": 179, + "line": 151, "column": 8 }, "end": { - "line": 199, + "line": 171, "column": 9 } }, @@ -1682,11 +2003,11 @@ "privacy": "protected", "sourceRange": { "start": { - "line": 201, + "line": 173, "column": 8 }, "end": { - "line": 209, + "line": 181, "column": 9 } }, @@ -1709,11 +2030,11 @@ "privacy": "protected", "sourceRange": { "start": { - "line": 211, + "line": 183, "column": 8 }, "end": { - "line": 216, + "line": 188, "column": 9 } }, @@ -1726,11 +2047,11 @@ "privacy": "protected", "sourceRange": { "start": { - "line": 218, + "line": 190, "column": 8 }, "end": { - "line": 220, + "line": 192, "column": 9 } }, @@ -1743,11 +2064,11 @@ "privacy": "protected", "sourceRange": { "start": { - "line": 222, + "line": 194, "column": 8 }, "end": { - "line": 234, + "line": 206, "column": 9 } }, @@ -1767,11 +2088,11 @@ "privacy": "protected", "sourceRange": { "start": { - "line": 236, + "line": 208, "column": 8 }, "end": { - "line": 248, + "line": 220, "column": 9 } }, @@ -1791,11 +2112,11 @@ "privacy": "protected", "sourceRange": { "start": { - "line": 250, + "line": 222, "column": 8 }, "end": { - "line": 254, + "line": 226, "column": 9 } }, @@ -1815,11 +2136,11 @@ "privacy": "protected", "sourceRange": { "start": { - "line": 256, + "line": 228, "column": 8 }, "end": { - "line": 260, + "line": 232, "column": 9 } }, @@ -1839,11 +2160,11 @@ "privacy": "protected", "sourceRange": { "start": { - "line": 262, + "line": 234, "column": 8 }, "end": { - "line": 272, + "line": 244, "column": 9 } }, @@ -1866,11 +2187,11 @@ "privacy": "protected", "sourceRange": { "start": { - "line": 274, + "line": 246, "column": 8 }, "end": { - "line": 277, + "line": 249, "column": 9 } }, @@ -1890,11 +2211,11 @@ "privacy": "protected", "sourceRange": { "start": { - "line": 279, + "line": 251, "column": 8 }, "end": { - "line": 285, + "line": 257, "column": 9 } }, @@ -1997,11 +2318,11 @@ "metadata": {}, "sourceRange": { "start": { - "line": 85, + "line": 57, "column": 6 }, "end": { - "line": 287, + "line": 259, "column": 7 } }, @@ -2014,11 +2335,11 @@ "description": "The current disabled state of the radio group. True if group and all internal radio buttons are disabled.", "sourceRange": { "start": { - "line": 95, + "line": 67, "column": 12 }, "end": { - "line": 99, + "line": 71, "column": 13 } }, @@ -2030,11 +2351,11 @@ "description": "String used for the label element.", "sourceRange": { "start": { - "line": 109, + "line": 81, "column": 12 }, "end": { - "line": 113, + "line": 85, "column": 13 } }, @@ -2046,11 +2367,11 @@ "description": "Value of the radio group.", "sourceRange": { "start": { - "line": 118, + "line": 90, "column": 12 }, "end": { - "line": 122, + "line": 94, "column": 13 } }, @@ -2076,12 +2397,12 @@ "name": "", "range": { "start": { - "line": 42, - "column": 8 + "line": 19, + "column": 4 }, "end": { - "line": 42, - "column": 31 + "line": 19, + "column": 27 } } } diff --git a/demo/radio-group-demos.html b/demo/radio-group-demos.html index f1401b3..7656468 100644 --- a/demo/radio-group-demos.html +++ b/demo/radio-group-demos.html @@ -29,6 +29,17 @@

Radio Group Disabled

+

Validation

+ + + +

Radio Group with Value

diff --git a/test/visual/default.html b/test/visual/default.html index 3709079..41c97e0 100644 --- a/test/visual/default.html +++ b/test/visual/default.html @@ -16,6 +16,11 @@ 2 3
+ + + 1 + 2 + diff --git a/test/visual/screens/vaadin-radio-button/default-tests/default/android.png b/test/visual/screens/vaadin-radio-button/default-tests/default/android.png index c0ce230..33312af 100644 Binary files a/test/visual/screens/vaadin-radio-button/default-tests/default/android.png and b/test/visual/screens/vaadin-radio-button/default-tests/default/android.png differ diff --git a/test/visual/screens/vaadin-radio-button/default-tests/default/chrome.png b/test/visual/screens/vaadin-radio-button/default-tests/default/chrome.png index c3e6fda..595b8f3 100644 Binary files a/test/visual/screens/vaadin-radio-button/default-tests/default/chrome.png and b/test/visual/screens/vaadin-radio-button/default-tests/default/chrome.png differ diff --git a/test/visual/screens/vaadin-radio-button/default-tests/default/edge.png b/test/visual/screens/vaadin-radio-button/default-tests/default/edge.png index dc2dfe4..66a57a1 100644 Binary files a/test/visual/screens/vaadin-radio-button/default-tests/default/edge.png and b/test/visual/screens/vaadin-radio-button/default-tests/default/edge.png differ diff --git a/test/visual/screens/vaadin-radio-button/default-tests/default/firefox.png b/test/visual/screens/vaadin-radio-button/default-tests/default/firefox.png index d0a64a9..03ba9e2 100644 Binary files a/test/visual/screens/vaadin-radio-button/default-tests/default/firefox.png and b/test/visual/screens/vaadin-radio-button/default-tests/default/firefox.png differ diff --git a/test/visual/screens/vaadin-radio-button/default-tests/default/ie.png b/test/visual/screens/vaadin-radio-button/default-tests/default/ie.png index 910f870..5ce5f03 100644 Binary files a/test/visual/screens/vaadin-radio-button/default-tests/default/ie.png and b/test/visual/screens/vaadin-radio-button/default-tests/default/ie.png differ diff --git a/theme/lumo/vaadin-radio-group-styles.html b/theme/lumo/vaadin-radio-group-styles.html index 8e467d7..b8bb982 100644 --- a/theme/lumo/vaadin-radio-group-styles.html +++ b/theme/lumo/vaadin-radio-group-styles.html @@ -55,6 +55,29 @@ :host([invalid]) [part="label"] { color: var(--lumo-error-text-color); } + + [part="error-message"] { + margin-left: calc(var(--lumo-border-radius) / 4); + font-size: var(--lumo-font-size-xs); + line-height: var(--lumo-line-height-xs); + color: var(--lumo-error-text-color); + will-change: max-height; + transition: 0.4s max-height; + max-height: 5em; + } + + /* Margin that doesn’t reserve space when there’s no error message */ + [part="error-message"]:not(:empty)::before, + [part="error-message"]:not(:empty)::after { + content: ""; + display: block; + height: 0.4em; + } + + :host(:not([invalid])) [part="error-message"] { + max-height: 0; + overflow: hidden; + } diff --git a/theme/material/vaadin-radio-group-styles.html b/theme/material/vaadin-radio-group-styles.html index 4911c2e..20b824d 100644 --- a/theme/material/vaadin-radio-group-styles.html +++ b/theme/material/vaadin-radio-group-styles.html @@ -62,6 +62,23 @@ :host([invalid]) [part="label"] { color: var(--material-error-text-color); } + + [part="error-message"] { + font-size: .75em; + line-height: 1; + color: var(--material-error-text-color); + margin-top: 6px; + } + + :host(:not([invalid])) [part="error-message"] { + margin-top: 0; + max-height: 0; + overflow: hidden; + } + + :host([invalid]) [part="error-message"] { + animation: reveal 0.2s; + }