1- import { css , customElement , html , nothing , property , state } from '@umbraco-cms/backoffice/external/lit' ;
1+ import { css , customElement , html , property , state } from '@umbraco-cms/backoffice/external/lit' ;
2+ import { generateAlias } from '@umbraco-cms/backoffice/utils' ;
23import { UmbChangeEvent } from '@umbraco-cms/backoffice/event' ;
34import { UmbFormControlMixin } from '@umbraco-cms/backoffice/validation' ;
45import { UmbLitElement } from '@umbraco-cms/backoffice/lit-element' ;
5- import { type UUIInputElement , UUIInputEvent } from '@umbraco-cms/backoffice/external/uui' ;
6- import { generateAlias } from '@umbraco-cms/backoffice/utils ' ;
6+ import { UUIInputEvent } from '@umbraco-cms/backoffice/external/uui' ;
7+ import type { UUIInputElement } from '@umbraco-cms/backoffice/external/uui ' ;
78
89@customElement ( 'umb-input-with-alias' )
910export class UmbInputWithAliasElement extends UmbFormControlMixin < string , typeof UmbLitElement > ( UmbLitElement ) {
@@ -64,8 +65,11 @@ export class UmbInputWithAliasElement extends UmbFormControlMixin<string, typeof
6465 }
6566 }
6667
67- #onToggleAliasLock( ) {
68+ #onToggleAliasLock( event : CustomEvent ) {
6869 this . _aliasLocked = ! this . _aliasLocked ;
70+ if ( ! this . _aliasLocked ) {
71+ ( event . target as UUIInputElement ) ?. focus ( ) ;
72+ }
6973 }
7074
7175 override render ( ) {
@@ -79,26 +83,18 @@ export class UmbInputWithAliasElement extends UmbFormControlMixin<string, typeof
7983 label= ${ nameLabel }
8084 .value = ${ this . value }
8185 @input = ${ this . #onNameChange} >
82- <!- - TODO: should use UUI- LOCK- INPUT, but that does not fire an event when its locked/ unlocked - - >
83- <uui- input
86+ <uui- input- lock
8487 auto - width
8588 name= "alias"
8689 slot = "append"
8790 label = ${ aliasLabel }
88- .value = ${ this . alias }
8991 placeholder= ${ aliasLabel }
90- ?dis abled= ${ this . _aliasLocked && ! this . aliasReadonly }
92+ .value = ${ this . alias }
93+ ?locked= ${ this . _aliasLocked && ! this . aliasReadonly }
9194 ?readonly = ${ this . aliasReadonly }
92- @input = ${ this . #onAliasChange} >
93- <!- - TODO: validation for bad characters - - >
94- ${ this . aliasReadonly
95- ? nothing
96- : html `
97- <div @click = ${ this . #onToggleAliasLock} @keydown = ${ ( ) => '' } id= "alias-lock" slot = "prepend" >
98- <uui- icon name= ${ this . _aliasLocked ? 'icon-lock' : 'icon-unlocked' } > </ uui- icon>
99- </ div>
100- ` }
101- </ uui- input>
95+ @input = ${ this . #onAliasChange}
96+ @lock-change = ${ this . #onToggleAliasLock} >
97+ </ uui- input- lock>
10298 </ uui- input>
10399 ` ;
104100 }
@@ -120,21 +116,10 @@ export class UmbInputWithAliasElement extends UmbFormControlMixin<string, typeof
120116 : host (: invalid : not ([pristine ])) > uui-input {
121117 border-color : var (--uui-color-danger );
122118 }
123-
124- # alias-lock {
125- display : flex;
126- align-items : center;
127- justify-content : center;
128- cursor : pointer;
129- }
130-
131- # alias-lock uui-icon {
132- margin-bottom : 2px ;
133- }
134119 ` ;
135120}
136121
137- export default UmbInputWithAliasElement ;
122+ export { UmbInputWithAliasElement as element } ;
138123
139124declare global {
140125 interface HTMLElementTagNameMap {
0 commit comments