@spectrum-web-components/radio 0.11.3 → 0.11.4
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.
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@spectrum-web-components/radio",
|
|
3
|
-
"version": "0.11.
|
|
3
|
+
"version": "0.11.4",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -66,9 +66,9 @@
|
|
|
66
66
|
],
|
|
67
67
|
"dependencies": {
|
|
68
68
|
"@spectrum-web-components/base": "^0.7.0",
|
|
69
|
-
"@spectrum-web-components/field-group": "^0.7.
|
|
70
|
-
"@spectrum-web-components/help-text": "^0.2.
|
|
71
|
-
"@spectrum-web-components/reactive-controllers": "^0.3.
|
|
69
|
+
"@spectrum-web-components/field-group": "^0.7.3",
|
|
70
|
+
"@spectrum-web-components/help-text": "^0.2.4",
|
|
71
|
+
"@spectrum-web-components/reactive-controllers": "^0.3.2",
|
|
72
72
|
"@spectrum-web-components/shared": "^0.15.1",
|
|
73
73
|
"tslib": "^2.0.0"
|
|
74
74
|
},
|
|
@@ -81,5 +81,5 @@
|
|
|
81
81
|
"./sp-*.js",
|
|
82
82
|
"./**/*.dev.js"
|
|
83
83
|
],
|
|
84
|
-
"gitHead": "
|
|
84
|
+
"gitHead": "31d083d1eb61a1382335030c190c85d85f41e15d"
|
|
85
85
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["RadioGroup.ts"],
|
|
4
|
-
"sourcesContent": ["/*\nCopyright 2020 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\n\nimport { PropertyValues } from '@spectrum-web-components/base';\nimport {\n property,\n queryAssignedNodes,\n} from '@spectrum-web-components/base/src/decorators.js';\nimport { FocusVisiblePolyfillMixin } from '@spectrum-web-components/shared/src/focus-visible.js';\nimport { FieldGroup } from '@spectrum-web-components/field-group';\n\nimport { Radio } from './Radio.dev.js'\nimport { RovingTabindexController } from '@spectrum-web-components/reactive-controllers/src/RovingTabindex.js';\n\n/**\n * @element sp-radio-group\n *\n * @slot - The `sp-radio` elements to display/manage in the group.\n * @slot help-text - default or non-negative help text to associate to your form element\n * @slot negative-help-text - negative help text to associate to your form element when `invalid`\n *\n * @fires change - An alteration to the value of the element has been committed by the user.\n */\nexport class RadioGroup extends FocusVisiblePolyfillMixin(FieldGroup) {\n @property({ type: String })\n public name = '';\n\n @queryAssignedNodes('')\n public defaultNodes!: Node[];\n\n public get buttons(): Radio[] {\n return this.defaultNodes.filter(\n (node) => (node as HTMLElement) instanceof Radio\n ) as Radio[];\n }\n\n rovingTabindexController = new RovingTabindexController<Radio>(this, {\n focusInIndex: (elements: Radio[]) => {\n return elements.findIndex((el) => {\n return this.selected\n ? !el.disabled && el.value === this.selected\n : !el.disabled;\n });\n },\n elementEnterAction: (el: Radio) => {\n this.selected = el.value;\n },\n elements: () => this.buttons,\n isFocusableElement: (el: Radio) => !el.disabled,\n });\n\n public override focus(): void {\n this.rovingTabindexController.focus();\n }\n\n private _setSelected(value: string): void {\n if (value === this.selected) {\n return;\n }\n const oldValue = this.selected;\n const radio = value\n ? (this.querySelector(`sp-radio[value=\"${value}\"]`) as Radio)\n : undefined;\n\n // If no matching radio, selected is reset to empty string\n this.selected = radio ? value : '';\n const applyDefault = this.dispatchEvent(\n new Event('change', {\n cancelable: true,\n bubbles: true,\n composed: true,\n })\n );\n if (!applyDefault) {\n this.selected = oldValue;\n return;\n }\n this.validateRadios();\n }\n\n @property({ reflect: true })\n public selected = '';\n\n protected override willUpdate(changes: PropertyValues<this>): void {\n if (!this.hasUpdated) {\n this.setAttribute('role', 'radiogroup');\n const checkedRadio = this.querySelector(\n 'sp-radio[checked]'\n ) as Radio;\n const checkedRadioValue = checkedRadio ? checkedRadio.value : '';\n // Prefer the checked item over the selected value\n this.selected = checkedRadioValue || this.selected;\n // Validate the selected value is actual a radio option\n if (this.selected && this.selected !== checkedRadioValue) {\n const selectedRadio = this.querySelector(\n `sp-radio[value=\"${this.selected}\"]`\n ) as Radio;\n if (!selectedRadio) {\n this.selected = '';\n } else {\n selectedRadio.checked = true;\n }\n }\n\n this.shadowRoot.addEventListener('change', (event: Event) => {\n event.stopPropagation();\n const target = event.target as Radio;\n this._setSelected(target.value);\n });\n }\n\n if (changes.has('selected')) {\n this.validateRadios();\n }\n }\n\n private async validateRadios(): Promise<void> {\n let validSelection = false;\n if (!this.hasUpdated) {\n // Initial validation has to happen after the initial render to allow\n // the buttons to be queries from the rendered <slot> element\n await this.updateComplete;\n }\n this.buttons.map((button) => {\n button.checked = this.selected === button.value;\n validSelection = validSelection || button.checked;\n });\n if (!validSelection) {\n this.selected = '';\n }\n }\n\n protected override handleSlotchange(): void {\n this.rovingTabindexController.clearElementCache();\n }\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;AAaA;AAAA,EACI;AAAA,EACA;AAAA,OACG;AACP,SAAS,iCAAiC;AAC1C,SAAS,kBAAkB;AAE3B,SAAS,aAAa;AACtB,SAAS,gCAAgC;AAWlC,aAAM,mBAAmB,0BAA0B,UAAU,EAAE;AAAA,EAA/D;AAAA;AAEH,
|
|
4
|
+
"sourcesContent": ["/*\nCopyright 2020 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\n\nimport { PropertyValues } from '@spectrum-web-components/base';\nimport {\n property,\n queryAssignedNodes,\n} from '@spectrum-web-components/base/src/decorators.js';\nimport { FocusVisiblePolyfillMixin } from '@spectrum-web-components/shared/src/focus-visible.js';\nimport { FieldGroup } from '@spectrum-web-components/field-group';\n\nimport { Radio } from './Radio.dev.js'\nimport { RovingTabindexController } from '@spectrum-web-components/reactive-controllers/src/RovingTabindex.js';\n\n/**\n * @element sp-radio-group\n *\n * @slot - The `sp-radio` elements to display/manage in the group.\n * @slot help-text - default or non-negative help text to associate to your form element\n * @slot negative-help-text - negative help text to associate to your form element when `invalid`\n *\n * @fires change - An alteration to the value of the element has been committed by the user.\n */\nexport class RadioGroup extends FocusVisiblePolyfillMixin(FieldGroup) {\n @property({ type: String })\n public override name = '';\n\n @queryAssignedNodes('')\n public defaultNodes!: Node[];\n\n public get buttons(): Radio[] {\n return this.defaultNodes.filter(\n (node) => (node as HTMLElement) instanceof Radio\n ) as Radio[];\n }\n\n rovingTabindexController = new RovingTabindexController<Radio>(this, {\n focusInIndex: (elements: Radio[]) => {\n return elements.findIndex((el) => {\n return this.selected\n ? !el.disabled && el.value === this.selected\n : !el.disabled;\n });\n },\n elementEnterAction: (el: Radio) => {\n this.selected = el.value;\n },\n elements: () => this.buttons,\n isFocusableElement: (el: Radio) => !el.disabled,\n });\n\n public override focus(): void {\n this.rovingTabindexController.focus();\n }\n\n private _setSelected(value: string): void {\n if (value === this.selected) {\n return;\n }\n const oldValue = this.selected;\n const radio = value\n ? (this.querySelector(`sp-radio[value=\"${value}\"]`) as Radio)\n : undefined;\n\n // If no matching radio, selected is reset to empty string\n this.selected = radio ? value : '';\n const applyDefault = this.dispatchEvent(\n new Event('change', {\n cancelable: true,\n bubbles: true,\n composed: true,\n })\n );\n if (!applyDefault) {\n this.selected = oldValue;\n return;\n }\n this.validateRadios();\n }\n\n @property({ reflect: true })\n public selected = '';\n\n protected override willUpdate(changes: PropertyValues<this>): void {\n if (!this.hasUpdated) {\n this.setAttribute('role', 'radiogroup');\n const checkedRadio = this.querySelector(\n 'sp-radio[checked]'\n ) as Radio;\n const checkedRadioValue = checkedRadio ? checkedRadio.value : '';\n // Prefer the checked item over the selected value\n this.selected = checkedRadioValue || this.selected;\n // Validate the selected value is actual a radio option\n if (this.selected && this.selected !== checkedRadioValue) {\n const selectedRadio = this.querySelector(\n `sp-radio[value=\"${this.selected}\"]`\n ) as Radio;\n if (!selectedRadio) {\n this.selected = '';\n } else {\n selectedRadio.checked = true;\n }\n }\n\n this.shadowRoot.addEventListener('change', (event: Event) => {\n event.stopPropagation();\n const target = event.target as Radio;\n this._setSelected(target.value);\n });\n }\n\n if (changes.has('selected')) {\n this.validateRadios();\n }\n }\n\n private async validateRadios(): Promise<void> {\n let validSelection = false;\n if (!this.hasUpdated) {\n // Initial validation has to happen after the initial render to allow\n // the buttons to be queries from the rendered <slot> element\n await this.updateComplete;\n }\n this.buttons.map((button) => {\n button.checked = this.selected === button.value;\n validSelection = validSelection || button.checked;\n });\n if (!validSelection) {\n this.selected = '';\n }\n }\n\n protected override handleSlotchange(): void {\n this.rovingTabindexController.clearElementCache();\n }\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;AAaA;AAAA,EACI;AAAA,EACA;AAAA,OACG;AACP,SAAS,iCAAiC;AAC1C,SAAS,kBAAkB;AAE3B,SAAS,aAAa;AACtB,SAAS,gCAAgC;AAWlC,aAAM,mBAAmB,0BAA0B,UAAU,EAAE;AAAA,EAA/D;AAAA;AAEH,SAAgB,OAAO;AAWvB,oCAA2B,IAAI,yBAAgC,MAAM;AAAA,MACjE,cAAc,CAAC,aAAsB;AACjC,eAAO,SAAS,UAAU,CAAC,OAAO;AAC9B,iBAAO,KAAK,WACN,CAAC,GAAG,YAAY,GAAG,UAAU,KAAK,WAClC,CAAC,GAAG;AAAA,QACd,CAA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U,CAAC,UAAiB;AACzD,cAAM,gBAAgB;AACtB,cAAM,SAAS,MAAM;AACrB,aAAK,aAAa,OAAO,KAAK;AAAA,MAClC,CAAC;AAAA,IACL;AAEA,QAAI,QAAQ,IAAI,UAAU,GAAG;AACzB,WAAK,eAAe;AAAA,IACxB;AAAA,EACJ;AAAA,EAEA,MAAc,iBAAgC;AAC1C,QAAI,iBAAiB;AACrB,QAAI,CAAC,KAAK,YAAY;AAGlB,YAAM,KAAK;AAAA,IACf;AACA,SAAK,QAAQ,IAAI,CAAC,WAAW;AACzB,aAAO,UAAU,KAAK,aAAa,OAAO;AAC1C,uBAAiB,kBAAkB,OAAO;AAAA,IAC9C,CAAC;AACD,QAAI,CAAC,gBAAgB;AACjB,WAAK,WAAW;AAAA,IACpB;AAAA,EACJ;AAAA,EAEmB,mBAAyB;AACxC,SAAK,yBAAyB,kBAAkB;AAAA,EACpD;AACJ;AA9GoB;AAAA,EADf,SAAS,EAAE,MAAM,OAAO,CAAC;AAAA,GADjB,WAEO;AAGT;AAAA,EADN,mBAAmB,EAAE;AAAA,GAJb,WAKF;AAqDA;AAAA,EADN,SAAS,EAAE,SAAS,KAAK,CAAC;AAAA,GAzDlB,WA0DF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/src/RadioGroup.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["RadioGroup.ts"],
|
|
4
|
-
"sourcesContent": ["/*\nCopyright 2020 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\n\nimport { PropertyValues } from '@spectrum-web-components/base';\nimport {\n property,\n queryAssignedNodes,\n} from '@spectrum-web-components/base/src/decorators.js';\nimport { FocusVisiblePolyfillMixin } from '@spectrum-web-components/shared/src/focus-visible.js';\nimport { FieldGroup } from '@spectrum-web-components/field-group';\n\nimport { Radio } from './Radio.js';\nimport { RovingTabindexController } from '@spectrum-web-components/reactive-controllers/src/RovingTabindex.js';\n\n/**\n * @element sp-radio-group\n *\n * @slot - The `sp-radio` elements to display/manage in the group.\n * @slot help-text - default or non-negative help text to associate to your form element\n * @slot negative-help-text - negative help text to associate to your form element when `invalid`\n *\n * @fires change - An alteration to the value of the element has been committed by the user.\n */\nexport class RadioGroup extends FocusVisiblePolyfillMixin(FieldGroup) {\n @property({ type: String })\n public name = '';\n\n @queryAssignedNodes('')\n public defaultNodes!: Node[];\n\n public get buttons(): Radio[] {\n return this.defaultNodes.filter(\n (node) => (node as HTMLElement) instanceof Radio\n ) as Radio[];\n }\n\n rovingTabindexController = new RovingTabindexController<Radio>(this, {\n focusInIndex: (elements: Radio[]) => {\n return elements.findIndex((el) => {\n return this.selected\n ? !el.disabled && el.value === this.selected\n : !el.disabled;\n });\n },\n elementEnterAction: (el: Radio) => {\n this.selected = el.value;\n },\n elements: () => this.buttons,\n isFocusableElement: (el: Radio) => !el.disabled,\n });\n\n public override focus(): void {\n this.rovingTabindexController.focus();\n }\n\n private _setSelected(value: string): void {\n if (value === this.selected) {\n return;\n }\n const oldValue = this.selected;\n const radio = value\n ? (this.querySelector(`sp-radio[value=\"${value}\"]`) as Radio)\n : undefined;\n\n // If no matching radio, selected is reset to empty string\n this.selected = radio ? value : '';\n const applyDefault = this.dispatchEvent(\n new Event('change', {\n cancelable: true,\n bubbles: true,\n composed: true,\n })\n );\n if (!applyDefault) {\n this.selected = oldValue;\n return;\n }\n this.validateRadios();\n }\n\n @property({ reflect: true })\n public selected = '';\n\n protected override willUpdate(changes: PropertyValues<this>): void {\n if (!this.hasUpdated) {\n this.setAttribute('role', 'radiogroup');\n const checkedRadio = this.querySelector(\n 'sp-radio[checked]'\n ) as Radio;\n const checkedRadioValue = checkedRadio ? checkedRadio.value : '';\n // Prefer the checked item over the selected value\n this.selected = checkedRadioValue || this.selected;\n // Validate the selected value is actual a radio option\n if (this.selected && this.selected !== checkedRadioValue) {\n const selectedRadio = this.querySelector(\n `sp-radio[value=\"${this.selected}\"]`\n ) as Radio;\n if (!selectedRadio) {\n this.selected = '';\n } else {\n selectedRadio.checked = true;\n }\n }\n\n this.shadowRoot.addEventListener('change', (event: Event) => {\n event.stopPropagation();\n const target = event.target as Radio;\n this._setSelected(target.value);\n });\n }\n\n if (changes.has('selected')) {\n this.validateRadios();\n }\n }\n\n private async validateRadios(): Promise<void> {\n let validSelection = false;\n if (!this.hasUpdated) {\n // Initial validation has to happen after the initial render to allow\n // the buttons to be queries from the rendered <slot> element\n await this.updateComplete;\n }\n this.buttons.map((button) => {\n button.checked = this.selected === button.value;\n validSelection = validSelection || button.checked;\n });\n if (!validSelection) {\n this.selected = '';\n }\n }\n\n protected override handleSlotchange(): void {\n this.rovingTabindexController.clearElementCache();\n }\n}\n"],
|
|
5
|
-
"mappings": "qNAaA,OACI,YAAAA,EACA,sBAAAC,MACG,kDACP,OAAS,6BAAAC,MAAiC,uDAC1C,OAAS,cAAAC,MAAkB,uCAE3B,OAAS,SAAAC,MAAa,aACtB,OAAS,4BAAAC,MAAgC,sEAWlC,aAAM,mBAAmBH,EAA0BC,CAAU,CAAE,CAA/D,kCAEH,
|
|
4
|
+
"sourcesContent": ["/*\nCopyright 2020 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\n\nimport { PropertyValues } from '@spectrum-web-components/base';\nimport {\n property,\n queryAssignedNodes,\n} from '@spectrum-web-components/base/src/decorators.js';\nimport { FocusVisiblePolyfillMixin } from '@spectrum-web-components/shared/src/focus-visible.js';\nimport { FieldGroup } from '@spectrum-web-components/field-group';\n\nimport { Radio } from './Radio.js';\nimport { RovingTabindexController } from '@spectrum-web-components/reactive-controllers/src/RovingTabindex.js';\n\n/**\n * @element sp-radio-group\n *\n * @slot - The `sp-radio` elements to display/manage in the group.\n * @slot help-text - default or non-negative help text to associate to your form element\n * @slot negative-help-text - negative help text to associate to your form element when `invalid`\n *\n * @fires change - An alteration to the value of the element has been committed by the user.\n */\nexport class RadioGroup extends FocusVisiblePolyfillMixin(FieldGroup) {\n @property({ type: String })\n public override name = '';\n\n @queryAssignedNodes('')\n public defaultNodes!: Node[];\n\n public get buttons(): Radio[] {\n return this.defaultNodes.filter(\n (node) => (node as HTMLElement) instanceof Radio\n ) as Radio[];\n }\n\n rovingTabindexController = new RovingTabindexController<Radio>(this, {\n focusInIndex: (elements: Radio[]) => {\n return elements.findIndex((el) => {\n return this.selected\n ? !el.disabled && el.value === this.selected\n : !el.disabled;\n });\n },\n elementEnterAction: (el: Radio) => {\n this.selected = el.value;\n },\n elements: () => this.buttons,\n isFocusableElement: (el: Radio) => !el.disabled,\n });\n\n public override focus(): void {\n this.rovingTabindexController.focus();\n }\n\n private _setSelected(value: string): void {\n if (value === this.selected) {\n return;\n }\n const oldValue = this.selected;\n const radio = value\n ? (this.querySelector(`sp-radio[value=\"${value}\"]`) as Radio)\n : undefined;\n\n // If no matching radio, selected is reset to empty string\n this.selected = radio ? value : '';\n const applyDefault = this.dispatchEvent(\n new Event('change', {\n cancelable: true,\n bubbles: true,\n composed: true,\n })\n );\n if (!applyDefault) {\n this.selected = oldValue;\n return;\n }\n this.validateRadios();\n }\n\n @property({ reflect: true })\n public selected = '';\n\n protected override willUpdate(changes: PropertyValues<this>): void {\n if (!this.hasUpdated) {\n this.setAttribute('role', 'radiogroup');\n const checkedRadio = this.querySelector(\n 'sp-radio[checked]'\n ) as Radio;\n const checkedRadioValue = checkedRadio ? checkedRadio.value : '';\n // Prefer the checked item over the selected value\n this.selected = checkedRadioValue || this.selected;\n // Validate the selected value is actual a radio option\n if (this.selected && this.selected !== checkedRadioValue) {\n const selectedRadio = this.querySelector(\n `sp-radio[value=\"${this.selected}\"]`\n ) as Radio;\n if (!selectedRadio) {\n this.selected = '';\n } else {\n selectedRadio.checked = true;\n }\n }\n\n this.shadowRoot.addEventListener('change', (event: Event) => {\n event.stopPropagation();\n const target = event.target as Radio;\n this._setSelected(target.value);\n });\n }\n\n if (changes.has('selected')) {\n this.validateRadios();\n }\n }\n\n private async validateRadios(): Promise<void> {\n let validSelection = false;\n if (!this.hasUpdated) {\n // Initial validation has to happen after the initial render to allow\n // the buttons to be queries from the rendered <slot> element\n await this.updateComplete;\n }\n this.buttons.map((button) => {\n button.checked = this.selected === button.value;\n validSelection = validSelection || button.checked;\n });\n if (!validSelection) {\n this.selected = '';\n }\n }\n\n protected override handleSlotchange(): void {\n this.rovingTabindexController.clearElementCache();\n }\n}\n"],
|
|
5
|
+
"mappings": "qNAaA,OACI,YAAAA,EACA,sBAAAC,MACG,kDACP,OAAS,6BAAAC,MAAiC,uDAC1C,OAAS,cAAAC,MAAkB,uCAE3B,OAAS,SAAAC,MAAa,aACtB,OAAS,4BAAAC,MAAgC,sEAWlC,aAAM,mBAAmBH,EAA0BC,CAAU,CAAE,CAA/D,kCAEH,KAAgB,KAAO,GAWvB,8BAA2B,IAAIE,EAAgC,KAAM,CACjE,aAAeC,GACJA,EAAS,UAAWC,GAChB,KAAK,SACN,CAACA,EAAG,UAAYA,EAAG,QAAU,KAAK,SAClC,CAACA,EAAG,QACb,EAEL,mBAAqBA,GAAc,CAC/B,KAAK,SAAWA,EAAG,KACvB,EACA,SAAU,IAAM,KAAK,QACrB,mBAAqBA,GAAc,CAACA,EAAG,QAC3C,CAAC,EAgCD,KAAO,SAAW,GAnDlB,I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AAkB,CACpD,CACJ,CA9GoBE,EAAA,CADfpB,EAAS,CAAE,KAAM,MAAO,CAAC,GADjB,WAEO,oBAGToB,EAAA,CADNnB,EAAmB,EAAE,GAJb,WAKF,4BAqDAmB,EAAA,CADNpB,EAAS,CAAE,QAAS,EAAK,CAAC,GAzDlB,WA0DF",
|
|
6
6
|
"names": ["property", "queryAssignedNodes", "FocusVisiblePolyfillMixin", "FieldGroup", "Radio", "RovingTabindexController", "elements", "el", "node", "value", "oldValue", "radio", "changes", "checkedRadio", "checkedRadioValue", "selectedRadio", "event", "target", "validSelection", "button", "__decorateClass"]
|
|
7
7
|
}
|