@profidev/pleiades 1.9.1 → 1.9.2

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.
@@ -8,7 +8,7 @@ export interface RequestOptions {
8
8
  }
9
9
  export declare const patch: <T = undefined>(path: string, options?: RequestOptions) => Promise<T | RequestError>;
10
10
  export declare const put: <T = undefined>(path: string, options?: RequestOptions) => Promise<T | RequestError>;
11
- export declare const delete_: <T = undefined>(path: string, options?: RequestOptions) => Promise<T | RequestError>;
11
+ export declare const delete_req: <T = undefined>(path: string, options?: RequestOptions) => Promise<T | RequestError>;
12
12
  export declare const post: <T = undefined>(path: string, options?: RequestOptions) => Promise<T | RequestError>;
13
13
  export declare const get: <T = undefined>(path: string, options?: Omit<RequestOptions, "body">) => Promise<T | RequestError>;
14
14
  export declare const request: <T = undefined>(path: string, method: string, { res_type, body, content_type, signal, fetch }?: RequestOptions) => Promise<T | RequestError>;
@@ -1,36 +1,36 @@
1
1
  import { RequestError, ResponseType } from './types.svelte';
2
2
  export const patch = async (path, options = {}) => await request(path, 'PATCH', options);
3
3
  export const put = async (path, options = {}) => await request(path, 'PUT', options);
4
- export const delete_ = async (path, options = {}) => await request(path, 'DELETE', options);
4
+ export const delete_req = async (path, options = {}) => await request(path, 'DELETE', options);
5
5
  export const post = async (path, options = {}) => await request(path, 'POST', options);
6
6
  export const get = async (path, options = {}) => await request(path, 'GET', options);
7
7
  // oxlint-disable-next-line complexity
8
8
  export const request = async (path, method, { res_type, body, content_type, signal, fetch } = {}) => {
9
- const res_type_ = res_type ?? ResponseType.None;
10
- let content_type_ = content_type;
11
- let body_ = body;
12
- if (body_ instanceof ArrayBuffer) {
13
- content_type_ = 'application/octet-stream';
9
+ const res_type_inner = res_type ?? ResponseType.None;
10
+ let content_type_inner = content_type;
11
+ let body_inner = body;
12
+ if (body_inner instanceof ArrayBuffer) {
13
+ content_type_inner = 'application/octet-stream';
14
14
  }
15
- else if (body_ instanceof Blob) {
16
- content_type_ = body_.type;
17
- body_ = body_.stream();
15
+ else if (body_inner instanceof Blob) {
16
+ content_type_inner = body_inner.type;
17
+ body_inner = body_inner.stream();
18
18
  }
19
- else if (typeof body_ === 'string') {
20
- content_type_ = 'text/plain';
19
+ else if (typeof body_inner === 'string') {
20
+ content_type_inner = 'text/plain';
21
21
  }
22
- else if (typeof body_ === 'object' && body_ !== null) {
23
- content_type_ = 'application/json';
24
- body_ = JSON.stringify(body_);
22
+ else if (typeof body_inner === 'object' && body_inner !== null) {
23
+ content_type_inner = 'application/json';
24
+ body_inner = JSON.stringify(body_inner);
25
25
  }
26
26
  const headers = {};
27
- if (content_type_) {
28
- headers['Content-Type'] = content_type_;
27
+ if (content_type_inner) {
28
+ headers['Content-Type'] = content_type_inner;
29
29
  }
30
- const fetch_ = fetch ?? globalThis.fetch;
30
+ const fetch_inner = fetch ?? globalThis.fetch;
31
31
  try {
32
- const res = await fetch_(path, {
33
- body: body_,
32
+ const res = await fetch_inner(path, {
33
+ body: body_inner,
34
34
  headers,
35
35
  method,
36
36
  signal
@@ -97,7 +97,7 @@ export const request = async (path, method, { res_type, body, content_type, sign
97
97
  return RequestError.Other;
98
98
  }
99
99
  }
100
- switch (res_type_) {
100
+ switch (res_type_inner) {
101
101
  case ResponseType.Json: {
102
102
  const json = await res.json();
103
103
  // oxlint-disable-next-line no-unsafe-type-assertion
@@ -1,30 +1,24 @@
1
1
  <script lang="ts">
2
2
  import KeyRound from '@lucide/svelte/icons/key-round';
3
3
  import LoaderCircle from '@lucide/svelte/icons/loader-circle';
4
+ import RotateCcw from '@lucide/svelte/icons/rotate-ccw';
4
5
  import { Button } from '../ui/button/index.js';
6
+ import { FieldSeparator } from '../ui/field/index.js';
5
7
 
6
8
  interface Props {
7
9
  isLoading: boolean;
8
10
  passkeyClick: () => void;
9
- passkeyError: string;
11
+ passkeyError: boolean;
10
12
  }
11
13
 
12
14
  let { isLoading, passkeyClick, passkeyError }: Props = $props();
13
15
  </script>
14
16
 
15
- <div class="relative">
16
- <div class="absolute inset-0 flex items-center">
17
- <span class="w-full border-t"></span>
18
- </div>
19
- <div class="relative flex justify-center text-xs uppercase">
20
- <span class="text-muted-foreground px-2">Or continue with </span>
21
- </div>
22
- </div>
23
- {#if passkeyError !== ''}
24
- <span class="text-destructive truncate text-sm">{passkeyError}</span>
25
- {/if}
17
+ <FieldSeparator class="*:data-[slot=field-separator-content]:bg-card my-4"
18
+ >Or continue with</FieldSeparator
19
+ >
26
20
  <Button
27
- variant="outline"
21
+ variant={passkeyError ? 'destructive' : 'outline'}
28
22
  type="button"
29
23
  disabled={isLoading}
30
24
  onclick={passkeyClick}
@@ -32,8 +26,10 @@
32
26
  >
33
27
  {#if isLoading}
34
28
  <LoaderCircle class="mr-2 h-4 w-4 animate-spin" />
29
+ {:else if passkeyError}
30
+ <RotateCcw />
35
31
  {:else}
36
32
  <KeyRound class="mr-2 h-4 w-4" />
37
33
  {/if}
38
- Passkey
34
+ {passkeyError ? 'Retry Passkey' : 'Passkey'}
39
35
  </Button>
@@ -1,7 +1,7 @@
1
1
  interface Props {
2
2
  isLoading: boolean;
3
3
  passkeyClick: () => void;
4
- passkeyError: string;
4
+ passkeyError: boolean;
5
5
  }
6
6
  declare const LoginOtherOptions: import("svelte").Component<Props, {}, "">;
7
7
  type LoginOtherOptions = ReturnType<typeof LoginOtherOptions>;
@@ -4,6 +4,7 @@
4
4
  import Ban from '@lucide/svelte/icons/ban';
5
5
  import CheckIcon from '@lucide/svelte/icons/check';
6
6
  import Plus from '@lucide/svelte/icons/plus';
7
+ import RotateCCW from '@lucide/svelte/icons/rotate-ccw';
7
8
  import { Badge } from '../ui/badge';
8
9
  import { Button } from '../ui/button';
9
10
  import * as Card from '../ui/card';
@@ -22,6 +23,7 @@
22
23
  ) => Error<any> | undefined | void | Promise<Error<any> | undefined | void>;
23
24
  data?: T;
24
25
  submitLabel?: string;
26
+ retryLabel?: string;
25
27
  submitIcon?: Component;
26
28
  cancelHref: string;
27
29
  }
@@ -32,7 +34,8 @@
32
34
  data = undefined as T,
33
35
  submitLabel = 'Create',
34
36
  submitIcon: SubmitIcon = Plus,
35
- cancelHref
37
+ cancelHref,
38
+ retryLabel = 'Retry'
36
39
  }: Props<T> = $props();
37
40
 
38
41
  let stage = $state(0);
@@ -96,7 +99,7 @@
96
99
  bind:isLoading
97
100
  {data}
98
101
  >
99
- {#snippet footer({ isLoading })}
102
+ {#snippet footer({ isLoading, isError })}
100
103
  <Card.Footer
101
104
  class="w-full gap-2 border-none bg-transparent px-0 pt-0"
102
105
  >
@@ -124,11 +127,18 @@
124
127
  <Ban />
125
128
  Cancel
126
129
  </Button>
127
- <Button class="cursor-pointer" type="submit" disabled={isLoading}>
130
+ <Button
131
+ class="cursor-pointer"
132
+ type="submit"
133
+ disabled={isLoading}
134
+ variant={isError ? 'destructive' : undefined}
135
+ >
128
136
  {#if stage === stages.length - 1}
129
- {submitLabel}
137
+ {isError ? retryLabel : submitLabel}
130
138
  {#if isLoading}
131
139
  <Spinner />
140
+ {:else if isError}
141
+ <RotateCCW />
132
142
  {:else}
133
143
  <SubmitIcon />
134
144
  {/if}
@@ -5,6 +5,7 @@ interface Props<T> {
5
5
  onsubmit: (data: object) => Error<any> | undefined | void | Promise<Error<any> | undefined | void>;
6
6
  data?: T;
7
7
  submitLabel?: string;
8
+ retryLabel?: string;
8
9
  submitIcon?: Component;
9
10
  cancelHref: string;
10
11
  }
@@ -13,9 +13,10 @@ export interface Error<V extends ZodValidationSchema> {
13
13
  export type FormEnctype = 'application/x-www-form-urlencoded' | 'multipart/form-data' | 'text/plain' | undefined | null;
14
14
  export interface StageProps<T = undefined> {
15
15
  initialValue?: any;
16
- onsubmit: ComponentProps<typeof BaseForm>['onsubmit'];
16
+ onsubmit: ComponentProps<BaseForm<any>>['onsubmit'];
17
17
  footer: Snippet<[{
18
18
  isLoading: boolean;
19
+ isError: boolean;
19
20
  }]>;
20
21
  isLoading: boolean;
21
22
  data: T;
@@ -29,7 +29,11 @@
29
29
  const current = (filteredItems: NavGroup[]) =>
30
30
  filteredItems
31
31
  .flatMap((group) => group.items)
32
- .filter((item) => page.url.pathname.startsWith(item.href))
32
+ .filter(
33
+ (item) =>
34
+ (page.url.pathname.startsWith(item.href) && item.href !== '/') ||
35
+ item.href === page.url.pathname
36
+ )
33
37
  .sort((a, b) => b.href.length - a.href.length)[0] ?? undefined;
34
38
  </script>
35
39
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@profidev/pleiades",
3
- "version": "1.9.1",
3
+ "version": "1.9.2",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/Profiidev/pleiades"