@synergy-design-system/components 1.0.0-main.9 → 1.0.1
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/LICENSE +5 -24
- package/README.md +1 -1
- package/dist/chunks/chunk.23HTU3YE.js +189 -0
- package/dist/chunks/chunk.23HTU3YE.js.map +7 -0
- package/dist/chunks/{chunk.SGZ5ADPY.js → chunk.2AFAC4WC.js} +2 -2
- package/dist/chunks/chunk.2KZQRT3X.js +12 -0
- package/dist/chunks/chunk.2KZQRT3X.js.map +7 -0
- package/dist/chunks/chunk.2XZKXVMR.js +44 -0
- package/dist/chunks/chunk.2XZKXVMR.js.map +7 -0
- package/dist/chunks/{chunk.H6VZTJD6.js → chunk.44XDJIKU.js} +2 -2
- package/dist/chunks/chunk.45EJNI43.js +12 -0
- package/dist/chunks/chunk.45EJNI43.js.map +7 -0
- package/dist/chunks/chunk.4CBN5LPQ.js +137 -0
- package/dist/chunks/chunk.4CBN5LPQ.js.map +7 -0
- package/dist/chunks/chunk.4I6M5V6O.js +56 -0
- package/dist/chunks/chunk.4I6M5V6O.js.map +7 -0
- package/dist/chunks/{chunk.5OIEI73E.js → chunk.4XAK6MOQ.js} +2 -2
- package/dist/chunks/chunk.4ZURABYO.js +24 -0
- package/dist/chunks/{chunk.BREU4ILT.js.map → chunk.4ZURABYO.js.map} +3 -3
- package/dist/chunks/chunk.AFEABUNX.js +107 -0
- package/dist/chunks/chunk.AFEABUNX.js.map +7 -0
- package/dist/chunks/chunk.CJRAYQIQ.js +360 -0
- package/dist/chunks/chunk.CJRAYQIQ.js.map +7 -0
- package/dist/chunks/chunk.D6VKS2T5.js +12 -0
- package/dist/chunks/chunk.D6VKS2T5.js.map +7 -0
- package/dist/chunks/chunk.F4MRQLNL.js +25 -0
- package/dist/chunks/chunk.F4MRQLNL.js.map +7 -0
- package/dist/chunks/chunk.FHA67NLP.js +12 -0
- package/dist/chunks/chunk.FHA67NLP.js.map +7 -0
- package/dist/chunks/{chunk.MQ3KYTNU.js → chunk.FVSP4LXX.js} +4 -4
- package/dist/chunks/chunk.FVSP4LXX.js.map +7 -0
- package/dist/chunks/chunk.GNAJOKCJ.js +32 -0
- package/dist/chunks/chunk.GNAJOKCJ.js.map +7 -0
- package/dist/chunks/chunk.ILEPKAEH.js +224 -0
- package/dist/chunks/chunk.ILEPKAEH.js.map +7 -0
- package/dist/chunks/chunk.JBYBQ5TQ.js +132 -0
- package/dist/chunks/chunk.JBYBQ5TQ.js.map +7 -0
- package/dist/chunks/chunk.JHXCBOUD.js +123 -0
- package/dist/chunks/chunk.JHXCBOUD.js.map +7 -0
- package/dist/chunks/chunk.K24GB7WK.js +86 -0
- package/dist/chunks/chunk.K24GB7WK.js.map +7 -0
- package/dist/chunks/chunk.KP6DSDGX.js +212 -0
- package/dist/chunks/chunk.KP6DSDGX.js.map +7 -0
- package/dist/chunks/{chunk.GRZ3TSGB.js → chunk.LDUXZQMQ.js} +2 -2
- package/dist/chunks/chunk.LGQOKLYP.js +12 -0
- package/dist/chunks/chunk.LGQOKLYP.js.map +7 -0
- package/dist/chunks/chunk.MNMITYTH.js +184 -0
- package/dist/chunks/chunk.MNMITYTH.js.map +7 -0
- package/dist/chunks/chunk.MNNPG5GD.js +12 -0
- package/dist/chunks/chunk.MNNPG5GD.js.map +7 -0
- package/dist/chunks/{chunk.6CFDQNJT.js → chunk.N2EPATPO.js} +14 -12
- package/dist/chunks/chunk.N2EPATPO.js.map +7 -0
- package/dist/chunks/chunk.NKIYFJN2.js +1 -0
- package/dist/chunks/chunk.NKIYFJN2.js.map +7 -0
- package/dist/chunks/chunk.OVVMSN4D.js +37 -0
- package/dist/chunks/chunk.OVVMSN4D.js.map +7 -0
- package/dist/chunks/{chunk.Q77OTWF2.js → chunk.OXUFFH57.js} +6 -66
- package/dist/chunks/{chunk.Q77OTWF2.js.map → chunk.OXUFFH57.js.map} +4 -4
- package/dist/chunks/{chunk.WDCAHRYG.js → chunk.P2LNG2PZ.js} +4 -2
- package/dist/chunks/chunk.PJO6TM3T.js +10 -0
- package/dist/chunks/{chunk.ILONRPL4.js.map → chunk.PJO6TM3T.js.map} +2 -2
- package/dist/chunks/chunk.QMK3O44E.js +351 -0
- package/dist/chunks/chunk.QMK3O44E.js.map +7 -0
- package/dist/chunks/{chunk.DYPYZ53B.js → chunk.QUUM6GP4.js} +13 -31
- package/dist/chunks/{chunk.DYPYZ53B.js.map → chunk.QUUM6GP4.js.map} +3 -3
- package/dist/chunks/{chunk.BREU4ILT.js → chunk.RSONAU45.js} +6 -1
- package/dist/chunks/chunk.RSONAU45.js.map +7 -0
- package/dist/chunks/{chunk.IZS6SARK.js → chunk.SUJGOV4C.js} +11 -38
- package/dist/chunks/{chunk.IZS6SARK.js.map → chunk.SUJGOV4C.js.map} +4 -4
- package/dist/chunks/chunk.V26UAJIM.js +111 -0
- package/dist/chunks/chunk.V26UAJIM.js.map +7 -0
- package/dist/chunks/chunk.V6VND4OF.js +49 -0
- package/dist/chunks/chunk.V6VND4OF.js.map +7 -0
- package/dist/chunks/chunk.VUW6CZ2F.js +12 -0
- package/dist/chunks/chunk.VUW6CZ2F.js.map +7 -0
- package/dist/chunks/chunk.VZ7S7YYN.js +34 -0
- package/dist/chunks/chunk.VZ7S7YYN.js.map +7 -0
- package/dist/chunks/chunk.W46CFM2R.js +90 -0
- package/dist/chunks/chunk.W46CFM2R.js.map +7 -0
- package/dist/chunks/chunk.WFAJR3FN.js +25 -0
- package/dist/chunks/chunk.WFAJR3FN.js.map +7 -0
- package/dist/chunks/chunk.X234HJNO.js +12 -0
- package/dist/chunks/chunk.X234HJNO.js.map +7 -0
- package/dist/chunks/chunk.YBIBWRKC.js +19 -0
- package/dist/chunks/chunk.YBIBWRKC.js.map +7 -0
- package/dist/chunks/chunk.YQQJ6ELJ.js +127 -0
- package/dist/chunks/chunk.YQQJ6ELJ.js.map +7 -0
- package/dist/chunks/{chunk.OZSASB66.js → chunk.YTS5TRJZ.js} +2 -2
- package/dist/chunks/{chunk.OZSASB66.js.map → chunk.YTS5TRJZ.js.map} +1 -1
- package/dist/chunks/{chunk.WTCUSH7V.js → chunk.Z3RZUTQU.js} +2 -2
- package/dist/chunks/{chunk.YOW3IJVJ.js → chunk.ZUNBGZ5R.js} +2 -2
- package/dist/chunks/{chunk.YOW3IJVJ.js.map → chunk.ZUNBGZ5R.js.map} +1 -1
- package/dist/components/button/button.component.js +13 -11
- package/dist/components/button/button.custom.styles.js +1 -1
- package/dist/components/button/button.js +14 -12
- package/dist/components/button/button.styles.js +2 -2
- package/dist/components/button-group/button-group.component.d.ts +28 -0
- package/dist/components/button-group/button-group.component.js +11 -0
- package/dist/components/button-group/button-group.component.js.map +7 -0
- package/dist/components/button-group/button-group.d.ts +8 -0
- package/dist/components/button-group/button-group.js +12 -0
- package/dist/components/button-group/button-group.js.map +7 -0
- package/dist/components/button-group/button-group.styles.d.ts +2 -0
- package/dist/components/button-group/button-group.styles.js +9 -0
- package/dist/components/button-group/button-group.styles.js.map +7 -0
- package/dist/components/checkbox/checkbox.component.d.ts +93 -0
- package/dist/components/checkbox/checkbox.component.js +22 -0
- package/dist/components/checkbox/checkbox.component.js.map +7 -0
- package/dist/components/checkbox/checkbox.custom.styles.js +3 -6
- package/dist/components/checkbox/checkbox.custom.styles.js.map +3 -3
- package/dist/components/checkbox/checkbox.d.ts +8 -0
- package/dist/components/checkbox/checkbox.js +23 -0
- package/dist/components/checkbox/checkbox.js.map +7 -0
- package/dist/components/checkbox/checkbox.styles.d.ts +2 -0
- package/dist/components/checkbox/checkbox.styles.js +10 -0
- package/dist/components/checkbox/checkbox.styles.js.map +7 -0
- package/dist/components/icon/icon.component.js +7 -5
- package/dist/components/icon/icon.custom.styles.d.ts +2 -0
- package/dist/components/icon/icon.custom.styles.js +8 -0
- package/dist/components/icon/icon.custom.styles.js.map +7 -0
- package/dist/components/icon/icon.js +9 -10
- package/dist/components/icon/icon.js.map +3 -3
- package/dist/components/icon/icon.styles.js +2 -1
- package/dist/components/icon/library.js +2 -2
- package/dist/components/icon/library.system.js +1 -1
- package/dist/components/input/input.component.js +14 -10
- package/dist/components/input/input.custom.styles.js +1 -1
- package/dist/components/input/input.js +15 -11
- package/dist/components/input/input.styles.js +3 -2
- package/dist/components/radio/radio.component.d.ts +53 -0
- package/dist/components/radio/radio.component.js +20 -0
- package/dist/components/radio/radio.component.js.map +7 -0
- package/dist/components/radio/radio.custom.styles.d.ts +2 -0
- package/dist/components/radio/radio.custom.styles.js +8 -0
- package/dist/components/radio/radio.custom.styles.js.map +7 -0
- package/dist/components/radio/radio.d.ts +8 -0
- package/dist/components/radio/radio.js +21 -0
- package/dist/components/radio/radio.js.map +7 -0
- package/dist/components/radio/radio.styles.d.ts +2 -0
- package/dist/components/radio/radio.styles.js +10 -0
- package/dist/components/radio/radio.styles.js.map +7 -0
- package/dist/components/radio-button/radio-button.component.d.ts +53 -0
- package/dist/components/radio-button/radio-button.component.js +15 -0
- package/dist/components/radio-button/radio-button.component.js.map +7 -0
- package/dist/components/radio-button/radio-button.d.ts +8 -0
- package/dist/components/radio-button/radio-button.js +16 -0
- package/dist/components/radio-button/radio-button.js.map +7 -0
- package/dist/components/radio-button/radio-button.styles.d.ts +2 -0
- package/dist/components/radio-button/radio-button.styles.js +11 -0
- package/dist/components/radio-button/radio-button.styles.js.map +7 -0
- package/dist/components/radio-group/radio-group.component.d.ts +89 -0
- package/dist/components/radio-group/radio-group.component.js +18 -0
- package/dist/components/radio-group/radio-group.component.js.map +7 -0
- package/dist/components/radio-group/radio-group.custom.styles.d.ts +2 -0
- package/dist/components/radio-group/radio-group.custom.styles.js +8 -0
- package/dist/components/radio-group/radio-group.custom.styles.js.map +7 -0
- package/dist/components/radio-group/radio-group.d.ts +8 -0
- package/dist/components/radio-group/radio-group.js +19 -0
- package/dist/components/radio-group/radio-group.js.map +7 -0
- package/dist/components/radio-group/radio-group.styles.d.ts +2 -0
- package/dist/components/radio-group/radio-group.styles.js +11 -0
- package/dist/components/radio-group/radio-group.styles.js.map +7 -0
- package/dist/components/spinner/spinner.component.js +2 -2
- package/dist/components/switch/switch.component.d.ts +86 -0
- package/dist/components/switch/switch.component.js +15 -0
- package/dist/components/switch/switch.component.js.map +7 -0
- package/dist/components/switch/switch.custom.styles.d.ts +2 -0
- package/dist/components/switch/switch.custom.styles.js +8 -0
- package/dist/components/switch/switch.custom.styles.js.map +7 -0
- package/dist/components/switch/switch.d.ts +8 -0
- package/dist/components/switch/switch.js +16 -0
- package/dist/components/switch/switch.js.map +7 -0
- package/dist/components/switch/switch.styles.d.ts +2 -0
- package/dist/components/switch/switch.styles.js +10 -0
- package/dist/components/switch/switch.styles.js.map +7 -0
- package/dist/components/textarea/textarea.component.d.ts +131 -0
- package/dist/components/textarea/textarea.component.js +17 -0
- package/dist/components/textarea/textarea.component.js.map +7 -0
- package/dist/components/textarea/textarea.custom.styles.js +3 -6
- package/dist/components/textarea/textarea.custom.styles.js.map +3 -3
- package/dist/components/textarea/textarea.d.ts +8 -0
- package/dist/components/textarea/textarea.js +18 -0
- package/dist/components/textarea/textarea.js.map +7 -0
- package/dist/components/textarea/textarea.styles.d.ts +2 -0
- package/dist/components/textarea/textarea.styles.js +11 -0
- package/dist/components/textarea/textarea.styles.js.map +7 -0
- package/dist/custom-elements.json +3072 -480
- package/dist/internal/test.d.ts +28 -0
- package/dist/styles/form-control.custom.styles.d.ts +2 -0
- package/dist/synergy.d.ts +11 -1
- package/dist/synergy.js +87 -21
- package/dist/utilities/form.js +2 -2
- package/dist/utilities/icon-library.d.ts +1 -0
- package/dist/utilities/icon-library.js +14 -0
- package/dist/utilities/icon-library.js.map +7 -0
- package/dist/vscode.html-custom-data.json +389 -0
- package/dist/web-types.json +866 -8
- package/package.json +23 -16
- package/dist/chunks/chunk.6CFDQNJT.js.map +0 -7
- package/dist/chunks/chunk.ILONRPL4.js +0 -10
- package/dist/chunks/chunk.MQ3KYTNU.js.map +0 -7
- package/dist/chunks/chunk.U7ZJ22QM.js +0 -128
- package/dist/chunks/chunk.U7ZJ22QM.js.map +0 -7
- /package/dist/chunks/{chunk.SGZ5ADPY.js.map → chunk.2AFAC4WC.js.map} +0 -0
- /package/dist/chunks/{chunk.H6VZTJD6.js.map → chunk.44XDJIKU.js.map} +0 -0
- /package/dist/chunks/{chunk.5OIEI73E.js.map → chunk.4XAK6MOQ.js.map} +0 -0
- /package/dist/chunks/{chunk.GRZ3TSGB.js.map → chunk.LDUXZQMQ.js.map} +0 -0
- /package/dist/chunks/{chunk.WDCAHRYG.js.map → chunk.P2LNG2PZ.js.map} +0 -0
- /package/dist/chunks/{chunk.WTCUSH7V.js.map → chunk.Z3RZUTQU.js.map} +0 -0
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/components/radio-group/radio-group.component.ts"],
|
|
4
|
+
"sourcesContent": ["// ---------------------------------------------------------------------\n// \uD83D\uDD12 AUTOGENERATED BY VENDORISM\n// Removing this comment will prevent it from being managed by it.\n// ---------------------------------------------------------------------\n\n/* eslint-disable */\nimport { classMap } from 'lit/directives/class-map.js';\nimport {\n customErrorValidityState,\n FormControlController,\n validValidityState,\n valueMissingValidityState\n} from '../../internal/form.js';\nimport { HasSlotController } from '../../internal/slot.js';\nimport { html } from 'lit';\nimport { property, query, state } from 'lit/decorators.js';\nimport { watch } from '../../internal/watch.js';\nimport SynergyElement from '../../internal/synergy-element.js';\nimport SynButtonGroup from '../button-group/button-group.component.js';\nimport styles from './radio-group.styles.js';\nimport type { CSSResultGroup } from 'lit';\nimport type { SynergyFormControl } from '../../internal/synergy-element.js';\nimport type SynRadio from '../radio/radio.js';\nimport type SynRadioButton from '../radio-button/radio-button.js';\n\n/**\n * @summary Radio groups are used to group multiple [radios](/components/radio) or [radio buttons](/components/radio-button) so they function as a single form control.\n * @documentation https://synergy.style/components/radio-group\n * @status stable\n * @since 2.0\n *\n * @dependency syn-button-group\n *\n * @slot - The default slot where `<syn-radio>` or `<syn-radio-button>` elements are placed.\n * @slot label - The radio group's label. Required for proper accessibility. Alternatively, you can use the `label`\n * attribute.\n *\n * @event syn-change - Emitted when the radio group's selected value changes.\n * @event syn-input - Emitted when the radio group receives user input.\n * @event syn-invalid - Emitted when the form control has been checked for validity and its constraints aren't satisfied.\n *\n * @csspart form-control - The form control that wraps the label, input, and help text.\n * @csspart form-control-label - The label's wrapper.\n * @csspart form-control-input - The input's wrapper.\n * @csspart form-control-help-text - The help text's wrapper.\n * @csspart button-group - The button group that wraps radio buttons.\n * @csspart button-group__base - The button group's `base` part.\n */\nexport default class SynRadioGroup extends SynergyElement implements SynergyFormControl {\n static styles: CSSResultGroup = styles;\n static dependencies = { 'syn-button-group': SynButtonGroup };\n\n protected readonly formControlController = new FormControlController(this);\n private readonly hasSlotController = new HasSlotController(this, 'help-text', 'label');\n private customValidityMessage = '';\n private validationTimeout: number;\n\n @query('slot:not([name])') defaultSlot: HTMLSlotElement;\n @query('.radio-group__validation-input') validationInput: HTMLInputElement;\n\n @state() private hasButtonGroup = false;\n @state() private errorMessage = '';\n @state() defaultValue = '';\n\n /**\n * The radio group's label. Required for proper accessibility. If you need to display HTML, use the `label` slot\n * instead.\n */\n @property() label = '';\n\n /** The radio groups's help text. If you need to display HTML, use the `help-text` slot instead. */\n @property({ attribute: 'help-text' }) helpText = '';\n\n /** The name of the radio group, submitted as a name/value pair with form data. */\n @property() name = 'option';\n\n /** The current value of the radio group, submitted as a name/value pair with form data. */\n @property({ reflect: true }) value = '';\n\n /** The radio group's size. This size will be applied to all child radios and radio buttons. */\n @property({ reflect: true }) size: 'small' | 'medium' | 'large' = 'medium';\n\n /**\n * By default, form controls are associated with the nearest containing `<form>` element. This attribute allows you\n * to place the form control outside of a form and associate it with the form that has this `id`. The form must be in\n * the same document or shadow root for this to work.\n */\n @property({ reflect: true }) form = '';\n\n /** Ensures a child radio is checked before allowing the containing form to submit. */\n @property({ type: Boolean, reflect: true }) required = false;\n\n /** Gets the validity state object */\n get validity() {\n const isRequiredAndEmpty = this.required && !this.value;\n const hasCustomValidityMessage = this.customValidityMessage !== '';\n\n if (hasCustomValidityMessage) {\n return customErrorValidityState;\n } else if (isRequiredAndEmpty) {\n return valueMissingValidityState;\n }\n\n return validValidityState;\n }\n\n /** Gets the validation message */\n get validationMessage() {\n const isRequiredAndEmpty = this.required && !this.value;\n const hasCustomValidityMessage = this.customValidityMessage !== '';\n\n if (hasCustomValidityMessage) {\n return this.customValidityMessage;\n } else if (isRequiredAndEmpty) {\n return this.validationInput.validationMessage;\n }\n\n return '';\n }\n\n connectedCallback() {\n super.connectedCallback();\n this.defaultValue = this.value;\n }\n\n firstUpdated() {\n this.formControlController.updateValidity();\n }\n\n private getAllRadios() {\n return [...this.querySelectorAll<SynRadio | SynRadioButton>('syn-radio, syn-radio-button')];\n }\n\n private handleRadioClick(event: MouseEvent) {\n const target = (event.target as HTMLElement).closest<SynRadio | SynRadioButton>('syn-radio, syn-radio-button')!;\n const radios = this.getAllRadios();\n const oldValue = this.value;\n\n if (target.disabled) {\n return;\n }\n\n this.value = target.value;\n radios.forEach(radio => (radio.checked = radio === target));\n\n if (this.value !== oldValue) {\n this.emit('syn-change');\n this.emit('syn-input');\n }\n }\n\n private handleKeyDown(event: KeyboardEvent) {\n if (!['ArrowUp', 'ArrowDown', 'ArrowLeft', 'ArrowRight', ' '].includes(event.key)) {\n return;\n }\n\n const radios = this.getAllRadios().filter(radio => !radio.disabled);\n const checkedRadio = radios.find(radio => radio.checked) ?? radios[0];\n const incr = event.key === ' ' ? 0 : ['ArrowUp', 'ArrowLeft'].includes(event.key) ? -1 : 1;\n const oldValue = this.value;\n let index = radios.indexOf(checkedRadio) + incr;\n\n if (index < 0) {\n index = radios.length - 1;\n }\n\n if (index > radios.length - 1) {\n index = 0;\n }\n\n this.getAllRadios().forEach(radio => {\n radio.checked = false;\n\n if (!this.hasButtonGroup) {\n radio.tabIndex = -1;\n }\n });\n\n this.value = radios[index].value;\n radios[index].checked = true;\n\n if (!this.hasButtonGroup) {\n radios[index].tabIndex = 0;\n radios[index].focus();\n } else {\n radios[index].shadowRoot!.querySelector('button')!.focus();\n }\n\n if (this.value !== oldValue) {\n this.emit('syn-change');\n this.emit('syn-input');\n }\n\n event.preventDefault();\n }\n\n private handleLabelClick() {\n const radios = this.getAllRadios();\n const checked = radios.find(radio => radio.checked);\n const radioToFocus = checked || radios[0];\n\n // Move focus to the checked radio (or the first one if none are checked) when clicking the label\n if (radioToFocus) {\n radioToFocus.focus();\n }\n }\n\n private handleInvalid(event: Event) {\n this.formControlController.setValidity(false);\n this.formControlController.emitInvalidEvent(event);\n }\n\n private async syncRadioElements() {\n const radios = this.getAllRadios();\n\n await Promise.all(\n // Sync the checked state and size\n radios.map(async radio => {\n await radio.updateComplete;\n radio.checked = radio.value === this.value;\n radio.size = this.size;\n })\n );\n\n this.hasButtonGroup = radios.some(radio => radio.tagName.toLowerCase() === 'syn-radio-button');\n\n if (!radios.some(radio => radio.checked)) {\n if (this.hasButtonGroup) {\n const buttonRadio = radios[0].shadowRoot?.querySelector('button');\n\n if (buttonRadio) {\n buttonRadio.tabIndex = 0;\n }\n } else {\n radios[0].tabIndex = 0;\n }\n }\n\n if (this.hasButtonGroup) {\n const buttonGroup = this.shadowRoot?.querySelector('syn-button-group');\n\n if (buttonGroup) {\n buttonGroup.disableRole = true;\n }\n }\n }\n\n private syncRadios() {\n if (customElements.get('syn-radio') && customElements.get('syn-radio-button')) {\n this.syncRadioElements();\n return;\n }\n\n if (customElements.get('syn-radio')) {\n this.syncRadioElements();\n } else {\n customElements.whenDefined('syn-radio').then(() => this.syncRadios());\n }\n\n if (customElements.get('syn-radio-button')) {\n this.syncRadioElements();\n } else {\n // Rerun this handler when <syn-radio> or <syn-radio-button> is registered\n customElements.whenDefined('syn-radio-button').then(() => this.syncRadios());\n }\n }\n\n private updateCheckedRadio() {\n const radios = this.getAllRadios();\n radios.forEach(radio => (radio.checked = radio.value === this.value));\n this.formControlController.setValidity(this.validity.valid);\n }\n\n @watch('size', { waitUntilFirstUpdate: true })\n handleSizeChange() {\n this.syncRadios();\n }\n\n @watch('value')\n handleValueChange() {\n if (this.hasUpdated) {\n this.updateCheckedRadio();\n }\n }\n\n /** Checks for validity but does not show a validation message. Returns `true` when valid and `false` when invalid. */\n checkValidity() {\n const isRequiredAndEmpty = this.required && !this.value;\n const hasCustomValidityMessage = this.customValidityMessage !== '';\n\n if (isRequiredAndEmpty || hasCustomValidityMessage) {\n this.formControlController.emitInvalidEvent();\n return false;\n }\n\n return true;\n }\n\n /** Gets the associated form, if one exists. */\n getForm(): HTMLFormElement | null {\n return this.formControlController.getForm();\n }\n\n /** Checks for validity and shows the browser's validation message if the control is invalid. */\n reportValidity(): boolean {\n const isValid = this.validity.valid;\n\n this.errorMessage = this.customValidityMessage || isValid ? '' : this.validationInput.validationMessage;\n this.formControlController.setValidity(isValid);\n this.validationInput.hidden = true;\n clearTimeout(this.validationTimeout);\n\n if (!isValid) {\n // Show the browser's constraint validation message\n this.validationInput.hidden = false;\n this.validationInput.reportValidity();\n this.validationTimeout = setTimeout(() => (this.validationInput.hidden = true), 10000) as unknown as number;\n }\n\n return isValid;\n }\n\n /** Sets a custom validation message. Pass an empty string to restore validity. */\n setCustomValidity(message = '') {\n this.customValidityMessage = message;\n this.errorMessage = message;\n this.validationInput.setCustomValidity(message);\n this.formControlController.updateValidity();\n }\n\n render() {\n const hasLabelSlot = this.hasSlotController.test('label');\n const hasHelpTextSlot = this.hasSlotController.test('help-text');\n const hasLabel = this.label ? true : !!hasLabelSlot;\n const hasHelpText = this.helpText ? true : !!hasHelpTextSlot;\n const defaultSlot = html`\n <slot @slotchange=${this.syncRadios} @click=${this.handleRadioClick} @keydown=${this.handleKeyDown}></slot>\n `;\n\n return html`\n <fieldset\n part=\"form-control\"\n class=${classMap({\n 'form-control': true,\n 'form-control--small': this.size === 'small',\n 'form-control--medium': this.size === 'medium',\n 'form-control--large': this.size === 'large',\n 'form-control--radio-group': true,\n 'form-control--has-label': hasLabel,\n 'form-control--has-help-text': hasHelpText\n })}\n role=\"radiogroup\"\n aria-labelledby=\"label\"\n aria-describedby=\"help-text\"\n aria-errormessage=\"error-message\"\n >\n <label\n part=\"form-control-label\"\n id=\"label\"\n class=\"form-control__label\"\n aria-hidden=${hasLabel ? 'false' : 'true'}\n @click=${this.handleLabelClick}\n >\n <slot name=\"label\">${this.label}</slot>\n </label>\n\n <div part=\"form-control-input\" class=\"form-control-input\">\n <div class=\"visually-hidden\">\n <div id=\"error-message\" aria-live=\"assertive\">${this.errorMessage}</div>\n <label class=\"radio-group__validation\">\n <input\n type=\"text\"\n class=\"radio-group__validation-input\"\n ?required=${this.required}\n tabindex=\"-1\"\n hidden\n @invalid=${this.handleInvalid}\n />\n </label>\n </div>\n\n ${this.hasButtonGroup\n ? html`\n <syn-button-group part=\"button-group\" exportparts=\"base:button-group__base\" role=\"presentation\">\n ${defaultSlot}\n </syn-button-group>\n `\n : defaultSlot}\n </div>\n\n <div\n part=\"form-control-help-text\"\n id=\"help-text\"\n class=\"form-control__help-text\"\n aria-hidden=${hasHelpText ? 'false' : 'true'}\n >\n <slot name=\"help-text\">${this.helpText}</slot>\n </div>\n </fieldset>\n `;\n }\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;AAMA,SAAS,gBAAgB;AAQzB,SAAS,YAAY;AACrB,SAAS,UAAU,OAAO,aAAa;AAiCvC,IAAqB,gBAArB,cAA2C,eAA6C;AAAA,EAAxF;AAAA;AAIE,SAAmB,wBAAwB,IAAI,sBAAsB,IAAI;AACzE,SAAiB,oBAAoB,IAAI,kBAAkB,MAAM,aAAa,OAAO;AACrF,SAAQ,wBAAwB;AAMvB,SAAQ,iBAAiB;AACzB,SAAQ,eAAe;AACvB,wBAAe;AAMZ,iBAAQ;AAGkB,oBAAW;AAGrC,gBAAO;AAGU,iBAAQ;AAGR,gBAAqC;AAOrC,gBAAO;AAGQ,oBAAW;AAAA;AAAA;AAAA,EAGvD,IAAI,WAAW;AACb,UAAM,qBA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GiB;AAAA,EAA5B,SAAS,EAAE,SAAS,KAAK,CAAC;AAAA,GA7BR,cA6BU;AAGA;AAAA,EAA5B,SAAS,EAAE,SAAS,KAAK,CAAC;AAAA,GAhCR,cAgCU;AAOA;AAAA,EAA5B,SAAS,EAAE,SAAS,KAAK,CAAC;AAAA,GAvCR,cAuCU;AAGe;AAAA,EAA3C,SAAS,EAAE,MAAM,SAAS,SAAS,KAAK,CAAC;AAAA,GA1CvB,cA0CyB;AAwL5C;AAAA,EADC,MAAM,QAAQ,EAAE,sBAAsB,KAAK,CAAC;AAAA,GAjO1B,cAkOnB;AAKA;AAAA,EADC,MAAM,OAAO;AAAA,GAtOK,cAuOnB;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -1,51 +1,33 @@
|
|
|
1
1
|
import {
|
|
2
2
|
input_styles_default
|
|
3
|
-
} from "./chunk.
|
|
3
|
+
} from "./chunk.OXUFFH57.js";
|
|
4
4
|
import {
|
|
5
|
-
|
|
6
|
-
} from "./chunk.
|
|
5
|
+
defaultValue
|
|
6
|
+
} from "./chunk.WFAJR3FN.js";
|
|
7
7
|
import {
|
|
8
8
|
LocalizeController
|
|
9
9
|
} from "./chunk.R6VNLE6N.js";
|
|
10
|
+
import {
|
|
11
|
+
HasSlotController
|
|
12
|
+
} from "./chunk.XGXFE6IF.js";
|
|
10
13
|
import {
|
|
11
14
|
FormControlController
|
|
12
|
-
} from "./chunk.
|
|
15
|
+
} from "./chunk.P2LNG2PZ.js";
|
|
16
|
+
import {
|
|
17
|
+
SynIcon
|
|
18
|
+
} from "./chunk.SUJGOV4C.js";
|
|
13
19
|
import {
|
|
14
|
-
SynIcon,
|
|
15
20
|
watch
|
|
16
|
-
} from "./chunk.
|
|
21
|
+
} from "./chunk.VZ7S7YYN.js";
|
|
17
22
|
import {
|
|
18
23
|
SynergyElement
|
|
19
|
-
} from "./chunk.
|
|
24
|
+
} from "./chunk.ZUNBGZ5R.js";
|
|
20
25
|
import {
|
|
21
26
|
__decorateClass
|
|
22
27
|
} from "./chunk.DJOAQ4JU.js";
|
|
23
28
|
|
|
24
29
|
// src/components/input/input.component.ts
|
|
25
30
|
import { classMap } from "lit/directives/class-map.js";
|
|
26
|
-
|
|
27
|
-
// src/internal/default-value.ts
|
|
28
|
-
import { defaultConverter } from "lit";
|
|
29
|
-
var defaultValue = (propertyName = "value") => (proto, key) => {
|
|
30
|
-
const ctor = proto.constructor;
|
|
31
|
-
const attributeChangedCallback = ctor.prototype.attributeChangedCallback;
|
|
32
|
-
ctor.prototype.attributeChangedCallback = function(name, old, value) {
|
|
33
|
-
var _a;
|
|
34
|
-
const options = ctor.getPropertyOptions(propertyName);
|
|
35
|
-
const attributeName = typeof options.attribute === "string" ? options.attribute : propertyName;
|
|
36
|
-
if (name === attributeName) {
|
|
37
|
-
const converter = options.converter || defaultConverter;
|
|
38
|
-
const fromAttribute = typeof converter === "function" ? converter : (_a = converter == null ? void 0 : converter.fromAttribute) != null ? _a : defaultConverter.fromAttribute;
|
|
39
|
-
const newValue = fromAttribute(value, options.type);
|
|
40
|
-
if (this[propertyName] !== newValue) {
|
|
41
|
-
this[key] = newValue;
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
attributeChangedCallback.call(this, name, old, value);
|
|
45
|
-
};
|
|
46
|
-
};
|
|
47
|
-
|
|
48
|
-
// src/components/input/input.component.ts
|
|
49
31
|
import { html } from "lit";
|
|
50
32
|
import { ifDefined } from "lit/directives/if-defined.js";
|
|
51
33
|
import { live } from "lit/directives/live.js";
|
|
@@ -495,4 +477,4 @@ __decorateClass([
|
|
|
495
477
|
export {
|
|
496
478
|
SynInput
|
|
497
479
|
};
|
|
498
|
-
//# sourceMappingURL=chunk.
|
|
480
|
+
//# sourceMappingURL=chunk.QUUM6GP4.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["../../src/components/input/input.component.ts"
|
|
4
|
-
"sourcesContent": ["// ---------------------------------------------------------------------\n// \uD83D\uDD12 AUTOGENERATED BY VENDORISM\n// Removing this comment will prevent it from being managed by it.\n// ---------------------------------------------------------------------\n\n/* eslint-disable */\nimport { classMap } from 'lit/directives/class-map.js';\nimport { defaultValue } from '../../internal/default-value.js';\nimport { FormControlController } from '../../internal/form.js';\nimport { HasSlotController } from '../../internal/slot.js';\nimport { html } from 'lit';\nimport { ifDefined } from 'lit/directives/if-defined.js';\nimport { live } from 'lit/directives/live.js';\nimport { LocalizeController } from '../../utilities/localize.js';\nimport { property, query, state } from 'lit/decorators.js';\nimport { watch } from '../../internal/watch.js';\nimport SynergyElement from '../../internal/synergy-element.js';\nimport SynIcon from '../icon/icon.component.js';\nimport styles from './input.styles.js';\nimport type { CSSResultGroup } from 'lit';\nimport type { SynergyFormControl } from '../../internal/synergy-element.js';\n\n/**\n * @summary Inputs collect data from the user.\n * @documentation https://synergy.style/components/input\n * @status stable\n * @since 2.0\n *\n * @dependency syn-icon\n *\n * @slot label - The input's label. Alternatively, you can use the `label` attribute.\n * @slot prefix - Used to prepend a presentational icon or similar element to the input.\n * @slot suffix - Used to append a presentational icon or similar element to the input.\n * @slot clear-icon - An icon to use in lieu of the default clear icon.\n * @slot show-password-icon - An icon to use in lieu of the default show password icon.\n * @slot hide-password-icon - An icon to use in lieu of the default hide password icon.\n * @slot help-text - Text that describes how to use the input. Alternatively, you can use the `help-text` attribute.\n *\n * @event syn-blur - Emitted when the control loses focus.\n * @event syn-change - Emitted when an alteration to the control's value is committed by the user.\n * @event syn-clear - Emitted when the clear button is activated.\n * @event syn-focus - Emitted when the control gains focus.\n * @event syn-input - Emitted when the control receives input.\n * @event syn-invalid - Emitted when the form control has been checked for validity and its constraints aren't satisfied.\n *\n * @csspart form-control - The form control that wraps the label, input, and help text.\n * @csspart form-control-label - The label's wrapper.\n * @csspart form-control-input - The input's wrapper.\n * @csspart form-control-help-text - The help text's wrapper.\n * @csspart base - The component's base wrapper.\n * @csspart input - The internal `<input>` control.\n * @csspart prefix - The container that wraps the prefix.\n * @csspart clear-button - The clear button.\n * @csspart password-toggle-button - The password toggle button.\n * @csspart suffix - The container that wraps the suffix.\n */\nexport default class SynInput extends SynergyElement implements SynergyFormControl {\n static styles: CSSResultGroup = styles;\n static dependencies = { 'syn-icon': SynIcon };\n\n private readonly formControlController = new FormControlController(this, {\n assumeInteractionOn: ['syn-blur', 'syn-input']\n });\n private readonly hasSlotController = new HasSlotController(this, 'help-text', 'label', 'prefix', 'suffix');\n private readonly localize = new LocalizeController(this);\n\n @query('.input__control') input: HTMLInputElement;\n\n @state() private hasFocus = false;\n @property() title = ''; // make reactive to pass through\n\n private __numberInput = Object.assign(document.createElement('input'), { type: 'number' });\n private __dateInput = Object.assign(document.createElement('input'), { type: 'date' });\n\n /**\n * The type of input. Works the same as a native `<input>` element, but only a subset of types are supported. Defaults\n * to `text`.\n */\n @property({ reflect: true }) type:\n | 'date'\n | 'datetime-local'\n | 'email'\n | 'number'\n | 'password'\n | 'search'\n | 'tel'\n | 'text'\n | 'time'\n | 'url' = 'text';\n\n /** The name of the input, submitted as a name/value pair with form data. */\n @property() name = '';\n\n /** The current value of the input, submitted as a name/value pair with form data. */\n @property() value = '';\n\n /** The default value of the form control. Primarily used for resetting the form control. */\n @defaultValue() defaultValue = '';\n\n /** The input's size. */\n @property({ reflect: true }) size: 'small' | 'medium' | 'large' = 'medium';\n\n /** The input's label. If you need to display HTML, use the `label` slot instead. */\n @property() label = '';\n\n /** The input's help text. If you need to display HTML, use the `help-text` slot instead. */\n @property({ attribute: 'help-text' }) helpText = '';\n\n /** Adds a clear button when the input is not empty. */\n @property({ type: Boolean }) clearable = false;\n\n /** Disables the input. */\n @property({ type: Boolean, reflect: true }) disabled = false;\n\n /** Placeholder text to show as a hint when the input is empty. */\n @property() placeholder = '';\n\n /** Makes the input readonly. */\n @property({ type: Boolean, reflect: true }) readonly = false;\n\n /** Adds a button to toggle the password's visibility. Only applies to password types. */\n @property({ attribute: 'password-toggle', type: Boolean }) passwordToggle = false;\n\n /** Determines whether or not the password is currently visible. Only applies to password input types. */\n @property({ attribute: 'password-visible', type: Boolean }) passwordVisible = false;\n\n /** Hides the browser's built-in increment/decrement spin buttons for number inputs. */\n @property({ attribute: 'no-spin-buttons', type: Boolean }) noSpinButtons = false;\n\n /**\n * By default, form controls are associated with the nearest containing `<form>` element. This attribute allows you\n * to place the form control outside of a form and associate it with the form that has this `id`. The form must be in\n * the same document or shadow root for this to work.\n */\n @property({ reflect: true }) form = '';\n\n /** Makes the input a required field. */\n @property({ type: Boolean, reflect: true }) required = false;\n\n /** A regular expression pattern to validate input against. */\n @property() pattern: string;\n\n /** The minimum length of input that will be considered valid. */\n @property({ type: Number }) minlength: number;\n\n /** The maximum length of input that will be considered valid. */\n @property({ type: Number }) maxlength: number;\n\n /** The input's minimum value. Only applies to date and number input types. */\n @property() min: number | string;\n\n /** The input's maximum value. Only applies to date and number input types. */\n @property() max: number | string;\n\n /**\n * Specifies the granularity that the value must adhere to, or the special value `any` which means no stepping is\n * implied, allowing any numeric value. Only applies to date and number input types.\n */\n @property() step: number | 'any';\n\n /** Controls whether and how text input is automatically capitalized as it is entered by the user. */\n @property() autocapitalize: 'off' | 'none' | 'on' | 'sentences' | 'words' | 'characters';\n\n /** Indicates whether the browser's autocorrect feature is on or off. */\n @property() autocorrect: 'off' | 'on';\n\n /**\n * Specifies what permission the browser has to provide assistance in filling out form field values. Refer to\n * [this page on MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/autocomplete) for available values.\n */\n @property() autocomplete: string;\n\n /** Indicates that the input should receive focus on page load. */\n @property({ type: Boolean }) autofocus: boolean;\n\n /** Used to customize the label or icon of the Enter key on virtual keyboards. */\n @property() enterkeyhint: 'enter' | 'done' | 'go' | 'next' | 'previous' | 'search' | 'send';\n\n /** Enables spell checking on the input. */\n @property({\n type: Boolean,\n converter: {\n // Allow \"true|false\" attribute values but keep the property boolean\n fromAttribute: value => (!value || value === 'false' ? false : true),\n toAttribute: value => (value ? 'true' : 'false')\n }\n })\n spellcheck = true;\n\n /**\n * Tells the browser what type of data will be entered by the user, allowing it to display the appropriate virtual\n * keyboard on supportive devices.\n */\n @property() inputmode: 'none' | 'text' | 'decimal' | 'numeric' | 'tel' | 'search' | 'email' | 'url';\n\n //\n // NOTE: We use an in-memory input for these getters/setters instead of the one in the template because the properties\n // can be set before the component is rendered.\n //\n\n /**\n * Gets or sets the current value as a `Date` object. Returns `null` if the value can't be converted. This will use the native `<input type=\"{{type}}\">` implementation and may result in an error.\n */\n get valueAsDate() {\n this.__dateInput.type = this.type;\n this.__dateInput.value = this.value;\n return this.input?.valueAsDate || this.__dateInput.valueAsDate;\n }\n\n set valueAsDate(newValue: Date | null) {\n this.__dateInput.type = this.type;\n this.__dateInput.valueAsDate = newValue;\n this.value = this.__dateInput.value;\n }\n\n /** Gets or sets the current value as a number. Returns `NaN` if the value can't be converted. */\n get valueAsNumber() {\n this.__numberInput.value = this.value;\n return this.input?.valueAsNumber || this.__numberInput.valueAsNumber;\n }\n\n set valueAsNumber(newValue: number) {\n this.__numberInput.valueAsNumber = newValue;\n this.value = this.__numberInput.value;\n }\n\n /** Gets the validity state object */\n get validity() {\n return this.input.validity;\n }\n\n /** Gets the validation message */\n get validationMessage() {\n return this.input.validationMessage;\n }\n\n firstUpdated() {\n this.formControlController.updateValidity();\n }\n\n private handleBlur() {\n this.hasFocus = false;\n this.emit('syn-blur');\n }\n\n private handleChange() {\n this.value = this.input.value;\n this.emit('syn-change');\n }\n\n private handleClearClick(event: MouseEvent) {\n this.value = '';\n this.emit('syn-clear');\n this.emit('syn-input');\n this.emit('syn-change');\n this.input.focus();\n\n event.stopPropagation();\n }\n\n private handleFocus() {\n this.hasFocus = true;\n this.emit('syn-focus');\n }\n\n private handleInput() {\n this.value = this.input.value;\n this.formControlController.updateValidity();\n this.emit('syn-input');\n }\n\n private handleInvalid(event: Event) {\n this.formControlController.setValidity(false);\n this.formControlController.emitInvalidEvent(event);\n }\n\n private handleKeyDown(event: KeyboardEvent) {\n const hasModifier = event.metaKey || event.ctrlKey || event.shiftKey || event.altKey;\n\n // Pressing enter when focused on an input should submit the form like a native input, but we wait a tick before\n // submitting to allow users to cancel the keydown event if they need to\n if (event.key === 'Enter' && !hasModifier) {\n setTimeout(() => {\n //\n // When using an Input Method Editor (IME), pressing enter will cause the form to submit unexpectedly. One way\n // to check for this is to look at event.isComposing, which will be true when the IME is open.\n //\n // See https://github.com/synergy-design-system/synergy/pull/988\n //\n if (!event.defaultPrevented && !event.isComposing) {\n this.formControlController.submit();\n }\n });\n }\n }\n\n private handlePasswordToggle() {\n this.passwordVisible = !this.passwordVisible;\n }\n\n @watch('disabled', { waitUntilFirstUpdate: true })\n handleDisabledChange() {\n // Disabled form controls are always valid\n this.formControlController.setValidity(this.disabled);\n }\n\n @watch('step', { waitUntilFirstUpdate: true })\n handleStepChange() {\n // If step changes, the value may become invalid so we need to recheck after the update. We set the new step\n // imperatively so we don't have to wait for the next render to report the updated validity.\n this.input.step = String(this.step);\n this.formControlController.updateValidity();\n }\n\n @watch('value', { waitUntilFirstUpdate: true })\n async handleValueChange() {\n await this.updateComplete;\n this.formControlController.updateValidity();\n }\n\n /** Sets focus on the input. */\n focus(options?: FocusOptions) {\n this.input.focus(options);\n }\n\n /** Removes focus from the input. */\n blur() {\n this.input.blur();\n }\n\n /** Selects all the text in the input. */\n select() {\n this.input.select();\n }\n\n /** Sets the start and end positions of the text selection (0-based). */\n setSelectionRange(\n selectionStart: number,\n selectionEnd: number,\n selectionDirection: 'forward' | 'backward' | 'none' = 'none'\n ) {\n this.input.setSelectionRange(selectionStart, selectionEnd, selectionDirection);\n }\n\n /** Replaces a range of text with a new string. */\n setRangeText(\n replacement: string,\n start?: number,\n end?: number,\n selectMode?: 'select' | 'start' | 'end' | 'preserve'\n ) {\n // @ts-expect-error - start, end, and selectMode are optional\n this.input.setRangeText(replacement, start, end, selectMode);\n\n if (this.value !== this.input.value) {\n this.value = this.input.value;\n }\n }\n\n /** Displays the browser picker for an input element (only works if the browser supports it for the input type). */\n showPicker() {\n if ('showPicker' in HTMLInputElement.prototype) {\n this.input.showPicker();\n }\n }\n\n /** Increments the value of a numeric input type by the value of the step attribute. */\n stepUp() {\n this.input.stepUp();\n if (this.value !== this.input.value) {\n this.value = this.input.value;\n }\n }\n\n /** Decrements the value of a numeric input type by the value of the step attribute. */\n stepDown() {\n this.input.stepDown();\n if (this.value !== this.input.value) {\n this.value = this.input.value;\n }\n }\n\n /** Checks for validity but does not show a validation message. Returns `true` when valid and `false` when invalid. */\n checkValidity() {\n return this.input.checkValidity();\n }\n\n /** Gets the associated form, if one exists. */\n getForm(): HTMLFormElement | null {\n return this.formControlController.getForm();\n }\n\n /** Checks for validity and shows the browser's validation message if the control is invalid. */\n reportValidity() {\n return this.input.reportValidity();\n }\n\n /** Sets a custom validation message. Pass an empty string to restore validity. */\n setCustomValidity(message: string) {\n this.input.setCustomValidity(message);\n this.formControlController.updateValidity();\n }\n\n render() {\n const hasLabelSlot = this.hasSlotController.test('label');\n const hasHelpTextSlot = this.hasSlotController.test('help-text');\n const hasPrefixSlot = this.hasSlotController.test('prefix');\n const hasSuffixSlot = this.hasSlotController.test('suffix');\n const hasLabel = this.label ? true : !!hasLabelSlot;\n const hasHelpText = this.helpText ? true : !!hasHelpTextSlot;\n const hasClearIcon = this.clearable && !this.disabled && !this.readonly;\n const isClearIconVisible = hasClearIcon && (typeof this.value === 'number' || this.value.length > 0);\n\n return html`\n <div\n part=\"form-control\"\n class=${classMap({\n 'form-control': true,\n 'form-control--small': this.size === 'small',\n 'form-control--medium': this.size === 'medium',\n 'form-control--large': this.size === 'large',\n 'form-control--has-label': hasLabel,\n 'form-control--has-help-text': hasHelpText,\n 'form-control--has-prefix': hasPrefixSlot,\n 'form-control--has-suffix': hasSuffixSlot\n })}\n >\n <label\n part=\"form-control-label\"\n class=\"form-control__label\"\n for=\"input\"\n aria-hidden=${hasLabel ? 'false' : 'true'}\n >\n <slot name=\"label\">${this.label}</slot>\n </label>\n\n <div part=\"form-control-input\" class=\"form-control-input\">\n <div\n part=\"base\"\n class=${classMap({\n input: true,\n\n // Sizes\n 'input--small': this.size === 'small',\n 'input--medium': this.size === 'medium',\n 'input--large': this.size === 'large',\n\n // States\n 'input--standard': !this.readonly,\n 'input--readonly': this.readonly,\n 'input--disabled': this.disabled,\n 'input--focused': this.hasFocus,\n 'input--empty': !this.value,\n 'input--no-spin-buttons': this.noSpinButtons\n })}\n >\n <span part=\"prefix\" class=\"input__prefix\">\n <slot name=\"prefix\"></slot>\n </span>\n\n <input\n part=\"input\"\n id=\"input\"\n class=\"input__control\"\n type=${this.type === 'password' && this.passwordVisible ? 'text' : this.type}\n title=${this.title /* An empty title prevents browser validation tooltips from appearing on hover */}\n name=${ifDefined(this.name)}\n ?disabled=${this.disabled}\n ?readonly=${this.readonly}\n ?required=${this.required}\n placeholder=${ifDefined(this.placeholder)}\n minlength=${ifDefined(this.minlength)}\n maxlength=${ifDefined(this.maxlength)}\n min=${ifDefined(this.min)}\n max=${ifDefined(this.max)}\n step=${ifDefined(this.step as number)}\n .value=${live(this.value)}\n autocapitalize=${ifDefined(this.autocapitalize)}\n autocomplete=${ifDefined(this.autocomplete)}\n autocorrect=${ifDefined(this.autocorrect)}\n ?autofocus=${this.autofocus}\n spellcheck=${this.spellcheck}\n pattern=${ifDefined(this.pattern)}\n enterkeyhint=${ifDefined(this.enterkeyhint)}\n inputmode=${ifDefined(this.inputmode)}\n aria-describedby=\"help-text\"\n @change=${this.handleChange}\n @input=${this.handleInput}\n @invalid=${this.handleInvalid}\n @keydown=${this.handleKeyDown}\n @focus=${this.handleFocus}\n @blur=${this.handleBlur}\n />\n\n ${hasClearIcon\n ? html`\n <button\n part=\"clear-button\"\n class=${classMap({\n input__clear: true,\n 'input__clear--visible': isClearIconVisible\n })}\n type=\"button\"\n aria-label=${this.localize.term('clearEntry')}\n @click=${this.handleClearClick}\n tabindex=\"-1\"\n >\n <slot name=\"clear-icon\">\n <syn-icon name=\"x-circle-fill\" library=\"system\"></syn-icon>\n </slot>\n </button>\n `\n : ''}\n ${this.passwordToggle && !this.disabled\n ? html`\n <button\n part=\"password-toggle-button\"\n class=\"input__password-toggle\"\n type=\"button\"\n aria-label=${this.localize.term(this.passwordVisible ? 'hidePassword' : 'showPassword')}\n @click=${this.handlePasswordToggle}\n tabindex=\"-1\"\n >\n ${this.passwordVisible\n ? html`\n <slot name=\"show-password-icon\">\n <syn-icon name=\"eye-slash\" library=\"system\"></syn-icon>\n </slot>\n `\n : html`\n <slot name=\"hide-password-icon\">\n <syn-icon name=\"eye\" library=\"system\"></syn-icon>\n </slot>\n `}\n </button>\n `\n : ''}\n\n <span part=\"suffix\" class=\"input__suffix\">\n <slot name=\"suffix\"></slot>\n </span>\n </div>\n </div>\n\n <div\n part=\"form-control-help-text\"\n id=\"help-text\"\n class=\"form-control__help-text\"\n aria-hidden=${hasHelpText ? 'false' : 'true'}\n >\n <slot name=\"help-text\">${this.helpText}</slot>\n </div>\n </div>\n `;\n }\n}\n", "// ---------------------------------------------------------------------\n// \uD83D\uDD12 AUTOGENERATED BY VENDORISM\n// Removing this comment will prevent it from being managed by it.\n// ---------------------------------------------------------------------\n\n/* eslint-disable */\n// @defaultValue decorator\n//\n// Runs when the corresponding attribute of the observed property changes, e.g. after calling Element.setAttribute or after updating\n// the observed property.\n//\n// The decorator checks whether the value of the attribute is different from the value of the property and in that case\n// it saves the new value.\n//\n//\n// Usage:\n//\n// @property({ type: Boolean, reflect: true }) checked = false;\n//\n// @defaultValue('checked') defaultChecked = false;\n//\n\nimport { defaultConverter } from 'lit';\nimport type { ReactiveElement } from 'lit';\n\nexport const defaultValue =\n (propertyName = 'value') =>\n (proto: ReactiveElement, key: string) => {\n const ctor = proto.constructor as typeof ReactiveElement;\n\n const attributeChangedCallback = ctor.prototype.attributeChangedCallback;\n ctor.prototype.attributeChangedCallback = function (\n this: ReactiveElement & { [name: string]: unknown },\n name,\n old,\n value\n ) {\n const options = ctor.getPropertyOptions(propertyName);\n const attributeName = typeof options.attribute === 'string' ? options.attribute : propertyName;\n\n if (name === attributeName) {\n const converter = options.converter || defaultConverter;\n const fromAttribute =\n typeof converter === 'function' ? converter : converter?.fromAttribute ?? defaultConverter.fromAttribute;\n\n const newValue: unknown = fromAttribute!(value, options.type);\n\n if (this[propertyName] !== newValue) {\n this[key] = newValue;\n }\n }\n\n attributeChangedCallback.call(this, name, old, value);\n };\n };\n"],
|
|
5
|
-
"mappings": "
|
|
3
|
+
"sources": ["../../src/components/input/input.component.ts"],
|
|
4
|
+
"sourcesContent": ["// ---------------------------------------------------------------------\n// \uD83D\uDD12 AUTOGENERATED BY VENDORISM\n// Removing this comment will prevent it from being managed by it.\n// ---------------------------------------------------------------------\n\n/* eslint-disable */\nimport { classMap } from 'lit/directives/class-map.js';\nimport { defaultValue } from '../../internal/default-value.js';\nimport { FormControlController } from '../../internal/form.js';\nimport { HasSlotController } from '../../internal/slot.js';\nimport { html } from 'lit';\nimport { ifDefined } from 'lit/directives/if-defined.js';\nimport { live } from 'lit/directives/live.js';\nimport { LocalizeController } from '../../utilities/localize.js';\nimport { property, query, state } from 'lit/decorators.js';\nimport { watch } from '../../internal/watch.js';\nimport SynergyElement from '../../internal/synergy-element.js';\nimport SynIcon from '../icon/icon.component.js';\nimport styles from './input.styles.js';\nimport type { CSSResultGroup } from 'lit';\nimport type { SynergyFormControl } from '../../internal/synergy-element.js';\n\n/**\n * @summary Inputs collect data from the user.\n * @documentation https://synergy.style/components/input\n * @status stable\n * @since 2.0\n *\n * @dependency syn-icon\n *\n * @slot label - The input's label. Alternatively, you can use the `label` attribute.\n * @slot prefix - Used to prepend a presentational icon or similar element to the input.\n * @slot suffix - Used to append a presentational icon or similar element to the input.\n * @slot clear-icon - An icon to use in lieu of the default clear icon.\n * @slot show-password-icon - An icon to use in lieu of the default show password icon.\n * @slot hide-password-icon - An icon to use in lieu of the default hide password icon.\n * @slot help-text - Text that describes how to use the input. Alternatively, you can use the `help-text` attribute.\n *\n * @event syn-blur - Emitted when the control loses focus.\n * @event syn-change - Emitted when an alteration to the control's value is committed by the user.\n * @event syn-clear - Emitted when the clear button is activated.\n * @event syn-focus - Emitted when the control gains focus.\n * @event syn-input - Emitted when the control receives input.\n * @event syn-invalid - Emitted when the form control has been checked for validity and its constraints aren't satisfied.\n *\n * @csspart form-control - The form control that wraps the label, input, and help text.\n * @csspart form-control-label - The label's wrapper.\n * @csspart form-control-input - The input's wrapper.\n * @csspart form-control-help-text - The help text's wrapper.\n * @csspart base - The component's base wrapper.\n * @csspart input - The internal `<input>` control.\n * @csspart prefix - The container that wraps the prefix.\n * @csspart clear-button - The clear button.\n * @csspart password-toggle-button - The password toggle button.\n * @csspart suffix - The container that wraps the suffix.\n */\nexport default class SynInput extends SynergyElement implements SynergyFormControl {\n static styles: CSSResultGroup = styles;\n static dependencies = { 'syn-icon': SynIcon };\n\n private readonly formControlController = new FormControlController(this, {\n assumeInteractionOn: ['syn-blur', 'syn-input']\n });\n private readonly hasSlotController = new HasSlotController(this, 'help-text', 'label', 'prefix', 'suffix');\n private readonly localize = new LocalizeController(this);\n\n @query('.input__control') input: HTMLInputElement;\n\n @state() private hasFocus = false;\n @property() title = ''; // make reactive to pass through\n\n private __numberInput = Object.assign(document.createElement('input'), { type: 'number' });\n private __dateInput = Object.assign(document.createElement('input'), { type: 'date' });\n\n /**\n * The type of input. Works the same as a native `<input>` element, but only a subset of types are supported. Defaults\n * to `text`.\n */\n @property({ reflect: true }) type:\n | 'date'\n | 'datetime-local'\n | 'email'\n | 'number'\n | 'password'\n | 'search'\n | 'tel'\n | 'text'\n | 'time'\n | 'url' = 'text';\n\n /** The name of the input, submitted as a name/value pair with form data. */\n @property() name = '';\n\n /** The current value of the input, submitted as a name/value pair with form data. */\n @property() value = '';\n\n /** The default value of the form control. Primarily used for resetting the form control. */\n @defaultValue() defaultValue = '';\n\n /** The input's size. */\n @property({ reflect: true }) size: 'small' | 'medium' | 'large' = 'medium';\n\n /** The input's label. If you need to display HTML, use the `label` slot instead. */\n @property() label = '';\n\n /** The input's help text. If you need to display HTML, use the `help-text` slot instead. */\n @property({ attribute: 'help-text' }) helpText = '';\n\n /** Adds a clear button when the input is not empty. */\n @property({ type: Boolean }) clearable = false;\n\n /** Disables the input. */\n @property({ type: Boolean, reflect: true }) disabled = false;\n\n /** Placeholder text to show as a hint when the input is empty. */\n @property() placeholder = '';\n\n /** Makes the input readonly. */\n @property({ type: Boolean, reflect: true }) readonly = false;\n\n /** Adds a button to toggle the password's visibility. Only applies to password types. */\n @property({ attribute: 'password-toggle', type: Boolean }) passwordToggle = false;\n\n /** Determines whether or not the password is currently visible. Only applies to password input types. */\n @property({ attribute: 'password-visible', type: Boolean }) passwordVisible = false;\n\n /** Hides the browser's built-in increment/decrement spin buttons for number inputs. */\n @property({ attribute: 'no-spin-buttons', type: Boolean }) noSpinButtons = false;\n\n /**\n * By default, form controls are associated with the nearest containing `<form>` element. This attribute allows you\n * to place the form control outside of a form and associate it with the form that has this `id`. The form must be in\n * the same document or shadow root for this to work.\n */\n @property({ reflect: true }) form = '';\n\n /** Makes the input a required field. */\n @property({ type: Boolean, reflect: true }) required = false;\n\n /** A regular expression pattern to validate input against. */\n @property() pattern: string;\n\n /** The minimum length of input that will be considered valid. */\n @property({ type: Number }) minlength: number;\n\n /** The maximum length of input that will be considered valid. */\n @property({ type: Number }) maxlength: number;\n\n /** The input's minimum value. Only applies to date and number input types. */\n @property() min: number | string;\n\n /** The input's maximum value. Only applies to date and number input types. */\n @property() max: number | string;\n\n /**\n * Specifies the granularity that the value must adhere to, or the special value `any` which means no stepping is\n * implied, allowing any numeric value. Only applies to date and number input types.\n */\n @property() step: number | 'any';\n\n /** Controls whether and how text input is automatically capitalized as it is entered by the user. */\n @property() autocapitalize: 'off' | 'none' | 'on' | 'sentences' | 'words' | 'characters';\n\n /** Indicates whether the browser's autocorrect feature is on or off. */\n @property() autocorrect: 'off' | 'on';\n\n /**\n * Specifies what permission the browser has to provide assistance in filling out form field values. Refer to\n * [this page on MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/autocomplete) for available values.\n */\n @property() autocomplete: string;\n\n /** Indicates that the input should receive focus on page load. */\n @property({ type: Boolean }) autofocus: boolean;\n\n /** Used to customize the label or icon of the Enter key on virtual keyboards. */\n @property() enterkeyhint: 'enter' | 'done' | 'go' | 'next' | 'previous' | 'search' | 'send';\n\n /** Enables spell checking on the input. */\n @property({\n type: Boolean,\n converter: {\n // Allow \"true|false\" attribute values but keep the property boolean\n fromAttribute: value => (!value || value === 'false' ? false : true),\n toAttribute: value => (value ? 'true' : 'false')\n }\n })\n spellcheck = true;\n\n /**\n * Tells the browser what type of data will be entered by the user, allowing it to display the appropriate virtual\n * keyboard on supportive devices.\n */\n @property() inputmode: 'none' | 'text' | 'decimal' | 'numeric' | 'tel' | 'search' | 'email' | 'url';\n\n //\n // NOTE: We use an in-memory input for these getters/setters instead of the one in the template because the properties\n // can be set before the component is rendered.\n //\n\n /**\n * Gets or sets the current value as a `Date` object. Returns `null` if the value can't be converted. This will use the native `<input type=\"{{type}}\">` implementation and may result in an error.\n */\n get valueAsDate() {\n this.__dateInput.type = this.type;\n this.__dateInput.value = this.value;\n return this.input?.valueAsDate || this.__dateInput.valueAsDate;\n }\n\n set valueAsDate(newValue: Date | null) {\n this.__dateInput.type = this.type;\n this.__dateInput.valueAsDate = newValue;\n this.value = this.__dateInput.value;\n }\n\n /** Gets or sets the current value as a number. Returns `NaN` if the value can't be converted. */\n get valueAsNumber() {\n this.__numberInput.value = this.value;\n return this.input?.valueAsNumber || this.__numberInput.valueAsNumber;\n }\n\n set valueAsNumber(newValue: number) {\n this.__numberInput.valueAsNumber = newValue;\n this.value = this.__numberInput.value;\n }\n\n /** Gets the validity state object */\n get validity() {\n return this.input.validity;\n }\n\n /** Gets the validation message */\n get validationMessage() {\n return this.input.validationMessage;\n }\n\n firstUpdated() {\n this.formControlController.updateValidity();\n }\n\n private handleBlur() {\n this.hasFocus = false;\n this.emit('syn-blur');\n }\n\n private handleChange() {\n this.value = this.input.value;\n this.emit('syn-change');\n }\n\n private handleClearClick(event: MouseEvent) {\n this.value = '';\n this.emit('syn-clear');\n this.emit('syn-input');\n this.emit('syn-change');\n this.input.focus();\n\n event.stopPropagation();\n }\n\n private handleFocus() {\n this.hasFocus = true;\n this.emit('syn-focus');\n }\n\n private handleInput() {\n this.value = this.input.value;\n this.formControlController.updateValidity();\n this.emit('syn-input');\n }\n\n private handleInvalid(event: Event) {\n this.formControlController.setValidity(false);\n this.formControlController.emitInvalidEvent(event);\n }\n\n private handleKeyDown(event: KeyboardEvent) {\n const hasModifier = event.metaKey || event.ctrlKey || event.shiftKey || event.altKey;\n\n // Pressing enter when focused on an input should submit the form like a native input, but we wait a tick before\n // submitting to allow users to cancel the keydown event if they need to\n if (event.key === 'Enter' && !hasModifier) {\n setTimeout(() => {\n //\n // When using an Input Method Editor (IME), pressing enter will cause the form to submit unexpectedly. One way\n // to check for this is to look at event.isComposing, which will be true when the IME is open.\n //\n // See https://github.com/synergy-design-system/synergy/pull/988\n //\n if (!event.defaultPrevented && !event.isComposing) {\n this.formControlController.submit();\n }\n });\n }\n }\n\n private handlePasswordToggle() {\n this.passwordVisible = !this.passwordVisible;\n }\n\n @watch('disabled', { waitUntilFirstUpdate: true })\n handleDisabledChange() {\n // Disabled form controls are always valid\n this.formControlController.setValidity(this.disabled);\n }\n\n @watch('step', { waitUntilFirstUpdate: true })\n handleStepChange() {\n // If step changes, the value may become invalid so we need to recheck after the update. We set the new step\n // imperatively so we don't have to wait for the next render to report the updated validity.\n this.input.step = String(this.step);\n this.formControlController.updateValidity();\n }\n\n @watch('value', { waitUntilFirstUpdate: true })\n async handleValueChange() {\n await this.updateComplete;\n this.formControlController.updateValidity();\n }\n\n /** Sets focus on the input. */\n focus(options?: FocusOptions) {\n this.input.focus(options);\n }\n\n /** Removes focus from the input. */\n blur() {\n this.input.blur();\n }\n\n /** Selects all the text in the input. */\n select() {\n this.input.select();\n }\n\n /** Sets the start and end positions of the text selection (0-based). */\n setSelectionRange(\n selectionStart: number,\n selectionEnd: number,\n selectionDirection: 'forward' | 'backward' | 'none' = 'none'\n ) {\n this.input.setSelectionRange(selectionStart, selectionEnd, selectionDirection);\n }\n\n /** Replaces a range of text with a new string. */\n setRangeText(\n replacement: string,\n start?: number,\n end?: number,\n selectMode?: 'select' | 'start' | 'end' | 'preserve'\n ) {\n // @ts-expect-error - start, end, and selectMode are optional\n this.input.setRangeText(replacement, start, end, selectMode);\n\n if (this.value !== this.input.value) {\n this.value = this.input.value;\n }\n }\n\n /** Displays the browser picker for an input element (only works if the browser supports it for the input type). */\n showPicker() {\n if ('showPicker' in HTMLInputElement.prototype) {\n this.input.showPicker();\n }\n }\n\n /** Increments the value of a numeric input type by the value of the step attribute. */\n stepUp() {\n this.input.stepUp();\n if (this.value !== this.input.value) {\n this.value = this.input.value;\n }\n }\n\n /** Decrements the value of a numeric input type by the value of the step attribute. */\n stepDown() {\n this.input.stepDown();\n if (this.value !== this.input.value) {\n this.value = this.input.value;\n }\n }\n\n /** Checks for validity but does not show a validation message. Returns `true` when valid and `false` when invalid. */\n checkValidity() {\n return this.input.checkValidity();\n }\n\n /** Gets the associated form, if one exists. */\n getForm(): HTMLFormElement | null {\n return this.formControlController.getForm();\n }\n\n /** Checks for validity and shows the browser's validation message if the control is invalid. */\n reportValidity() {\n return this.input.reportValidity();\n }\n\n /** Sets a custom validation message. Pass an empty string to restore validity. */\n setCustomValidity(message: string) {\n this.input.setCustomValidity(message);\n this.formControlController.updateValidity();\n }\n\n render() {\n const hasLabelSlot = this.hasSlotController.test('label');\n const hasHelpTextSlot = this.hasSlotController.test('help-text');\n const hasPrefixSlot = this.hasSlotController.test('prefix');\n const hasSuffixSlot = this.hasSlotController.test('suffix');\n const hasLabel = this.label ? true : !!hasLabelSlot;\n const hasHelpText = this.helpText ? true : !!hasHelpTextSlot;\n const hasClearIcon = this.clearable && !this.disabled && !this.readonly;\n const isClearIconVisible = hasClearIcon && (typeof this.value === 'number' || this.value.length > 0);\n\n return html`\n <div\n part=\"form-control\"\n class=${classMap({\n 'form-control': true,\n 'form-control--small': this.size === 'small',\n 'form-control--medium': this.size === 'medium',\n 'form-control--large': this.size === 'large',\n 'form-control--has-label': hasLabel,\n 'form-control--has-help-text': hasHelpText,\n 'form-control--has-prefix': hasPrefixSlot,\n 'form-control--has-suffix': hasSuffixSlot\n })}\n >\n <label\n part=\"form-control-label\"\n class=\"form-control__label\"\n for=\"input\"\n aria-hidden=${hasLabel ? 'false' : 'true'}\n >\n <slot name=\"label\">${this.label}</slot>\n </label>\n\n <div part=\"form-control-input\" class=\"form-control-input\">\n <div\n part=\"base\"\n class=${classMap({\n input: true,\n\n // Sizes\n 'input--small': this.size === 'small',\n 'input--medium': this.size === 'medium',\n 'input--large': this.size === 'large',\n\n // States\n 'input--standard': !this.readonly,\n 'input--readonly': this.readonly,\n 'input--disabled': this.disabled,\n 'input--focused': this.hasFocus,\n 'input--empty': !this.value,\n 'input--no-spin-buttons': this.noSpinButtons\n })}\n >\n <span part=\"prefix\" class=\"input__prefix\">\n <slot name=\"prefix\"></slot>\n </span>\n\n <input\n part=\"input\"\n id=\"input\"\n class=\"input__control\"\n type=${this.type === 'password' && this.passwordVisible ? 'text' : this.type}\n title=${this.title /* An empty title prevents browser validation tooltips from appearing on hover */}\n name=${ifDefined(this.name)}\n ?disabled=${this.disabled}\n ?readonly=${this.readonly}\n ?required=${this.required}\n placeholder=${ifDefined(this.placeholder)}\n minlength=${ifDefined(this.minlength)}\n maxlength=${ifDefined(this.maxlength)}\n min=${ifDefined(this.min)}\n max=${ifDefined(this.max)}\n step=${ifDefined(this.step as number)}\n .value=${live(this.value)}\n autocapitalize=${ifDefined(this.autocapitalize)}\n autocomplete=${ifDefined(this.autocomplete)}\n autocorrect=${ifDefined(this.autocorrect)}\n ?autofocus=${this.autofocus}\n spellcheck=${this.spellcheck}\n pattern=${ifDefined(this.pattern)}\n enterkeyhint=${ifDefined(this.enterkeyhint)}\n inputmode=${ifDefined(this.inputmode)}\n aria-describedby=\"help-text\"\n @change=${this.handleChange}\n @input=${this.handleInput}\n @invalid=${this.handleInvalid}\n @keydown=${this.handleKeyDown}\n @focus=${this.handleFocus}\n @blur=${this.handleBlur}\n />\n\n ${hasClearIcon\n ? html`\n <button\n part=\"clear-button\"\n class=${classMap({\n input__clear: true,\n 'input__clear--visible': isClearIconVisible\n })}\n type=\"button\"\n aria-label=${this.localize.term('clearEntry')}\n @click=${this.handleClearClick}\n tabindex=\"-1\"\n >\n <slot name=\"clear-icon\">\n <syn-icon name=\"x-circle-fill\" library=\"system\"></syn-icon>\n </slot>\n </button>\n `\n : ''}\n ${this.passwordToggle && !this.disabled\n ? html`\n <button\n part=\"password-toggle-button\"\n class=\"input__password-toggle\"\n type=\"button\"\n aria-label=${this.localize.term(this.passwordVisible ? 'hidePassword' : 'showPassword')}\n @click=${this.handlePasswordToggle}\n tabindex=\"-1\"\n >\n ${this.passwordVisible\n ? html`\n <slot name=\"show-password-icon\">\n <syn-icon name=\"eye-slash\" library=\"system\"></syn-icon>\n </slot>\n `\n : html`\n <slot name=\"hide-password-icon\">\n <syn-icon name=\"eye\" library=\"system\"></syn-icon>\n </slot>\n `}\n </button>\n `\n : ''}\n\n <span part=\"suffix\" class=\"input__suffix\">\n <slot name=\"suffix\"></slot>\n </span>\n </div>\n </div>\n\n <div\n part=\"form-control-help-text\"\n id=\"help-text\"\n class=\"form-control__help-text\"\n aria-hidden=${hasHelpText ? 'false' : 'true'}\n >\n <slot name=\"help-text\">${this.helpText}</slot>\n </div>\n </div>\n `;\n }\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAMA,SAAS,gBAAgB;AAIzB,SAAS,YAAY;AACrB,SAAS,iBAAiB;AAC1B,SAAS,YAAY;AAErB,SAAS,UAAU,OAAO,aAAa;AA0CvC,IAAqB,WAArB,cAAsC,eAA6C;AAAA,EAAnF;AAAA;AAIE,SAAiB,wBAAwB,IA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,eAAe,WAAU,CAAC,SAAS,UAAU,UAAU,QAAQ;AAAA,MAC/D,aAAa,WAAU,QAAQ,SAAS;AAAA,IAC1C;AAAA,EACF,CAAC;AAAA,GAlIkB,SAmInB;AAMY;AAAA,EAAX,SAAS;AAAA,GAzIS,SAyIP;AA4GZ;AAAA,EADC,MAAM,YAAY,EAAE,sBAAsB,KAAK,CAAC;AAAA,GApP9B,SAqPnB;AAMA;AAAA,EADC,MAAM,QAAQ,EAAE,sBAAsB,KAAK,CAAC;AAAA,GA1P1B,SA2PnB;AAQM;AAAA,EADL,MAAM,SAAS,EAAE,sBAAsB,KAAK,CAAC;AAAA,GAlQ3B,SAmQb;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import {
|
|
2
|
+
icon_custom_styles_default
|
|
3
|
+
} from "./chunk.PJO6TM3T.js";
|
|
1
4
|
import {
|
|
2
5
|
component_styles_default
|
|
3
6
|
} from "./chunk.O7USYXBT.js";
|
|
@@ -20,9 +23,11 @@ var icon_styles_default = css`
|
|
|
20
23
|
height: 100%;
|
|
21
24
|
width: 100%;
|
|
22
25
|
}
|
|
26
|
+
|
|
27
|
+
${icon_custom_styles_default}
|
|
23
28
|
`;
|
|
24
29
|
|
|
25
30
|
export {
|
|
26
31
|
icon_styles_default
|
|
27
32
|
};
|
|
28
|
-
//# sourceMappingURL=chunk.
|
|
33
|
+
//# sourceMappingURL=chunk.RSONAU45.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/components/icon/icon.styles.ts"],
|
|
4
|
+
"sourcesContent": ["// ---------------------------------------------------------------------\n// \uD83D\uDD12 AUTOGENERATED BY VENDORISM\n// Removing this comment will prevent it from being managed by it.\n// ---------------------------------------------------------------------\n\n/* eslint-disable */\nimport { css } from 'lit';\nimport customStyles from './icon.custom.styles.js';\nimport componentStyles from '../../styles/component.styles.js';\n\nexport default css`\n\t/* stylelint-disable */\n ${componentStyles}\n\n :host {\n display: inline-block;\n width: 1em;\n height: 1em;\n box-sizing: content-box !important;\n }\n\n svg {\n display: block;\n height: 100%;\n width: 100%;\n }\n\n ${customStyles}\n`;\n\n"],
|
|
5
|
+
"mappings": ";;;;;;;;AAMA,SAAS,WAAW;AAIpB,IAAO,sBAAQ;AAAA;AAAA,IAEX,wBAAe;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAef,0BAAY;AAAA;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -1,51 +1,25 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
} from "./chunk.
|
|
4
|
-
import {
|
|
5
|
-
icon_styles_default
|
|
6
|
-
} from "./chunk.BREU4ILT.js";
|
|
2
|
+
watch
|
|
3
|
+
} from "./chunk.VZ7S7YYN.js";
|
|
7
4
|
import {
|
|
8
5
|
getIconLibrary,
|
|
9
6
|
unwatchIcon,
|
|
10
7
|
watchIcon
|
|
11
|
-
} from "./chunk.
|
|
8
|
+
} from "./chunk.4XAK6MOQ.js";
|
|
12
9
|
import {
|
|
13
|
-
|
|
14
|
-
|
|
10
|
+
icon_styles_default
|
|
11
|
+
} from "./chunk.RSONAU45.js";
|
|
12
|
+
import {
|
|
13
|
+
SynergyElement
|
|
14
|
+
} from "./chunk.ZUNBGZ5R.js";
|
|
15
|
+
import {
|
|
16
|
+
__decorateClass
|
|
15
17
|
} from "./chunk.DJOAQ4JU.js";
|
|
16
18
|
|
|
17
19
|
// src/components/icon/icon.component.ts
|
|
18
20
|
import { html } from "lit";
|
|
19
21
|
import { isTemplateResult } from "lit/directive-helpers.js";
|
|
20
22
|
import { property, state } from "lit/decorators.js";
|
|
21
|
-
|
|
22
|
-
// src/internal/watch.ts
|
|
23
|
-
function watch(propertyName, options) {
|
|
24
|
-
const resolvedOptions = __spreadValues({
|
|
25
|
-
waitUntilFirstUpdate: false
|
|
26
|
-
}, options);
|
|
27
|
-
return (proto, decoratedFnName) => {
|
|
28
|
-
const { update } = proto;
|
|
29
|
-
const watchedProperties = Array.isArray(propertyName) ? propertyName : [propertyName];
|
|
30
|
-
proto.update = function(changedProps) {
|
|
31
|
-
watchedProperties.forEach((property2) => {
|
|
32
|
-
const key = property2;
|
|
33
|
-
if (changedProps.has(key)) {
|
|
34
|
-
const oldValue = changedProps.get(key);
|
|
35
|
-
const newValue = this[key];
|
|
36
|
-
if (oldValue !== newValue) {
|
|
37
|
-
if (!resolvedOptions.waitUntilFirstUpdate || this.hasUpdated) {
|
|
38
|
-
this[decoratedFnName](oldValue, newValue);
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
});
|
|
43
|
-
update.call(this, changedProps);
|
|
44
|
-
};
|
|
45
|
-
};
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
// src/components/icon/icon.component.ts
|
|
49
23
|
var CACHEABLE_ERROR = Symbol();
|
|
50
24
|
var RETRYABLE_ERROR = Symbol();
|
|
51
25
|
var parser;
|
|
@@ -196,7 +170,6 @@ __decorateClass([
|
|
|
196
170
|
], SynIcon.prototype, "setIcon", 1);
|
|
197
171
|
|
|
198
172
|
export {
|
|
199
|
-
watch,
|
|
200
173
|
SynIcon
|
|
201
174
|
};
|
|
202
|
-
//# sourceMappingURL=chunk.
|
|
175
|
+
//# sourceMappingURL=chunk.SUJGOV4C.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["../../src/components/icon/icon.component.ts"
|
|
4
|
-
"sourcesContent": ["// ---------------------------------------------------------------------\n// \uD83D\uDD12 AUTOGENERATED BY VENDORISM\n// Removing this comment will prevent it from being managed by it.\n// ---------------------------------------------------------------------\n\n/* eslint-disable */\nimport { getIconLibrary, type IconLibrary, unwatchIcon, watchIcon } from './library.js';\nimport { html } from 'lit';\nimport { isTemplateResult } from 'lit/directive-helpers.js';\nimport { property, state } from 'lit/decorators.js';\nimport { watch } from '../../internal/watch.js';\nimport SynergyElement from '../../internal/synergy-element.js';\nimport styles from './icon.styles.js';\n\nimport type { CSSResultGroup, HTMLTemplateResult } from 'lit';\n\nconst CACHEABLE_ERROR = Symbol();\nconst RETRYABLE_ERROR = Symbol();\ntype SVGResult = HTMLTemplateResult | SVGSVGElement | typeof RETRYABLE_ERROR | typeof CACHEABLE_ERROR;\n\nlet parser: DOMParser;\nconst iconCache = new Map<string, Promise<SVGResult>>();\n\ninterface IconSource {\n url?: string;\n fromLibrary: boolean;\n}\n\n/**\n * @summary Icons are symbols that can be used to represent various options within an application.\n * @documentation https://synergy.style/components/icon\n * @status stable\n * @since 2.0\n *\n * @event syn-load - Emitted when the icon has loaded. When using `spriteSheet: true` this will not emit.\n * @event syn-error - Emitted when the icon fails to load due to an error. When using `spriteSheet: true` this will not emit.\n *\n * @csspart svg - The internal SVG element.\n * @csspart use - The <use> element generated when using `spriteSheet: true`\n */\nexport default class SynIcon extends SynergyElement {\n static styles: CSSResultGroup = styles;\n\n private initialRender = false;\n\n /** Given a URL, this function returns the resulting SVG element or an appropriate error symbol. */\n private async resolveIcon(url: string, library?: IconLibrary): Promise<SVGResult> {\n let fileData: Response;\n\n if (library?.spriteSheet) {\n return html`<svg part=\"svg\">\n <use part=\"use\" href=\"${url}\"></use>\n </svg>`;\n }\n\n try {\n fileData = await fetch(url, { mode: 'cors' });\n if (!fileData.ok) return fileData.status === 410 ? CACHEABLE_ERROR : RETRYABLE_ERROR;\n } catch {\n return RETRYABLE_ERROR;\n }\n\n try {\n const div = document.createElement('div');\n div.innerHTML = await fileData.text();\n\n const svg = div.firstElementChild;\n if (svg?.tagName?.toLowerCase() !== 'svg') return CACHEABLE_ERROR;\n\n if (!parser) parser = new DOMParser();\n const doc = parser.parseFromString(svg.outerHTML, 'text/html');\n\n const svgEl = doc.body.querySelector('svg');\n if (!svgEl) return CACHEABLE_ERROR;\n\n svgEl.part.add('svg');\n return document.adoptNode(svgEl);\n } catch {\n return CACHEABLE_ERROR;\n }\n }\n\n @state() private svg: SVGElement | HTMLTemplateResult | null = null;\n\n /** The name of the icon to draw. Available names depend on the icon library being used. */\n @property({ reflect: true }) name?: string;\n\n /**\n * An external URL of an SVG file. Be sure you trust the content you are including, as it will be executed as code and\n * can result in XSS attacks.\n */\n @property() src?: string;\n\n /**\n * An alternate description to use for assistive devices. If omitted, the icon will be considered presentational and\n * ignored by assistive devices.\n */\n @property() label = '';\n\n /** The name of a registered custom icon library. */\n @property({ reflect: true }) library = 'default';\n\n connectedCallback() {\n super.connectedCallback();\n watchIcon(this);\n }\n\n firstUpdated() {\n this.initialRender = true;\n this.setIcon();\n }\n\n disconnectedCallback() {\n super.disconnectedCallback();\n unwatchIcon(this);\n }\n\n private getIconSource(): IconSource {\n const library = getIconLibrary(this.library);\n if (this.name && library) {\n return {\n url: library.resolver(this.name),\n fromLibrary: true\n };\n }\n\n return {\n url: this.src,\n fromLibrary: false\n };\n }\n\n @watch('label')\n handleLabelChange() {\n const hasLabel = typeof this.label === 'string' && this.label.length > 0;\n\n if (hasLabel) {\n this.setAttribute('role', 'img');\n this.setAttribute('aria-label', this.label);\n this.removeAttribute('aria-hidden');\n } else {\n this.removeAttribute('role');\n this.removeAttribute('aria-label');\n this.setAttribute('aria-hidden', 'true');\n }\n }\n\n @watch(['name', 'src', 'library'])\n async setIcon() {\n const { url, fromLibrary } = this.getIconSource();\n const library = fromLibrary ? getIconLibrary(this.library) : undefined;\n\n if (!url) {\n this.svg = null;\n return;\n }\n\n let iconResolver = iconCache.get(url);\n if (!iconResolver) {\n iconResolver = this.resolveIcon(url, library);\n iconCache.set(url, iconResolver);\n }\n\n // If we haven't rendered yet, exit early. This avoids unnecessary work due to watching multiple props.\n if (!this.initialRender) {\n return;\n }\n\n const svg = await iconResolver;\n\n if (svg === RETRYABLE_ERROR) {\n iconCache.delete(url);\n }\n\n if (url !== this.getIconSource().url) {\n // If the url has changed while fetching the icon, ignore this request\n return;\n }\n\n if (isTemplateResult(svg)) {\n this.svg = svg;\n return;\n }\n\n switch (svg) {\n case RETRYABLE_ERROR:\n case CACHEABLE_ERROR:\n this.svg = null;\n this.emit('syn-error');\n break;\n default:\n this.svg = svg.cloneNode(true) as SVGElement;\n library?.mutator?.(this.svg);\n this.emit('syn-load');\n }\n }\n\n render() {\n return this.svg;\n }\n}\n"
|
|
5
|
-
"mappings": "
|
|
6
|
-
"names": [
|
|
3
|
+
"sources": ["../../src/components/icon/icon.component.ts"],
|
|
4
|
+
"sourcesContent": ["// ---------------------------------------------------------------------\n// \uD83D\uDD12 AUTOGENERATED BY VENDORISM\n// Removing this comment will prevent it from being managed by it.\n// ---------------------------------------------------------------------\n\n/* eslint-disable */\nimport { getIconLibrary, type IconLibrary, unwatchIcon, watchIcon } from './library.js';\nimport { html } from 'lit';\nimport { isTemplateResult } from 'lit/directive-helpers.js';\nimport { property, state } from 'lit/decorators.js';\nimport { watch } from '../../internal/watch.js';\nimport SynergyElement from '../../internal/synergy-element.js';\nimport styles from './icon.styles.js';\n\nimport type { CSSResultGroup, HTMLTemplateResult } from 'lit';\n\nconst CACHEABLE_ERROR = Symbol();\nconst RETRYABLE_ERROR = Symbol();\ntype SVGResult = HTMLTemplateResult | SVGSVGElement | typeof RETRYABLE_ERROR | typeof CACHEABLE_ERROR;\n\nlet parser: DOMParser;\nconst iconCache = new Map<string, Promise<SVGResult>>();\n\ninterface IconSource {\n url?: string;\n fromLibrary: boolean;\n}\n\n/**\n * @summary Icons are symbols that can be used to represent various options within an application.\n * @documentation https://synergy.style/components/icon\n * @status stable\n * @since 2.0\n *\n * @event syn-load - Emitted when the icon has loaded. When using `spriteSheet: true` this will not emit.\n * @event syn-error - Emitted when the icon fails to load due to an error. When using `spriteSheet: true` this will not emit.\n *\n * @csspart svg - The internal SVG element.\n * @csspart use - The <use> element generated when using `spriteSheet: true`\n */\nexport default class SynIcon extends SynergyElement {\n static styles: CSSResultGroup = styles;\n\n private initialRender = false;\n\n /** Given a URL, this function returns the resulting SVG element or an appropriate error symbol. */\n private async resolveIcon(url: string, library?: IconLibrary): Promise<SVGResult> {\n let fileData: Response;\n\n if (library?.spriteSheet) {\n return html`<svg part=\"svg\">\n <use part=\"use\" href=\"${url}\"></use>\n </svg>`;\n }\n\n try {\n fileData = await fetch(url, { mode: 'cors' });\n if (!fileData.ok) return fileData.status === 410 ? CACHEABLE_ERROR : RETRYABLE_ERROR;\n } catch {\n return RETRYABLE_ERROR;\n }\n\n try {\n const div = document.createElement('div');\n div.innerHTML = await fileData.text();\n\n const svg = div.firstElementChild;\n if (svg?.tagName?.toLowerCase() !== 'svg') return CACHEABLE_ERROR;\n\n if (!parser) parser = new DOMParser();\n const doc = parser.parseFromString(svg.outerHTML, 'text/html');\n\n const svgEl = doc.body.querySelector('svg');\n if (!svgEl) return CACHEABLE_ERROR;\n\n svgEl.part.add('svg');\n return document.adoptNode(svgEl);\n } catch {\n return CACHEABLE_ERROR;\n }\n }\n\n @state() private svg: SVGElement | HTMLTemplateResult | null = null;\n\n /** The name of the icon to draw. Available names depend on the icon library being used. */\n @property({ reflect: true }) name?: string;\n\n /**\n * An external URL of an SVG file. Be sure you trust the content you are including, as it will be executed as code and\n * can result in XSS attacks.\n */\n @property() src?: string;\n\n /**\n * An alternate description to use for assistive devices. If omitted, the icon will be considered presentational and\n * ignored by assistive devices.\n */\n @property() label = '';\n\n /** The name of a registered custom icon library. */\n @property({ reflect: true }) library = 'default';\n\n connectedCallback() {\n super.connectedCallback();\n watchIcon(this);\n }\n\n firstUpdated() {\n this.initialRender = true;\n this.setIcon();\n }\n\n disconnectedCallback() {\n super.disconnectedCallback();\n unwatchIcon(this);\n }\n\n private getIconSource(): IconSource {\n const library = getIconLibrary(this.library);\n if (this.name && library) {\n return {\n url: library.resolver(this.name),\n fromLibrary: true\n };\n }\n\n return {\n url: this.src,\n fromLibrary: false\n };\n }\n\n @watch('label')\n handleLabelChange() {\n const hasLabel = typeof this.label === 'string' && this.label.length > 0;\n\n if (hasLabel) {\n this.setAttribute('role', 'img');\n this.setAttribute('aria-label', this.label);\n this.removeAttribute('aria-hidden');\n } else {\n this.removeAttribute('role');\n this.removeAttribute('aria-label');\n this.setAttribute('aria-hidden', 'true');\n }\n }\n\n @watch(['name', 'src', 'library'])\n async setIcon() {\n const { url, fromLibrary } = this.getIconSource();\n const library = fromLibrary ? getIconLibrary(this.library) : undefined;\n\n if (!url) {\n this.svg = null;\n return;\n }\n\n let iconResolver = iconCache.get(url);\n if (!iconResolver) {\n iconResolver = this.resolveIcon(url, library);\n iconCache.set(url, iconResolver);\n }\n\n // If we haven't rendered yet, exit early. This avoids unnecessary work due to watching multiple props.\n if (!this.initialRender) {\n return;\n }\n\n const svg = await iconResolver;\n\n if (svg === RETRYABLE_ERROR) {\n iconCache.delete(url);\n }\n\n if (url !== this.getIconSource().url) {\n // If the url has changed while fetching the icon, ignore this request\n return;\n }\n\n if (isTemplateResult(svg)) {\n this.svg = svg;\n return;\n }\n\n switch (svg) {\n case RETRYABLE_ERROR:\n case CACHEABLE_ERROR:\n this.svg = null;\n this.emit('syn-error');\n break;\n default:\n this.svg = svg.cloneNode(true) as SVGElement;\n library?.mutator?.(this.svg);\n this.emit('syn-load');\n }\n }\n\n render() {\n return this.svg;\n }\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;AAOA,SAAS,YAAY;AACrB,SAAS,wBAAwB;AACjC,SAAS,UAAU,aAAa;AAOhC,IAAM,kBAAkB,OAAO;AAC/B,IAAM,kBAAkB,OAAO;AAG/B,IAAI;AACJ,IAAM,YAAY,oBAAI,IAAgC;AAmBtD,IAAqB,UAArB,cAAqC,eAAe;AAAA,EAApD;AAAA;AAGE,SAAQ,gBAAgB;AAuCf,SAAQ,MAA8C;AAenD,iBAAQ;AAGS,mBAAU;AAAA;AAAA;AAAA,EAtDvC,MAAc,YAAY,KAAa,SAA2C;AA9CpF;AA+CI,QAAI;AAEJ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AC;AAAA,GA7CR,QA6CU;AAMjB;AAAA,EAAX,SAAS;AAAA,GAnDS,QAmDP;AAMA;AAAA,EAAX,SAAS;AAAA,GAzDS,QAyDP;AAGiB;AAAA,EAA5B,SAAS,EAAE,SAAS,KAAK,CAAC;AAAA,GA5DR,QA4DU;AAiC7B;AAAA,EADC,MAAM,OAAO;AAAA,GA5FK,QA6FnB;AAeM;AAAA,EADL,MAAM,CAAC,QAAQ,OAAO,SAAS,CAAC;AAAA,GA3Gd,QA4Gb;",
|
|
6
|
+
"names": []
|
|
7
7
|
}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import {
|
|
2
|
+
radio_styles_default
|
|
3
|
+
} from "./chunk.JBYBQ5TQ.js";
|
|
4
|
+
import {
|
|
5
|
+
SynIcon
|
|
6
|
+
} from "./chunk.SUJGOV4C.js";
|
|
7
|
+
import {
|
|
8
|
+
watch
|
|
9
|
+
} from "./chunk.VZ7S7YYN.js";
|
|
10
|
+
import {
|
|
11
|
+
SynergyElement
|
|
12
|
+
} from "./chunk.ZUNBGZ5R.js";
|
|
13
|
+
import {
|
|
14
|
+
__decorateClass
|
|
15
|
+
} from "./chunk.DJOAQ4JU.js";
|
|
16
|
+
|
|
17
|
+
// src/components/radio/radio.component.ts
|
|
18
|
+
import { classMap } from "lit/directives/class-map.js";
|
|
19
|
+
import { html } from "lit";
|
|
20
|
+
import { property, state } from "lit/decorators.js";
|
|
21
|
+
var SynRadio = class extends SynergyElement {
|
|
22
|
+
constructor() {
|
|
23
|
+
super();
|
|
24
|
+
this.checked = false;
|
|
25
|
+
this.hasFocus = false;
|
|
26
|
+
this.size = "medium";
|
|
27
|
+
this.disabled = false;
|
|
28
|
+
this.handleBlur = () => {
|
|
29
|
+
this.hasFocus = false;
|
|
30
|
+
this.emit("syn-blur");
|
|
31
|
+
};
|
|
32
|
+
this.handleClick = () => {
|
|
33
|
+
if (!this.disabled) {
|
|
34
|
+
this.checked = true;
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
this.handleFocus = () => {
|
|
38
|
+
this.hasFocus = true;
|
|
39
|
+
this.emit("syn-focus");
|
|
40
|
+
};
|
|
41
|
+
this.addEventListener("blur", this.handleBlur);
|
|
42
|
+
this.addEventListener("click", this.handleClick);
|
|
43
|
+
this.addEventListener("focus", this.handleFocus);
|
|
44
|
+
}
|
|
45
|
+
connectedCallback() {
|
|
46
|
+
super.connectedCallback();
|
|
47
|
+
this.setInitialAttributes();
|
|
48
|
+
}
|
|
49
|
+
setInitialAttributes() {
|
|
50
|
+
this.setAttribute("role", "radio");
|
|
51
|
+
this.setAttribute("tabindex", "-1");
|
|
52
|
+
this.setAttribute("aria-disabled", this.disabled ? "true" : "false");
|
|
53
|
+
}
|
|
54
|
+
handleCheckedChange() {
|
|
55
|
+
this.setAttribute("aria-checked", this.checked ? "true" : "false");
|
|
56
|
+
this.setAttribute("tabindex", this.checked ? "0" : "-1");
|
|
57
|
+
}
|
|
58
|
+
handleDisabledChange() {
|
|
59
|
+
this.setAttribute("aria-disabled", this.disabled ? "true" : "false");
|
|
60
|
+
}
|
|
61
|
+
render() {
|
|
62
|
+
return html`
|
|
63
|
+
<span
|
|
64
|
+
part="base"
|
|
65
|
+
class=${classMap({
|
|
66
|
+
radio: true,
|
|
67
|
+
"radio--checked": this.checked,
|
|
68
|
+
"radio--disabled": this.disabled,
|
|
69
|
+
"radio--focused": this.hasFocus,
|
|
70
|
+
"radio--small": this.size === "small",
|
|
71
|
+
"radio--medium": this.size === "medium",
|
|
72
|
+
"radio--large": this.size === "large"
|
|
73
|
+
})}
|
|
74
|
+
>
|
|
75
|
+
<span part="${`control${this.checked ? " control--checked" : ""}`}" class="radio__control">
|
|
76
|
+
${this.checked ? html` <syn-icon part="checked-icon" class="radio__checked-icon" library="system" name="radio"></syn-icon> ` : ""}
|
|
77
|
+
</span>
|
|
78
|
+
|
|
79
|
+
<slot part="label" class="radio__label"></slot>
|
|
80
|
+
</span>
|
|
81
|
+
`;
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
SynRadio.styles = radio_styles_default;
|
|
85
|
+
SynRadio.dependencies = { "syn-icon": SynIcon };
|
|
86
|
+
__decorateClass([
|
|
87
|
+
state()
|
|
88
|
+
], SynRadio.prototype, "checked", 2);
|
|
89
|
+
__decorateClass([
|
|
90
|
+
state()
|
|
91
|
+
], SynRadio.prototype, "hasFocus", 2);
|
|
92
|
+
__decorateClass([
|
|
93
|
+
property()
|
|
94
|
+
], SynRadio.prototype, "value", 2);
|
|
95
|
+
__decorateClass([
|
|
96
|
+
property({ reflect: true })
|
|
97
|
+
], SynRadio.prototype, "size", 2);
|
|
98
|
+
__decorateClass([
|
|
99
|
+
property({ type: Boolean, reflect: true })
|
|
100
|
+
], SynRadio.prototype, "disabled", 2);
|
|
101
|
+
__decorateClass([
|
|
102
|
+
watch("checked")
|
|
103
|
+
], SynRadio.prototype, "handleCheckedChange", 1);
|
|
104
|
+
__decorateClass([
|
|
105
|
+
watch("disabled", { waitUntilFirstUpdate: true })
|
|
106
|
+
], SynRadio.prototype, "handleDisabledChange", 1);
|
|
107
|
+
|
|
108
|
+
export {
|
|
109
|
+
SynRadio
|
|
110
|
+
};
|
|
111
|
+
//# sourceMappingURL=chunk.V26UAJIM.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/components/radio/radio.component.ts"],
|
|
4
|
+
"sourcesContent": ["// ---------------------------------------------------------------------\n// \uD83D\uDD12 AUTOGENERATED BY VENDORISM\n// Removing this comment will prevent it from being managed by it.\n// ---------------------------------------------------------------------\n\n/* eslint-disable */\nimport { classMap } from 'lit/directives/class-map.js';\nimport { html } from 'lit';\nimport { property, state } from 'lit/decorators.js';\nimport { watch } from '../../internal/watch.js';\nimport SynergyElement from '../../internal/synergy-element.js';\nimport SynIcon from '../icon/icon.component.js';\nimport styles from './radio.styles.js';\nimport type { CSSResultGroup } from 'lit';\n\n/**\n * @summary Radios allow the user to select a single option from a group.\n * @documentation https://synergy.style/components/radio\n * @status stable\n * @since 2.0\n *\n * @dependency syn-icon\n *\n * @slot - The radio's label.\n *\n * @event syn-blur - Emitted when the control loses focus.\n * @event syn-focus - Emitted when the control gains focus.\n *\n * @csspart base - The component's base wrapper.\n * @csspart control - The circular container that wraps the radio's checked state.\n * @csspart control--checked - The radio control when the radio is checked.\n * @csspart checked-icon - The checked icon, an `<syn-icon>` element.\n * @csspart label - The container that wraps the radio's label.\n */\nexport default class SynRadio extends SynergyElement {\n static styles: CSSResultGroup = styles;\n static dependencies = { 'syn-icon': SynIcon };\n\n @state() checked = false;\n @state() protected hasFocus = false;\n\n /** The radio's value. When selected, the radio group will receive this value. */\n @property() value: string;\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, reflect: true }) disabled = false;\n\n constructor() {\n super();\n this.addEventListener('blur', this.handleBlur);\n this.addEventListener('click', this.handleClick);\n this.addEventListener('focus', this.handleFocus);\n }\n\n connectedCallback() {\n super.connectedCallback();\n this.setInitialAttributes();\n }\n\n private handleBlur = () => {\n this.hasFocus = false;\n this.emit('syn-blur');\n };\n\n private handleClick = () => {\n if (!this.disabled) {\n this.checked = true;\n }\n };\n\n private handleFocus = () => {\n this.hasFocus = true;\n this.emit('syn-focus');\n };\n\n private setInitialAttributes() {\n this.setAttribute('role', 'radio');\n this.setAttribute('tabindex', '-1');\n this.setAttribute('aria-disabled', this.disabled ? 'true' : 'false');\n }\n\n @watch('checked')\n handleCheckedChange() {\n this.setAttribute('aria-checked', this.checked ? 'true' : 'false');\n this.setAttribute('tabindex', this.checked ? '0' : '-1');\n }\n\n @watch('disabled', { waitUntilFirstUpdate: true })\n handleDisabledChange() {\n this.setAttribute('aria-disabled', this.disabled ? 'true' : 'false');\n }\n\n render() {\n return html`\n <span\n part=\"base\"\n class=${classMap({\n radio: true,\n 'radio--checked': this.checked,\n 'radio--disabled': this.disabled,\n 'radio--focused': this.hasFocus,\n 'radio--small': this.size === 'small',\n 'radio--medium': this.size === 'medium',\n 'radio--large': this.size === 'large'\n })}\n >\n <span part=\"${`control${this.checked ? ' control--checked' : ''}`}\" class=\"radio__control\">\n ${this.checked\n ? html` <syn-icon part=\"checked-icon\" class=\"radio__checked-icon\" library=\"system\" name=\"radio\"></syn-icon> `\n : ''}\n </span>\n\n <slot part=\"label\" class=\"radio__label\"></slot>\n </span>\n `;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'syn-radio': SynRadio;\n }\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;AAMA,SAAS,gBAAgB;AACzB,SAAS,YAAY;AACrB,SAAS,UAAU,aAAa;AA0BhC,IAAqB,WAArB,cAAsC,eAAe;AAAA,EAmBnD,cAAc;AACZ,UAAM;AAhBC,mBAAU;AACV,SAAU,WAAW;AASD,gBAAqC;AAGtB,oBAAW;AAcvD,SAAQ,aAAa,MAAM;AACzB,WAAK,WAAW;AAChB,WAAK,KAAK,UAAU;AAAA,IACtB;AAEA,SAAQ,cAAc,MAAM;AAC1B,UAAI,CAAC,KAAK,UAAU;AAClB,aAAK,UAAU;AAAA,MACjB;AAAA,IACF;AAEA,SAAQ,cAAc,MAAM;AAC1B,WAAK,WAAW;AAChB,WAAK,KAAK,WAAW;AAAA,IACvB;AAxBE,SAAK,iBAAiB,QAAQ,KAAK,UAAU;AAC7C,SAAK,iBAAiB,SAAS,KAAK,WAAW;AAC/C,SAAK,iBAAiB,SAAS,KAAK,WAAW;AAAA,EACjD;AAAA,EAEA,oBAAoB;AAClB,UAAM,kBAAkB;AACxB,SAAK,qBAAqB;AAAA,EAC5B;AAAA,EAkBQ,uBAAuB;AAC7B,SAAK,aAAa,QAAQ,OAAO;AACjC,SAAK,aAAa,YAAY,IAAI;AAClC,SAAK,aAAa,iBAAiB,KAAK,WAAW,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
import { css } from "lit";
|
|
3
|
+
var radio_custom_styles_default = css`
|
|
4
|
+
|
|
5
|
+
.radio {
|
|
6
|
+
padding: var(--syn-spacing-2x-small) 0;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
:host(:focus-visible) .radio__control {
|
|
10
|
+
outline: var(--syn-focus-ring);
|
|
11
|
+
outline-offset: var(--syn-focus-ring-width);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/* Checked + hover */
|
|
15
|
+
.radio.radio--checked:not(.radio--disabled):hover .radio__control {
|
|
16
|
+
background-color: var(--syn-color-primary-950);
|
|
17
|
+
border-color: var(--syn-color-primary-950);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/* Hover */
|
|
21
|
+
.radio:not(.radio--checked):not(.radio--disabled):hover .radio__control {
|
|
22
|
+
border-color: var(--syn-color-primary-900);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/*
|
|
26
|
+
* Size modifiers
|
|
27
|
+
*/
|
|
28
|
+
|
|
29
|
+
.radio--small {
|
|
30
|
+
--toggle-size: var(--syn-input-font-size-small);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
.radio--medium {
|
|
34
|
+
--toggle-size: var(--syn-font-size-medium);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
.radio--large {
|
|
38
|
+
--toggle-size: var(--syn-spacing-large);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
.radio--small .radio__label, .radio--large .radio__label {
|
|
42
|
+
margin-inline-start: var(--syn-spacing-x-small);
|
|
43
|
+
}
|
|
44
|
+
`;
|
|
45
|
+
|
|
46
|
+
export {
|
|
47
|
+
radio_custom_styles_default
|
|
48
|
+
};
|
|
49
|
+
//# sourceMappingURL=chunk.V6VND4OF.js.map
|