@rt-tools/ui-kit 0.0.27 → 0.0.28

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
@@ -1,99 +1,178 @@
1
- # Set of utility types and functions for TypeScript
2
- Package uses Angular Signals (Angular 16+).
3
-
4
- ## Interfaces & Types
5
-
6
- * ```typescript
7
- IDictionary
8
- ```
9
- * ```typescript
10
- IntersectionType
11
- ```
12
- * ```typescript
13
- Modify
14
- ```
15
- * ```typescript
16
- IMapper
17
- ```
18
- * ```typescript
19
- Nullable
20
- ```
21
- * ```typescript
22
- PartialOmit
23
- ```
24
- * ```typescript
25
- Primitive
26
- ```
27
- * Makes selected props from a record optional
28
- ```typescript
29
- Optional
30
- ```
31
- * Get the union type of all the values in an object, array or array-like type
32
- ```typescript
33
- ValuesType
34
- ```
1
+ # @rt-tools/ui-kit
35
2
 
3
+ [![npm](https://img.shields.io/npm/v/@rt-tools/ui-kit?color=c00)](https://www.npmjs.com/package/@rt-tools/ui-kit)
4
+ [![Angular](https://img.shields.io/badge/Angular-22%2B-dd0031?logo=angular&logoColor=white)](https://angular.dev)
5
+ [![License](https://img.shields.io/badge/license-Apache--2.0-blue)](https://github.com/Eyhenij/rt-tools/blob/main/LICENSE)
36
6
 
37
- ## Functions
7
+ Themeable, signal-based UI components for Angular. Every component is standalone, tree-shakeable,
8
+ and driven by CSS design tokens with built-in light / dark / auto theming and swappable brand
9
+ color schemes.
38
10
 
11
+ ## Installation
12
+
13
+ ```bash
14
+ pnpm add @rt-tools/ui-kit
15
+ # or
16
+ npm install @rt-tools/ui-kit
17
+ ```
18
+
19
+ `@rt-tools/core`, `@rt-tools/store`, and `@rt-tools/utils` are installed automatically as dependencies.
20
+
21
+ **Peer requirements:** Angular `^22.0.0` (`@angular/core`, `common`, `forms`, `animations`,
22
+ `cdk`, `material`, `router`, `platform-browser`), `rxjs ^7.8.2`, `typescript ^6.0.0`.
23
+
24
+ ## Setup
25
+
26
+ Provide the UI configuration once at bootstrap:
39
27
 
40
- * ```typescript
41
- isDateValid(date?: Date): boolean;
42
- ```
43
- * ```typescript
44
- dateStringToDate(date: string | Date): Date;
45
- ```
46
- * Indicates if the arguments are equal
47
- ```typescript
48
- isEqual<T>(f: T, s: T): boolean;
49
- ```
50
- * Indicates if the content of two arrays is identical
51
- ```typescript
52
- areArraysEqual<T>(f: T[], s: T[]): boolean;
53
- ```
54
- * Indicates if the content of two arrays is identical
55
- ```typescript
56
- areObjectsEqual<T>(f: T, s: T): boolean;
57
- ```
58
- * ```typescript
59
- isNumber<T>(value: T | number | unknown | undefined): value is number;
60
- ```
61
- * ```typescript
62
- initToday(): Date;
63
- ```
64
- * ```typescript
65
- isToday(date: Date): boolean;
66
- ```
67
- * Make shallow copy of passed object
68
- ```typescript
69
- removeFieldFromObject<T extends object, K extends string>(obj: T, key: K): Omit<T, K>;
70
- ```
71
- * Allow to compare two values by provided comparator
72
- ```typescript
73
- safeCompare<T>(a: T, b: T, comparator: ComparatorType<T>): number;
74
- ```
75
- * Allow to safely compare two string values
76
28
  ```typescript
77
- safeStrCompare(a: string, b: string): number;
78
- ```
79
- * Allow to safely compare two number values
29
+ import { bootstrapApplication } from '@angular/platform-browser';
30
+ import { provideRtUi } from '@rt-tools/ui-kit';
31
+
32
+ bootstrapApplication(AppComponent, {
33
+ providers: [
34
+ provideRtUi({
35
+ global: { theme: 'auto', design: 'custom' },
36
+ components: { button: { size: 'md', appearance: 'solid' } },
37
+ }),
38
+ ],
39
+ });
40
+ ```
41
+
42
+ Import the design-token stylesheet so components and your own styles share the same `--rt-*` variables:
43
+
44
+ ```scss
45
+ @use '@rt-tools/ui-kit/styles/tokens.css';
46
+ ```
47
+
48
+ ## Usage
49
+
50
+ Components are standalone — import only what you use:
51
+
80
52
  ```typescript
81
- safeNumCompare(a: number, b: number): number;
82
- ```
83
- * Allow composing comparison chain of several comparators
84
- that delegate comparison by the chain to the next comparators if current comparator returns 0
53
+ import { Component } from '@angular/core';
54
+ import { RtuiButtonComponent } from '@rt-tools/ui-kit';
55
+
56
+ @Component({
57
+ selector: 'app-demo',
58
+ imports: [RtuiButtonComponent],
59
+ template: `
60
+ <rtui-button type="pill" variant="primary" text="Save" icon="check" (click)="save()" />
61
+ `,
62
+ })
63
+ export class DemoComponent {
64
+ save(): void {
65
+ /* ... */
66
+ }
67
+ }
68
+ ```
69
+
70
+ ## Components
71
+
72
+ All components use the `rtui-` prefix.
73
+
74
+ | Group | Components |
75
+ | --- | --- |
76
+ | **Actions & forms** | `rtui-button`, `rtui-multi-button`, `rtui-icon`, `rtui-checkbox`, `rtui-toggle`, `rtui-file-upload`, `rtui-image-upload` |
77
+ | **Overlays & feedback** | `rtui-modal`, `rtui-aside`, `rtui-popover`, `rtui-snack-bar`, `rtui-spinner`, `rtui-info-badge` |
78
+ | **Data display** | `rtui-table`, `rtui-dynamic-list`, `rtui-dynamic-selector`, `rtui-dynamic-input`, `rtui-pagination` |
79
+ | **Layout & navigation** | `rtui-header`, `rtui-toolbar`, `rtui-side-menu`, `rtui-scrollable`, `rtui-action-bar` |
80
+
81
+ ### `rtui-button`
82
+
83
+ The button is fully configurable through inputs (all with sensible defaults):
84
+
85
+ | Input | Type | Default |
86
+ | --- | --- | --- |
87
+ | `type` | `'icon' \| 'fab' \| 'pill'` | `'icon'` |
88
+ | `variant` | `'default' \| 'primary' \| 'danger' \| 'success' \| 'warning' \| 'accent'` | `'default'` |
89
+ | `appearance` | `'solid' \| 'outline' \| 'light' \| 'text'` | config / `'solid'` |
90
+ | `size` | `'xs' \| 'sm' \| 'md' \| 'lg'` | config / `'md'` |
91
+ | `radius` | `'none' \| 'sm' \| 'md' \| 'lg' \| 'full'` | config / `'full'` |
92
+ | `design` | `'custom' \| 'material'` | config / `'custom'` |
93
+ | `icon` / `iconPosition` | `string` / `'start' \| 'end'` | `''` / `'start'` |
94
+ | `text` | `string` | `''` |
95
+ | `loading` / `disabled` | `boolean` | `false` |
96
+
97
+ ```html
98
+ <rtui-button type="pill" variant="primary" appearance="outline" text="Confirm" icon="check" />
99
+ <rtui-button type="icon" icon="delete" variant="danger" />
100
+ <rtui-button type="pill" text="Loading" [loading]="true" />
101
+ ```
102
+
103
+ ## Theming
104
+
105
+ `RtThemeService` controls the active mode and brand palette from anywhere:
106
+
85
107
  ```typescript
86
- safeComparatorPipe(...comparators: Array<() => number>): number;
87
- ```
88
- * ```typescript
89
- sortByAlphabet: <T extends object>(a: T, b: T, field: keyof T) => number;
90
- ```
91
- * ```typescript
92
- sortByDate: (a: { [field: string]: any }, b: { [field: string]: any }, field: string) => number
93
- ```
94
- * ```typescript
95
- stringifyHttpLikeParams<T extends {}>(params: T): { [param: string]: string | string[] }
96
- ```
97
- * ```typescript
98
- transformArrayInput<T>(array: unknown): T[]
99
- ```
108
+ import { inject } from '@angular/core';
109
+ import { RtThemeService } from '@rt-tools/ui-kit';
110
+
111
+ const theme = inject(RtThemeService);
112
+
113
+ theme.setTheme('dark'); // 'light' | 'dark' | 'auto'
114
+ theme.toggle();
115
+
116
+ // Register and activate a brand color scheme (tonal ramp, 0–100)
117
+ theme.registerColorScheme('teal', {
118
+ primary: { 40: '#5cb8b5', 60: '#1a9d99', 100: '#008582' },
119
+ brand: { 100: '#008582' },
120
+ });
121
+ theme.setColorScheme('teal'); // pass null to reset to the default palette
122
+ ```
123
+
124
+ Accent roles a scheme may override: `primary`, `info`, `success`, `warning`, `danger`, `brand`.
125
+ One ramp serves both light and dark — the active mode selects the tone. The chosen theme and
126
+ scheme are persisted per user.
127
+
128
+ ## Configuration resolution
129
+
130
+ Defaults are resolved most-specific-first:
131
+
132
+ 1. the component input on a concrete instance,
133
+ 2. `components.<name>` in `provideRtUi()`,
134
+ 3. `global` in `provideRtUi()`,
135
+ 4. the library default.
136
+
137
+ ## Design modes
138
+
139
+ Design-aware controls render in one of two modes:
140
+
141
+ - **`custom`** — the native rt-tools look driven by design tokens (default).
142
+ - **`material`** — the control renders as a real Angular Material component, so it matches
143
+ surrounding Material UI while you migrate.
144
+
145
+ ```html
146
+ <rtui-button design="material" type="pill" text="Native Material" />
147
+ ```
148
+
149
+ ## Using Material Symbols icons
150
+
151
+ `rtui-icon` (and icon-bearing components) render [Material Symbols](https://fonts.google.com/icons):
152
+
153
+ 1. Add the font to `index.html`:
154
+
155
+ ```html
156
+ <link rel="preconnect" href="https://fonts.gstatic.com" />
157
+ <link
158
+ href="https://fonts.googleapis.com/css2?family=Material+Symbols+Outlined:opsz,wght,FILL,GRAD@20..48,100..700,0..1,-50..200&display=block"
159
+ rel="stylesheet" />
160
+ ```
161
+
162
+ 2. Set the default font set in your root component:
163
+
164
+ ```typescript
165
+ import { inject } from '@angular/core';
166
+ import { MatIconRegistry } from '@angular/material/icon';
167
+
168
+ inject(MatIconRegistry).setDefaultFontSetClass('material-symbols-outlined');
169
+ ```
170
+
171
+ ## Documentation
172
+
173
+ Full API references and live examples are available in **Storybook** (`pnpm run storybook` in the
174
+ [repository](https://github.com/Eyhenij/rt-tools)).
175
+
176
+ ## License
177
+
178
+ [Apache-2.0](https://github.com/Eyhenij/rt-tools/blob/main/LICENSE) © Yauheni Krumin
package/package.json CHANGED
@@ -1,19 +1,19 @@
1
1
  {
2
2
  "name": "@rt-tools/ui-kit",
3
- "version": "0.0.27",
3
+ "version": "0.0.28",
4
4
  "license": "Apache-2.0",
5
5
  "author": "Yauheni Krumin",
6
6
  "type": "module",
7
7
  "dependencies": {
8
8
  "tslib": "^2.8.0",
9
- "@rt-tools/core": "^0.0.5",
10
- "@rt-tools/store": "^0.0.6",
11
- "@rt-tools/utils": "^0.0.7"
9
+ "@rt-tools/core": "^0.0.6",
10
+ "@rt-tools/store": "^0.0.7",
11
+ "@rt-tools/utils": "^0.0.8"
12
12
  },
13
13
  "peerDependencies": {
14
- "@rt-tools/core": "^0.0.5",
15
- "@rt-tools/store": "^0.0.6",
16
- "@rt-tools/utils": "^0.0.7",
14
+ "@rt-tools/core": "^0.0.6",
15
+ "@rt-tools/store": "^0.0.7",
16
+ "@rt-tools/utils": "^0.0.8",
17
17
  "@angular/animations": "^22.0.0",
18
18
  "@angular/cdk": "^22.0.0",
19
19
  "@angular/common": "^22.0.0",
Binary file
Binary file