amp-workflow-ui 0.1.27 → 0.1.29

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,128 +1,128 @@
1
- # amp-workflow-ui
2
-
3
- Reusable Approval Workflow UI components (DialogOpener, ApprovalWorkflow) for Ampersand portals. Components are decoupled from app internals and accept an injected API client and optional URL builder.
4
-
5
- ## Install
6
-
7
- ```bash
8
- npm install amp-workflow-ui
9
- # or
10
- yarn add amp-workflow-ui
11
- ```
12
-
13
- Peer dependencies required in host:
14
-
15
- - react, react-dom (18.x)
16
- - @mui/material, @mui/system, @mui/icons-material
17
- - @emotion/react, @emotion/styled
18
- - react-hot-toast
19
-
20
- ## Usage
21
-
22
- ### 1) Basic React usage
23
-
24
- ```tsx
25
- import { DialogOpener } from 'amp-workflow-ui'
26
- import axios from 'axios'
27
-
28
- const api = {
29
- get: (p: any) => axios({ method: 'GET', baseURL: 'https://api.example.com', url: p.url }),
30
- post: (p: any) => axios({ method: 'POST', baseURL: 'https://api.example.com', url: p.url, data: p.data })
31
- }
32
-
33
- <DialogOpener
34
- openDialog={open}
35
- handleClose={() => setOpen(false)}
36
- userInfoData={userInfo}
37
- api={api}
38
- // optional
39
- urlBuilder={(moduleName, moduleId, ctx, referenceId) => `/${moduleName}/${moduleId}${referenceId ? `?ref=${referenceId}` : ''}`}
40
- />
41
- ```
42
-
43
- Or render inline:
44
-
45
- ```tsx
46
- import { ApprovalWorkflow } from 'amp-workflow-ui'
47
-
48
- <ApprovalWorkflow userInfo={userInfo} api={api} />
49
- ```
50
-
51
- Props overview:
52
- - DialogOpener
53
- - required: openDialog, userInfoData, api
54
- - optional: handleClose, selectedWorkflowsList, urlBuilder, loadingComponent
55
- - ApprovalWorkflow
56
- - required: userInfo, api
57
- - optional: selectedWorkflowsList, urlBuilder, loadingComponent
58
-
59
- ### 2) Next.js usage (recommended)
60
-
61
- Next.js may SSR your imports by default. To ensure client-only execution and avoid Node ESM resolver issues, dynamically import the package in a client component:
62
-
63
- ```tsx
64
- // app or pages client component
65
- import React from 'react'
66
- import dynamic from 'next/dynamic'
67
-
68
- export const WorkflowDialog = dynamic(
69
- async () => {
70
- // Prefer the package root; if your environment errors on ESM resolution,
71
- // fall back to the CJS build at /dist/index.cjs.js.
72
- try {
73
- const mod = await import('amp-workflow-ui')
74
- return mod.DialogOpener
75
- } catch {
76
- const mod = await import('amp-workflow-ui/dist/index.cjs.js')
77
- return mod.DialogOpener
78
- }
79
- },
80
- { ssr: false, loading: () => <div>Loading Approval Management...</div> }
81
- )
82
- ```
83
-
84
- If you still see “Directory import '@mui/material/Button' is not supported” during SSR, force the CJS build:
85
- ```tsx
86
- const WorkflowDialog = dynamic(() => import('amp-workflow-ui/dist/index.cjs.js').then(m => m.DialogOpener), { ssr: false })
87
- ```
88
-
89
- ## Build (package maintainers)
90
-
91
- ```bash
92
- npm run build
93
- ```
94
-
95
- ## Publish (package maintainers)
96
-
97
- ```bash
98
- # 1) Ensure you are logged in and have publish rights
99
- npm whoami || npm login
100
-
101
- # 2) Bump version (semver)
102
- npm version patch # or minor | major
103
-
104
- # 3) Build
105
- npm run build
106
-
107
- # 4) Publish (public)
108
- npm publish --access public
109
- ```
110
-
111
- Notes:
112
- - Do not publish pre-releases unless explicitly needed; otherwise npm requires --tag.
113
- - If your org enforces 2FA for publish, complete the OTP step in your terminal.
114
- - Keep peerDependencies in sync to avoid duplicate React/MUI bundles in hosts.
115
-
116
- ## Troubleshooting
117
-
118
- - Error: Element type is invalid … got: object
119
- - Ensure you are importing the React component (named export) and not the module object. When using dynamic(), return the component (e.g., m.DialogOpener).
120
-
121
- - Error: Directory import '@mui/material/Button' is not supported resolving ES modules
122
- - This comes from Node’s ESM resolver during SSR. Use dynamic import with ssr: false or import the CJS build: `amp-workflow-ui/dist/index.cjs.js`.
123
-
124
- ## License
125
-
126
- MIT
127
-
128
-
1
+ # amp-workflow-ui
2
+
3
+ Reusable Approval Workflow UI components (DialogOpener, ApprovalWorkflow) for Ampersand portals. Components are decoupled from app internals and accept an injected API client and optional URL builder.
4
+
5
+ ## Install
6
+
7
+ ```bash
8
+ npm install amp-workflow-ui
9
+ # or
10
+ yarn add amp-workflow-ui
11
+ ```
12
+
13
+ Peer dependencies required in host:
14
+
15
+ - react, react-dom (18.x)
16
+ - @mui/material, @mui/system, @mui/icons-material
17
+ - @emotion/react, @emotion/styled
18
+ - react-hot-toast
19
+
20
+ ## Usage
21
+
22
+ ### 1) Basic React usage
23
+
24
+ ```tsx
25
+ import { DialogOpener } from 'amp-workflow-ui'
26
+ import axios from 'axios'
27
+
28
+ const api = {
29
+ get: (p: any) => axios({ method: 'GET', baseURL: 'https://api.example.com', url: p.url }),
30
+ post: (p: any) => axios({ method: 'POST', baseURL: 'https://api.example.com', url: p.url, data: p.data })
31
+ }
32
+
33
+ <DialogOpener
34
+ openDialog={open}
35
+ handleClose={() => setOpen(false)}
36
+ userInfoData={userInfo}
37
+ api={api}
38
+ // optional
39
+ urlBuilder={(moduleName, moduleId, ctx, referenceId) => `/${moduleName}/${moduleId}${referenceId ? `?ref=${referenceId}` : ''}`}
40
+ />
41
+ ```
42
+
43
+ Or render inline:
44
+
45
+ ```tsx
46
+ import { ApprovalWorkflow } from 'amp-workflow-ui'
47
+
48
+ <ApprovalWorkflow userInfo={userInfo} api={api} />
49
+ ```
50
+
51
+ Props overview:
52
+ - DialogOpener
53
+ - required: openDialog, userInfoData, api
54
+ - optional: handleClose, selectedWorkflowsList, urlBuilder, loadingComponent
55
+ - ApprovalWorkflow
56
+ - required: userInfo, api
57
+ - optional: selectedWorkflowsList, urlBuilder, loadingComponent
58
+
59
+ ### 2) Next.js usage (recommended)
60
+
61
+ Next.js may SSR your imports by default. To ensure client-only execution and avoid Node ESM resolver issues, dynamically import the package in a client component:
62
+
63
+ ```tsx
64
+ // app or pages client component
65
+ import React from 'react'
66
+ import dynamic from 'next/dynamic'
67
+
68
+ export const WorkflowDialog = dynamic(
69
+ async () => {
70
+ // Prefer the package root; if your environment errors on ESM resolution,
71
+ // fall back to the CJS build at /dist/index.cjs.js.
72
+ try {
73
+ const mod = await import('amp-workflow-ui')
74
+ return mod.DialogOpener
75
+ } catch {
76
+ const mod = await import('amp-workflow-ui/dist/index.cjs.js')
77
+ return mod.DialogOpener
78
+ }
79
+ },
80
+ { ssr: false, loading: () => <div>Loading Approval Management...</div> }
81
+ )
82
+ ```
83
+
84
+ If you still see “Directory import '@mui/material/Button' is not supported” during SSR, force the CJS build:
85
+ ```tsx
86
+ const WorkflowDialog = dynamic(() => import('amp-workflow-ui/dist/index.cjs.js').then(m => m.DialogOpener), { ssr: false })
87
+ ```
88
+
89
+ ## Build (package maintainers)
90
+
91
+ ```bash
92
+ npm run build
93
+ ```
94
+
95
+ ## Publish (package maintainers)
96
+
97
+ ```bash
98
+ # 1) Ensure you are logged in and have publish rights
99
+ npm whoami || npm login
100
+
101
+ # 2) Bump version (semver)
102
+ npm version patch # or minor | major
103
+
104
+ # 3) Build
105
+ npm run build
106
+
107
+ # 4) Publish (public)
108
+ npm publish --access public
109
+ ```
110
+
111
+ Notes:
112
+ - Do not publish pre-releases unless explicitly needed; otherwise npm requires --tag.
113
+ - If your org enforces 2FA for publish, complete the OTP step in your terminal.
114
+ - Keep peerDependencies in sync to avoid duplicate React/MUI bundles in hosts.
115
+
116
+ ## Troubleshooting
117
+
118
+ - Error: Element type is invalid … got: object
119
+ - Ensure you are importing the React component (named export) and not the module object. When using dynamic(), return the component (e.g., m.DialogOpener).
120
+
121
+ - Error: Directory import '@mui/material/Button' is not supported resolving ES modules
122
+ - This comes from Node’s ESM resolver during SSR. Use dynamic import with ssr: false or import the CJS build: `amp-workflow-ui/dist/index.cjs.js`.
123
+
124
+ ## License
125
+
126
+ MIT
127
+
128
+