Skip to content

Commit

Permalink
refactor: fixup typescript errors
Browse files Browse the repository at this point in the history
  • Loading branch information
maxpatiiuk committed Sep 13, 2024
1 parent 81e2bbb commit 460c6e8
Show file tree
Hide file tree
Showing 19 changed files with 27 additions and 29 deletions.
8 changes: 7 additions & 1 deletion packages/calcite-components/src/components/button/button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,13 @@ export class Button
}}
disabled={childElType === "button" ? this.disabled || this.loading : null}
download={
childElType === "a" && (this.download === "" || this.download) ? this.download : null
childElType === "a"
? this.download === true
? ""
: this.download
? this.download
: null
: null
}
href={childElType === "a" && this.href}
name={childElType === "button" && this.name}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ import {
import { componentOnReady } from "../../utils/component";
import { SLOTS as PANEL_SLOTS } from "../panel/resources";
import { HeadingLevel } from "../functional/Heading";
import { OverlayPositioning } from "../../components";
import type { OverlayPositioning } from "../../utils/floating-ui";
import { DialogMessages } from "./assets/dialog/t9n";
import {
CSS,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { FunctionalComponent, h, VNode } from "@stencil/core";
import { JSXAttributes } from "@stencil/core/internal";
import { FloatingLayout } from "../../utils/floating-ui";

interface FloatingArrowProps extends JSXAttributes {
interface FloatingArrowProps extends JSXAttributes<SVGSVGElement> {
floatingLayout: FloatingLayout;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { newE2EPage } from "@stencil/core/testing";
import { accessible, disabled, hidden, renders, t9n } from "../../tests/commonTests";
import { HandleMessages } from "../../components";
import { CSS, SUBSTITUTIONS } from "./resources";
import type { HandleMessages } from "./assets/handle/t9n";

describe("calcite-handle", () => {
describe("renders", () => {
Expand Down
4 changes: 2 additions & 2 deletions packages/calcite-components/src/components/link/link.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ export class Link implements InteractiveComponent, LoadableComponent {
When the 'download' property of type 'boolean | string' is set to true, the value is "".
This works around that issue for now.
*/
download={Tag === "a" && (download === "" || download) ? download : null}
download={Tag === "a" ? (download === true ? "" : download ? download : null) : null}
href={Tag === "a" && this.href}
onClick={this.childElClickHandler}
ref={this.storeTagRef}
Expand Down Expand Up @@ -174,7 +174,7 @@ export class Link implements InteractiveComponent, LoadableComponent {
/** the rendered child element */
private childEl: HTMLAnchorElement | HTMLSpanElement;

private childElClickHandler = (event: PointerEvent): void => {
private childElClickHandler = (event: MouseEvent): void => {
if (!event.isTrusted) {
// click was invoked internally, we stop it here
event.stopPropagation();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -814,7 +814,7 @@ export class ListItem
this.calciteListItemToggle.emit();
};

private handleItemClick = (event: PointerEvent): void => {
private handleItemClick = (event: MouseEvent): void => {
if (event.defaultPrevented) {
return;
}
Expand Down
4 changes: 2 additions & 2 deletions packages/calcite-components/src/components/panel/panel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -700,7 +700,7 @@ export class Panel
};

render(): VNode {
const { disabled, loading, panelKeyDownHandler, isClosed } = this;
const { disabled, loading, isClosed } = this;

const panelNode = (
<article
Expand All @@ -718,7 +718,7 @@ export class Panel
);

return (
<Host onKeyDown={panelKeyDownHandler}>
<Host onKeyDown={this.panelKeyDownHandler}>
<InteractiveContainer disabled={disabled}>
{loading ? <calcite-scrim loading={loading} /> : null}
{panelNode}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ export class Popover

@State() defaultMessages: PopoverMessages;

arrowEl: SVGElement;
arrowEl: SVGSVGElement;

closeButtonEl: HTMLCalciteActionElement;

Expand Down Expand Up @@ -515,7 +515,7 @@ export class Popover
deactivateFocusTrap(this);
}

storeArrowEl = (el: SVGElement): void => {
storeArrowEl = (el: SVGSVGElement): void => {
this.arrowEl = el;
this.reposition(true);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ export class Rating
}
};

private handleInputChange = (event: InputEvent) => {
private handleInputChange = (event: Event) => {
if (this.isKeyboardInteraction === true) {
const inputVal = Number(event.target["value"]);
this.hoverValue = inputVal;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ export class Tooltip implements FloatingUIComponent, OpenCloseComponent {

@State() floatingLayout: FloatingLayout = "vertical";

arrowEl: SVGElement;
arrowEl: SVGSVGElement;

guid = `calcite-tooltip-${guid()}`;

Expand Down Expand Up @@ -344,7 +344,7 @@ export class Tooltip implements FloatingUIComponent, OpenCloseComponent {
>
<FloatingArrow
floatingLayout={floatingLayout}
ref={(arrowEl: SVGElement) => (this.arrowEl = arrowEl)}
ref={(arrowEl) => (this.arrowEl = arrowEl)}
/>
<div class={CSS.container}>
<slot />
Expand Down
5 changes: 2 additions & 3 deletions packages/calcite-components/src/demos/_assets/head.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@
};

const loadHeader = async (): Promise<void> => {
const root = window.location.pathname.split(DEMO_ROOT).shift();
const response = await window.fetch(`${root}${ASSETS_PATH}/demo-template.html`);
const response = await window.fetch(`${ROOT}${ASSETS_PATH}/demo-template.html`);
const text = await response.text();
const template = parseTemplate(text);
if (template) {
Expand All @@ -45,7 +44,7 @@
document.readyState === "loading" ? document.addEventListener("DOMContentLoaded", loadHeader) : loadHeader();
}

const ROOT = window.location.pathname.split(DEMO_ROOT).shift();
const ROOT = window.location.pathname.split(DEMO_ROOT)[0];

function loadCss(url: string): void {
const link = document.createElement("link");
Expand Down
2 changes: 0 additions & 2 deletions packages/calcite-components/src/demos/input-time-picker.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta http-equiv="X-UA-Compatible" content="ie=edge" />
<title>Input Time Picker</title>
<link rel="stylesheet" href="../build/calcite.css" />
<script type="module" src="../build/calcite.esm.js"></script>
<script src="./_assets/head.js"></script>
<style>
.demo-header {
Expand Down
2 changes: 0 additions & 2 deletions packages/calcite-components/src/demos/menu.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta http-equiv="X-UA-Compatible" content="ie=edge" />
<title>Calcite Menu / Calcite Menu Item</title>
<link rel="stylesheet" href="../build/calcite.css" />
<script type="module" src="../build/calcite.esm.js"></script>
<script src="_assets/head.js"></script>

<script src="https://js.arcgis.com/next/"></script>
Expand Down
2 changes: 0 additions & 2 deletions packages/calcite-components/src/demos/navigation.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta http-equiv="X-UA-Compatible" content="ie=edge" />
<title>Calcite Nav / Calcite Nav Logo / Calcite Nav User</title>
<link rel="stylesheet" href="../build/calcite.css" />
<script type="module" src="../build/calcite.esm.js"></script>
<script src="_assets/head.js"></script>

<script src="https://js.arcgis.com/next/"></script>
Expand Down
4 changes: 2 additions & 2 deletions packages/calcite-components/src/utils/floating-ui.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ export const positionFloatingUI =
flipPlacements?: FlipPlacement[];
offsetDistance?: number;
offsetSkidding?: number;
arrowEl?: SVGElement;
arrowEl?: SVGSVGElement;
type: UIType;
},
): Promise<void> => {
Expand Down Expand Up @@ -335,7 +335,7 @@ function getMiddleware({
flipPlacements?: EffectivePlacement[];
offsetDistance?: number;
offsetSkidding?: number;
arrowEl?: SVGElement;
arrowEl?: SVGSVGElement;
type: UIType;
}): Middleware[] {
const defaultMiddleware = [shift(), hide()];
Expand Down
3 changes: 2 additions & 1 deletion packages/calcite-components/src/utils/form.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { FunctionalComponent, h, VNode } from "@stencil/core";
import { Writable } from "type-fest";
import { IconNameOrString, Status } from "../components";
import { Status } from "../components/interfaces";
import type { IconNameOrString } from "../components/icon/interfaces";
import { closestElementCrossShadowBoundary, queryElementRoots } from "./dom";

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { SelectionMode } from "../components";
import { SelectionMode } from "../components/interfaces";

/**
* Defines interface for group components that manage selection behavior of their children.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { Rule } from "eslint";
// @ts-ignore
import { stencilComponentContext } from "stencil-eslint-core";

const rule: Rule.RuleModule = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { Rule } from "eslint";
// @ts-ignore
import { getDecorator, stencilComponentContext } from "stencil-eslint-core";

const rule: Rule.RuleModule = {
Expand Down

0 comments on commit 460c6e8

Please sign in to comment.