Skip to content

Commit 3ec8bf0

Browse files
GirlBossRushBeryJu
authored andcommitted
web: Normalize use of toJSON.
1 parent 00639d9 commit 3ec8bf0

File tree

11 files changed

+14
-23
lines changed

11 files changed

+14
-23
lines changed

web/src/admin/admin-settings/AdminSettingsFooterLinks.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ export class FooterLinkInput extends AKControlElement<FooterLink> {
5353
}
5454

5555
get valid() {
56-
const href = this.json()?.href ?? "";
56+
const href = this.toJSON()?.href ?? "";
5757
return hasLegalScheme(href) && URL.canParse(href);
5858
}
5959

web/src/admin/admin-settings/stories/AdminSettingsFooterLinks.stories.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ const metadata: Meta<FooterLinkInput> = {
3434
return;
3535
}
3636
const target = event.target as FooterLinkInput;
37-
messages!.innerText = `${JSON.stringify(target.json(), null, 2)}\n\nValid: ${target.valid ? "Yes" : "No"}`;
37+
messages!.innerText = `${JSON.stringify(target.toJSON(), null, 2)}\n\nValid: ${target.valid ? "Yes" : "No"}`;
3838
});
3939
}, 250);
4040

web/src/admin/admin-settings/stories/ak-array-input.stories.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ const metadata: Meta<IArrayInput<unknown>> = {
4040
return;
4141
}
4242
const target = event.target as FooterLinkInput;
43-
messages!.innerText = `${JSON.stringify(target.json(), null, 2)}\n\nValid: ${target.valid ? "Yes" : "No"}`;
43+
messages!.innerText = `${JSON.stringify(target.toJSON(), null, 2)}\n\nValid: ${target.valid ? "Yes" : "No"}`;
4444
});
4545
}, 250);
4646

web/src/admin/applications/wizard/steps/ak-application-wizard-bindings-step.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ export class ApplicationWizardBindingsStep extends ApplicationWizardStep {
9696

9797
protected onDeleteBindings() {
9898
const toDelete = this.selectTable
99-
.json()
99+
.toJSON()
100100
.map((i) => (typeof i === "string" ? parseInt(i, 10) : i));
101101
const bindings = this.wizard.bindings.filter((binding, index) => !toDelete.includes(index));
102102

web/src/components/ak-multi-select.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ export class AkMultiSelect extends AKControlElement {
8383
* control that produces values of specific interest to our REST API. This is our modern
8484
* accessor name.
8585
*/
86-
json() {
86+
toJSON() {
8787
return this.values;
8888
}
8989

web/src/components/stories/ak-multi-select.stories.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ export const RadioInput = () => {
6060
</ul>
6161
<p>Results from component:</p>
6262
<ul style="list-style-type: disc">
63-
${component!.json().map((v: string) => html`<li>${v}</li>`)}
63+
${component!.toJSON().map((v: string) => html`<li>${v}</li>`)}
6464
</ul>
6565
`;
6666

web/src/elements/ControlElement.ts

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,19 +21,10 @@ export abstract class AKControlElement<T = string | string[]>
2121

2222
public abstract name: string | null;
2323

24-
/**
25-
* @deprecated Rename to `toJSON`
26-
*/
27-
public json(): T {
28-
throw new Error("Controllers using this protocol must override this method");
29-
}
30-
3124
/**
3225
* Convert the value of the control to a JSON-serializable format.
3326
*/
34-
public toJSON(): T {
35-
return this.json();
36-
}
27+
public abstract toJSON(): T;
3728

3829
public get valid(): boolean {
3930
return true;

web/src/elements/ak-array-input.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ export class ArrayInput<T> extends AKControlElement<T[]> implements IArrayInput<
9090
@queryAll("div.ak-input-group")
9191
inputGroups?: HTMLDivElement[];
9292

93-
json() {
93+
toJSON() {
9494
if (!this.inputGroups) {
9595
throw new Error("Could not find input group collection in ak-array-input");
9696
}
@@ -112,8 +112,9 @@ export class ArrayInput<T> extends AKControlElement<T[]> implements IArrayInput<
112112
return Array.from(this.inputGroups ?? [])
113113
.map(
114114
(group) =>
115-
group.querySelector<HTMLInputElement & AKControlElement<T>>("[name]")?.json() ??
116-
null,
115+
group
116+
.querySelector<HTMLInputElement & AKControlElement<T>>("[name]")
117+
?.toJSON() ?? null,
117118
)
118119
.filter((i) => i !== null);
119120
}

web/src/elements/ak-table/ak-select-table.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ export class SelectTable extends SimpleTable {
124124
return this._selected;
125125
}
126126

127-
public json() {
127+
public toJSON() {
128128
return this._selected;
129129
}
130130

web/src/elements/dialogs/dialog.css

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
--ak-c-dialog--WidthBasis: 100%;
1111
--ak-c-dialog--HeightBasis: 75dvh;
12+
--ak-c-dialog--HeightBasis: clamp(75dvh, 40rem, 95dvh);
1213

1314
--ak-c-dialog--MarginBlock: var(--pf-global--spacer--xl);
1415
--ak-c-dialog--MarginInline: var(--pf-global--spacer--4xl);
@@ -221,7 +222,6 @@
221222

222223
@media (width <= 768px) or (height <= 600px) {
223224
--ak-c-dialog--MaxHeight: 100dvh;
224-
--ak-c-dialog--AspectRatioHeight: none;
225225
/* Note that a unit is required for to perform the calculation. */
226226
--ak-c-dialog--MarginBlock: 0em;
227227
--ak-c-dialog--MarginInline: 0em;
@@ -231,7 +231,6 @@
231231

232232
.ak-m-dialog--full-screen {
233233
--ak-c-dialog--MaxHeight: 100dvh;
234-
--ak-c-dialog--AspectRatioHeight: none;
235234
/* Note that a unit is required for to perform the calculation. */
236235
--ak-c-dialog--MarginBlock: 0em;
237236
--ak-c-dialog--MarginInline: 0em;

0 commit comments

Comments
 (0)