Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dropdown/select: when there is no placeholder, label will have default font-size #134

Open
wants to merge 1 commit into
base: sunMota/dropdown-focus-border
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
72 changes: 69 additions & 3 deletions components/combobox/demo/api.min.js
Original file line number Diff line number Diff line change
Expand Up @@ -2925,7 +2925,7 @@ let AuroIcon$2 = class AuroIcon extends BaseIcon$2 {

var iconVersion$2 = '6.1.1';

var styleCss$1$2 = i$3$1`:host{position:relative;display:inline-block;max-width:100%}:host([fluid]){display:block}#bibSizer{position:absolute;z-index:-1;opacity:0;pointer-events:none}.label{font-size:var(--ds-text-body-size-xs, 0.75rem);line-height:var(--ds-text-body-size-default, 1rem);white-space:normal}.trigger{position:relative;display:flex;align-items:center;border-width:1px;border-style:solid}@media(hover: hover){.trigger:hover{cursor:pointer}}.triggerContentWrapper{overflow:hidden;flex:1;text-overflow:ellipsis;white-space:nowrap}#showStateIcon{display:flex;height:100%;align-items:center;margin-left:var(--ds-size-100, 0.5rem)}#showStateIcon [auro-icon]{height:var(--ds-size-300, 1.5rem);line-height:var(--ds-size-300, 1.5rem)}#showStateIcon[data-expanded=true] [auro-icon]{transform:rotate(-180deg)}.helpText{margin-top:var(--ds-size-50, 0.25rem);font-size:var(--ds-text-body-size-xs, 0.75rem);line-height:var(--ds-text-body-size-default, 1rem)}:host([matchwidth]) #bibSizer{width:100%}:host([disabled]){pointer-events:none}:host([inset]) .trigger{padding:var(--ds-size-150, 0.75rem) var(--ds-size-200, 1rem)}:host([common]) .trigger,:host([inset][bordered]) .trigger{padding:var(--ds-size-200, 1rem) var(--ds-size-150, 0.75rem)}:host([common]) .trigger,:host([rounded]) .trigger{border-radius:var(--ds-border-radius, 0.375rem)}`;
var styleCss$1$2 = i$3$1`:host{position:relative;display:inline-block;max-width:100%}:host([fluid]){display:block}#bibSizer{position:absolute;z-index:-1;opacity:0;pointer-events:none}.label{font-size:var(--ds-text-body-size-xs, 0.75rem);line-height:var(--ds-text-body-size-default, 1rem);transition:font-size .3s cubic-bezier(0.215, 0.61, 0.355, 1);white-space:normal}.label[hasTrigger=false]{font-size:var(--ds-text-body-size-default, 1rem)}.trigger{position:relative;display:flex;align-items:center;border-width:1px;border-style:solid}@media(hover: hover){.trigger:hover{cursor:pointer}}.triggerContentWrapper{overflow:hidden;flex:1;text-overflow:ellipsis;white-space:nowrap}#showStateIcon{display:flex;height:100%;align-items:center;margin-left:var(--ds-size-100, 0.5rem)}#showStateIcon [auro-icon]{height:var(--ds-size-300, 1.5rem);line-height:var(--ds-size-300, 1.5rem)}#showStateIcon[data-expanded=true] [auro-icon]{transform:rotate(-180deg)}.helpText{margin-top:var(--ds-size-50, 0.25rem);font-size:var(--ds-text-body-size-xs, 0.75rem);line-height:var(--ds-text-body-size-default, 1rem)}:host([matchwidth]) #bibSizer{width:100%}:host([disabled]){pointer-events:none}:host([inset]) .trigger{padding:var(--ds-size-150, 0.75rem) var(--ds-size-200, 1rem)}:host([common]) .trigger,:host([inset][bordered]) .trigger{padding:var(--ds-size-200, 1rem) var(--ds-size-150, 0.75rem)}:host([common]) .trigger,:host([rounded]) .trigger{border-radius:var(--ds-border-radius, 0.375rem)}`;

var colorCss$1$2 = i$3$1`.label{color:var(--ds-auro-dropdown-label-text-color)}.trigger{border-color:var(--ds-auro-dropdown-trigger-border-color);background-color:var(--ds-auro-dropdown-trigger-container-color);color:var(--ds-auro-dropdown-trigger-text-color)}.trigger:focus-within,.trigger:active{--ds-auro-dropdown-trigger-border-color: var(--ds-color-border-active-default, #0074c8)}.trigger:focus-within:not(:active){--ds-auro-dropdown-trigger-border-color: var(--ds-color-border-ui-focus-default, #2c67b5);box-shadow:inset 0 0 0 1px var(--ds-color-border-ui-focus-default, #2c67b5)}.trigger:hover{--ds-auro-dropdown-trigger-container-color: var(--ds-color-container-ui-secondary-hover-default, rgba(0, 0, 0, 0.03))}.helpText{color:var(--ds-auro-dropdown-help-text-color)}:host([disabled]){--ds-auro-dropdown-trigger-text-color: var(--ds-color-text-ui-disabled-default, #adadad);--ds-auro-dropdown-label-text-color: var(--ds-color-text-ui-disabled-default, #adadad)}:host([common]),:host([bordered]){--ds-auro-dropdown-trigger-border-color: var(--ds-color-border-primary-default, #585e67)}:host([common]) .trigger:active,:host([common]) .trigger:focus-within,:host([bordered]) .trigger:active,:host([bordered]) .trigger:focus-within{--ds-auro-dropdown-trigger-border-color: var(--ds-color-border-ui-focus-default, #2c67b5)}:host([error]){--ds-auro-dropdown-help-text-color: var(--ds-color-text-error-default, #cc1816);--ds-auro-dropdown-trigger-border-color: var(--ds-color-border-error-default, #cc1816)}:host([error]) .trigger{box-shadow:inset 0 0 0 1px var(--ds-auro-dropdown-trigger-border-color)}:host([error]) .trigger:focus-within{--ds-auro-dropdown-trigger-border-color: var(--ds-color-border-ui-focus-default, #2c67b5);box-shadow:none}:host([error]) .trigger:active{--ds-auro-dropdown-trigger-border-color: var(--ds-color-border-ui-focus-default, #2c67b5);box-shadow:inset 0 0 0 1px var(--ds-auro-dropdown-trigger-border-color)}:host([disabled][common]),:host([disabled][bordered]){--ds-auro-dropdown-trigger-border-color: var(--ds-color-border-ui-disabled-default, #adadad)}`;

Expand Down Expand Up @@ -3081,6 +3081,16 @@ class AuroDropdown extends r$5 {
this.tabIndex = 0;
this.noToggle = false;

/**
* @private
*/
this._hasTriggerContent = false;

/**
* @private
*/
this.triggerContentSlot = undefined;

/**
* @private
*/
Expand Down Expand Up @@ -3214,6 +3224,37 @@ class AuroDropdown extends r$5 {
];
}

/**
* Sets the value of the hasTriggerContent property and requests an update if changed.
*
* This setter updates the internal `_hasTriggerContent` property only if the new value differs
* from the current value. If a change is detected, it triggers a request for the component to
* update, ensuring that UI elements are refreshed accordingly.
*
* @private
* @setter hasTriggerContent
* @param {boolean} value - The new value indicating whether the trigger content is present.
* @returns {void}
*/
set hasTriggerContent(value) {
if (value !== this._hasTriggerContent) {
this._hasTriggerContent = value;
this.requestUpdate();
}
}

/**
* Retrieves the value of the hasTriggerContent property.
*
* @private
* @getter hasTriggerContent
* @type {boolean}
* @returns {boolean} The current value of the hasTriggerContent property.
*/
get hasTriggerContent() {
return this._hasTriggerContent;
}

/**
* This will register this element with the browser.
* @param {string} [name="auro-dropdown"] - The name of element that you want to register to.
Expand All @@ -3240,6 +3281,12 @@ class AuroDropdown extends r$5 {
if (changedProperties.has('mobileFullscreenBreakpoint')) {
this.bibContent.mobileFullscreenBreakpoint = this.mobileFullscreenBreakpoint;
}

if (this.triggerContentSlot) {
this.hasTriggerContent = this.triggerContentSlot.reduce((old, sl) => old || Boolean(sl.textContent.trim()), false);
} else {
this.hasTriggerContent = false;
}
}

firstUpdated() {
Expand Down Expand Up @@ -3282,6 +3329,25 @@ class AuroDropdown extends r$5 {
return inCustomSlot;
}

/**
* Handles changes to the trigger content slot and updates related properties.
*
* It first updates the floater settings
* Then, it retrieves the assigned nodes from the event target and checks if any of
* the nodes contain non-empty text content, updating the `hasTriggerContent` property accordingly.
*
* @private
* @method handleTriggerContentSlotChange
* @param {Event} event - native slotchange event
* @returns {void}
*/
handleTriggerContentSlotChange(event) {
this.floater.handleTriggerTabIndex();

this.triggerContentSlot = event.target.assignedNodes();
this.hasTriggerContent = this.triggerContentSlot.reduce((old, sl) => old || Boolean(sl.textContent.trim()), false);
}

/**
* Handles the default slot change event and updates the content.
*
Expand Down Expand Up @@ -3316,13 +3382,13 @@ class AuroDropdown extends r$5 {
tabindex="${this.tabIndex}"
>
<div class="triggerContentWrapper">
<label class="label" id="triggerLabel">
<label class="label" id="triggerLabel" hasTrigger=${this.hasTriggerContent}>
<slot name="label"></slot>
</label>
<div class="triggerContent">
<slot
name="trigger"
@slotchange="${() => {this.floater.handleTriggerTabIndex(); }}"></slot>
@slotchange="${(event) => this.handleTriggerContentSlotChange(event)}"></slot>
</div>
</div>
${this.chevron || this.common ? u$1$1`
Expand Down
72 changes: 69 additions & 3 deletions components/combobox/demo/index.min.js
Original file line number Diff line number Diff line change
Expand Up @@ -2791,7 +2791,7 @@ let AuroIcon$2 = class AuroIcon extends BaseIcon$2 {

var iconVersion$2 = '6.1.1';

var styleCss$1$2 = i$3$1`:host{position:relative;display:inline-block;max-width:100%}:host([fluid]){display:block}#bibSizer{position:absolute;z-index:-1;opacity:0;pointer-events:none}.label{font-size:var(--ds-text-body-size-xs, 0.75rem);line-height:var(--ds-text-body-size-default, 1rem);white-space:normal}.trigger{position:relative;display:flex;align-items:center;border-width:1px;border-style:solid}@media(hover: hover){.trigger:hover{cursor:pointer}}.triggerContentWrapper{overflow:hidden;flex:1;text-overflow:ellipsis;white-space:nowrap}#showStateIcon{display:flex;height:100%;align-items:center;margin-left:var(--ds-size-100, 0.5rem)}#showStateIcon [auro-icon]{height:var(--ds-size-300, 1.5rem);line-height:var(--ds-size-300, 1.5rem)}#showStateIcon[data-expanded=true] [auro-icon]{transform:rotate(-180deg)}.helpText{margin-top:var(--ds-size-50, 0.25rem);font-size:var(--ds-text-body-size-xs, 0.75rem);line-height:var(--ds-text-body-size-default, 1rem)}:host([matchwidth]) #bibSizer{width:100%}:host([disabled]){pointer-events:none}:host([inset]) .trigger{padding:var(--ds-size-150, 0.75rem) var(--ds-size-200, 1rem)}:host([common]) .trigger,:host([inset][bordered]) .trigger{padding:var(--ds-size-200, 1rem) var(--ds-size-150, 0.75rem)}:host([common]) .trigger,:host([rounded]) .trigger{border-radius:var(--ds-border-radius, 0.375rem)}`;
var styleCss$1$2 = i$3$1`:host{position:relative;display:inline-block;max-width:100%}:host([fluid]){display:block}#bibSizer{position:absolute;z-index:-1;opacity:0;pointer-events:none}.label{font-size:var(--ds-text-body-size-xs, 0.75rem);line-height:var(--ds-text-body-size-default, 1rem);transition:font-size .3s cubic-bezier(0.215, 0.61, 0.355, 1);white-space:normal}.label[hasTrigger=false]{font-size:var(--ds-text-body-size-default, 1rem)}.trigger{position:relative;display:flex;align-items:center;border-width:1px;border-style:solid}@media(hover: hover){.trigger:hover{cursor:pointer}}.triggerContentWrapper{overflow:hidden;flex:1;text-overflow:ellipsis;white-space:nowrap}#showStateIcon{display:flex;height:100%;align-items:center;margin-left:var(--ds-size-100, 0.5rem)}#showStateIcon [auro-icon]{height:var(--ds-size-300, 1.5rem);line-height:var(--ds-size-300, 1.5rem)}#showStateIcon[data-expanded=true] [auro-icon]{transform:rotate(-180deg)}.helpText{margin-top:var(--ds-size-50, 0.25rem);font-size:var(--ds-text-body-size-xs, 0.75rem);line-height:var(--ds-text-body-size-default, 1rem)}:host([matchwidth]) #bibSizer{width:100%}:host([disabled]){pointer-events:none}:host([inset]) .trigger{padding:var(--ds-size-150, 0.75rem) var(--ds-size-200, 1rem)}:host([common]) .trigger,:host([inset][bordered]) .trigger{padding:var(--ds-size-200, 1rem) var(--ds-size-150, 0.75rem)}:host([common]) .trigger,:host([rounded]) .trigger{border-radius:var(--ds-border-radius, 0.375rem)}`;

var colorCss$1$2 = i$3$1`.label{color:var(--ds-auro-dropdown-label-text-color)}.trigger{border-color:var(--ds-auro-dropdown-trigger-border-color);background-color:var(--ds-auro-dropdown-trigger-container-color);color:var(--ds-auro-dropdown-trigger-text-color)}.trigger:focus-within,.trigger:active{--ds-auro-dropdown-trigger-border-color: var(--ds-color-border-active-default, #0074c8)}.trigger:focus-within:not(:active){--ds-auro-dropdown-trigger-border-color: var(--ds-color-border-ui-focus-default, #2c67b5);box-shadow:inset 0 0 0 1px var(--ds-color-border-ui-focus-default, #2c67b5)}.trigger:hover{--ds-auro-dropdown-trigger-container-color: var(--ds-color-container-ui-secondary-hover-default, rgba(0, 0, 0, 0.03))}.helpText{color:var(--ds-auro-dropdown-help-text-color)}:host([disabled]){--ds-auro-dropdown-trigger-text-color: var(--ds-color-text-ui-disabled-default, #adadad);--ds-auro-dropdown-label-text-color: var(--ds-color-text-ui-disabled-default, #adadad)}:host([common]),:host([bordered]){--ds-auro-dropdown-trigger-border-color: var(--ds-color-border-primary-default, #585e67)}:host([common]) .trigger:active,:host([common]) .trigger:focus-within,:host([bordered]) .trigger:active,:host([bordered]) .trigger:focus-within{--ds-auro-dropdown-trigger-border-color: var(--ds-color-border-ui-focus-default, #2c67b5)}:host([error]){--ds-auro-dropdown-help-text-color: var(--ds-color-text-error-default, #cc1816);--ds-auro-dropdown-trigger-border-color: var(--ds-color-border-error-default, #cc1816)}:host([error]) .trigger{box-shadow:inset 0 0 0 1px var(--ds-auro-dropdown-trigger-border-color)}:host([error]) .trigger:focus-within{--ds-auro-dropdown-trigger-border-color: var(--ds-color-border-ui-focus-default, #2c67b5);box-shadow:none}:host([error]) .trigger:active{--ds-auro-dropdown-trigger-border-color: var(--ds-color-border-ui-focus-default, #2c67b5);box-shadow:inset 0 0 0 1px var(--ds-auro-dropdown-trigger-border-color)}:host([disabled][common]),:host([disabled][bordered]){--ds-auro-dropdown-trigger-border-color: var(--ds-color-border-ui-disabled-default, #adadad)}`;

Expand Down Expand Up @@ -2947,6 +2947,16 @@ class AuroDropdown extends r$5 {
this.tabIndex = 0;
this.noToggle = false;

/**
* @private
*/
this._hasTriggerContent = false;

/**
* @private
*/
this.triggerContentSlot = undefined;

/**
* @private
*/
Expand Down Expand Up @@ -3080,6 +3090,37 @@ class AuroDropdown extends r$5 {
];
}

/**
* Sets the value of the hasTriggerContent property and requests an update if changed.
*
* This setter updates the internal `_hasTriggerContent` property only if the new value differs
* from the current value. If a change is detected, it triggers a request for the component to
* update, ensuring that UI elements are refreshed accordingly.
*
* @private
* @setter hasTriggerContent
* @param {boolean} value - The new value indicating whether the trigger content is present.
* @returns {void}
*/
set hasTriggerContent(value) {
if (value !== this._hasTriggerContent) {
this._hasTriggerContent = value;
this.requestUpdate();
}
}

/**
* Retrieves the value of the hasTriggerContent property.
*
* @private
* @getter hasTriggerContent
* @type {boolean}
* @returns {boolean} The current value of the hasTriggerContent property.
*/
get hasTriggerContent() {
return this._hasTriggerContent;
}

/**
* This will register this element with the browser.
* @param {string} [name="auro-dropdown"] - The name of element that you want to register to.
Expand All @@ -3106,6 +3147,12 @@ class AuroDropdown extends r$5 {
if (changedProperties.has('mobileFullscreenBreakpoint')) {
this.bibContent.mobileFullscreenBreakpoint = this.mobileFullscreenBreakpoint;
}

if (this.triggerContentSlot) {
this.hasTriggerContent = this.triggerContentSlot.reduce((old, sl) => old || Boolean(sl.textContent.trim()), false);
} else {
this.hasTriggerContent = false;
}
}

firstUpdated() {
Expand Down Expand Up @@ -3148,6 +3195,25 @@ class AuroDropdown extends r$5 {
return inCustomSlot;
}

/**
* Handles changes to the trigger content slot and updates related properties.
*
* It first updates the floater settings
* Then, it retrieves the assigned nodes from the event target and checks if any of
* the nodes contain non-empty text content, updating the `hasTriggerContent` property accordingly.
*
* @private
* @method handleTriggerContentSlotChange
* @param {Event} event - native slotchange event
* @returns {void}
*/
handleTriggerContentSlotChange(event) {
this.floater.handleTriggerTabIndex();

this.triggerContentSlot = event.target.assignedNodes();
this.hasTriggerContent = this.triggerContentSlot.reduce((old, sl) => old || Boolean(sl.textContent.trim()), false);
}

/**
* Handles the default slot change event and updates the content.
*
Expand Down Expand Up @@ -3182,13 +3248,13 @@ class AuroDropdown extends r$5 {
tabindex="${this.tabIndex}"
>
<div class="triggerContentWrapper">
<label class="label" id="triggerLabel">
<label class="label" id="triggerLabel" hasTrigger=${this.hasTriggerContent}>
<slot name="label"></slot>
</label>
<div class="triggerContent">
<slot
name="trigger"
@slotchange="${() => {this.floater.handleTriggerTabIndex(); }}"></slot>
@slotchange="${(event) => this.handleTriggerContentSlotChange(event)}"></slot>
</div>
</div>
${this.chevron || this.common ? u$1$1`
Expand Down
Loading