@lgsm/modules 1.6.20-beta.1 → 1.6.20-beta.10

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,78 +1,201 @@
1
- # Installation
2
- 1. npm i
3
- 2. npm run storybook
4
-
5
- Project using **React component library**, with **Vite**, **TypeScript** and **Storybook**.
6
-
7
- Link download : https://www.npmjs.com/package/@lgsm/modules
8
-
9
- ## Features
10
-
11
- - ⚛️ **React** component library with **TypeScript**.
12
-
13
- - 🏗️ **Vite** as development environment.
14
-
15
- - 🌳 **Tree shaking**, for not distributing dead-code.
16
-
17
- - 📚 **Storybook** for live viewing the components.
18
-
19
- - 🎨 **PostCSS** for processing our CSS.
20
-
21
- - 🖌️ **CSS Modules** in development, compiled CSS for production builds.
22
-
23
- - 🧪 Testing with **Vitest** and **React Testing Library**.
24
-
25
- - ✅ Code quality tools with **ESLint**, **Prettier** and **Stylelint**.
26
-
27
- ## 🤖 Scripts
28
-
29
- | Script | Function |
30
- | :---------------: | ---------------------------------------------------------------------------------- |
31
- | `build` | Build the `dist`, with types declarations, after checking types with TypeScript. |
32
- | `lint` | Lint the project with **Eslint**. |
33
- | `lint:fix` | Lint and fix the project with **Eslint**. |
34
- | `format` | Check the project format with **Prettier**. |
35
- | `format:fix` | Format the project code with **Prettier**. |
36
- | `stylelint` | Lint the styles code with **Stylelint**. |
37
- | `stylelint:fix` | Lint and fix the styles code with **Stylelint**. |
38
- | `storybook` | Start a Storybook development server. |
39
- | `build-storybook` | Build the Storybook `dist`. |
40
- | `test` | Run the tests with **Vitest** using `jsdom` and starts a **Vitest UI** dev server. |
41
- | `coverage` | Generate a coverage report, with **v8**. |
42
-
43
- ## How to setup API Service
44
- 1. Installation
45
- ```
46
- npm i
47
- ```
48
- 2. Create your environment files (eg: '.env.dev' or '.env.prod') and define your base URL
49
- ```
50
- VITE_BASE_URL=https://your-api-domain.com
51
- ```
52
- 3. Update your package.json to include appropriate Vite modes for each environment
53
- ```"scripts": {
54
- "dev": "vite --mode dev [your settings]",
55
- "prod": "vite --mode prod [your settings]"
56
- }
57
- ```
58
- 4. In your main.tsx, (or wherever your app initializes), import and set up the base URL using setupBaseURL.
59
- ```
60
- import { setupBaseURL } from "@lgsm/modules";
61
-
62
- setupBaseURL(import.meta.env.VITE_BASE_URL);
63
- ```
64
- 5. The API client automatically handles certain error codes and displays notifications (popups). To enable this behavior, make sure the NotificationContainer component is rendered at the root level of your app, for example in App.tsx:
65
- ```
66
- <ErrorBoundary fallback={}>
67
- <Suspense fallback={<ThreeDotsLoader />}>
68
- <NotificationContainer />
69
- </Suspense>
70
- </ErrorBoundary>
71
- ```
72
-
73
- ## Usage Example
74
- Please refer to:
75
- ### For API Service
76
- src > usage-example > example-apiService.tsx
77
- ### For Components
78
- src > usage-example > example-components.tsx
1
+ # LGSM shared packages
2
+
3
+ One repository maintains four focused packages and the full-library entry point.
4
+ All packages currently use version 1.6.20-beta.10.
5
+
6
+ | Package | Owns | LGSM dependencies |
7
+ | --- | --- | --- |
8
+ | @lgsm/core | API client, authentication redirects and token decoding | None |
9
+ | @lgsm/ui | Basic controls, dropdowns, dialogs/side drawers, loaders, notifications and error views | None |
10
+ | @lgsm/account | ProfileMenu, SystemSwitcher shell and profile URL helpers | ui |
11
+ | @lgsm/data-table | Tables, editing/filtering/pagination, date/command controls and Excel export | ui |
12
+ | @lgsm/modules | Re-exports all four packages and preserves existing imports | All four |
13
+
14
+ The feature packages never import @lgsm/modules. Account and UI do not depend on
15
+ TanStack Table, Excel/file-export libraries, date pickers or command controls.
16
+ React and React DOM remain peer dependencies. Source code has one home under
17
+ packages/; the umbrella contains exports and the legacy API notification adapter.
18
+
19
+ ## Install everything
20
+
21
+ After this release is published:
22
+
23
+ ~~~sh
24
+ bun add @lgsm/modules
25
+ ~~~
26
+
27
+ Existing imports continue to work:
28
+
29
+ ~~~tsx
30
+ import { DataTable, ProfileMenu, SystemSwitcher, Sheet, MainErrorFallback } from '@lgsm/modules'
31
+ ~~~
32
+
33
+ The umbrella depends on the feature packages, so one command installs all of them.
34
+ A teammate cloning an app only runs bun install, using its package.json and lockfile.
35
+
36
+ ## Install selected features
37
+
38
+ ~~~sh
39
+ bun add @lgsm/account
40
+ # Or choose several packages in one command:
41
+ bun add @lgsm/core @lgsm/ui @lgsm/data-table
42
+ ~~~
43
+
44
+ ~~~tsx
45
+ import { ProfileMenu, SystemSwitcher } from '@lgsm/account'
46
+ import { DataTable, type ColumnConfig } from '@lgsm/data-table'
47
+ import { Sheet, SheetContent, SheetTitle, SheetTrigger, NotFound } from '@lgsm/ui'
48
+ ~~~
49
+
50
+ Only required dependencies are installed automatically. Installing account does
51
+ not install core, data-table or the umbrella. The package entry points import their
52
+ compiled, scoped CSS; no source files need to be copied into the app. The shared
53
+ UI package supplies fonts and base styles. Apps intentionally suppressing library
54
+ CSS must register the installed @lgsm packages with Tailwind @source, as LMS does.
55
+ CSS is also exported at each UI package's /styles.css subpath.
56
+
57
+ ## Develop this repository
58
+
59
+ ~~~sh
60
+ bun install
61
+ bun run build
62
+ bun run test --run
63
+ bun run check:packages
64
+ bun run check:install
65
+ ~~~
66
+
67
+ Run bun install once at the repository root. Workspaces link the local packages.
68
+ The build command type-checks and builds core, UI, account, data-table and finally
69
+ the umbrella in dependency order. Existing Storybook stories now live beside their
70
+ components in packages/*/src; start them with bun run storybook.
71
+
72
+ Commit scripts/ alongside the package sources: build and publish checks depend
73
+ on those files. Generated dist/ folders remain Git-ignored.
74
+
75
+ check:packages verifies package boundaries, declared imports, build outputs and
76
+ account-only dependency isolation. check:install packs the actual release files
77
+ and performs clean account-only and full-library installs in temporary directories.
78
+ It asserts that heavy table dependencies are absent from the account-only install.
79
+ It does not publish anything. Open scripts/check-style-isolation.html through the
80
+ local Vite server after building to verify shared CSS isolation in a browser.
81
+
82
+ ## Local consumer repositories
83
+
84
+ HRIS, Jakarta and LMS currently keep @lgsm/modules as file:../lampung-fe.
85
+ Their package.json overrides resolve the four unpublished packages from sibling
86
+ folders in packages/. Run bun install in each app after building Lampung. After
87
+ subsequent library-only edits, rebuild Lampung and refresh the app's copied local
88
+ packages with bun install --force. App feature edits do not need a library build.
89
+
90
+ Keep `resolve.dedupe: ['react', 'react-dom']` in each consuming app's Vite config
91
+ so linked library dependencies use the app's React instance. After changing this
92
+ setting, restart the dev server with `bun run dev --force` to refresh Vite's cache.
93
+
94
+ Another local app can use a selective file dependency, for example
95
+ file:../lampung-fe/packages/account, with a local override for its UI dependency.
96
+ Keep overrides in the consuming app, not in published packages.
97
+ When using the published release, replace the file dependency with the package
98
+ version and remove the local LGSM overrides.
99
+
100
+ ## Shared account controls
101
+
102
+ ~~~tsx
103
+ import { DropdownMenuItem, ProfileMenu, SystemSwitcher } from '@lgsm/modules'
104
+
105
+ <div className="flex items-center gap-4">
106
+ <SystemSwitcher label="Open navigation menus" contentClassName="w-100">
107
+ <div className="grid grid-cols-4 gap-2">
108
+ {menus.map((menu) => (
109
+ <DropdownMenuItem key={menu.path} onSelect={() => navigate(menu.path)}>
110
+ {menu.name}
111
+ </DropdownMenuItem>
112
+ ))}
113
+ </div>
114
+ </SystemSwitcher>
115
+ <ProfileMenu
116
+ avatarUrl={user?.userDetails.avtrPath}
117
+ jakartaUrl={import.meta.env.VITE_APP_URL_JAKARTA}
118
+ onChangePassword={changePassword}
119
+ onLogout={logout}
120
+ />
121
+ </div>
122
+ ~~~
123
+
124
+ ProfileMenu owns the bundled fallback avatar and account-menu behavior. My Profile
125
+ opens /profile on the configured Jakarta base URL. Jakarta passes
126
+ window.location.origin. Authentication actions remain app callbacks.
127
+
128
+ SystemSwitcher owns only the shared 32px button, dropdown container, focus and
129
+ open/close behavior. Pass the content as children, use label to name the button,
130
+ and optionally change container sizing through contentClassName. Use
131
+ DropdownMenuItem for selectable children so keyboard navigation and dismissal work.
132
+ Selective consumers import SystemSwitcher from @lgsm/account and declare @lgsm/ui
133
+ when importing DropdownMenuItem directly.
134
+
135
+ Each app owns its API calls, filtering, grid layout and navigation. HRIS's local
136
+ MenuSwitcher uses the existing access-menu context and internal router links in a
137
+ four-column grid. Jakarta supplies its already-loaded application list through a
138
+ local ApplicationSwitcher. LMS's ApplicationSwitcher calls its own SystemService
139
+ and handles loading, retry, inactive systems and HTTP(S)-only external links.
140
+ There are no API calls or application data types in @lgsm/account. The previous
141
+ userId and systems props are replaced by children in this unpublished release.
142
+
143
+ ## API initialization
144
+
145
+ The full @lgsm/modules setupBaseURL export keeps existing toast notifications.
146
+ It delegates to the shared core client. Existing five-argument initialization
147
+ calls remain compatible.
148
+
149
+ Selective consumers importing the client directly should declare @lgsm/core as
150
+ an app dependency and provide their notification callback when needed:
151
+
152
+ ~~~ts
153
+ import { setupBaseURL } from '@lgsm/core'
154
+
155
+ setupBaseURL(apiUrl, getAccessToken, loginUrl, environment, setAccessToken, showApiError)
156
+ ~~~
157
+
158
+ The last callback receives (message, description). Core defaults to console.error
159
+ and has no UI dependency. Apps wanting the shared notifications can pass notifyError
160
+ from @lgsm/ui and render Sonner from that same package. Keep API configuration and
161
+ token state in the host app; feature packages share the configured core client.
162
+
163
+ ## Tables, drawers and errors
164
+
165
+ DataTable and ServerTable retain their existing props and permission behavior.
166
+ The app supplies data, columns, validation, save callbacks and access flags.
167
+ Missing permissions keep built-in editing actions read-only. Table-specific
168
+ calendar/command controls and Excel code live only in @lgsm/data-table.
169
+
170
+ Sheet, SheetContent, SheetTrigger, SheetTitle and the other Sheet primitives provide
171
+ the side drawer. MainErrorFallback and NotFound provide the shared error views.
172
+ The host app still owns its router, error-boundary wiring, navigation and permissions.
173
+ All shared roots and portal content retain data-lgsm-ui for style isolation.
174
+
175
+ ## Publish
176
+
177
+ Build, test and run both package checks first. Publish to your existing registry
178
+ with the intended package visibility, in this order:
179
+
180
+ 1. packages/core and packages/ui
181
+ 2. packages/account and packages/data-table
182
+ 3. repository root (@lgsm/modules)
183
+
184
+ From this repository root, after npm login:
185
+
186
+ ~~~sh
187
+ npm publish -w @lgsm/core --tag beta --access public
188
+ npm publish -w @lgsm/ui --tag beta --access public
189
+ npm publish -w @lgsm/account --tag beta --access public
190
+ npm publish -w @lgsm/data-table --tag beta --access public
191
+ npm publish --tag beta --access public
192
+ ~~~
193
+
194
+ The root command publishes only @lgsm/modules, not the workspace packages.
195
+ Published versions cannot be overwritten: use a new beta number for each release.
196
+
197
+ Each folder is independently publishable; only dist, package metadata and README
198
+ are shipped. Runtime package dependencies use registry versions, not local file or
199
+ workspace paths. Use the same release version across the five package manifests
200
+ for now and update internal versions together. No release-management service or
201
+ additional build framework is required.
package/dist/main.d.ts CHANGED
@@ -1,14 +1,5 @@
1
- export { Button } from './shared-ui/Button';
2
- export { MyCounter } from './shared-ui/MyCounter';
3
- export { MyTitle } from './shared-ui/MyTitle';
4
- export { Notification } from './shared-ui/Notification';
5
- export { ThreeDotsLoader } from './shared-ui/ThreeDotsLoader';
6
- export { NotificationContainer } from './shared-ui/Notification/NotificationContainer';
7
- export { Sonner } from './shared-ui/Sonner';
8
- export { Modal } from './shared-ui/Modal';
9
- export { Dropdown } from './shared-ui/Dropdown';
10
- export { notifyError, notifySuccess, notifyWarning } from './shared-ui/sonnerHelper';
11
- export { default as apiService } from './shared-service/apiService';
12
- export { setupBaseURL } from './shared-service/axiosInstance';
13
- export { loginRedirect } from './shared-function/loginRedirect';
14
- export { decodeToken } from './shared-function/jwtDecodeFunc';
1
+ export * from '@lgsm/core';
2
+ export * from '@lgsm/ui';
3
+ export * from '@lgsm/account';
4
+ export * from '@lgsm/data-table';
5
+ export { setupBaseURL } from './setupBaseURL';