ngx-skeleton-loader 12.0.0 → 14.0.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/CHANGELOG.md +61 -1
- package/README.md +184 -2
- package/fesm2022/ngx-skeleton-loader.mjs +84 -46
- package/fesm2022/ngx-skeleton-loader.mjs.map +1 -1
- package/package.json +3 -2
- package/types/ngx-skeleton-loader.d.ts +51 -9
package/CHANGELOG.md
CHANGED
|
@@ -5,8 +5,66 @@ All notable changes to this project will be documented in this file.
|
|
|
5
5
|
The format is based on [Keep a Changelog](http://keepachangelog.com/)
|
|
6
6
|
and this project adheres to [Semantic Versioning](http://semver.org/).
|
|
7
7
|
|
|
8
|
+
|
|
8
9
|
## [Unreleased][]
|
|
9
10
|
|
|
11
|
+
## [14.0.0][] - 2026-10-20
|
|
12
|
+
|
|
13
|
+
### Changed
|
|
14
|
+
|
|
15
|
+
#### Breaking Change
|
|
16
|
+
|
|
17
|
+
- WAI-ARIA attributes (`role="progressbar"`, `aria-busy`, `aria-valuemin`, `aria-valuemax`, `aria-label` and `aria-valuetext`) are now applied once in the `<ngx-skeleton-loader>` element, instead of in every skeleton item, so screen readers announce a single progress bar per component. Skeleton items are hidden from assistive technologies via `aria-hidden="true"` and no longer have `tabindex="-1"`. Code or tests querying these attributes in `.skeleton-loader` items need to query the `<ngx-skeleton-loader>` element instead - https://github.com/willmendesneto/ngx-skeleton-loader/pull/297
|
|
18
|
+
- `<ngx-skeleton-loader>` is now rendered as a block element (`display: block`), wrapping its skeleton items. Multiple `<ngx-skeleton-loader>` elements placed side by side as inline elements (without a flex or grid container) are now rendered in separate lines - https://github.com/willmendesneto/ngx-skeleton-loader/pull/298
|
|
19
|
+
|
|
20
|
+
#### Other Changes
|
|
21
|
+
|
|
22
|
+
- Migrating CI from CircleCI to GitHub Actions, adding an SSR server check (`npm run test:ssr`) and Dependabot updates for GitHub Actions - https://github.com/willmendesneto/ngx-skeleton-loader/pull/303
|
|
23
|
+
- Removing `extendsFromRoot` flag from the styles applied to skeletons, since it's not a valid CSS property - https://github.com/willmendesneto/ngx-skeleton-loader/pull/276
|
|
24
|
+
- Linting demo app and e2e files via `npm run lint`, fixing existing lint errors - https://github.com/willmendesneto/ngx-skeleton-loader/pull/285
|
|
25
|
+
- Improving rendering performance by scoping CSS `will-change` to the animated parts only: `transform` on the `progress`/`progress-dark` shimmer and `opacity` on `pulse`/`pulse-dark`. Skeletons without animation, or rendered with `prefers-reduced-motion: reduce`, are no longer promoted to their own GPU layer. In the demo page (95 skeletons), composited layers dropped from 137 to 82 with animations and from 90 to 5 with reduced motion - https://github.com/willmendesneto/ngx-skeleton-loader/pull/277
|
|
26
|
+
- Replacing `transform: translate3d(0, 0, 0)` with `isolation: isolate` in `progress`/`progress-dark` skeletons, keeping the shimmer clipped by `border-radius` without an extra GPU layer - https://github.com/willmendesneto/ngx-skeleton-loader/pull/277
|
|
27
|
+
- Replacing deprecated `min-device-width` media query with `(hover: hover) and (pointer: fine)` to show the `wait` cursor and disable text selection only on devices with mouse/trackpad. Desktop and touch devices keep the same behavior, but it now also covers laptops with smaller screens and tablets with mouse/trackpad - https://github.com/willmendesneto/ngx-skeleton-loader/pull/280
|
|
28
|
+
- Removing unused and duplicated CSS rules (unused `:after` pseudo-element styles, duplicated `box-sizing`, and `prefers-reduced-motion` rules for `custom-content`/`pulse-dark` that had no effect), decreasing bundle size from 3.99KB to 3.96KB (gzip) - https://github.com/willmendesneto/ngx-skeleton-loader/pull/280
|
|
29
|
+
- Adding CSS containment (`contain: layout paint`) to skeletons. It isolates the skeleton layout and paint work from the rest of the page, so changes inside of a skeleton (e.g. animations or `custom-content`) don't trigger layout/paint work outside of it. There are no visual changes, since skeletons were already using `overflow: hidden` and `position: relative` - https://github.com/willmendesneto/ngx-skeleton-loader/pull/279
|
|
30
|
+
- Improving `progress` and `progress-dark` animations by making the shimmer cross the skeleton based on its own width, instead of the viewport width (`100vw`). Previously, small skeletons (e.g. a `40px` circle) displayed the shimmer for only a fraction of the animation duration, spending the rest of it animating an invisible (clipped) element. Now the shimmer is visible during the whole animation, starting right before the skeleton left edge and finishing right after its right edge, for any skeleton width. The animation is still composited (`transform` only) - https://github.com/willmendesneto/ngx-skeleton-loader/pull/278
|
|
31
|
+
- Using a single class binding for skeleton items, instead of one binding per appearance/animation class - https://github.com/willmendesneto/ngx-skeleton-loader/pull/290
|
|
32
|
+
- Removing redundant `standalone: true` and using `styleUrl` in `NgxSkeletonLoaderComponent` - https://github.com/willmendesneto/ngx-skeleton-loader/pull/288
|
|
33
|
+
- Removing unused dependencies (`@angular/animations`, `@angular/forms`, `@angular/platform-browser-dynamic`, `core-js`, `ts-node` and `zone.js`) and using zoneless change detection in the demo app - https://github.com/willmendesneto/ngx-skeleton-loader/pull/291
|
|
34
|
+
- Adding GPU layers count regression e2e tests - https://github.com/willmendesneto/ngx-skeleton-loader/pull/299
|
|
35
|
+
- Checking the package in an app using the minimum `peerDependencies` version (Angular 19) in CI - https://github.com/willmendesneto/ngx-skeleton-loader/pull/300
|
|
36
|
+
|
|
37
|
+
### Added
|
|
38
|
+
|
|
39
|
+
- Adding `wave` animation, similar to `progress` but with an oblique shimmer - https://github.com/willmendesneto/ngx-skeleton-loader/pull/295
|
|
40
|
+
- Adding stagger effect via `--ngx-skeleton-loader-animation-stagger` CSS custom property (`0s` by default), delaying each item animation based on its index. Items also expose their index via `--ngx-skeleton-loader-index`, which can be used in custom animations - https://github.com/willmendesneto/ngx-skeleton-loader/pull/294
|
|
41
|
+
- Adding right-to-left (RTL) support for `progress` and `progress-dark` animations: the shimmer crosses the skeleton from right to left when rendered in a `dir="rtl"` context - https://github.com/willmendesneto/ngx-skeleton-loader/pull/293
|
|
42
|
+
- Adding `width`, `height` and `borderRadius` inputs as shortcuts for the most common `[theme]` styles, accepting the same values as `size` - https://github.com/willmendesneto/ngx-skeleton-loader/pull/296
|
|
43
|
+
- Adding types for `theme` values (strings or numbers) instead of `any`, raising TypeScript errors for invalid values such as objects or arrays - https://github.com/willmendesneto/ngx-skeleton-loader/pull/289
|
|
44
|
+
|
|
45
|
+
- Adding opt-in dark mode. Skeletons keep light colors by default, as in previous versions, and dark mode can be enabled via `colorScheme` input or config (`auto` follows the user's color scheme preference, `dark` forces dark colors) or via `--ngx-skeleton-loader-color-scheme` CSS custom property, using `light-dark()` for the default base and shimmer colors - https://github.com/willmendesneto/ngx-skeleton-loader/pull/283 and https://github.com/willmendesneto/ngx-skeleton-loader/pull/305
|
|
46
|
+
- Adding support for type-safe custom animations. Consumers can register their own animation names by extending `NgxSkeletonLoaderCustomAnimations` interface via TypeScript declaration merging, and use them via `animation` attribute or config. Invalid names raise TypeScript errors (in templates, when `strictTemplates` is enabled) - https://github.com/willmendesneto/ngx-skeleton-loader/pull/284
|
|
47
|
+
- Custom animations are rendered as CSS class with `animation-` prefix (e.g. `animation="my-wave"` renders `.skeleton-loader.animation-my-wave`), avoiding collisions with internal classes. Their styles must be added in a global stylesheet or via `::ng-deep`, since component styles are encapsulated. They are disabled automatically - including the ones applied to `::before`/`::after` - when user prefers reduced motion - https://github.com/willmendesneto/ngx-skeleton-loader/pull/284
|
|
48
|
+
- Adding docs about theming via CSS custom properties, color scheme (dark mode) and custom animations on `README.md` file, with examples in the demo page
|
|
49
|
+
|
|
50
|
+
### Deprecated
|
|
51
|
+
|
|
52
|
+
- Deprecating `NgxSkeletonLoaderModule` and `NgxSkeletonLoaderModule.forRoot()` in favor of the standalone `NgxSkeletonLoaderComponent` and `provideNgxSkeletonLoader()`, which also work in `NgModule` based apps. They will be removed in a future major version - https://github.com/willmendesneto/ngx-skeleton-loader/pull/292
|
|
53
|
+
|
|
54
|
+
### Fixed
|
|
55
|
+
|
|
56
|
+
- Fixing SSR demo server startup with Express 5, which no longer accepts `**` as a wildcard path, and declaring the hostnames allowed by `CommonEngine` (`localhost` by default, `NG_ALLOWED_HOSTS` environment variable for other environments) - https://github.com/willmendesneto/ngx-skeleton-loader/pull/302
|
|
57
|
+
- Fixing `custom-content` appearance rendering multiple DOM nodes in production when `count` is bigger than `1`. `count` is now forced to `1` in every environment, keeping the error message in development mode only - https://github.com/willmendesneto/ngx-skeleton-loader/pull/273
|
|
58
|
+
- Fixing `progress-dark` animation still running when user prefers reduced motion - https://github.com/willmendesneto/ngx-skeleton-loader/pull/274
|
|
59
|
+
- Fixing `size` for `square` appearance ignoring decimal values (e.g. `1.5` became `15`) and CSS measure units passed in `size` (e.g. `10rem` became `10px`). A unit passed in `size` now takes precedence over `measureUnit`, and invalid values don't add `width`/`height` styles - https://github.com/willmendesneto/ngx-skeleton-loader/pull/275
|
|
60
|
+
- Fixing CSS custom properties (e.g. `--ngx-skeleton-loader-base-color`) being ignored when set in an ancestor element, such as `:root`, `body` or a wrapper element. Now they are consumed with their default values as fallback, keeping the same names and the `[theme]` support - https://github.com/willmendesneto/ngx-skeleton-loader/pull/283
|
|
61
|
+
|
|
62
|
+
## [13.0.0][] - 2026-06-05
|
|
63
|
+
|
|
64
|
+
### Changed
|
|
65
|
+
|
|
66
|
+
- Merging rollback due to malformed code
|
|
67
|
+
|
|
10
68
|
## [12.0.0][] - 2026-01-18
|
|
11
69
|
|
|
12
70
|
### Changed
|
|
@@ -672,7 +730,9 @@ Now we can define the animation we want to use in `<ngx-skeleton-loader>` compon
|
|
|
672
730
|
[5.0.0]: https://github.com/willmendesneto/ngx-skeleton-loader/tree/v5.0.0
|
|
673
731
|
[unreleased]: https://github.com/willmendesneto/ngx-skeleton-loader/compare/v6.0.0...HEAD
|
|
674
732
|
[6.0.0]: https://github.com/willmendesneto/ngx-skeleton-loader/tree/v6.0.0
|
|
675
|
-
[Unreleased]: https://github.com/willmendesneto/ngx-skeleton-loader/compare/
|
|
733
|
+
[Unreleased]: https://github.com/willmendesneto/ngx-skeleton-loader/compare/v14.0.0...HEAD
|
|
734
|
+
[14.0.0]: https://github.com/willmendesneto/ngx-skeleton-loader/compare/v13.0.0...v14.0.0
|
|
735
|
+
[13.0.0]: https://github.com/willmendesneto/ngx-skeleton-loader/compare/v12.0.0...v13.0.0
|
|
676
736
|
[12.0.0]: https://github.com/willmendesneto/ngx-skeleton-loader/compare/v11.3.0...v12.0.0
|
|
677
737
|
[11.3.0]: https://github.com/willmendesneto/ngx-skeleton-loader/compare/v11.2.1...v11.3.0
|
|
678
738
|
[11.2.1]: https://github.com/willmendesneto/ngx-skeleton-loader/compare/v11.2.0...v11.2.1
|
package/README.md
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
[](https://npmjs.org/ngx-skeleton-loader)
|
|
8
8
|
[](https://npmjs.org/ngx-skeleton-loader)
|
|
9
9
|
|
|
10
|
-
[](https://github.com/willmendesneto/ngx-skeleton-loader/actions/workflows/ci.yml)
|
|
11
11
|
[](https://coveralls.io/r/willmendesneto/ngx-skeleton-loader?branch=main)
|
|
12
12
|
[](https://bundlephobia.com/result?p=ngx-skeleton-loader)
|
|
13
13
|
[](/LICENSE)
|
|
@@ -83,6 +83,8 @@ After that, you can use the `ngx-skeleton-loader` component in your templates. O
|
|
|
83
83
|
|
|
84
84
|
## NgModule Setup
|
|
85
85
|
|
|
86
|
+
> ⚠️ `NgxSkeletonLoaderModule` and `NgxSkeletonLoaderModule.forRoot()` are **deprecated** and will be removed in a future major version. `NgxSkeletonLoaderComponent` is standalone: import it directly in your components and use `provideNgxSkeletonLoader()` for global configuration, as described in [Standalone Setup](#standalone-setup). It also works in applications using `NgModule`, by adding `NgxSkeletonLoaderComponent` to the module `imports` and `provideNgxSkeletonLoader()` to the module `providers`.
|
|
87
|
+
|
|
86
88
|
You'll need to add `NgxSkeletonLoaderModule` to your application module. So that, the `<ngx-skeleton-loader>` components will be accessible in your application.
|
|
87
89
|
|
|
88
90
|
```typescript
|
|
@@ -227,11 +229,24 @@ export class YourAppComponent {}
|
|
|
227
229
|
```
|
|
228
230
|
|
|
229
231
|
|
|
232
|
+
## Layout
|
|
233
|
+
|
|
234
|
+
`<ngx-skeleton-loader>` is rendered as a block element (`display: block`), taking the full width of its container. To render skeletons side by side (e.g. an avatar next to a title), use a flex or grid container:
|
|
235
|
+
|
|
236
|
+
```html
|
|
237
|
+
<div style="display: flex; gap: 10px; align-items: center">
|
|
238
|
+
<ngx-skeleton-loader appearance="circle" />
|
|
239
|
+
<ngx-skeleton-loader width="200" />
|
|
240
|
+
</div>
|
|
241
|
+
```
|
|
242
|
+
|
|
230
243
|
## WAI-ARIA values
|
|
231
244
|
|
|
232
245
|
- loadingText - _default_ `Loading...`: attribute that defines the text value for `aria-valuetext` attribute. Defaults to "Loading..."
|
|
233
246
|
- `aria-label` - _default_ `loading`: you can add `ariaLabel` as input of the component to set a different value.
|
|
234
247
|
|
|
248
|
+
WAI-ARIA attributes (`role="progressbar"`, `aria-busy`, `aria-valuemin`, `aria-valuemax`, `aria-label` and `aria-valuetext`) are applied once in the `<ngx-skeleton-loader>` element, so screen readers announce a single progress bar per component - regardless of `count`. The skeleton items inside of it are hidden from assistive technologies via `aria-hidden="true"`.
|
|
249
|
+
|
|
235
250
|
## Appearance
|
|
236
251
|
|
|
237
252
|
You can also define which appearance want to use in your skeleton loader by passing the options in your component via `[appearance]` attribute.
|
|
@@ -247,7 +262,7 @@ You can also define which appearance want to use in your skeleton loader by pass
|
|
|
247
262
|
### Appearance props (specific for `square`)
|
|
248
263
|
|
|
249
264
|
When setting `square` as appearance, your component can also use these other input attributes to configure it properly
|
|
250
|
-
- `size` - default _40_: number to be passed as definition for `width` and `height`. If not passed, it defaults to `40`
|
|
265
|
+
- `size` - default _40_: number to be passed as definition for `width` and `height`. If not passed, it defaults to `40`. It accepts decimal values (e.g. `1.5`) and also a CSS measure unit as suffix (e.g. `10rem`), which takes precedence over `measureUnit`
|
|
251
266
|
- `measureUnit` - default _px_: CSS measure unit to be used for `width` and `height`. If not passed, it defaults to `px`. Valid options: `px`, `em`, `rem`, `%`, `vh`, `vw`
|
|
252
267
|
|
|
253
268
|
## Animations
|
|
@@ -262,9 +277,12 @@ You can also define which CSS animation you want to use - even not use any, if i
|
|
|
262
277
|
- `progress-dark`: it will use it `progress-dark` as animation. Recommended if your color schema is darken;
|
|
263
278
|
- `pulse`: it will use `pulse` as animation;
|
|
264
279
|
- `pulse-dark`: it will use `pulse-dark` as animation. Recommended if your color schema is darken;
|
|
280
|
+
- `wave`: it will use `wave` as animation. Similar to `progress`, but with an oblique shimmer;
|
|
265
281
|
|
|
266
282
|
> `progress` is the default animation, used as the single one previously. If you don't pass the animation attribute, it defaults to `progress`.
|
|
267
283
|
|
|
284
|
+
> `progress` and `progress-dark` animations support right-to-left (RTL) layouts: when the skeleton is rendered inside an element with `dir="rtl"` (e.g. `<html dir="rtl">`), the shimmer crosses the skeleton from right to left.
|
|
285
|
+
|
|
268
286
|
```html
|
|
269
287
|
<!--
|
|
270
288
|
If you need to change all the background wrapper
|
|
@@ -282,11 +300,80 @@ you need to apply the style changes on the
|
|
|
282
300
|
<ngx-skeleton-loader />
|
|
283
301
|
<!-- Uses `pulse` as animation -->
|
|
284
302
|
<ngx-skeleton-loader animation="pulse" />
|
|
303
|
+
<!-- Uses `wave` as animation -->
|
|
304
|
+
<ngx-skeleton-loader animation="wave" />
|
|
285
305
|
</div>
|
|
286
306
|
```
|
|
287
307
|
|
|
288
308
|
> You can check the code details in the [Stackblitz Live Demo Link](https://stackblitz.com/edit/ngx-skeleton-loader-sample?file=app%2Fapp.component.html)
|
|
289
309
|
|
|
310
|
+
### Stagger effect
|
|
311
|
+
|
|
312
|
+
You can delay the animation of each skeleton item based on its position, creating a cascade effect, via `--ngx-skeleton-loader-animation-stagger` CSS custom property. It's `0s` by default (no delay), and it can be set in any ancestor element or via `[theme]` attribute.
|
|
313
|
+
|
|
314
|
+
```html
|
|
315
|
+
<!-- Each item starts its animation 150ms after the previous one -->
|
|
316
|
+
<ngx-skeleton-loader count="5" [theme]="{ '--ngx-skeleton-loader-animation-stagger': '150ms' }" />
|
|
317
|
+
```
|
|
318
|
+
|
|
319
|
+
Each item also exposes its index (starting from `0`) via `--ngx-skeleton-loader-index` CSS custom property, so you can use it in [custom animations](#custom-animations) as well:
|
|
320
|
+
|
|
321
|
+
```css
|
|
322
|
+
.skeleton-loader.animation-my-wave {
|
|
323
|
+
animation: my-wave 1.5s ease-in-out infinite;
|
|
324
|
+
animation-delay: calc(var(--ngx-skeleton-loader-index, 0) * 100ms);
|
|
325
|
+
}
|
|
326
|
+
```
|
|
327
|
+
|
|
328
|
+
### Custom animations
|
|
329
|
+
|
|
330
|
+
You can also create your own animations. These are the steps:
|
|
331
|
+
|
|
332
|
+
1. Register your animation name via TypeScript declaration merging, extending `NgxSkeletonLoaderCustomAnimations` interface. The file needs to be a module - that's why it has the `import` statement - otherwise it will replace the module types instead of extending them
|
|
333
|
+
|
|
334
|
+
```ts
|
|
335
|
+
// file: `src/ngx-skeleton-loader.d.ts`
|
|
336
|
+
import 'ngx-skeleton-loader';
|
|
337
|
+
|
|
338
|
+
declare module 'ngx-skeleton-loader' {
|
|
339
|
+
interface NgxSkeletonLoaderCustomAnimations {
|
|
340
|
+
'my-wave': true;
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
```
|
|
344
|
+
|
|
345
|
+
2. Add your animation styles in a **global stylesheet** (e.g. `styles.css`). The skeleton will receive your animation name as CSS class with `animation-` prefix - in this case, `animation-my-wave`. The prefix avoids collisions with `ngx-skeleton-loader` internal classes, such as `circle` or `progress`
|
|
346
|
+
|
|
347
|
+
```css
|
|
348
|
+
/* file: `styles.css` */
|
|
349
|
+
.skeleton-loader.animation-my-wave {
|
|
350
|
+
will-change: opacity;
|
|
351
|
+
animation: my-wave 1.5s ease-in-out infinite;
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
@keyframes my-wave {
|
|
355
|
+
50% {
|
|
356
|
+
opacity: 0.5;
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
```
|
|
360
|
+
|
|
361
|
+
3. Use it as any other animation
|
|
362
|
+
|
|
363
|
+
```html
|
|
364
|
+
<ngx-skeleton-loader animation="my-wave" />
|
|
365
|
+
```
|
|
366
|
+
|
|
367
|
+
```ts
|
|
368
|
+
provideNgxSkeletonLoader({ animation: 'my-wave' });
|
|
369
|
+
```
|
|
370
|
+
|
|
371
|
+
Some details to be aware of:
|
|
372
|
+
|
|
373
|
+
- **Type checking**: invalid animation names raise a TypeScript error (e.g. `Type '"my-wavee"' is not assignable to type ... Did you mean '"my-wave"'?`). In templates, static attributes such as `animation="my-wave"` are checked only when `strictTemplates` is enabled in your `tsconfig.json` - which is the default for new Angular projects
|
|
374
|
+
- **Global styles**: since component styles are encapsulated by Angular, your animation styles need to be added in a global stylesheet or via `::ng-deep`. Styles added in your component stylesheet won't reach the skeleton
|
|
375
|
+
- **Reduced motion**: custom animations - including the ones applied to `::before` and `::after` pseudo-elements - are disabled automatically when the user enabled the `Reduce Motion` option via operational system and/or browser, as it happens with the built-in animations
|
|
376
|
+
|
|
290
377
|
## Theming
|
|
291
378
|
|
|
292
379
|
You can also define different styles for the skeleton loader by passing an object with the css styles - in dashed case - into the component via `[theme]` attribute.
|
|
@@ -329,6 +416,97 @@ having `height.px` receiving a number and `background-color` receiving a HEX Col
|
|
|
329
416
|
</div>
|
|
330
417
|
```
|
|
331
418
|
|
|
419
|
+
### `width`, `height` and `borderRadius` shortcuts
|
|
420
|
+
|
|
421
|
+
For the most common theming cases, you can use `width`, `height` and `borderRadius` attributes instead of `[theme]`. They accept the same values as `size` - numbers (e.g. `100`), decimals (e.g. `1.5`) or values with CSS measure unit (e.g. `50%`, `10rem`) - and values without unit use `measureUnit` (`px` by default). They override the same styles passed via `[theme]`.
|
|
422
|
+
|
|
423
|
+
```html
|
|
424
|
+
<!-- Same as [theme]="{ width: '100px', height: '20px', 'border-radius': '8px' }" -->
|
|
425
|
+
<ngx-skeleton-loader width="100" height="20" borderRadius="8" />
|
|
426
|
+
<!-- Using CSS measure units -->
|
|
427
|
+
<ngx-skeleton-loader width="50%" height="1.5" measureUnit="rem" />
|
|
428
|
+
```
|
|
429
|
+
|
|
430
|
+
> For `square` appearance, `size` takes precedence over `width` and `height`.
|
|
431
|
+
|
|
432
|
+
### Theming via CSS custom properties
|
|
433
|
+
|
|
434
|
+
You can also customize skeletons via CSS custom properties (CSS variables). They can be set in any ancestor element - such as `:root`, `body`, a wrapper element in your component stylesheet - or directly via `[theme]` attribute, and they are inherited by every `<ngx-skeleton-loader>` inside of it.
|
|
435
|
+
|
|
436
|
+
| CSS custom property | Default value | Description |
|
|
437
|
+
| --- | --- | --- |
|
|
438
|
+
| `--ngx-skeleton-loader-color-scheme` | `light` | Color scheme used by the skeleton. Use `light dark` to follow the user's preference (automatic dark mode) or `dark` to force dark colors. See [Color scheme (dark mode)](#color-scheme-dark-mode) |
|
|
439
|
+
| `--ngx-skeleton-loader-base-color` | `light-dark(rgb(239, 241, 246), rgb(48, 52, 61))` | Skeleton background color. The dark value is used only when dark mode is enabled |
|
|
440
|
+
| `--ngx-skeleton-loader-light-mode-color` | `light-dark(rgba(255, 255, 255, 0.6), rgba(255, 255, 255, 0.1))` | Shimmer color used by `progress` and `wave` animations. The dark value is used only when dark mode is enabled |
|
|
441
|
+
| `--ngx-skeleton-loader-light-mode-color-to` | `rgba(255, 255, 255, 0)` | Shimmer edges color used by `progress` animation |
|
|
442
|
+
| `--ngx-skeleton-loader-dark-mode-color` | `rgba(0, 0, 0, 0.2)` | Shimmer color used by `progress-dark` animation and background color used by `pulse-dark` animation |
|
|
443
|
+
| `--ngx-skeleton-loader-dark-mode-color-to` | `transparent` | Shimmer edges color used by `progress-dark` animation |
|
|
444
|
+
| `--ngx-skeleton-loader-animation-duration` | `2s` | Duration of the animations |
|
|
445
|
+
| `--ngx-skeleton-loader-animation-stagger` | `0s` | Delay between the animation of each item. See [Stagger effect](#stagger-effect) |
|
|
446
|
+
| `--ngx-skeleton-loader-background-image-light-mode` | gradient based on `light-mode` colors | Full shimmer `background-image` used by `progress` animation |
|
|
447
|
+
| `--ngx-skeleton-loader-background-image-dark-mode` | gradient based on `dark-mode` colors | Full shimmer `background-image` used by `progress-dark` animation |
|
|
448
|
+
|
|
449
|
+
```css
|
|
450
|
+
/* file: `styles.css` - applying it globally */
|
|
451
|
+
:root {
|
|
452
|
+
--ngx-skeleton-loader-base-color: rgb(224, 231, 255);
|
|
453
|
+
--ngx-skeleton-loader-light-mode-color: rgba(99, 102, 241, 0.25);
|
|
454
|
+
--ngx-skeleton-loader-animation-duration: 1s;
|
|
455
|
+
}
|
|
456
|
+
```
|
|
457
|
+
|
|
458
|
+
```css
|
|
459
|
+
/* file: `my-component.component.css` - applying it only for skeletons inside of `.my-wrapper` element */
|
|
460
|
+
.my-wrapper {
|
|
461
|
+
--ngx-skeleton-loader-base-color: rgb(224, 231, 255);
|
|
462
|
+
}
|
|
463
|
+
```
|
|
464
|
+
|
|
465
|
+
```html
|
|
466
|
+
<!-- applying it to a specific skeleton via `[theme]` attribute -->
|
|
467
|
+
<ngx-skeleton-loader [theme]="{ '--ngx-skeleton-loader-base-color': 'rgb(224, 231, 255)' }" />
|
|
468
|
+
```
|
|
469
|
+
|
|
470
|
+
### Color scheme (dark mode)
|
|
471
|
+
|
|
472
|
+
Skeletons use light colors by default, regardless of the user's color scheme preference - as in previous versions. Dark mode is **opt-in**: you can enable it via `colorScheme` - as component attribute or via `provideNgxSkeletonLoader()`/`NgxSkeletonLoaderModule.forRoot()` config - or via `--ngx-skeleton-loader-color-scheme` CSS custom property.
|
|
473
|
+
|
|
474
|
+
- `light` - _default_: light colors, regardless of the user's color scheme preference;
|
|
475
|
+
- `auto`: follows the user's color scheme preference (OS and/or browser), switching to dark colors automatically;
|
|
476
|
+
- `dark`: forces dark colors;
|
|
477
|
+
|
|
478
|
+
```html
|
|
479
|
+
<!-- Light colors (default) -->
|
|
480
|
+
<ngx-skeleton-loader />
|
|
481
|
+
<!-- Follows the user's color scheme preference -->
|
|
482
|
+
<ngx-skeleton-loader colorScheme="auto" />
|
|
483
|
+
<!-- Forces dark colors -->
|
|
484
|
+
<ngx-skeleton-loader colorScheme="dark" />
|
|
485
|
+
```
|
|
486
|
+
|
|
487
|
+
```ts
|
|
488
|
+
// Enabling automatic dark mode for every skeleton
|
|
489
|
+
provideNgxSkeletonLoader({ colorScheme: 'auto' });
|
|
490
|
+
```
|
|
491
|
+
|
|
492
|
+
```css
|
|
493
|
+
/* Enabling automatic dark mode for every skeleton via CSS */
|
|
494
|
+
:root {
|
|
495
|
+
--ngx-skeleton-loader-color-scheme: light dark;
|
|
496
|
+
}
|
|
497
|
+
```
|
|
498
|
+
|
|
499
|
+
> If your application has its own theme switcher - instead of following the user's preference - use `light` or `dark` based on your application theme.
|
|
500
|
+
|
|
501
|
+
CSS custom properties are applied in both color schemes. When dark mode is enabled, you can use [`light-dark()`](https://developer.mozilla.org/en-US/docs/Web/CSS/color_value/light-dark) to define different values per color scheme:
|
|
502
|
+
|
|
503
|
+
```css
|
|
504
|
+
:root {
|
|
505
|
+
--ngx-skeleton-loader-color-scheme: light dark;
|
|
506
|
+
--ngx-skeleton-loader-base-color: light-dark(rgb(254, 243, 199), rgb(120, 53, 15));
|
|
507
|
+
}
|
|
508
|
+
```
|
|
509
|
+
|
|
332
510
|
### ⚠️ This is here only as a documentation, but it's not encouraged to be used. Please consider use it with caution ⚠️
|
|
333
511
|
|
|
334
512
|
Also, you can use CSS to add theme styles into your component. However, there are some implications:
|
|
@@ -391,6 +569,10 @@ You can apply theme changes in our stylesheet. At the end it will be
|
|
|
391
569
|
|
|
392
570
|
1. Run `npm test` for run tests. In case you want to test using watch, please use `npm run tdd`
|
|
393
571
|
|
|
572
|
+
### Check minimum peer dependency
|
|
573
|
+
|
|
574
|
+
1. Run `npm run check:min-peer` to build the package and install it in an Angular app using the minimum `peerDependencies` version (`integration/angular-min-peer`). It also runs in CI (GitHub Actions)
|
|
575
|
+
|
|
394
576
|
### Publish
|
|
395
577
|
|
|
396
578
|
this project is using `np` package to publish, which makes things straightforward. EX: `npx np <patch|minor|major> --no-yarn --no-cleanup --contents=dist/ngx-skeleton-loader`
|
|
@@ -3,6 +3,11 @@ import { InjectionToken, inject, input, numberAttribute, computed, isDevMode, Ch
|
|
|
3
3
|
|
|
4
4
|
const NGX_SKELETON_LOADER_CONFIG = new InjectionToken('ngx-skeleton-loader.config');
|
|
5
5
|
|
|
6
|
+
// Converts a size (e.g. `10`, `'1.5'`, `'10rem'`) into a CSS value, using `unit` if it has none
|
|
7
|
+
const toCSSSize = (size, unit) => {
|
|
8
|
+
const [, value, sizeUnit] = `${size ?? ''}`.trim().match(/^(\d*\.?\d+)(px|em|rem|%|vh|vw)?$/) || [];
|
|
9
|
+
return value ? `${Number(value)}${sizeUnit || unit}` : null;
|
|
10
|
+
};
|
|
6
11
|
/**
|
|
7
12
|
* The `NgxSkeletonLoaderComponent` is a standalone Angular component that provides a skeleton
|
|
8
13
|
* loader UI element.
|
|
@@ -25,14 +30,15 @@ class NgxSkeletonLoaderComponent {
|
|
|
25
30
|
* is not provided.
|
|
26
31
|
* The `transform: numberAttribute` option ensures that the input value is converted to a number.
|
|
27
32
|
*/
|
|
28
|
-
this.count = input(this.#config?.count || 1, { ...(ngDevMode ? { debugName: "count" } : {}), transform: numberAttribute });
|
|
33
|
+
this.count = input(this.#config?.count || 1, { ...(ngDevMode ? { debugName: "count" } : /* istanbul ignore next */ {}), transform: numberAttribute });
|
|
29
34
|
/**
|
|
30
35
|
* The `loadingText` property is an input that determines the text to display while the content
|
|
31
36
|
* is loading.
|
|
32
37
|
* It is initialized with the value from the `NgxSkeletonLoaderConfig` object, or 'Loading...'
|
|
33
38
|
* if the config is not provided.
|
|
34
39
|
*/
|
|
35
|
-
this.loadingText = input(this.#config?.loadingText || 'Loading...',
|
|
40
|
+
this.loadingText = input(this.#config?.loadingText || 'Loading...', /* @ts-ignore */
|
|
41
|
+
...(ngDevMode ? [{ debugName: "loadingText" }] : /* istanbul ignore next */ []));
|
|
36
42
|
/**
|
|
37
43
|
* The `appearance` property is an input that determines the visual appearance of the skeleton
|
|
38
44
|
* loader.
|
|
@@ -41,7 +47,8 @@ class NgxSkeletonLoaderComponent {
|
|
|
41
47
|
* The available appearance options are defined in the `NgxSkeletonLoaderConfig['appearance']`
|
|
42
48
|
* type.
|
|
43
49
|
*/
|
|
44
|
-
this.appearance = input(this.#config?.appearance || 'line',
|
|
50
|
+
this.appearance = input(this.#config?.appearance || 'line', /* @ts-ignore */
|
|
51
|
+
...(ngDevMode ? [{ debugName: "appearance" }] : /* istanbul ignore next */ []));
|
|
45
52
|
/**
|
|
46
53
|
* The `animation` property is an input that determines the type of animation to apply to the
|
|
47
54
|
* skeleton loader.
|
|
@@ -49,14 +56,16 @@ class NgxSkeletonLoaderComponent {
|
|
|
49
56
|
* the config is not provided.
|
|
50
57
|
* The available animation options are defined in the `NgxSkeletonLoaderConfig['animation']` type.
|
|
51
58
|
*/
|
|
52
|
-
this.animation = input(this.#config?.animation || 'progress',
|
|
59
|
+
this.animation = input(this.#config?.animation || 'progress', /* @ts-ignore */
|
|
60
|
+
...(ngDevMode ? [{ debugName: "animation" }] : /* istanbul ignore next */ []));
|
|
53
61
|
/**
|
|
54
62
|
* The `ariaLabel` property is an input that determines the ARIA label to be used for the skeleton
|
|
55
63
|
* loader element. This is useful for providing accessibility information to screen readers.
|
|
56
64
|
* It is initialized with the value from the `NgxSkeletonLoaderConfig` object, or 'loading' if the
|
|
57
65
|
* config is not provided.
|
|
58
66
|
*/
|
|
59
|
-
this.ariaLabel = input(this.#config?.ariaLabel || 'loading',
|
|
67
|
+
this.ariaLabel = input(this.#config?.ariaLabel || 'loading', /* @ts-ignore */
|
|
68
|
+
...(ngDevMode ? [{ debugName: "ariaLabel" }] : /* istanbul ignore next */ []));
|
|
60
69
|
/**
|
|
61
70
|
* The `theme` property is an input that determines the theme configuration for the skeleton
|
|
62
71
|
* loader.
|
|
@@ -66,14 +75,16 @@ class NgxSkeletonLoaderComponent {
|
|
|
66
75
|
* customizing various aspects of the skeleton loader's appearance, such as colors, animation,
|
|
67
76
|
* etc.
|
|
68
77
|
*/
|
|
69
|
-
this.theme = input(this.#config?.theme || null,
|
|
78
|
+
this.theme = input(this.#config?.theme || null, /* @ts-ignore */
|
|
79
|
+
...(ngDevMode ? [{ debugName: "theme" }] : /* istanbul ignore next */ []));
|
|
70
80
|
/**
|
|
71
81
|
* The `size` property is an input that determines the size of the skeleton loader.
|
|
72
82
|
* It is initialized with the value from the `NgxSkeletonLoaderConfig` object, or `null` if the
|
|
73
83
|
* config is not provided.
|
|
74
84
|
* The size can be specified as a number (in pixels) (e.g., '50', '200').
|
|
75
85
|
*/
|
|
76
|
-
this.size = input(this.#config?.size || null,
|
|
86
|
+
this.size = input(this.#config?.size || null, /* @ts-ignore */
|
|
87
|
+
...(ngDevMode ? [{ debugName: "size" }] : /* istanbul ignore next */ []));
|
|
77
88
|
/**
|
|
78
89
|
* The `measureUnit` property is an input that determines the unit of measurement for the size
|
|
79
90
|
* of the skeleton loader.
|
|
@@ -81,7 +92,18 @@ class NgxSkeletonLoaderComponent {
|
|
|
81
92
|
* config is not provided.
|
|
82
93
|
* This allows the size to be specified in different units, such as 'px', 'em', etc.
|
|
83
94
|
*/
|
|
84
|
-
this.measureUnit = input(this.#config?.measureUnit || 'px',
|
|
95
|
+
this.measureUnit = input(this.#config?.measureUnit || 'px', /* @ts-ignore */
|
|
96
|
+
...(ngDevMode ? [{ debugName: "measureUnit" }] : /* istanbul ignore next */ []));
|
|
97
|
+
/** Shortcuts for `width`, `height` and `border-radius` styles (same values as `size`) */
|
|
98
|
+
this.width = input(null, /* @ts-ignore */
|
|
99
|
+
...(ngDevMode ? [{ debugName: "width" }] : /* istanbul ignore next */ []));
|
|
100
|
+
this.height = input(null, /* @ts-ignore */
|
|
101
|
+
...(ngDevMode ? [{ debugName: "height" }] : /* istanbul ignore next */ []));
|
|
102
|
+
this.borderRadius = input(null, /* @ts-ignore */
|
|
103
|
+
...(ngDevMode ? [{ debugName: "borderRadius" }] : /* istanbul ignore next */ []));
|
|
104
|
+
/** Color scheme: 'light' (default), 'auto' (follows the user's preference) or 'dark' */
|
|
105
|
+
this.colorScheme = input(this.#config?.colorScheme || 'light', /* @ts-ignore */
|
|
106
|
+
...(ngDevMode ? [{ debugName: "colorScheme" }] : /* istanbul ignore next */ []));
|
|
85
107
|
/**
|
|
86
108
|
* The `items` property is a computed property that generates an array of indices based on the
|
|
87
109
|
* `count` input.
|
|
@@ -93,36 +115,39 @@ class NgxSkeletonLoaderComponent {
|
|
|
93
115
|
this.items = computed(() => {
|
|
94
116
|
let count = this.count() || 1;
|
|
95
117
|
// Force count to 1 when custom-content is used
|
|
96
|
-
if (this.appearance() === 'custom-content') {
|
|
118
|
+
if (this.appearance() === 'custom-content' && count !== 1) {
|
|
97
119
|
// Shows error message only in Development
|
|
98
|
-
if (isDevMode()
|
|
120
|
+
if (isDevMode()) {
|
|
99
121
|
// eslint-disable-next-line no-console
|
|
100
122
|
console.error(`\`NgxSkeletonLoaderComponent\` enforces elements with "custom-content" appearance as DOM nodes. Forcing "count" to "1".`);
|
|
101
|
-
count = 1;
|
|
102
123
|
}
|
|
124
|
+
count = 1;
|
|
103
125
|
}
|
|
104
126
|
return [...Array(count)].map((_, index) => index);
|
|
105
|
-
},
|
|
127
|
+
}, /* @ts-ignore */
|
|
128
|
+
...(ngDevMode ? [{ debugName: "items" }] : /* istanbul ignore next */ []));
|
|
129
|
+
/** Item classes. Custom animations are `animation-` prefixed to avoid collisions */
|
|
130
|
+
this.classes = computed(() => {
|
|
131
|
+
const appearance = this.appearance();
|
|
132
|
+
const animation = this.animation();
|
|
133
|
+
return `${/^(circle|square|custom-content)$/.test(appearance) ? appearance : ''} ${!animation || animation === 'false'
|
|
134
|
+
? ''
|
|
135
|
+
: /^(wave|(progress|pulse)(-dark)?)$/.test(animation)
|
|
136
|
+
? animation
|
|
137
|
+
: `animation-${animation}`}`;
|
|
138
|
+
}, /* @ts-ignore */
|
|
139
|
+
...(ngDevMode ? [{ debugName: "classes" }] : /* istanbul ignore next */ []));
|
|
106
140
|
/**
|
|
107
141
|
* The `squareSize` property is a computed property that calculates the size of the skeleton
|
|
108
142
|
* loader when the appearance is set to 'square'.
|
|
109
|
-
* It checks the `size` input and ensures that it is a valid number
|
|
110
|
-
*
|
|
111
|
-
*
|
|
143
|
+
* It checks the `size` input and ensures that it is a valid number, optionally with a CSS unit
|
|
144
|
+
* that takes precedence over `measureUnit` (e.g. '1.5', '10rem'). If the `size` is not valid,
|
|
145
|
+
* or the `appearance` is not 'square', it returns `null`.
|
|
112
146
|
* This computed property is used to set the width and height of the skeleton loader when it
|
|
113
147
|
* is displayed as a square.
|
|
114
148
|
*/
|
|
115
|
-
this.squareSize = computed(() =>
|
|
116
|
-
|
|
117
|
-
if (this.appearance() !== 'square' || (typeof size !== 'number' && typeof size !== 'string')) {
|
|
118
|
-
return null;
|
|
119
|
-
}
|
|
120
|
-
const sizeValueInNumbersOnly = Number(size.toString().trim().replace(/\D/g, ''));
|
|
121
|
-
if (!Number.isInteger(sizeValueInNumbersOnly)) {
|
|
122
|
-
return null;
|
|
123
|
-
}
|
|
124
|
-
return `${sizeValueInNumbersOnly}${this.measureUnit()}`;
|
|
125
|
-
}, { ...(ngDevMode ? { debugName: "squareSize" } : {}) });
|
|
149
|
+
this.squareSize = computed(() => this.appearance() === 'square' ? toCSSSize(this.size(), this.measureUnit()) : null, /* @ts-ignore */
|
|
150
|
+
...(ngDevMode ? [{ debugName: "squareSize" }] : /* istanbul ignore next */ []));
|
|
126
151
|
/**
|
|
127
152
|
* A computed property that returns the final theme configuration for the skeleton loader.
|
|
128
153
|
* If the `extendsFromRoot` property is set in the `NgxSkeletonLoaderConfig`, the theme is merged
|
|
@@ -131,20 +156,24 @@ class NgxSkeletonLoaderComponent {
|
|
|
131
156
|
* component-specific theme customization.
|
|
132
157
|
*/
|
|
133
158
|
this.styles = computed(() => {
|
|
134
|
-
const theme = this.theme();
|
|
135
159
|
const size = this.squareSize();
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
...theme,
|
|
160
|
+
const colorScheme = this.colorScheme();
|
|
161
|
+
const unit = this.measureUnit();
|
|
162
|
+
const width = toCSSSize(this.width(), unit);
|
|
163
|
+
const height = toCSSSize(this.height(), unit);
|
|
164
|
+
const borderRadius = toCSSSize(this.borderRadius(), unit);
|
|
165
|
+
const { extendsFromRoot, ...styles } = {
|
|
166
|
+
...(colorScheme !== 'light' && { 'color-scheme': colorScheme === 'auto' ? 'light dark' : colorScheme }),
|
|
167
|
+
...(this.#config?.theme?.extendsFromRoot && this.#config.theme),
|
|
168
|
+
...this.theme(),
|
|
169
|
+
...(width && { width }),
|
|
170
|
+
...(height && { height }),
|
|
171
|
+
...(borderRadius && { 'border-radius': borderRadius }),
|
|
145
172
|
...(size && { width: size, height: size }),
|
|
146
173
|
};
|
|
147
|
-
|
|
174
|
+
return styles;
|
|
175
|
+
}, /* @ts-ignore */
|
|
176
|
+
...(ngDevMode ? [{ debugName: "styles" }] : /* istanbul ignore next */ []));
|
|
148
177
|
}
|
|
149
178
|
/**
|
|
150
179
|
* Injects the `NgxSkeletonLoaderConfig` configuration object, which is optional.
|
|
@@ -152,26 +181,35 @@ class NgxSkeletonLoaderComponent {
|
|
|
152
181
|
* and appearance of the `NgxSkeletonLoaderComponent`.
|
|
153
182
|
*/
|
|
154
183
|
#config;
|
|
155
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
156
|
-
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "
|
|
184
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.0", ngImport: i0, type: NgxSkeletonLoaderComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
185
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.0.0", type: NgxSkeletonLoaderComponent, isStandalone: true, selector: "ngx-skeleton-loader", inputs: { count: { classPropertyName: "count", publicName: "count", isSignal: true, isRequired: false, transformFunction: null }, loadingText: { classPropertyName: "loadingText", publicName: "loadingText", isSignal: true, isRequired: false, transformFunction: null }, appearance: { classPropertyName: "appearance", publicName: "appearance", isSignal: true, isRequired: false, transformFunction: null }, animation: { classPropertyName: "animation", publicName: "animation", isSignal: true, isRequired: false, transformFunction: null }, ariaLabel: { classPropertyName: "ariaLabel", publicName: "ariaLabel", isSignal: true, isRequired: false, transformFunction: null }, theme: { classPropertyName: "theme", publicName: "theme", isSignal: true, isRequired: false, transformFunction: null }, size: { classPropertyName: "size", publicName: "size", isSignal: true, isRequired: false, transformFunction: null }, measureUnit: { classPropertyName: "measureUnit", publicName: "measureUnit", isSignal: true, isRequired: false, transformFunction: null }, width: { classPropertyName: "width", publicName: "width", isSignal: true, isRequired: false, transformFunction: null }, height: { classPropertyName: "height", publicName: "height", isSignal: true, isRequired: false, transformFunction: null }, borderRadius: { classPropertyName: "borderRadius", publicName: "borderRadius", isSignal: true, isRequired: false, transformFunction: null }, colorScheme: { classPropertyName: "colorScheme", publicName: "colorScheme", isSignal: true, isRequired: false, transformFunction: null } }, host: { attributes: { "role": "progressbar", "aria-busy": "true", "aria-valuemin": "0", "aria-valuemax": "100" }, properties: { "attr.aria-label": "ariaLabel()", "attr.aria-valuetext": "loadingText()" } }, ngImport: i0, template: "@let appearanceValue = appearance();\n@for (item of items(); track item) {\n <div\n class=\"skeleton-loader\"\n [class]=\"classes()\"\n aria-hidden=\"true\"\n [style]=\"styles()\"\n [style.--ngx-skeleton-loader-index]=\"item || null\"\n >\n @if (appearanceValue === 'custom-content') {\n <ng-content></ng-content>\n }\n </div>\n}\n", styles: [":host{display:block}.skeleton-loader{box-sizing:border-box;color-scheme:var(--ngx-skeleton-loader-color-scheme, light);overflow:hidden;position:relative;contain:layout paint;background:var(--ngx-skeleton-loader-base-color, light-dark(rgb(239, 241, 246), rgb(48, 52, 61))) no-repeat;border-radius:4px;width:100%;height:20px;display:inline-block;margin-bottom:10px}.skeleton-loader:before{box-sizing:border-box}.skeleton-loader.circle{width:40px;height:40px;margin:5px;border-radius:50%}.skeleton-loader.square{width:40px;height:40px;margin:5px}.skeleton-loader.progress,.skeleton-loader.progress-dark,.skeleton-loader.wave{isolation:isolate}.skeleton-loader.progress:before,.skeleton-loader.progress-dark:before,.skeleton-loader.wave:before{will-change:transform;animation:progress var(--ngx-skeleton-loader-animation-duration, 2s) ease-in-out infinite;animation-delay:calc(var(--ngx-skeleton-loader-index, 0) * var(--ngx-skeleton-loader-animation-stagger, 0s));background-size:200px 100%;background-repeat:no-repeat;background-position:right;position:absolute;z-index:1;top:0;left:0;width:calc(100% + 200px);height:100%;content:\"\"}.skeleton-loader.progress:dir(rtl):before,.skeleton-loader.progress-dark:dir(rtl):before,.skeleton-loader.wave:dir(rtl):before{animation-direction:reverse}.skeleton-loader.progress:before{background-image:var(--ngx-skeleton-loader-background-image-light-mode, linear-gradient(90deg, var(--ngx-skeleton-loader-light-mode-color-to, rgba(255, 255, 255, 0)), var(--ngx-skeleton-loader-light-mode-color, light-dark(rgba(255, 255, 255, .6), rgba(255, 255, 255, .1))), var(--ngx-skeleton-loader-light-mode-color-to, rgba(255, 255, 255, 0))))}.skeleton-loader.wave:before{background-image:linear-gradient(120deg,transparent 30%,var(--ngx-skeleton-loader-light-mode-color, light-dark(rgba(255, 255, 255, .6), rgba(255, 255, 255, .1))),transparent 70%)}.skeleton-loader.progress-dark:before{background-image:var(--ngx-skeleton-loader-background-image-dark-mode, linear-gradient(90deg, var(--ngx-skeleton-loader-dark-mode-color-to, transparent), var(--ngx-skeleton-loader-dark-mode-color, rgba(0, 0, 0, .2)), var(--ngx-skeleton-loader-dark-mode-color-to, transparent)))}.skeleton-loader.pulse{will-change:opacity;animation:pulse var(--ngx-skeleton-loader-animation-duration, 2s) cubic-bezier(.4,0,.2,1) infinite;animation-delay:calc(.5s + var(--ngx-skeleton-loader-index, 0) * var(--ngx-skeleton-loader-animation-stagger, 0s))}.skeleton-loader.pulse-dark{background:var(--ngx-skeleton-loader-dark-mode-color, rgba(0, 0, 0, .2));will-change:opacity;animation:pulse var(--ngx-skeleton-loader-animation-duration, 2s) cubic-bezier(.4,0,.2,1) infinite;animation-delay:calc(.5s + var(--ngx-skeleton-loader-index, 0) * var(--ngx-skeleton-loader-animation-stagger, 0s))}.skeleton-loader.custom-content{height:100%;background:none}@media(prefers-reduced-motion:reduce){.skeleton-loader.pulse,.skeleton-loader.pulse-dark,.skeleton-loader.progress:before,.skeleton-loader.progress-dark:before,.skeleton-loader.wave:before{animation:none;will-change:auto}.skeleton-loader[class*=animation-],.skeleton-loader[class*=animation-]:before,.skeleton-loader[class*=animation-]:after{animation:none;will-change:auto}.skeleton-loader.progress:before,.skeleton-loader.progress-dark:before,.skeleton-loader.wave:before{background-image:none}}@media(hover:hover)and (pointer:fine){.skeleton-loader{-webkit-user-select:none;user-select:none;cursor:wait}}@keyframes progress{0%{transform:translate3d(-100%,0,0)}to{transform:translateZ(0)}}@keyframes pulse{0%{opacity:1}50%{opacity:.4}to{opacity:1}}\n"], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
|
|
157
186
|
}
|
|
158
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
187
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.0", ngImport: i0, type: NgxSkeletonLoaderComponent, decorators: [{
|
|
159
188
|
type: Component,
|
|
160
|
-
args: [{ selector: 'ngx-skeleton-loader', changeDetection: ChangeDetectionStrategy.OnPush,
|
|
161
|
-
|
|
189
|
+
args: [{ selector: 'ngx-skeleton-loader', changeDetection: ChangeDetectionStrategy.OnPush, host: {
|
|
190
|
+
role: 'progressbar',
|
|
191
|
+
'aria-busy': 'true',
|
|
192
|
+
'aria-valuemin': '0',
|
|
193
|
+
'aria-valuemax': '100',
|
|
194
|
+
'[attr.aria-label]': 'ariaLabel()',
|
|
195
|
+
'[attr.aria-valuetext]': 'loadingText()',
|
|
196
|
+
}, template: "@let appearanceValue = appearance();\n@for (item of items(); track item) {\n <div\n class=\"skeleton-loader\"\n [class]=\"classes()\"\n aria-hidden=\"true\"\n [style]=\"styles()\"\n [style.--ngx-skeleton-loader-index]=\"item || null\"\n >\n @if (appearanceValue === 'custom-content') {\n <ng-content></ng-content>\n }\n </div>\n}\n", styles: [":host{display:block}.skeleton-loader{box-sizing:border-box;color-scheme:var(--ngx-skeleton-loader-color-scheme, light);overflow:hidden;position:relative;contain:layout paint;background:var(--ngx-skeleton-loader-base-color, light-dark(rgb(239, 241, 246), rgb(48, 52, 61))) no-repeat;border-radius:4px;width:100%;height:20px;display:inline-block;margin-bottom:10px}.skeleton-loader:before{box-sizing:border-box}.skeleton-loader.circle{width:40px;height:40px;margin:5px;border-radius:50%}.skeleton-loader.square{width:40px;height:40px;margin:5px}.skeleton-loader.progress,.skeleton-loader.progress-dark,.skeleton-loader.wave{isolation:isolate}.skeleton-loader.progress:before,.skeleton-loader.progress-dark:before,.skeleton-loader.wave:before{will-change:transform;animation:progress var(--ngx-skeleton-loader-animation-duration, 2s) ease-in-out infinite;animation-delay:calc(var(--ngx-skeleton-loader-index, 0) * var(--ngx-skeleton-loader-animation-stagger, 0s));background-size:200px 100%;background-repeat:no-repeat;background-position:right;position:absolute;z-index:1;top:0;left:0;width:calc(100% + 200px);height:100%;content:\"\"}.skeleton-loader.progress:dir(rtl):before,.skeleton-loader.progress-dark:dir(rtl):before,.skeleton-loader.wave:dir(rtl):before{animation-direction:reverse}.skeleton-loader.progress:before{background-image:var(--ngx-skeleton-loader-background-image-light-mode, linear-gradient(90deg, var(--ngx-skeleton-loader-light-mode-color-to, rgba(255, 255, 255, 0)), var(--ngx-skeleton-loader-light-mode-color, light-dark(rgba(255, 255, 255, .6), rgba(255, 255, 255, .1))), var(--ngx-skeleton-loader-light-mode-color-to, rgba(255, 255, 255, 0))))}.skeleton-loader.wave:before{background-image:linear-gradient(120deg,transparent 30%,var(--ngx-skeleton-loader-light-mode-color, light-dark(rgba(255, 255, 255, .6), rgba(255, 255, 255, .1))),transparent 70%)}.skeleton-loader.progress-dark:before{background-image:var(--ngx-skeleton-loader-background-image-dark-mode, linear-gradient(90deg, var(--ngx-skeleton-loader-dark-mode-color-to, transparent), var(--ngx-skeleton-loader-dark-mode-color, rgba(0, 0, 0, .2)), var(--ngx-skeleton-loader-dark-mode-color-to, transparent)))}.skeleton-loader.pulse{will-change:opacity;animation:pulse var(--ngx-skeleton-loader-animation-duration, 2s) cubic-bezier(.4,0,.2,1) infinite;animation-delay:calc(.5s + var(--ngx-skeleton-loader-index, 0) * var(--ngx-skeleton-loader-animation-stagger, 0s))}.skeleton-loader.pulse-dark{background:var(--ngx-skeleton-loader-dark-mode-color, rgba(0, 0, 0, .2));will-change:opacity;animation:pulse var(--ngx-skeleton-loader-animation-duration, 2s) cubic-bezier(.4,0,.2,1) infinite;animation-delay:calc(.5s + var(--ngx-skeleton-loader-index, 0) * var(--ngx-skeleton-loader-animation-stagger, 0s))}.skeleton-loader.custom-content{height:100%;background:none}@media(prefers-reduced-motion:reduce){.skeleton-loader.pulse,.skeleton-loader.pulse-dark,.skeleton-loader.progress:before,.skeleton-loader.progress-dark:before,.skeleton-loader.wave:before{animation:none;will-change:auto}.skeleton-loader[class*=animation-],.skeleton-loader[class*=animation-]:before,.skeleton-loader[class*=animation-]:after{animation:none;will-change:auto}.skeleton-loader.progress:before,.skeleton-loader.progress-dark:before,.skeleton-loader.wave:before{background-image:none}}@media(hover:hover)and (pointer:fine){.skeleton-loader{-webkit-user-select:none;user-select:none;cursor:wait}}@keyframes progress{0%{transform:translate3d(-100%,0,0)}to{transform:translateZ(0)}}@keyframes pulse{0%{opacity:1}50%{opacity:.4}to{opacity:1}}\n"] }]
|
|
197
|
+
}], propDecorators: { count: [{ type: i0.Input, args: [{ isSignal: true, alias: "count", required: false }] }], loadingText: [{ type: i0.Input, args: [{ isSignal: true, alias: "loadingText", required: false }] }], appearance: [{ type: i0.Input, args: [{ isSignal: true, alias: "appearance", required: false }] }], animation: [{ type: i0.Input, args: [{ isSignal: true, alias: "animation", required: false }] }], ariaLabel: [{ type: i0.Input, args: [{ isSignal: true, alias: "ariaLabel", required: false }] }], theme: [{ type: i0.Input, args: [{ isSignal: true, alias: "theme", required: false }] }], size: [{ type: i0.Input, args: [{ isSignal: true, alias: "size", required: false }] }], measureUnit: [{ type: i0.Input, args: [{ isSignal: true, alias: "measureUnit", required: false }] }], width: [{ type: i0.Input, args: [{ isSignal: true, alias: "width", required: false }] }], height: [{ type: i0.Input, args: [{ isSignal: true, alias: "height", required: false }] }], borderRadius: [{ type: i0.Input, args: [{ isSignal: true, alias: "borderRadius", required: false }] }], colorScheme: [{ type: i0.Input, args: [{ isSignal: true, alias: "colorScheme", required: false }] }] } });
|
|
162
198
|
|
|
199
|
+
/** @deprecated Import the standalone `NgxSkeletonLoaderComponent` and use `provideNgxSkeletonLoader()` */
|
|
163
200
|
class NgxSkeletonLoaderModule {
|
|
201
|
+
/** @deprecated Use `provideNgxSkeletonLoader()` */
|
|
164
202
|
static forRoot(config) {
|
|
165
203
|
return {
|
|
166
204
|
ngModule: NgxSkeletonLoaderModule,
|
|
167
205
|
providers: [{ provide: NGX_SKELETON_LOADER_CONFIG, useValue: config }],
|
|
168
206
|
};
|
|
169
207
|
}
|
|
170
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
171
|
-
static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "
|
|
172
|
-
static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "
|
|
208
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.0", ngImport: i0, type: NgxSkeletonLoaderModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
|
|
209
|
+
static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "22.0.0", ngImport: i0, type: NgxSkeletonLoaderModule, imports: [NgxSkeletonLoaderComponent], exports: [NgxSkeletonLoaderComponent] }); }
|
|
210
|
+
static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "22.0.0", ngImport: i0, type: NgxSkeletonLoaderModule }); }
|
|
173
211
|
}
|
|
174
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
212
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.0", ngImport: i0, type: NgxSkeletonLoaderModule, decorators: [{
|
|
175
213
|
type: NgModule,
|
|
176
214
|
args: [{
|
|
177
215
|
imports: [NgxSkeletonLoaderComponent],
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ngx-skeleton-loader.mjs","sources":["../../../projects/ngx-skeleton-loader/src/lib/ngx-skeleton-loader-config.types.ts","../../../projects/ngx-skeleton-loader/src/lib/ngx-skeleton-loader.component.ts","../../../projects/ngx-skeleton-loader/src/lib/ngx-skeleton-loader.html","../../../projects/ngx-skeleton-loader/src/lib/ngx-skeleton-loader.module.ts","../../../projects/ngx-skeleton-loader/src/lib/ngx-skeleton-loader.providers.ts","../../../projects/ngx-skeleton-loader/src/public-api.ts","../../../projects/ngx-skeleton-loader/src/ngx-skeleton-loader.ts"],"sourcesContent":["import { InjectionToken } from '@angular/core';\n\nexport type NgxSkeletonLoaderConfigTheme = {\n /** It enforces a combination of `fromRoot` styles with component `styles` attribute */\n extendsFromRoot?: boolean;\n // This is required since [style] is using `any` as well\n // More details in https://angular.dev/api/common/NgStyle\n [k: string]: any;\n} | null;\n\ntype CSSMeasureUnit = 'px' | 'em' | 'rem' | '%' | 'vh' | 'vw';\n\nexport interface NgxSkeletonLoaderConfig {\n appearance: 'circle' | 'line' | 'custom-content' | 'square' | '';\n animation: 'progress' | 'progress-dark' | 'pulse' | 'pulse-dark' | 'false' | false;\n theme: NgxSkeletonLoaderConfigTheme;\n loadingText: string;\n count: number;\n ariaLabel: string;\n size: number | `${number}` | `${number}${CSSMeasureUnit}` | null;\n measureUnit: CSSMeasureUnit;\n}\n\nexport const NGX_SKELETON_LOADER_CONFIG = new InjectionToken<NgxSkeletonLoaderConfig>('ngx-skeleton-loader.config');\n","import {\n Component,\n isDevMode,\n ChangeDetectionStrategy,\n input,\n inject,\n numberAttribute,\n computed,\n} from '@angular/core';\nimport {\n NgxSkeletonLoaderConfig,\n NgxSkeletonLoaderConfigTheme,\n NGX_SKELETON_LOADER_CONFIG,\n} from './ngx-skeleton-loader-config.types';\n\n/**\n * The `NgxSkeletonLoaderComponent` is a standalone Angular component that provides a skeleton\n * loader UI element.\n * It can be used to display a loading state before the actual content is available.\n * The component can be configured with various options such as the number of elements, appearance,\n * animation, and theme.\n */\n@Component({\n selector: 'ngx-skeleton-loader',\n templateUrl: './ngx-skeleton-loader.html',\n styleUrls: ['./ngx-skeleton-loader.scss'],\n changeDetection: ChangeDetectionStrategy.OnPush,\n standalone: true,\n})\nexport class NgxSkeletonLoaderComponent {\n /**\n * Injects the `NgxSkeletonLoaderConfig` configuration object, which is optional.\n * This configuration object provides various options for customizing the behavior\n * and appearance of the `NgxSkeletonLoaderComponent`.\n */\n readonly #config = inject<NgxSkeletonLoaderConfig>(NGX_SKELETON_LOADER_CONFIG, { optional: true });\n /**\n * The `count` property is an input that determines the number of skeleton loader elements\n * to display.\n * It is initialized with the value from the `NgxSkeletonLoaderConfig` object, or 1 if the config\n * is not provided.\n * The `transform: numberAttribute` option ensures that the input value is converted to a number.\n */\n readonly count = input(this.#config?.count || 1, { transform: numberAttribute });\n /**\n * The `loadingText` property is an input that determines the text to display while the content\n * is loading.\n * It is initialized with the value from the `NgxSkeletonLoaderConfig` object, or 'Loading...'\n * if the config is not provided.\n */\n readonly loadingText = input<NgxSkeletonLoaderConfig['loadingText']>(this.#config?.loadingText || 'Loading...');\n /**\n * The `appearance` property is an input that determines the visual appearance of the skeleton\n * loader.\n * It is initialized with the value from the `NgxSkeletonLoaderConfig` object, or 'line' if the\n * config is not provided.\n * The available appearance options are defined in the `NgxSkeletonLoaderConfig['appearance']`\n * type.\n */\n readonly appearance = input<NgxSkeletonLoaderConfig['appearance']>(this.#config?.appearance || 'line');\n /**\n * The `animation` property is an input that determines the type of animation to apply to the\n * skeleton loader.\n * It is initialized with the value from the `NgxSkeletonLoaderConfig` object, or 'progress' if\n * the config is not provided.\n * The available animation options are defined in the `NgxSkeletonLoaderConfig['animation']` type.\n */\n readonly animation = input<NgxSkeletonLoaderConfig['animation']>(this.#config?.animation || 'progress');\n /**\n * The `ariaLabel` property is an input that determines the ARIA label to be used for the skeleton\n * loader element. This is useful for providing accessibility information to screen readers.\n * It is initialized with the value from the `NgxSkeletonLoaderConfig` object, or 'loading' if the\n * config is not provided.\n */\n readonly ariaLabel = input<NgxSkeletonLoaderConfig['ariaLabel']>(this.#config?.ariaLabel || 'loading');\n /**\n * The `theme` property is an input that determines the theme configuration for the skeleton\n * loader.\n * It is initialized with the value from the `NgxSkeletonLoaderConfig` object, or `null` if the\n * config is not provided.\n * The theme configuration is defined by the `NgxSkeletonLoaderConfigTheme` type, which allows\n * customizing various aspects of the skeleton loader's appearance, such as colors, animation,\n * etc.\n */\n readonly theme = input<NgxSkeletonLoaderConfigTheme>(this.#config?.theme || null);\n /**\n * The `size` property is an input that determines the size of the skeleton loader.\n * It is initialized with the value from the `NgxSkeletonLoaderConfig` object, or `null` if the\n * config is not provided.\n * The size can be specified as a number (in pixels) (e.g., '50', '200').\n */\n readonly size = input<NgxSkeletonLoaderConfig['size']>(this.#config?.size || null);\n /**\n * The `measureUnit` property is an input that determines the unit of measurement for the size\n * of the skeleton loader.\n * It is initialized with the value from the `NgxSkeletonLoaderConfig` object, or 'px' if the\n * config is not provided.\n * This allows the size to be specified in different units, such as 'px', 'em', etc.\n */\n readonly measureUnit = input<NgxSkeletonLoaderConfig['measureUnit']>(this.#config?.measureUnit || 'px');\n /**\n * The `items` property is a computed property that generates an array of indices based on the\n * `count` input.\n * If the `appearance` is set to 'custom-content', the `count` is forced to 1 to ensure that the\n * skeleton loader is displayed as a single DOM node, as required by the 'custom-content'\n * appearance.\n * This computed property is used to render the appropriate number of skeleton loader elements.\n */\n readonly items = computed(() => {\n let count = this.count() || 1;\n\n // Force count to 1 when custom-content is used\n if (this.appearance() === 'custom-content') {\n // Shows error message only in Development\n if (isDevMode() && count !== 1) {\n // eslint-disable-next-line no-console\n console.error(\n `\\`NgxSkeletonLoaderComponent\\` enforces elements with \"custom-content\" appearance as DOM nodes. Forcing \"count\" to \"1\".`,\n );\n count = 1;\n }\n }\n return [...Array(count)].map((_, index) => index);\n });\n /**\n * The `squareSize` property is a computed property that calculates the size of the skeleton\n * loader when the appearance is set to 'square'.\n * It checks the `size` input and ensures that it is a valid number or string representing a\n * valid pixel value. If the `size` is not a valid number or string, it returns `null`.\n * If the `appearance` is not 'square', it also returns `null`.\n * This computed property is used to set the width and height of the skeleton loader when it\n * is displayed as a square.\n */\n readonly squareSize = computed(() => {\n const size = this.size();\n\n if (this.appearance() !== 'square' || (typeof size !== 'number' && typeof size !== 'string')) {\n return null;\n }\n\n const sizeValueInNumbersOnly = Number(size.toString().trim().replace(/\\D/g, ''));\n if (!Number.isInteger(sizeValueInNumbersOnly)) {\n return null;\n }\n\n return `${sizeValueInNumbersOnly}${this.measureUnit()}`;\n });\n\n /**\n * A computed property that returns the final theme configuration for the skeleton loader.\n * If the `extendsFromRoot` property is set in the `NgxSkeletonLoaderConfig`, the theme is merged\n * with the root theme configuration. Otherwise, the theme is returned as-is.\n * This allows the skeleton loader to inherit global theme settings while still allowing for\n * component-specific theme customization.\n */\n readonly styles = computed(() => {\n const theme = this.theme();\n const size = this.squareSize();\n\n if (this.#config?.theme?.extendsFromRoot) {\n return {\n ...this.#config?.theme,\n ...theme,\n ...(size && { width: size, height: size }),\n };\n }\n\n return {\n ...theme,\n ...(size && { width: size, height: size }),\n };\n });\n}\n","@let appearanceValue = appearance();\n@let animationValue = animation();\n@for (item of items(); track item) {\n <div\n class=\"skeleton-loader\"\n [attr.aria-label]=\"ariaLabel()\"\n aria-busy=\"true\"\n aria-valuemin=\"0\"\n aria-valuemax=\"100\"\n [attr.aria-valuetext]=\"loadingText()\"\n role=\"progressbar\"\n tabindex=\"-1\"\n [class.custom-content]=\"appearanceValue === 'custom-content'\"\n [class.circle]=\"appearanceValue === 'circle'\"\n [class.square]=\"appearanceValue === 'square'\"\n [class.progress]=\"animationValue === 'progress'\"\n [class.progress-dark]=\"animationValue === 'progress-dark'\"\n [class.pulse]=\"animationValue === 'pulse'\"\n [class.pulse-dark]=\"animationValue === 'pulse-dark'\"\n [style]=\"styles()\"\n >\n @if (appearanceValue === 'custom-content') {\n <ng-content></ng-content>\n }\n </div>\n}\n","import { ModuleWithProviders, NgModule } from '@angular/core';\n\nimport { NgxSkeletonLoaderComponent } from './ngx-skeleton-loader.component';\nimport { NgxSkeletonLoaderConfig, NGX_SKELETON_LOADER_CONFIG } from './ngx-skeleton-loader-config.types';\n\n@NgModule({\n imports: [NgxSkeletonLoaderComponent],\n exports: [NgxSkeletonLoaderComponent],\n})\nexport class NgxSkeletonLoaderModule {\n static forRoot(config?: Partial<NgxSkeletonLoaderConfig>): ModuleWithProviders<NgxSkeletonLoaderModule> {\n return {\n ngModule: NgxSkeletonLoaderModule,\n providers: [{ provide: NGX_SKELETON_LOADER_CONFIG, useValue: config }],\n };\n }\n}\n","import { makeEnvironmentProviders } from '@angular/core';\nimport { NgxSkeletonLoaderConfig, NGX_SKELETON_LOADER_CONFIG } from './ngx-skeleton-loader-config.types';\n\nexport function provideNgxSkeletonLoader(config?: Partial<NgxSkeletonLoaderConfig>) {\n return makeEnvironmentProviders([\n { provide: NGX_SKELETON_LOADER_CONFIG, useValue: config },\n ]);\n}\n","/*\n * Public API Surface of ngx-skeleton-loader\n */\n\nexport * from './lib/ngx-skeleton-loader.component';\nexport * from './lib/ngx-skeleton-loader.module';\nexport * from './lib/ngx-skeleton-loader.providers';\nexport * from './lib/ngx-skeleton-loader-config.types';\n","/**\n * Generated bundle index.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AAE,OAAO,EAAE,0BAA0B,EAAE,QAAQ,EAAE,MAAM,EAAE;AAC1D,KAAA,CAAC;AACJ;;ACPA;;AAEG;;ACFH;;AAEG;;;;"}
|
|
1
|
+
{"version":3,"file":"ngx-skeleton-loader.mjs","sources":["../../../projects/ngx-skeleton-loader/src/lib/ngx-skeleton-loader-config.types.ts","../../../projects/ngx-skeleton-loader/src/lib/ngx-skeleton-loader.component.ts","../../../projects/ngx-skeleton-loader/src/lib/ngx-skeleton-loader.html","../../../projects/ngx-skeleton-loader/src/lib/ngx-skeleton-loader.module.ts","../../../projects/ngx-skeleton-loader/src/lib/ngx-skeleton-loader.providers.ts","../../../projects/ngx-skeleton-loader/src/public-api.ts","../../../projects/ngx-skeleton-loader/src/ngx-skeleton-loader.ts"],"sourcesContent":["import { InjectionToken } from '@angular/core';\n\nexport type NgxSkeletonLoaderConfigTheme = {\n /** It enforces a combination of `fromRoot` styles with component `styles` attribute */\n extendsFromRoot?: boolean;\n /**\n * Same entries accepted by `[style]` binding: CSS properties (dash-case or camelCase),\n * CSS custom properties (e.g. `--ngx-skeleton-loader-base-color`) and CSS properties with\n * unit suffix (e.g. `'height.px': 50`). Values are strings or numbers, and `null`/`undefined`\n * remove the style. More details in https://angular.dev/guide/templates/binding#css-style-properties\n */\n [k: string]: string | number | boolean | null | undefined;\n} | null;\n\ntype CSSMeasureUnit = 'px' | 'em' | 'rem' | '%' | 'vh' | 'vw';\n\n/**\n * Registry of custom animations, extended by consumers via TypeScript declaration merging.\n * Every key registered here becomes a valid `animation` value, rendered as `animation-<key>`\n * CSS class in the skeleton. E.g.:\n *\n * ```ts\n * import 'ngx-skeleton-loader';\n *\n * declare module 'ngx-skeleton-loader' {\n * interface NgxSkeletonLoaderCustomAnimations {\n * 'my-wave': true;\n * }\n * }\n * ```\n *\n * The animation styles must be added in a global stylesheet (e.g. `styles.css`) or via `::ng-deep`,\n * targeting `.skeleton-loader.animation-my-wave`, since component styles are encapsulated.\n */\nexport interface NgxSkeletonLoaderCustomAnimations {}\n\nexport interface NgxSkeletonLoaderConfig {\n appearance: 'circle' | 'line' | 'custom-content' | 'square' | '';\n animation:\n | 'progress'\n | 'progress-dark'\n | 'pulse'\n | 'pulse-dark'\n | 'wave'\n | 'false'\n | false\n | Extract<keyof NgxSkeletonLoaderCustomAnimations, string>;\n theme: NgxSkeletonLoaderConfigTheme;\n loadingText: string;\n count: number;\n ariaLabel: string;\n size: number | `${number}` | `${number}${CSSMeasureUnit}` | null;\n measureUnit: CSSMeasureUnit;\n /**\n * `light` (default) keeps light colors, as in previous versions. `auto` enables dark mode\n * following the user's color scheme preference (OS and/or browser), and `dark` forces it.\n */\n colorScheme: 'auto' | 'light' | 'dark';\n}\n\nexport const NGX_SKELETON_LOADER_CONFIG = new InjectionToken<NgxSkeletonLoaderConfig>('ngx-skeleton-loader.config');\n","import {\n Component,\n isDevMode,\n ChangeDetectionStrategy,\n input,\n inject,\n numberAttribute,\n computed,\n} from '@angular/core';\nimport {\n NgxSkeletonLoaderConfig,\n NgxSkeletonLoaderConfigTheme,\n NGX_SKELETON_LOADER_CONFIG,\n} from './ngx-skeleton-loader-config.types';\n\n// Converts a size (e.g. `10`, `'1.5'`, `'10rem'`) into a CSS value, using `unit` if it has none\nconst toCSSSize = (size: NgxSkeletonLoaderConfig['size'], unit: NgxSkeletonLoaderConfig['measureUnit']) => {\n const [, value, sizeUnit] = `${size ?? ''}`.trim().match(/^(\\d*\\.?\\d+)(px|em|rem|%|vh|vw)?$/) || [];\n\n return value ? `${Number(value)}${sizeUnit || unit}` : null;\n};\n\n/**\n * The `NgxSkeletonLoaderComponent` is a standalone Angular component that provides a skeleton\n * loader UI element.\n * It can be used to display a loading state before the actual content is available.\n * The component can be configured with various options such as the number of elements, appearance,\n * animation, and theme.\n */\n@Component({\n selector: 'ngx-skeleton-loader',\n templateUrl: './ngx-skeleton-loader.html',\n styleUrl: './ngx-skeleton-loader.scss',\n changeDetection: ChangeDetectionStrategy.OnPush,\n // WAI-ARIA in the host: a single progress bar per component (items are `aria-hidden`)\n host: {\n role: 'progressbar',\n 'aria-busy': 'true',\n 'aria-valuemin': '0',\n 'aria-valuemax': '100',\n '[attr.aria-label]': 'ariaLabel()',\n '[attr.aria-valuetext]': 'loadingText()',\n },\n})\nexport class NgxSkeletonLoaderComponent {\n /**\n * Injects the `NgxSkeletonLoaderConfig` configuration object, which is optional.\n * This configuration object provides various options for customizing the behavior\n * and appearance of the `NgxSkeletonLoaderComponent`.\n */\n readonly #config = inject<NgxSkeletonLoaderConfig>(NGX_SKELETON_LOADER_CONFIG, { optional: true });\n /**\n * The `count` property is an input that determines the number of skeleton loader elements\n * to display.\n * It is initialized with the value from the `NgxSkeletonLoaderConfig` object, or 1 if the config\n * is not provided.\n * The `transform: numberAttribute` option ensures that the input value is converted to a number.\n */\n readonly count = input(this.#config?.count || 1, { transform: numberAttribute });\n /**\n * The `loadingText` property is an input that determines the text to display while the content\n * is loading.\n * It is initialized with the value from the `NgxSkeletonLoaderConfig` object, or 'Loading...'\n * if the config is not provided.\n */\n readonly loadingText = input<NgxSkeletonLoaderConfig['loadingText']>(this.#config?.loadingText || 'Loading...');\n /**\n * The `appearance` property is an input that determines the visual appearance of the skeleton\n * loader.\n * It is initialized with the value from the `NgxSkeletonLoaderConfig` object, or 'line' if the\n * config is not provided.\n * The available appearance options are defined in the `NgxSkeletonLoaderConfig['appearance']`\n * type.\n */\n readonly appearance = input<NgxSkeletonLoaderConfig['appearance']>(this.#config?.appearance || 'line');\n /**\n * The `animation` property is an input that determines the type of animation to apply to the\n * skeleton loader.\n * It is initialized with the value from the `NgxSkeletonLoaderConfig` object, or 'progress' if\n * the config is not provided.\n * The available animation options are defined in the `NgxSkeletonLoaderConfig['animation']` type.\n */\n readonly animation = input<NgxSkeletonLoaderConfig['animation']>(this.#config?.animation || 'progress');\n /**\n * The `ariaLabel` property is an input that determines the ARIA label to be used for the skeleton\n * loader element. This is useful for providing accessibility information to screen readers.\n * It is initialized with the value from the `NgxSkeletonLoaderConfig` object, or 'loading' if the\n * config is not provided.\n */\n readonly ariaLabel = input<NgxSkeletonLoaderConfig['ariaLabel']>(this.#config?.ariaLabel || 'loading');\n /**\n * The `theme` property is an input that determines the theme configuration for the skeleton\n * loader.\n * It is initialized with the value from the `NgxSkeletonLoaderConfig` object, or `null` if the\n * config is not provided.\n * The theme configuration is defined by the `NgxSkeletonLoaderConfigTheme` type, which allows\n * customizing various aspects of the skeleton loader's appearance, such as colors, animation,\n * etc.\n */\n readonly theme = input<NgxSkeletonLoaderConfigTheme>(this.#config?.theme || null);\n /**\n * The `size` property is an input that determines the size of the skeleton loader.\n * It is initialized with the value from the `NgxSkeletonLoaderConfig` object, or `null` if the\n * config is not provided.\n * The size can be specified as a number (in pixels) (e.g., '50', '200').\n */\n readonly size = input<NgxSkeletonLoaderConfig['size']>(this.#config?.size || null);\n /**\n * The `measureUnit` property is an input that determines the unit of measurement for the size\n * of the skeleton loader.\n * It is initialized with the value from the `NgxSkeletonLoaderConfig` object, or 'px' if the\n * config is not provided.\n * This allows the size to be specified in different units, such as 'px', 'em', etc.\n */\n readonly measureUnit = input<NgxSkeletonLoaderConfig['measureUnit']>(this.#config?.measureUnit || 'px');\n /** Shortcuts for `width`, `height` and `border-radius` styles (same values as `size`) */\n readonly width = input<NgxSkeletonLoaderConfig['size']>(null);\n readonly height = input<NgxSkeletonLoaderConfig['size']>(null);\n readonly borderRadius = input<NgxSkeletonLoaderConfig['size']>(null);\n /** Color scheme: 'light' (default), 'auto' (follows the user's preference) or 'dark' */\n readonly colorScheme = input<NgxSkeletonLoaderConfig['colorScheme']>(this.#config?.colorScheme || 'light');\n /**\n * The `items` property is a computed property that generates an array of indices based on the\n * `count` input.\n * If the `appearance` is set to 'custom-content', the `count` is forced to 1 to ensure that the\n * skeleton loader is displayed as a single DOM node, as required by the 'custom-content'\n * appearance.\n * This computed property is used to render the appropriate number of skeleton loader elements.\n */\n readonly items = computed(() => {\n let count = this.count() || 1;\n\n // Force count to 1 when custom-content is used\n if (this.appearance() === 'custom-content' && count !== 1) {\n // Shows error message only in Development\n if (isDevMode()) {\n // eslint-disable-next-line no-console\n console.error(\n `\\`NgxSkeletonLoaderComponent\\` enforces elements with \"custom-content\" appearance as DOM nodes. Forcing \"count\" to \"1\".`,\n );\n }\n count = 1;\n }\n return [...Array(count)].map((_, index) => index);\n });\n /** Item classes. Custom animations are `animation-` prefixed to avoid collisions */\n readonly classes = computed(() => {\n const appearance = this.appearance();\n const animation = this.animation();\n\n return `${/^(circle|square|custom-content)$/.test(appearance) ? appearance : ''} ${\n !animation || animation === 'false'\n ? ''\n : /^(wave|(progress|pulse)(-dark)?)$/.test(animation)\n ? animation\n : `animation-${animation}`\n }`;\n });\n /**\n * The `squareSize` property is a computed property that calculates the size of the skeleton\n * loader when the appearance is set to 'square'.\n * It checks the `size` input and ensures that it is a valid number, optionally with a CSS unit\n * that takes precedence over `measureUnit` (e.g. '1.5', '10rem'). If the `size` is not valid,\n * or the `appearance` is not 'square', it returns `null`.\n * This computed property is used to set the width and height of the skeleton loader when it\n * is displayed as a square.\n */\n readonly squareSize = computed(() =>\n this.appearance() === 'square' ? toCSSSize(this.size(), this.measureUnit()) : null,\n );\n\n /**\n * A computed property that returns the final theme configuration for the skeleton loader.\n * If the `extendsFromRoot` property is set in the `NgxSkeletonLoaderConfig`, the theme is merged\n * with the root theme configuration. Otherwise, the theme is returned as-is.\n * This allows the skeleton loader to inherit global theme settings while still allowing for\n * component-specific theme customization.\n */\n readonly styles = computed(() => {\n const size = this.squareSize();\n const colorScheme = this.colorScheme();\n const unit = this.measureUnit();\n const width = toCSSSize(this.width(), unit);\n const height = toCSSSize(this.height(), unit);\n const borderRadius = toCSSSize(this.borderRadius(), unit);\n const { extendsFromRoot, ...styles } = {\n ...(colorScheme !== 'light' && { 'color-scheme': colorScheme === 'auto' ? 'light dark' : colorScheme }),\n ...(this.#config?.theme?.extendsFromRoot && this.#config.theme),\n ...this.theme(),\n ...(width && { width }),\n ...(height && { height }),\n ...(borderRadius && { 'border-radius': borderRadius }),\n ...(size && { width: size, height: size }),\n };\n\n return styles;\n });\n}\n","@let appearanceValue = appearance();\n@for (item of items(); track item) {\n <div\n class=\"skeleton-loader\"\n [class]=\"classes()\"\n aria-hidden=\"true\"\n [style]=\"styles()\"\n [style.--ngx-skeleton-loader-index]=\"item || null\"\n >\n @if (appearanceValue === 'custom-content') {\n <ng-content></ng-content>\n }\n </div>\n}\n","import { ModuleWithProviders, NgModule } from '@angular/core';\n\nimport { NgxSkeletonLoaderComponent } from './ngx-skeleton-loader.component';\nimport { NgxSkeletonLoaderConfig, NGX_SKELETON_LOADER_CONFIG } from './ngx-skeleton-loader-config.types';\n\n/** @deprecated Import the standalone `NgxSkeletonLoaderComponent` and use `provideNgxSkeletonLoader()` */\n@NgModule({\n imports: [NgxSkeletonLoaderComponent],\n exports: [NgxSkeletonLoaderComponent],\n})\nexport class NgxSkeletonLoaderModule {\n /** @deprecated Use `provideNgxSkeletonLoader()` */\n static forRoot(config?: Partial<NgxSkeletonLoaderConfig>): ModuleWithProviders<NgxSkeletonLoaderModule> {\n return {\n ngModule: NgxSkeletonLoaderModule,\n providers: [{ provide: NGX_SKELETON_LOADER_CONFIG, useValue: config }],\n };\n }\n}\n","import { makeEnvironmentProviders } from '@angular/core';\nimport { NgxSkeletonLoaderConfig, NGX_SKELETON_LOADER_CONFIG } from './ngx-skeleton-loader-config.types';\n\nexport function provideNgxSkeletonLoader(config?: Partial<NgxSkeletonLoaderConfig>) {\n return makeEnvironmentProviders([\n { provide: NGX_SKELETON_LOADER_CONFIG, useValue: config },\n ]);\n}\n","/*\n * Public API Surface of ngx-skeleton-loader\n */\n\nexport * from './lib/ngx-skeleton-loader.component';\nexport * from './lib/ngx-skeleton-loader.module';\nexport * from './lib/ngx-skeleton-loader.providers';\nexport * from './lib/ngx-skeleton-loader-config.types';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;MA4Da,0BAA0B,GAAG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AuB,CAAA;;IAElC,OAAO,OAAO,CAAC,MAAyC,EAAA;QACtD,OAAO;AACL,YAAA,QAAQ,EAAE,uBAAuB;YACjC,SAAS,EAAE,CAAC,EAAE,OAAO,EAAE,0BAA0B,EAAE,QAAQ,EAAE,MAAM,EAAE,CAAC;SACvE;IACH;8GAPW,uBAAuB,EAAA,IAAA,EAAA,EAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,QAAA,EAAA,CAAA,CAAA;+GAAvB,uBAAuB,EAAA,OAAA,EAAA,CAHxB,0BAA0B,CAAA,EAAA,OAAA,EAAA,CAC1B,0BAA0B,CAAA,EAAA,CAAA,CAAA;+GAEzB,uBAAuB,EAAA,CAAA,CAAA;;2FAAvB,uBAAuB,EAAA,UAAA,EAAA,CAAA;kBAJnC,QAAQ;AAAC,YAAA,IAAA,EAAA,CAAA;oBACR,OAAO,EAAE,CAAC,0BAA0B,CAAC;oBACrC,OAAO,EAAE,CAAC,0BAA0B,CAAC;AACtC,iBAAA;;;ACNK,SAAU,wBAAwB,CAAC,MAAyC,EAAA;AAChF,IAAA,OAAO,wBAAwB,CAAC;AAC9B,QAAA,EAAE,OAAO,EAAE,0BAA0B,EAAE,QAAQ,EAAE,MAAM,EAAE;AAC1D,KAAA,CAAC;AACJ;;ACPA;;AAEG;;ACFH;;AAEG;;;;"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ngx-skeleton-loader",
|
|
3
3
|
"description": "Make beautiful, animated loading skeletons that automatically adapt to your Angular apps",
|
|
4
|
-
"version": "
|
|
4
|
+
"version": "14.0.0",
|
|
5
5
|
"peerDependencies": {
|
|
6
6
|
"@angular/common": ">=19.0.0",
|
|
7
7
|
"@angular/core": ">=19.0.0"
|
|
@@ -42,5 +42,6 @@
|
|
|
42
42
|
"types": "./types/ngx-skeleton-loader.d.ts",
|
|
43
43
|
"default": "./fesm2022/ngx-skeleton-loader.mjs"
|
|
44
44
|
}
|
|
45
|
-
}
|
|
45
|
+
},
|
|
46
|
+
"type": "module"
|
|
46
47
|
}
|
|
@@ -4,18 +4,49 @@ import { InjectionToken, ModuleWithProviders } from '@angular/core';
|
|
|
4
4
|
type NgxSkeletonLoaderConfigTheme = {
|
|
5
5
|
/** It enforces a combination of `fromRoot` styles with component `styles` attribute */
|
|
6
6
|
extendsFromRoot?: boolean;
|
|
7
|
-
|
|
7
|
+
/**
|
|
8
|
+
* Same entries accepted by `[style]` binding: CSS properties (dash-case or camelCase),
|
|
9
|
+
* CSS custom properties (e.g. `--ngx-skeleton-loader-base-color`) and CSS properties with
|
|
10
|
+
* unit suffix (e.g. `'height.px': 50`). Values are strings or numbers, and `null`/`undefined`
|
|
11
|
+
* remove the style. More details in https://angular.dev/guide/templates/binding#css-style-properties
|
|
12
|
+
*/
|
|
13
|
+
[k: string]: string | number | boolean | null | undefined;
|
|
8
14
|
} | null;
|
|
9
15
|
type CSSMeasureUnit = 'px' | 'em' | 'rem' | '%' | 'vh' | 'vw';
|
|
16
|
+
/**
|
|
17
|
+
* Registry of custom animations, extended by consumers via TypeScript declaration merging.
|
|
18
|
+
* Every key registered here becomes a valid `animation` value, rendered as `animation-<key>`
|
|
19
|
+
* CSS class in the skeleton. E.g.:
|
|
20
|
+
*
|
|
21
|
+
* ```ts
|
|
22
|
+
* import 'ngx-skeleton-loader';
|
|
23
|
+
*
|
|
24
|
+
* declare module 'ngx-skeleton-loader' {
|
|
25
|
+
* interface NgxSkeletonLoaderCustomAnimations {
|
|
26
|
+
* 'my-wave': true;
|
|
27
|
+
* }
|
|
28
|
+
* }
|
|
29
|
+
* ```
|
|
30
|
+
*
|
|
31
|
+
* The animation styles must be added in a global stylesheet (e.g. `styles.css`) or via `::ng-deep`,
|
|
32
|
+
* targeting `.skeleton-loader.animation-my-wave`, since component styles are encapsulated.
|
|
33
|
+
*/
|
|
34
|
+
interface NgxSkeletonLoaderCustomAnimations {
|
|
35
|
+
}
|
|
10
36
|
interface NgxSkeletonLoaderConfig {
|
|
11
37
|
appearance: 'circle' | 'line' | 'custom-content' | 'square' | '';
|
|
12
|
-
animation: 'progress' | 'progress-dark' | 'pulse' | 'pulse-dark' | 'false' | false
|
|
38
|
+
animation: 'progress' | 'progress-dark' | 'pulse' | 'pulse-dark' | 'wave' | 'false' | false | Extract<keyof NgxSkeletonLoaderCustomAnimations, string>;
|
|
13
39
|
theme: NgxSkeletonLoaderConfigTheme;
|
|
14
40
|
loadingText: string;
|
|
15
41
|
count: number;
|
|
16
42
|
ariaLabel: string;
|
|
17
43
|
size: number | `${number}` | `${number}${CSSMeasureUnit}` | null;
|
|
18
44
|
measureUnit: CSSMeasureUnit;
|
|
45
|
+
/**
|
|
46
|
+
* `light` (default) keeps light colors, as in previous versions. `auto` enables dark mode
|
|
47
|
+
* following the user's color scheme preference (OS and/or browser), and `dark` forces it.
|
|
48
|
+
*/
|
|
49
|
+
colorScheme: 'auto' | 'light' | 'dark';
|
|
19
50
|
}
|
|
20
51
|
declare const NGX_SKELETON_LOADER_CONFIG: InjectionToken<NgxSkeletonLoaderConfig>;
|
|
21
52
|
|
|
@@ -59,7 +90,7 @@ declare class NgxSkeletonLoaderComponent {
|
|
|
59
90
|
* the config is not provided.
|
|
60
91
|
* The available animation options are defined in the `NgxSkeletonLoaderConfig['animation']` type.
|
|
61
92
|
*/
|
|
62
|
-
readonly animation: _angular_core.InputSignal<false | "progress" | "progress-dark" | "pulse" | "pulse-dark" | "false">;
|
|
93
|
+
readonly animation: _angular_core.InputSignal<false | "progress" | "progress-dark" | "pulse" | "pulse-dark" | "wave" | "false">;
|
|
63
94
|
/**
|
|
64
95
|
* The `ariaLabel` property is an input that determines the ARIA label to be used for the skeleton
|
|
65
96
|
* loader element. This is useful for providing accessibility information to screen readers.
|
|
@@ -92,6 +123,12 @@ declare class NgxSkeletonLoaderComponent {
|
|
|
92
123
|
* This allows the size to be specified in different units, such as 'px', 'em', etc.
|
|
93
124
|
*/
|
|
94
125
|
readonly measureUnit: _angular_core.InputSignal<"px" | "em" | "rem" | "%" | "vh" | "vw">;
|
|
126
|
+
/** Shortcuts for `width`, `height` and `border-radius` styles (same values as `size`) */
|
|
127
|
+
readonly width: _angular_core.InputSignal<number | `${number}` | `${number}px` | `${number}em` | `${number}rem` | `${number}%` | `${number}vh` | `${number}vw` | null>;
|
|
128
|
+
readonly height: _angular_core.InputSignal<number | `${number}` | `${number}px` | `${number}em` | `${number}rem` | `${number}%` | `${number}vh` | `${number}vw` | null>;
|
|
129
|
+
readonly borderRadius: _angular_core.InputSignal<number | `${number}` | `${number}px` | `${number}em` | `${number}rem` | `${number}%` | `${number}vh` | `${number}vw` | null>;
|
|
130
|
+
/** Color scheme: 'light' (default), 'auto' (follows the user's preference) or 'dark' */
|
|
131
|
+
readonly colorScheme: _angular_core.InputSignal<"auto" | "light" | "dark">;
|
|
95
132
|
/**
|
|
96
133
|
* The `items` property is a computed property that generates an array of indices based on the
|
|
97
134
|
* `count` input.
|
|
@@ -101,12 +138,14 @@ declare class NgxSkeletonLoaderComponent {
|
|
|
101
138
|
* This computed property is used to render the appropriate number of skeleton loader elements.
|
|
102
139
|
*/
|
|
103
140
|
readonly items: _angular_core.Signal<number[]>;
|
|
141
|
+
/** Item classes. Custom animations are `animation-` prefixed to avoid collisions */
|
|
142
|
+
readonly classes: _angular_core.Signal<string>;
|
|
104
143
|
/**
|
|
105
144
|
* The `squareSize` property is a computed property that calculates the size of the skeleton
|
|
106
145
|
* loader when the appearance is set to 'square'.
|
|
107
|
-
* It checks the `size` input and ensures that it is a valid number
|
|
108
|
-
*
|
|
109
|
-
*
|
|
146
|
+
* It checks the `size` input and ensures that it is a valid number, optionally with a CSS unit
|
|
147
|
+
* that takes precedence over `measureUnit` (e.g. '1.5', '10rem'). If the `size` is not valid,
|
|
148
|
+
* or the `appearance` is not 'square', it returns `null`.
|
|
110
149
|
* This computed property is used to set the width and height of the skeleton loader when it
|
|
111
150
|
* is displayed as a square.
|
|
112
151
|
*/
|
|
@@ -121,13 +160,16 @@ declare class NgxSkeletonLoaderComponent {
|
|
|
121
160
|
readonly styles: _angular_core.Signal<{
|
|
122
161
|
width?: string | undefined;
|
|
123
162
|
height?: string | undefined;
|
|
124
|
-
|
|
163
|
+
'border-radius'?: string | undefined;
|
|
164
|
+
'color-scheme'?: string | undefined;
|
|
125
165
|
}>;
|
|
126
166
|
static ɵfac: _angular_core.ɵɵFactoryDeclaration<NgxSkeletonLoaderComponent, never>;
|
|
127
|
-
static ɵcmp: _angular_core.ɵɵComponentDeclaration<NgxSkeletonLoaderComponent, "ngx-skeleton-loader", never, { "count": { "alias": "count"; "required": false; "isSignal": true; }; "loadingText": { "alias": "loadingText"; "required": false; "isSignal": true; }; "appearance": { "alias": "appearance"; "required": false; "isSignal": true; }; "animation": { "alias": "animation"; "required": false; "isSignal": true; }; "ariaLabel": { "alias": "ariaLabel"; "required": false; "isSignal": true; }; "theme": { "alias": "theme"; "required": false; "isSignal": true; }; "size": { "alias": "size"; "required": false; "isSignal": true; }; "measureUnit": { "alias": "measureUnit"; "required": false; "isSignal": true; }; }, {}, never, ["*"], true, never>;
|
|
167
|
+
static ɵcmp: _angular_core.ɵɵComponentDeclaration<NgxSkeletonLoaderComponent, "ngx-skeleton-loader", never, { "count": { "alias": "count"; "required": false; "isSignal": true; }; "loadingText": { "alias": "loadingText"; "required": false; "isSignal": true; }; "appearance": { "alias": "appearance"; "required": false; "isSignal": true; }; "animation": { "alias": "animation"; "required": false; "isSignal": true; }; "ariaLabel": { "alias": "ariaLabel"; "required": false; "isSignal": true; }; "theme": { "alias": "theme"; "required": false; "isSignal": true; }; "size": { "alias": "size"; "required": false; "isSignal": true; }; "measureUnit": { "alias": "measureUnit"; "required": false; "isSignal": true; }; "width": { "alias": "width"; "required": false; "isSignal": true; }; "height": { "alias": "height"; "required": false; "isSignal": true; }; "borderRadius": { "alias": "borderRadius"; "required": false; "isSignal": true; }; "colorScheme": { "alias": "colorScheme"; "required": false; "isSignal": true; }; }, {}, never, ["*"], true, never>;
|
|
128
168
|
}
|
|
129
169
|
|
|
170
|
+
/** @deprecated Import the standalone `NgxSkeletonLoaderComponent` and use `provideNgxSkeletonLoader()` */
|
|
130
171
|
declare class NgxSkeletonLoaderModule {
|
|
172
|
+
/** @deprecated Use `provideNgxSkeletonLoader()` */
|
|
131
173
|
static forRoot(config?: Partial<NgxSkeletonLoaderConfig>): ModuleWithProviders<NgxSkeletonLoaderModule>;
|
|
132
174
|
static ɵfac: _angular_core.ɵɵFactoryDeclaration<NgxSkeletonLoaderModule, never>;
|
|
133
175
|
static ɵmod: _angular_core.ɵɵNgModuleDeclaration<NgxSkeletonLoaderModule, never, [typeof NgxSkeletonLoaderComponent], [typeof NgxSkeletonLoaderComponent]>;
|
|
@@ -137,4 +179,4 @@ declare class NgxSkeletonLoaderModule {
|
|
|
137
179
|
declare function provideNgxSkeletonLoader(config?: Partial<NgxSkeletonLoaderConfig>): _angular_core.EnvironmentProviders;
|
|
138
180
|
|
|
139
181
|
export { NGX_SKELETON_LOADER_CONFIG, NgxSkeletonLoaderComponent, NgxSkeletonLoaderModule, provideNgxSkeletonLoader };
|
|
140
|
-
export type { NgxSkeletonLoaderConfig, NgxSkeletonLoaderConfigTheme };
|
|
182
|
+
export type { NgxSkeletonLoaderConfig, NgxSkeletonLoaderConfigTheme, NgxSkeletonLoaderCustomAnimations };
|