@overlastic/svelte 0.5.0 → 0.6.1

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 CHANGED
@@ -1,99 +1,29 @@
1
- # Getting Started
1
+ <p align="center">
2
+ <a href="https://overlastic.vercel.app/" target="blank">
3
+ <img src="https://github.com/hairyf/overlastic/raw/master/docs/public/logo.svg" width="120" alt="Nest Logo" />
4
+ </a>
5
+ </p>
2
6
 
3
- create imperative overlays in the svelte application, supporting context inheritance!
7
+ <p align="center">
8
+ A create modal | dialog | popup promise deferred library
9
+ </p>
4
10
 
5
- ## Install
11
+ <p align="center">
12
+ <a href="https://www.npmjs.com/@overlastic/svelte"><img src="https://img.shields.io/npm/v/@overlastic/svelte.svg" alt="NPM Version" /></a>
13
+ <a href="https://www.npmjs.com/@overlastic/svelte"><img src="https://img.shields.io/npm/l/@overlastic/svelte.svg" alt="Package License" /></a>
14
+ <a href="https://www.npmjs.com/@overlastic/svelte"><img src="https://img.shields.io/npm/dm/@overlastic/svelte.svg" alt="NPM Downloads" /></a>
15
+ </p>
6
16
 
7
- With pnpm:
8
- ```sh
9
- pnpm add @overlastic/svelte
10
- ```
11
-
12
- With yarn:
13
- ```sh
14
- yarn add @overlastic/svelte
15
- ```
16
-
17
- ## Usage
18
-
19
- ### Step 1: Define Component
20
-
21
- ```svelte
22
- <script lang="ts">
23
- import { useOverlayDefine, Overlay } from "@overlastic/svelte";
24
- import { fly } from "svelte/transition";
25
-
26
- export let title: number
27
- export let duration = 200
28
-
29
- // duration of overlay duration, helps prevent premature component destroy
30
- const { resolve, reject } = useOverlayDefine({ duration })
31
-
32
- function onClick() {
33
- resolve(`${title}:confirmed`)
34
- }
35
- </script>
36
-
37
- <Overlay>
38
- <div transition:fly={{ opacity: 0, duration }} on:click={onClick}>
39
- <slot name="title">
40
- { title }
41
- </slot>
42
- </div>
43
- </Overlay>
44
- ```
17
+ ## Description
45
18
 
46
- ### Step 2: Create Overlay
19
+ Create messages or dialog overlays using Overlastic in Svelte APP.
47
20
 
48
- You can use the `defineOverlay` method to convert the component into a modal dialog in Javascript / Typescript, which allows you to call it.
21
+ ## Installation
49
22
 
50
- ```ts
51
- import { defineOverlay } from '@overlastic/svelte'
52
- import OverlayComponent from './overlay.svelte'
53
-
54
- // Convert to imperative callback
55
- const callback = defineOverlay(OverlayComponent)
56
- // Call the component and get the value of the resolve callback
57
- const value = await callback({ title: 'callbackOverlay' })
58
- // value === "callbackOverlay:confirmed"
59
- ```
60
-
61
- You can also use `renderOverlay` to directly call the component and skip the `defineOverlay` method.
62
-
63
- ```ts
64
- import { renderOverlay } from '@overlastic/svelte'
65
- import OverlayComponent from './overlay.svelte'
66
-
67
- const value = await renderOverlay(OverlayComponent, {
68
- title: 'useOverlayDefine'
69
- })
70
- // value === "useOverlayDefine:confirmed"
23
+ ```bash
24
+ $ npm install --save @overlastic/svelte
71
25
  ```
72
26
 
73
- ## Controlled manner
74
-
75
- By default, you do not need to control the display and hiding of the `visible` variable. The value is controlled by the component `Overlay`, and you can pass in `visible` to control the display
27
+ ## Quick Start
76
28
 
77
- ```svelte
78
- <script lang="ts">
79
- import { useOverlayDefine, Overlay } from "@overlastic/svelte";
80
-
81
- let visible = false
82
-
83
- const { resolve, reject, deferred, vanish } = useOverlayDefine({
84
- // close the transition duration, at this point you need to manually destroy it
85
- duration: false,
86
- // cancel setting visible to true immediately
87
- immediate: false
88
- })
89
-
90
- // Manually set vanish (when promise ends)
91
- deferred.finally(() => vanish())
92
- </script>
93
-
94
- <Overlay bind:visible={visible}>
95
- <div on:click={() => resolve(`${title}:confirmed`)}>
96
- ...
97
- </div>
98
- </Overlay>
99
- ```
29
+ [Overview & Tutorial](https://overlastic.vercel.app/svelte/)
package/dist/index.cjs CHANGED
@@ -23,7 +23,7 @@ __export(src_exports, {
23
23
  Overlay: () => Overlay,
24
24
  defineOverlay: () => defineOverlay,
25
25
  renderOverlay: () => renderOverlay,
26
- useOverlayDefine: () => useOverlayDefine
26
+ useDefineOverlay: () => useDefineOverlay
27
27
  });
28
28
  module.exports = __toCommonJS(src_exports);
29
29
 
@@ -62,7 +62,7 @@ var renderOverlay = constructor.render;
62
62
 
63
63
  // src/composable/define.ts
64
64
  var import_svelte = require("svelte");
65
- function useOverlayDefine(options = {}) {
65
+ function useDefineOverlay(options = {}) {
66
66
  (0, import_svelte.setContext)(injectOptionsKey, options);
67
67
  return (0, import_svelte.getContext)(injectOverlayKey);
68
68
  }
@@ -226,5 +226,5 @@ var Overlay = class extends import_internal3.SvelteComponentTyped {
226
226
  Overlay,
227
227
  defineOverlay,
228
228
  renderOverlay,
229
- useOverlayDefine
229
+ useDefineOverlay
230
230
  });
package/dist/index.d.cts CHANGED
@@ -11,25 +11,25 @@ interface SMountOptions {
11
11
  declare const defineOverlay: <Props, Resolved = void>(instance: any, options?: _overlastic_core.MountOptions<SMountOptions> | undefined) => _overlastic_core.ImperativeOverlay<Props, Resolved, SMountOptions>;
12
12
  declare const renderOverlay: <Props, Resolved = void>(instance: any, props?: Props | undefined, options?: _overlastic_core.MountOptions<SMountOptions> | undefined) => Promise<Resolved>;
13
13
 
14
- interface ProgramsReturn {
14
+ interface DefineOverlayReturn {
15
15
  /** the notification reject, modify visible, and destroy it after the duration ends */
16
- reject: Function;
16
+ reject: (reason?: any) => void;
17
17
  /** the notification resolve, modify visible, and destroy it after the duration ends */
18
- resolve: Function;
18
+ resolve: (value?: any) => void;
19
19
  /** destroy the current instance (immediately) */
20
- vanish: Function;
20
+ vanish: () => void;
21
21
  /** visible control popup display and hide */
22
22
  /** current deferred */
23
23
  deferred?: Deferred<any>;
24
24
  }
25
25
 
26
- interface OverlayDefineOptions {
26
+ interface DefineOverlayOptions {
27
27
  /** animation duration to avoid premature destruction of components */
28
28
  duration?: number;
29
29
  /** whether to set visible to true immediately */
30
30
  immediate?: boolean;
31
31
  }
32
- declare function useOverlayDefine(options?: OverlayDefineOptions): ProgramsReturn;
32
+ declare function useDefineOverlay(options?: DefineOverlayOptions): DefineOverlayReturn;
33
33
 
34
34
  declare class Overlay extends SvelteComponentTyped<{
35
35
  visible?: boolean;
@@ -37,4 +37,4 @@ declare class Overlay extends SvelteComponentTyped<{
37
37
  constructor(options: ComponentConstructorOptions);
38
38
  }
39
39
 
40
- export { Overlay, type OverlayDefineOptions, type ProgramsReturn, defineOverlay, renderOverlay, useOverlayDefine };
40
+ export { type DefineOverlayOptions, type DefineOverlayReturn, Overlay, defineOverlay, renderOverlay, useDefineOverlay };
package/dist/index.d.ts CHANGED
@@ -11,25 +11,25 @@ interface SMountOptions {
11
11
  declare const defineOverlay: <Props, Resolved = void>(instance: any, options?: _overlastic_core.MountOptions<SMountOptions> | undefined) => _overlastic_core.ImperativeOverlay<Props, Resolved, SMountOptions>;
12
12
  declare const renderOverlay: <Props, Resolved = void>(instance: any, props?: Props | undefined, options?: _overlastic_core.MountOptions<SMountOptions> | undefined) => Promise<Resolved>;
13
13
 
14
- interface ProgramsReturn {
14
+ interface DefineOverlayReturn {
15
15
  /** the notification reject, modify visible, and destroy it after the duration ends */
16
- reject: Function;
16
+ reject: (reason?: any) => void;
17
17
  /** the notification resolve, modify visible, and destroy it after the duration ends */
18
- resolve: Function;
18
+ resolve: (value?: any) => void;
19
19
  /** destroy the current instance (immediately) */
20
- vanish: Function;
20
+ vanish: () => void;
21
21
  /** visible control popup display and hide */
22
22
  /** current deferred */
23
23
  deferred?: Deferred<any>;
24
24
  }
25
25
 
26
- interface OverlayDefineOptions {
26
+ interface DefineOverlayOptions {
27
27
  /** animation duration to avoid premature destruction of components */
28
28
  duration?: number;
29
29
  /** whether to set visible to true immediately */
30
30
  immediate?: boolean;
31
31
  }
32
- declare function useOverlayDefine(options?: OverlayDefineOptions): ProgramsReturn;
32
+ declare function useDefineOverlay(options?: DefineOverlayOptions): DefineOverlayReturn;
33
33
 
34
34
  declare class Overlay extends SvelteComponentTyped<{
35
35
  visible?: boolean;
@@ -37,4 +37,4 @@ declare class Overlay extends SvelteComponentTyped<{
37
37
  constructor(options: ComponentConstructorOptions);
38
38
  }
39
39
 
40
- export { Overlay, type OverlayDefineOptions, type ProgramsReturn, defineOverlay, renderOverlay, useOverlayDefine };
40
+ export { type DefineOverlayOptions, type DefineOverlayReturn, Overlay, defineOverlay, renderOverlay, useDefineOverlay };
@@ -24,7 +24,7 @@ var OverlaysSvelte = (() => {
24
24
  Overlay: () => Overlay,
25
25
  defineOverlay: () => defineOverlay,
26
26
  renderOverlay: () => renderOverlay,
27
- useOverlayDefine: () => useOverlayDefine
27
+ useDefineOverlay: () => useDefineOverlay
28
28
  });
29
29
 
30
30
  // ../@core/src/define/global.ts
@@ -607,7 +607,7 @@ var OverlaysSvelte = (() => {
607
607
  }
608
608
 
609
609
  // src/composable/define.ts
610
- function useOverlayDefine(options = {}) {
610
+ function useDefineOverlay(options = {}) {
611
611
  setContext(injectOptionsKey, options);
612
612
  return getContext(injectOverlayKey);
613
613
  }
package/dist/index.js CHANGED
@@ -33,7 +33,7 @@ var renderOverlay = constructor.render;
33
33
 
34
34
  // src/composable/define.ts
35
35
  import { getContext, setContext } from "svelte";
36
- function useOverlayDefine(options = {}) {
36
+ function useDefineOverlay(options = {}) {
37
37
  setContext(injectOptionsKey, options);
38
38
  return getContext(injectOverlayKey);
39
39
  }
@@ -212,5 +212,5 @@ export {
212
212
  Overlay,
213
213
  defineOverlay,
214
214
  renderOverlay,
215
- useOverlayDefine
215
+ useDefineOverlay
216
216
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@overlastic/svelte",
3
3
  "type": "module",
4
- "version": "0.5.0",
4
+ "version": "0.6.1",
5
5
  "license": "MIT",
6
6
  "homepage": "https://github.com/hairyf/overlastic#readme",
7
7
  "repository": {
@@ -26,7 +26,7 @@
26
26
  ],
27
27
  "dependencies": {
28
28
  "svelte": "^3.57.0",
29
- "@overlastic/core": "^0.5.0"
29
+ "@overlastic/core": "^0.6.1"
30
30
  },
31
31
  "scripts": {
32
32
  "build": "tsup src/index.ts",