@nubisco/ui 1.40.0 → 1.41.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.
@@ -1,2 +1,53 @@
1
- export declare const fonts: () => import("vite").Plugin<any> | import("vite").Plugin<any>[];
1
+ import Unfonts from 'unplugin-fonts/vite';
2
+ /**
3
+ * Options accepted by {@link fonts}. This is the exact option object that
4
+ * `unplugin-fonts` exposes, so any provider it supports (`fontsource`,
5
+ * `custom`, `google`, `typekit`) can be configured here.
6
+ */
7
+ export type TFontsOptions = NonNullable<Parameters<typeof Unfonts>[0]>;
8
+ /**
9
+ * Default font configuration for NubiscoUI.
10
+ *
11
+ * Self-hosted via the `fontsource` provider (RGPD-friendly, no third-party
12
+ * CDN). These are the two families declared as the library defaults in
13
+ * `src/styles/variables/_type.scss` (`--nb-font-family-sans` / `-mono`):
14
+ *
15
+ * - Plus Jakarta Sans: weights 400, 500, 600, 700 (sans default)
16
+ * - Fira Code: weights 400, 600 (mono default)
17
+ *
18
+ * Only `normal` styles are loaded. Every subset shipped by Fontsource is
19
+ * imported, but each `@font-face` carries a `unicode-range`, so the browser
20
+ * only downloads the subsets a page actually needs. `font-display: swap` is
21
+ * baked into the Fontsource stylesheets.
22
+ *
23
+ * Consumers must install the source packages themselves:
24
+ * `pnpm add -D @fontsource/plus-jakarta-sans @fontsource/fira-code`.
25
+ */
26
+ export declare const DEFAULT_FONTS: TFontsOptions;
27
+ /**
28
+ * Vite plugin that loads NubiscoUI's typefaces.
29
+ *
30
+ * Called with no arguments it self-hosts the library defaults (Plus Jakarta
31
+ * Sans + Fira Code) via Fontsource, keeping every existing consumer's output
32
+ * unchanged. Pass an options object to fully replace that configuration: load
33
+ * different families/weights, point the `custom` provider at your own woff2
34
+ * files, or use any other provider `unplugin-fonts` supports.
35
+ *
36
+ * @example
37
+ * // vite.config.ts (keep the NubiscoUI defaults)
38
+ * import { fonts } from '@nubisco/ui/plugins/fonts'
39
+ * export default defineConfig({ plugins: [fonts()] })
40
+ *
41
+ * @example
42
+ * // bring your own families/weights
43
+ * fonts({
44
+ * fontsource: {
45
+ * families: [
46
+ * { name: 'Inter', weights: [400, 600], styles: ['normal'] },
47
+ * { name: 'JetBrains Mono', weights: [400], styles: ['normal'] },
48
+ * ],
49
+ * },
50
+ * })
51
+ */
52
+ export declare const fonts: (options?: TFontsOptions) => import("vite").Plugin<any> | import("vite").Plugin<any>[];
2
53
  //# sourceMappingURL=fonts.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"fonts.d.ts","sourceRoot":"","sources":["../../src/plugins/fonts.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,KAAK,iEAgBd,CAAA"}
1
+ {"version":3,"file":"fonts.d.ts","sourceRoot":"","sources":["../../src/plugins/fonts.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,qBAAqB,CAAA;AAEzC;;;;GAIG;AACH,MAAM,MAAM,aAAa,GAAG,WAAW,CAAC,UAAU,CAAC,OAAO,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;AAEtE;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,aAAa,EAAE,aAe3B,CAAA;AAED;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,eAAO,MAAM,KAAK,GAAI,UAAS,aAA6B,8DAC1C,CAAA"}
@@ -1,16 +1,61 @@
1
1
  import Unfonts from 'unplugin-fonts/vite';
2
- export const fonts = () => Unfonts({
3
- google: {
4
- injectTo: 'head-prepend',
2
+ /**
3
+ * Default font configuration for NubiscoUI.
4
+ *
5
+ * Self-hosted via the `fontsource` provider (RGPD-friendly, no third-party
6
+ * CDN). These are the two families declared as the library defaults in
7
+ * `src/styles/variables/_type.scss` (`--nb-font-family-sans` / `-mono`):
8
+ *
9
+ * - Plus Jakarta Sans: weights 400, 500, 600, 700 (sans default)
10
+ * - Fira Code: weights 400, 600 (mono default)
11
+ *
12
+ * Only `normal` styles are loaded. Every subset shipped by Fontsource is
13
+ * imported, but each `@font-face` carries a `unicode-range`, so the browser
14
+ * only downloads the subsets a page actually needs. `font-display: swap` is
15
+ * baked into the Fontsource stylesheets.
16
+ *
17
+ * Consumers must install the source packages themselves:
18
+ * `pnpm add -D @fontsource/plus-jakarta-sans @fontsource/fira-code`.
19
+ */
20
+ export const DEFAULT_FONTS = {
21
+ fontsource: {
5
22
  families: [
6
23
  {
7
- name: 'Plus+Jakarta+Sans',
8
- styles: 'ital,wght@0,200..800;1,200..800',
24
+ name: 'Plus Jakarta Sans',
25
+ weights: [400, 500, 600, 700],
26
+ styles: ['normal'],
9
27
  },
10
28
  {
11
- name: 'Fira+Code',
12
- styles: 'wght@300..700',
29
+ name: 'Fira Code',
30
+ weights: [400, 600],
31
+ styles: ['normal'],
13
32
  },
14
33
  ],
15
34
  },
16
- });
35
+ };
36
+ /**
37
+ * Vite plugin that loads NubiscoUI's typefaces.
38
+ *
39
+ * Called with no arguments it self-hosts the library defaults (Plus Jakarta
40
+ * Sans + Fira Code) via Fontsource, keeping every existing consumer's output
41
+ * unchanged. Pass an options object to fully replace that configuration: load
42
+ * different families/weights, point the `custom` provider at your own woff2
43
+ * files, or use any other provider `unplugin-fonts` supports.
44
+ *
45
+ * @example
46
+ * // vite.config.ts (keep the NubiscoUI defaults)
47
+ * import { fonts } from '@nubisco/ui/plugins/fonts'
48
+ * export default defineConfig({ plugins: [fonts()] })
49
+ *
50
+ * @example
51
+ * // bring your own families/weights
52
+ * fonts({
53
+ * fontsource: {
54
+ * families: [
55
+ * { name: 'Inter', weights: [400, 600], styles: ['normal'] },
56
+ * { name: 'JetBrains Mono', weights: [400], styles: ['normal'] },
57
+ * ],
58
+ * },
59
+ * })
60
+ */
61
+ export const fonts = (options = DEFAULT_FONTS) => Unfonts(options);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nubisco/ui",
3
- "version": "1.40.0",
3
+ "version": "1.41.0",
4
4
  "description": "Vue 3 UI component library",
5
5
  "packageManager": "pnpm@11.0.8",
6
6
  "repository": {
@@ -120,6 +120,8 @@
120
120
  },
121
121
  "devDependencies": {
122
122
  "@eslint/js": "^10.0.1",
123
+ "@fontsource/fira-code": "^5.2.7",
124
+ "@fontsource/plus-jakarta-sans": "^5.2.8",
123
125
  "@phosphor-icons/core": "^2.1.1",
124
126
  "@semantic-release/changelog": "^6.0.3",
125
127
  "@semantic-release/git": "^10.0.1",
@@ -1,19 +1,71 @@
1
1
  import Unfonts from 'unplugin-fonts/vite'
2
2
 
3
- export const fonts = () =>
4
- Unfonts({
5
- google: {
6
- injectTo: 'head-prepend',
3
+ /**
4
+ * Options accepted by {@link fonts}. This is the exact option object that
5
+ * `unplugin-fonts` exposes, so any provider it supports (`fontsource`,
6
+ * `custom`, `google`, `typekit`) can be configured here.
7
+ */
8
+ export type TFontsOptions = NonNullable<Parameters<typeof Unfonts>[0]>
7
9
 
8
- families: [
9
- {
10
- name: 'Plus+Jakarta+Sans',
11
- styles: 'ital,wght@0,200..800;1,200..800',
12
- },
13
- {
14
- name: 'Fira+Code',
15
- styles: 'wght@300..700',
16
- },
17
- ],
18
- },
19
- })
10
+ /**
11
+ * Default font configuration for NubiscoUI.
12
+ *
13
+ * Self-hosted via the `fontsource` provider (RGPD-friendly, no third-party
14
+ * CDN). These are the two families declared as the library defaults in
15
+ * `src/styles/variables/_type.scss` (`--nb-font-family-sans` / `-mono`):
16
+ *
17
+ * - Plus Jakarta Sans: weights 400, 500, 600, 700 (sans default)
18
+ * - Fira Code: weights 400, 600 (mono default)
19
+ *
20
+ * Only `normal` styles are loaded. Every subset shipped by Fontsource is
21
+ * imported, but each `@font-face` carries a `unicode-range`, so the browser
22
+ * only downloads the subsets a page actually needs. `font-display: swap` is
23
+ * baked into the Fontsource stylesheets.
24
+ *
25
+ * Consumers must install the source packages themselves:
26
+ * `pnpm add -D @fontsource/plus-jakarta-sans @fontsource/fira-code`.
27
+ */
28
+ export const DEFAULT_FONTS: TFontsOptions = {
29
+ fontsource: {
30
+ families: [
31
+ {
32
+ name: 'Plus Jakarta Sans',
33
+ weights: [400, 500, 600, 700],
34
+ styles: ['normal'],
35
+ },
36
+ {
37
+ name: 'Fira Code',
38
+ weights: [400, 600],
39
+ styles: ['normal'],
40
+ },
41
+ ],
42
+ },
43
+ }
44
+
45
+ /**
46
+ * Vite plugin that loads NubiscoUI's typefaces.
47
+ *
48
+ * Called with no arguments it self-hosts the library defaults (Plus Jakarta
49
+ * Sans + Fira Code) via Fontsource, keeping every existing consumer's output
50
+ * unchanged. Pass an options object to fully replace that configuration: load
51
+ * different families/weights, point the `custom` provider at your own woff2
52
+ * files, or use any other provider `unplugin-fonts` supports.
53
+ *
54
+ * @example
55
+ * // vite.config.ts (keep the NubiscoUI defaults)
56
+ * import { fonts } from '@nubisco/ui/plugins/fonts'
57
+ * export default defineConfig({ plugins: [fonts()] })
58
+ *
59
+ * @example
60
+ * // bring your own families/weights
61
+ * fonts({
62
+ * fontsource: {
63
+ * families: [
64
+ * { name: 'Inter', weights: [400, 600], styles: ['normal'] },
65
+ * { name: 'JetBrains Mono', weights: [400], styles: ['normal'] },
66
+ * ],
67
+ * },
68
+ * })
69
+ */
70
+ export const fonts = (options: TFontsOptions = DEFAULT_FONTS) =>
71
+ Unfonts(options)