@jdpo2008/ngx-ds 0.1.0 → 0.3.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
@@ -4,15 +4,25 @@ An Angular 21 component library: standalone components, a signal-based API, `OnP
4
4
 
5
5
  ## Install
6
6
 
7
+ ```bash
8
+ ng add @jdpo2008/ngx-ds
9
+ ```
10
+
11
+ `ng add` installs the package and `lucide-angular`, and adds the design tokens stylesheet to the `styles` of your application in `angular.json`. In a workspace with several applications, pass `--project <name>`.
12
+
13
+ To set it up by hand instead:
14
+
7
15
  ```bash
8
16
  npm install @jdpo2008/ngx-ds lucide-angular
9
17
  ```
10
18
 
19
+ then load the stylesheet as described in [Styles](#styles).
20
+
11
21
  Peer dependencies: `@angular/common`, `@angular/core`, `@angular/forms` and `@angular/platform-browser` 21, and `lucide-angular` 1.
12
22
 
13
23
  ## Styles
14
24
 
15
- Load the design tokens once, globally. Add the stylesheet to `angular.json`:
25
+ `ng add` does this for you. Otherwise, load the design tokens once, globally. Add the stylesheet to `angular.json`:
16
26
 
17
27
  ```json
18
28
  "styles": ["node_modules/@jdpo2008/ngx-ds/styles/ngx-ds.scss", "src/styles.scss"]
@@ -36,7 +46,7 @@ Every color is a CSS custom property (`--primary-600`, `--text-base`, `--surface
36
46
  }
37
47
  ```
38
48
 
39
- The dark theme is opt-in. Set `data-theme="dark"` on `<html>` or add the `dark` class to an ancestor.
49
+ The dark theme is opt-in. Set `data-theme="dark"` on `<html>`, add the `dark` class to an ancestor, or use the `theme` option of `provideNgxDs()` (see [Configuration](#configuration)).
40
50
 
41
51
  ## Usage
42
52
 
@@ -62,6 +72,23 @@ export class AppComponent {
62
72
 
63
73
  Form controls (Input, Select, Checkbox, Datepicker, …) implement `ControlValueAccessor`, so they also work with `ngModel` and reactive forms. SearchInput is the exception: bind it with `[(value)]`.
64
74
 
75
+ They also work with Signal Forms (`@angular/forms/signals`, experimental in Angular 21). Bind them with `[formField]`:
76
+
77
+ ```ts
78
+ import { FormField, form, required } from '@angular/forms/signals';
79
+
80
+ @Component({
81
+ imports: [FormField, InputComponent],
82
+ template: `<ngx-ds-input label="Name" [formField]="f.name" />`,
83
+ })
84
+ export class Profile {
85
+ model = signal({ name: '' });
86
+ f = form(this.model, (p) => required(p.name, { message: 'Name is required' }));
87
+ }
88
+ ```
89
+
90
+ The field's value, touched and disabled state stay in sync. The field's `min` and `max` validators also set the limits of NumberInput and RangeSlider, and `max` sets the star count of Rating. Once the field is touched, its errors show automatically: Input, Textarea, NumberInput, Select, Dropdown, Autocomplete, MultiSelect, Datepicker and DateRangePicker show the first error's `message` and switch to the error style. An error without a `message` only switches the style. An explicit `[errorMessage]` takes priority.
91
+
65
92
  ### Toasts and confirmations
66
93
 
67
94
  Place the hosts once, usually in the root component, and trigger them from the services:
@@ -84,18 +111,26 @@ const ok = await confirmation.confirm({
84
111
  });
85
112
  ```
86
113
 
87
- ### Language
114
+ ### Configuration
88
115
 
89
- Labels default to Spanish and dates to `es-ES`. To switch app-wide:
116
+ Labels default to Spanish and dates to `es-ES`. Configure the library app-wide with `provideNgxDs()`:
90
117
 
91
118
  ```ts
92
- import { NGX_DS_LABELS_EN, provideNgxDsLabels, provideNgxDsLocale } from '@jdpo2008/ngx-ds';
119
+ import { provideNgxDs } from '@jdpo2008/ngx-ds';
93
120
 
94
121
  bootstrapApplication(AppComponent, {
95
- providers: [provideNgxDsLabels(NGX_DS_LABELS_EN), provideNgxDsLocale('en-US')],
122
+ providers: [provideNgxDs({ locale: 'en-US', labels: { close: 'Dismiss' }, theme: 'system' })],
96
123
  });
97
124
  ```
98
125
 
126
+ | Option | Default | Effect |
127
+ | -------- | --------- | --------------------------------------------------------------------------------------------------------------------------------------------------------- |
128
+ | `locale` | `'es-ES'` | Month and weekday names, date and number formatting. An `en-*` locale also switches the labels to English. |
129
+ | `labels` | — | Overrides individual labels. Missing keys come from the locale's set. |
130
+ | `theme` | — | `'light'`, `'dark'` or `'system'` (follows `prefers-color-scheme` and updates live). Sets `data-theme` on `<html>`. Omit it to manage the theme yourself. |
131
+
132
+ `provideNgxDsLocale()` and `provideNgxDsLabels()` still work for setting one thing at a time.
133
+
99
134
  ## Components
100
135
 
101
136
  - **Atoms:** Avatar, Badge, Button, Divider, Icon, IconButton, Kbd, MenuButton, ProgressBar, Skeleton, Spinner, Tag, Tooltip.