Skip to content

Commit fab4feb

Browse files
authored
chore: Apply transformations to make code compatible with 1P (#1655)
This PR applies safe, style-only, or best-practice transformations to the codebase, reducing the number of transformations needed when importing to 1P. It covers adding the override keyword, replacing external imports with relative ones, and explicitly typing TextField. The transformation related to stripping the accessor keyword was skipped as it is not an inherently backwards-compatible/style change. Next, I'll add enforcing lint enforcing so that we don't regress on this #1667
1 parent b8e87b0 commit fab4feb

27 files changed

Lines changed: 76 additions & 71 deletions

renderers/lit/src/v0_9/a2ui-lit-element.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import {LitElement, nothing} from 'lit';
1818
import {property} from 'lit/decorators.js';
1919
import {ComponentContext, ComponentApi, type ComponentId} from '@a2ui/web_core/v0_9';
2020
import {renderA2uiNode} from './surface/render-a2ui-node.js';
21-
import {A2uiController} from '@a2ui/lit/v0_9';
21+
import {A2uiController} from './a2ui-controller.js';
2222

2323
/**
2424
* A reference to a child component to render. Either a string ID, or an object
@@ -100,7 +100,7 @@ export abstract class A2uiLitElement<Api extends ComponentApi> extends LitElemen
100100
* cleans up any existing controller and invokes `createController()` to bind to
101101
* the new context.
102102
*/
103-
willUpdate(changedProperties: Map<string, any>) {
103+
override willUpdate(changedProperties: Map<string, any>) {
104104
super.willUpdate(changedProperties);
105105
if (changedProperties.has('context') && this.context) {
106106
if (this.controller) {

renderers/lit/src/v0_9/catalogs/basic/basic-catalog-a2ui-lit-element.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,12 @@ export type ResolvedChildList = ResolvedChildRef[];
3737
export abstract class BasicCatalogA2uiLitElement<
3838
Api extends ComponentApi,
3939
> extends A2uiLitElement<Api> {
40-
connectedCallback() {
40+
override connectedCallback() {
4141
super.connectedCallback();
4242
injectBasicCatalogStyles();
4343
}
4444

45-
willUpdate(changedProperties: Map<string, any>) {
45+
override willUpdate(changedProperties: Map<string, any>) {
4646
super.willUpdate(changedProperties);
4747

4848
const props = this.controller?.props as any;

renderers/lit/src/v0_9/catalogs/basic/components/AudioPlayer.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@ import {html, nothing, css} from 'lit';
1818
import {customElement} from 'lit/decorators.js';
1919
import {AudioPlayerApi} from '@a2ui/web_core/v0_9/basic_catalog';
2020
import {BasicCatalogA2uiLitElement} from '../basic-catalog-a2ui-lit-element.js';
21-
import {A2uiController} from '@a2ui/lit/v0_9';
21+
import {A2uiController} from '../../../a2ui-controller.js';
2222

2323
@customElement('a2ui-audioplayer')
2424
export class A2uiAudioPlayerElement extends BasicCatalogA2uiLitElement<typeof AudioPlayerApi> {
25-
static styles = css`
25+
static override styles = css`
2626
:host {
2727
display: flex;
2828
flex-direction: column;
@@ -37,7 +37,7 @@ export class A2uiAudioPlayerElement extends BasicCatalogA2uiLitElement<typeof Au
3737
return new A2uiController(this, AudioPlayerApi);
3838
}
3939

40-
render() {
40+
override render() {
4141
const props = this.controller.props;
4242
if (!props) return nothing;
4343

renderers/lit/src/v0_9/catalogs/basic/components/Button.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import {customElement} from 'lit/decorators.js';
1919
import {classMap} from 'lit/directives/class-map.js';
2020
import {ButtonApi} from '@a2ui/web_core/v0_9/basic_catalog';
2121
import {BasicCatalogA2uiLitElement} from '../basic-catalog-a2ui-lit-element.js';
22-
import {A2uiController} from '@a2ui/lit/v0_9';
22+
import {A2uiController} from '../../../a2ui-controller.js';
2323

2424
/**
2525
* A button component that can be used to trigger an action.
@@ -41,7 +41,7 @@ export class A2uiBasicButtonElement extends BasicCatalogA2uiLitElement<typeof Bu
4141
* - `--a2ui-button-padding`: The padding of the button. Defaults to `--a2ui-spacing-m`.
4242
* - `--a2ui-button-margin`: The outer margin of the button. Defaults to `--a2ui-spacing-m`.
4343
*/
44-
static styles = css`
44+
static override styles = css`
4545
:host {
4646
display: inline-block;
4747
margin: var(--a2ui-button-margin, var(--a2ui-spacing-m));
@@ -95,7 +95,7 @@ export class A2uiBasicButtonElement extends BasicCatalogA2uiLitElement<typeof Bu
9595
return new A2uiController(this, ButtonApi);
9696
}
9797

98-
render() {
98+
override render() {
9999
const props = this.controller.props;
100100
if (!props) return nothing;
101101

renderers/lit/src/v0_9/catalogs/basic/components/Card.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import {html, nothing, css} from 'lit';
1818
import {customElement} from 'lit/decorators.js';
1919
import {CardApi} from '@a2ui/web_core/v0_9/basic_catalog';
2020
import {BasicCatalogA2uiLitElement} from '../basic-catalog-a2ui-lit-element.js';
21-
import {A2uiController} from '@a2ui/lit/v0_9';
21+
import {A2uiController} from '../../../a2ui-controller.js';
2222

2323
@customElement('a2ui-card')
2424
export class A2uiCardElement extends BasicCatalogA2uiLitElement<typeof CardApi> {
@@ -32,7 +32,7 @@ export class A2uiCardElement extends BasicCatalogA2uiLitElement<typeof CardApi>
3232
* - `--a2ui-card-box-shadow`: The box shadow of the card. Defaults to `0 2px 4px rgba(0,0,0,0.1)`.
3333
* - `--a2ui-card-margin`: The outer margin of the card. Defaults to `--a2ui-spacing-m`.
3434
*/
35-
static styles = css`
35+
static override styles = css`
3636
:host {
3737
display: block;
3838
border: var(
@@ -52,7 +52,7 @@ export class A2uiCardElement extends BasicCatalogA2uiLitElement<typeof CardApi>
5252
return new A2uiController(this, CardApi);
5353
}
5454

55-
render() {
55+
override render() {
5656
const props = this.controller.props;
5757
if (!props) return nothing;
5858

renderers/lit/src/v0_9/catalogs/basic/components/CheckBox.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import {customElement} from 'lit/decorators.js';
1919
import {classMap} from 'lit/directives/class-map.js';
2020
import {CheckBoxApi} from '@a2ui/web_core/v0_9/basic_catalog';
2121
import {BasicCatalogA2uiLitElement} from '../basic-catalog-a2ui-lit-element.js';
22-
import {A2uiController} from '@a2ui/lit/v0_9';
22+
import {A2uiController} from '../../../a2ui-controller.js';
2323

2424
@customElement('a2ui-checkbox')
2525
export class A2uiCheckBoxElement extends BasicCatalogA2uiLitElement<typeof CheckBoxApi> {
@@ -35,7 +35,7 @@ export class A2uiCheckBoxElement extends BasicCatalogA2uiLitElement<typeof Check
3535
* - `--a2ui-checkbox-label-font-size`: Font size of the label. Defaults to `--a2ui-label-font-size` then `--a2ui-font-size-s`.
3636
* - `--a2ui-checkbox-label-font-weight`: Font weight of the label. Defaults to `--a2ui-label-font-weight` then `bold`.
3737
*/
38-
static styles = css`
38+
static override styles = css`
3939
:host {
4040
display: block;
4141
}
@@ -79,7 +79,7 @@ export class A2uiCheckBoxElement extends BasicCatalogA2uiLitElement<typeof Check
7979
return new A2uiController(this, CheckBoxApi);
8080
}
8181

82-
render() {
82+
override render() {
8383
const props = this.controller.props;
8484
if (!props) return nothing;
8585

renderers/lit/src/v0_9/catalogs/basic/components/ChoicePicker.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import {customElement, state} from 'lit/decorators.js';
1919
import {classMap} from 'lit/directives/class-map.js';
2020
import {ChoicePickerApi} from '@a2ui/web_core/v0_9/basic_catalog';
2121
import {BasicCatalogA2uiLitElement} from '../basic-catalog-a2ui-lit-element.js';
22-
import {A2uiController} from '@a2ui/lit/v0_9';
22+
import {A2uiController} from '../../../a2ui-controller.js';
2323

2424
@customElement('a2ui-choicepicker')
2525
export class A2uiChoicePickerElement extends BasicCatalogA2uiLitElement<typeof ChoicePickerApi> {
@@ -35,7 +35,7 @@ export class A2uiChoicePickerElement extends BasicCatalogA2uiLitElement<typeof C
3535
* - `--a2ui-choicepicker-chip-padding`: Padding for chips. Defaults to `--a2ui-spacing-s` and `--a2ui-spacing-m` (4px 8px).
3636
* - `--a2ui-choicepicker-chip-border-radius`: Border radius for chips. Defaults to `999px`.
3737
*/
38-
static styles = css`
38+
static override styles = css`
3939
:host {
4040
display: flex;
4141
flex-direction: column;
@@ -105,7 +105,7 @@ export class A2uiChoicePickerElement extends BasicCatalogA2uiLitElement<typeof C
105105
return new A2uiController(this, ChoicePickerApi);
106106
}
107107

108-
render() {
108+
override render() {
109109
const props = this.controller.props;
110110
if (!props) return nothing;
111111

renderers/lit/src/v0_9/catalogs/basic/components/Column.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import {
2222
BasicCatalogA2uiLitElement,
2323
type ResolvedChildList,
2424
} from '../basic-catalog-a2ui-lit-element.js';
25-
import {A2uiController} from '@a2ui/lit/v0_9';
25+
import {A2uiController} from '../../../a2ui-controller.js';
2626

2727
const JUSTIFY_MAP: Record<string, string> = {
2828
start: 'flex-start',
@@ -49,7 +49,7 @@ export class A2uiBasicColumnElement extends BasicCatalogA2uiLitElement<typeof Co
4949
*
5050
* - `--a2ui-column-gap`: The gap between items in the column. Defaults to `--a2ui-spacing-m`.
5151
*/
52-
static styles = css`
52+
static override styles = css`
5353
:host {
5454
display: flex;
5555
flex-direction: column;
@@ -61,7 +61,7 @@ export class A2uiBasicColumnElement extends BasicCatalogA2uiLitElement<typeof Co
6161
return new A2uiController(this, ColumnApi);
6262
}
6363

64-
updated(changedProperties: PropertyValues) {
64+
override updated(changedProperties: PropertyValues) {
6565
super.updated(changedProperties);
6666
const props = this.controller.props;
6767
if (props) {
@@ -70,7 +70,7 @@ export class A2uiBasicColumnElement extends BasicCatalogA2uiLitElement<typeof Co
7070
}
7171
}
7272

73-
render() {
73+
override render() {
7474
const props = this.controller.props;
7575
if (!props) return nothing;
7676

renderers/lit/src/v0_9/catalogs/basic/components/DateTimeInput.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import {html, nothing, css} from 'lit';
1818
import {customElement} from 'lit/decorators.js';
1919
import {DateTimeInputApi} from '@a2ui/web_core/v0_9/basic_catalog';
2020
import {BasicCatalogA2uiLitElement} from '../basic-catalog-a2ui-lit-element.js';
21-
import {A2uiController} from '@a2ui/lit/v0_9';
21+
import {A2uiController} from '../../../a2ui-controller.js';
2222

2323
/**
2424
* Normalizes an incoming ISO or partial date/time value into a format accepted by HTML5 inputs.
@@ -60,7 +60,7 @@ export class A2uiDateTimeInputElement extends BasicCatalogA2uiLitElement<typeof
6060
* - `--a2ui-datetimeinput-label-font-size`: Font size of the label. Defaults to `--a2ui-label-font-size` then `--a2ui-font-size-s`.
6161
* - `--a2ui-datetimeinput-label-font-weight`: Font weight of the label. Defaults to `--a2ui-label-font-weight` then `bold`.
6262
*/
63-
static styles = css`
63+
static override styles = css`
6464
:host {
6565
display: flex;
6666
flex-direction: column;
@@ -86,7 +86,7 @@ export class A2uiDateTimeInputElement extends BasicCatalogA2uiLitElement<typeof
8686
return new A2uiController(this, DateTimeInputApi);
8787
}
8888

89-
render() {
89+
override render() {
9090
const props = this.controller.props;
9191
if (!props) return nothing;
9292
// If neither date or time are enabled, render nothing.

renderers/lit/src/v0_9/catalogs/basic/components/Divider.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import {html, nothing, css} from 'lit';
1818
import {customElement} from 'lit/decorators.js';
1919
import {classMap} from 'lit/directives/class-map.js';
2020
import {DividerApi} from '@a2ui/web_core/v0_9/basic_catalog';
21-
import {A2uiController} from '@a2ui/lit/v0_9';
21+
import {A2uiController} from '../../../a2ui-controller.js';
2222
import {BasicCatalogA2uiLitElement} from '../basic-catalog-a2ui-lit-element.js';
2323

2424
@customElement('a2ui-divider')
@@ -30,7 +30,7 @@ export class A2uiDividerElement extends BasicCatalogA2uiLitElement<typeof Divide
3030
* - `--a2ui-divider-border`: The styling for the divider border. Defaults to `--a2ui-border-width` solid `--a2ui-color-border`.
3131
* - `--a2ui-divider-spacing`: The spacing around the divider. Defaults to `--a2ui-spacing-m`.
3232
*/
33-
static styles = css`
33+
static override styles = css`
3434
:host {
3535
display: block;
3636
align-self: stretch;
@@ -60,7 +60,7 @@ export class A2uiDividerElement extends BasicCatalogA2uiLitElement<typeof Divide
6060
return new A2uiController(this, DividerApi);
6161
}
6262

63-
render() {
63+
override render() {
6464
const props = this.controller.props;
6565
if (!props) return nothing;
6666

0 commit comments

Comments
 (0)