@khaojai/approval-flow
v0.1.1
Published
Standalone approval flow editor package for React applications.
Downloads
116
Maintainers
Readme
khaojai-approval-flow
Published package name: @khaojai/approval-flow
Standalone approval flow editor package (React + XYFlow + Ant Design). This folder is not wired into khaojai-ui by default — the app keeps its own src/components/approveBoxFlow copy until you choose to integrate.
Contents
- Visual flow editor (
ApprovalFlow), context (ApprovalFlowProvider), step/transform helpers (approverutilities). - JSON helpers:
parseApprovalFlowJson,mapApprovalApiResponseToFlowData,exportApprovalFlowJson, plus built-in import/export controls onApprovalFlowand optionalImportFlowJsonModal/ExportFlowJsonModal. - Host registration: call
registerApprovalFlowAdapters(...)once at app startup with your HTTP client, FormBuilder, table filters, etc. (seesrc/adapters.ts).
Peer dependencies
See package.json — React 18, Ant Design 5, @xyflow/react, styled-components, react-i18next, Refine packages used by embedded drawers.
Build the library
From this repo (install deps first):
pnpm run build— writesdist/(ESM + CJS +.d.ts) viatsup. Header icons undersrc/assets/approval/*.svgare inlined (data URLs) so consumers do not need/images/approval/*on the host (unlike a typical Vite apppublic/folder).
Publish or link uses the files field (dist only), so build before npm pack, publishing, or consuming via file:.
Publish to npm
The package is prepared for npm publication with GitHub Actions and direct publish from main.
Before the first publish:
- Create an npm access token and save it as the repository secret
NPM_TOKEN. - Confirm the package name in
package.jsonis the one you want on npm. This repo is configured for@khaojai/approval-flow. - Push the repository to GitHub with
mainas the default branch.
Release flow:
- Push a change to
main. - The release workflow validates the package, bumps the patch version, and publishes
@khaojai/approval-flowto npm. - The workflow pushes the release commit and git tag back to
main.
Notes:
pnpm run prepublishOnlyvalidates typecheck, tests, and build before a direct publish.pnpm run pack:checkshows what would go into the npm tarball.- The workflow uses a
[skip release]marker in the automated release commit message so the version-bump commit does not trigger a second publish loop. - Consumers do not update automatically just because
mainchanges. They receive updates when they install a newer published version that matches their semver range and redeploy.
Sample app (POC)
The poc-project/ folder is a small Vite + React app that depends on this package via "file:..". After pnpm run build at the repo root, follow poc-project/README.md to run it.
Use it in another project
- Install the package and all
peerDependencies(React, Ant Design,@xyflow/react,@ant-design/icons, Refine,styled-components,react-i18next,i18next,solar-icon-set, etc. — seepackage.json). - Add the dependency, for example:
- Local folder:
"@khaojai/approval-flow": "file:../khaojai-approval-flow"after runningpnpm run buildin this repo. - Registry:
pnpm add @khaojai/approval-flowafter the package has been published, then use the version range you want.
- Local folder:
- Import from
'@khaojai/approval-flow'(resolved todist/). Your app bundler should handle ESM/CJS viaexports. - Call
registerApprovalFlowAdapters(...)once at startup, then renderApprovalFlow/ApprovalFlowProvideras needed. - Use
ApprovalFlow's built-in JSON controls, or callparseApprovalFlowJson(...)/exportApprovalFlowJson(...)directly when you need custom import/export flows.
Integration (when you want it)
- Add the package as above.
- Register adapters before rendering any editor UI.
- Replace imports from
@/components/approveBoxFlowwith this package, or keep both during migration.
Do not delete the in-repo approveBoxFlow until you have tested the package in your app.
