Skip to content
This repository has been archived by the owner on Mar 27, 2023. It is now read-only.

fix(core): lit lifecycle type #6667

Merged
merged 1 commit into from
Feb 9, 2022
Merged
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
2 changes: 1 addition & 1 deletion packages/core/npm.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"*"
],
"dependencies": {
"lit": "2.1.2",
"lit": "^2.1.3",
"ramda": "^0.28.0",
"tslib": "^2.3.1"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
"url": "https://github.com/vmware/clarity/issues"
},
"dependencies": {
"lit": "2.1.2",
"lit": "^2.1.3",
"ramda": "^0.28.0",
"tslib": "^2.3.1"
},
Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/accordion/accordion-panel.element.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* The full license information can be found in LICENSE in the root directory of this project.
*/

import { html, LitElement } from 'lit';
import { html, LitElement, PropertyValues } from 'lit';
import {
AnimationAccordionPanelOpenName,
reverseAnimation,
Expand Down Expand Up @@ -77,7 +77,7 @@ export class CdsAccordionPanel extends LitElement {
this.expandedChange.emit(!this.expanded);
}

updated(props: Map<string, any>) {
updated(props: PropertyValues<this>) {
super.updated(props);

if (this.content && this.header) {
Expand Down
6 changes: 3 additions & 3 deletions packages/core/src/alert/alert-actions.element.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
/*
* Copyright (c) 2016-2021 VMware, Inc. All Rights Reserved.
* Copyright (c) 2016-2022 VMware, Inc. All Rights Reserved.
* This software is released under MIT license.
* The full license information can be found in LICENSE in the root directory of this project.
*/

import { html, LitElement, PropertyValues } from 'lit';
import { AlertGroupTypes } from '@cds/core/alert';
import { CdsButton } from '@cds/core/button';
import { assignSlotNames, baseStyles, querySlotAll, state } from '@cds/core/internal';
import { html, LitElement } from 'lit';
import styles from './alert-actions.element.scss';

/**
Expand Down Expand Up @@ -54,7 +54,7 @@ export class CdsAlertActions extends LitElement {
assignSlotNames([this, 'actions']);
}

updated(props: Map<string, any>) {
updated(props: PropertyValues<this>) {
super.updated(props);
this.buttons.forEach(b => {
b.status = this.type === 'banner' ? 'inverse' : 'primary';
Expand Down
8 changes: 4 additions & 4 deletions packages/core/src/alert/alert-group.element.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
/*
* Copyright (c) 2016-2021 VMware, Inc. All Rights Reserved.
* Copyright (c) 2016-2022 VMware, Inc. All Rights Reserved.
* This software is released under MIT license.
* The full license information can be found in LICENSE in the root directory of this project.
*/

import { html, LitElement } from 'lit';
import { html, LitElement, PropertyValues } from 'lit';
import { query } from 'lit/decorators/query.js';
import { baseStyles, property, querySlot, querySlotAll, syncProps } from '@cds/core/internal';
import { CdsAlert } from './alert.element.js';
Expand Down Expand Up @@ -110,7 +110,7 @@ export class CdsAlertGroup extends LitElement {
this.role = 'region';
}

firstUpdated(props: Map<string, any>) {
firstUpdated(props: PropertyValues<this>) {
super.firstUpdated(props);
this.setupAlertsUpdate();
}
Expand All @@ -132,7 +132,7 @@ export class CdsAlertGroup extends LitElement {
);
}

updated(props: Map<string, any>) {
updated(props: PropertyValues<this>) {
super.updated(props);
this.syncAlerts({
status: props.has('status'),
Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/alert/alert.element.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* The full license information can be found in LICENSE in the root directory of this project.
*/

import { html, LitElement } from 'lit';
import { html, LitElement, PropertyValues } from 'lit';
import {
baseStyles,
event,
Expand Down Expand Up @@ -181,7 +181,7 @@ export class CdsAlert extends LitElement {
setAttributes(this, ['aria-describedby', this.idForAriaDescriber], ['role', 'region']);
}

updated(props: Map<string, any>) {
updated(props: PropertyValues<this>) {
super.updated(props);
syncDefinedProps(props, this, [this.alertActions]);
}
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/button-action/button-action.element.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export class CdsButtonAction extends CdsBaseButton {
`;
}

updated(props: PropertyValues) {
updated(props: PropertyValues<this>) {
super.updated(props);

if (!this.ariaLabel && !this.readonly) {
Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/button-expand/button-expand.element.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2016-2021 VMware, Inc. All Rights Reserved.
* Copyright (c) 2016-2022 VMware, Inc. All Rights Reserved.
* This software is released under MIT license.
* The full license information can be found in LICENSE in the root directory of this project.
*/
Expand Down Expand Up @@ -61,7 +61,7 @@ export class CdsButtonExpand extends CdsButtonAction {
this.pressed = false;
}

firstUpdated(props: PropertyValues) {
firstUpdated(props: PropertyValues<this>) {
super.firstUpdated(props);

if (!this.readonly) {
Expand Down
6 changes: 3 additions & 3 deletions packages/core/src/button/button.element.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
* The full license information can be found in LICENSE in the root directory of this project.
*/

import { html, PropertyValues } from 'lit';
import { baseStyles, CdsBaseButton, getElementWidth, property } from '@cds/core/internal';
import { html } from 'lit';
import styles from './button.element.scss';

export const enum ClrLoadingState {
Expand Down Expand Up @@ -83,15 +83,15 @@ export class CdsButton extends CdsBaseButton {
@property({ type: String })
loadingState: keyof typeof ClrLoadingState = ClrLoadingState.default;

firstUpdated(props: Map<string, any>) {
firstUpdated(props: PropertyValues<this>) {
super.firstUpdated(props);

if (!this.isDefaultLoadingState(this.loadingState)) {
this.disabled = true;
}
}

update(props: Map<string, any>) {
update(props: PropertyValues<this>) {
if (props.has('loadingState')) {
if (this.isDefaultLoadingState(props.get('loadingState'))) {
// track prior disabled state to set prior value after button is re-enabled from a loading state
Expand Down
14 changes: 7 additions & 7 deletions packages/core/src/dropdown/dropdown.stories.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
/*
* Copyright (c) 2016-2021 VMware, Inc. All Rights Reserved.
* Copyright (c) 2016-2022 VMware, Inc. All Rights Reserved.
* This software is released under MIT license.
* The full license information can be found in LICENSE in the root directory of this project.
*/

import { html, LitElement, PropertyValues } from 'lit';
import { query } from 'lit/decorators/query.js';
import { customElement } from 'lit/decorators/custom-element.js';
import '@cds/core/button/register.js';
import '@cds/core/radio/register.js';
import '@cds/core/dropdown/register.js';
import '@cds/core/modal/register.js';
import { customElement } from 'lit/decorators/custom-element.js';
import { spreadProps, getElementStorybookArgs, state, property } from '@cds/core/internal';
import { html, LitElement } from 'lit';
import { query } from 'lit/decorators/query.js';
import { CdsButton } from '@cds/core/button';
import { CdsDropdown } from '@cds/core/dropdown';
import { CdsModal } from '@cds/core/modal';
Expand Down Expand Up @@ -49,7 +49,7 @@ class DemoDropdown extends LitElement {

@customElement('demo-dropdown-basic')
class DemoDropdownBasic extends DemoDropdown {
firstUpdated(props: Map<string, any>) {
firstUpdated(props: PropertyValues<this>) {
super.firstUpdated(props);
this.popup.anchor = this.popupAnchor;
}
Expand Down Expand Up @@ -81,7 +81,7 @@ class DemoDropdownBasic extends DemoDropdown {

@customElement('demo-dropdown-scrollable')
class DemoDropdownScrollable extends DemoDropdown {
firstUpdated(props: Map<string, any>) {
firstUpdated(props: PropertyValues<this>) {
super.firstUpdated(props);
this.popup.anchor = this.popupAnchor;
}
Expand Down Expand Up @@ -292,7 +292,7 @@ class DemoDropdownResponsive extends DemoDropdown {

@customElement('demo-dropdown-closable')
class DemoDropdownClosable extends DemoDropdown {
firstUpdated(props: Map<string, any>) {
firstUpdated(props: PropertyValues<this>) {
super.firstUpdated(props);
this.popup.anchor = this.popupAnchor;
}
Expand Down
6 changes: 3 additions & 3 deletions packages/core/src/file/file.element.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
/*
* Copyright (c) 2016-2021 VMware, Inc. All Rights Reserved.
* Copyright (c) 2016-2022 VMware, Inc. All Rights Reserved.
* This software is released under MIT license.
* The full license information can be found in LICENSE in the root directory of this project.
*/

import { html } from 'lit';
import { html, PropertyValues } from 'lit';
import { state } from '@cds/core/internal';
import { i18n, I18nService } from '@cds/core/internal';
import { CdsControl } from '@cds/core/forms';
Expand Down Expand Up @@ -62,7 +62,7 @@ export class CdsFile extends CdsControl {
: html``;
}

firstUpdated(props: Map<string, any>) {
firstUpdated(props: PropertyValues<this>) {
super.firstUpdated(props);
(this.inputControl as Element).addEventListener('change', e => {
// NOTE: have to distinguish here being user-caused events and programmatic
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2016-2021 VMware, Inc. All Rights Reserved.
* Copyright (c) 2016-2022 VMware, Inc. All Rights Reserved.
* This software is released under MIT license.
* The full license information can be found in LICENSE in the root directory of this project.
*/
Expand Down Expand Up @@ -27,7 +27,7 @@ import { CdsButtonAction } from '@cds/core/button-action';
export class CdsControlAction extends CdsButtonAction {
@property({ type: String, reflect: true }) action: 'label' | 'prefix' | 'suffix';

updated(props: PropertyValues) {
updated(props: PropertyValues<this>) {
super.updated(props);
assignSlotNames([this, this.action ?? false]);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
/*
* Copyright (c) 2016-2021 VMware, Inc. All Rights Reserved.
* Copyright (c) 2016-2022 VMware, Inc. All Rights Reserved.
* This software is released under MIT license.
* The full license information can be found in LICENSE in the root directory of this project.
*/

import { html, LitElement } from 'lit';
import { html, LitElement, PropertyValues } from 'lit';
import { query } from 'lit/decorators/query.js';
import {
baseStyles,
Expand Down Expand Up @@ -181,13 +181,13 @@ export class CdsInternalControlGroup extends LitElement {
setAttributes(this, ['role', 'group'], ['cds-control-group', '']);
}

firstUpdated(props: Map<string, any>) {
firstUpdated(props: PropertyValues<this>) {
super.firstUpdated(props);
this.associateLabelAndGroup();
this.setupResponsive();
}

updated(props: Map<string, any>) {
updated(props: PropertyValues<any>) {
mathisscott marked this conversation as resolved.
Show resolved Hide resolved
super.updated(props);
props.set('isControlGroup', true);
this.controls.forEach((c: any) => (c.isControlGroup = true));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
/*
* Copyright (c) 2016-2021 VMware, Inc. All Rights Reserved.
* Copyright (c) 2016-2022 VMware, Inc. All Rights Reserved.
* This software is released under MIT license.
* The full license information can be found in LICENSE in the root directory of this project.
*/

import { html } from 'lit';
import { html, PropertyValues } from 'lit';
import { EventEmitter, property, event, getElementUpdates, state } from '@cds/core/internal';
import styles from './control-inline.element.scss';
import { CdsControl } from '../control/control.element.js';
Expand Down Expand Up @@ -86,7 +86,7 @@ export class CdsInternalControlInline extends CdsControl {
`;
}

firstUpdated(props: Map<string, any>) {
firstUpdated(props: PropertyValues<this>) {
super.firstUpdated(props);
this.inputControl.addEventListener('change', () => (this.checked = this.inputControl.checked));
this.observers.push(
Expand All @@ -99,7 +99,7 @@ export class CdsInternalControlInline extends CdsControl {
);
}

updated(props: Map<string, any>) {
updated(props: PropertyValues<any>) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are the others PropertyValues<this> but this one is PropertyValues<any>?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

super.updated(props);

if (props.has('indeterminate') && props.get('indeterminate') !== this.indeterminate && this.indeterminate) {
Expand Down
8 changes: 4 additions & 4 deletions packages/core/src/forms/control/control.element.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
/*
* Copyright (c) 2016-2021 VMware, Inc. All Rights Reserved.
* Copyright (c) 2016-2022 VMware, Inc. All Rights Reserved.
* This software is released under MIT license.
* The full license information can be found in LICENSE in the root directory of this project.
*/

import { html, LitElement, TemplateResult } from 'lit';
import { html, LitElement, TemplateResult, PropertyValues } from 'lit';
import { query } from 'lit/decorators/query.js';
import {
baseStyles,
Expand Down Expand Up @@ -282,7 +282,7 @@ export class CdsControl extends LitElement {
this.setAttribute('cds-control', '');
}

firstUpdated(props: Map<string, any>) {
firstUpdated(props: PropertyValues<this>) {
super.firstUpdated(props);
this.setupHostAttributes();
this.setupHTML5Validation();
Expand All @@ -293,7 +293,7 @@ export class CdsControl extends LitElement {
this.assignSlotIfInControlGroup();
}

updated(props: Map<string, any>) {
updated(props: PropertyValues<any>) {
super.updated(props);
this.messages.forEach(message => syncProps(message, this, { disabled: props.has('disabled') }));

Expand Down
8 changes: 4 additions & 4 deletions packages/core/src/forms/form-group/form-group.element.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
/*
* Copyright (c) 2016-2021 VMware, Inc. All Rights Reserved.
* Copyright (c) 2016-2022 VMware, Inc. All Rights Reserved.
* This software is released under MIT license.
* The full license information can be found in LICENSE in the root directory of this project.
*/

import { LitElement, html } from 'lit';
import { LitElement, html, PropertyValues } from 'lit';
import {
baseStyles,
querySlotAll,
Expand Down Expand Up @@ -97,14 +97,14 @@ export class CdsFormGroup extends LitElement {

private overflowElement: CdsControl | null;

firstUpdated(props: Map<string, any>) {
firstUpdated(props: PropertyValues<this>) {
super.firstUpdated(props);
this.syncLayouts();
this.setControlLabelWidths();
this.observers.push(elementVisible(this, () => this.setControlLabelWidths()));
}

updated(props: Map<string, any>) {
updated(props: PropertyValues<this>) {
super.updated(props);
syncDefinedProps(props, this, this.controlsAndGroups);
}
Expand Down
Loading