@reqquest/ui 1.7.1 → 1.8.0

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.
@@ -0,0 +1,22 @@
1
+ <script lang="ts">
2
+ import type { Loader } from "../registry"
3
+ import ApplicantPromptSkeleton from "../../internal/components/ApplicantPromptSkeleton.svelte"
4
+
5
+ export let loader: Loader
6
+
7
+ const wait = () => {
8
+ return new Promise((resolve) => {
9
+ setTimeout(resolve, typeof loader === 'boolean' ? 0 : loader?.delay ?? 0)
10
+ })
11
+ }
12
+ </script>
13
+
14
+ {#await wait()}
15
+ <!-- Nothing displayed if delayed, expecting content to load quickly -->
16
+ {:then}
17
+ {#if typeof loader === 'boolean'}
18
+ <ApplicantPromptSkeleton />
19
+ {:else}
20
+ <svelte:component this={loader.skeletonComponent} />
21
+ {/if}
22
+ {/await}
@@ -0,0 +1,21 @@
1
+ import type { Loader } from "../registry";
2
+ interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> = any, Events extends Record<string, any> = any, Slots extends Record<string, any> = any, Exports = {}, Bindings = string> {
3
+ new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
4
+ $$bindings?: Bindings;
5
+ } & Exports;
6
+ (internal: unknown, props: Props & {
7
+ $$events?: Events;
8
+ $$slots?: Slots;
9
+ }): Exports & {
10
+ $set?: any;
11
+ $on?: any;
12
+ };
13
+ z_$$bindings?: Bindings;
14
+ }
15
+ declare const DelayedSkeleton: $$__sveltets_2_IsomorphicComponent<{
16
+ loader: Loader;
17
+ }, {
18
+ [evt: string]: CustomEvent<any>;
19
+ }, {}, {}, string>;
20
+ type DelayedSkeleton = InstanceType<typeof DelayedSkeleton>;
21
+ export default DelayedSkeleton;
@@ -10,7 +10,7 @@
10
10
  export let externalLinks: { url: string, label: string, target?: string, rel?: string }[] = []
11
11
 
12
12
  /**
13
- * If true, the form will take the full width of its container. If false, it will be constrained to max-w-screen-md.
13
+ * If true, the form will take the full width of its container. If false, it will be constrained to max-w-[800px].
14
14
  * @type {boolean}
15
15
  */
16
16
  export let fullWidth = false
@@ -30,12 +30,12 @@
30
30
  $: effectiveIntroAlignment = introTextAlignment ?? align
31
31
  </script>
32
32
  {#if $$slots.intro}
33
- <div id="questionnaire-intro" class="prompt-intro flow max-w-screen-md px-px-3 sm:px-6" class:mx-auto={align === 'center'} class:text-center={effectiveIntroAlignment === 'center'} class:text-right={effectiveIntroAlignment === 'right'} style:color="var(--cds-text-02)">
33
+ <div id="questionnaire-intro" class="prompt-intro flow max-w-[800px] px-px-3 sm:px-6" class:mx-auto={align === 'center'} class:text-center={effectiveIntroAlignment === 'center'} class:text-right={effectiveIntroAlignment === 'right'} style:color="var(--cds-text-02)">
34
34
  <slot name="intro" />
35
35
  </div>
36
36
  {/if}
37
37
  {#if externalLinks.length > 0}
38
- <div class="prompt-intro-links flow max-w-screen-md px-3 sm:px-6" class:mx-auto={align === 'center'}>
38
+ <div class="prompt-intro-links flow max-w-[800px] px-3 sm:px-6" class:mx-auto={align === 'center'}>
39
39
  <ul class="flex gap-4 flex-wrap mb-4" class:justify-center={align === 'center'}>
40
40
  {#each externalLinks.slice(0, 3) as link (link.url)}
41
41
  <li><Button kind="ghost" icon={Launch} href={link.url} target={link.target ?? '_blank'} rel={link.rel ?? 'noopener noreferrer'}>{link.label}{#if (link.target ?? '_blank') === '_blank'}<span class="sr-only"> (opens in a new tab)</span>{/if}</Button></li>
@@ -44,6 +44,6 @@
44
44
  </div>
45
45
  {/if}
46
46
 
47
- <div class="prompt-form flow px-3 sm:px-6" class:max-w-screen-md={!fullWidth} class:w-full={fullWidth} class:mx-auto={align === 'center'}>
47
+ <div class={!fullWidth ? 'prompt-form flow px-3 sm:px-6 max-w-[800px]' : 'prompt-form flow px-3 sm:px-6 w-full'} class:mx-auto={align === 'center'}>
48
48
  <slot />
49
49
  </div>
@@ -28,7 +28,7 @@ declare const QuestionnairePrompt: $$__sveltets_2_IsomorphicComponent<$$__svelte
28
28
  rel?: string;
29
29
  }[];
30
30
  /**
31
- * If true, the form will take the full width of its container. If false, it will be constrained to max-w-screen-md.
31
+ * If true, the form will take the full width of its container. If false, it will be constrained to max-w-[800px].
32
32
  * @type {boolean}
33
33
  */ fullWidth?: boolean;
34
34
  /**
@@ -1,5 +1,14 @@
1
1
  import type { LayoutStructureNode, LayoutStructureNodeRoot, UserProfile } from '@txstate-mws/carbon-svelte';
2
2
  import type { Component } from 'svelte';
3
+ export interface PromptLoader {
4
+ skeletonComponent: Component<any>;
5
+ /**
6
+ * The number of milliseconds to wait before showing the skeleton loader. This is useful for preventing flickering when the data is fetched quickly.
7
+ * Since some data is can be cached, the initial load needs a skeleton loader, but after caching the data comes back quicker and no skeleton loader is needed.
8
+ */
9
+ delay?: number;
10
+ }
11
+ export type Loader = PromptLoader | boolean;
3
12
  export interface ProgramDefinition {
4
13
  /**
5
14
  * The key for the program. Allows us to match up API programs with
@@ -40,7 +49,7 @@ export interface PromptDefinition {
40
49
  * by an automation. The applicant view cannot handle this, so always include
41
50
  * a formComponent for applicant prompts.
42
51
  */
43
- formComponent?: Component;
52
+ formComponent?: Component<any>;
44
53
  /**
45
54
  * Control the size of the area the formComponent will be rendered in.
46
55
  * - 'small' will render the form in a small area (about 8 lines or less at 320px width).
@@ -68,7 +77,7 @@ export interface PromptDefinition {
68
77
  * A component that displays the data collected from this prompt instead of collecting
69
78
  * it. Should be as compact as possible, as it will be displayed in a big list of prompts.
70
79
  */
71
- displayComponent: Component;
80
+ displayComponent: Component<any>;
72
81
  /**
73
82
  * Control the size of the area the displayComponent will be rendered in.
74
83
  * - 'small' will render the component in a small area (about 8 lines or less at 320px width).
@@ -93,6 +102,11 @@ export interface PromptDefinition {
93
102
  * An icon for the navigation.
94
103
  */
95
104
  icon?: Component;
105
+ /**
106
+ * Determines if the prompt should display a skeleton loader while the data is being fetched. Defaults to false.
107
+ * A boolean value will result in a default skeleton loader.
108
+ */
109
+ loader?: Loader;
96
110
  }
97
111
  export interface Terminologies {
98
112
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@reqquest/ui",
3
- "version": "1.7.1",
3
+ "version": "1.8.0",
4
4
  "exports": {
5
5
  ".": {
6
6
  "types": "./dist/index.d.ts",