@ng-shangjc/utils 0.0.1-beta → 0.0.1
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/package.json +1 -1
- package/README.md +0 -155
- package/styles/collapse.css +0 -15
- package/styles/expand.css +0 -14
- package/styles/fade-in.css +0 -12
- package/styles/fade-out.css +0 -12
- package/styles/fade-scale-in.css +0 -18
package/package.json
CHANGED
package/README.md
DELETED
|
@@ -1,155 +0,0 @@
|
|
|
1
|
-
# @ng-shangjc/utils
|
|
2
|
-
|
|
3
|
-
A comprehensive utility library for Angular Shangjc Components that provides essential tools for building modern UI components with Tailwind CSS.
|
|
4
|
-
|
|
5
|
-
## 🚀 Features
|
|
6
|
-
|
|
7
|
-
- **Class Name Utility (`cn`)** - Smart Tailwind CSS class merging with conflict resolution
|
|
8
|
-
- **Portal Host Directive** - Angular directive for managing portal elements
|
|
9
|
-
- **Animation Styles** - Pre-built CSS animations for smooth transitions
|
|
10
|
-
|
|
11
|
-
## 📦 Installation
|
|
12
|
-
|
|
13
|
-
```bash
|
|
14
|
-
npm install @ng-shangjc/utils
|
|
15
|
-
```
|
|
16
|
-
|
|
17
|
-
### Peer Dependencies
|
|
18
|
-
|
|
19
|
-
This package requires the following peer dependencies:
|
|
20
|
-
|
|
21
|
-
```bash
|
|
22
|
-
npm install @angular/common @angular/core clsx tailwind-merge
|
|
23
|
-
```
|
|
24
|
-
|
|
25
|
-
**Compatible Angular versions:** `^17.0.0 || ^18.0.0 || ^19.0.0 || ^20.0.0 || ^21.0.0`
|
|
26
|
-
|
|
27
|
-
## 🔧 Usage
|
|
28
|
-
|
|
29
|
-
### Class Name Utility (`cn`)
|
|
30
|
-
|
|
31
|
-
The `cn` function combines `clsx` and `tailwind-merge` to provide intelligent class merging that respects Tailwind CSS specificity rules.
|
|
32
|
-
|
|
33
|
-
```typescript
|
|
34
|
-
import { cn } from '@ng-shangjc/utils';
|
|
35
|
-
|
|
36
|
-
// Basic usage
|
|
37
|
-
const classes = cn('text-red-500', 'bg-blue-500');
|
|
38
|
-
|
|
39
|
-
// With conditional classes
|
|
40
|
-
const isActive = true;
|
|
41
|
-
const isDisabled = false;
|
|
42
|
-
const classes = cn(
|
|
43
|
-
'base-class',
|
|
44
|
-
isActive && 'text-blue-500',
|
|
45
|
-
isDisabled ? 'opacity-50' : 'opacity-100'
|
|
46
|
-
);
|
|
47
|
-
|
|
48
|
-
// Handles class conflicts automatically
|
|
49
|
-
const classes = cn('text-red-500', 'text-blue-500'); // Result: 'text-blue-500'
|
|
50
|
-
```
|
|
51
|
-
|
|
52
|
-
### Portal Host Directive
|
|
53
|
-
|
|
54
|
-
The `portalHost` directive allows you to render elements outside their normal DOM hierarchy, useful for modals, tooltips, and overlays.
|
|
55
|
-
|
|
56
|
-
```typescript
|
|
57
|
-
import { Component } from '@angular/core';
|
|
58
|
-
|
|
59
|
-
@Component({
|
|
60
|
-
selector: 'app-example',
|
|
61
|
-
template: `
|
|
62
|
-
<div portalHost class="modal-content">
|
|
63
|
-
<!-- This content will be moved to document.body -->
|
|
64
|
-
<h2>Modal Content</h2>
|
|
65
|
-
<p>This is rendered outside the normal DOM flow</p>
|
|
66
|
-
</div>
|
|
67
|
-
`
|
|
68
|
-
})
|
|
69
|
-
export class ExampleComponent {}
|
|
70
|
-
```
|
|
71
|
-
|
|
72
|
-
**Features:**
|
|
73
|
-
- Automatically moves the element to `document.body` on initialization
|
|
74
|
-
- Handles Escape key events to prevent unwanted behavior
|
|
75
|
-
- Cleans up the element when the directive is destroyed
|
|
76
|
-
|
|
77
|
-
### Animation Styles
|
|
78
|
-
|
|
79
|
-
Import the CSS animation files to use pre-built animations:
|
|
80
|
-
|
|
81
|
-
```css
|
|
82
|
-
/* In your global styles or component styles */
|
|
83
|
-
@import '@ng-shangjc/utils/styles/fade-scale-in.css';
|
|
84
|
-
@import '@ng-shangjc/utils/styles/fade-in.css';
|
|
85
|
-
@import '@ng-shangjc/utils/styles/fade-out.css';
|
|
86
|
-
@import '@ng-shangjc/utils/styles/collapse.css';
|
|
87
|
-
@import '@ng-shangjc/utils/styles/expand.css';
|
|
88
|
-
```
|
|
89
|
-
|
|
90
|
-
#### Available Animations
|
|
91
|
-
|
|
92
|
-
- **fade-scale-in** - Fade in with scale effect (0 to 1)
|
|
93
|
-
- **fade-in** - Simple fade in animation
|
|
94
|
-
- **fade-out** - Simple fade out animation
|
|
95
|
-
- **collapse** - Collapse animation
|
|
96
|
-
- **expand** - Expand animation
|
|
97
|
-
|
|
98
|
-
## 🎯 API Reference
|
|
99
|
-
|
|
100
|
-
### `cn(...inputs: ClassValue[]): string`
|
|
101
|
-
|
|
102
|
-
Merges class names using clsx and tailwind-merge.
|
|
103
|
-
|
|
104
|
-
**Parameters:**
|
|
105
|
-
- `inputs` - Variable number of class values (strings, objects, arrays)
|
|
106
|
-
|
|
107
|
-
**Returns:**
|
|
108
|
-
- Merged class name string with conflicts resolved
|
|
109
|
-
|
|
110
|
-
### `portalHost` Directive
|
|
111
|
-
|
|
112
|
-
**Selector:** `[portalHost]`
|
|
113
|
-
|
|
114
|
-
**Properties:**
|
|
115
|
-
- `element: HTMLElement` - Reference to the native DOM element
|
|
116
|
-
|
|
117
|
-
**Lifecycle Hooks:**
|
|
118
|
-
- `ngAfterViewInit()` - Moves element to document.body and sets up event handlers
|
|
119
|
-
- `ngOnDestroy()` - Removes element from DOM
|
|
120
|
-
|
|
121
|
-
## 🏗️ Development
|
|
122
|
-
|
|
123
|
-
This package is built with Angular's library format using ng-packagr.
|
|
124
|
-
|
|
125
|
-
### Building
|
|
126
|
-
|
|
127
|
-
```bash
|
|
128
|
-
npm run build
|
|
129
|
-
```
|
|
130
|
-
|
|
131
|
-
### Testing
|
|
132
|
-
|
|
133
|
-
```bash
|
|
134
|
-
npm run test
|
|
135
|
-
```
|
|
136
|
-
|
|
137
|
-
## 📄 License
|
|
138
|
-
|
|
139
|
-
This package is part of the ng-shadcn project. See the main project license for details.
|
|
140
|
-
|
|
141
|
-
## 🔗 Related Packages
|
|
142
|
-
|
|
143
|
-
- [@ng-shangjc/components](https://www.npmjs.com/package/@ng-shangjc/components) - UI components built with these utilities
|
|
144
|
-
|
|
145
|
-
## 🤝 Contributing
|
|
146
|
-
|
|
147
|
-
Contributions are welcome! Please read our contributing guidelines before submitting pull requests.
|
|
148
|
-
|
|
149
|
-
## 📝 Changelog
|
|
150
|
-
|
|
151
|
-
### 0.0.1
|
|
152
|
-
- Initial release
|
|
153
|
-
- Added `cn` utility function
|
|
154
|
-
- Added `portalHost` directive
|
|
155
|
-
- Added basic animation styles
|
package/styles/collapse.css
DELETED
package/styles/expand.css
DELETED
package/styles/fade-in.css
DELETED
package/styles/fade-out.css
DELETED