@lerx/promise-modal 0.11.0 → 0.12.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.
- package/bin/claude-sync.mjs +28 -0
- package/dist/@aileron/declare/index.d.ts +4 -4
- package/dist/app/ModalManager.d.ts +3 -3
- package/dist/app/constant.d.ts +1 -1
- package/dist/bootstrap/BootstrapProvider/BootstrapProvider.d.ts +1 -1
- package/dist/bootstrap/BootstrapProvider/helpers/bootstrap.d.ts +2 -2
- package/dist/bootstrap/BootstrapProvider/index.d.ts +3 -3
- package/dist/bootstrap/BootstrapProvider/type.d.ts +2 -2
- package/dist/bootstrap/BootstrapProvider/useBootstrap.d.ts +1 -1
- package/dist/bootstrap/index.d.ts +1 -1
- package/dist/claude-hashes.json +18 -0
- package/dist/components/Anchor/index.d.ts +1 -1
- package/dist/components/Background/Background.d.ts +1 -1
- package/dist/components/Background/index.d.ts +1 -1
- package/dist/components/FallbackComponents/FallbackFooter.d.ts +1 -1
- package/dist/components/FallbackComponents/FallbackForegroundFrame.d.ts +1 -1
- package/dist/components/FallbackComponents/index.d.ts +5 -5
- package/dist/components/Foreground/Foreground.d.ts +1 -1
- package/dist/components/Foreground/components/AlertInner.d.ts +2 -2
- package/dist/components/Foreground/components/ConfirmInner.d.ts +2 -2
- package/dist/components/Foreground/components/PromptInner.d.ts +2 -2
- package/dist/components/Foreground/components/index.d.ts +3 -3
- package/dist/components/Foreground/index.d.ts +1 -1
- package/dist/components/Presenter/Presenter.d.ts +1 -1
- package/dist/components/Presenter/index.d.ts +1 -1
- package/dist/core/handle/alert.d.ts +2 -2
- package/dist/core/handle/confirm.d.ts +2 -2
- package/dist/core/handle/index.d.ts +5 -5
- package/dist/core/handle/prompt.d.ts +2 -2
- package/dist/core/handle/static.d.ts +1 -1
- package/dist/core/handle/type.d.ts +2 -2
- package/dist/core/index.d.ts +2 -2
- package/dist/core/node/ModalNode/AbstractNode.d.ts +2 -2
- package/dist/core/node/ModalNode/AlertNode.d.ts +2 -2
- package/dist/core/node/ModalNode/ConfirmNode.d.ts +2 -2
- package/dist/core/node/ModalNode/PromptNode.d.ts +3 -3
- package/dist/core/node/ModalNode/index.d.ts +3 -3
- package/dist/core/node/index.d.ts +2 -2
- package/dist/core/node/nodeFactory.d.ts +2 -2
- package/dist/core/node/type.d.ts +1 -1
- package/dist/helpers/closeModal.d.ts +1 -1
- package/dist/helpers/subscribeAbortSignal.d.ts +1 -1
- package/dist/hooks/useActiveModalCount.d.ts +2 -2
- package/dist/hooks/useDestroyAfter.d.ts +2 -2
- package/dist/hooks/useModal.d.ts +2 -2
- package/dist/hooks/useModalAnimation.d.ts +1 -1
- package/dist/hooks/useModalDuration.d.ts +1 -1
- package/dist/hooks/useSubscribeModal.d.ts +1 -1
- package/dist/index.d.ts +10 -10
- package/dist/providers/ConfigurationContext/ConfigurationContext.d.ts +1 -1
- package/dist/providers/ConfigurationContext/ConfigurationContextProvider.d.ts +1 -1
- package/dist/providers/ConfigurationContext/index.d.ts +2 -2
- package/dist/providers/ModalManagerContext/ModalManagerContext.d.ts +3 -3
- package/dist/providers/ModalManagerContext/ModalManagerContextProvider.d.ts +1 -1
- package/dist/providers/ModalManagerContext/index.d.ts +2 -2
- package/dist/providers/ModalManagerContext/useModalManagerContext.d.ts +1 -1
- package/dist/providers/UserDefinedContext/UserDefinedContext.d.ts +1 -1
- package/dist/providers/UserDefinedContext/UserDefinedContextProvider.d.ts +1 -1
- package/dist/providers/UserDefinedContext/index.d.ts +2 -2
- package/dist/providers/UserDefinedContext/useUserDefinedContext.d.ts +1 -1
- package/dist/providers/index.d.ts +3 -3
- package/dist/types/alert.d.ts +2 -2
- package/dist/types/base.d.ts +3 -3
- package/dist/types/confirm.d.ts +2 -2
- package/dist/types/index.d.ts +7 -7
- package/dist/types/modal.d.ts +6 -6
- package/dist/types/option.d.ts +1 -1
- package/dist/types/prompt.d.ts +2 -2
- package/docs/claude/skills/{expert → promise-modal-skill}/SKILL.md +32 -34
- package/docs/claude/skills/{expert → promise-modal-skill}/knowledge/advanced-patterns.md +8 -6
- package/docs/claude/skills/{expert → promise-modal-skill}/knowledge/hooks-reference.md +1 -7
- package/package.json +13 -6
- package/docs/claude/commands/guide.md +0 -760
- /package/docs/claude/skills/{expert → promise-modal-skill}/knowledge/api-reference.md +0 -0
- /package/docs/claude/skills/{expert → promise-modal-skill}/knowledge/type-definitions.md +0 -0
package/dist/types/option.d.ts
CHANGED
package/dist/types/prompt.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { ComponentType, ReactNode } from 'react';
|
|
2
|
-
import type { Dictionary, Fn, SetStateFn } from '../@aileron/declare';
|
|
3
|
-
import type { BaseModal, ContentComponentProps, FooterOptions } from './base';
|
|
2
|
+
import type { Dictionary, Fn, SetStateFn } from '../@aileron/declare/index.js';
|
|
3
|
+
import type { BaseModal, ContentComponentProps, FooterOptions } from './base.js';
|
|
4
4
|
export type PromptFooterRender<T, Context extends Dictionary = object> = Fn<[
|
|
5
5
|
props: {
|
|
6
6
|
value: T | undefined;
|
|
@@ -1,37 +1,33 @@
|
|
|
1
1
|
---
|
|
2
|
-
name: promise-modal-
|
|
2
|
+
name: promise-modal-skill
|
|
3
3
|
description: "@lerx/promise-modal library expert. Guide users on React-based Promise modal utilities (alert, confirm, prompt), architecture, and customization."
|
|
4
|
-
user-invocable: false
|
|
5
4
|
---
|
|
6
5
|
|
|
7
|
-
# Promise Modal Expert
|
|
6
|
+
# Promise Modal Expert
|
|
8
7
|
|
|
9
|
-
|
|
8
|
+
Guide users on the `@lerx/promise-modal` library for React-based Promise modal utilities. Apply this skill when users ask how to implement, configure, customize, or troubleshoot modal dialogs built with `@lerx/promise-modal`.
|
|
10
9
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
## Core Knowledge
|
|
14
|
-
|
|
15
|
-
### Library Overview
|
|
10
|
+
## Library Overview
|
|
16
11
|
|
|
17
12
|
`@lerx/promise-modal` is a universal modal utility for React that provides:
|
|
13
|
+
|
|
18
14
|
- Promise-based modal interactions (alert, confirm, prompt)
|
|
19
15
|
- Usage both inside and outside React components
|
|
20
16
|
- High-level component customization
|
|
21
17
|
- Automatic lifecycle management
|
|
22
18
|
- Programmatic modal cancellation via AbortSignal
|
|
23
19
|
|
|
24
|
-
|
|
20
|
+
## Architecture
|
|
25
21
|
|
|
26
22
|
The library uses a layered architecture:
|
|
27
23
|
|
|
28
|
-
1. **Core Layer**
|
|
29
|
-
2. **Application Layer**
|
|
30
|
-
3. **Bootstrap Layer**
|
|
31
|
-
4. **Provider Layer**
|
|
32
|
-
5. **Component Layer**
|
|
24
|
+
1. **Core Layer** — Main API functions (alert, confirm, prompt)
|
|
25
|
+
2. **Application Layer** — ModalManager singleton for lifecycle and DOM management
|
|
26
|
+
3. **Bootstrap Layer** — ModalProvider component for initialization
|
|
27
|
+
4. **Provider Layer** — Context providers for configuration and state
|
|
28
|
+
5. **Component Layer** — Customizable UI components
|
|
33
29
|
|
|
34
|
-
|
|
30
|
+
## Configuration Priority
|
|
35
31
|
|
|
36
32
|
Configuration is applied hierarchically, with lower levels overriding higher levels:
|
|
37
33
|
|
|
@@ -49,9 +45,9 @@ Provider Config (Lowest) < Hook Config < Handler Config (Highest)
|
|
|
49
45
|
|
|
50
46
|
## Basic Usage Patterns
|
|
51
47
|
|
|
52
|
-
### Pattern
|
|
48
|
+
### Pattern A: Static API
|
|
53
49
|
|
|
54
|
-
|
|
50
|
+
Use static functions outside React components.
|
|
55
51
|
|
|
56
52
|
```typescript
|
|
57
53
|
import { alert, confirm, prompt } from '@lerx/promise-modal';
|
|
@@ -85,9 +81,9 @@ const name = await prompt({
|
|
|
85
81
|
});
|
|
86
82
|
```
|
|
87
83
|
|
|
88
|
-
### Pattern
|
|
84
|
+
### Pattern B: Component-Scoped with useModal
|
|
89
85
|
|
|
90
|
-
|
|
86
|
+
Tie modals to component lifecycle — automatically cleaned up on unmount.
|
|
91
87
|
|
|
92
88
|
```typescript
|
|
93
89
|
import { useModal } from '@lerx/promise-modal';
|
|
@@ -107,7 +103,7 @@ function MyComponent() {
|
|
|
107
103
|
}
|
|
108
104
|
```
|
|
109
105
|
|
|
110
|
-
**
|
|
106
|
+
**Static API vs useModal**:
|
|
111
107
|
|
|
112
108
|
| Feature | Static Handlers | useModal Hook |
|
|
113
109
|
|------|------------|-------------|
|
|
@@ -115,6 +111,8 @@ function MyComponent() {
|
|
|
115
111
|
| Cleanup | Manual | Auto on unmount |
|
|
116
112
|
| Usage Location | Anywhere | Inside React components |
|
|
117
113
|
|
|
114
|
+
For advanced patterns (AbortSignal cancellation, toasts, nested modals, custom anchors, complex forms), see `knowledge/advanced-patterns.md`.
|
|
115
|
+
|
|
118
116
|
---
|
|
119
117
|
|
|
120
118
|
## Troubleshooting
|
|
@@ -147,25 +145,25 @@ function MyComponent() {
|
|
|
147
145
|
|
|
148
146
|
## Best Practices
|
|
149
147
|
|
|
150
|
-
1. **Place ModalProvider at Root
|
|
151
|
-
2. **Use useModal in Components
|
|
152
|
-
3. **Use Static API in Utilities
|
|
153
|
-
4. **Customize at Provider Level
|
|
154
|
-
5. **Use subtype Semantically
|
|
155
|
-
6. **Handle Promises Properly
|
|
156
|
-
7. **Keep Modal Content Simple
|
|
157
|
-
8. **Test Accessibility
|
|
158
|
-
9. **Leverage AbortSignal
|
|
148
|
+
1. **Place ModalProvider at Root** — wrap the entire app
|
|
149
|
+
2. **Use useModal in Components** — for automatic cleanup
|
|
150
|
+
3. **Use Static API in Utilities** — for non-component code
|
|
151
|
+
4. **Customize at Provider Level** — set global styles once
|
|
152
|
+
5. **Use subtype Semantically** — info, success, warning, error
|
|
153
|
+
6. **Handle Promises Properly** — always await or handle rejection
|
|
154
|
+
7. **Keep Modal Content Simple** — avoid complex state in modals
|
|
155
|
+
8. **Test Accessibility** — verify keyboard navigation
|
|
156
|
+
9. **Leverage AbortSignal** — when programmatic modal closure is needed
|
|
159
157
|
|
|
160
158
|
---
|
|
161
159
|
|
|
162
|
-
##
|
|
160
|
+
## Resources
|
|
163
161
|
|
|
164
|
-
|
|
162
|
+
Load these files on demand for detailed API, patterns, and type definitions:
|
|
165
163
|
|
|
166
164
|
| File | Contents |
|
|
167
165
|
|------|------|
|
|
168
166
|
| `knowledge/api-reference.md` | Static functions (alert, confirm, prompt) and ModalProvider detailed API |
|
|
169
167
|
| `knowledge/hooks-reference.md` | Complete reference for 8 hooks (useModal, useActiveModalCount, etc.) |
|
|
170
|
-
| `knowledge/advanced-patterns.md` | Advanced patterns
|
|
171
|
-
| `knowledge/type-definitions.md` | TypeScript interface definitions (ModalFrameProps,
|
|
168
|
+
| `knowledge/advanced-patterns.md` | Advanced patterns: AbortSignal, toast, nested modals, custom anchors, complex forms |
|
|
169
|
+
| `knowledge/type-definitions.md` | TypeScript interface definitions (ModalFrameProps, FooterComponentProps, PromptInputProps) |
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
# Advanced Patterns
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
These patterns extend the basic Static API and `useModal` patterns documented in `SKILL.md`.
|
|
4
|
+
|
|
5
|
+
## Pattern 1: Modal Cancellation with AbortSignal
|
|
4
6
|
|
|
5
7
|
Programmatically cancel modals.
|
|
6
8
|
|
|
@@ -47,7 +49,7 @@ function ManualAbortControl() {
|
|
|
47
49
|
|
|
48
50
|
---
|
|
49
51
|
|
|
50
|
-
## Pattern
|
|
52
|
+
## Pattern 2: Toast Implementation
|
|
51
53
|
|
|
52
54
|
Implement auto-dismissing toast notifications.
|
|
53
55
|
|
|
@@ -104,7 +106,7 @@ toast('An error occurred.', 2000);
|
|
|
104
106
|
|
|
105
107
|
---
|
|
106
108
|
|
|
107
|
-
## Pattern
|
|
109
|
+
## Pattern 3: Nested Modals
|
|
108
110
|
|
|
109
111
|
Display multiple modals sequentially in steps.
|
|
110
112
|
|
|
@@ -149,7 +151,7 @@ async function multiStepProcess() {
|
|
|
149
151
|
|
|
150
152
|
---
|
|
151
153
|
|
|
152
|
-
## Pattern
|
|
154
|
+
## Pattern 4: Custom Anchor
|
|
153
155
|
|
|
154
156
|
Render modals inside a specific DOM element.
|
|
155
157
|
|
|
@@ -191,7 +193,7 @@ function CustomAnchorExample() {
|
|
|
191
193
|
|
|
192
194
|
---
|
|
193
195
|
|
|
194
|
-
## Pattern
|
|
196
|
+
## Pattern 5: Complex Form Input
|
|
195
197
|
|
|
196
198
|
Collect complex form data using prompt.
|
|
197
199
|
|
|
@@ -258,7 +260,7 @@ async function collectUserInfo() {
|
|
|
258
260
|
|
|
259
261
|
---
|
|
260
262
|
|
|
261
|
-
## Pattern
|
|
263
|
+
## Pattern 6: Conditional Modal Styles
|
|
262
264
|
|
|
263
265
|
Display different styled modals based on situation.
|
|
264
266
|
|
|
@@ -20,13 +20,7 @@ function MyComponent() {
|
|
|
20
20
|
}
|
|
21
21
|
```
|
|
22
22
|
|
|
23
|
-
**Key Feature**: Modals are automatically cleaned up when component unmounts.
|
|
24
|
-
|
|
25
|
-
| Feature | Static Handlers | useModal Hook |
|
|
26
|
-
|------|------------|-------------|
|
|
27
|
-
| Lifecycle | Independent | Tied to component |
|
|
28
|
-
| Cleanup | Manual | Auto on unmount |
|
|
29
|
-
| Usage Location | Anywhere | Inside React components |
|
|
23
|
+
**Key Feature**: Modals are automatically cleaned up when component unmounts. For a comparison with the Static API, see `SKILL.md`.
|
|
30
24
|
|
|
31
25
|
---
|
|
32
26
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lerx/promise-modal",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.12.0",
|
|
4
4
|
"description": "Universal React modal utility that can be used outside React components with promise-based results for alert, confirm, and prompt modals",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react",
|
|
@@ -42,19 +42,25 @@
|
|
|
42
42
|
"main": "dist/index.cjs",
|
|
43
43
|
"module": "dist/index.mjs",
|
|
44
44
|
"types": "dist/index.d.ts",
|
|
45
|
+
"bin": {
|
|
46
|
+
"claude-sync": "./bin/claude-sync.mjs"
|
|
47
|
+
},
|
|
45
48
|
"files": [
|
|
46
49
|
"dist",
|
|
47
50
|
"docs",
|
|
51
|
+
"bin",
|
|
48
52
|
"README.md"
|
|
49
53
|
],
|
|
50
54
|
"scripts": {
|
|
51
|
-
"build": "rollup -c && yarn build:types",
|
|
55
|
+
"build": "rollup -c && yarn build:types && yarn build:hashes",
|
|
56
|
+
"build:hashes": "node scripts/build-hashes.mjs",
|
|
52
57
|
"build:publish:npm": "yarn build && yarn publish:npm",
|
|
53
|
-
"build:types": "
|
|
58
|
+
"build:types": "node ../../aileron/script/build/buildTypes.mjs",
|
|
54
59
|
"build-storybook": "storybook build",
|
|
55
60
|
"format": "prettier --write \"src/**/*.{ts,tsx}\"",
|
|
56
61
|
"lint": "eslint \"src/**/*.{ts,tsx}\"",
|
|
57
62
|
"make-dependency-graph": "npx depcruise src --config .dependency-cruiser.js --output-type dot > dependency-graph.dot && dot -Tpng dependency-graph.dot -o dependency-graph.png",
|
|
63
|
+
"prepublishOnly": "yarn build",
|
|
58
64
|
"publish:npm": "yarn npm publish --access public",
|
|
59
65
|
"size-limit": "size-limit",
|
|
60
66
|
"start": "yarn build && yarn storybook",
|
|
@@ -65,9 +71,10 @@
|
|
|
65
71
|
"version:patch": "yarn version patch"
|
|
66
72
|
},
|
|
67
73
|
"dependencies": {
|
|
68
|
-
"@
|
|
69
|
-
"@winglet/
|
|
70
|
-
"@winglet/
|
|
74
|
+
"@slats/claude-assets-sync": "^0.2.0",
|
|
75
|
+
"@winglet/common-utils": "^0.12.0",
|
|
76
|
+
"@winglet/react-utils": "^0.12.0",
|
|
77
|
+
"@winglet/style-utils": "^0.12.0"
|
|
71
78
|
},
|
|
72
79
|
"devDependencies": {
|
|
73
80
|
"@types/react": "^19.0.0",
|