Skip to content

Commit ce0d995

Browse files
authored
Merge branch 'master' into sivanova/disabled-date-picker
2 parents c395bdf + d8851a5 commit ce0d995

File tree

7 files changed

+48
-32
lines changed

7 files changed

+48
-32
lines changed

src/components/combo/themes/combo.base.scss

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
@use 'styles/utilities' as *;
33

44
:host {
5+
--item-count: 6;
6+
57
display: block;
68
font-family: var(--ig-font-family);
79

@@ -73,7 +75,7 @@
7375
}
7476

7577
[part='list'] {
76-
min-height: rem(200px) !important;
78+
min-height: calc(var(--size) * var(--item-count)) !important;
7779
outline-style: none;
7880
}
7981

src/components/combo/themes/shared/combo.indigo.scss

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ $dropdown-theme: dropdown-theme.$indigo;
99

1010
:host {
1111
--component-size: var(--ig-size, #{var-get($theme, 'default-size')});
12+
--input-icon: #{sizable(rem(14px), rem(16px), rem(18px))};
1213
--combo-size: var(--component-size);
1314

1415
igc-input::part(container) {
@@ -21,6 +22,11 @@ $dropdown-theme: dropdown-theme.$indigo;
2122
margin-block-start: rem(4px);
2223
grid-auto-rows: minmax(rem(15px), auto);
2324
}
25+
26+
igc-icon,
27+
::slotted(igc-icon) {
28+
--size: var(--input-icon) !important;
29+
}
2430
}
2531

2632
[part='case-icon'] {
@@ -61,6 +67,10 @@ $dropdown-theme: dropdown-theme.$indigo;
6167
}
6268
}
6369

70+
[part='list'] {
71+
min-height: calc(var(--size) * var(--item-count) + rem(16px)) !important;
72+
}
73+
6474
[part='filter-input'] {
6575
padding: pad-inline(rem(12px));
6676
}

src/components/common/util.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { isServer } from 'lit';
1+
import { isServer, nothing } from 'lit';
22

33
export const asPercent = (part: number, whole: number) => (part / whole) * 100;
44

@@ -581,3 +581,13 @@ export function toMerged<
581581
>(target: T, source: S): T & S {
582582
return merge(structuredClone(target), source);
583583
}
584+
585+
/**
586+
* Similar to Lit's `ifDefined` directive except one can check `assertion`
587+
* and bind a different `value` through this wrapper.
588+
*/
589+
export function bindIf<T>(assertion: unknown, value: T): NonNullable<T> {
590+
return assertion
591+
? (value ?? (nothing as NonNullable<T>))
592+
: (nothing as NonNullable<T>);
593+
}

src/components/file-input/file-input.ts

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
import { html, nothing } from 'lit';
1+
import { html } from 'lit';
22
import { property, state } from 'lit/decorators.js';
3-
import { ifDefined } from 'lit/directives/if-defined.js';
43

54
import { addThemingController } from '../../theming/theming-controller.js';
65
import IgcButtonComponent from '../button/button.js';
@@ -10,7 +9,7 @@ import { EventEmitterMixin } from '../common/mixins/event-emitter.js';
109
import { FormValueFileListTransformers } from '../common/mixins/forms/form-transformers.js';
1110
import { createFormValueState } from '../common/mixins/forms/form-value.js';
1211
import { partMap } from '../common/part-map.js';
13-
import { isEmpty } from '../common/util.js';
12+
import { bindIf, isEmpty } from '../common/util.js';
1413
import {
1514
IgcInputBaseComponent,
1615
type IgcInputComponentEventMap,
@@ -126,12 +125,6 @@ export default class IgcFileInputComponent extends EventEmitterMixin<
126125
@property({ type: Boolean })
127126
public override autofocus!: boolean;
128127

129-
/**
130-
* @internal
131-
*/
132-
@property({ type: Number })
133-
public override tabIndex = 0;
134-
135128
/** @hidden */
136129
@property({ type: Boolean, attribute: false, noAccessor: true })
137130
public override readonly readOnly = false;
@@ -208,6 +201,9 @@ export default class IgcFileInputComponent extends EventEmitterMixin<
208201
}
209202

210203
protected renderInput() {
204+
const hasNegativeTabIndex = this.getAttribute('tabindex') === '-1';
205+
const hasHelperText = !isEmpty(this._helperText);
206+
211207
return html`
212208
<input
213209
id=${this.inputId}
@@ -217,11 +213,9 @@ export default class IgcFileInputComponent extends EventEmitterMixin<
217213
?required=${this.required}
218214
?autofocus=${this.autofocus}
219215
?multiple=${this.multiple}
220-
tabindex=${this.tabIndex}
221-
accept=${ifDefined(this.accept === '' ? undefined : this.accept)}
222-
aria-describedby=${ifDefined(
223-
isEmpty(this._helperText) ? nothing : 'helper-text'
224-
)}
216+
tabindex=${bindIf(hasNegativeTabIndex, -1)}
217+
accept=${bindIf(this.accept, this.accept)}
218+
aria-describedby=${bindIf(hasHelperText, 'helper-text')}
225219
@click=${this._handleClick}
226220
@change=${this._handleChange}
227221
@cancel=${this._handleCancel}

src/components/input/input.ts

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
import { html, nothing } from 'lit';
1+
import { html } from 'lit';
22
import { property } from 'lit/decorators.js';
33
import { ifDefined } from 'lit/directives/if-defined.js';
44
import { live } from 'lit/directives/live.js';
55

66
import { registerComponent } from '../common/definitions/register.js';
77
import { createFormValueState } from '../common/mixins/forms/form-value.js';
88
import { partMap } from '../common/part-map.js';
9-
import { isEmpty } from '../common/util.js';
9+
import { bindIf, isEmpty } from '../common/util.js';
1010
import type { InputType, RangeTextSelectMode } from '../types.js';
1111
import IgcValidationContainerComponent from '../validation-container/validation-container.js';
1212
import { IgcInputBaseComponent } from './input-base.js';
@@ -199,12 +199,6 @@ export default class IgcInputComponent extends IgcInputBaseComponent {
199199
@property({ type: Boolean, reflect: true, attribute: 'validate-only' })
200200
public validateOnly = false;
201201

202-
/**
203-
* @internal
204-
*/
205-
@property({ type: Number })
206-
public override tabIndex = 0;
207-
208202
/* blazorSuppress */
209203
/** Replaces the selected text in the input. */
210204
public override setRangeText(
@@ -247,6 +241,9 @@ export default class IgcInputComponent extends IgcInputBaseComponent {
247241
}
248242

249243
protected renderInput() {
244+
const hasNegativeTabIndex = this.getAttribute('tabindex') === '-1';
245+
const hasHelperText = !isEmpty(this._helperText);
246+
250247
return html`
251248
<input
252249
id=${this.inputId}
@@ -260,17 +257,15 @@ export default class IgcInputComponent extends IgcInputBaseComponent {
260257
?disabled=${this.disabled}
261258
?required=${this.required}
262259
?autofocus=${this.autofocus}
263-
tabindex=${this.tabIndex}
260+
tabindex=${bindIf(hasNegativeTabIndex, -1)}
264261
autocomplete=${ifDefined(this.autocomplete as any)}
265262
inputmode=${ifDefined(this.inputMode)}
266-
min=${ifDefined(this.validateOnly ? undefined : this.min)}
267-
max=${ifDefined(this.validateOnly ? undefined : this.max)}
263+
min=${bindIf(!this.validateOnly, this.min)}
264+
max=${bindIf(!this.validateOnly, this.max)}
268265
minlength=${ifDefined(this.minLength)}
269-
maxlength=${ifDefined(this.validateOnly ? undefined : this.maxLength)}
266+
maxlength=${bindIf(!this.validateOnly, this.maxLength)}
270267
step=${ifDefined(this.step)}
271-
aria-describedby=${ifDefined(
272-
isEmpty(this._helperText) ? nothing : 'helper-text'
273-
)}
268+
aria-describedby=${bindIf(hasHelperText, 'helper-text')}
274269
@change=${this.handleChange}
275270
@input=${this.handleInput}
276271
@blur=${this._handleBlur}

src/components/select/select.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -663,7 +663,6 @@ export default class IgcSelectComponent extends FormAssociatedRequiredMixin(
663663
aria-describedby="select-helper-text"
664664
aria-expanded=${this.open}
665665
exportparts="container: input, input: native-input, label, prefix, suffix"
666-
tabIndex=${this.disabled ? -1 : 0}
667666
value=${ifDefined(value)}
668667
placeholder=${ifDefined(this.placeholder)}
669668
label=${ifDefined(this.label)}

src/components/select/themes/shared/select.indigo.scss

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ $input-theme: input-theme.$indigo;
1111
--component-size: var(--ig-size, #{var-get($theme, 'default-size')});
1212
--select-size: var(--component-size);
1313
--dropdown-size: var(--component-size);
14+
--input-icon: #{sizable(rem(14px), rem(16px), rem(18px))};
1415

1516
::part(helper-text) {
1617
@include type-style('caption');
@@ -26,6 +27,11 @@ $input-theme: input-theme.$indigo;
2627
igc-input::part(container) {
2728
padding-inline: 0;
2829
}
30+
31+
igc-icon,
32+
::slotted(igc-icon) {
33+
--size: var(--input-icon) !important;
34+
}
2935
}
3036

3137
[part='base'] {

0 commit comments

Comments
 (0)