@ssv/ngx.ux 2.1.2 → 3.0.0-dev.32
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +28 -114
- package/eslint.config.js +43 -0
- package/index.ts +1 -0
- package/jest.config.ts +21 -0
- package/ng-package.json +7 -0
- package/package.json +4 -30
- package/project.json +36 -0
- package/src/index.ts +4 -0
- package/src/internal/internal.model.ts +3 -0
- package/src/platform/window.ts +31 -0
- package/src/test-setup.ts +8 -0
- package/src/ux.module.ts +15 -0
- package/src/version.ts +1 -0
- package/src/viewport/index.ts +20 -0
- package/src/viewport/viewport-data/README.md +47 -0
- package/src/viewport/viewport-data/index.ts +3 -0
- package/src/viewport/viewport-data/viewport-data-matcher.spec.ts +227 -0
- package/src/viewport/viewport-data/viewport-data-matcher.ts +175 -0
- package/src/viewport/viewport-data/viewport-data.pipe.ts +51 -0
- package/src/viewport/viewport-data/viewport-data.service.ts +48 -0
- package/src/viewport/viewport-data/viewport-data.utils.spec.ts +228 -0
- package/src/viewport/viewport-data/viewport-data.utils.ts +137 -0
- package/src/viewport/viewport-matcher-var.directive.ts +85 -0
- package/src/viewport/viewport-matcher.directive.ts +170 -0
- package/src/viewport/viewport-server-size.service.ts +37 -0
- package/src/viewport/viewport.model.ts +54 -0
- package/src/viewport/viewport.module.ts +19 -0
- package/src/viewport/viewport.options.ts +74 -0
- package/src/viewport/viewport.service.ts +123 -0
- package/src/viewport/viewport.util.spec.ts +254 -0
- package/src/viewport/viewport.util.ts +152 -0
- package/tsconfig.json +28 -0
- package/tsconfig.lib.json +12 -0
- package/tsconfig.lib.prod.json +9 -0
- package/tsconfig.spec.json +11 -0
- package/LICENSE +0 -21
- package/config.d.ts +0 -7
- package/esm2020/config.mjs +0 -7
- package/esm2020/index.mjs +0 -5
- package/esm2020/internal/internal.model.mjs +0 -2
- package/esm2020/module.mjs +0 -65
- package/esm2020/platform/window.mjs +0 -30
- package/esm2020/ssv-ngx.ux.mjs +0 -5
- package/esm2020/version.mjs +0 -2
- package/esm2020/viewport/index.mjs +0 -9
- package/esm2020/viewport/viewport-data/index.mjs +0 -4
- package/esm2020/viewport/viewport-data/viewport-data-matcher.mjs +0 -108
- package/esm2020/viewport/viewport-data/viewport-data.pipe.mjs +0 -43
- package/esm2020/viewport/viewport-data/viewport-data.service.mjs +0 -37
- package/esm2020/viewport/viewport-data/viewport-data.utils.mjs +0 -100
- package/esm2020/viewport/viewport-matcher-var.directive.mjs +0 -63
- package/esm2020/viewport/viewport-matcher.directive.mjs +0 -131
- package/esm2020/viewport/viewport-server-size.service.mjs +0 -43
- package/esm2020/viewport/viewport.const.mjs +0 -17
- package/esm2020/viewport/viewport.model.mjs +0 -30
- package/esm2020/viewport/viewport.service.mjs +0 -66
- package/esm2020/viewport/viewport.util.mjs +0 -117
- package/fesm2015/ssv-ngx.ux.mjs +0 -826
- package/fesm2015/ssv-ngx.ux.mjs.map +0 -1
- package/fesm2020/ssv-ngx.ux.mjs +0 -820
- package/fesm2020/ssv-ngx.ux.mjs.map +0 -1
- package/index.d.ts +0 -4
- package/internal/internal.model.d.ts +0 -9
- package/module.d.ts +0 -19
- package/platform/window.d.ts +0 -13
- package/version.d.ts +0 -1
- package/viewport/index.d.ts +0 -8
- package/viewport/viewport-data/index.d.ts +0 -3
- package/viewport/viewport-data/viewport-data-matcher.d.ts +0 -32
- package/viewport/viewport-data/viewport-data.pipe.d.ts +0 -18
- package/viewport/viewport-data/viewport-data.service.d.ts +0 -20
- package/viewport/viewport-data/viewport-data.utils.d.ts +0 -21
- package/viewport/viewport-matcher-var.directive.d.ts +0 -25
- package/viewport/viewport-matcher.directive.d.ts +0 -33
- package/viewport/viewport-server-size.service.d.ts +0 -12
- package/viewport/viewport.const.d.ts +0 -5
- package/viewport/viewport.model.d.ts +0 -59
- package/viewport/viewport.service.d.ts +0 -37
- package/viewport/viewport.util.d.ts +0 -25
package/README.md
CHANGED
|
@@ -1,19 +1,10 @@
|
|
|
1
|
-
[projectUri]: https://github.com/sketch7/ngx.ux
|
|
2
|
-
[changeLog]: ./CHANGELOG.md
|
|
3
|
-
[releaseWorkflowWiki]: ./docs/RELEASE-WORKFLOW.md
|
|
4
|
-
|
|
5
1
|
[npm]: https://www.npmjs.com
|
|
6
2
|
|
|
7
3
|
# @ssv/ngx.ux
|
|
8
|
-
[](https://github.com/sketch7/ngx.ux/actions/workflows/ci.yml)
|
|
9
4
|
[](https://badge.fury.io/js/%40ssv%2Fngx.ux)
|
|
10
5
|
|
|
11
6
|
UX essentials for building apps, utilities which enables you writing richer apps easier.
|
|
12
7
|
|
|
13
|
-
**Quick links**
|
|
14
|
-
|
|
15
|
-
[Change logs][changeLog] | [Project Repository][projectUri]
|
|
16
|
-
|
|
17
8
|
## Installation
|
|
18
9
|
|
|
19
10
|
Get library via [npm]
|
|
@@ -26,29 +17,17 @@ Choose the version corresponding to your Angular version:
|
|
|
26
17
|
|
|
27
18
|
| Angular | library |
|
|
28
19
|
| ------- | ------- |
|
|
20
|
+
| 17+ | 3.x+ |
|
|
29
21
|
| 10+ | 2.x+ |
|
|
30
22
|
| 4 to 9 | 1.x+ |
|
|
31
23
|
|
|
24
|
+
|
|
32
25
|
## Features
|
|
33
26
|
- Viewport (see below)
|
|
34
27
|
- [Viewport Data](./src/viewport/viewport-data/README.md)
|
|
35
28
|
|
|
36
29
|
# Usage
|
|
37
30
|
|
|
38
|
-
## Register module
|
|
39
|
-
|
|
40
|
-
```ts
|
|
41
|
-
import { SsvUxModule } from "@ssv/ngx.ux";
|
|
42
|
-
|
|
43
|
-
@NgModule({
|
|
44
|
-
imports: [
|
|
45
|
-
SsvUxModule
|
|
46
|
-
]
|
|
47
|
-
}
|
|
48
|
-
export class AppModule {
|
|
49
|
-
}
|
|
50
|
-
```
|
|
51
|
-
|
|
52
31
|
## Viewport
|
|
53
32
|
Provides utilities to handle responsiveness easier based on the viewport (view size)
|
|
54
33
|
|
|
@@ -161,10 +140,19 @@ Since in SSR there is no way to know the client viewport size, we should at leas
|
|
|
161
140
|
The basic implementation allows to provide a device type `mobile`, `tablet` or `desktop` and there are static sizes for those.
|
|
162
141
|
|
|
163
142
|
```ts
|
|
164
|
-
import {
|
|
143
|
+
import { withViewportSsrDevice } from "@ssv/ngx.ux";
|
|
165
144
|
|
|
166
145
|
const deviceType = deviceTypeFromServer;
|
|
167
|
-
|
|
146
|
+
export const appConfig: ApplicationConfig = {
|
|
147
|
+
providers: [
|
|
148
|
+
withViewportSsrDevice(deviceType)
|
|
149
|
+
// or
|
|
150
|
+
provideSsvUxViewportOptions(
|
|
151
|
+
{},
|
|
152
|
+
withViewportSsrDevice(deviceType)
|
|
153
|
+
)
|
|
154
|
+
]
|
|
155
|
+
}
|
|
168
156
|
```
|
|
169
157
|
|
|
170
158
|
The default implementation can also be replaced by implementing a small class as following:
|
|
@@ -180,11 +168,10 @@ export class SuperViewportServerSizeService {
|
|
|
180
168
|
|
|
181
169
|
import { ViewportServerSizeService } from "@ssv/ngx.ux";
|
|
182
170
|
|
|
183
|
-
|
|
171
|
+
export const appConfig: ApplicationConfig = {
|
|
184
172
|
providers: [
|
|
185
173
|
{ provide: ViewportServerSizeService, useClass: SuperViewportServerSizeService }
|
|
186
174
|
]
|
|
187
|
-
}) export class AppModule {
|
|
188
175
|
}
|
|
189
176
|
```
|
|
190
177
|
|
|
@@ -194,7 +181,7 @@ You can configure the existing resize polling speed and as well as provide your
|
|
|
194
181
|
|
|
195
182
|
### Custom Breakpoints
|
|
196
183
|
```ts
|
|
197
|
-
import {
|
|
184
|
+
import { provideSsvUxViewportOptions, generateViewportSizeType } from "@ssv/ngx.ux";
|
|
198
185
|
|
|
199
186
|
const breakpoints = { // custom breakpoints - key/width
|
|
200
187
|
smallest: 500,
|
|
@@ -207,98 +194,25 @@ const breakpoints = { // custom breakpoints - key/width
|
|
|
207
194
|
uhd: 3840
|
|
208
195
|
};
|
|
209
196
|
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
}
|
|
197
|
+
export const appConfig: ApplicationConfig = {
|
|
198
|
+
providers: [
|
|
199
|
+
provideSsvUxViewportOptions({
|
|
200
|
+
resizePollingSpeed: 66, // optional - defaults to 33
|
|
201
|
+
breakpoints // provide the custom breakpoints
|
|
216
202
|
}),
|
|
217
|
-
],
|
|
218
|
-
```
|
|
219
203
|
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
imports: [
|
|
225
|
-
SsvUxModule.forRoot({
|
|
226
|
-
viewport: {
|
|
204
|
+
// override existing breakpoints
|
|
205
|
+
provideSsvUxViewportOptions(defaults => {
|
|
206
|
+
return {
|
|
227
207
|
breakpoints: {
|
|
228
|
-
...
|
|
229
|
-
|
|
230
|
-
uhd: 3840 // add new breakpoint
|
|
208
|
+
...defaults.breakpoints,
|
|
209
|
+
small: 1000,
|
|
231
210
|
}
|
|
232
|
-
}
|
|
211
|
+
};
|
|
233
212
|
}),
|
|
234
|
-
]
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
## Getting Started
|
|
239
|
-
|
|
240
|
-
### Setup Machine for Development
|
|
241
|
-
Install/setup the following:
|
|
242
|
-
|
|
243
|
-
- NodeJS v18.16.0+
|
|
244
|
-
- Visual Studio Code or similar code editor
|
|
245
|
-
- TypeScript 5.0+
|
|
246
|
-
- Git + SourceTree, SmartGit or similar (optional)
|
|
247
|
-
- Ensure to install **global NPM modules** using the following:
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
```bash
|
|
251
|
-
npm install -g git gulp devtool
|
|
252
|
-
```
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
### Project Setup
|
|
256
|
-
The following process need to be executed in order to get started.
|
|
257
|
-
|
|
258
|
-
```bash
|
|
259
|
-
npm install
|
|
260
|
-
```
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
### Building the code
|
|
264
|
-
|
|
265
|
-
```bash
|
|
266
|
-
npm run build
|
|
267
|
-
```
|
|
268
|
-
|
|
269
|
-
### Running the tests
|
|
270
|
-
|
|
271
|
-
```bash
|
|
272
|
-
npm test
|
|
273
|
-
```
|
|
274
|
-
|
|
275
|
-
#### Watch
|
|
276
|
-
Handles compiling of changes.
|
|
277
|
-
|
|
278
|
-
```bash
|
|
279
|
-
npm start
|
|
280
|
-
```
|
|
213
|
+
]
|
|
214
|
+
}
|
|
281
215
|
|
|
282
216
|
|
|
283
|
-
#### Running Continuous Tests
|
|
284
|
-
Spawns test runner and keep watching for changes.
|
|
285
217
|
|
|
286
|
-
```bash
|
|
287
|
-
npm run tdd
|
|
288
218
|
```
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
### Preparation for Release
|
|
292
|
-
|
|
293
|
-
- Update changelogs
|
|
294
|
-
- bump version
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
Check out the [release workflow guide][releaseWorkflowWiki] in order to guide you creating a release and publishing it.
|
|
298
|
-
|
|
299
|
-
### Regen Examples
|
|
300
|
-
- `ng new examples --skip-install --create-application=false`
|
|
301
|
-
- `cd examples`
|
|
302
|
-
- `ng g example-app --routing --style=scss`
|
|
303
|
-
- `ng lint`
|
|
304
|
-
- `ng add @angular/material`
|
package/eslint.config.js
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
const nx = require("@nx/eslint-plugin");
|
|
2
|
+
const baseConfig = require("../../eslint.config.js");
|
|
3
|
+
|
|
4
|
+
module.exports = [
|
|
5
|
+
...baseConfig,
|
|
6
|
+
{
|
|
7
|
+
files: ["**/*.json"],
|
|
8
|
+
rules: {
|
|
9
|
+
"@nx/dependency-checks": ["error", { ignoredFiles: ["{projectRoot}/eslint.config.{js,cjs,mjs}"] }],
|
|
10
|
+
},
|
|
11
|
+
languageOptions: { parser: require("jsonc-eslint-parser") },
|
|
12
|
+
},
|
|
13
|
+
...nx.configs["flat/angular"],
|
|
14
|
+
...nx.configs["flat/angular-template"],
|
|
15
|
+
{
|
|
16
|
+
files: ["**/*.ts"],
|
|
17
|
+
rules: {
|
|
18
|
+
"@angular-eslint/directive-selector": [
|
|
19
|
+
"error",
|
|
20
|
+
{
|
|
21
|
+
type: "attribute",
|
|
22
|
+
prefix: "ssv",
|
|
23
|
+
style: "camelCase",
|
|
24
|
+
},
|
|
25
|
+
],
|
|
26
|
+
"@angular-eslint/component-selector": [
|
|
27
|
+
"error",
|
|
28
|
+
{
|
|
29
|
+
type: "element",
|
|
30
|
+
prefix: "ssv",
|
|
31
|
+
style: "kebab-case",
|
|
32
|
+
},
|
|
33
|
+
],
|
|
34
|
+
"@angular-eslint/directive-selector": "off",
|
|
35
|
+
"@angular-eslint/no-input-rename": "off",
|
|
36
|
+
},
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
files: ["**/*.html"],
|
|
40
|
+
// Override or add rules here
|
|
41
|
+
rules: {},
|
|
42
|
+
},
|
|
43
|
+
];
|
package/index.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./src/index";
|
package/jest.config.ts
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export default {
|
|
2
|
+
displayName: "ngx.ux",
|
|
3
|
+
preset: "../../jest.preset.js",
|
|
4
|
+
setupFilesAfterEnv: ["<rootDir>/src/test-setup.ts"],
|
|
5
|
+
coverageDirectory: "../../coverage/libs/ngx.ux",
|
|
6
|
+
transform: {
|
|
7
|
+
"^.+\\.(ts|mjs|js|html)$": [
|
|
8
|
+
"jest-preset-angular",
|
|
9
|
+
{
|
|
10
|
+
tsconfig: "<rootDir>/tsconfig.spec.json",
|
|
11
|
+
stringifyContentPathRegex: "\\.(html|svg)$",
|
|
12
|
+
},
|
|
13
|
+
],
|
|
14
|
+
},
|
|
15
|
+
transformIgnorePatterns: ["node_modules/(?!.*\\.mjs$)"],
|
|
16
|
+
snapshotSerializers: [
|
|
17
|
+
"jest-preset-angular/build/serializers/no-ng-attributes",
|
|
18
|
+
"jest-preset-angular/build/serializers/ng-snapshot",
|
|
19
|
+
"jest-preset-angular/build/serializers/html-comment",
|
|
20
|
+
],
|
|
21
|
+
};
|
package/ng-package.json
ADDED
package/package.json
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ssv/ngx.ux",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.0-dev.32",
|
|
4
4
|
"versionSuffix": "",
|
|
5
5
|
"description": "UX essentials for building apps, utilities which enables you writing richer apps easier.",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"sketch7",
|
|
8
8
|
"ngx",
|
|
9
|
-
"angular15",
|
|
10
9
|
"angular",
|
|
11
10
|
"ssv",
|
|
12
11
|
"ux",
|
|
@@ -20,37 +19,12 @@
|
|
|
20
19
|
"private": false,
|
|
21
20
|
"repository": {
|
|
22
21
|
"type": "git",
|
|
23
|
-
"url": "https://github.com/sketch7/ngx.
|
|
24
|
-
},
|
|
25
|
-
"dependencies": {
|
|
26
|
-
"tslib": "^2.0.0"
|
|
22
|
+
"url": "https://github.com/sketch7/ssv.ngx.git"
|
|
27
23
|
},
|
|
24
|
+
"dependencies": {},
|
|
28
25
|
"peerDependencies": {
|
|
29
|
-
"@angular/core": ">=
|
|
30
|
-
"lodash": "^4.0.0",
|
|
26
|
+
"@angular/core": ">=17.0.0",
|
|
31
27
|
"rxjs": ">=6.0.0"
|
|
32
28
|
},
|
|
33
|
-
"resolutions": {
|
|
34
|
-
"natives": "1.1.3"
|
|
35
|
-
},
|
|
36
|
-
"module": "fesm2015/ssv-ngx.ux.mjs",
|
|
37
|
-
"es2020": "fesm2020/ssv-ngx.ux.mjs",
|
|
38
|
-
"esm2020": "esm2020/ssv-ngx.ux.mjs",
|
|
39
|
-
"fesm2020": "fesm2020/ssv-ngx.ux.mjs",
|
|
40
|
-
"fesm2015": "fesm2015/ssv-ngx.ux.mjs",
|
|
41
|
-
"typings": "index.d.ts",
|
|
42
|
-
"exports": {
|
|
43
|
-
"./package.json": {
|
|
44
|
-
"default": "./package.json"
|
|
45
|
-
},
|
|
46
|
-
".": {
|
|
47
|
-
"types": "./index.d.ts",
|
|
48
|
-
"esm2020": "./esm2020/ssv-ngx.ux.mjs",
|
|
49
|
-
"es2020": "./fesm2020/ssv-ngx.ux.mjs",
|
|
50
|
-
"es2015": "./fesm2015/ssv-ngx.ux.mjs",
|
|
51
|
-
"node": "./fesm2015/ssv-ngx.ux.mjs",
|
|
52
|
-
"default": "./fesm2020/ssv-ngx.ux.mjs"
|
|
53
|
-
}
|
|
54
|
-
},
|
|
55
29
|
"sideEffects": false
|
|
56
30
|
}
|
package/project.json
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@ssv/ngx.ux",
|
|
3
|
+
"$schema": "../../node_modules/nx/schemas/project-schema.json",
|
|
4
|
+
"sourceRoot": "libs/ngx.ux/src",
|
|
5
|
+
"prefix": "ssv",
|
|
6
|
+
"projectType": "library",
|
|
7
|
+
"tags": [],
|
|
8
|
+
"targets": {
|
|
9
|
+
"build": {
|
|
10
|
+
"executor": "@nx/angular:package",
|
|
11
|
+
"outputs": ["{workspaceRoot}/dist/{projectRoot}"],
|
|
12
|
+
"options": {
|
|
13
|
+
"project": "libs/ngx.ux/ng-package.json"
|
|
14
|
+
},
|
|
15
|
+
"configurations": {
|
|
16
|
+
"production": {
|
|
17
|
+
"tsConfig": "libs/ngx.ux/tsconfig.lib.prod.json"
|
|
18
|
+
},
|
|
19
|
+
"development": {
|
|
20
|
+
"tsConfig": "libs/ngx.ux/tsconfig.lib.json"
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
"defaultConfiguration": "production"
|
|
24
|
+
},
|
|
25
|
+
"test": {
|
|
26
|
+
"executor": "@nx/jest:jest",
|
|
27
|
+
"outputs": ["{workspaceRoot}/coverage/{projectRoot}"],
|
|
28
|
+
"options": {
|
|
29
|
+
"jestConfig": "libs/ngx.ux/jest.config.ts"
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
"lint": {
|
|
33
|
+
"executor": "@nx/eslint:lint"
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { InjectionToken, Injectable, inject } from "@angular/core";
|
|
2
|
+
|
|
3
|
+
export const WINDOW = new InjectionToken<Window>("Window", {
|
|
4
|
+
factory: () => _window() as Window,
|
|
5
|
+
});
|
|
6
|
+
|
|
7
|
+
export function _window(): unknown {
|
|
8
|
+
if (typeof window !== "undefined") {
|
|
9
|
+
return window;
|
|
10
|
+
}
|
|
11
|
+
return {};
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
@Injectable({
|
|
15
|
+
providedIn: "root",
|
|
16
|
+
})
|
|
17
|
+
export class WindowRef {
|
|
18
|
+
|
|
19
|
+
private readonly window = inject(WINDOW);
|
|
20
|
+
|
|
21
|
+
/** Window underlying native object. */
|
|
22
|
+
get native(): Window {
|
|
23
|
+
return this.window as Window;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/** Determines whether native element is supported or not. Generally `false` when executing in SSR. */
|
|
27
|
+
get hasNative(): boolean {
|
|
28
|
+
return !!this.native.window;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
// @ts-expect-error https://thymikee.github.io/jest-preset-angular/docs/getting-started/test-environment
|
|
2
|
+
globalThis.ngJest = {
|
|
3
|
+
testEnvironmentOptions: {
|
|
4
|
+
errorOnUnknownElements: true,
|
|
5
|
+
errorOnUnknownProperties: true,
|
|
6
|
+
},
|
|
7
|
+
};
|
|
8
|
+
import "jest-preset-angular/setup-jest";
|
package/src/ux.module.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { NgModule } from "@angular/core";
|
|
2
|
+
|
|
3
|
+
import { SsvUxViewportModule } from "./viewport/viewport.module";
|
|
4
|
+
|
|
5
|
+
const EXPORTED_IMPORTS = [
|
|
6
|
+
SsvUxViewportModule,
|
|
7
|
+
];
|
|
8
|
+
|
|
9
|
+
@NgModule({
|
|
10
|
+
imports: [EXPORTED_IMPORTS],
|
|
11
|
+
exports: [EXPORTED_IMPORTS]
|
|
12
|
+
})
|
|
13
|
+
export class SsvUxModule {
|
|
14
|
+
|
|
15
|
+
}
|
package/src/version.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const VERSION = "3.0.0-dev.32";
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export * from "./viewport-data/index";
|
|
2
|
+
|
|
3
|
+
export { SsvUxViewportModule } from "./viewport.module";
|
|
4
|
+
export { provideSsvUxViewportOptions, VIEWPORT_OPTIONS, type UxViewportOptions, withViewportSsrDevice } from "./viewport.options";
|
|
5
|
+
|
|
6
|
+
export { SsvViewportMatcherVarDirective, SsvViewportMatcherVarContext } from "./viewport-matcher-var.directive";
|
|
7
|
+
export { SsvViewportMatcherDirective, SsvViewportMatcherContext } from "./viewport-matcher.directive";
|
|
8
|
+
export { VIEWPORT_SSR_DEVICE, ViewportServerSizeService } from "./viewport-server-size.service";
|
|
9
|
+
export {
|
|
10
|
+
type ComparisonOperationValueType,
|
|
11
|
+
type ComparisonOperationLiteral,
|
|
12
|
+
type ComparisonOperationKeyType,
|
|
13
|
+
type ViewportSize,
|
|
14
|
+
type ViewportSizeTypeInfo,
|
|
15
|
+
ComparisonOperation,
|
|
16
|
+
DeviceType,
|
|
17
|
+
ViewportSizeType,
|
|
18
|
+
} from "./viewport.model";
|
|
19
|
+
export { ViewportService } from "./viewport.service";
|
|
20
|
+
export { generateViewportSizeType } from "./viewport.util";
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
# Viewport Data
|
|
2
|
+
Data/config per viewport with fallback strategies
|
|
3
|
+
|
|
4
|
+
## Usage
|
|
5
|
+
|
|
6
|
+
```ts
|
|
7
|
+
import { ViewportDataConfig } from "@ssv/ngx.ux";
|
|
8
|
+
|
|
9
|
+
// define data config object
|
|
10
|
+
dataConfig: ViewportDataConfig<string> = {
|
|
11
|
+
default: "default",
|
|
12
|
+
small: "small",
|
|
13
|
+
large: "large",
|
|
14
|
+
xlarge: "laaarger (xlarge)",
|
|
15
|
+
};
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
```html
|
|
19
|
+
{{ dataConfig | ssvViewportData: "smaller" }}
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
### Using Service
|
|
23
|
+
```ts
|
|
24
|
+
import { ViewportDataService, ViewportDataConfig } from "@ssv/ngx.ux";
|
|
25
|
+
|
|
26
|
+
class MyComp {
|
|
27
|
+
|
|
28
|
+
constructor(
|
|
29
|
+
viewportDataService: ViewportDataService
|
|
30
|
+
) {
|
|
31
|
+
viewportDataService.get$(dataConfig, ViewportDataMatchStrategy.smaller).pipe(
|
|
32
|
+
tap(x => console.log("Viewport - data changed", x)),
|
|
33
|
+
).subscribe(); // handle unsubscribe
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
}
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
### Viewport Matcher Strategies
|
|
40
|
+
|
|
41
|
+
| Strategy | Description |
|
|
42
|
+
| ------------------- | ------------------------------------------------------------------------------------------------------------- |
|
|
43
|
+
| exact | Size should match exact or default. |
|
|
44
|
+
| smaller | Size matches when exact, first match smaller (down) or default. |
|
|
45
|
+
| larger | Size matches when exact match, first match larger (up) or default. |
|
|
46
|
+
| closestSmallerFirst | size matches when exact match, or it tries both smaller/larger (smaller is preferred) until match or default. |
|
|
47
|
+
| closestLargerFirst | Size matches when exact match, or it tries both larger/smaller (larger is preferred) until match or default. |
|