@tylertech/forge 3.3.4 → 3.3.5

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.
@@ -9,11 +9,12 @@ import { FieldLabelPosition } from './base/base-field-constants';
9
9
  import { IFieldComponent } from './field';
10
10
  export interface IFieldAdapter extends IBaseAdapter<IFieldComponent> {
11
11
  readonly focusIndicator: IFocusIndicatorComponent;
12
+ readonly hasSlottedLabel: boolean;
12
13
  addRootListener(name: keyof HTMLElementEventMap, listener: EventListener): void;
13
14
  addPopoverIconClickListener(listener: EventListener): void;
14
15
  removePopoverIconClickListener(listener: EventListener): void;
15
16
  setLabelPosition(value: FieldLabelPosition): void;
16
- setFloatingLabel(value: boolean, skipAnimation?: boolean): void;
17
+ setFloatingLabel(value: boolean): void;
17
18
  handleSlotChange(slot: HTMLSlotElement): void;
18
19
  initializeSlots(): void;
19
20
  }
@@ -22,9 +23,11 @@ export declare class FieldAdapter extends BaseAdapter<IFieldComponent> implement
22
23
  private readonly _containerElement;
23
24
  private readonly _inputContainerElement;
24
25
  private readonly _labelElement;
26
+ private readonly _labelSlotElement;
25
27
  private readonly _popoverIconElement;
26
28
  private readonly _focusIndicatorElement;
27
29
  get focusIndicator(): IFocusIndicatorComponent;
30
+ get hasSlottedLabel(): boolean;
28
31
  constructor(component: IFieldComponent);
29
32
  addRootListener(name: keyof HTMLElementEventMap, listener: EventListener): void;
30
33
  addPopoverIconClickListener(listener: EventListener): void;
@@ -37,7 +40,7 @@ export declare class FieldAdapter extends BaseAdapter<IFieldComponent> implement
37
40
  /**
38
41
  * Adds or removes animation classes on the root element.
39
42
  */
40
- setFloatingLabel(value: boolean, skipAnimation?: boolean): void;
43
+ setFloatingLabel(value: boolean): void;
41
44
  /**
42
45
  * Adds or removes a class from the root element indicating whether the slot has any assigned
43
46
  * nodes.
@@ -11,12 +11,16 @@ export class FieldAdapter extends BaseAdapter {
11
11
  get focusIndicator() {
12
12
  return this._focusIndicatorElement;
13
13
  }
14
+ get hasSlottedLabel() {
15
+ return !!this._labelSlotElement.assignedNodes({ flatten: true }).length;
16
+ }
14
17
  constructor(component) {
15
18
  super(component);
16
19
  this._rootElement = getShadowElement(component, FIELD_CONSTANTS.selectors.ROOT);
17
20
  this._containerElement = getShadowElement(component, FIELD_CONSTANTS.selectors.CONTAINER);
18
21
  this._inputContainerElement = getShadowElement(component, FIELD_CONSTANTS.selectors.INPUT_CONTAINER);
19
22
  this._labelElement = getShadowElement(component, FIELD_CONSTANTS.selectors.LABEL);
23
+ this._labelSlotElement = getShadowElement(component, FIELD_CONSTANTS.selectors.LABEL_SLOT);
20
24
  this._popoverIconElement = getShadowElement(component, FIELD_CONSTANTS.selectors.POPOVER_ICON);
21
25
  this._focusIndicatorElement = getShadowElement(component, FOCUS_INDICATOR_CONSTANTS.elementName);
22
26
  }
@@ -45,10 +49,7 @@ export class FieldAdapter extends BaseAdapter {
45
49
  /**
46
50
  * Adds or removes animation classes on the root element.
47
51
  */
48
- setFloatingLabel(value, skipAnimation = false) {
49
- if (skipAnimation || !this._labelElement) {
50
- return;
51
- }
52
+ setFloatingLabel(value) {
52
53
  // Temporarily lock the input container element width to its current width before the animation starts
53
54
  // to ensure that the element cannot collapse while the animation is executing. The width will be
54
55
  // removed after the animation completes.
@@ -61,6 +61,7 @@ export declare const FIELD_CONSTANTS: {
61
61
  CONTAINER: string;
62
62
  INPUT_CONTAINER: string;
63
63
  LABEL: string;
64
+ LABEL_SLOT: string;
64
65
  POPOVER_ICON: string;
65
66
  LABEL_ELEMENTS: string;
66
67
  POPOVER_TARGET: string;
@@ -32,6 +32,7 @@ const selectors = {
32
32
  CONTAINER: '#container',
33
33
  INPUT_CONTAINER: '#input',
34
34
  LABEL: '#label',
35
+ LABEL_SLOT: 'slot[name=label]',
35
36
  POPOVER_ICON: '#popover-icon',
36
37
  LABEL_ELEMENTS: `:where(label, ${LABEL_CONSTANTS.elementName})`,
37
38
  POPOVER_TARGET: '.popover-target'
@@ -44,7 +44,6 @@ export class FieldCore {
44
44
  floatLabelWithoutAnimation(value) {
45
45
  if (this._floatLabel !== value) {
46
46
  this._floatLabel = value;
47
- this._adapter.setFloatingLabel(this._floatLabel, true);
48
47
  this._adapter.toggleHostAttribute(FIELD_CONSTANTS.attributes.FLOAT_LABEL, this._floatLabel);
49
48
  }
50
49
  }
@@ -76,7 +75,9 @@ export class FieldCore {
76
75
  set floatLabel(value) {
77
76
  if (this._floatLabel !== value) {
78
77
  this._floatLabel = value;
79
- this._adapter.setFloatingLabel(this._floatLabel);
78
+ if (this._adapter.hasSlottedLabel) {
79
+ this._adapter.setFloatingLabel(this._floatLabel);
80
+ }
80
81
  this._adapter.toggleHostAttribute(FIELD_CONSTANTS.attributes.FLOAT_LABEL, this._floatLabel);
81
82
  }
82
83
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@tylertech/forge",
3
3
  "description": "Tyler Forge™ Web Components library",
4
- "version": "3.3.4",
4
+ "version": "3.3.5",
5
5
  "author": "Tyler Technologies, Inc.",
6
6
  "license": "Apache-2.0",
7
7
  "repository": {