hanap-labs 0.1.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/LICENSE +21 -0
- package/README.md +190 -0
- package/dist/auto-import/index.js +40 -0
- package/dist/chunks/components-BlNF7xT6.js +3951 -0
- package/dist/chunks/composables-C9eE_X8p.js +1393 -0
- package/dist/chunks/helpers-QkG7gR6t.js +6 -0
- package/dist/chunks/usePopup-zCvtcQsc.js +943 -0
- package/dist/components/index.js +2 -0
- package/dist/composables/index.js +3 -0
- package/dist/helpers/index.js +2 -0
- package/dist/index.js +6 -0
- package/dist/toolkit.css +2 -0
- package/dist/types/auto-import/index.d.ts +31 -0
- package/dist/types/components/hl-avatar/HLAvatar.types.d.ts +6 -0
- package/dist/types/components/hl-avatar/index.d.ts +2 -0
- package/dist/types/components/hl-breadcrumb/HLBreadcrumb.types.d.ts +24 -0
- package/dist/types/components/hl-breadcrumb/index.d.ts +2 -0
- package/dist/types/components/hl-breadcrumb/useBreadcrumb.d.ts +7 -0
- package/dist/types/components/hl-button/HLButton.types.d.ts +19 -0
- package/dist/types/components/hl-button/index.d.ts +2 -0
- package/dist/types/components/hl-checkbox/HLCheckbox.types.d.ts +17 -0
- package/dist/types/components/hl-checkbox/index.d.ts +2 -0
- package/dist/types/components/hl-icon/HLIcon.registry.d.ts +2 -0
- package/dist/types/components/hl-icon/HLIcon.types.d.ts +10 -0
- package/dist/types/components/hl-icon/index.d.ts +3 -0
- package/dist/types/components/hl-input/HLInput.types.d.ts +30 -0
- package/dist/types/components/hl-input/index.d.ts +2 -0
- package/dist/types/components/hl-label/HLLabel.types.d.ts +11 -0
- package/dist/types/components/hl-label/index.d.ts +2 -0
- package/dist/types/components/hl-menu-action/HLMenuAction.types.d.ts +23 -0
- package/dist/types/components/hl-menu-action/index.d.ts +2 -0
- package/dist/types/components/hl-notify/index.d.ts +12 -0
- package/dist/types/components/hl-popup/index.d.ts +12 -0
- package/dist/types/components/hl-select/HLSelect.types.d.ts +31 -0
- package/dist/types/components/hl-select/index.d.ts +2 -0
- package/dist/types/components/hl-skeleton/HLSkeleton.types.d.ts +3 -0
- package/dist/types/components/hl-skeleton/index.d.ts +2 -0
- package/dist/types/components/hl-table/HLTable.types.d.ts +35 -0
- package/dist/types/components/hl-table/index.d.ts +2 -0
- package/dist/types/components/hl-tabs/HLTabs.types.d.ts +9 -0
- package/dist/types/components/hl-tabs/index.d.ts +2 -0
- package/dist/types/components/hl-textarea/HLTextarea.types.d.ts +17 -0
- package/dist/types/components/hl-textarea/index.d.ts +2 -0
- package/dist/types/components/index.d.ts +15 -0
- package/dist/types/composables/data/useMutation.d.ts +12 -0
- package/dist/types/composables/data/useQuery.d.ts +18 -0
- package/dist/types/composables/form/useForm.d.ts +22 -0
- package/dist/types/composables/index.d.ts +9 -0
- package/dist/types/composables/ui/useFloat.d.ts +29 -0
- package/dist/types/composables/ui/useNotify.d.ts +25 -0
- package/dist/types/composables/ui/usePopup.d.ts +25 -0
- package/dist/types/helpers/formatLabel.d.ts +1 -0
- package/dist/types/helpers/index.d.ts +1 -0
- package/dist/types/index.d.ts +6 -0
- package/dist/types/types/index.d.ts +1 -0
- package/dist/types/types/ui.types.d.ts +5 -0
- package/package.json +97 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 hanap-labs contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
# hanap-labs
|
|
2
|
+
|
|
3
|
+
Shared UI toolkit package for components, helpers, and composables.
|
|
4
|
+
|
|
5
|
+
## Build
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install
|
|
9
|
+
npm run build
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
## Public Entrypoints
|
|
13
|
+
|
|
14
|
+
- Root entrypoint: `hanap-labs`
|
|
15
|
+
- Components entrypoint: `hanap-labs/components`
|
|
16
|
+
- Helpers entrypoint: `hanap-labs/helpers`
|
|
17
|
+
- Composables entrypoint: `hanap-labs/composables`
|
|
18
|
+
- Auto-import helper entrypoint: `hanap-labs/auto-import`
|
|
19
|
+
|
|
20
|
+
## Consumption Modes
|
|
21
|
+
|
|
22
|
+
### 1) Manual Named Imports (Default)
|
|
23
|
+
|
|
24
|
+
Use named imports when you want explicit dependencies per file.
|
|
25
|
+
|
|
26
|
+
```ts
|
|
27
|
+
import { AHButton, formatLabel, usePopup } from "hanap-labs";
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
You can also import by module group:
|
|
31
|
+
|
|
32
|
+
```ts
|
|
33
|
+
import { AHButton } from "hanap-labs/components";
|
|
34
|
+
import type { AHButtonProps } from "hanap-labs/components";
|
|
35
|
+
import { formatLabel } from "hanap-labs/helpers";
|
|
36
|
+
import { usePopup } from "hanap-labs/composables";
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
### 2) Optional Auto-Import Integration
|
|
40
|
+
|
|
41
|
+
If a consumer app uses `unplugin-vue-components` and `unplugin-auto-import`, the toolkit exposes helper factories to wire components and composables in one place.
|
|
42
|
+
|
|
43
|
+
Install plugins in the consumer app:
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
npm install -D unplugin-vue-components unplugin-auto-import
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
Update the consumer app `vite.config.ts`:
|
|
50
|
+
|
|
51
|
+
```ts
|
|
52
|
+
import { defineConfig } from "vite";
|
|
53
|
+
import vue from "@vitejs/plugin-vue";
|
|
54
|
+
import Components from "unplugin-vue-components/vite";
|
|
55
|
+
import AutoImport from "unplugin-auto-import/vite";
|
|
56
|
+
import { createToolkitAutoImportOptions } from "hanap-labs/auto-import";
|
|
57
|
+
|
|
58
|
+
const toolkitAutoImport = createToolkitAutoImportOptions();
|
|
59
|
+
|
|
60
|
+
export default defineConfig({
|
|
61
|
+
plugins: [
|
|
62
|
+
vue(),
|
|
63
|
+
Components({
|
|
64
|
+
resolvers: toolkitAutoImport.components.resolvers,
|
|
65
|
+
}),
|
|
66
|
+
AutoImport({
|
|
67
|
+
imports: toolkitAutoImport.composables.imports,
|
|
68
|
+
}),
|
|
69
|
+
],
|
|
70
|
+
});
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
To scope auto-imports, pass selected names:
|
|
74
|
+
|
|
75
|
+
```ts
|
|
76
|
+
createToolkitAutoImportOptions({
|
|
77
|
+
componentNames: ["AHButton"],
|
|
78
|
+
composableNames: ["usePopup"],
|
|
79
|
+
});
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
## Consumer Setup Checklist
|
|
83
|
+
|
|
84
|
+
Apply these steps in each consuming website:
|
|
85
|
+
|
|
86
|
+
1. Install `hanap-labs`.
|
|
87
|
+
2. Import toolkit styles once in your app entry:
|
|
88
|
+
- `import "hanap-labs/styles.css";`
|
|
89
|
+
3. Choose a mode:
|
|
90
|
+
- Keep manual named imports (default).
|
|
91
|
+
- Enable optional auto-import using the Vite plugin setup above.
|
|
92
|
+
4. Run the app build and confirm toolkit components/composables resolve correctly.
|
|
93
|
+
|
|
94
|
+
## Global Overlay Setup (`popup` and `notify`)
|
|
95
|
+
|
|
96
|
+
The toolkit includes app-level overlay plugins:
|
|
97
|
+
|
|
98
|
+
- `createPopupPlugin()` for popup host mounting
|
|
99
|
+
- `createNotifyPlugin()` for toast/notify host mounting
|
|
100
|
+
|
|
101
|
+
### Auto-mount (recommended)
|
|
102
|
+
|
|
103
|
+
Use auto-mount when you want the toolkit to create and mount hosts to `document.body`:
|
|
104
|
+
|
|
105
|
+
```ts
|
|
106
|
+
import { createApp } from "vue";
|
|
107
|
+
import App from "./App.vue";
|
|
108
|
+
import {
|
|
109
|
+
createNotifyPlugin,
|
|
110
|
+
createPopupPlugin,
|
|
111
|
+
} from "hanap-labs/components";
|
|
112
|
+
|
|
113
|
+
createApp(App).use(createPopupPlugin()).use(createNotifyPlugin()).mount("#app");
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
### Manual mount target
|
|
117
|
+
|
|
118
|
+
Use manual targets when your app needs explicit host element control:
|
|
119
|
+
|
|
120
|
+
```html
|
|
121
|
+
<div id="app"></div>
|
|
122
|
+
<div id="popup-root"></div>
|
|
123
|
+
<div id="notify-root"></div>
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
```ts
|
|
127
|
+
import { createApp } from "vue";
|
|
128
|
+
import App from "./App.vue";
|
|
129
|
+
import {
|
|
130
|
+
createNotifyPlugin,
|
|
131
|
+
createPopupPlugin,
|
|
132
|
+
} from "hanap-labs/components";
|
|
133
|
+
|
|
134
|
+
createApp(App)
|
|
135
|
+
.use(createPopupPlugin({ mountId: "popup-root", autoMount: true }))
|
|
136
|
+
.use(createNotifyPlugin({ mountId: "notify-root", autoMount: true }))
|
|
137
|
+
.mount("#app");
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
## Theming
|
|
141
|
+
|
|
142
|
+
The toolkit supports host-driven theming through CSS variables and `.dark` mode.
|
|
143
|
+
|
|
144
|
+
1. Define theme tokens in your app `:root` and `.dark`.
|
|
145
|
+
2. Toggle `.dark` on a parent element (usually `html` or `body`).
|
|
146
|
+
3. Toolkit components consume those values automatically.
|
|
147
|
+
|
|
148
|
+
Example:
|
|
149
|
+
|
|
150
|
+
```css
|
|
151
|
+
:root {
|
|
152
|
+
--button-primary: #15803d;
|
|
153
|
+
--button-primary-text: #ffffff;
|
|
154
|
+
--border-muted: #d8e0da;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
.dark {
|
|
158
|
+
--button-primary: #85bb65;
|
|
159
|
+
--button-primary-text: #030712;
|
|
160
|
+
--border-muted: rgba(255, 255, 255, 0.1);
|
|
161
|
+
}
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
## TanStack Vue Query Setup (`useQuery`)
|
|
165
|
+
|
|
166
|
+
The `useQuery` composable requires TanStack Vue Query to be installed and configured in your app.
|
|
167
|
+
|
|
168
|
+
```bash
|
|
169
|
+
npm install @tanstack/vue-query
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
In your app entry (e.g., `main.ts`):
|
|
173
|
+
|
|
174
|
+
```ts
|
|
175
|
+
import { createApp } from "vue";
|
|
176
|
+
import App from "./App.vue";
|
|
177
|
+
import { VueQueryPlugin, QueryClient } from "@tanstack/vue-query";
|
|
178
|
+
|
|
179
|
+
const queryClient = new QueryClient({
|
|
180
|
+
defaultOptions: {
|
|
181
|
+
queries: {
|
|
182
|
+
staleTime: 1000 * 60 * 5,
|
|
183
|
+
},
|
|
184
|
+
},
|
|
185
|
+
});
|
|
186
|
+
|
|
187
|
+
createApp(App).use(VueQueryPlugin, { queryClient }).mount("#app");
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
Without this setup, `useQuery` will throw a runtime error in fresh consumer apps.
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
//#region src/auto-import/index.ts
|
|
2
|
+
var e = "anonghanap-toolkit", t = `${e}/components`, n = `${e}/composables`, r = [
|
|
3
|
+
"AHAvatar",
|
|
4
|
+
"AHBreadcrumb",
|
|
5
|
+
"AHButton",
|
|
6
|
+
"AHIcon",
|
|
7
|
+
"AHMenuAction",
|
|
8
|
+
"AHSelect",
|
|
9
|
+
"AHSkeleton",
|
|
10
|
+
"AHTabs",
|
|
11
|
+
"AHTable"
|
|
12
|
+
], i = [
|
|
13
|
+
"useFloat",
|
|
14
|
+
"useNotify",
|
|
15
|
+
"usePopup",
|
|
16
|
+
"useQuery"
|
|
17
|
+
];
|
|
18
|
+
function a(e = [...r]) {
|
|
19
|
+
let n = new Set(e);
|
|
20
|
+
return {
|
|
21
|
+
type: "component",
|
|
22
|
+
resolve(e) {
|
|
23
|
+
if (n.has(e)) return {
|
|
24
|
+
name: e,
|
|
25
|
+
from: t
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
function o(e = [...i]) {
|
|
31
|
+
return [{ [n]: [...e] }];
|
|
32
|
+
}
|
|
33
|
+
function s(e = {}) {
|
|
34
|
+
return {
|
|
35
|
+
components: { resolvers: [a(e.componentNames ?? [...r])] },
|
|
36
|
+
composables: { imports: o(e.composableNames ?? [...i]) }
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
//#endregion
|
|
40
|
+
export { o as createToolkitAutoImportModules, s as createToolkitAutoImportOptions, a as createToolkitComponentsResolver };
|