diff --git a/packages/components/src/components/@deprecated/input/controller.ts b/packages/components/src/components/@deprecated/input/controller.ts index 393a1ed15d..272b5d10dc 100644 --- a/packages/components/src/components/@deprecated/input/controller.ts +++ b/packages/components/src/components/@deprecated/input/controller.ts @@ -1,12 +1,14 @@ import type { Generic } from 'adopted-style-sheets'; import type { + AccessKeyPropType, AdjustHeightPropType, ButtonProps, HideErrorPropType, InputTypeOnDefault, LabelWithExpertSlotPropType, MsgPropType, + ShortKeyPropType, StencilUnknown, Stringified, TooltipAlignPropType, @@ -18,6 +20,7 @@ import { objectObjectHandler, parseJson, setState, + validateAccessKey, validateAdjustHeight, validateHideError, validateHideLabel, @@ -27,6 +30,7 @@ import { validateTooltipAlign, watchBoolean, watchString, + validateShortKey, } from '../../../schema'; import { stopPropagation, tryToDispatchKoliBriEvent } from '../../../utils/events'; @@ -34,6 +38,7 @@ import { ControlledInputController } from '../../input-adapter-leanup/controller import type { Props as AdapterProps } from '../../input-adapter-leanup/types'; import type { Props, Watches } from './types'; +import { validateAccessAndShortKey } from '../../../schema/validators/access-and-short-key'; type ValueChangeListener = (value: StencilUnknown) => void; @@ -47,8 +52,9 @@ export class InputController extends ControlledInputController implements Watche this.component = component; } - public validateAccessKey(value?: string): void { - watchString(this.component, '_accessKey', value); + public validateAccessKey(value?: AccessKeyPropType): void { + validateAccessKey(this.component, value); + validateAccessAndShortKey(value, this.component._shortKey); } public validateAdjustHeight(value?: AdjustHeightPropType): void { @@ -127,6 +133,11 @@ export class InputController extends ControlledInputController implements Watche } } + public validateShortKey(value?: ShortKeyPropType): void { + validateShortKey(this.component, value); + validateAccessAndShortKey(this.component._accessKey, value); + } + public validateSmartButton(value?: ButtonProps | string): void { objectObjectHandler(value, () => { try { @@ -155,9 +166,11 @@ export class InputController extends ControlledInputController implements Watche this.validateHint(this.component._hint); this.validateId(this.component._id); this.validateLabel(this.component._label); + this.validateShortKey(this.component._shortKey); this.validateSmartButton(this.component._smartButton); this.validateOn(this.component._on); this.validateTabIndex(this.component._tabIndex); + validateAccessAndShortKey(this.component._accessKey, this.component._shortKey); } protected onBlur(event: Event): void { diff --git a/packages/components/src/components/@deprecated/input/types.ts b/packages/components/src/components/@deprecated/input/types.ts index a0d69b2cef..a877e7ab11 100644 --- a/packages/components/src/components/@deprecated/input/types.ts +++ b/packages/components/src/components/@deprecated/input/types.ts @@ -1,9 +1,9 @@ -import type { ButtonProps, InputTypeOnDefault, MsgPropType, PropLabelWithExpertSlot, Stringified } from '../../../schema'; +import type { AccessKeyPropType, ButtonProps, InputTypeOnDefault, MsgPropType, PropLabelWithExpertSlot, ShortKeyPropType, Stringified } from '../../../schema'; import type { Generic } from 'adopted-style-sheets'; type RequiredProps = NonNullable; type OptionalProps = PropLabelWithExpertSlot & { - accessKey: string; + accessKey: AccessKeyPropType; adjustHeight: boolean; disabled: boolean; error: string; @@ -13,6 +13,7 @@ type OptionalProps = PropLabelWithExpertSlot & { id: string; msg: MsgPropType; on: InputTypeOnDefault; + shortKey: ShortKeyPropType; smartButton: Stringified; syncValueBySelector: string; tabIndex: number; diff --git a/packages/components/src/components/button-link/shadow.tsx b/packages/components/src/components/button-link/shadow.tsx index 821babaec7..ab7e35d598 100644 --- a/packages/components/src/components/button-link/shadow.tsx +++ b/packages/components/src/components/button-link/shadow.tsx @@ -10,6 +10,7 @@ import type { IdPropType, LabelWithExpertSlotPropType, NamePropType, + ShortKeyPropType, StencilUnknown, Stringified, SyncValueBySelectorPropType, @@ -72,6 +73,7 @@ export class KolButtonLink implements ButtonLinkProps, FocusableElement { _name={this._name} _on={this._on} _role="link" + _shortKey={this._shortKey} _syncValueBySelector={this._syncValueBySelector} _tabIndex={this._tabIndex} _tooltipAlign={this._tooltipAlign} @@ -154,6 +156,11 @@ export class KolButtonLink implements ButtonLinkProps, FocusableElement { */ @Prop() public _role?: AlternativeButtonLinkRolePropType; + /** + * Adds a visual short key hint to the component. + */ + @Prop() public _shortKey?: ShortKeyPropType; + /** * Selector for synchronizing the value with another input element. * @internal diff --git a/packages/components/src/components/button/component.tsx b/packages/components/src/components/button/component.tsx index 1bc2d5d9cf..2a0b68393c 100644 --- a/packages/components/src/components/button/component.tsx +++ b/packages/components/src/components/button/component.tsx @@ -12,6 +12,7 @@ import type { FocusableElement, IconsPropType, LabelWithExpertSlotPropType, + ShortKeyPropType, StencilUnknown, Stringified, SyncValueBySelectorPropType, @@ -37,6 +38,7 @@ import { validateHideLabel, validateIcons, validateLabelWithExpertSlot, + validateShortKey, validateTabIndex, validateTooltipAlign, watchString, @@ -49,6 +51,7 @@ import { nonce } from '../../utils/dev.utils'; import { propagateResetEventToForm, propagateSubmitEventToForm } from '../form/controller'; import { AssociatedInputController } from '../input-adapter-leanup/associated.controller'; import { KolSpanWcTag, KolTooltipWcTag } from '../../core/component-names'; +import { validateAccessAndShortKey } from '../../schema/validators/access-and-short-key'; /** * @internal @@ -134,7 +137,7 @@ export class KolButtonWc implements ButtonAPI, FocusableElement { >