@rt-tools/ui-kit 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
@@ -1,99 +1,179 @@
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-container`, `rtui-aside-panel`, `rtui-popover-container`, `rtui-snack-bar`, `rtui-spinner`, `rtui-info-badge` |
78
+ | **Data display** | `rtui-table`, `rtui-dynamic-list`, `rtui-dynamic-selector`, `rtui-dynamic-input`, `rtui-multi-selector-popup`, `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
+ | `iconSize` | `RtuiIconSizeType` | derived from `size` |
95
+ | `text` | `string` | `''` |
96
+ | `loading` / `disabled` | `boolean` | `false` |
97
+
98
+ ```html
99
+ <rtui-button type="pill" variant="primary" appearance="outline" text="Confirm" icon="check" />
100
+ <rtui-button type="icon" icon="delete" variant="danger" />
101
+ <rtui-button type="pill" text="Loading" [loading]="true" />
102
+ ```
103
+
104
+ ## Theming
105
+
106
+ `RtThemeService` controls the active mode and brand palette from anywhere:
107
+
85
108
  ```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
- ```
109
+ import { inject } from '@angular/core';
110
+ import { RtThemeService } from '@rt-tools/ui-kit';
111
+
112
+ const theme = inject(RtThemeService);
113
+
114
+ theme.setTheme('dark'); // 'light' | 'dark' | 'auto'
115
+ theme.toggle();
116
+
117
+ // Register and activate a brand color scheme (tonal ramp, 0–100)
118
+ theme.registerColorScheme('teal', {
119
+ primary: { 40: '#5cb8b5', 60: '#1a9d99', 100: '#008582' },
120
+ brand: { 100: '#008582' },
121
+ });
122
+ theme.setColorScheme('teal'); // pass null to reset to the default palette
123
+ ```
124
+
125
+ Accent roles a scheme may override: `primary`, `info`, `success`, `warning`, `danger`, `brand`.
126
+ One ramp serves both light and dark — the active mode selects the tone. The chosen theme and
127
+ scheme are persisted per user.
128
+
129
+ ## Configuration resolution
130
+
131
+ Defaults are resolved most-specific-first:
132
+
133
+ 1. the component input on a concrete instance,
134
+ 2. `components.<name>` in `provideRtUi()`,
135
+ 3. `global` in `provideRtUi()`,
136
+ 4. the library default.
137
+
138
+ ## Design modes
139
+
140
+ Design-aware controls render in one of two modes:
141
+
142
+ - **`custom`** — the native rt-tools look driven by design tokens (default).
143
+ - **`material`** — the control renders as a real Angular Material component, so it matches
144
+ surrounding Material UI while you migrate.
145
+
146
+ ```html
147
+ <rtui-button design="material" type="pill" text="Native Material" />
148
+ ```
149
+
150
+ ## Using Material Symbols icons
151
+
152
+ `rtui-icon` (and icon-bearing components) render [Material Symbols](https://fonts.google.com/icons):
153
+
154
+ 1. Add the font to `index.html`:
155
+
156
+ ```html
157
+ <link rel="preconnect" href="https://fonts.gstatic.com" />
158
+ <link
159
+ href="https://fonts.googleapis.com/css2?family=Material+Symbols+Outlined:opsz,wght,FILL,GRAD@20..48,100..700,0..1,-50..200&display=block"
160
+ rel="stylesheet" />
161
+ ```
162
+
163
+ 2. Set the default font set in your root component:
164
+
165
+ ```typescript
166
+ import { inject } from '@angular/core';
167
+ import { MatIconRegistry } from '@angular/material/icon';
168
+
169
+ inject(MatIconRegistry).setDefaultFontSetClass('material-symbols-outlined');
170
+ ```
171
+
172
+ ## Documentation
173
+
174
+ Full API references and live examples are available in **Storybook** (`pnpm run storybook` in the
175
+ [repository](https://github.com/Eyhenij/rt-tools)).
176
+
177
+ ## License
178
+
179
+ [Apache-2.0](https://github.com/Eyhenij/rt-tools/blob/main/LICENSE) © Yauheni Krumin