@cal.macconnachie/web-components 0.0.9 → 0.0.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +8 -8
- package/dist/components/auth.js +1 -1
- package/dist/components/index.d.ts +17 -3
- package/dist/components/theme-toggle.js +1 -1
- package/dist/index.d.ts +17 -3
- package/dist/index.js +2763 -955
- package/package.json +2 -1
package/README.md
CHANGED
|
@@ -34,14 +34,14 @@ Then create a type declaration file for TypeScript support:
|
|
|
34
34
|
|
|
35
35
|
```typescript
|
|
36
36
|
// src/types/auth.d.ts
|
|
37
|
-
export interface
|
|
37
|
+
export interface Auth extends HTMLElement {
|
|
38
38
|
openModal(): void;
|
|
39
39
|
logout(): void;
|
|
40
40
|
}
|
|
41
41
|
|
|
42
42
|
declare global {
|
|
43
43
|
interface HTMLElementTagNameMap {
|
|
44
|
-
'auth':
|
|
44
|
+
'auth': Auth;
|
|
45
45
|
}
|
|
46
46
|
}
|
|
47
47
|
```
|
|
@@ -57,9 +57,9 @@ Now you can use it with full type safety in your components:
|
|
|
57
57
|
|
|
58
58
|
<script setup lang="ts">
|
|
59
59
|
import { ref } from 'vue';
|
|
60
|
-
import type {
|
|
60
|
+
import type { Auth } from '@/types/auth';
|
|
61
61
|
|
|
62
|
-
const authRef = ref<
|
|
62
|
+
const authRef = ref<Auth>();
|
|
63
63
|
|
|
64
64
|
const openAuth = () => {
|
|
65
65
|
authRef.value?.openModal();
|
|
@@ -70,10 +70,10 @@ const openAuth = () => {
|
|
|
70
70
|
**React:**
|
|
71
71
|
```tsx
|
|
72
72
|
import { useRef } from 'react';
|
|
73
|
-
import type {
|
|
73
|
+
import type { Auth } from '@/types/auth';
|
|
74
74
|
|
|
75
75
|
function App() {
|
|
76
|
-
const authRef = useRef<
|
|
76
|
+
const authRef = useRef<Auth>(null);
|
|
77
77
|
|
|
78
78
|
return (
|
|
79
79
|
<>
|
|
@@ -112,9 +112,9 @@ document.getElementById('logout-auth')?.addEventListener('click', () => {
|
|
|
112
112
|
|
|
113
113
|
TypeScript:
|
|
114
114
|
```typescript
|
|
115
|
-
import type {
|
|
115
|
+
import type { Auth } from 'https://cdn.cals-api.com/components/auth.js';
|
|
116
116
|
|
|
117
|
-
const auth = document.querySelector<
|
|
117
|
+
const auth = document.querySelector<Auth>('auth');
|
|
118
118
|
|
|
119
119
|
document.getElementById('open-auth')?.addEventListener('click', () => {
|
|
120
120
|
auth?.openModal();
|
package/dist/components/auth.js
CHANGED
|
@@ -1,12 +1,18 @@
|
|
|
1
|
+
import { AxiosInstance } from 'axios';
|
|
1
2
|
import { CSSResult } from 'lit';
|
|
2
3
|
import { LitElement } from 'lit';
|
|
3
4
|
import { nothing } from 'lit';
|
|
4
5
|
import { PropertyValues } from 'lit';
|
|
5
6
|
import { TemplateResult } from 'lit-html';
|
|
6
7
|
|
|
7
|
-
declare
|
|
8
|
+
export declare const apiClient: ({ baseUrl, apiBaseUrl }: ApiClientConfig) => AxiosInstance;
|
|
8
9
|
|
|
9
|
-
|
|
10
|
+
declare interface ApiClientConfig {
|
|
11
|
+
baseUrl: string;
|
|
12
|
+
apiBaseUrl?: string;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export declare class Auth extends LitElement {
|
|
10
16
|
open: boolean;
|
|
11
17
|
initialMode: AuthMode;
|
|
12
18
|
logoUrl: string;
|
|
@@ -110,7 +116,15 @@ export declare class CalsAuth extends LitElement {
|
|
|
110
116
|
static styles: CSSResult;
|
|
111
117
|
}
|
|
112
118
|
|
|
113
|
-
|
|
119
|
+
declare type AuthMode = 'signin' | 'signup';
|
|
120
|
+
|
|
121
|
+
export declare class AuthRefreshError extends Error {
|
|
122
|
+
constructor(message?: string);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
export declare const createApiClient: ({ baseUrl, apiBaseUrl }: ApiClientConfig) => AxiosInstance;
|
|
126
|
+
|
|
127
|
+
export declare class ThemeToggle extends LitElement {
|
|
114
128
|
theme: 'light' | 'dark';
|
|
115
129
|
storageKey: string;
|
|
116
130
|
size: 'sm' | 'md' | 'lg';
|
package/dist/index.d.ts
CHANGED
|
@@ -1,12 +1,18 @@
|
|
|
1
|
+
import { AxiosInstance } from 'axios';
|
|
1
2
|
import { CSSResult } from 'lit';
|
|
2
3
|
import { LitElement } from 'lit';
|
|
3
4
|
import { nothing } from 'lit';
|
|
4
5
|
import { PropertyValues } from 'lit';
|
|
5
6
|
import { TemplateResult } from 'lit-html';
|
|
6
7
|
|
|
7
|
-
declare
|
|
8
|
+
export declare const apiClient: ({ baseUrl, apiBaseUrl }: ApiClientConfig) => AxiosInstance;
|
|
8
9
|
|
|
9
|
-
|
|
10
|
+
declare interface ApiClientConfig {
|
|
11
|
+
baseUrl: string;
|
|
12
|
+
apiBaseUrl?: string;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export declare class Auth extends LitElement {
|
|
10
16
|
open: boolean;
|
|
11
17
|
initialMode: AuthMode;
|
|
12
18
|
logoUrl: string;
|
|
@@ -110,7 +116,15 @@ export declare class CalsAuth extends LitElement {
|
|
|
110
116
|
static styles: CSSResult;
|
|
111
117
|
}
|
|
112
118
|
|
|
113
|
-
|
|
119
|
+
declare type AuthMode = 'signin' | 'signup';
|
|
120
|
+
|
|
121
|
+
export declare class AuthRefreshError extends Error {
|
|
122
|
+
constructor(message?: string);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
export declare const createApiClient: ({ baseUrl, apiBaseUrl }: ApiClientConfig) => AxiosInstance;
|
|
126
|
+
|
|
127
|
+
export declare class ThemeToggle extends LitElement {
|
|
114
128
|
theme: 'light' | 'dark';
|
|
115
129
|
storageKey: string;
|
|
116
130
|
size: 'sm' | 'md' | 'lg';
|