@ongov/ontario-design-system-component-library 8.1.0-alpha.3 → 8.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.
- package/components/ontario-radio-buttons.js +33 -16
- package/components/ontario-radio-buttons.js.map +1 -1
- package/dist/cjs/ontario-accordion_49.cjs.entry.js +32 -15
- package/dist/cjs/ontario-accordion_49.cjs.entry.js.map +1 -1
- package/dist/collection/components/ontario-radio-buttons/ontario-radio-buttons.js +32 -15
- package/dist/collection/components/ontario-radio-buttons/ontario-radio-buttons.js.map +1 -1
- package/dist/esm/ontario-accordion_49.entry.js +32 -15
- package/dist/esm/ontario-accordion_49.entry.js.map +1 -1
- package/dist/ontario-design-system-components/ontario-design-system-components.esm.js +1 -1
- package/dist/ontario-design-system-components/{p-f09ec9a6.entry.js → p-bae4c0db.entry.js} +27 -17
- package/dist/ontario-design-system-components/{p-f09ec9a6.entry.js.map → p-bae4c0db.entry.js.map} +1 -1
- package/hydrate/index.js +33 -16
- package/hydrate/index.mjs +33 -16
- package/package.json +9 -4
- package/src/components/ontario-radio-buttons/ontario-radio-buttons.tsx +13 -0
- package/src/components/ontario-radio-buttons/test/ontario-radio-button.spec.tsx +33 -0
- package/www/build/ontario-design-system-components.esm.js +1 -1
- package/www/build/{p-bb13b1c1.js → p-8ff41991.js} +1 -1
- package/www/build/{p-f09ec9a6.entry.js → p-bae4c0db.entry.js} +27 -17
- package/www/build/{p-f09ec9a6.entry.js.map → p-bae4c0db.entry.js.map} +1 -1
- package/www/index.html +2 -2
|
@@ -238,7 +238,8 @@ const OntarioRadioButtons$1 = /*@__PURE__*/ proxyCustomElement(
|
|
|
238
238
|
);
|
|
239
239
|
}
|
|
240
240
|
syncValueFromOptions() {
|
|
241
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
241
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
|
|
242
|
+
// Case 1: a non-empty value was provided and matches one of the options; derive checked state from value.
|
|
242
243
|
const hasMatchingValue =
|
|
243
244
|
this.value &&
|
|
244
245
|
((_a = this.internalOptions) === null || _a === void 0
|
|
@@ -253,6 +254,20 @@ const OntarioRadioButtons$1 = /*@__PURE__*/ proxyCustomElement(
|
|
|
253
254
|
: _c.call(_b, (_d = this.value) !== null && _d !== void 0 ? _d : '');
|
|
254
255
|
return;
|
|
255
256
|
}
|
|
257
|
+
// Case 2: value was explicitly set to ''; the consumer wants to clear the selection.
|
|
258
|
+
// Distinguish this from undefined (prop never set) so the fallback below does not silently
|
|
259
|
+
// re-select the previously checked option.
|
|
260
|
+
if (this.value === '') {
|
|
261
|
+
this.internalOptions =
|
|
262
|
+
(_e = this.internalOptions) === null || _e === void 0
|
|
263
|
+
? void 0
|
|
264
|
+
: _e.map((option) => Object.assign(Object.assign({}, option), { checked: false }));
|
|
265
|
+
(_g = (_f = this.internals) === null || _f === void 0 ? void 0 : _f.setFormValue) === null || _g === void 0
|
|
266
|
+
? void 0
|
|
267
|
+
: _g.call(_f, '');
|
|
268
|
+
return;
|
|
269
|
+
}
|
|
270
|
+
// Case 3: a non-empty value was provided but did not match any option; warn and fall back.
|
|
256
271
|
if (this.value) {
|
|
257
272
|
const message = new ConsoleMessageClass();
|
|
258
273
|
message
|
|
@@ -263,20 +278,22 @@ const OntarioRadioButtons$1 = /*@__PURE__*/ proxyCustomElement(
|
|
|
263
278
|
.addRegularText('did not match any option values. Falling back to the checked option.')
|
|
264
279
|
.printMessage();
|
|
265
280
|
}
|
|
281
|
+
// Case 4: value is undefined (prop was never set); derive the value from whichever option
|
|
282
|
+
// has checked: true, matching native radio-button initial-state behaviour.
|
|
266
283
|
const checkedOption =
|
|
267
|
-
(
|
|
284
|
+
(_h = this.internalOptions) === null || _h === void 0 ? void 0 : _h.find((option) => option.checked);
|
|
268
285
|
this.value =
|
|
269
|
-
(
|
|
270
|
-
|
|
271
|
-
?
|
|
286
|
+
(_j = checkedOption === null || checkedOption === void 0 ? void 0 : checkedOption.value) !== null &&
|
|
287
|
+
_j !== void 0
|
|
288
|
+
? _j
|
|
272
289
|
: '';
|
|
273
290
|
this.internalOptions =
|
|
274
|
-
(
|
|
291
|
+
(_k = this.internalOptions) === null || _k === void 0
|
|
275
292
|
? void 0
|
|
276
|
-
:
|
|
277
|
-
(
|
|
293
|
+
: _k.map((option) => Object.assign(Object.assign({}, option), { checked: option.value === this.value }));
|
|
294
|
+
(_m = (_l = this.internals) === null || _l === void 0 ? void 0 : _l.setFormValue) === null || _m === void 0
|
|
278
295
|
? void 0
|
|
279
|
-
:
|
|
296
|
+
: _m.call(_l, (_o = this.value) !== null && _o !== void 0 ? _o : '');
|
|
280
297
|
}
|
|
281
298
|
/**
|
|
282
299
|
* If a `hintText` prop is passed, the id generated from it will be set to the internal `hintTextId` state to match with the fieldset `aria-describedBy` attribute.
|
|
@@ -299,27 +316,27 @@ const OntarioRadioButtons$1 = /*@__PURE__*/ proxyCustomElement(
|
|
|
299
316
|
const error = !!this.errorMessage;
|
|
300
317
|
return h(
|
|
301
318
|
'div',
|
|
302
|
-
{ key: '
|
|
319
|
+
{ key: 'd4abd3961692197f8c1f05e6abbc4c69888074f6', class: error ? 'ontario-input--error' : '' },
|
|
303
320
|
h(
|
|
304
321
|
'fieldset',
|
|
305
322
|
{
|
|
306
|
-
'key': '
|
|
323
|
+
'key': '3becc5a2f570d5ba636639919db6009a973e686f',
|
|
307
324
|
'class': 'ontario-fieldset',
|
|
308
325
|
'aria-describedby': this.hintTextId,
|
|
309
326
|
},
|
|
310
327
|
this.captionState.getCaption(undefined, !!this.internalHintExpander),
|
|
311
328
|
this.internalHintText &&
|
|
312
329
|
h('ontario-hint-text', {
|
|
313
|
-
key: '
|
|
330
|
+
key: 'f00f87af83af1294a041e3ab185bd5e9e31c54aa',
|
|
314
331
|
hint: this.internalHintText.hint,
|
|
315
332
|
hintContentType: this.internalHintText.hintContentType,
|
|
316
333
|
ref: (el) => (this.hintTextRef = el),
|
|
317
334
|
}),
|
|
318
335
|
h(
|
|
319
336
|
'div',
|
|
320
|
-
{ key: '
|
|
337
|
+
{ key: '414f4e82831fbd80c1785e3d4ff93a20ee636e33', class: 'ontario-radios' },
|
|
321
338
|
h(ErrorMessage, {
|
|
322
|
-
key: '
|
|
339
|
+
key: '117f4e8cbfc45a205713e4f8a0152a4246ebcc9d',
|
|
323
340
|
message: this.errorMessage,
|
|
324
341
|
error: error,
|
|
325
342
|
}),
|
|
@@ -364,9 +381,9 @@ const OntarioRadioButtons$1 = /*@__PURE__*/ proxyCustomElement(
|
|
|
364
381
|
this.internalHintExpander &&
|
|
365
382
|
h(
|
|
366
383
|
'div',
|
|
367
|
-
{ key: '
|
|
384
|
+
{ key: 'f0a4b33b9c4b82c66cd2c94b70356ad9aad05727', class: 'ontario-radios__hint-expander' },
|
|
368
385
|
h('ontario-hint-expander', {
|
|
369
|
-
'key': '
|
|
386
|
+
'key': '417d89d778b6e0bb4b8b83dffd33f1f134dcf21b',
|
|
370
387
|
'hint': this.internalHintExpander.hint,
|
|
371
388
|
'content': this.internalHintExpander.content,
|
|
372
389
|
'hintContentType': this.internalHintExpander.hintContentType,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"file":"ontario-radio-buttons.js","mappings":";;;;;;;;;;;;;;AAAA,MAAM,sBAAsB,GAAG,4oWAA4oW;;MCmD9pWA,qBAAmB,iBAAAC,kBAAA,CAAA,MAAA,mBAAA,SAAAC,CAAA,CAAA;AANhC,IAAA,WAAA,GAAA;;;;;;;;;AA6EC;;;;AAIG;AACK,QAAA,IAAQ,CAAA,QAAA,GAAa,KAAK;AAkclC;AAhVA;;AAEG;AAEH,IAAA,oBAAoB,CAAC,KAA4B,EAAA;AAChD,QAAA,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE;AACnB,YAAA,IAAI,CAAC,QAAQ,GAAG,gBAAgB,CAAC,KAAK,CAAC;;;AAIzC;;;AAGG;AAEH,IAAA,2BAA2B,CAAC,KAAoD,EAAA;QAC/E,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AAA,EAAA,CAAA,CACpB,CACN,CACI,CACI,CACN;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","names":["OntarioRadioButtons","__stencil_proxyCustomElement","HTMLElement"],"sources":["src/components/ontario-radio-buttons/ontario-radio-buttons.scss?tag=ontario-radio-buttons&encapsulation=shadow","src/components/ontario-radio-buttons/ontario-radio-buttons.tsx"],"sourcesContent":["@use 'sass:math';\n@use 'pkg:@ongov/ontario-design-system-global-styles/styles/scss/1-variables/global.variables' as globalVariables;\n@use 'pkg:@ongov/ontario-design-system-global-styles/styles/scss/1-variables/spacing.variables' as spacing;\n@use 'pkg:@ongov/ontario-design-system-global-styles/styles/scss/1-variables/colours.variables' as colours;\n@use 'pkg:@ongov/ontario-design-system-global-styles/styles/scss/1-variables/breakpoints.variables' as breakpoints;\n@use 'pkg:@ongov/ontario-design-system-global-styles/styles/scss/1-variables/fonts.variables' as fonts;\n@use 'pkg:@ongov/ontario-design-system-global-styles/styles/scss/1-variables/z-index.variables' as zIndex;\n@use 'pkg:@ongov/ontario-design-system-global-styles/styles/scss/1-variables/font-sizes.variables' as fontSizes;\n@use 'pkg:@ongov/ontario-design-system-global-styles/styles/scss/1-variables/line-heights.variables' as lineheight;\n@use 'pkg:@ongov/ontario-design-system-global-styles/styles/scss/1-variables/font-weights.variables' as fontWeights;\n@use 'pkg:@ongov/ontario-design-system-global-styles/styles/scss/2-tools/placeholder/focus.placeholders' as placeholders;\n@use 'pkg:@ongov/ontario-design-system-global-styles/styles/scss/4-elements/global.elements';\n@use 'pkg:@ongov/ontario-design-system-global-styles/styles/scss/7-overrides/visibility.overrides';\n\n@use '../../styles/fieldsets.scss';\n@use '../../styles/labels.scss';\n@use '../../styles/text-inputs.scss';\n@forward '../../utils/components/error-message/error-message';\n\n$ontario-radios-size: 32px;\n$ontario-radios-size-mobile: 36px;\n$ontario-input-offset: math.div((globalVariables.$touch-target-size - $ontario-radios-size), 2);\n\n.ontario-radios {\n\tpadding: spacing.$spacing-0 spacing.$spacing-0 spacing.$spacing-0 math.div(spacing.$spacing-1, 2);\n\tmax-width: globalVariables.$standard-width;\n}\n\n.ontario-radios__item {\n\tposition: relative;\n\tdisplay: block;\n\tmargin: spacing.$spacing-0 spacing.$spacing-0 spacing.$spacing-4;\n\tpadding: spacing.$spacing-0 spacing.$spacing-6 spacing.$spacing-0;\n\n\t&:last-of-type {\n\t\tmargin-bottom: spacing.$spacing-0;\n\t}\n\n\t.ontario-radios__hint-expander {\n\t\tmargin: spacing.$spacing-3 spacing.$spacing-0 spacing.$spacing-0 spacing.$spacing-2;\n\n\t\t@media screen and (max-width: breakpoints.$small-breakpoint) {\n\t\t\tmargin-top: spacing.$spacing-4;\n\t\t}\n\t}\n}\n\n.ontario-radios__input {\n\tcursor: pointer;\n\tmargin: spacing.$spacing-0;\n\tposition: absolute;\n\topacity: 0;\n\ttop: $ontario-input-offset * -1;\n\tleft: $ontario-input-offset * -1;\n\twidth: globalVariables.$touch-target-size;\n\theight: globalVariables.$touch-target-size;\n\tz-index: zIndex.$ontario-z-index-neutral;\n\n\t@media screen and (max-width: breakpoints.$small-breakpoint) {\n\t\twidth: globalVariables.$touch-target-size-mobile;\n\t\theight: globalVariables.$touch-target-size-mobile;\n\t\ttop: $ontario-input-offset * -0.75;\n\t\tleft: $ontario-input-offset * -0.75;\n\t}\n}\n\n.ontario-radios__label {\n\tcursor: pointer;\n\tcolor: colours.$ontario-colour-black;\n\tdisplay: inline-block;\n\tfont-family: fonts.$ontario-font-raleway-modified;\n\tfont-size: fontSizes.$ontario-font-size-standard-body-text;\n\tfont-weight: fontWeights.$ontario-font-weights-bold;\n\tline-height: globalVariables.$line-height-default;\n\t// Specific spacing required in order to visually align label with input\n\tmargin: 0.2rem 0;\n\tmax-width: globalVariables.$narrow-width;\n\tpadding: spacing.$spacing-0 spacing.$spacing-3;\n\t// remove 300ms pause on mobile\n\ttouch-action: manipulation;\n\twhite-space: normal;\n\twidth: auto;\n\twhite-space: normal;\n\n\t@media screen and (max-width: breakpoints.$small-breakpoint) {\n\t\t// Specific spacing required in order to visually align label with input\n\t\tmargin: 0.3rem spacing.$spacing-0;\n\t\tpadding: spacing.$spacing-0 spacing.$spacing-4;\n\t}\n\n\t&:before {\n\t\tcontent: '';\n\t\tborder: globalVariables.$border-size-standard solid colours.$ontario-colour-black;\n\t\tborder-radius: 50%;\n\t\tbox-sizing: border-box;\n\t\tposition: absolute;\n\t\ttop: 0;\n\t\tleft: 0;\n\t\twidth: $ontario-radios-size;\n\t\theight: $ontario-radios-size;\n\t\ttransition: border 0.1s ease-in-out;\n\n\t\t@media screen and (max-width: breakpoints.$small-breakpoint) {\n\t\t\twidth: $ontario-radios-size-mobile;\n\t\t\theight: $ontario-radios-size-mobile;\n\t\t}\n\t}\n\n\t&:after {\n\t\tcontent: '';\n\t\tborder-radius: 50%;\n\t\tborder: 10px solid colours.$ontario-colour-black;\n\t\tposition: absolute;\n\t\ttop: 0;\n\t\tleft: 0;\n\t\ttransform: translate($ontario-input-offset * 3, $ontario-input-offset * 3);\n\t\topacity: 0;\n\n\t\t@media screen and (max-width: breakpoints.$small-breakpoint) {\n\t\t\tborder: 12px solid colours.$ontario-colour-black;\n\t\t}\n\t}\n}\n\n.ontario-radios__input:focus + .ontario-radios__label:before {\n\t-moz-box-shadow: placeholders.$ontario-focus-box-shadow;\n\t-webkit-box-shadow: colours.$ontario-colour-focus;\n\t@extend %ontario-focus;\n}\n\n.ontario-radios__input:checked + .ontario-radios__label:after {\n\topacity: 1;\n}\n\n.ontario-radios__hint-expander {\n\tmargin: spacing.$spacing-3 spacing.$spacing-0 spacing.$spacing-0 spacing.$spacing-0;\n\n\t@media screen and (max-width: breakpoints.$small-breakpoint) {\n\t\tmargin-top: spacing.$spacing-4;\n\t}\n}\n","import { Component, h, Prop, State, Event, Listen, Watch, Element, EventEmitter, AttachInternals } from '@stencil/core';\nimport { RadioButtons } from './radio-buttons.interface';\nimport { RadioOption } from './radio-option.interface';\n\nimport { Input } from '../../utils/common/input/input';\nimport { Hint } from '../../utils/common/common.interface';\nimport { InputCaption } from '../../utils/common/input-caption/input-caption';\nimport { Caption } from '../../utils/common/input-caption/caption.interface';\nimport { HintExpander } from '../ontario-hint-expander/hint-expander.interface';\nimport {\n\tvalidateObjectExists,\n\tvalidatePropExists,\n\tvalidateLanguage,\n} from '../../utils/validation/validation-functions';\nimport { ConsoleMessageClass } from '../../utils/console-message/console-message';\nimport { Language } from '../../utils/common/language-types';\nimport { constructHintTextObject } from '../../utils/components/hints/hints';\nimport {\n\tInputFocusBlurEvent,\n\tRadioAndCheckboxChangeEvent,\n\tEventType,\n} from '../../utils/events/event-handler.interface';\nimport { handleInputEvent } from '../../utils/events/event-handler';\nimport { ErrorMessage } from '../../utils/components/error-message/error-message';\nimport { ConsoleType } from '../../utils/console-message/console-message.enum';\nimport { HeaderLanguageToggleEventDetails } from '../../utils/events/common-events.interface';\n\nimport { default as translations } from '../../translations/global.i18n.json';\n\n/**\n * Ontario Radio Buttons captures a single choice from a defined option set.\n *\n * This component intentionally does not expose group-level `readOnly` or `disabled` props.\n *\n * To support accessible and understandable form completion:\n * - keep options and submission actions available\n * - use validation and error messaging to guide corrections\n *\n * For component guidance, see:\n * - https://designsystem.ontario.ca/components/detail/radio-buttons.html\n * - https://designsystem.ontario.ca/developer-docs/components/ontario-radio-buttons/\n *\n * Disabled/read-only policy source:\n * - https://designsystem.ontario.ca/components/detail/buttons.html#disabled-buttons\n */\n@Component({\n\ttag: 'ontario-radio-buttons',\n\tstyleUrl: 'ontario-radio-buttons.scss',\n\tshadow: true,\n\tformAssociated: true,\n})\nexport class OntarioRadioButtons implements RadioButtons {\n\t@Element() element: HTMLElement;\n\t@AttachInternals() internals: ElementInternals;\n\n\thintTextRef: HTMLOntarioHintTextElement | undefined;\n\n\t/**\n\t * The text to display for the radio button legend.\n\t *\n\t * @example\n\t * <ontario-radio-buttons\n\t * caption='{\n\t * \"captionText\": \"Radio legend\",\n\t * \"captionType\": \"heading\",\n\t * }'\n\t * required=\"true\"\n\t * ...>\n\t * </ontario-radio-buttons>\n\t */\n\t@Prop() caption: Caption | string;\n\t/**\n\t * The language of the component.\n\t * This is used for translations, and is by default set through event listeners checking for a language property from the header. If no language is passed, it will default to English.\n\t */\n\t@Prop({ mutable: true }) language?: Language;\n\n\t/**\n\t * The name assigned to the radio button. The name value is used to reference form data after a form is submitted.\n\t */\n\t@Prop() name: string;\n\n\t/**\n\t * Used to include the ontario-hint-text component for radio button group.\n\t * This is optional.\n\t */\n\t@Prop() hintText?: string | Hint;\n\n\t/**\n\t * Used to include the ontario-hint-expander component for the radio button group.\n\t * This is passed in as an object with key-value pairs.\n\t *\n\t * This is optional.\n\t *\n\t * @example\n\t * <ontario-radio-buttons\n\t * caption='{\n\t * \"captionText\": \"Radio legend\",\n\t * \"captionType\": \"heading\",\n\t * }'\n\t * \t name=\"radios\"\n\t * options='[\n\t * \t {\n\t * \"value\": \"radio-option-1\",\n\t * \t\t \"elementId\": \"radio-1\",\n\t * \"label\": \"Radio option 1 label\",\n\t * \"hintExpander\": {\n\t *\t\t\t \"hint\": \"Hint expander for radio option 1\",\n\t * \t\t \"content\": \"Example hint expander content for radio option 1.\"\n\t *\t\t }\n\t * }\n\t * ]'\n\t * hint-expander='{\n\t * \"hint\": \"Hint expander for the radio button group\",\n\t * \"content\": \"Example hint expander content for the radio button group.\"\n\t * }'\n\t * required=\"true\"\n\t * >\n\t * </ontario-radio-buttons>\n\t */\n\t@Prop() hintExpander?: HintExpander | string;\n\n\t/**\n\t * This is used to determine whether the radio button is required or not.\n\t * This prop also gets passed to the InputCaption utility to display either an optional or required flag in the label.\n\t * If no prop is set, it will default to false (optional).\n\t */\n\t@Prop() required?: boolean = false;\n\n\t/**\n\t * The currently selected radio option value.\n\t *\n\t * The component keeps the host `value` in sync as users interact with the radio group.\n\t * If `value` is provided, it takes precedence over any `checked` flags passed through `options`.\n\t */\n\t@Prop({ mutable: true }) value?: string;\n\n\t/**\n\t * The options for the radio button group.\n\t *\n\t * Each property will be passed in through an object in the options array.\n\t * This can either be passed in as an object directly (if using react), or as a string in HTML.\n\t * If there are multiple radio buttons in a group, each radio button will be displayed as an option.\n\t *\n\t * In the example below, the options are being passed in as a string and there are two radio buttons to be displayed in the group.\n\t *\n\t * @example\n\t * <ontario-radio-buttons\n\t * caption='{\n\t * \"captionText\": \"Radio legend\",\n\t * \"captionType\": \"heading\",\n\t * }'\n\t * name=\"radios\"\n\t * hint-text=\"Hint text for the radio button group.\"\n\t * options='[\n\t * {\n\t * \"value\": \"radio-option-1\",\n\t * \t\t \"elementId\": \"radio-1\",\n\t * \"label\": \"Radio option 1 label\"\n\t * },\n\t * {\n\t * \"value\": \"radio-option-2\",\n\t * \t\t \"elementId\": \"radio-2\",\n\t * \"label\": \"Radio option 2 label\",\n\t * \"hintExpander\": {\n\t *\t\t\t \"hint\": \"Hint expander for radio option 2\",\n\t * \t\t \"content\": \"Example hint expander content for radio option 2.\"\n\t *\t\t }\n\t * }\n\t * ]'\n\t * required=\"true\"\n\t * >\n\t * </ontario-radio-buttons>\n\t */\n\t@Prop() options: string | RadioOption[];\n\n\t/**\n\t * Set this to display an error message\n\t */\n\t@Prop({ mutable: true }) errorMessage?: string;\n\n\t/**\n\t * Used to add a custom function to the radio input onChange event.\n\t */\n\t@Prop() customOnChange?: (event: globalThis.Event) => void;\n\n\t/**\n\t * Used to add a custom function to the radio input onBlur event.\n\t */\n\t@Prop() customOnBlur?: (event: globalThis.Event) => void;\n\n\t/**\n\t * Used to add a custom function to the radio input onFocus event.\n\t */\n\t@Prop() customOnFocus?: (event: globalThis.Event) => void;\n\n\t/**\n\t * Used for the `aria-describedby` value of the radio button group. This will match with the id of the hint text.\n\t */\n\t@State() hintTextId: string | null | undefined;\n\n\t/**\n\t * The hint text options are re-assigned to the internalHintText array.\n\t */\n\t@State() private internalHintText: Hint;\n\n\t/**\n\t * The hint expander options are re-assigned to the internalHintExpander array.\n\t */\n\t@State() private internalHintExpander: HintExpander;\n\n\t/**\n\t * The options are re-assigned to the internalOptions array.\n\t */\n\t@State() private internalOptions: RadioOption[];\n\n\t/**\n\t * Instantiate an InputCaption object for internal logic use\n\t */\n\t@State() private captionState: InputCaption;\n\n\t/**\n\t * Emitted when a keyboard input or mouse event occurs when a radio option has been changed.\n\t */\n\t@Event({ eventName: 'radioOnChange' }) radioOnChange: EventEmitter<RadioAndCheckboxChangeEvent>;\n\n\t/**\n\t * Emitted when a keyboard input event occurs when a radio option has lost focus.\n\t */\n\t@Event({ eventName: 'radioOnBlur' }) radioOnBlur: EventEmitter<InputFocusBlurEvent>;\n\n\t/**\n\t * Emitted when a keyboard input event occurs when a radio option has gained focus.\n\t */\n\t@Event({ eventName: 'radioOnFocus' }) radioOnFocus: EventEmitter<InputFocusBlurEvent>;\n\n\t/**\n\t * Emitted when an error message is reported to the component.\n\t */\n\t@Event() inputErrorOccurred: EventEmitter<{ errorMessage: string }>;\n\n\t/**\n\t * This listens for the `setAppLanguage` event sent from the test language toggler when it is is connected to the DOM. It is used for the initial language when the input component loads.\n\t */\n\t@Listen('setAppLanguage', { target: 'window' })\n\thandleSetAppLanguage(event: CustomEvent<Language>) {\n\t\tif (!this.language) {\n\t\t\tthis.language = validateLanguage(event);\n\t\t}\n\t}\n\n\t/**\n\t * Handles an update to the language should the user request a language update from the language toggle.\n\t * @param {CustomEvent} - The language that has been selected.\n\t */\n\t@Listen('headerLanguageToggled', { target: 'window' })\n\thandleHeaderLanguageToggled(event: CustomEvent<HeaderLanguageToggleEventDetails>) {\n\t\tthis.language = validateLanguage(event.detail.newLanguage);\n\t}\n\n\t/**\n\t * Watch for changes to the `hintText` prop.\n\t *\n\t * If a `hintText` prop is passed, the `constructHintTextObject` function will convert it to the correct format, and set the result to the `internalHintText` state.\n\t */\n\t@Watch('hintText')\n\tprivate parseHintText() {\n\t\tif (this.hintText) {\n\t\t\tconst hintTextObject = constructHintTextObject(this.hintText);\n\t\t\tthis.internalHintText = hintTextObject;\n\t\t}\n\t}\n\n\t/**\n\t * Watch for changes to the `hintExpander` prop.\n\t *\n\t * If a `hintExpander` prop is passed, it will be parsed (if it is a string), and the result will be set to the `internalHintExpander` state.\n\t */\n\t@Watch('hintExpander')\n\tprivate parseHintExpander() {\n\t\tconst hintExpander = this.hintExpander;\n\t\tif (hintExpander) {\n\t\t\ttry {\n\t\t\t\tif (typeof hintExpander === 'string') this.internalHintExpander = JSON.parse(hintExpander);\n\t\t\t\telse this.internalHintExpander = hintExpander;\n\t\t\t} catch (error) {\n\t\t\t\tconst message = new ConsoleMessageClass();\n\t\t\t\tmessage\n\t\t\t\t\t.addDesignSystemTag()\n\t\t\t\t\t.addMonospaceText(' hintExpander ')\n\t\t\t\t\t.addRegularText('for')\n\t\t\t\t\t.addMonospaceText(' <ontario-radio-buttons> ')\n\t\t\t\t\t.addRegularText('was not provided in a valid format')\n\t\t\t\t\t.addMonospaceText(error.stack)\n\t\t\t\t\t.printMessage(ConsoleType.Error);\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Watch for changes to the `options` prop.\n\t *\n\t * If an `options` prop is passed, it will be parsed (if it is a string), and the result will be set to the `internalOptions` state. The result will be run through a validation function.\n\t */\n\t@Watch('options')\n\tparseOptions() {\n\t\tif (typeof this.options !== 'undefined') {\n\t\t\ttry {\n\t\t\t\tif (!Array.isArray(this.options)) {\n\t\t\t\t\tthis.internalOptions = JSON.parse(this.options);\n\t\t\t\t} else {\n\t\t\t\t\tthis.internalOptions = this.options;\n\t\t\t\t}\n\t\t\t} catch (error) {\n\t\t\t\tconst message = new ConsoleMessageClass();\n\t\t\t\tmessage\n\t\t\t\t\t.addDesignSystemTag()\n\t\t\t\t\t.addMonospaceText(' options ')\n\t\t\t\t\t.addRegularText('for')\n\t\t\t\t\t.addMonospaceText(' <ontario-radio-buttons> ')\n\t\t\t\t\t.addRegularText('was not provided in a valid format')\n\t\t\t\t\t.addMonospaceText(error.stack)\n\t\t\t\t\t.printMessage(ConsoleType.Error);\n\t\t\t}\n\t\t}\n\n\t\tthis.syncValueFromOptions();\n\t}\n\n\t/*\n\t * Watch for changes in the `name` prop for validation purposes.\n\t *\n\t * Validate the `name` and make sure the `name` prop has a value.\n\t * Log a warning if user doesn't input a value for the `name`.\n\t */\n\t@Watch('name')\n\tvalidateName(newValue: string) {\n\t\tif (validatePropExists(newValue)) {\n\t\t\tconst message = new ConsoleMessageClass();\n\t\t\tmessage\n\t\t\t\t.addDesignSystemTag()\n\t\t\t\t.addMonospaceText(' name ')\n\t\t\t\t.addRegularText('for')\n\t\t\t\t.addMonospaceText(' <ontario-radio-buttons> ')\n\t\t\t\t.addRegularText('was not provided')\n\t\t\t\t.printMessage();\n\t\t}\n\t}\n\n\t/*\n\t * Watch for changes in the `options` prop for validation purposes.\n\n\t * Validate the `options` and make sure the `options` prop has a value.\n\t * Log a warning if user doesn't input a value for the `options`.\n\t */\n\t@Watch('options')\n\tvalidateOptions(newValue: object) {\n\t\tif (validateObjectExists(newValue)) {\n\t\t\tconst message = new ConsoleMessageClass();\n\t\t\tmessage\n\t\t\t\t.addDesignSystemTag()\n\t\t\t\t.addMonospaceText(' options ')\n\t\t\t\t.addRegularText('for')\n\t\t\t\t.addMonospaceText(' <ontario-radio-buttons> ')\n\t\t\t\t.addRegularText('was not provided')\n\t\t\t\t.printMessage();\n\t\t}\n\t}\n\n\t/**\n\t * Watch for changes to the `caption` prop.\n\t *\n\t * The caption will be run through the InputCaption constructor to convert it to the correct format, and set the result to the `captionState` state.\n\t * @param newValue: Caption | string\n\t */\n\t@Watch('caption')\n\tupdateCaptionState(newValue: Caption | string) {\n\t\tthis.captionState = new InputCaption(\n\t\t\tthis.element.tagName,\n\t\t\tnewValue,\n\t\t\ttranslations,\n\t\t\tthis.language,\n\t\t\ttrue,\n\t\t\tthis.required,\n\t\t);\n\t}\n\n\t/**\n\t * Watch for changes to the `language` prop to render either the English or French translations\n\t */\n\t@Watch('language')\n\tupdateLanguage() {\n\t\tthis.updateCaptionState(this.caption);\n\t}\n\n\t@Watch('errorMessage')\n\tbroadcastInputErrorOccurredEvent() {\n\t\t// Emit event to notify anyone who wants to listen for errors occurring\n\t\tthis.inputErrorOccurred.emit({ errorMessage: this.errorMessage ?? '' });\n\t}\n\n\t@Watch('value')\n\tsyncValueFromValueProp() {\n\t\tif (this.internalOptions) {\n\t\t\tthis.syncValueFromOptions();\n\t\t}\n\t}\n\n\t/**\n\t * Function to handle radio buttons events and the information pertaining to the radio buttons to emit.\n\t */\n\tprivate handleEvent(event: Event, eventType: EventType) {\n\t\tif (eventType === EventType.Change) {\n\t\t\tevent.stopPropagation();\n\t\t}\n\n\t\tconst input = event.target as HTMLInputElement | null;\n\n\t\t// Reset all internalOptions checked states\n\t\tconst changedOption = this.internalOptions\n\t\t\t.map((x) => {\n\t\t\t\tx.checked = false;\n\t\t\t\treturn x;\n\t\t\t})\n\t\t\t.find((x) => x.value === input?.value);\n\t\t// Set the new checked state for the selected value\n\t\tif (changedOption) changedOption.checked = !changedOption?.checked;\n\t\tthis.value = this.internalOptions.find((x) => !!x.checked)?.value ?? '';\n\n\t\t// Set the value within the form\n\t\tthis.internals?.setFormValue?.(this.value ?? '');\n\n\t\thandleInputEvent(\n\t\t\tevent,\n\t\t\teventType,\n\t\t\tinput,\n\t\t\tthis.radioOnChange,\n\t\t\tthis.radioOnFocus,\n\t\t\tthis.radioOnBlur,\n\t\t\tundefined,\n\t\t\t'radio',\n\t\t\tthis.customOnChange,\n\t\t\tthis.customOnFocus,\n\t\t\tthis.customOnBlur,\n\t\t\tundefined,\n\t\t\tundefined,\n\t\t);\n\n\t\tif (eventType === EventType.Change) {\n\t\t\tthis.emitHostValueEvent('change');\n\t\t}\n\t}\n\n\tprivate emitHostValueEvent(name: 'change') {\n\t\tthis.element.dispatchEvent(\n\t\t\tnew CustomEvent(name, {\n\t\t\t\tbubbles: true,\n\t\t\t\tcomposed: true,\n\t\t\t\tdetail: {\n\t\t\t\t\tvalue: this.value ?? '',\n\t\t\t\t},\n\t\t\t}),\n\t\t);\n\t}\n\n\tprivate syncValueFromOptions() {\n\t\tconst hasMatchingValue = this.value && this.internalOptions?.some((option) => option.value === this.value);\n\t\tif (hasMatchingValue) {\n\t\t\tthis.internalOptions = this.internalOptions.map((option) => ({\n\t\t\t\t...option,\n\t\t\t\tchecked: option.value === this.value,\n\t\t\t}));\n\t\t\tthis.internals?.setFormValue?.(this.value ?? '');\n\t\t\treturn;\n\t\t}\n\n\t\tif (this.value) {\n\t\t\tconst message = new ConsoleMessageClass();\n\t\t\tmessage\n\t\t\t\t.addDesignSystemTag()\n\t\t\t\t.addMonospaceText(' value ')\n\t\t\t\t.addRegularText('for')\n\t\t\t\t.addMonospaceText(' <ontario-radio-buttons> ')\n\t\t\t\t.addRegularText('did not match any option values. Falling back to the checked option.')\n\t\t\t\t.printMessage();\n\t\t}\n\n\t\tconst checkedOption = this.internalOptions?.find((option) => option.checked);\n\t\tthis.value = checkedOption?.value ?? '';\n\t\tthis.internalOptions = this.internalOptions?.map((option) => ({\n\t\t\t...option,\n\t\t\tchecked: option.value === this.value,\n\t\t}));\n\t\tthis.internals?.setFormValue?.(this.value ?? '');\n\t}\n\n\t/**\n\t * If a `hintText` prop is passed, the id generated from it will be set to the internal `hintTextId` state to match with the fieldset `aria-describedBy` attribute.\n\t */\n\tasync componentDidLoad() {\n\t\tthis.hintTextId = await this.hintTextRef?.getHintTextId();\n\t}\n\n\tcomponentWillLoad() {\n\t\tthis.updateCaptionState(this.caption);\n\t\tthis.parseOptions();\n\t\tthis.parseHintText();\n\t\tthis.parseHintExpander();\n\t\tthis.validateName(this.name);\n\t\tthis.validateOptions(this.internalOptions);\n\t\tthis.language = validateLanguage(this.language);\n\t}\n\n\trender() {\n\t\tconst error = !!this.errorMessage;\n\t\treturn (\n\t\t\t<div class={error ? 'ontario-input--error' : ''}>\n\t\t\t\t<fieldset class=\"ontario-fieldset\" aria-describedby={this.hintTextId}>\n\t\t\t\t\t{this.captionState.getCaption(undefined, !!this.internalHintExpander)}\n\t\t\t\t\t{this.internalHintText && (\n\t\t\t\t\t\t<ontario-hint-text\n\t\t\t\t\t\t\thint={this.internalHintText.hint}\n\t\t\t\t\t\t\thintContentType={this.internalHintText.hintContentType}\n\t\t\t\t\t\t\tref={(el) => (this.hintTextRef = el)}\n\t\t\t\t\t\t></ontario-hint-text>\n\t\t\t\t\t)}\n\n\t\t\t\t\t<div class=\"ontario-radios\">\n\t\t\t\t\t\t<ErrorMessage message={this.errorMessage} error={error} />\n\t\t\t\t\t\t{this.internalOptions?.map((radioOption) => (\n\t\t\t\t\t\t\t<div class=\"ontario-radios__item\">\n\t\t\t\t\t\t\t\t<Input\n\t\t\t\t\t\t\t\t\tclassName=\"ontario-radios__input\"\n\t\t\t\t\t\t\t\t\tid={radioOption.elementId}\n\t\t\t\t\t\t\t\t\tname={this.name}\n\t\t\t\t\t\t\t\t\ttype=\"radio\"\n\t\t\t\t\t\t\t\t\tvalue={radioOption.value}\n\t\t\t\t\t\t\t\t\trequired={!!this.required}\n\t\t\t\t\t\t\t\t\tchecked={!!radioOption.checked}\n\t\t\t\t\t\t\t\t\tonChange={(e) => this.handleEvent(e, EventType.Change)}\n\t\t\t\t\t\t\t\t\tonBlur={(e) => this.handleEvent(e, EventType.Blur)}\n\t\t\t\t\t\t\t\t\tonFocus={(e) => this.handleEvent(e, EventType.Focus)}\n\t\t\t\t\t\t\t\t></Input>\n\t\t\t\t\t\t\t\t<label class=\"ontario-radios__label\" htmlFor={radioOption.elementId}>\n\t\t\t\t\t\t\t\t\t{radioOption.label}\n\t\t\t\t\t\t\t\t\t{radioOption.hintExpander &&\n\t\t\t\t\t\t\t\t\t\tthis.captionState.getHintExpanderAccessibilityText(radioOption.label, true)}\n\t\t\t\t\t\t\t\t</label>\n\n\t\t\t\t\t\t\t\t{radioOption.hintExpander && (\n\t\t\t\t\t\t\t\t\t<div class=\"ontario-radios__hint-expander\">\n\t\t\t\t\t\t\t\t\t\t<ontario-hint-expander\n\t\t\t\t\t\t\t\t\t\t\thint={radioOption.hintExpander.hint}\n\t\t\t\t\t\t\t\t\t\t\tcontent={radioOption.hintExpander.content}\n\t\t\t\t\t\t\t\t\t\t\thintContentType={radioOption.hintExpander.hintContentType}\n\t\t\t\t\t\t\t\t\t\t\tinput-exists\n\t\t\t\t\t\t\t\t\t\t></ontario-hint-expander>\n\t\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t)}\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t))}\n\n\t\t\t\t\t\t{this.internalHintExpander && (\n\t\t\t\t\t\t\t<div class=\"ontario-radios__hint-expander\">\n\t\t\t\t\t\t\t\t<ontario-hint-expander\n\t\t\t\t\t\t\t\t\thint={this.internalHintExpander.hint}\n\t\t\t\t\t\t\t\t\tcontent={this.internalHintExpander.content}\n\t\t\t\t\t\t\t\t\thintContentType={this.internalHintExpander.hintContentType}\n\t\t\t\t\t\t\t\t\tinput-exists\n\t\t\t\t\t\t\t\t></ontario-hint-expander>\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t)}\n\t\t\t\t\t</div>\n\t\t\t\t</fieldset>\n\t\t\t</div>\n\t\t);\n\t}\n}\n"],"version":3}
|
|
1
|
+
{"file":"ontario-radio-buttons.js","mappings":";;;;;;;;;;;;;;AAAA,MAAM,sBAAsB,GAAG,4oWAA4oW;;MCmD9pWA,qBAAmB,iBAAAC,kBAAA,CAAA,MAAA,mBAAA,SAAAC,CAAA,CAAA;AANhC,IAAA,WAAA,GAAA;;;;;;;;;AA6EC;;;;AAIG;AACK,QAAA,IAAQ,CAAA,QAAA,GAAa,KAAK;AA+clC;AA7VA;;AAEG;AAEH,IAAA,oBAAoB,CAAC,KAA4B,EAAA;AAChD,QAAA,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE;AACnB,YAAA,IAAI,CAAC,QAAQ,GAAG,gBAAgB,CAAC,KAAK,CAAC;;;AAIzC;;;AAGG;AAEH,IAAA,2BAA2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A,uBAAA,EAAA,EACC,IAAI,EAAE,WAAW,CAAC,YAAY,CAAC,IAAI,EACnC,OAAO,EAAE,WAAW,CAAC,YAAY,CAAC,OAAO,EACzC,eAAe,EAAE,WAAW,CAAC,YAAY,CAAC,eAAe,EAAA,cAAA,EAAA,IAAA,EAAA,CAEjC,CACpB,CACN,CACI,CACN,CAAC,EAED,IAAI,CAAC,oBAAoB,KACzB,CAAK,CAAA,KAAA,EAAA,EAAA,GAAA,EAAA,0CAAA,EAAA,KAAK,EAAC,+BAA+B,EAAA,EACzC,CAAA,CAAA,uBAAA,EAAA,EAAA,GAAA,EAAA,0CAAA,EACC,IAAI,EAAE,IAAI,CAAC,oBAAoB,CAAC,IAAI,EACpC,OAAO,EAAE,IAAI,CAAC,oBAAoB,CAAC,OAAO,EAC1C,eAAe,EAAE,IAAI,CAAC,oBAAoB,CAAC,eAAe,EAElC,cAAA,EAAA,IAAA,EAAA,CAAA,CACpB,CACN,CACI,CACI,CACN;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","names":["OntarioRadioButtons","__stencil_proxyCustomElement","HTMLElement"],"sources":["src/components/ontario-radio-buttons/ontario-radio-buttons.scss?tag=ontario-radio-buttons&encapsulation=shadow","src/components/ontario-radio-buttons/ontario-radio-buttons.tsx"],"sourcesContent":["@use 'sass:math';\n@use 'pkg:@ongov/ontario-design-system-global-styles/styles/scss/1-variables/global.variables' as globalVariables;\n@use 'pkg:@ongov/ontario-design-system-global-styles/styles/scss/1-variables/spacing.variables' as spacing;\n@use 'pkg:@ongov/ontario-design-system-global-styles/styles/scss/1-variables/colours.variables' as colours;\n@use 'pkg:@ongov/ontario-design-system-global-styles/styles/scss/1-variables/breakpoints.variables' as breakpoints;\n@use 'pkg:@ongov/ontario-design-system-global-styles/styles/scss/1-variables/fonts.variables' as fonts;\n@use 'pkg:@ongov/ontario-design-system-global-styles/styles/scss/1-variables/z-index.variables' as zIndex;\n@use 'pkg:@ongov/ontario-design-system-global-styles/styles/scss/1-variables/font-sizes.variables' as fontSizes;\n@use 'pkg:@ongov/ontario-design-system-global-styles/styles/scss/1-variables/line-heights.variables' as lineheight;\n@use 'pkg:@ongov/ontario-design-system-global-styles/styles/scss/1-variables/font-weights.variables' as fontWeights;\n@use 'pkg:@ongov/ontario-design-system-global-styles/styles/scss/2-tools/placeholder/focus.placeholders' as placeholders;\n@use 'pkg:@ongov/ontario-design-system-global-styles/styles/scss/4-elements/global.elements';\n@use 'pkg:@ongov/ontario-design-system-global-styles/styles/scss/7-overrides/visibility.overrides';\n\n@use '../../styles/fieldsets.scss';\n@use '../../styles/labels.scss';\n@use '../../styles/text-inputs.scss';\n@forward '../../utils/components/error-message/error-message';\n\n$ontario-radios-size: 32px;\n$ontario-radios-size-mobile: 36px;\n$ontario-input-offset: math.div((globalVariables.$touch-target-size - $ontario-radios-size), 2);\n\n.ontario-radios {\n\tpadding: spacing.$spacing-0 spacing.$spacing-0 spacing.$spacing-0 math.div(spacing.$spacing-1, 2);\n\tmax-width: globalVariables.$standard-width;\n}\n\n.ontario-radios__item {\n\tposition: relative;\n\tdisplay: block;\n\tmargin: spacing.$spacing-0 spacing.$spacing-0 spacing.$spacing-4;\n\tpadding: spacing.$spacing-0 spacing.$spacing-6 spacing.$spacing-0;\n\n\t&:last-of-type {\n\t\tmargin-bottom: spacing.$spacing-0;\n\t}\n\n\t.ontario-radios__hint-expander {\n\t\tmargin: spacing.$spacing-3 spacing.$spacing-0 spacing.$spacing-0 spacing.$spacing-2;\n\n\t\t@media screen and (max-width: breakpoints.$small-breakpoint) {\n\t\t\tmargin-top: spacing.$spacing-4;\n\t\t}\n\t}\n}\n\n.ontario-radios__input {\n\tcursor: pointer;\n\tmargin: spacing.$spacing-0;\n\tposition: absolute;\n\topacity: 0;\n\ttop: $ontario-input-offset * -1;\n\tleft: $ontario-input-offset * -1;\n\twidth: globalVariables.$touch-target-size;\n\theight: globalVariables.$touch-target-size;\n\tz-index: zIndex.$ontario-z-index-neutral;\n\n\t@media screen and (max-width: breakpoints.$small-breakpoint) {\n\t\twidth: globalVariables.$touch-target-size-mobile;\n\t\theight: globalVariables.$touch-target-size-mobile;\n\t\ttop: $ontario-input-offset * -0.75;\n\t\tleft: $ontario-input-offset * -0.75;\n\t}\n}\n\n.ontario-radios__label {\n\tcursor: pointer;\n\tcolor: colours.$ontario-colour-black;\n\tdisplay: inline-block;\n\tfont-family: fonts.$ontario-font-raleway-modified;\n\tfont-size: fontSizes.$ontario-font-size-standard-body-text;\n\tfont-weight: fontWeights.$ontario-font-weights-bold;\n\tline-height: globalVariables.$line-height-default;\n\t// Specific spacing required in order to visually align label with input\n\tmargin: 0.2rem 0;\n\tmax-width: globalVariables.$narrow-width;\n\tpadding: spacing.$spacing-0 spacing.$spacing-3;\n\t// remove 300ms pause on mobile\n\ttouch-action: manipulation;\n\twhite-space: normal;\n\twidth: auto;\n\twhite-space: normal;\n\n\t@media screen and (max-width: breakpoints.$small-breakpoint) {\n\t\t// Specific spacing required in order to visually align label with input\n\t\tmargin: 0.3rem spacing.$spacing-0;\n\t\tpadding: spacing.$spacing-0 spacing.$spacing-4;\n\t}\n\n\t&:before {\n\t\tcontent: '';\n\t\tborder: globalVariables.$border-size-standard solid colours.$ontario-colour-black;\n\t\tborder-radius: 50%;\n\t\tbox-sizing: border-box;\n\t\tposition: absolute;\n\t\ttop: 0;\n\t\tleft: 0;\n\t\twidth: $ontario-radios-size;\n\t\theight: $ontario-radios-size;\n\t\ttransition: border 0.1s ease-in-out;\n\n\t\t@media screen and (max-width: breakpoints.$small-breakpoint) {\n\t\t\twidth: $ontario-radios-size-mobile;\n\t\t\theight: $ontario-radios-size-mobile;\n\t\t}\n\t}\n\n\t&:after {\n\t\tcontent: '';\n\t\tborder-radius: 50%;\n\t\tborder: 10px solid colours.$ontario-colour-black;\n\t\tposition: absolute;\n\t\ttop: 0;\n\t\tleft: 0;\n\t\ttransform: translate($ontario-input-offset * 3, $ontario-input-offset * 3);\n\t\topacity: 0;\n\n\t\t@media screen and (max-width: breakpoints.$small-breakpoint) {\n\t\t\tborder: 12px solid colours.$ontario-colour-black;\n\t\t}\n\t}\n}\n\n.ontario-radios__input:focus + .ontario-radios__label:before {\n\t-moz-box-shadow: placeholders.$ontario-focus-box-shadow;\n\t-webkit-box-shadow: colours.$ontario-colour-focus;\n\t@extend %ontario-focus;\n}\n\n.ontario-radios__input:checked + .ontario-radios__label:after {\n\topacity: 1;\n}\n\n.ontario-radios__hint-expander {\n\tmargin: spacing.$spacing-3 spacing.$spacing-0 spacing.$spacing-0 spacing.$spacing-0;\n\n\t@media screen and (max-width: breakpoints.$small-breakpoint) {\n\t\tmargin-top: spacing.$spacing-4;\n\t}\n}\n","import { Component, h, Prop, State, Event, Listen, Watch, Element, EventEmitter, AttachInternals } from '@stencil/core';\nimport { RadioButtons } from './radio-buttons.interface';\nimport { RadioOption } from './radio-option.interface';\n\nimport { Input } from '../../utils/common/input/input';\nimport { Hint } from '../../utils/common/common.interface';\nimport { InputCaption } from '../../utils/common/input-caption/input-caption';\nimport { Caption } from '../../utils/common/input-caption/caption.interface';\nimport { HintExpander } from '../ontario-hint-expander/hint-expander.interface';\nimport {\n\tvalidateObjectExists,\n\tvalidatePropExists,\n\tvalidateLanguage,\n} from '../../utils/validation/validation-functions';\nimport { ConsoleMessageClass } from '../../utils/console-message/console-message';\nimport { Language } from '../../utils/common/language-types';\nimport { constructHintTextObject } from '../../utils/components/hints/hints';\nimport {\n\tInputFocusBlurEvent,\n\tRadioAndCheckboxChangeEvent,\n\tEventType,\n} from '../../utils/events/event-handler.interface';\nimport { handleInputEvent } from '../../utils/events/event-handler';\nimport { ErrorMessage } from '../../utils/components/error-message/error-message';\nimport { ConsoleType } from '../../utils/console-message/console-message.enum';\nimport { HeaderLanguageToggleEventDetails } from '../../utils/events/common-events.interface';\n\nimport { default as translations } from '../../translations/global.i18n.json';\n\n/**\n * Ontario Radio Buttons captures a single choice from a defined option set.\n *\n * This component intentionally does not expose group-level `readOnly` or `disabled` props.\n *\n * To support accessible and understandable form completion:\n * - keep options and submission actions available\n * - use validation and error messaging to guide corrections\n *\n * For component guidance, see:\n * - https://designsystem.ontario.ca/components/detail/radio-buttons.html\n * - https://designsystem.ontario.ca/developer-docs/components/ontario-radio-buttons/\n *\n * Disabled/read-only policy source:\n * - https://designsystem.ontario.ca/components/detail/buttons.html#disabled-buttons\n */\n@Component({\n\ttag: 'ontario-radio-buttons',\n\tstyleUrl: 'ontario-radio-buttons.scss',\n\tshadow: true,\n\tformAssociated: true,\n})\nexport class OntarioRadioButtons implements RadioButtons {\n\t@Element() element: HTMLElement;\n\t@AttachInternals() internals: ElementInternals;\n\n\thintTextRef: HTMLOntarioHintTextElement | undefined;\n\n\t/**\n\t * The text to display for the radio button legend.\n\t *\n\t * @example\n\t * <ontario-radio-buttons\n\t * caption='{\n\t * \"captionText\": \"Radio legend\",\n\t * \"captionType\": \"heading\",\n\t * }'\n\t * required=\"true\"\n\t * ...>\n\t * </ontario-radio-buttons>\n\t */\n\t@Prop() caption: Caption | string;\n\t/**\n\t * The language of the component.\n\t * This is used for translations, and is by default set through event listeners checking for a language property from the header. If no language is passed, it will default to English.\n\t */\n\t@Prop({ mutable: true }) language?: Language;\n\n\t/**\n\t * The name assigned to the radio button. The name value is used to reference form data after a form is submitted.\n\t */\n\t@Prop() name: string;\n\n\t/**\n\t * Used to include the ontario-hint-text component for radio button group.\n\t * This is optional.\n\t */\n\t@Prop() hintText?: string | Hint;\n\n\t/**\n\t * Used to include the ontario-hint-expander component for the radio button group.\n\t * This is passed in as an object with key-value pairs.\n\t *\n\t * This is optional.\n\t *\n\t * @example\n\t * <ontario-radio-buttons\n\t * caption='{\n\t * \"captionText\": \"Radio legend\",\n\t * \"captionType\": \"heading\",\n\t * }'\n\t * \t name=\"radios\"\n\t * options='[\n\t * \t {\n\t * \"value\": \"radio-option-1\",\n\t * \t\t \"elementId\": \"radio-1\",\n\t * \"label\": \"Radio option 1 label\",\n\t * \"hintExpander\": {\n\t *\t\t\t \"hint\": \"Hint expander for radio option 1\",\n\t * \t\t \"content\": \"Example hint expander content for radio option 1.\"\n\t *\t\t }\n\t * }\n\t * ]'\n\t * hint-expander='{\n\t * \"hint\": \"Hint expander for the radio button group\",\n\t * \"content\": \"Example hint expander content for the radio button group.\"\n\t * }'\n\t * required=\"true\"\n\t * >\n\t * </ontario-radio-buttons>\n\t */\n\t@Prop() hintExpander?: HintExpander | string;\n\n\t/**\n\t * This is used to determine whether the radio button is required or not.\n\t * This prop also gets passed to the InputCaption utility to display either an optional or required flag in the label.\n\t * If no prop is set, it will default to false (optional).\n\t */\n\t@Prop() required?: boolean = false;\n\n\t/**\n\t * The currently selected radio option value.\n\t *\n\t * The component keeps the host `value` in sync as users interact with the radio group.\n\t * If `value` is provided, it takes precedence over any `checked` flags passed through `options`.\n\t */\n\t@Prop({ mutable: true }) value?: string;\n\n\t/**\n\t * The options for the radio button group.\n\t *\n\t * Each property will be passed in through an object in the options array.\n\t * This can either be passed in as an object directly (if using react), or as a string in HTML.\n\t * If there are multiple radio buttons in a group, each radio button will be displayed as an option.\n\t *\n\t * In the example below, the options are being passed in as a string and there are two radio buttons to be displayed in the group.\n\t *\n\t * @example\n\t * <ontario-radio-buttons\n\t * caption='{\n\t * \"captionText\": \"Radio legend\",\n\t * \"captionType\": \"heading\",\n\t * }'\n\t * name=\"radios\"\n\t * hint-text=\"Hint text for the radio button group.\"\n\t * options='[\n\t * {\n\t * \"value\": \"radio-option-1\",\n\t * \t\t \"elementId\": \"radio-1\",\n\t * \"label\": \"Radio option 1 label\"\n\t * },\n\t * {\n\t * \"value\": \"radio-option-2\",\n\t * \t\t \"elementId\": \"radio-2\",\n\t * \"label\": \"Radio option 2 label\",\n\t * \"hintExpander\": {\n\t *\t\t\t \"hint\": \"Hint expander for radio option 2\",\n\t * \t\t \"content\": \"Example hint expander content for radio option 2.\"\n\t *\t\t }\n\t * }\n\t * ]'\n\t * required=\"true\"\n\t * >\n\t * </ontario-radio-buttons>\n\t */\n\t@Prop() options: string | RadioOption[];\n\n\t/**\n\t * Set this to display an error message\n\t */\n\t@Prop({ mutable: true }) errorMessage?: string;\n\n\t/**\n\t * Used to add a custom function to the radio input onChange event.\n\t */\n\t@Prop() customOnChange?: (event: globalThis.Event) => void;\n\n\t/**\n\t * Used to add a custom function to the radio input onBlur event.\n\t */\n\t@Prop() customOnBlur?: (event: globalThis.Event) => void;\n\n\t/**\n\t * Used to add a custom function to the radio input onFocus event.\n\t */\n\t@Prop() customOnFocus?: (event: globalThis.Event) => void;\n\n\t/**\n\t * Used for the `aria-describedby` value of the radio button group. This will match with the id of the hint text.\n\t */\n\t@State() hintTextId: string | null | undefined;\n\n\t/**\n\t * The hint text options are re-assigned to the internalHintText array.\n\t */\n\t@State() private internalHintText: Hint;\n\n\t/**\n\t * The hint expander options are re-assigned to the internalHintExpander array.\n\t */\n\t@State() private internalHintExpander: HintExpander;\n\n\t/**\n\t * The options are re-assigned to the internalOptions array.\n\t */\n\t@State() private internalOptions: RadioOption[];\n\n\t/**\n\t * Instantiate an InputCaption object for internal logic use\n\t */\n\t@State() private captionState: InputCaption;\n\n\t/**\n\t * Emitted when a keyboard input or mouse event occurs when a radio option has been changed.\n\t */\n\t@Event({ eventName: 'radioOnChange' }) radioOnChange: EventEmitter<RadioAndCheckboxChangeEvent>;\n\n\t/**\n\t * Emitted when a keyboard input event occurs when a radio option has lost focus.\n\t */\n\t@Event({ eventName: 'radioOnBlur' }) radioOnBlur: EventEmitter<InputFocusBlurEvent>;\n\n\t/**\n\t * Emitted when a keyboard input event occurs when a radio option has gained focus.\n\t */\n\t@Event({ eventName: 'radioOnFocus' }) radioOnFocus: EventEmitter<InputFocusBlurEvent>;\n\n\t/**\n\t * Emitted when an error message is reported to the component.\n\t */\n\t@Event() inputErrorOccurred: EventEmitter<{ errorMessage: string }>;\n\n\t/**\n\t * This listens for the `setAppLanguage` event sent from the test language toggler when it is is connected to the DOM. It is used for the initial language when the input component loads.\n\t */\n\t@Listen('setAppLanguage', { target: 'window' })\n\thandleSetAppLanguage(event: CustomEvent<Language>) {\n\t\tif (!this.language) {\n\t\t\tthis.language = validateLanguage(event);\n\t\t}\n\t}\n\n\t/**\n\t * Handles an update to the language should the user request a language update from the language toggle.\n\t * @param {CustomEvent} - The language that has been selected.\n\t */\n\t@Listen('headerLanguageToggled', { target: 'window' })\n\thandleHeaderLanguageToggled(event: CustomEvent<HeaderLanguageToggleEventDetails>) {\n\t\tthis.language = validateLanguage(event.detail.newLanguage);\n\t}\n\n\t/**\n\t * Watch for changes to the `hintText` prop.\n\t *\n\t * If a `hintText` prop is passed, the `constructHintTextObject` function will convert it to the correct format, and set the result to the `internalHintText` state.\n\t */\n\t@Watch('hintText')\n\tprivate parseHintText() {\n\t\tif (this.hintText) {\n\t\t\tconst hintTextObject = constructHintTextObject(this.hintText);\n\t\t\tthis.internalHintText = hintTextObject;\n\t\t}\n\t}\n\n\t/**\n\t * Watch for changes to the `hintExpander` prop.\n\t *\n\t * If a `hintExpander` prop is passed, it will be parsed (if it is a string), and the result will be set to the `internalHintExpander` state.\n\t */\n\t@Watch('hintExpander')\n\tprivate parseHintExpander() {\n\t\tconst hintExpander = this.hintExpander;\n\t\tif (hintExpander) {\n\t\t\ttry {\n\t\t\t\tif (typeof hintExpander === 'string') this.internalHintExpander = JSON.parse(hintExpander);\n\t\t\t\telse this.internalHintExpander = hintExpander;\n\t\t\t} catch (error) {\n\t\t\t\tconst message = new ConsoleMessageClass();\n\t\t\t\tmessage\n\t\t\t\t\t.addDesignSystemTag()\n\t\t\t\t\t.addMonospaceText(' hintExpander ')\n\t\t\t\t\t.addRegularText('for')\n\t\t\t\t\t.addMonospaceText(' <ontario-radio-buttons> ')\n\t\t\t\t\t.addRegularText('was not provided in a valid format')\n\t\t\t\t\t.addMonospaceText(error.stack)\n\t\t\t\t\t.printMessage(ConsoleType.Error);\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Watch for changes to the `options` prop.\n\t *\n\t * If an `options` prop is passed, it will be parsed (if it is a string), and the result will be set to the `internalOptions` state. The result will be run through a validation function.\n\t */\n\t@Watch('options')\n\tparseOptions() {\n\t\tif (typeof this.options !== 'undefined') {\n\t\t\ttry {\n\t\t\t\tif (!Array.isArray(this.options)) {\n\t\t\t\t\tthis.internalOptions = JSON.parse(this.options);\n\t\t\t\t} else {\n\t\t\t\t\tthis.internalOptions = this.options;\n\t\t\t\t}\n\t\t\t} catch (error) {\n\t\t\t\tconst message = new ConsoleMessageClass();\n\t\t\t\tmessage\n\t\t\t\t\t.addDesignSystemTag()\n\t\t\t\t\t.addMonospaceText(' options ')\n\t\t\t\t\t.addRegularText('for')\n\t\t\t\t\t.addMonospaceText(' <ontario-radio-buttons> ')\n\t\t\t\t\t.addRegularText('was not provided in a valid format')\n\t\t\t\t\t.addMonospaceText(error.stack)\n\t\t\t\t\t.printMessage(ConsoleType.Error);\n\t\t\t}\n\t\t}\n\n\t\tthis.syncValueFromOptions();\n\t}\n\n\t/*\n\t * Watch for changes in the `name` prop for validation purposes.\n\t *\n\t * Validate the `name` and make sure the `name` prop has a value.\n\t * Log a warning if user doesn't input a value for the `name`.\n\t */\n\t@Watch('name')\n\tvalidateName(newValue: string) {\n\t\tif (validatePropExists(newValue)) {\n\t\t\tconst message = new ConsoleMessageClass();\n\t\t\tmessage\n\t\t\t\t.addDesignSystemTag()\n\t\t\t\t.addMonospaceText(' name ')\n\t\t\t\t.addRegularText('for')\n\t\t\t\t.addMonospaceText(' <ontario-radio-buttons> ')\n\t\t\t\t.addRegularText('was not provided')\n\t\t\t\t.printMessage();\n\t\t}\n\t}\n\n\t/*\n\t * Watch for changes in the `options` prop for validation purposes.\n\n\t * Validate the `options` and make sure the `options` prop has a value.\n\t * Log a warning if user doesn't input a value for the `options`.\n\t */\n\t@Watch('options')\n\tvalidateOptions(newValue: object) {\n\t\tif (validateObjectExists(newValue)) {\n\t\t\tconst message = new ConsoleMessageClass();\n\t\t\tmessage\n\t\t\t\t.addDesignSystemTag()\n\t\t\t\t.addMonospaceText(' options ')\n\t\t\t\t.addRegularText('for')\n\t\t\t\t.addMonospaceText(' <ontario-radio-buttons> ')\n\t\t\t\t.addRegularText('was not provided')\n\t\t\t\t.printMessage();\n\t\t}\n\t}\n\n\t/**\n\t * Watch for changes to the `caption` prop.\n\t *\n\t * The caption will be run through the InputCaption constructor to convert it to the correct format, and set the result to the `captionState` state.\n\t * @param newValue: Caption | string\n\t */\n\t@Watch('caption')\n\tupdateCaptionState(newValue: Caption | string) {\n\t\tthis.captionState = new InputCaption(\n\t\t\tthis.element.tagName,\n\t\t\tnewValue,\n\t\t\ttranslations,\n\t\t\tthis.language,\n\t\t\ttrue,\n\t\t\tthis.required,\n\t\t);\n\t}\n\n\t/**\n\t * Watch for changes to the `language` prop to render either the English or French translations\n\t */\n\t@Watch('language')\n\tupdateLanguage() {\n\t\tthis.updateCaptionState(this.caption);\n\t}\n\n\t@Watch('errorMessage')\n\tbroadcastInputErrorOccurredEvent() {\n\t\t// Emit event to notify anyone who wants to listen for errors occurring\n\t\tthis.inputErrorOccurred.emit({ errorMessage: this.errorMessage ?? '' });\n\t}\n\n\t@Watch('value')\n\tsyncValueFromValueProp() {\n\t\tif (this.internalOptions) {\n\t\t\tthis.syncValueFromOptions();\n\t\t}\n\t}\n\n\t/**\n\t * Function to handle radio buttons events and the information pertaining to the radio buttons to emit.\n\t */\n\tprivate handleEvent(event: Event, eventType: EventType) {\n\t\tif (eventType === EventType.Change) {\n\t\t\tevent.stopPropagation();\n\t\t}\n\n\t\tconst input = event.target as HTMLInputElement | null;\n\n\t\t// Reset all internalOptions checked states\n\t\tconst changedOption = this.internalOptions\n\t\t\t.map((x) => {\n\t\t\t\tx.checked = false;\n\t\t\t\treturn x;\n\t\t\t})\n\t\t\t.find((x) => x.value === input?.value);\n\t\t// Set the new checked state for the selected value\n\t\tif (changedOption) changedOption.checked = !changedOption?.checked;\n\t\tthis.value = this.internalOptions.find((x) => !!x.checked)?.value ?? '';\n\n\t\t// Set the value within the form\n\t\tthis.internals?.setFormValue?.(this.value ?? '');\n\n\t\thandleInputEvent(\n\t\t\tevent,\n\t\t\teventType,\n\t\t\tinput,\n\t\t\tthis.radioOnChange,\n\t\t\tthis.radioOnFocus,\n\t\t\tthis.radioOnBlur,\n\t\t\tundefined,\n\t\t\t'radio',\n\t\t\tthis.customOnChange,\n\t\t\tthis.customOnFocus,\n\t\t\tthis.customOnBlur,\n\t\t\tundefined,\n\t\t\tundefined,\n\t\t);\n\n\t\tif (eventType === EventType.Change) {\n\t\t\tthis.emitHostValueEvent('change');\n\t\t}\n\t}\n\n\tprivate emitHostValueEvent(name: 'change') {\n\t\tthis.element.dispatchEvent(\n\t\t\tnew CustomEvent(name, {\n\t\t\t\tbubbles: true,\n\t\t\t\tcomposed: true,\n\t\t\t\tdetail: {\n\t\t\t\t\tvalue: this.value ?? '',\n\t\t\t\t},\n\t\t\t}),\n\t\t);\n\t}\n\n\tprivate syncValueFromOptions() {\n\t\t// Case 1: a non-empty value was provided and matches one of the options; derive checked state from value.\n\t\tconst hasMatchingValue = this.value && this.internalOptions?.some((option) => option.value === this.value);\n\t\tif (hasMatchingValue) {\n\t\t\tthis.internalOptions = this.internalOptions.map((option) => ({\n\t\t\t\t...option,\n\t\t\t\tchecked: option.value === this.value,\n\t\t\t}));\n\t\t\tthis.internals?.setFormValue?.(this.value ?? '');\n\t\t\treturn;\n\t\t}\n\n\t\t// Case 2: value was explicitly set to ''; the consumer wants to clear the selection.\n\t\t// Distinguish this from undefined (prop never set) so the fallback below does not silently\n\t\t// re-select the previously checked option.\n\t\tif (this.value === '') {\n\t\t\tthis.internalOptions = this.internalOptions?.map((option) => ({ ...option, checked: false }));\n\t\t\tthis.internals?.setFormValue?.('');\n\t\t\treturn;\n\t\t}\n\n\t\t// Case 3: a non-empty value was provided but did not match any option; warn and fall back.\n\t\tif (this.value) {\n\t\t\tconst message = new ConsoleMessageClass();\n\t\t\tmessage\n\t\t\t\t.addDesignSystemTag()\n\t\t\t\t.addMonospaceText(' value ')\n\t\t\t\t.addRegularText('for')\n\t\t\t\t.addMonospaceText(' <ontario-radio-buttons> ')\n\t\t\t\t.addRegularText('did not match any option values. Falling back to the checked option.')\n\t\t\t\t.printMessage();\n\t\t}\n\n\t\t// Case 4: value is undefined (prop was never set); derive the value from whichever option\n\t\t// has checked: true, matching native radio-button initial-state behaviour.\n\t\tconst checkedOption = this.internalOptions?.find((option) => option.checked);\n\t\tthis.value = checkedOption?.value ?? '';\n\t\tthis.internalOptions = this.internalOptions?.map((option) => ({\n\t\t\t...option,\n\t\t\tchecked: option.value === this.value,\n\t\t}));\n\t\tthis.internals?.setFormValue?.(this.value ?? '');\n\t}\n\n\t/**\n\t * If a `hintText` prop is passed, the id generated from it will be set to the internal `hintTextId` state to match with the fieldset `aria-describedBy` attribute.\n\t */\n\tasync componentDidLoad() {\n\t\tthis.hintTextId = await this.hintTextRef?.getHintTextId();\n\t}\n\n\tcomponentWillLoad() {\n\t\tthis.updateCaptionState(this.caption);\n\t\tthis.parseOptions();\n\t\tthis.parseHintText();\n\t\tthis.parseHintExpander();\n\t\tthis.validateName(this.name);\n\t\tthis.validateOptions(this.internalOptions);\n\t\tthis.language = validateLanguage(this.language);\n\t}\n\n\trender() {\n\t\tconst error = !!this.errorMessage;\n\t\treturn (\n\t\t\t<div class={error ? 'ontario-input--error' : ''}>\n\t\t\t\t<fieldset class=\"ontario-fieldset\" aria-describedby={this.hintTextId}>\n\t\t\t\t\t{this.captionState.getCaption(undefined, !!this.internalHintExpander)}\n\t\t\t\t\t{this.internalHintText && (\n\t\t\t\t\t\t<ontario-hint-text\n\t\t\t\t\t\t\thint={this.internalHintText.hint}\n\t\t\t\t\t\t\thintContentType={this.internalHintText.hintContentType}\n\t\t\t\t\t\t\tref={(el) => (this.hintTextRef = el)}\n\t\t\t\t\t\t></ontario-hint-text>\n\t\t\t\t\t)}\n\n\t\t\t\t\t<div class=\"ontario-radios\">\n\t\t\t\t\t\t<ErrorMessage message={this.errorMessage} error={error} />\n\t\t\t\t\t\t{this.internalOptions?.map((radioOption) => (\n\t\t\t\t\t\t\t<div class=\"ontario-radios__item\">\n\t\t\t\t\t\t\t\t<Input\n\t\t\t\t\t\t\t\t\tclassName=\"ontario-radios__input\"\n\t\t\t\t\t\t\t\t\tid={radioOption.elementId}\n\t\t\t\t\t\t\t\t\tname={this.name}\n\t\t\t\t\t\t\t\t\ttype=\"radio\"\n\t\t\t\t\t\t\t\t\tvalue={radioOption.value}\n\t\t\t\t\t\t\t\t\trequired={!!this.required}\n\t\t\t\t\t\t\t\t\tchecked={!!radioOption.checked}\n\t\t\t\t\t\t\t\t\tonChange={(e) => this.handleEvent(e, EventType.Change)}\n\t\t\t\t\t\t\t\t\tonBlur={(e) => this.handleEvent(e, EventType.Blur)}\n\t\t\t\t\t\t\t\t\tonFocus={(e) => this.handleEvent(e, EventType.Focus)}\n\t\t\t\t\t\t\t\t></Input>\n\t\t\t\t\t\t\t\t<label class=\"ontario-radios__label\" htmlFor={radioOption.elementId}>\n\t\t\t\t\t\t\t\t\t{radioOption.label}\n\t\t\t\t\t\t\t\t\t{radioOption.hintExpander &&\n\t\t\t\t\t\t\t\t\t\tthis.captionState.getHintExpanderAccessibilityText(radioOption.label, true)}\n\t\t\t\t\t\t\t\t</label>\n\n\t\t\t\t\t\t\t\t{radioOption.hintExpander && (\n\t\t\t\t\t\t\t\t\t<div class=\"ontario-radios__hint-expander\">\n\t\t\t\t\t\t\t\t\t\t<ontario-hint-expander\n\t\t\t\t\t\t\t\t\t\t\thint={radioOption.hintExpander.hint}\n\t\t\t\t\t\t\t\t\t\t\tcontent={radioOption.hintExpander.content}\n\t\t\t\t\t\t\t\t\t\t\thintContentType={radioOption.hintExpander.hintContentType}\n\t\t\t\t\t\t\t\t\t\t\tinput-exists\n\t\t\t\t\t\t\t\t\t\t></ontario-hint-expander>\n\t\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t)}\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t))}\n\n\t\t\t\t\t\t{this.internalHintExpander && (\n\t\t\t\t\t\t\t<div class=\"ontario-radios__hint-expander\">\n\t\t\t\t\t\t\t\t<ontario-hint-expander\n\t\t\t\t\t\t\t\t\thint={this.internalHintExpander.hint}\n\t\t\t\t\t\t\t\t\tcontent={this.internalHintExpander.content}\n\t\t\t\t\t\t\t\t\thintContentType={this.internalHintExpander.hintContentType}\n\t\t\t\t\t\t\t\t\tinput-exists\n\t\t\t\t\t\t\t\t></ontario-hint-expander>\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t)}\n\t\t\t\t\t</div>\n\t\t\t\t</fieldset>\n\t\t\t</div>\n\t\t);\n\t}\n}\n"],"version":3}
|
|
@@ -10483,7 +10483,8 @@ const OntarioRadioButtons = class {
|
|
|
10483
10483
|
);
|
|
10484
10484
|
}
|
|
10485
10485
|
syncValueFromOptions() {
|
|
10486
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
10486
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
|
|
10487
|
+
// Case 1: a non-empty value was provided and matches one of the options; derive checked state from value.
|
|
10487
10488
|
const hasMatchingValue =
|
|
10488
10489
|
this.value &&
|
|
10489
10490
|
((_a = this.internalOptions) === null || _a === void 0
|
|
@@ -10498,6 +10499,20 @@ const OntarioRadioButtons = class {
|
|
|
10498
10499
|
: _c.call(_b, (_d = this.value) !== null && _d !== void 0 ? _d : '');
|
|
10499
10500
|
return;
|
|
10500
10501
|
}
|
|
10502
|
+
// Case 2: value was explicitly set to ''; the consumer wants to clear the selection.
|
|
10503
|
+
// Distinguish this from undefined (prop never set) so the fallback below does not silently
|
|
10504
|
+
// re-select the previously checked option.
|
|
10505
|
+
if (this.value === '') {
|
|
10506
|
+
this.internalOptions =
|
|
10507
|
+
(_e = this.internalOptions) === null || _e === void 0
|
|
10508
|
+
? void 0
|
|
10509
|
+
: _e.map((option) => Object.assign(Object.assign({}, option), { checked: false }));
|
|
10510
|
+
(_g = (_f = this.internals) === null || _f === void 0 ? void 0 : _f.setFormValue) === null || _g === void 0
|
|
10511
|
+
? void 0
|
|
10512
|
+
: _g.call(_f, '');
|
|
10513
|
+
return;
|
|
10514
|
+
}
|
|
10515
|
+
// Case 3: a non-empty value was provided but did not match any option; warn and fall back.
|
|
10501
10516
|
if (this.value) {
|
|
10502
10517
|
const message = new consoleMessage.ConsoleMessageClass();
|
|
10503
10518
|
message
|
|
@@ -10508,19 +10523,21 @@ const OntarioRadioButtons = class {
|
|
|
10508
10523
|
.addRegularText('did not match any option values. Falling back to the checked option.')
|
|
10509
10524
|
.printMessage();
|
|
10510
10525
|
}
|
|
10526
|
+
// Case 4: value is undefined (prop was never set); derive the value from whichever option
|
|
10527
|
+
// has checked: true, matching native radio-button initial-state behaviour.
|
|
10511
10528
|
const checkedOption =
|
|
10512
|
-
(
|
|
10529
|
+
(_h = this.internalOptions) === null || _h === void 0 ? void 0 : _h.find((option) => option.checked);
|
|
10513
10530
|
this.value =
|
|
10514
|
-
(
|
|
10515
|
-
?
|
|
10531
|
+
(_j = checkedOption === null || checkedOption === void 0 ? void 0 : checkedOption.value) !== null && _j !== void 0
|
|
10532
|
+
? _j
|
|
10516
10533
|
: '';
|
|
10517
10534
|
this.internalOptions =
|
|
10518
|
-
(
|
|
10535
|
+
(_k = this.internalOptions) === null || _k === void 0
|
|
10519
10536
|
? void 0
|
|
10520
|
-
:
|
|
10521
|
-
(
|
|
10537
|
+
: _k.map((option) => Object.assign(Object.assign({}, option), { checked: option.value === this.value }));
|
|
10538
|
+
(_m = (_l = this.internals) === null || _l === void 0 ? void 0 : _l.setFormValue) === null || _m === void 0
|
|
10522
10539
|
? void 0
|
|
10523
|
-
:
|
|
10540
|
+
: _m.call(_l, (_o = this.value) !== null && _o !== void 0 ? _o : '');
|
|
10524
10541
|
}
|
|
10525
10542
|
/**
|
|
10526
10543
|
* If a `hintText` prop is passed, the id generated from it will be set to the internal `hintTextId` state to match with the fieldset `aria-describedBy` attribute.
|
|
@@ -10543,27 +10560,27 @@ const OntarioRadioButtons = class {
|
|
|
10543
10560
|
const error = !!this.errorMessage;
|
|
10544
10561
|
return index.h(
|
|
10545
10562
|
'div',
|
|
10546
|
-
{ key: '
|
|
10563
|
+
{ key: 'd4abd3961692197f8c1f05e6abbc4c69888074f6', class: error ? 'ontario-input--error' : '' },
|
|
10547
10564
|
index.h(
|
|
10548
10565
|
'fieldset',
|
|
10549
10566
|
{
|
|
10550
|
-
'key': '
|
|
10567
|
+
'key': '3becc5a2f570d5ba636639919db6009a973e686f',
|
|
10551
10568
|
'class': 'ontario-fieldset',
|
|
10552
10569
|
'aria-describedby': this.hintTextId,
|
|
10553
10570
|
},
|
|
10554
10571
|
this.captionState.getCaption(undefined, !!this.internalHintExpander),
|
|
10555
10572
|
this.internalHintText &&
|
|
10556
10573
|
index.h('ontario-hint-text', {
|
|
10557
|
-
key: '
|
|
10574
|
+
key: 'f00f87af83af1294a041e3ab185bd5e9e31c54aa',
|
|
10558
10575
|
hint: this.internalHintText.hint,
|
|
10559
10576
|
hintContentType: this.internalHintText.hintContentType,
|
|
10560
10577
|
ref: (el) => (this.hintTextRef = el),
|
|
10561
10578
|
}),
|
|
10562
10579
|
index.h(
|
|
10563
10580
|
'div',
|
|
10564
|
-
{ key: '
|
|
10581
|
+
{ key: '414f4e82831fbd80c1785e3d4ff93a20ee636e33', class: 'ontario-radios' },
|
|
10565
10582
|
index.h(ErrorMessage, {
|
|
10566
|
-
key: '
|
|
10583
|
+
key: '117f4e8cbfc45a205713e4f8a0152a4246ebcc9d',
|
|
10567
10584
|
message: this.errorMessage,
|
|
10568
10585
|
error: error,
|
|
10569
10586
|
}),
|
|
@@ -10608,9 +10625,9 @@ const OntarioRadioButtons = class {
|
|
|
10608
10625
|
this.internalHintExpander &&
|
|
10609
10626
|
index.h(
|
|
10610
10627
|
'div',
|
|
10611
|
-
{ key: '
|
|
10628
|
+
{ key: 'f0a4b33b9c4b82c66cd2c94b70356ad9aad05727', class: 'ontario-radios__hint-expander' },
|
|
10612
10629
|
index.h('ontario-hint-expander', {
|
|
10613
|
-
'key': '
|
|
10630
|
+
'key': '417d89d778b6e0bb4b8b83dffd33f1f134dcf21b',
|
|
10614
10631
|
'hint': this.internalHintExpander.hint,
|
|
10615
10632
|
'content': this.internalHintExpander.content,
|
|
10616
10633
|
'hintContentType': this.internalHintExpander.hintContentType,
|