classcard-ui 0.2.1523 → 0.2.1524-beta.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/README.md CHANGED
@@ -22,3 +22,119 @@ npm run lint
22
22
 
23
23
  ### Customize configuration
24
24
  See [Configuration Reference](https://cli.vuejs.org/config/).
25
+
26
+ ---
27
+
28
+ ## Consuming `classcard-ui`
29
+
30
+ The package ships **two** builds from one npm package. Nothing about the classic
31
+ global install changed — the tree-shakeable build is purely additive.
32
+
33
+ ### Build outputs
34
+
35
+ | Field | File | Used by |
36
+ | --- | --- | --- |
37
+ | `main` | `dist/classcard-ui.umd.min.js` | `require()` / `Vue.use()` consumers (unchanged) |
38
+ | `module` | `dist/esm/index.js` | Bundlers (webpack/nuxt/vite) — tree-shakeable |
39
+ | `exports["./components/*"]` | `dist/esm/components/*/index.js` | Per-component deep imports |
40
+
41
+ Build both with:
42
+
43
+ ```bash
44
+ npm run build-lib # = clean-dist + build-bundle (UMD) + build-esm (Rollup)
45
+ ```
46
+
47
+ (`npm run build-bundle` builds only the UMD monolith; `npm run build-esm` builds
48
+ only the tree-shakeable `dist/esm`. The publish scripts run `build-lib`.)
49
+
50
+ ### Option A — global install (existing, unchanged)
51
+
52
+ Registers **all** ~64 components globally. Every page loads the full ~1.9 MB UMD
53
+ bundle. Keep using this if you don't want to touch your build config.
54
+
55
+ ```js
56
+ import classcardUI from "classcard-ui";
57
+ import "classcard-ui/dist/classcard-ui.css";
58
+
59
+ Vue.use(classcardUI); // registers <c-button>, <c-table>, … everywhere
60
+ ```
61
+
62
+ ### Option B — named imports (tree-shakeable)
63
+
64
+ Import only what you use. Your bundler drops every component you don't reference,
65
+ **and the heavy dependency of each unused component** (quill, filestack-js,
66
+ v-calendar, vue-good-table, vue-tel-input, @shopify/draggable, …). Those libs are
67
+ marked `external` in the ESM build, so they are only pulled in for the components
68
+ that actually import them.
69
+
70
+ ```js
71
+ import { CButton, CInput } from "classcard-ui";
72
+ import "classcard-ui/dist/classcard-ui.css"; // still needed — see "Styles" below
73
+
74
+ export default {
75
+ components: { CButton, CInput }, // quill/filestack/v-calendar NOT bundled
76
+ };
77
+ ```
78
+
79
+ ### Option C — "slim mode": keep every `<c-*>` tag, drop `Vue.use`
80
+
81
+ This is the zero-usage-change upgrade path. Remove `Vue.use(classcardUI)` and add
82
+ the bundled resolver for [`unplugin-vue-components`](https://github.com/unplugin/unplugin-vue-components).
83
+ Every existing `<c-button>` / `<c-table>` template tag then **auto-imports** its own
84
+ per-component ESM module — so you get tree-shaking with **no changes to any template**.
85
+
86
+ **webpack:**
87
+
88
+ ```js
89
+ // webpack.config.js
90
+ const Components = require("unplugin-vue-components/webpack");
91
+ const ClasscardUIResolver = require("classcard-ui/resolver");
92
+
93
+ module.exports = {
94
+ plugins: [
95
+ Components.default({
96
+ resolvers: [ClasscardUIResolver()],
97
+ }),
98
+ ],
99
+ };
100
+ ```
101
+
102
+ **Nuxt 2 (`buildModules`):**
103
+
104
+ ```js
105
+ // nuxt.config.js
106
+ import Components from "unplugin-vue-components/webpack";
107
+ import ClasscardUIResolver from "classcard-ui/resolver";
108
+
109
+ export default {
110
+ build: {
111
+ plugins: [Components({ resolvers: [ClasscardUIResolver()] })],
112
+ },
113
+ };
114
+ ```
115
+
116
+ Then delete `Vue.use(classcardUI)` and keep the CSS import. No `<c-*>` tag changes.
117
+
118
+ ### Styles
119
+
120
+ CSS is still one shared file (`dist/classcard-ui.css`, ~75 KB) — Tailwind utility
121
+ classes live there and are **not** in the per-component JS. Import it once,
122
+ globally, in every mode above:
123
+
124
+ ```js
125
+ import "classcard-ui/dist/classcard-ui.css";
126
+ ```
127
+
128
+ (Per-SFC `<style scoped>` rules are injected by the ESM modules themselves, so
129
+ scoped styles work in slim mode even before the global CSS loads. Per-component
130
+ CSS splitting of the shared file is a possible future improvement.)
131
+
132
+ ### Notes
133
+
134
+ - `vue` is a **peer dependency** (`^2.6.14`) — provided by the host app.
135
+ - The heavy libs are regular `dependencies`, so `npm i classcard-ui` installs
136
+ them, but Options B/C only *bundle* the ones you actually use.
137
+ - `Vue.use(classcardUI)` also registers the `FocusTrap` component and the
138
+ `v-scroll-lock` directive globally. In slim mode, components that rely on the
139
+ `v-scroll-lock` directive need it registered by the host app
140
+ (`Vue.use(require("v-scroll-lock").default)`).