@warp-ds/elements 2.2.0-next.19 → 2.2.0-next.20

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.
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../packages/rip-and-tear-radio/radio.ts", "../../../packages/rip-and-tear-radio/form-associated-element.ts", "../../../packages/rip-and-tear-radio/base-element.ts", "../../../packages/rip-and-tear-radio/host-styles.ts", "../../../packages/rip-and-tear-radio/custom-error-validator.ts", "../../../packages/rip-and-tear-radio/invalid.ts", "../../../packages/rip-and-tear-radio/radio-styles.ts"],
4
- "sourcesContent": ["import type { PropertyValues } from 'lit';\nimport { html } from 'lit';\n\nimport { property, state } from 'lit/decorators.js';\n\nimport { BaseFormAssociatedElement } from './form-associated-element';\n// eslint-disable-next-line\n// @ts-ignore\nimport { styles } from './radio-styles';\n\nexport class WRadio extends BaseFormAssociatedElement {\n static css = [styles];\n\n @state() checked = false;\n\n /** @internal Used by radio group to force disable radios while preserving their original disabled state. */\n @state() forceDisabled = false;\n\n /**\n * The string pointing to a form's id.\n */\n @property({ reflect: true }) form: string | null = null;\n\n /** The radio's value. When selected, the radio group will receive this value. */\n @property({ reflect: true }) value: string;\n\n /** The radio's value. When selected, the radio group will receive this value. */\n @property({ reflect: true }) appearance: 'default' | 'button' | 'clickable' = 'default';\n\n /**\n * The radio's size. When used inside a radio group, the size will be determined by the radio group's size so this\n * attribute can typically be omitted.\n */\n @property({ reflect: true }) size: 'small' | 'medium' | 'large' = 'medium';\n\n /** Disables the radio. */\n @property({ type: Boolean }) disabled = false;\n\n constructor() {\n super();\n this.addEventListener('click', this.handleClick);\n }\n\n connectedCallback() {\n super.connectedCallback();\n this.setInitialAttributes();\n }\n\n private setInitialAttributes() {\n this.setAttribute('role', 'radio');\n this.tabIndex = 0;\n this.setAttribute('aria-disabled', this.disabled || this.forceDisabled ? 'true' : 'false');\n }\n\n updated(changedProperties: PropertyValues<this>) {\n super.updated(changedProperties);\n\n if (changedProperties.has('checked')) {\n this.customStates.set('checked', this.checked);\n this.setAttribute('aria-checked', this.checked ? 'true' : 'false');\n // Only set tabIndex if not disabled\n if (!this.disabled && !this.forceDisabled) {\n this.tabIndex = this.checked ? 0 : -1;\n }\n }\n\n if (changedProperties.has('disabled') || changedProperties.has('forceDisabled')) {\n const effectivelyDisabled = this.disabled || this.forceDisabled;\n this.customStates.set('disabled', effectivelyDisabled);\n this.setAttribute('aria-disabled', effectivelyDisabled ? 'true' : 'false');\n\n // Set tabIndex based on disabled state\n if (effectivelyDisabled) {\n this.tabIndex = -1;\n } else {\n // Restore proper tabIndex - this will be managed by the radio group\n this.tabIndex = this.checked ? 0 : -1;\n }\n }\n }\n\n /**\n * @override\n */\n setValue(): void {\n // We override `setValue` because we don't want to set form values from here. We want to do that in \"RadioGroup\" itself.\n }\n\n // Update the handleClick method (around line 75)\n private handleClick = () => {\n if (!this.disabled && !this.forceDisabled) {\n this.checked = true;\n }\n };\n\n render() {\n return html`\n <span part=\"control\" class=\"control\"></span>\n <slot part=\"label\" class=\"label\"></slot>\n `;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'w-radio': WRadio;\n }\n}\n", "import { LitElement, isServer } from 'lit';\n\nimport { property } from 'lit/decorators.js';\n\nimport BaseElement from './base-element.js';\nimport { CustomErrorValidator } from './custom-error-validator.js';\nimport { WInvalidEvent } from './invalid';\n\nexport interface Validator<T extends BaseFormAssociatedElement = BaseFormAssociatedElement> {\n observedAttributes?: string[];\n checkValidity: (element: T) => {\n message: string;\n isValid: boolean;\n invalidKeys: Exclude<keyof ValidityState, 'valid'>[];\n };\n message?: string | ((element: T) => string);\n}\n\nexport interface BaseFormControl extends BaseElement {\n // Form attributes\n name: null | string;\n disabled?: boolean;\n defaultValue?: unknown;\n defaultChecked?: boolean;\n checked?: boolean;\n defaultSelected?: boolean;\n selected?: boolean;\n form?: string | null;\n\n value?: unknown;\n\n // Constraint validation attributes\n pattern?: string;\n min?: number | string | Date;\n max?: number | string | Date;\n step?: number | 'any';\n required?: boolean;\n minlength?: number;\n maxlength?: number;\n\n // Form validation properties\n readonly validity: ValidityState;\n readonly validationMessage: string;\n\n // Form validation methods\n checkValidity: () => boolean;\n getForm: () => HTMLFormElement | null;\n reportValidity: () => boolean;\n setCustomValidity: (message: string) => void;\n\n // Form properties\n hasInteracted: boolean;\n valueHasChanged?: boolean;\n\n /** Convenience API for `setCustomValidity()` */\n customError: null | string;\n}\n\n// setFormValue omitted so that we can use `setValue`\nexport class BaseFormAssociatedElement extends BaseElement implements Omit<ElementInternals, 'form' | 'setFormValue'>, BaseFormControl {\n static formAssociated = true;\n\n /**\n * Validators are static because they have `observedAttributes`, essentially attributes to \"watch\"\n * for changes. Whenever these attributes change, we want to be notified and update the validator.\n */\n static get validators(): Validator[] {\n return [CustomErrorValidator()];\n }\n\n // Append all Validator \"observedAttributes\" into the \"observedAttributes\" so they can run.\n static get observedAttributes() {\n const parentAttrs = new Set(super.observedAttributes || []);\n\n for (const validator of this.validators) {\n if (!validator.observedAttributes) {\n continue;\n }\n\n for (const attr of validator.observedAttributes) {\n parentAttrs.add(attr);\n }\n }\n\n return [...parentAttrs];\n }\n\n // Form attributes\n /** The name of the input, submitted as a name/value pair with form data. */\n @property({ reflect: true }) name: string | null = null;\n\n /** Disables the form control. */\n @property({ type: Boolean }) disabled = false;\n\n required: boolean = false;\n\n assumeInteractionOn: string[] = ['input'];\n\n // Additional\n input?: (HTMLElement & { value: unknown }) | HTMLInputElement | HTMLTextAreaElement;\n\n validators: Validator[] = [];\n\n // Should these be private?\n @property({ state: true, attribute: false }) valueHasChanged: boolean = false;\n @property({ state: true, attribute: false }) hasInteracted: boolean = false;\n\n // This works around a limitation in Safari. It is a hacky way for us to preserve custom errors generated by the user.\n @property({ attribute: 'custom-error', reflect: true }) customError: string | null = null;\n\n private emittedEvents: string[] = [];\n\n constructor() {\n super();\n\n if (!isServer) {\n this.addEventListener('invalid', this.emitInvalid);\n }\n }\n // this bullshit makes no sense but tsc is angry about it\n // this needs both 'private' and 'typeof' or it will be angry and we don't know why\n // eslint-disable-next-line\n // @ts-ignore\n private states: typeof CustomStateSet;\n\n connectedCallback() {\n super.connectedCallback();\n this.updateValidity();\n\n // Lazily evaluate after the constructor to allow people to override the `assumeInteractionOn`\n this.assumeInteractionOn.forEach((event) => {\n this.addEventListener(event, this.handleInteraction);\n });\n }\n\n firstUpdated(...args: Parameters<LitElement['firstUpdated']>) {\n super.firstUpdated(...args);\n this.updateValidity();\n }\n\n emitInvalid = (e: Event) => {\n if (e.target !== this) return;\n\n // An \"invalid\" event counts as interacted, this is usually triggered by a button \"submitting\"\n this.hasInteracted = true;\n this.dispatchEvent(new WInvalidEvent());\n };\n\n protected willUpdate(changedProperties: Parameters<LitElement['willUpdate']>[0]) {\n if (!isServer && changedProperties.has('customError')) {\n // We use null because it we really don't want it to show up in the attributes because `custom-error` does reflect\n if (!this.customError) {\n this.customError = null;\n }\n this.setCustomValidity(this.customError || '');\n }\n\n if (changedProperties.has('value') || changedProperties.has('disabled')) {\n // @ts-expect-error Some components will use an accessors, other use a property, so we don't want to limit them.\n const value = this.value as unknown;\n\n // Accounts for the snowflake case on `<wa-select>`\n if (Array.isArray(value)) {\n if (this.name) {\n const formData = new FormData();\n for (const val of value) {\n formData.append(this.name, val as string);\n }\n this.setValue(formData, formData);\n }\n } else {\n this.setValue(value as FormData | string | File | null, value as FormData | string | File | null);\n }\n }\n\n if (changedProperties.has('disabled')) {\n this.customStates.set('disabled', this.disabled);\n\n if (this.hasAttribute('disabled') || (!isServer && !this.matches(':disabled'))) {\n this.toggleAttribute('disabled', this.disabled);\n }\n }\n\n this.updateValidity();\n super.willUpdate(changedProperties);\n }\n\n private handleInteraction = (event: Event) => {\n const emittedEvents = this.emittedEvents;\n if (!emittedEvents.includes(event.type)) {\n emittedEvents.push(event.type);\n }\n\n // Mark it as user-interacted as soon as all associated events have been emitted\n if (emittedEvents.length === this.assumeInteractionOn?.length) {\n this.hasInteracted = true;\n }\n };\n\n get labels() {\n return this.internals.labels;\n }\n\n getForm() {\n return this.internals.form;\n }\n\n @property({ attribute: false, state: true, type: Object })\n get validity() {\n return this.internals.validity;\n }\n\n // Not sure if this supports `novalidate`. Will need to test.\n get willValidate() {\n return this.internals.willValidate;\n }\n\n get validationMessage() {\n return this.internals.validationMessage;\n }\n\n checkValidity() {\n this.updateValidity();\n return this.internals.checkValidity();\n }\n\n reportValidity() {\n this.updateValidity();\n // This seems reasonable. `reportValidity()` is kind of like \"we expect you to have interacted\"\n this.hasInteracted = true;\n return this.internals.reportValidity();\n }\n\n /**\n * Override this to change where constraint validation popups are anchored.\n */\n get validationTarget(): undefined | HTMLElement {\n return (this.input || undefined) as undefined | HTMLElement;\n }\n\n setValidity(...args: Parameters<typeof this.internals.setValidity>) {\n const flags = args[0];\n const message = args[1];\n let anchor = args[2];\n\n if (!anchor) {\n anchor = this.validationTarget;\n }\n\n this.internals.setValidity(flags, message, anchor || undefined);\n this.requestUpdate('validity');\n this.setCustomStates();\n }\n\n setCustomStates() {\n const required = Boolean(this.required);\n const isValid = this.internals.validity.valid;\n const hasInteracted = this.hasInteracted;\n\n this.customStates.set('required', required);\n this.customStates.set('optional', !required);\n this.customStates.set('invalid', !isValid);\n this.customStates.set('valid', isValid);\n this.customStates.set('user-invalid', !isValid && hasInteracted);\n this.customStates.set('user-valid', isValid && hasInteracted);\n }\n\n /**\n * Do not use this when creating a \"Validator\". This is intended for end users of components.\n * We track manually defined custom errors so we don't clear them on accident in our validators.\n *\n */\n setCustomValidity(message: string) {\n if (!message) {\n // We use null because it we really don't want it to show up in the attributes because `custom-error` does reflect\n this.customError = null;\n this.setValidity({});\n return;\n }\n\n this.customError = message;\n this.setValidity({ customError: true }, message, this.validationTarget);\n }\n\n formResetCallback() {\n this.resetValidity();\n this.hasInteracted = false;\n this.valueHasChanged = false;\n this.emittedEvents = [];\n this.updateValidity();\n }\n\n formDisabledCallback(isDisabled: boolean) {\n this.disabled = isDisabled;\n\n this.updateValidity();\n }\n\n /**\n * Called when the browser is trying to restore element\u2019s state to state in which case reason is \"restore\", or when\n * the browser is trying to fulfill autofill on behalf of user in which case reason is \"autocomplete\". In the case of\n * \"restore\", state is a string, File, or FormData object previously set as the second argument to setFormValue.\n */\n formStateRestoreCallback(state: string | File | FormData | null, reason: 'autocomplete' | 'restore') {\n // @ts-expect-error We purposely do not have a value property. It makes things hard to extend.\n this.value = state;\n\n if (reason === 'restore') {\n this.resetValidity();\n }\n\n this.updateValidity();\n }\n\n setValue(...args: Parameters<typeof this.internals.setFormValue>) {\n const [value, state] = args;\n\n this.internals.setFormValue(value, state);\n }\n\n get allValidators() {\n const staticValidators = (this.constructor as typeof BaseFormAssociatedElement).validators || [];\n\n const validators = this.validators || [];\n return [...staticValidators, ...validators];\n }\n\n /**\n * Reset validity is a way of removing manual custom errors and native validation.\n */\n resetValidity() {\n this.setCustomValidity('');\n this.setValidity({});\n }\n\n updateValidity() {\n if (\n this.disabled ||\n this.hasAttribute('disabled') ||\n !this.willValidate //\n ) {\n this.resetValidity();\n\n return;\n }\n\n const validators = this.allValidators;\n\n if (!validators?.length) {\n // If there's no validators, we do nothing. We also don't want to mess with custom errors, so we just stop here.\n return;\n }\n\n type ValidityKey = { -readonly [P in keyof ValidityState]: ValidityState[P] };\n\n const flags: Partial<ValidityKey> = {\n // Don't trust custom errors from the Browser. Safari breaks the spec.\n customError: Boolean(this.customError),\n };\n\n const formControl = this.validationTarget || this.input || undefined;\n\n let finalMessage = '';\n\n for (const validator of validators) {\n const { isValid, message, invalidKeys } = validator.checkValidity(this);\n\n if (isValid) {\n continue;\n }\n\n if (!finalMessage) {\n finalMessage = message;\n }\n\n if (invalidKeys?.length >= 0) {\n (invalidKeys as (keyof ValidityState)[]).forEach((str) => (flags[str] = true));\n }\n }\n\n // This is a workaround for preserving custom errors\n if (!finalMessage) {\n finalMessage = this.validationMessage;\n }\n\n this.setValidity(flags, finalMessage, formControl);\n }\n}\n", "// eslint-disable-next-line\n// @ts-nocheck\nimport type { CSSResult, CSSResultGroup } from 'lit';\nimport { LitElement, unsafeCSS } from 'lit';\n\nimport { property } from 'lit/decorators.js';\n\nimport { styles as hostStyles } from './host-styles';\n\n// Augment Lit's module\ndeclare module 'lit' {\n interface PropertyDeclaration {\n /**\n * Specifies the property\u2019s default value\n */\n /* eslint-disable */\n default?: any;\n /* eslint-disable */\n initial?: any;\n }\n}\n\nexport default class BaseElement extends LitElement {\n /**\n * One or more CSS files to include in the component's shadow root. Host styles are automatically prepended. We use\n * this instead of Lit's styles property because we're importing CSS files as strings and need to convert them using\n * unsafeCSS.\n */\n static css?: CSSResultGroup | CSSResult | string | (CSSResult | string)[];\n\n /**\n * Override the default styles property to fetch and convert string CSS files. Components can override this behavior\n * by setting their own `static styles = []` property.\n */\n static get styles(): CSSResultGroup {\n const styles = Array.isArray(this.css) ? this.css : this.css ? [this.css] : [];\n return [hostStyles, ...styles].map((style) => (typeof style === 'string' ? unsafeCSS(style) : style));\n }\n\n #hasRecordedInitialProperties = false;\n initialReflectedProperties: Map<string, unknown> = new Map();\n internals: ElementInternals;\n\n // Make localization attributes reactive\n @property() dir: string;\n @property() lang: string;\n\n constructor() {\n super();\n\n try {\n this.internals = this.attachInternals();\n } catch {\n /* Need to tell people if they need a polyfill. */\n\n console.error('Element internals are not supported in your browser. Consider using a polyfill');\n }\n\n this.customStates.set('wa-defined', true);\n\n const Self = this.constructor as typeof BaseElement;\n for (const [property, spec] of Self.elementProperties) {\n if (spec.default === 'inherit' && spec.initial !== undefined && typeof property === 'string') {\n this.customStates.set(`initial-${property}-${spec.initial}`, true);\n }\n }\n }\n\n attributeChangedCallback(name: string, oldValue: string | null, newValue: string | null) {\n if (!this.#hasRecordedInitialProperties) {\n (this.constructor as typeof BaseElement).elementProperties.forEach((obj, prop: keyof typeof this & string) => {\n\n if (obj.reflect && this[prop] != null) {\n this.initialReflectedProperties.set(prop, this[prop]);\n }\n });\n\n this.#hasRecordedInitialProperties = true;\n }\n\n super.attributeChangedCallback(name, oldValue, newValue);\n }\n\n protected willUpdate(changedProperties: Parameters<LitElement['willUpdate']>[0]): void {\n super.willUpdate(changedProperties);\n\n // Run the morph fixing *after* willUpdate.\n this.initialReflectedProperties.forEach((value, prop: string & keyof typeof this) => {\n // If a prop changes to `null`, we assume this happens via an attribute changing to `null`.\n\n if (changedProperties.has(prop) && this[prop] == null) {\n // Silly type gymnastics to appease the compiler.\n (this as Record<string, unknown>)[prop] = value;\n }\n });\n }\n\n /**\n * Methods for setting and checking custom states.\n */\n public customStates = {\n /** Adds or removes the specified custom state. */\n set: (customState: string, active: boolean) => {\n if (!this.internals?.states) return;\n if (active) {\n this.internals.states.add(customState);\n } else {\n this.internals.states.delete(customState);\n }\n },\n\n /** Determines whether or not the element currently has the specified state. */\n has: (customState: string) => {\n if (!this.internals?.states) return false;\n return this.internals.states.has(customState);\n },\n };\n\n /**\n * Given a native event, this function cancels it and dispatches it again from the host element using the desired\n * event options.\n */\n relayNativeEvent(event: Event, eventOptions?: EventInit) {\n event.stopImmediatePropagation();\n\n this.dispatchEvent(\n new (event.constructor as typeof Event)(event.type, {\n ...event,\n ...eventOptions,\n }),\n );\n }\n}\n", "import { css } from 'lit';\n\nexport const styles = css`\n :host {\n box-sizing: border-box !important;\n }\n\n :host *,\n :host *::before,\n :host *::after {\n box-sizing: inherit !important;\n }\n`;\n", "import type { Validator } from './form-associated-element';\n\n/**\n * This validator is for if you have an exact copy of your element in the shadow DOM. Rather than needing\n * custom translations and error messages, you can simply rely on the element \"formControl\" in your shadow dom.\n */\nexport const CustomErrorValidator = (): Validator => {\n return {\n observedAttributes: ['custom-error'],\n checkValidity(element) {\n const validity: ReturnType<Validator['checkValidity']> = {\n message: '',\n isValid: true,\n invalidKeys: [],\n };\n\n if (element.customError) {\n validity.message = element.customError;\n validity.isValid = false;\n validity.invalidKeys = ['customError'];\n }\n\n return validity;\n },\n };\n};\n", "export class WInvalidEvent extends Event {\n constructor() {\n super('w-invalid', { bubbles: true, cancelable: false, composed: true });\n }\n}\n\ndeclare global {\n interface GlobalEventHandlersEventMap {\n 'wa-invalid': WInvalidEvent;\n }\n}\n", "import { css } from 'lit';\n\nexport const styles = css`\n :host {\n color: var(--wa-form-control-value-color);\n display: inline-flex;\n flex-direction: row;\n align-items: top;\n font-family: inherit;\n font-weight: var(--wa-form-control-value-font-weight);\n line-height: var(--wa-form-control-value-line-height);\n cursor: pointer;\n user-select: none;\n -webkit-user-select: none;\n }\n\n :host(:focus) {\n outline: none;\n }\n\n [part~='label'] {\n display: inline;\n }\n\n [part~='hint'] {\n margin-block-start: 0.5em;\n }\n\n /* Default appearance */\n :host([appearance='default']) {\n .control {\n flex: 0 0 auto;\n position: relative;\n display: inline-flex;\n align-items: center;\n justify-content: center;\n width: var(--wa-form-control-toggle-size, 2rem);\n height: var(--wa-form-control-toggle-size, 2rem);\n border-color: var(--wa-form-control-border-color, gray);\n border-radius: 50%;\n border-style: var(--wa-form-control-border-style, solid);\n border-width: var(--wa-form-control-border-width, 1px);\n background-color: var(--wa-form-control-background-color, white);\n color: transparent;\n transition-property: all;\n transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);\n transition-duration: 150ms;\n\n margin-inline-end: 0.5em;\n }\n }\n\n :host([appearance='clickable']) .control {\n position: absolute;\n inset: 0;\n height: 100%;\n width: 100%;\n cursor: pointer;\n }\n\n /* Checked */\n :host(:state(checked)):not(:host([appearance='clickable'])) .control {\n /* color: var(--checked-icon-color, white); */\n border-color: var(--wa-form-control-activated-color, blue);\n background-color: var(--wa-form-control-background-color, white);\n border-width: 0.6rem;\n }\n\n /* Focus */\n :host(:focus-visible) .control {\n outline: 2px solid var(--w-s-color-border-focus);\n outline-offset: var(--w-outline-offset, 1px);\n }\n\n :host([appearance='clickable']:focus-visible) .control {\n outline-offset: -4px;\n border-radius: 8px;\n }\n\n /* Disabled */\n :host(:state(disabled)) {\n opacity: 0.5;\n cursor: not-allowed;\n }\n\n /* Button appearance */\n :host([appearance='button']) {\n align-items: center;\n min-height: var(--wa-form-control-height);\n background-color: var(--wa-color-surface-default);\n border: var(--wa-form-control-border-width) var(--wa-form-control-border-style) var(--wa-form-control-border-color);\n border-radius: var(--wa-border-radius-m);\n padding: 0 var(--wa-form-control-padding-inline);\n transition:\n background-color var(--wa-transition-fast),\n border-color var(--wa-transition-fast);\n\n .control {\n display: none;\n }\n }\n\n /* Horizontal grouping - remove inner border radius */\n :host([appearance='button'][data-wa-radio-horizontal][data-wa-radio-inner]) {\n border-radius: 0;\n }\n\n :host([appearance='button'][data-wa-radio-horizontal][data-wa-radio-first]) {\n border-start-end-radius: 0;\n border-end-end-radius: 0;\n }\n\n :host([appearance='button'][data-wa-radio-horizontal][data-wa-radio-last]) {\n border-start-start-radius: 0;\n border-end-start-radius: 0;\n }\n\n /* Vertical grouping - remove inner border radius */\n :host([appearance='button'][data-wa-radio-vertical][data-wa-radio-inner]) {\n border-radius: 0;\n }\n\n :host([appearance='button'][data-wa-radio-vertical][data-wa-radio-first]) {\n border-end-start-radius: 0;\n border-end-end-radius: 0;\n }\n\n :host([appearance='button'][data-wa-radio-vertical][data-wa-radio-last]) {\n border-start-start-radius: 0;\n border-start-end-radius: 0;\n }\n\n @media (hover: hover) {\n :host([appearance='button']:hover:not(:state(disabled), :state(checked))) {\n background-color: color-mix(in srgb, var(--wa-color-surface-default) 95%, var(--wa-color-mix-hover));\n }\n }\n\n :host([appearance='button']:focus-visible) {\n outline: var(--wa-focus-ring);\n outline-offset: var(--wa-focus-ring-offset);\n }\n\n :host([appearance='button']:state(checked)) {\n border-color: var(--wa-form-control-activated-color);\n background-color: var(--wa-color-brand-fill-quiet);\n }\n\n :host([appearance='button']:state(checked):focus-visible) {\n outline: var(--wa-focus-ring-style) var(--wa-focus-ring-width) var(--wa-color-brand-border-loud);\n outline-offset: var(--wa-focus-ring-offset);\n }\n\n /* Remove inner borders and handle overlap */\n :host([appearance='button'][data-wa-radio-horizontal]:not([data-wa-radio-first])) {\n margin-inline-start: calc(-1 * var(--wa-form-control-border-width));\n }\n\n :host([appearance='button'][data-wa-radio-vertical]:not([data-wa-radio-first])) {\n margin-block-start: calc(-1 * var(--wa-form-control-border-width));\n }\n\n /* Ensure interactive states are visible above adjacent buttons */\n :host([appearance='button']:hover),\n :host([appearance='button']:state(checked)) {\n position: relative;\n z-index: 1;\n }\n\n :host([appearance='button']:focus-visible) {\n z-index: 2;\n }\n`;\n"],
5
- "mappings": "mhBACA,OAAS,QAAAA,MAAY,MAErB,OAAS,YAAAC,EAAU,SAAAC,MAAa,oBCHhC,OAAqB,YAAAC,MAAgB,MAErC,OAAS,YAAAC,MAAgB,oBCCzB,OAAS,cAAAC,EAAY,aAAAC,MAAiB,MAEtC,OAAS,YAAAC,MAAgB,oBCLzB,OAAS,OAAAC,MAAW,MAEb,IAAMC,EAASD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;EDFtB,IAAAE,EAsBqBC,EAArB,cAAyCC,CAAW,CAyBlD,aAAc,CACZ,MAAM,EATRC,EAAA,KAAAH,EAAgC,IAChC,gCAAmD,IAAI,IA4DvD,KAAO,aAAe,CAEpB,IAAK,CAACI,EAAqBC,IAAoB,CAtGnD,IAAAC,GAuGWA,EAAA,KAAK,YAAL,MAAAA,EAAgB,SACjBD,EACF,KAAK,UAAU,OAAO,IAAID,CAAW,EAErC,KAAK,UAAU,OAAO,OAAOA,CAAW,EAE5C,EAGA,IAAMA,GAAwB,CAhHlC,IAAAE,EAiHM,OAAKA,EAAA,KAAK,YAAL,MAAAA,EAAgB,OACd,KAAK,UAAU,OAAO,IAAIF,CAAW,EADR,EAEtC,CACF,EAlEE,GAAI,CACF,KAAK,UAAY,KAAK,gBAAgB,CACxC,OAAQ,GAGN,QAAQ,MAAM,gFAAgF,CAChG,CAEA,KAAK,aAAa,IAAI,aAAc,EAAI,EAExC,IAAMG,EAAO,KAAK,YAClB,OAAW,CAACC,EAAUC,CAAI,IAAKF,EAAK,kBAC9BE,EAA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,EAAA,CAA5BE,EAAS,CAAE,QAAS,EAAK,CAAC,GAjBhBR,EAiBkB,0BAMAM,EAAA,CAA5BE,EAAS,CAAE,QAAS,EAAK,CAAC,GAvBhBR,EAuBkB,oBAGAM,EAAA,CAA5BE,EAAS,CAAE,KAAM,OAAQ,CAAC,GA1BhBR,EA0BkB",
4
+ "sourcesContent": ["import type { PropertyValues } from 'lit';\nimport { html } from 'lit';\n\nimport { property, state } from 'lit/decorators.js';\n\nimport { BaseFormAssociatedElement } from './form-associated-element';\n// eslint-disable-next-line\n// @ts-ignore\nimport { styles } from './radio-styles';\n\nexport class WRadio extends BaseFormAssociatedElement {\n static css = [styles];\n\n @state() checked = false;\n\n /** @internal Used by radio group to force disable radios while preserving their original disabled state. */\n @state() forceDisabled = false;\n\n /**\n * The string pointing to a form's id.\n */\n @property({ reflect: true }) form: string | null = null;\n\n /** The radio's value. When selected, the radio group will receive this value. */\n @property({ reflect: true }) value: string;\n\n /** The radio's value. When selected, the radio group will receive this value. */\n @property({ reflect: true }) appearance: 'default' | 'button' | 'clickable' = 'default';\n\n /**\n * The radio's size. When used inside a radio group, the size will be determined by the radio group's size so this\n * attribute can typically be omitted.\n */\n @property({ reflect: true }) size: 'small' | 'medium' | 'large' = 'medium';\n\n /** Disables the radio. */\n @property({ type: Boolean }) disabled = false;\n\n constructor() {\n super();\n this.addEventListener('click', this.handleClick);\n }\n\n connectedCallback() {\n super.connectedCallback();\n this.setInitialAttributes();\n }\n\n private setInitialAttributes() {\n this.setAttribute('role', 'radio');\n this.tabIndex = 0;\n this.setAttribute('aria-disabled', this.disabled || this.forceDisabled ? 'true' : 'false');\n }\n\n updated(changedProperties: PropertyValues<this>) {\n super.updated(changedProperties);\n\n if (changedProperties.has('checked')) {\n this.customStates.set('checked', this.checked);\n this.setAttribute('aria-checked', this.checked ? 'true' : 'false');\n // Only set tabIndex if not disabled\n if (!this.disabled && !this.forceDisabled) {\n this.tabIndex = this.checked ? 0 : -1;\n }\n }\n\n if (changedProperties.has('disabled') || changedProperties.has('forceDisabled')) {\n const effectivelyDisabled = this.disabled || this.forceDisabled;\n this.customStates.set('disabled', effectivelyDisabled);\n this.setAttribute('aria-disabled', effectivelyDisabled ? 'true' : 'false');\n\n // Set tabIndex based on disabled state\n if (effectivelyDisabled) {\n this.tabIndex = -1;\n } else {\n // Restore proper tabIndex - this will be managed by the radio group\n this.tabIndex = this.checked ? 0 : -1;\n }\n }\n }\n\n /**\n * @override\n */\n setValue(): void {\n // We override `setValue` because we don't want to set form values from here. We want to do that in \"RadioGroup\" itself.\n }\n\n // Update the handleClick method (around line 75)\n private handleClick = () => {\n if (!this.disabled && !this.forceDisabled) {\n this.checked = true;\n }\n };\n\n render() {\n return html`\n <span part=\"control\" class=\"control\"></span>\n <slot part=\"label\" class=\"label\"></slot>\n `;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'w-radio': WRadio;\n }\n}\n", "import { LitElement, isServer } from 'lit';\n\nimport { property } from 'lit/decorators.js';\n\nimport BaseElement from './base-element.js';\nimport { CustomErrorValidator } from './custom-error-validator.js';\nimport { WInvalidEvent } from './invalid';\n\nexport interface Validator<T extends BaseFormAssociatedElement = BaseFormAssociatedElement> {\n observedAttributes?: string[];\n checkValidity: (element: T) => {\n message: string;\n isValid: boolean;\n invalidKeys: Exclude<keyof ValidityState, 'valid'>[];\n };\n message?: string | ((element: T) => string);\n}\n\nexport interface BaseFormControl extends BaseElement {\n // Form attributes\n name: null | string;\n disabled?: boolean;\n defaultValue?: unknown;\n defaultChecked?: boolean;\n checked?: boolean;\n defaultSelected?: boolean;\n selected?: boolean;\n form?: string | null;\n\n value?: unknown;\n\n // Constraint validation attributes\n pattern?: string;\n min?: number | string | Date;\n max?: number | string | Date;\n step?: number | 'any';\n required?: boolean;\n minlength?: number;\n maxlength?: number;\n\n // Form validation properties\n readonly validity: ValidityState;\n readonly validationMessage: string;\n\n // Form validation methods\n checkValidity: () => boolean;\n getForm: () => HTMLFormElement | null;\n reportValidity: () => boolean;\n setCustomValidity: (message: string) => void;\n\n // Form properties\n hasInteracted: boolean;\n valueHasChanged?: boolean;\n\n /** Convenience API for `setCustomValidity()` */\n customError: null | string;\n}\n\n// setFormValue omitted so that we can use `setValue`\nexport class BaseFormAssociatedElement extends BaseElement implements Omit<ElementInternals, 'form' | 'setFormValue'>, BaseFormControl {\n static formAssociated = true;\n\n /**\n * Validators are static because they have `observedAttributes`, essentially attributes to \"watch\"\n * for changes. Whenever these attributes change, we want to be notified and update the validator.\n */\n static get validators(): Validator[] {\n return [CustomErrorValidator()];\n }\n\n // Append all Validator \"observedAttributes\" into the \"observedAttributes\" so they can run.\n static get observedAttributes() {\n const parentAttrs = new Set(super.observedAttributes || []);\n\n for (const validator of this.validators) {\n if (!validator.observedAttributes) {\n continue;\n }\n\n for (const attr of validator.observedAttributes) {\n parentAttrs.add(attr);\n }\n }\n\n return [...parentAttrs];\n }\n\n // Form attributes\n /** The name of the input, submitted as a name/value pair with form data. */\n @property({ reflect: true }) name: string | null = null;\n\n /** Disables the form control. */\n @property({ type: Boolean }) disabled = false;\n\n required: boolean = false;\n\n assumeInteractionOn: string[] = ['input'];\n\n // Additional\n input?: (HTMLElement & { value: unknown }) | HTMLInputElement | HTMLTextAreaElement;\n\n validators: Validator[] = [];\n\n // Should these be private?\n @property({ state: true, attribute: false }) valueHasChanged: boolean = false;\n @property({ state: true, attribute: false }) hasInteracted: boolean = false;\n\n // This works around a limitation in Safari. It is a hacky way for us to preserve custom errors generated by the user.\n @property({ attribute: 'custom-error', reflect: true }) customError: string | null = null;\n\n private emittedEvents: string[] = [];\n\n constructor() {\n super();\n\n if (!isServer) {\n this.addEventListener('invalid', this.emitInvalid);\n }\n }\n // this bullshit makes no sense but tsc is angry about it\n // this needs both 'private' and 'typeof' or it will be angry and we don't know why\n // eslint-disable-next-line\n // @ts-ignore\n private states: typeof CustomStateSet;\n\n connectedCallback() {\n super.connectedCallback();\n this.updateValidity();\n\n // Lazily evaluate after the constructor to allow people to override the `assumeInteractionOn`\n this.assumeInteractionOn.forEach((event) => {\n this.addEventListener(event, this.handleInteraction);\n });\n }\n\n firstUpdated(...args: Parameters<LitElement['firstUpdated']>) {\n super.firstUpdated(...args);\n this.updateValidity();\n }\n\n emitInvalid = (e: Event) => {\n if (e.target !== this) return;\n\n // An \"invalid\" event counts as interacted, this is usually triggered by a button \"submitting\"\n this.hasInteracted = true;\n this.dispatchEvent(new WInvalidEvent());\n };\n\n protected willUpdate(changedProperties: Parameters<LitElement['willUpdate']>[0]) {\n if (!isServer && changedProperties.has('customError')) {\n // We use null because it we really don't want it to show up in the attributes because `custom-error` does reflect\n if (!this.customError) {\n this.customError = null;\n }\n this.setCustomValidity(this.customError || '');\n }\n\n if (changedProperties.has('value') || changedProperties.has('disabled')) {\n // @ts-expect-error Some components will use an accessors, other use a property, so we don't want to limit them.\n const value = this.value as unknown;\n\n // Accounts for the snowflake case on `<wa-select>`\n if (Array.isArray(value)) {\n if (this.name) {\n const formData = new FormData();\n for (const val of value) {\n formData.append(this.name, val as string);\n }\n this.setValue(formData, formData);\n }\n } else {\n this.setValue(value as FormData | string | File | null, value as FormData | string | File | null);\n }\n }\n\n if (changedProperties.has('disabled')) {\n this.customStates.set('disabled', this.disabled);\n\n if (this.hasAttribute('disabled') || (!isServer && !this.matches(':disabled'))) {\n this.toggleAttribute('disabled', this.disabled);\n }\n }\n\n this.updateValidity();\n super.willUpdate(changedProperties);\n }\n\n private handleInteraction = (event: Event) => {\n const emittedEvents = this.emittedEvents;\n if (!emittedEvents.includes(event.type)) {\n emittedEvents.push(event.type);\n }\n\n // Mark it as user-interacted as soon as all associated events have been emitted\n if (emittedEvents.length === this.assumeInteractionOn?.length) {\n this.hasInteracted = true;\n }\n };\n\n get labels() {\n return this.internals.labels;\n }\n\n getForm() {\n return this.internals.form;\n }\n\n @property({ attribute: false, state: true, type: Object })\n get validity() {\n return this.internals.validity;\n }\n\n // Not sure if this supports `novalidate`. Will need to test.\n get willValidate() {\n return this.internals.willValidate;\n }\n\n get validationMessage() {\n return this.internals.validationMessage;\n }\n\n checkValidity() {\n this.updateValidity();\n return this.internals.checkValidity();\n }\n\n reportValidity() {\n this.updateValidity();\n // This seems reasonable. `reportValidity()` is kind of like \"we expect you to have interacted\"\n this.hasInteracted = true;\n return this.internals.reportValidity();\n }\n\n /**\n * Override this to change where constraint validation popups are anchored.\n */\n get validationTarget(): undefined | HTMLElement {\n return (this.input || undefined) as undefined | HTMLElement;\n }\n\n setValidity(...args: Parameters<typeof this.internals.setValidity>) {\n const flags = args[0];\n const message = args[1];\n let anchor = args[2];\n\n if (!anchor) {\n anchor = this.validationTarget;\n }\n\n this.internals.setValidity(flags, message, anchor || undefined);\n this.requestUpdate('validity');\n this.setCustomStates();\n }\n\n setCustomStates() {\n const required = Boolean(this.required);\n const isValid = this.internals.validity.valid;\n const hasInteracted = this.hasInteracted;\n\n this.customStates.set('required', required);\n this.customStates.set('optional', !required);\n this.customStates.set('invalid', !isValid);\n this.customStates.set('valid', isValid);\n this.customStates.set('user-invalid', !isValid && hasInteracted);\n this.customStates.set('user-valid', isValid && hasInteracted);\n }\n\n /**\n * Do not use this when creating a \"Validator\". This is intended for end users of components.\n * We track manually defined custom errors so we don't clear them on accident in our validators.\n *\n */\n setCustomValidity(message: string) {\n if (!message) {\n // We use null because it we really don't want it to show up in the attributes because `custom-error` does reflect\n this.customError = null;\n this.setValidity({});\n return;\n }\n\n this.customError = message;\n this.setValidity({ customError: true }, message, this.validationTarget);\n }\n\n formResetCallback() {\n this.resetValidity();\n this.hasInteracted = false;\n this.valueHasChanged = false;\n this.emittedEvents = [];\n this.updateValidity();\n }\n\n formDisabledCallback(isDisabled: boolean) {\n this.disabled = isDisabled;\n\n this.updateValidity();\n }\n\n /**\n * Called when the browser is trying to restore element\u2019s state to state in which case reason is \"restore\", or when\n * the browser is trying to fulfill autofill on behalf of user in which case reason is \"autocomplete\". In the case of\n * \"restore\", state is a string, File, or FormData object previously set as the second argument to setFormValue.\n */\n formStateRestoreCallback(state: string | File | FormData | null, reason: 'autocomplete' | 'restore') {\n // @ts-expect-error We purposely do not have a value property. It makes things hard to extend.\n this.value = state;\n\n if (reason === 'restore') {\n this.resetValidity();\n }\n\n this.updateValidity();\n }\n\n setValue(...args: Parameters<typeof this.internals.setFormValue>) {\n const [value, state] = args;\n\n this.internals.setFormValue(value, state);\n }\n\n get allValidators() {\n const staticValidators = (this.constructor as typeof BaseFormAssociatedElement).validators || [];\n\n const validators = this.validators || [];\n return [...staticValidators, ...validators];\n }\n\n /**\n * Reset validity is a way of removing manual custom errors and native validation.\n */\n resetValidity() {\n this.setCustomValidity('');\n this.setValidity({});\n }\n\n updateValidity() {\n if (\n this.disabled ||\n this.hasAttribute('disabled') ||\n !this.willValidate //\n ) {\n this.resetValidity();\n\n return;\n }\n\n const validators = this.allValidators;\n\n if (!validators?.length) {\n // If there's no validators, we do nothing. We also don't want to mess with custom errors, so we just stop here.\n return;\n }\n\n type ValidityKey = { -readonly [P in keyof ValidityState]: ValidityState[P] };\n\n const flags: Partial<ValidityKey> = {\n // Don't trust custom errors from the Browser. Safari breaks the spec.\n customError: Boolean(this.customError),\n };\n\n const formControl = this.validationTarget || this.input || undefined;\n\n let finalMessage = '';\n\n for (const validator of validators) {\n const { isValid, message, invalidKeys } = validator.checkValidity(this);\n\n if (isValid) {\n continue;\n }\n\n if (!finalMessage) {\n finalMessage = message;\n }\n\n if (invalidKeys?.length >= 0) {\n (invalidKeys as (keyof ValidityState)[]).forEach((str) => (flags[str] = true));\n }\n }\n\n // This is a workaround for preserving custom errors\n if (!finalMessage) {\n finalMessage = this.validationMessage;\n }\n\n this.setValidity(flags, finalMessage, formControl);\n }\n}\n", "// eslint-disable-next-line\n// @ts-nocheck\nimport type { CSSResult, CSSResultGroup } from 'lit';\nimport { LitElement, unsafeCSS } from 'lit';\n\nimport { property } from 'lit/decorators.js';\n\nimport { styles as hostStyles } from './host-styles';\n\n// Augment Lit's module\ndeclare module 'lit' {\n interface PropertyDeclaration {\n /**\n * Specifies the property\u2019s default value\n */\n /* eslint-disable */\n default?: any;\n /* eslint-disable */\n initial?: any;\n }\n}\n\nexport default class BaseElement extends LitElement {\n /**\n * One or more CSS files to include in the component's shadow root. Host styles are automatically prepended. We use\n * this instead of Lit's styles property because we're importing CSS files as strings and need to convert them using\n * unsafeCSS.\n */\n static css?: CSSResultGroup | CSSResult | string | (CSSResult | string)[];\n\n /**\n * Override the default styles property to fetch and convert string CSS files. Components can override this behavior\n * by setting their own `static styles = []` property.\n */\n static get styles(): CSSResultGroup {\n const styles = Array.isArray(this.css) ? this.css : this.css ? [this.css] : [];\n return [hostStyles, ...styles].map((style) => (typeof style === 'string' ? unsafeCSS(style) : style));\n }\n\n #hasRecordedInitialProperties = false;\n initialReflectedProperties: Map<string, unknown> = new Map();\n internals: ElementInternals;\n\n // Make localization attributes reactive\n @property() dir: string;\n @property() lang: string;\n\n constructor() {\n super();\n\n try {\n this.internals = this.attachInternals();\n } catch {\n /* Need to tell people if they need a polyfill. */\n\n console.error('Element internals are not supported in your browser. Consider using a polyfill');\n }\n\n this.customStates.set('wa-defined', true);\n\n const Self = this.constructor as typeof BaseElement;\n for (const [property, spec] of Self.elementProperties) {\n if (spec.default === 'inherit' && spec.initial !== undefined && typeof property === 'string') {\n this.customStates.set(`initial-${property}-${spec.initial}`, true);\n }\n }\n }\n\n attributeChangedCallback(name: string, oldValue: string | null, newValue: string | null) {\n if (!this.#hasRecordedInitialProperties) {\n (this.constructor as typeof BaseElement).elementProperties.forEach((obj, prop: keyof typeof this & string) => {\n\n if (obj.reflect && this[prop] != null) {\n this.initialReflectedProperties.set(prop, this[prop]);\n }\n });\n\n this.#hasRecordedInitialProperties = true;\n }\n\n super.attributeChangedCallback(name, oldValue, newValue);\n }\n\n protected willUpdate(changedProperties: Parameters<LitElement['willUpdate']>[0]): void {\n super.willUpdate(changedProperties);\n\n // Run the morph fixing *after* willUpdate.\n this.initialReflectedProperties.forEach((value, prop: string & keyof typeof this) => {\n // If a prop changes to `null`, we assume this happens via an attribute changing to `null`.\n\n if (changedProperties.has(prop) && this[prop] == null) {\n // Silly type gymnastics to appease the compiler.\n (this as Record<string, unknown>)[prop] = value;\n }\n });\n }\n\n /**\n * Methods for setting and checking custom states.\n */\n public customStates = {\n /** Adds or removes the specified custom state. */\n set: (customState: string, active: boolean) => {\n if (!this.internals?.states) return;\n if (active) {\n this.internals.states.add(customState);\n } else {\n this.internals.states.delete(customState);\n }\n },\n\n /** Determines whether or not the element currently has the specified state. */\n has: (customState: string) => {\n if (!this.internals?.states) return false;\n return this.internals.states.has(customState);\n },\n };\n\n /**\n * Given a native event, this function cancels it and dispatches it again from the host element using the desired\n * event options.\n */\n relayNativeEvent(event: Event, eventOptions?: EventInit) {\n event.stopImmediatePropagation();\n\n this.dispatchEvent(\n new (event.constructor as typeof Event)(event.type, {\n ...event,\n ...eventOptions,\n }),\n );\n }\n}\n", "import { css } from 'lit';\n\nexport const styles = css`\n :host {\n box-sizing: border-box !important;\n }\n\n :host *,\n :host *::before,\n :host *::after {\n box-sizing: inherit !important;\n }\n`;\n", "import type { Validator } from './form-associated-element';\n\n/**\n * This validator is for if you have an exact copy of your element in the shadow DOM. Rather than needing\n * custom translations and error messages, you can simply rely on the element \"formControl\" in your shadow dom.\n */\nexport const CustomErrorValidator = (): Validator => {\n return {\n observedAttributes: ['custom-error'],\n checkValidity(element) {\n const validity: ReturnType<Validator['checkValidity']> = {\n message: '',\n isValid: true,\n invalidKeys: [],\n };\n\n if (element.customError) {\n validity.message = element.customError;\n validity.isValid = false;\n validity.invalidKeys = ['customError'];\n }\n\n return validity;\n },\n };\n};\n", "export class WInvalidEvent extends Event {\n constructor() {\n super('w-invalid', { bubbles: true, cancelable: false, composed: true });\n }\n}\n\ndeclare global {\n interface GlobalEventHandlersEventMap {\n 'wa-invalid': WInvalidEvent;\n }\n}\n", "import { css } from 'lit';\n\nexport const styles = css`\n :host {\n color: var(--wa-form-control-value-color);\n display: inline-flex;\n flex-direction: row;\n align-items: top;\n font-family: inherit;\n font-weight: var(--wa-form-control-value-font-weight);\n line-height: var(--wa-form-control-value-line-height);\n cursor: pointer;\n user-select: none;\n -webkit-user-select: none;\n }\n\n :host(:focus) {\n outline: none;\n }\n\n [part~='label'] {\n display: inline;\n }\n\n [part~='hint'] {\n margin-block-start: 0.5em;\n }\n\n /* Default appearance */\n :host([appearance='default']) .control {\n flex: 0 0 auto;\n position: relative;\n display: inline-flex;\n align-items: center;\n justify-content: center;\n width: var(--wa-form-control-toggle-size, 2rem);\n height: var(--wa-form-control-toggle-size, 2rem);\n border-color: var(--wa-form-control-border-color, gray);\n border-radius: 50%;\n border-style: var(--wa-form-control-border-style, solid);\n border-width: var(--wa-form-control-border-width, 1px);\n background-color: var(--wa-form-control-background-color, white);\n color: transparent;\n transition-property: all;\n transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);\n transition-duration: 150ms;\n\n margin-inline-end: 0.5em;\n }\n\n :host([appearance='clickable']) .control {\n position: absolute;\n inset: 0;\n height: 100%;\n width: 100%;\n cursor: pointer;\n }\n\n /* Checked */\n :host(:state(checked)):not(:host([appearance='clickable'])) .control {\n /* color: var(--checked-icon-color, white); */\n border-color: var(--wa-form-control-activated-color, blue);\n background-color: var(--wa-form-control-background-color, white);\n border-width: 0.6rem;\n }\n\n /* Focus */\n :host(:focus-visible) .control {\n outline: 2px solid var(--w-s-color-border-focus);\n outline-offset: var(--w-outline-offset, 1px);\n }\n\n :host([appearance='clickable']:focus-visible) .control {\n outline-offset: -4px;\n border-radius: 8px;\n }\n\n /* Disabled */\n :host(:state(disabled)) {\n opacity: 0.5;\n cursor: not-allowed;\n }\n\n /* Button appearance */\n :host([appearance='button']) {\n align-items: center;\n min-height: var(--wa-form-control-height);\n background-color: var(--wa-color-surface-default);\n border: var(--wa-form-control-border-width) var(--wa-form-control-border-style) var(--wa-form-control-border-color);\n border-radius: var(--wa-border-radius-m);\n padding: 0 var(--wa-form-control-padding-inline);\n transition:\n background-color var(--wa-transition-fast),\n border-color var(--wa-transition-fast);\n }\n\n :host([appearance='button']) .control {\n display: none;\n }\n\n /* Horizontal grouping - remove inner border radius */\n :host([appearance='button'][data-wa-radio-horizontal][data-wa-radio-inner]) {\n border-radius: 0;\n }\n\n :host([appearance='button'][data-wa-radio-horizontal][data-wa-radio-first]) {\n border-start-end-radius: 0;\n border-end-end-radius: 0;\n }\n\n :host([appearance='button'][data-wa-radio-horizontal][data-wa-radio-last]) {\n border-start-start-radius: 0;\n border-end-start-radius: 0;\n }\n\n /* Vertical grouping - remove inner border radius */\n :host([appearance='button'][data-wa-radio-vertical][data-wa-radio-inner]) {\n border-radius: 0;\n }\n\n :host([appearance='button'][data-wa-radio-vertical][data-wa-radio-first]) {\n border-end-start-radius: 0;\n border-end-end-radius: 0;\n }\n\n :host([appearance='button'][data-wa-radio-vertical][data-wa-radio-last]) {\n border-start-start-radius: 0;\n border-start-end-radius: 0;\n }\n\n @media (hover: hover) {\n :host([appearance='button']:hover:not(:state(disabled), :state(checked))) {\n background-color: color-mix(in srgb, var(--wa-color-surface-default) 95%, var(--wa-color-mix-hover));\n }\n }\n\n :host([appearance='button']:focus-visible) {\n outline: var(--wa-focus-ring);\n outline-offset: var(--wa-focus-ring-offset);\n }\n\n :host([appearance='button']:state(checked)) {\n border-color: var(--wa-form-control-activated-color);\n background-color: var(--wa-color-brand-fill-quiet);\n }\n\n :host([appearance='button']:state(checked):focus-visible) {\n outline: var(--wa-focus-ring-style) var(--wa-focus-ring-width) var(--wa-color-brand-border-loud);\n outline-offset: var(--wa-focus-ring-offset);\n }\n\n /* Remove inner borders and handle overlap */\n :host([appearance='button'][data-wa-radio-horizontal]:not([data-wa-radio-first])) {\n margin-inline-start: calc(-1 * var(--wa-form-control-border-width));\n }\n\n :host([appearance='button'][data-wa-radio-vertical]:not([data-wa-radio-first])) {\n margin-block-start: calc(-1 * var(--wa-form-control-border-width));\n }\n\n /* Ensure interactive states are visible above adjacent buttons */\n :host([appearance='button']:hover),\n :host([appearance='button']:state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R,EA0BkB",
6
6
  "names": ["html", "property", "state", "isServer", "property", "LitElement", "unsafeCSS", "property", "css", "styles", "_hasRecordedInitialProperties", "BaseElement", "LitElement", "__privateAdd", "customState", "active", "_a", "Self", "property", "spec", "styles", "style", "unsafeCSS", "name", "oldValue", "newValue", "__privateGet", "obj", "prop", "__privateSet", "changedProperties", "value", "event", "eventOptions", "__decorateClass", "CustomErrorValidator", "element", "validity", "WInvalidEvent", "BaseFormAssociatedElement", "BaseElement", "e", "WInvalidEvent", "event", "_a", "emittedEvents", "isServer", "CustomErrorValidator", "parentAttrs", "validator", "attr", "args", "changedProperties", "value", "formData", "val", "flags", "message", "anchor", "required", "isValid", "hasInteracted", "isDisabled", "state", "reason", "staticValidators", "validators", "formControl", "finalMessage", "invalidKeys", "str", "__decorateClass", "property", "css", "styles", "WRadio", "BaseFormAssociatedElement", "changedProperties", "effectivelyDisabled", "html", "styles", "__decorateClass", "state", "property"]
7
7
  }
@@ -0,0 +1,8 @@
1
+ import type { StoryObj } from '@storybook/web-components-vite';
2
+ import './index';
3
+ declare const _default: {
4
+ title: string;
5
+ render: () => import("lit").TemplateResult<1>;
6
+ };
7
+ export default _default;
8
+ export declare const Default: StoryObj;
@@ -0,0 +1,275 @@
1
+ var U=Object.defineProperty;var B=Object.getOwnPropertyDescriptor;var V=s=>{throw TypeError(s)};var l=(s,r,t,e)=>{for(var a=e>1?void 0:e?B(r,t):r,i=s.length-1,o;i>=0;i--)(o=s[i])&&(a=(e?o(r,t,a):o(a))||a);return e&&a&&U(r,t,a),a};var x=(s,r,t)=>r.has(s)||V("Cannot "+t);var C=(s,r,t)=>(x(s,r,"read from private field"),t?t.call(s):r.get(s)),S=(s,r,t)=>r.has(s)?V("Cannot add the same private member more than once"):r instanceof WeakSet?r.add(s):r.set(s,t),A=(s,r,t,e)=>(x(s,r,"write to private field"),e?e.call(s,t):r.set(s,t),t);import{html as Y}from"lit";import{html as K}from"lit";import{property as y,state as M}from"lit/decorators.js";import{isServer as k}from"lit";import{property as b}from"lit/decorators.js";import{LitElement as $,unsafeCSS as _}from"lit";import{property as L}from"lit/decorators.js";import{css as P}from"lit";var R=P`
2
+ :host {
3
+ box-sizing: border-box !important;
4
+ }
5
+
6
+ :host *,
7
+ :host *::before,
8
+ :host *::after {
9
+ box-sizing: inherit !important;
10
+ }
11
+ `;var g,p=class extends ${constructor(){super();S(this,g,!1);this.initialReflectedProperties=new Map;this.customStates={set:(t,e)=>{var a;(a=this.internals)!=null&&a.states&&(e?this.internals.states.add(t):this.internals.states.delete(t))},has:t=>{var e;return(e=this.internals)!=null&&e.states?this.internals.states.has(t):!1}};try{this.internals=this.attachInternals()}catch(e){console.error("Element internals are not supported in your browser. Consider using a polyfill")}this.customStates.set("wa-defined",!0);let t=this.constructor;for(let[e,a]of t.elementProperties)a.default==="inherit"&&a.initial!==void 0&&typeof e=="string"&&this.customStates.set(`initial-${e}-${a.initial}`,!0)}static get styles(){let t=Array.isArray(this.css)?this.css:this.css?[this.css]:[];return[R,...t].map(e=>typeof e=="string"?_(e):e)}attributeChangedCallback(t,e,a){C(this,g)||(this.constructor.elementProperties.forEach((i,o)=>{i.reflect&&this[o]!=null&&this.initialReflectedProperties.set(o,this[o])}),A(this,g,!0)),super.attributeChangedCallback(t,e,a)}willUpdate(t){super.willUpdate(t),this.initialReflectedProperties.forEach((e,a)=>{t.has(a)&&this[a]==null&&(this[a]=e)})}relayNativeEvent(t,e){t.stopImmediatePropagation(),this.dispatchEvent(new t.constructor(t.type,{...t,...e}))}};g=new WeakMap,l([L()],p.prototype,"dir",2),l([L()],p.prototype,"lang",2);var T=()=>({observedAttributes:["custom-error"],checkValidity(s){let r={message:"",isValid:!0,invalidKeys:[]};return s.customError&&(r.message=s.customError,r.isValid=!1,r.invalidKeys=["customError"]),r}});var w=class extends Event{constructor(){super("w-invalid",{bubbles:!0,cancelable:!1,composed:!0})}};var c=class extends p{constructor(){super();this.name=null;this.disabled=!1;this.required=!1;this.assumeInteractionOn=["input"];this.validators=[];this.valueHasChanged=!1;this.hasInteracted=!1;this.customError=null;this.emittedEvents=[];this.emitInvalid=t=>{t.target===this&&(this.hasInteracted=!0,this.dispatchEvent(new w))};this.handleInteraction=t=>{var a;let e=this.emittedEvents;e.includes(t.type)||e.push(t.type),e.length===((a=this.assumeInteractionOn)==null?void 0:a.length)&&(this.hasInteracted=!0)};k||this.addEventListener("invalid",this.emitInvalid)}static get validators(){return[T()]}static get observedAttributes(){let t=new Set(super.observedAttributes||[]);for(let e of this.validators)if(e.observedAttributes)for(let a of e.observedAttributes)t.add(a);return[...t]}connectedCallback(){super.connectedCallback(),this.updateValidity(),this.assumeInteractionOn.forEach(t=>{this.addEventListener(t,this.handleInteraction)})}firstUpdated(...t){super.firstUpdated(...t),this.updateValidity()}willUpdate(t){if(!k&&t.has("customError")&&(this.customError||(this.customError=null),this.setCustomValidity(this.customError||"")),t.has("value")||t.has("disabled")){let e=this.value;if(Array.isArray(e)){if(this.name){let a=new FormData;for(let i of e)a.append(this.name,i);this.setValue(a,a)}}else this.setValue(e,e)}t.has("disabled")&&(this.customStates.set("disabled",this.disabled),(this.hasAttribute("disabled")||!k&&!this.matches(":disabled"))&&this.toggleAttribute("disabled",this.disabled)),this.updateValidity(),super.willUpdate(t)}get labels(){return this.internals.labels}getForm(){return this.internals.form}get validity(){return this.internals.validity}get willValidate(){return this.internals.willValidate}get validationMessage(){return this.internals.validationMessage}checkValidity(){return this.updateValidity(),this.internals.checkValidity()}reportValidity(){return this.updateValidity(),this.hasInteracted=!0,this.internals.reportValidity()}get validationTarget(){return this.input||void 0}setValidity(...t){let e=t[0],a=t[1],i=t[2];i||(i=this.validationTarget),this.internals.setValidity(e,a,i||void 0),this.requestUpdate("validity"),this.setCustomStates()}setCustomStates(){let t=!!this.required,e=this.internals.validity.valid,a=this.hasInteracted;this.customStates.set("required",t),this.customStates.set("optional",!t),this.customStates.set("invalid",!e),this.customStates.set("valid",e),this.customStates.set("user-invalid",!e&&a),this.customStates.set("user-valid",e&&a)}setCustomValidity(t){if(!t){this.customError=null,this.setValidity({});return}this.customError=t,this.setValidity({customError:!0},t,this.validationTarget)}formResetCallback(){this.resetValidity(),this.hasInteracted=!1,this.valueHasChanged=!1,this.emittedEvents=[],this.updateValidity()}formDisabledCallback(t){this.disabled=t,this.updateValidity()}formStateRestoreCallback(t,e){this.value=t,e==="restore"&&this.resetValidity(),this.updateValidity()}setValue(...t){let[e,a]=t;this.internals.setFormValue(e,a)}get allValidators(){let t=this.constructor.validators||[],e=this.validators||[];return[...t,...e]}resetValidity(){this.setCustomValidity(""),this.setValidity({})}updateValidity(){if(this.disabled||this.hasAttribute("disabled")||!this.willValidate){this.resetValidity();return}let t=this.allValidators;if(!(t!=null&&t.length))return;let e={customError:!!this.customError},a=this.validationTarget||this.input||void 0,i="";for(let o of t){let{isValid:n,message:v,invalidKeys:h}=o.checkValidity(this);n||(i||(i=v),(h==null?void 0:h.length)>=0&&h.forEach(f=>e[f]=!0))}i||(i=this.validationMessage),this.setValidity(e,i,a)}};c.formAssociated=!0,l([b({reflect:!0})],c.prototype,"name",2),l([b({type:Boolean})],c.prototype,"disabled",2),l([b({state:!0,attribute:!1})],c.prototype,"valueHasChanged",2),l([b({state:!0,attribute:!1})],c.prototype,"hasInteracted",2),l([b({attribute:"custom-error",reflect:!0})],c.prototype,"customError",2),l([b({attribute:!1,state:!0,type:Object})],c.prototype,"validity",1);import{css as j}from"lit";var I=j`
12
+ :host {
13
+ color: var(--wa-form-control-value-color);
14
+ display: inline-flex;
15
+ flex-direction: row;
16
+ align-items: top;
17
+ font-family: inherit;
18
+ font-weight: var(--wa-form-control-value-font-weight);
19
+ line-height: var(--wa-form-control-value-line-height);
20
+ cursor: pointer;
21
+ user-select: none;
22
+ -webkit-user-select: none;
23
+ }
24
+
25
+ :host(:focus) {
26
+ outline: none;
27
+ }
28
+
29
+ [part~='label'] {
30
+ display: inline;
31
+ }
32
+
33
+ [part~='hint'] {
34
+ margin-block-start: 0.5em;
35
+ }
36
+
37
+ /* Default appearance */
38
+ :host([appearance='default']) .control {
39
+ flex: 0 0 auto;
40
+ position: relative;
41
+ display: inline-flex;
42
+ align-items: center;
43
+ justify-content: center;
44
+ width: var(--wa-form-control-toggle-size, 2rem);
45
+ height: var(--wa-form-control-toggle-size, 2rem);
46
+ border-color: var(--wa-form-control-border-color, gray);
47
+ border-radius: 50%;
48
+ border-style: var(--wa-form-control-border-style, solid);
49
+ border-width: var(--wa-form-control-border-width, 1px);
50
+ background-color: var(--wa-form-control-background-color, white);
51
+ color: transparent;
52
+ transition-property: all;
53
+ transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
54
+ transition-duration: 150ms;
55
+
56
+ margin-inline-end: 0.5em;
57
+ }
58
+
59
+ :host([appearance='clickable']) .control {
60
+ position: absolute;
61
+ inset: 0;
62
+ height: 100%;
63
+ width: 100%;
64
+ cursor: pointer;
65
+ }
66
+
67
+ /* Checked */
68
+ :host(:state(checked)):not(:host([appearance='clickable'])) .control {
69
+ /* color: var(--checked-icon-color, white); */
70
+ border-color: var(--wa-form-control-activated-color, blue);
71
+ background-color: var(--wa-form-control-background-color, white);
72
+ border-width: 0.6rem;
73
+ }
74
+
75
+ /* Focus */
76
+ :host(:focus-visible) .control {
77
+ outline: 2px solid var(--w-s-color-border-focus);
78
+ outline-offset: var(--w-outline-offset, 1px);
79
+ }
80
+
81
+ :host([appearance='clickable']:focus-visible) .control {
82
+ outline-offset: -4px;
83
+ border-radius: 8px;
84
+ }
85
+
86
+ /* Disabled */
87
+ :host(:state(disabled)) {
88
+ opacity: 0.5;
89
+ cursor: not-allowed;
90
+ }
91
+
92
+ /* Button appearance */
93
+ :host([appearance='button']) {
94
+ align-items: center;
95
+ min-height: var(--wa-form-control-height);
96
+ background-color: var(--wa-color-surface-default);
97
+ border: var(--wa-form-control-border-width) var(--wa-form-control-border-style) var(--wa-form-control-border-color);
98
+ border-radius: var(--wa-border-radius-m);
99
+ padding: 0 var(--wa-form-control-padding-inline);
100
+ transition:
101
+ background-color var(--wa-transition-fast),
102
+ border-color var(--wa-transition-fast);
103
+ }
104
+
105
+ :host([appearance='button']) .control {
106
+ display: none;
107
+ }
108
+
109
+ /* Horizontal grouping - remove inner border radius */
110
+ :host([appearance='button'][data-wa-radio-horizontal][data-wa-radio-inner]) {
111
+ border-radius: 0;
112
+ }
113
+
114
+ :host([appearance='button'][data-wa-radio-horizontal][data-wa-radio-first]) {
115
+ border-start-end-radius: 0;
116
+ border-end-end-radius: 0;
117
+ }
118
+
119
+ :host([appearance='button'][data-wa-radio-horizontal][data-wa-radio-last]) {
120
+ border-start-start-radius: 0;
121
+ border-end-start-radius: 0;
122
+ }
123
+
124
+ /* Vertical grouping - remove inner border radius */
125
+ :host([appearance='button'][data-wa-radio-vertical][data-wa-radio-inner]) {
126
+ border-radius: 0;
127
+ }
128
+
129
+ :host([appearance='button'][data-wa-radio-vertical][data-wa-radio-first]) {
130
+ border-end-start-radius: 0;
131
+ border-end-end-radius: 0;
132
+ }
133
+
134
+ :host([appearance='button'][data-wa-radio-vertical][data-wa-radio-last]) {
135
+ border-start-start-radius: 0;
136
+ border-start-end-radius: 0;
137
+ }
138
+
139
+ @media (hover: hover) {
140
+ :host([appearance='button']:hover:not(:state(disabled), :state(checked))) {
141
+ background-color: color-mix(in srgb, var(--wa-color-surface-default) 95%, var(--wa-color-mix-hover));
142
+ }
143
+ }
144
+
145
+ :host([appearance='button']:focus-visible) {
146
+ outline: var(--wa-focus-ring);
147
+ outline-offset: var(--wa-focus-ring-offset);
148
+ }
149
+
150
+ :host([appearance='button']:state(checked)) {
151
+ border-color: var(--wa-form-control-activated-color);
152
+ background-color: var(--wa-color-brand-fill-quiet);
153
+ }
154
+
155
+ :host([appearance='button']:state(checked):focus-visible) {
156
+ outline: var(--wa-focus-ring-style) var(--wa-focus-ring-width) var(--wa-color-brand-border-loud);
157
+ outline-offset: var(--wa-focus-ring-offset);
158
+ }
159
+
160
+ /* Remove inner borders and handle overlap */
161
+ :host([appearance='button'][data-wa-radio-horizontal]:not([data-wa-radio-first])) {
162
+ margin-inline-start: calc(-1 * var(--wa-form-control-border-width));
163
+ }
164
+
165
+ :host([appearance='button'][data-wa-radio-vertical]:not([data-wa-radio-first])) {
166
+ margin-block-start: calc(-1 * var(--wa-form-control-border-width));
167
+ }
168
+
169
+ /* Ensure interactive states are visible above adjacent buttons */
170
+ :host([appearance='button']:hover),
171
+ :host([appearance='button']:state(checked)) {
172
+ position: relative;
173
+ z-index: 1;
174
+ }
175
+
176
+ :host([appearance='button']:focus-visible) {
177
+ z-index: 2;
178
+ }
179
+ `;var u=class extends c{constructor(){super();this.checked=!1;this.forceDisabled=!1;this.form=null;this.appearance="default";this.size="medium";this.disabled=!1;this.handleClick=()=>{!this.disabled&&!this.forceDisabled&&(this.checked=!0)};this.addEventListener("click",this.handleClick)}connectedCallback(){super.connectedCallback(),this.setInitialAttributes()}setInitialAttributes(){this.setAttribute("role","radio"),this.tabIndex=0,this.setAttribute("aria-disabled",this.disabled||this.forceDisabled?"true":"false")}updated(t){if(super.updated(t),t.has("checked")&&(this.customStates.set("checked",this.checked),this.setAttribute("aria-checked",this.checked?"true":"false"),!this.disabled&&!this.forceDisabled&&(this.tabIndex=this.checked?0:-1)),t.has("disabled")||t.has("forceDisabled")){let e=this.disabled||this.forceDisabled;this.customStates.set("disabled",e),this.setAttribute("aria-disabled",e?"true":"false"),e?this.tabIndex=-1:this.tabIndex=this.checked?0:-1}}setValue(){}render(){return K`
180
+ <span part="control" class="control"></span>
181
+ <slot part="label" class="label"></slot>
182
+ `}};u.css=[I],l([M()],u.prototype,"checked",2),l([M()],u.prototype,"forceDisabled",2),l([y({reflect:!0})],u.prototype,"form",2),l([y({reflect:!0})],u.prototype,"value",2),l([y({reflect:!0})],u.prototype,"appearance",2),l([y({reflect:!0})],u.prototype,"size",2),l([y({type:Boolean})],u.prototype,"disabled",2);import{html as J}from"lit";import{property as m,query as Q,state as O}from"lit/decorators.js";import{classMap as F}from"lit/directives/class-map.js";var H="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";var D=(s=21)=>{let r="",t=crypto.getRandomValues(new Uint8Array(s|=0));for(;s--;)r+=H[t[s]&63];return r};function q(s=""){return`${s}${D()}`}import{css as X}from"lit";var N=X`
183
+ :host {
184
+ display: block;
185
+ }
186
+
187
+ .form-control {
188
+ position: relative;
189
+ border: none;
190
+ padding: 0;
191
+ margin: 0;
192
+ }
193
+
194
+ .label {
195
+ font-size: var(--w-font-size-s);
196
+ line-height: var(--w-line-height-s);
197
+ font-weight: 700;
198
+ -webkit-font-smoothing: antialiased;
199
+ -moz-osx-font-smoothing: grayscale;
200
+ font-smoothing: grayscale;
201
+ cursor: pointer;
202
+ padding-bottom: 0.4rem;
203
+ color: var(--w-s-color-text);
204
+ display: block;
205
+ }
206
+
207
+ .radio-group-required .label::after {
208
+ content: var(--wa-form-control-required-content);
209
+ margin-inline-start: var(--wa-form-control-required-content-offset);
210
+ }
211
+
212
+ .button-group {
213
+ display: flex;
214
+ }
215
+
216
+ [part~='form-control-input'] {
217
+ display: flex;
218
+ flex-direction: column;
219
+ flex-wrap: wrap;
220
+ gap: 0.75em;
221
+ }
222
+
223
+ /* Horizontal */
224
+ :host([orientation='horizontal']) [part~='form-control-input'] {
225
+ flex-direction: row;
226
+ gap: 1em;
227
+ }
228
+
229
+ /* Help text */
230
+ [part~='hint'] {
231
+ margin-block-start: 0.5em;
232
+ }
233
+
234
+ /* Radios have the "button" appearance */
235
+ :host fieldset.has-radio-buttons {
236
+ [part~='form-control-input'] {
237
+ gap: 0;
238
+ }
239
+ }
240
+ `;var z=(s={})=>{let{validationElement:r,validationProperty:t}=s;r||(r=Object.assign(document.createElement("input"),{required:!0})),t||(t="value");let e={observedAttributes:["required"],message:r.validationMessage,checkValidity(a){var h;let i={message:"",isValid:!0,invalidKeys:[]};return((h=a.required)!=null?h:a.hasAttribute("required"))&&!a[t]&&(i.message=typeof e.message=="function"?e.message(a):e.message||"",i.isValid=!1,i.invalidKeys.push("valueMissing")),i}};return e};var E=class{constructor(r,...t){this.slotNames=[];this.handleSlotChange=r=>{let t=r.target;(this.slotNames.includes("[default]")&&!t.name||t.name&&this.slotNames.includes(t.name))&&this.host.requestUpdate()};(this.host=r).addController(this),this.slotNames=t}hasDefaultSlot(){return[...this.host.childNodes].some(r=>{if(r.nodeType===Node.TEXT_NODE&&r.textContent.trim()!=="")return!0;if(r.nodeType===Node.ELEMENT_NODE){let t=r;if(t.tagName.toLowerCase()==="w-visually-hidden")return!1;if(!t.hasAttribute("slot"))return!0}return!1})}hasNamedSlot(r){return this.host.querySelector(`:scope > [slot="${r}"]`)!==null}test(r){return r==="[default]"?this.hasDefaultSlot():this.hasNamedSlot(r)}hostConnected(){this.host.shadowRoot.addEventListener("slotchange",this.handleSlotChange)}hostDisconnected(){this.host.shadowRoot.removeEventListener("slotchange",this.handleSlotChange)}};var d=class extends c{constructor(){super();this.hasSlotController=new E(this,"hint","label");this.hasRadioButtons=!1;this.label="";this.hint="";this.name=null;this.disabled=!1;this.orientation="vertical";this._value=null;this.defaultValue=this.getAttribute("value")||null;this.size="medium";this.required=!1;this.withLabel=!1;this.withHint=!1;this.handleRadioClick=t=>{let e=t.target.closest("w-radio");if(!e||e.disabled||e.forceDisabled||this.disabled)return;let a=this.value;this.value=e.value,e.checked=!0;let i=this.getAllRadios();for(let o of i)e!==o&&(o.checked=!1,o.setAttribute("tabindex","-1"));this.value!==a&&this.updateComplete.then(()=>{this.dispatchEvent(new InputEvent("input",{bubbles:!0,composed:!0})),this.dispatchEvent(new Event("change",{bubbles:!0,composed:!0}))})};this.addEventListener("keydown",this.handleKeyDown),this.addEventListener("click",this.handleRadioClick)}static get validators(){let t=[z({validationElement:Object.assign(document.createElement("input"),{required:!0,type:"radio",name:q("__w-radio")})})];return[...super.validators,...t]}get value(){var t;return this.valueHasChanged?this._value:(t=this._value)!=null?t:this.defaultValue}set value(t){typeof t=="number"&&(t=String(t)),this.valueHasChanged=!0,this._value=t}get validationTarget(){let t=this.querySelector(":is(w-radio):not([disabled])");if(t)return t}updated(t){(t.has("disabled")||t.has("value"))&&this.syncRadioElements()}formResetCallback(...t){this.value=this.defaultValue,super.formResetCallback(...t),this.syncRadioElements()}getAllRadios(){return[...this.querySelectorAll("w-radio")]}handleLabelClick(){this.focus()}async syncRadioElements(){let t=this.getAllRadios(),e=!1;if(t.forEach((a,i)=>{a.appearance==="button"&&(e=!0),a.setAttribute("size",this.size),a.toggleAttribute("data-w-radio-horizontal",this.orientation!=="vertical"),a.toggleAttribute("data-w-radio-vertical",this.orientation==="vertical"),a.toggleAttribute("data-w-radio-first",i===0),a.toggleAttribute("data-w-radio-inner",i!==0&&i!==t.length-1),a.toggleAttribute("data-w-radio-last",i===t.length-1),a.forceDisabled=this.disabled}),this.hasRadioButtons=e,await Promise.all(t.map(async a=>{await a.updateComplete,!a.disabled&&a.value===this.value?a.checked=!0:a.checked=!1})),this.disabled)t.forEach(a=>{a.tabIndex=-1});else{let a=t.filter(o=>!o.disabled),i=a.find(o=>o.checked);a.length>0&&(i?a.forEach(o=>{o.tabIndex=o.checked?0:-1}):a.forEach((o,n)=>{o.tabIndex=n===0?0:-1})),t.filter(o=>o.disabled).forEach(o=>{o.tabIndex=-1})}}handleKeyDown(t){var h;if(!["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"," "].includes(t.key)||this.disabled)return;let e=this.getAllRadios().filter(f=>!f.disabled);if(e.length<=0)return;t.preventDefault();let a=this.value,i=(h=e.find(f=>f.checked))!=null?h:e[0],o=t.key===" "?0:["ArrowUp","ArrowLeft"].includes(t.key)?-1:1,n=e.indexOf(i)+o;n||(n=0),n<0&&(n=e.length-1),n>e.length-1&&(n=0);let v=e.some(f=>f.tagName.toLowerCase()==="w-radio-button");this.getAllRadios().forEach(f=>{f.checked=!1,v||f.setAttribute("tabindex","-1")}),this.value=e[n].value,e[n].checked=!0,v?e[n].shadowRoot.querySelector("button").focus():(e[n].setAttribute("tabindex","0"),e[n].focus()),this.value!==a&&this.updateComplete.then(()=>{this.dispatchEvent(new InputEvent("input",{bubbles:!0,composed:!0})),this.dispatchEvent(new Event("change",{bubbles:!0,composed:!0}))}),t.preventDefault()}focus(t){if(this.disabled)return;let e=this.getAllRadios(),a=e.find(n=>n.checked),i=e.find(n=>!n.disabled),o=a||i;o&&o.focus(t)}render(){let t=this.hasUpdated?this.hasSlotController.test("label"):this.withLabel,e=this.hasUpdated?this.hasSlotController.test("hint"):this.withHint,a=this.label?!0:!!t,i=this.hint?!0:!!e;return J`
241
+ <fieldset
242
+ part="form-control"
243
+ class=${F({"form-control":!0,"form-control-radio-group":!0,"form-control-has-label":a,"has-radio-buttons":this.hasRadioButtons})}
244
+ role="radiogroup"
245
+ aria-labelledby="label"
246
+ aria-describedby="hint"
247
+ aria-errormessage="error-message"
248
+ aria-orientation=${this.orientation}>
249
+ <label
250
+ part="form-control-label"
251
+ id="label"
252
+ class="label"
253
+ aria-hidden=${a?"false":"true"}
254
+ @click=${this.handleLabelClick}>
255
+ <slot name="label">${this.label}</slot>
256
+ </label>
257
+
258
+ <slot part="form-control-input" @slotchange=${this.syncRadioElements}></slot>
259
+
260
+ <slot
261
+ id="hint"
262
+ name="hint"
263
+ part="hint"
264
+ class=${F({"has-slotted":i})}
265
+ aria-hidden=${i?"false":"true"}
266
+ >${this.hint}</slot
267
+ >
268
+ </fieldset>
269
+ `}};d.css=[N],d.shadowRootOptions={...c.shadowRootOptions,delegatesFocus:!0},l([O()],d.prototype,"hasRadioButtons",2),l([Q("slot:not([name])")],d.prototype,"defaultSlot",2),l([m()],d.prototype,"label",2),l([m({attribute:"hint"})],d.prototype,"hint",2),l([m({reflect:!0})],d.prototype,"name",2),l([m({type:Boolean,reflect:!0})],d.prototype,"disabled",2),l([m({reflect:!0})],d.prototype,"orientation",2),l([O()],d.prototype,"value",1),l([m({attribute:"value",reflect:!0})],d.prototype,"defaultValue",2),l([m({reflect:!0})],d.prototype,"size",2),l([m({type:Boolean,reflect:!0})],d.prototype,"required",2),l([m({type:Boolean,attribute:"with-label"})],d.prototype,"withLabel",2),l([m({type:Boolean,attribute:"with-hint"})],d.prototype,"withHint",2);customElements.get("w-radio")||(customElements.define("w-radio",u),customElements.define("w-radio-group",d));var Xt={title:"Forms/Radio",render:()=>Y`
270
+ <w-radio-group label="Group" name="foobar" value="foo">
271
+ <w-radio value="foo">foo</w-radio>
272
+ <w-radio value="bar">bar</w-radio>
273
+ </w-radio-group>
274
+ `},Jt={};export{Jt as Default,Xt as default};
275
+ //# sourceMappingURL=radio.stories.js.map