@letsprogram/ng-oat 0.1.1 → 0.1.2

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
@@ -73,7 +73,7 @@ Open `angular.json` and add the stylesheet, tokens, and script:
73
73
 
74
74
  ### 3. Configure the provider
75
75
 
76
- Add `provideNgOat()` to your application config:
76
+ Add `provideNgOat()` to your application config. Since CSS and JS are already loaded via `angular.json`, the provider only sets up internal injection tokens — no runtime asset loading occurs by default.
77
77
 
78
78
  ```typescript
79
79
  // src/app/app.config.ts
@@ -3,7 +3,7 @@ import { makeEnvironmentProviders, provideAppInitializer, inject, PLATFORM_ID, I
3
3
  import { DOCUMENT, isPlatformBrowser } from '@angular/common';
4
4
 
5
5
  const DEFAULT_OPTIONS = {
6
- assets: { css: 'auto', js: 'auto' },
6
+ assets: { css: false, js: false },
7
7
  registerWebComponents: true,
8
8
  basePath: 'assets/oat',
9
9
  };
@@ -22,14 +22,18 @@ function injectTag(doc, tag, attrs, id) {
22
22
  });
23
23
  }
24
24
  /**
25
- * Provides Oat UI assets and initialisation.
25
+ * Provides Oat UI core initialisation.
26
+ *
27
+ * By default, CSS and JS are **not** injected at runtime — add them via
28
+ * `angular.json` `styles` / `scripts` arrays instead (recommended).
26
29
  *
27
- * Include in your app config providers array:
28
30
  * ```ts
29
- * provideNgOat() // auto-inject CSS + JS
30
- * provideNgOat({ assets: { css: false } }) // user imported CSS manually
31
- * provideNgOat({ basePath: '/custom/oat' }) // custom asset location
31
+ * provideNgOat() // recommended (CSS/JS via angular.json)
32
+ * provideNgOat({ assets: { css: 'link', js: 'script' } }) // opt-in runtime injection *
32
33
  * ```
34
+ *
35
+ * \* Runtime injection requires an assets glob in angular.json to copy files:
36
+ * `{ glob: '**\/*', input: 'node_modules/@letsprogram/ng-oat/assets/oat', output: '/assets/oat' }`
33
37
  */
34
38
  function provideNgOat(options) {
35
39
  const opts = {
@@ -46,15 +50,13 @@ function provideNgOat(options) {
46
50
  const base = opts.basePath.replace(/\/+$/, '');
47
51
  const promises = [];
48
52
  // CSS
49
- const cssMode = opts.assets.css === 'auto' ? 'link' : opts.assets.css;
50
- if (cssMode === 'link') {
53
+ if (opts.assets.css === 'link') {
51
54
  promises.push(injectTag(doc, 'link', { rel: 'stylesheet', href: `${base}/oat.min.css` }, 'ng-oat-css'));
52
55
  // Also inject the token layer CSS
53
56
  promises.push(injectTag(doc, 'link', { rel: 'stylesheet', href: `${base}/tokens.css` }, 'ng-oat-tokens-css'));
54
57
  }
55
58
  // JS
56
- const jsMode = opts.assets.js === 'auto' ? 'script' : opts.assets.js;
57
- if (jsMode === 'script') {
59
+ if (opts.assets.js === 'script') {
58
60
  promises.push(injectTag(doc, 'script', { src: `${base}/oat.min.js`, defer: '' }, 'ng-oat-js'));
59
61
  }
60
62
  return Promise.all(promises).then(() => { });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@letsprogram/ng-oat",
3
- "version": "0.1.1",
3
+ "version": "0.1.2",
4
4
  "description": "Angular component library built on top of the Oat CSS framework — signals-first, lightweight, and accessible.",
5
5
  "license": "MIT",
6
6
  "author": "SashiKumar Yadav",
@@ -36,9 +36,16 @@
36
36
  "publishConfig": {
37
37
  "access": "public"
38
38
  },
39
- "module": "fesm2022/letsprogram-ng-oat.mjs",
40
- "typings": "types/letsprogram-ng-oat.d.ts",
41
39
  "exports": {
40
+ "./assets/*": {
41
+ "default": "./assets/*"
42
+ },
43
+ "./src/lib/styles/*": {
44
+ "default": "./src/lib/styles/*"
45
+ },
46
+ "./src/lib/tokens/*": {
47
+ "default": "./src/lib/tokens/*"
48
+ },
42
49
  "./package.json": {
43
50
  "default": "./package.json"
44
51
  },
@@ -50,5 +57,7 @@
50
57
  "types": "./types/letsprogram-ng-oat-cdk.d.ts",
51
58
  "default": "./fesm2022/letsprogram-ng-oat-cdk.mjs"
52
59
  }
53
- }
60
+ },
61
+ "module": "fesm2022/letsprogram-ng-oat.mjs",
62
+ "typings": "types/letsprogram-ng-oat.d.ts"
54
63
  }
@@ -5,25 +5,43 @@ import { FormCheckboxControl, FormValueControl, ValidationError, FieldState } fr
5
5
  /** Configuration for provideNgOat() */
6
6
  interface NgOatOptions {
7
7
  assets?: {
8
- /** How to load Oat CSS. 'auto' = 'link'. false = skip. */
9
- css?: 'auto' | 'link' | 'import' | false;
10
- /** How to load Oat JS. 'auto' = 'script'. false = skip. */
11
- js?: 'auto' | 'script' | false;
8
+ /**
9
+ * How to load Oat CSS at runtime.
10
+ * - `false` (default) CSS is loaded via angular.json styles array (recommended).
11
+ * - `'link'` dynamically inject a `<link>` tag (requires assets glob in angular.json).
12
+ * - `'import'` — reserved for future use.
13
+ */
14
+ css?: 'link' | 'import' | false;
15
+ /**
16
+ * How to load Oat JS at runtime.
17
+ * - `false` (default) — JS is loaded via angular.json scripts array (recommended).
18
+ * - `'script'` — dynamically inject a `<script>` tag (requires assets glob in angular.json).
19
+ */
20
+ js?: 'script' | false;
12
21
  };
13
22
  /** Register ot-tabs/ot-dropdown custom elements from Oat JS (default: true). */
14
23
  registerWebComponents?: boolean;
15
- /** Base path for vendored Oat assets (default: 'assets/oat'). */
24
+ /**
25
+ * Base path for vendored Oat assets when using dynamic injection (`css: 'link'` or `js: 'script'`).
26
+ * Only relevant if you opted into runtime injection AND configured an assets glob
27
+ * to copy files from `node_modules/@letsprogram/ng-oat/assets/oat` to this path.
28
+ * Default: `'assets/oat'`.
29
+ */
16
30
  basePath?: string;
17
31
  }
18
32
  /**
19
- * Provides Oat UI assets and initialisation.
33
+ * Provides Oat UI core initialisation.
34
+ *
35
+ * By default, CSS and JS are **not** injected at runtime — add them via
36
+ * `angular.json` `styles` / `scripts` arrays instead (recommended).
20
37
  *
21
- * Include in your app config providers array:
22
38
  * ```ts
23
- * provideNgOat() // auto-inject CSS + JS
24
- * provideNgOat({ assets: { css: false } }) // user imported CSS manually
25
- * provideNgOat({ basePath: '/custom/oat' }) // custom asset location
39
+ * provideNgOat() // recommended (CSS/JS via angular.json)
40
+ * provideNgOat({ assets: { css: 'link', js: 'script' } }) // opt-in runtime injection *
26
41
  * ```
42
+ *
43
+ * \* Runtime injection requires an assets glob in angular.json to copy files:
44
+ * `{ glob: '**\/*', input: 'node_modules/@letsprogram/ng-oat/assets/oat', output: '/assets/oat' }`
27
45
  */
28
46
  declare function provideNgOat(options?: NgOatOptions): EnvironmentProviders;
29
47