@overlastic/vanilla 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,100 +1,29 @@
1
- # @overlastic/vanilla
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 native application, support custom-element!
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/core"><img src="https://img.shields.io/npm/v/@overlastic/core.svg" alt="NPM Version" /></a>
13
+ <a href="https://www.npmjs.com/@overlastic/core"><img src="https://img.shields.io/npm/l/@overlastic/core.svg" alt="Package License" /></a>
14
+ <a href="https://www.npmjs.com/@overlastic/core"><img src="https://img.shields.io/npm/dm/@overlastic/core.svg" alt="NPM Downloads" /></a>
15
+ </p>
6
16
 
7
- With pnpm:
8
- ```sh
9
- pnpm add @overlastic/vanilla
10
- ```
11
-
12
- With yarn:
13
- ```sh
14
- yarn add @overlastic/vanilla
15
- ```
16
-
17
- ## Usage
18
-
19
- ### Step 1: Define Component
20
-
21
- Create custom elements in the form of functions and return them.
22
-
23
- ```js
24
- // overlay.ts
25
- function Component(props) {
26
- const element = document.createElement('div')
27
- element.innerHTML = props.title
28
-
29
- const { resolve, reject, deferred } = useOverlayDefine({
30
- // Duration of overlays duration to avoid premature destruction of the component
31
- duration: 1000,
32
- })
33
-
34
- // Add events that cause the overlays to end
35
- element.onclick = function () {
36
- resolve('ok')
37
- }
38
-
39
- // Use setTimeout to wait for the element to be appended, then add a class name with animation
40
- setTimeout(() => element.classList.add('show'))
41
- // When the deferred is triggered, remove the displayed class name
42
- deferred.finally(() => element.classList.remove('show'))
43
-
44
- return element
45
- }
46
-
47
- export default Component
48
- ```
17
+ ## Description
49
18
 
50
- ### Step 2: Create Overlay
19
+ Create messages or dialog overlays using Overlastic in native HTML.
51
20
 
52
- 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
53
22
 
54
- ```ts
55
- import { defineOverlay } from '@overlastic/vanilla'
56
- import Component from './overlay'
57
-
58
- // Convert to imperative callback
59
- const callback = defineOverlay(Component)
60
- // Call the component and get the value of the resolve callback
61
- const value = await callback({ title: 'callbackOverlay' })
62
- // value === "callbackOverlay:confirmed"
23
+ ```bash
24
+ $ npm install --save @overlastic/vanilla
63
25
  ```
64
26
 
65
- You can also use `renderOverlay` to directly call the component and skip the `defineOverlay` method.
66
-
67
- ```ts
68
- import { defineOverlay } from '@overlastic/vanilla'
69
- import Component from './overlay'
70
-
71
- const value = await renderOverlay(Component, {
72
- title: 'useOverlayDefine'
73
- })
74
- // value === "useOverlayDefine:confirmed"
75
- ```
76
-
77
- ## Custom Element
78
-
79
- After mounting a custom element, you can pass in the corresponding custom element or name through 'defineOverlay' to use the custom element.
80
-
81
- > You can use [lit](https://lit.dev/) Quickly build custom elements.
27
+ ## Quick Start
82
28
 
83
- ```ts
84
- const callback1 = defineOverlay('my-custom-element')
85
-
86
- callback1({/* props(attrs) */})
87
-
88
- function CustomComponent(props) {
89
- const customElement = document.createElement('my-custom-element')
90
-
91
- const { resolve, reject } = useOverlayDefine({
92
- duration: 1000,
93
- })
94
-
95
- // ...
96
- return customElement
97
- }
98
-
99
- const callback2 = defineOverlay(CustomComponent)
100
- ```
29
+ [Overview & Tutorial](https://overlastic.vercel.app/vanilla/)
package/dist/index.cjs CHANGED
@@ -22,7 +22,7 @@ var src_exports = {};
22
22
  __export(src_exports, {
23
23
  defineOverlay: () => defineOverlay,
24
24
  renderOverlay: () => renderOverlay,
25
- useOverlayDefine: () => useOverlayDefine
25
+ useDefineOverlay: () => useDefineOverlay
26
26
  });
27
27
  module.exports = __toCommonJS(src_exports);
28
28
 
@@ -83,7 +83,7 @@ var defineOverlay = constructor.define;
83
83
  var renderOverlay = constructor.render;
84
84
 
85
85
  // src/composable/define.ts
86
- function useOverlayDefine(options) {
86
+ function useDefineOverlay(options) {
87
87
  const trigger = context.trigger;
88
88
  if (!trigger)
89
89
  throw new Error("Please execute in the overlays constructor");
@@ -94,5 +94,5 @@ function useOverlayDefine(options) {
94
94
  0 && (module.exports = {
95
95
  defineOverlay,
96
96
  renderOverlay,
97
- useOverlayDefine
97
+ useDefineOverlay
98
98
  });
package/dist/index.d.cts CHANGED
@@ -13,13 +13,13 @@ interface Context<T = void> {
13
13
  resolve: Deferred<T>['resolve'];
14
14
  reject: Deferred<T>['reject'];
15
15
  deferred: Deferred<T>;
16
- vanish: Function;
16
+ vanish: () => void;
17
17
  }
18
18
 
19
- interface OverlayDefineOptions {
19
+ interface DefineOverlayOptions {
20
20
  /** animation duration to avoid premature destruction of components */
21
21
  duration?: number;
22
22
  }
23
- declare function useOverlayDefine(options?: OverlayDefineOptions): Context<void>;
23
+ declare function useDefineOverlay(options?: DefineOverlayOptions): Context<void>;
24
24
 
25
- export { type Context, type OverlayDefineOptions, defineOverlay, renderOverlay, useOverlayDefine };
25
+ export { type Context, type DefineOverlayOptions, defineOverlay, renderOverlay, useDefineOverlay };
package/dist/index.d.ts CHANGED
@@ -13,13 +13,13 @@ interface Context<T = void> {
13
13
  resolve: Deferred<T>['resolve'];
14
14
  reject: Deferred<T>['reject'];
15
15
  deferred: Deferred<T>;
16
- vanish: Function;
16
+ vanish: () => void;
17
17
  }
18
18
 
19
- interface OverlayDefineOptions {
19
+ interface DefineOverlayOptions {
20
20
  /** animation duration to avoid premature destruction of components */
21
21
  duration?: number;
22
22
  }
23
- declare function useOverlayDefine(options?: OverlayDefineOptions): Context<void>;
23
+ declare function useDefineOverlay(options?: DefineOverlayOptions): Context<void>;
24
24
 
25
- export { type Context, type OverlayDefineOptions, defineOverlay, renderOverlay, useOverlayDefine };
25
+ export { type Context, type DefineOverlayOptions, defineOverlay, renderOverlay, useDefineOverlay };
@@ -23,7 +23,7 @@ var OverlaysVanilla = (() => {
23
23
  __export(src_exports, {
24
24
  defineOverlay: () => defineOverlay,
25
25
  renderOverlay: () => renderOverlay,
26
- useOverlayDefine: () => useOverlayDefine
26
+ useDefineOverlay: () => useDefineOverlay
27
27
  });
28
28
 
29
29
  // ../@core/src/define/global.ts
@@ -187,7 +187,7 @@ var OverlaysVanilla = (() => {
187
187
  var renderOverlay = constructor.render;
188
188
 
189
189
  // src/composable/define.ts
190
- function useOverlayDefine(options) {
190
+ function useDefineOverlay(options) {
191
191
  const trigger = context2.trigger;
192
192
  if (!trigger)
193
193
  throw new Error("Please execute in the overlays constructor");
package/dist/index.js CHANGED
@@ -55,7 +55,7 @@ var defineOverlay = constructor.define;
55
55
  var renderOverlay = constructor.render;
56
56
 
57
57
  // src/composable/define.ts
58
- function useOverlayDefine(options) {
58
+ function useDefineOverlay(options) {
59
59
  const trigger = context.trigger;
60
60
  if (!trigger)
61
61
  throw new Error("Please execute in the overlays constructor");
@@ -65,5 +65,5 @@ function useOverlayDefine(options) {
65
65
  export {
66
66
  defineOverlay,
67
67
  renderOverlay,
68
- useOverlayDefine
68
+ useDefineOverlay
69
69
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@overlastic/vanilla",
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": {
@@ -25,7 +25,7 @@
25
25
  "dist"
26
26
  ],
27
27
  "dependencies": {
28
- "@overlastic/core": "^0.5.0"
28
+ "@overlastic/core": "^0.6.1"
29
29
  },
30
30
  "scripts": {
31
31
  "build": "tsup src/index.ts",