@scaloster_971/scaleadjus 1.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.
Files changed (52) hide show
  1. package/LICENSE +0 -0
  2. package/README.md +215 -0
  3. package/dist/adapters/angular.d.ts +19 -0
  4. package/dist/adapters/angular.d.ts.map +1 -0
  5. package/dist/adapters/react.d.ts +11 -0
  6. package/dist/adapters/react.d.ts.map +1 -0
  7. package/dist/adapters/vanilla.d.ts +3 -0
  8. package/dist/adapters/vanilla.d.ts.map +1 -0
  9. package/dist/adapters/vue.d.ts +11 -0
  10. package/dist/adapters/vue.d.ts.map +1 -0
  11. package/dist/angular.js +535 -0
  12. package/dist/angular.js.map +1 -0
  13. package/dist/angular.mjs +533 -0
  14. package/dist/angular.mjs.map +1 -0
  15. package/dist/core/ScaleAdjus.d.ts +42 -0
  16. package/dist/core/ScaleAdjus.d.ts.map +1 -0
  17. package/dist/core/constants.d.ts +47 -0
  18. package/dist/core/constants.d.ts.map +1 -0
  19. package/dist/core/types.d.ts +80 -0
  20. package/dist/core/types.d.ts.map +1 -0
  21. package/dist/index.d.ts +11 -0
  22. package/dist/index.d.ts.map +1 -0
  23. package/dist/index.js +590 -0
  24. package/dist/index.js.map +1 -0
  25. package/dist/index.min.js +2 -0
  26. package/dist/index.min.js.map +1 -0
  27. package/dist/index.mjs +582 -0
  28. package/dist/index.mjs.map +1 -0
  29. package/dist/index.umd.js +596 -0
  30. package/dist/index.umd.js.map +1 -0
  31. package/dist/plugins/css.d.ts +3 -0
  32. package/dist/plugins/css.d.ts.map +1 -0
  33. package/dist/plugins/tailwind.d.ts +3 -0
  34. package/dist/plugins/tailwind.d.ts.map +1 -0
  35. package/dist/react.js +454 -0
  36. package/dist/react.js.map +1 -0
  37. package/dist/react.mjs +452 -0
  38. package/dist/react.mjs.map +1 -0
  39. package/dist/styles.css +1 -0
  40. package/dist/utils/debounce.d.ts +3 -0
  41. package/dist/utils/debounce.d.ts.map +1 -0
  42. package/dist/utils/device.d.ts +12 -0
  43. package/dist/utils/device.d.ts.map +1 -0
  44. package/dist/utils/dom.d.ts +13 -0
  45. package/dist/utils/dom.d.ts.map +1 -0
  46. package/dist/utils/events.d.ts +12 -0
  47. package/dist/utils/events.d.ts.map +1 -0
  48. package/dist/vue.js +452 -0
  49. package/dist/vue.js.map +1 -0
  50. package/dist/vue.mjs +450 -0
  51. package/dist/vue.mjs.map +1 -0
  52. package/package.json +116 -0
package/LICENSE ADDED
File without changes
package/README.md ADDED
@@ -0,0 +1,215 @@
1
+ # ScaleAdjus
2
+
3
+ -Universal responsive scaling for websites and apps(compatible with npm) and applications across all devices.
4
+ -Implement scaleadjus npm package to your projects and you no need to extra work in adjusting components for website/apps across multi-devices (pc,laptop,tablet,phones) as it adjust the size of components/icons/buttons,etc throughout entire website.
5
+
6
+
7
+ [![npm version](https://badge.fury.io/js/scaleadjus.svg)](https://www.npmjs.com/package/scaleadjus)
8
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
9
+ [![TypeScript](https://img.shields.io/badge/TypeScript-5.2-blue.svg)](https://www.typescriptlang.org/)
10
+ [![Downloads](https://img.shields.io/npm/dm/scaleadjus.svg)](https://www.npmjs.com/package/scaleadjus)
11
+
12
+ ScaleAdjus is a small TypeScript package for automatic, device-aware scaling. It helps developers keep components, buttons, icons, cards, layouts, and text visually balanced across phones, tablets, laptops, desktops, and large monitors without rewriting the same responsive sizing rules again and again.
13
+
14
+ ## Why Use It
15
+
16
+ - Automatically detects screen size and maps it to mobile, tablet, desktop, or large monitor.
17
+ - Applies a controlled scale factor to selected elements.
18
+ - Updates CSS variables such as `--sa-scale` and `--sa-device`.
19
+ - Includes vanilla JavaScript, React, Vue, Angular, CSS, and Tailwind entry points.
20
+ - Keeps framework adapters optional, so plain JavaScript users do not need React, Vue, or Angular installed.
21
+ - Ships TypeScript declarations and browser-ready UMD, CommonJS, and ESM builds.
22
+
23
+ ## Installation
24
+
25
+ ```bash
26
+ npm install scaleadjus
27
+ ```
28
+
29
+ ```bash
30
+ yarn add scaleadjus
31
+ ```
32
+
33
+ ```bash
34
+ pnpm add scaleadjus
35
+ ```
36
+
37
+ ```bash
38
+ bun add scaleadjus
39
+ ```
40
+
41
+ ## Quick Start
42
+
43
+ ```ts
44
+ import ScaleAdjus from 'scaleadjus';
45
+ import 'scaleadjus/styles.css';
46
+
47
+ const scaler = new ScaleAdjus({
48
+ autoInit: true,
49
+ baseScale: 1,
50
+ minScale: 0.75,
51
+ maxScale: 1.25,
52
+ });
53
+
54
+ scaler.setScale(1.05);
55
+ ```
56
+
57
+ By default, ScaleAdjus targets the page and updates itself on resize, orientation changes, and DOM changes.
58
+
59
+ ## CDN Usage
60
+
61
+ ```html
62
+ <link rel="stylesheet" href="https://unpkg.com/scaleadjus/dist/styles.css">
63
+ <script src="https://unpkg.com/scaleadjus/dist/index.umd.js"></script>
64
+ ```
65
+
66
+ ```html
67
+ <script>
68
+ const scaler = new ScaleAdjus.ScaleAdjus({
69
+ autoInit: true,
70
+ });
71
+ </script>
72
+ ```
73
+
74
+ ## Options
75
+
76
+ ```ts
77
+ const scaler = new ScaleAdjus({
78
+ baseScale: 1,
79
+ minScale: 0.75,
80
+ maxScale: 1.25,
81
+ smoothTransition: true,
82
+ transitionDuration: 300,
83
+ includeSelectors: ['body', '.app-shell', '.scale-me'],
84
+ excludeSelectors: ['.sa-no-scale', '[data-no-scale]'],
85
+ breakpoints: {
86
+ mobile: 768,
87
+ tablet: 1024,
88
+ desktop: 1200,
89
+ largeMonitor: 1600,
90
+ },
91
+ scaleFactors: {
92
+ mobile: 0.85,
93
+ tablet: 0.95,
94
+ desktop: 1,
95
+ largeMonitor: 1.1,
96
+ },
97
+ });
98
+ ```
99
+
100
+ ## Framework Adapters
101
+
102
+ ### React
103
+
104
+ ```tsx
105
+ import { createReactHook } from 'scaleadjus/react';
106
+ import 'scaleadjus/styles.css';
107
+
108
+ export function App() {
109
+ const { scale, deviceInfo, setScale, resetScale } = createReactHook();
110
+
111
+ return (
112
+ <main>
113
+ <p>Current scale: {scale}</p>
114
+ <p>Device: {deviceInfo?.type}</p>
115
+ <button onClick={() => setScale(1.1)}>Scale up</button>
116
+ <button onClick={resetScale}>Reset</button>
117
+ </main>
118
+ );
119
+ }
120
+ ```
121
+
122
+ ### Vue
123
+
124
+ ```ts
125
+ import { createVuePlugin } from 'scaleadjus/vue';
126
+ import 'scaleadjus/styles.css';
127
+
128
+ const { scale, deviceInfo, setScale, resetScale } = createVuePlugin();
129
+ ```
130
+
131
+ ### Angular
132
+
133
+ ```ts
134
+ import { createAngularService } from 'scaleadjus/angular';
135
+
136
+ // Provide createAngularService in Angular and inject it where scaling controls are needed.
137
+ ```
138
+
139
+ ## Vanilla Adapter
140
+
141
+ ```ts
142
+ import { VanillaScaleAdjus } from 'scaleadjus';
143
+
144
+ const scaler = VanillaScaleAdjus({
145
+ includeSelectors: ['.app', '.card', '.button'],
146
+ });
147
+ ```
148
+
149
+ ## CSS Utilities
150
+
151
+ Import the stylesheet once:
152
+
153
+ ```ts
154
+ import 'scaleadjus/styles.css';
155
+ ```
156
+
157
+ Useful classes:
158
+
159
+ - `sa-container` keeps content full-width and boxed correctly.
160
+ - `sa-grid` creates responsive grid columns.
161
+ - `sa-flex` enables wrapping flex layouts.
162
+ - `sa-responsive` scales text with `--sa-scale`.
163
+ - `sa-no-scale` excludes an element from ScaleAdjus transforms.
164
+ - `sa-hidden-mobile`, `sa-visible-mobile`, `sa-hidden-tablet`, and related helpers handle visibility by device range.
165
+
166
+ ## Events
167
+
168
+ ```ts
169
+ scaler.addEventListener('scaleadjus:scale', (event) => {
170
+ console.log(event.scale, event.device, event.width, event.height);
171
+ });
172
+ ```
173
+
174
+ Available events:
175
+
176
+ - `scaleadjus:init`
177
+ - `scaleadjus:scale`
178
+ - `scaleadjus:reset`
179
+ - `scaleadjus:destroy`
180
+ - `scaleadjus:update`
181
+ - `scaleadjus:device-change`
182
+
183
+ ## API
184
+
185
+ - `init()` starts scaling.
186
+ - `destroy()` removes listeners, injected styles, and scaling state.
187
+ - `setScale(scale)` applies a manual scale.
188
+ - `resetScale()` returns to the configured base scale.
189
+ - `updateOptions(options)` changes runtime configuration.
190
+ - `getCurrentScale()` returns the current scale value.
191
+ - `getDeviceInfo()` returns the current device type, viewport size, and calculated scale.
192
+ - `setElementScale(element, scale)` scales one element.
193
+ - `resetElementScale(element)` removes scaling from one element.
194
+
195
+ ## Build From Source
196
+
197
+ ```bash
198
+ npm install
199
+ npm run build
200
+ npm run lint
201
+ ```
202
+
203
+ Generated package files are written to `dist`.
204
+
205
+ ## Package Entry Points
206
+
207
+ - `scaleadjus` for the core package, vanilla adapter, CSS plugin, and Tailwind plugin.
208
+ - `scaleadjus/react` for the React hook adapter.
209
+ - `scaleadjus/vue` for the Vue composition adapter.
210
+ - `scaleadjus/angular` for the Angular service adapter.
211
+ - `scaleadjus/styles.css` for packaged CSS utilities.
212
+
213
+ ## License
214
+
215
+ MIT
@@ -0,0 +1,19 @@
1
+ import { OnDestroy } from '@angular/core';
2
+ import { ScaleOptions, DeviceInfo, ScaleEvent } from '../core/types';
3
+ import { Observable } from 'rxjs';
4
+ export declare class createAngularService implements OnDestroy {
5
+ private instance;
6
+ private scaleSubject;
7
+ private deviceSubject;
8
+ scale$: Observable<ScaleEvent>;
9
+ device$: Observable<DeviceInfo>;
10
+ constructor();
11
+ getScale(): number;
12
+ getDeviceInfo(): DeviceInfo | null;
13
+ setScale(scale: number): void;
14
+ resetScale(): void;
15
+ updateOptions(options: Partial<ScaleOptions>): void;
16
+ destroy(): void;
17
+ ngOnDestroy(): void;
18
+ }
19
+ //# sourceMappingURL=angular.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"angular.d.ts","sourceRoot":"","sources":["../../src/adapters/angular.ts"],"names":[],"mappings":"AAAA,OAAO,EAAc,SAAS,EAAE,MAAM,eAAe,CAAC;AAEtD,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AACrE,OAAO,EAAE,UAAU,EAAW,MAAM,MAAM,CAAC;AAE3C,qBAGa,oBAAqB,YAAW,SAAS;IACpD,OAAO,CAAC,QAAQ,CAA2B;IAC3C,OAAO,CAAC,YAAY,CAA6B;IACjD,OAAO,CAAC,aAAa,CAA6B;IAE3C,MAAM,EAAE,UAAU,CAAC,UAAU,CAAC,CAAoC;IAClE,OAAO,EAAE,UAAU,CAAC,UAAU,CAAC,CAAqC;;IAgBpE,QAAQ,IAAI,MAAM;IAIlB,aAAa,IAAI,UAAU,GAAG,IAAI;IAIlC,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAI7B,UAAU,IAAI,IAAI;IAIlB,aAAa,CAAC,OAAO,EAAE,OAAO,CAAC,YAAY,CAAC,GAAG,IAAI;IAInD,OAAO,IAAI,IAAI;IAOf,WAAW,IAAI,IAAI;CAG3B"}
@@ -0,0 +1,11 @@
1
+ import { ScaleAdjus } from '../core/ScaleAdjus';
2
+ import { ScaleOptions, DeviceInfo } from '../core/types';
3
+ export declare function createReactHook(options?: ScaleOptions): {
4
+ scale: number;
5
+ deviceInfo: DeviceInfo | null;
6
+ setScale: (newScale: number) => void;
7
+ resetScale: () => void;
8
+ updateOptions: (newOptions: Partial<ScaleOptions>) => void;
9
+ instance: ScaleAdjus | null;
10
+ };
11
+ //# sourceMappingURL=react.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"react.d.ts","sourceRoot":"","sources":["../../src/adapters/react.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,YAAY,EAAE,UAAU,EAAc,MAAM,eAAe,CAAC;AAErE,wBAAgB,eAAe,CAAC,OAAO,GAAE,YAAiB;;;yBA2BhB,MAAM;;gCAQC,OAAO,CAAC,YAAY,CAAC;;EAYrE"}
@@ -0,0 +1,3 @@
1
+ import { ScaleOptions, ScaleAdjusInstance } from '../core/types';
2
+ export declare function vanillaAdapter(options?: ScaleOptions): ScaleAdjusInstance;
3
+ //# sourceMappingURL=vanilla.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vanilla.d.ts","sourceRoot":"","sources":["../../src/adapters/vanilla.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAEjE,wBAAgB,cAAc,CAAC,OAAO,GAAE,YAAiB,GAAG,kBAAkB,CAO7E"}
@@ -0,0 +1,11 @@
1
+ import { ScaleAdjus } from '../core/ScaleAdjus';
2
+ import { ScaleOptions, DeviceInfo } from '../core/types';
3
+ export declare function createVuePlugin(options?: ScaleOptions): {
4
+ instance: import("vue").Ref<ScaleAdjus | null>;
5
+ scale: import("vue").Ref<number>;
6
+ deviceInfo: import("vue").Ref<DeviceInfo | null>;
7
+ setScale: (newScale: number) => void;
8
+ resetScale: () => void;
9
+ updateOptions: (newOptions: Partial<ScaleOptions>) => void;
10
+ };
11
+ //# sourceMappingURL=vue.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vue.d.ts","sourceRoot":"","sources":["../../src/adapters/vue.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,YAAY,EAAE,UAAU,EAAc,MAAM,eAAe,CAAC;AAErE,wBAAgB,eAAe,CAAC,OAAO,GAAE,YAAiB;;;;yBAyB5B,MAAM;;gCAQC,OAAO,CAAC,YAAY,CAAC;EAYzD"}