@furystack/shades-common-components 10.0.35 → 11.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 +66 -0
- package/esm/components/animations.spec.d.ts +2 -0
- package/esm/components/animations.spec.d.ts.map +1 -0
- package/esm/components/animations.spec.js +201 -0
- package/esm/components/animations.spec.js.map +1 -0
- package/esm/components/app-bar-link.js +21 -20
- package/esm/components/app-bar-link.js.map +1 -1
- package/esm/components/app-bar-link.spec.d.ts +2 -0
- package/esm/components/app-bar-link.spec.d.ts.map +1 -0
- package/esm/components/app-bar-link.spec.js +252 -0
- package/esm/components/app-bar-link.spec.js.map +1 -0
- package/esm/components/app-bar.js +21 -21
- package/esm/components/app-bar.js.map +1 -1
- package/esm/components/app-bar.spec.d.ts +2 -0
- package/esm/components/app-bar.spec.d.ts.map +1 -0
- package/esm/components/app-bar.spec.js +117 -0
- package/esm/components/app-bar.spec.js.map +1 -0
- package/esm/components/avatar.d.ts.map +1 -1
- package/esm/components/avatar.js +15 -19
- package/esm/components/avatar.js.map +1 -1
- package/esm/components/avatar.spec.d.ts +2 -0
- package/esm/components/avatar.spec.d.ts.map +1 -0
- package/esm/components/avatar.spec.js +114 -0
- package/esm/components/avatar.spec.js.map +1 -0
- package/esm/components/button.d.ts.map +1 -1
- package/esm/components/button.js +145 -156
- package/esm/components/button.js.map +1 -1
- package/esm/components/button.spec.d.ts +2 -0
- package/esm/components/button.spec.d.ts.map +1 -0
- package/esm/components/button.spec.js +155 -0
- package/esm/components/button.spec.js.map +1 -0
- package/esm/components/command-palette/command-palette-input.d.ts.map +1 -1
- package/esm/components/command-palette/command-palette-input.js +18 -16
- package/esm/components/command-palette/command-palette-input.js.map +1 -1
- package/esm/components/command-palette/command-palette-input.spec.d.ts +2 -0
- package/esm/components/command-palette/command-palette-input.spec.d.ts.map +1 -0
- package/esm/components/command-palette/command-palette-input.spec.js +233 -0
- package/esm/components/command-palette/command-palette-input.spec.js.map +1 -0
- package/esm/components/command-palette/command-palette-manager.spec.d.ts +2 -0
- package/esm/components/command-palette/command-palette-manager.spec.d.ts.map +1 -0
- package/esm/components/command-palette/command-palette-manager.spec.js +362 -0
- package/esm/components/command-palette/command-palette-manager.spec.js.map +1 -0
- package/esm/components/command-palette/command-palette-suggestion-list.d.ts.map +1 -1
- package/esm/components/command-palette/command-palette-suggestion-list.js +42 -46
- package/esm/components/command-palette/command-palette-suggestion-list.js.map +1 -1
- package/esm/components/command-palette/command-palette-suggestion-list.spec.d.ts +2 -0
- package/esm/components/command-palette/command-palette-suggestion-list.spec.d.ts.map +1 -0
- package/esm/components/command-palette/command-palette-suggestion-list.spec.js +376 -0
- package/esm/components/command-palette/command-palette-suggestion-list.spec.js.map +1 -0
- package/esm/components/command-palette/index.d.ts.map +1 -1
- package/esm/components/command-palette/index.js +100 -110
- package/esm/components/command-palette/index.js.map +1 -1
- package/esm/components/command-palette/index.spec.d.ts +2 -0
- package/esm/components/command-palette/index.spec.d.ts.map +1 -0
- package/esm/components/command-palette/index.spec.js +509 -0
- package/esm/components/command-palette/index.spec.js.map +1 -0
- package/esm/components/data-grid/body.js +1 -1
- package/esm/components/data-grid/body.js.map +1 -1
- package/esm/components/data-grid/body.spec.d.ts +2 -0
- package/esm/components/data-grid/body.spec.d.ts.map +1 -0
- package/esm/components/data-grid/body.spec.js +228 -0
- package/esm/components/data-grid/body.spec.js.map +1 -0
- package/esm/components/data-grid/data-grid-row.d.ts.map +1 -1
- package/esm/components/data-grid/data-grid-row.js +49 -73
- package/esm/components/data-grid/data-grid-row.js.map +1 -1
- package/esm/components/data-grid/data-grid-row.spec.d.ts +2 -0
- package/esm/components/data-grid/data-grid-row.spec.d.ts.map +1 -0
- package/esm/components/data-grid/data-grid-row.spec.js +296 -0
- package/esm/components/data-grid/data-grid-row.spec.js.map +1 -0
- package/esm/components/data-grid/data-grid.d.ts.map +1 -1
- package/esm/components/data-grid/data-grid.js +35 -28
- package/esm/components/data-grid/data-grid.js.map +1 -1
- package/esm/components/data-grid/data-grid.spec.d.ts +2 -0
- package/esm/components/data-grid/data-grid.spec.d.ts.map +1 -0
- package/esm/components/data-grid/data-grid.spec.js +544 -0
- package/esm/components/data-grid/data-grid.spec.js.map +1 -0
- package/esm/components/data-grid/footer.js +21 -15
- package/esm/components/data-grid/footer.js.map +1 -1
- package/esm/components/data-grid/footer.spec.d.ts +2 -0
- package/esm/components/data-grid/footer.spec.d.ts.map +1 -0
- package/esm/components/data-grid/footer.spec.js +264 -0
- package/esm/components/data-grid/footer.spec.js.map +1 -0
- package/esm/components/data-grid/header.d.ts.map +1 -1
- package/esm/components/data-grid/header.js +55 -33
- package/esm/components/data-grid/header.js.map +1 -1
- package/esm/components/data-grid/header.spec.d.ts +2 -0
- package/esm/components/data-grid/header.spec.d.ts.map +1 -0
- package/esm/components/data-grid/header.spec.js +421 -0
- package/esm/components/data-grid/header.spec.js.map +1 -0
- package/esm/components/data-grid/selection-cell.d.ts.map +1 -1
- package/esm/components/data-grid/selection-cell.js +13 -6
- package/esm/components/data-grid/selection-cell.js.map +1 -1
- package/esm/components/data-grid/selection-cell.spec.d.ts +2 -0
- package/esm/components/data-grid/selection-cell.spec.d.ts.map +1 -0
- package/esm/components/data-grid/selection-cell.spec.js +118 -0
- package/esm/components/data-grid/selection-cell.spec.js.map +1 -0
- package/esm/components/fab.d.ts.map +1 -1
- package/esm/components/fab.js +10 -1
- package/esm/components/fab.js.map +1 -1
- package/esm/components/fab.spec.d.ts +2 -0
- package/esm/components/fab.spec.d.ts.map +1 -0
- package/esm/components/fab.spec.js +95 -0
- package/esm/components/fab.spec.js.map +1 -0
- package/esm/components/form.spec.d.ts +2 -0
- package/esm/components/form.spec.d.ts.map +1 -0
- package/esm/components/form.spec.js +314 -0
- package/esm/components/form.spec.js.map +1 -0
- package/esm/components/grid.d.ts.map +1 -1
- package/esm/components/grid.js +40 -37
- package/esm/components/grid.js.map +1 -1
- package/esm/components/grid.spec.d.ts +2 -0
- package/esm/components/grid.spec.d.ts.map +1 -0
- package/esm/components/grid.spec.js +316 -0
- package/esm/components/grid.spec.js.map +1 -0
- package/esm/components/inputs/autocomplete.spec.d.ts +2 -0
- package/esm/components/inputs/autocomplete.spec.d.ts.map +1 -0
- package/esm/components/inputs/autocomplete.spec.js +194 -0
- package/esm/components/inputs/autocomplete.spec.js.map +1 -0
- package/esm/components/inputs/input.d.ts.map +1 -1
- package/esm/components/inputs/input.js +141 -109
- package/esm/components/inputs/input.js.map +1 -1
- package/esm/components/inputs/input.spec.d.ts +2 -0
- package/esm/components/inputs/input.spec.d.ts.map +1 -0
- package/esm/components/inputs/input.spec.js +577 -0
- package/esm/components/inputs/input.spec.js.map +1 -0
- package/esm/components/inputs/text-area.d.ts.map +1 -1
- package/esm/components/inputs/text-area.js +54 -58
- package/esm/components/inputs/text-area.js.map +1 -1
- package/esm/components/inputs/text-area.spec.d.ts +2 -0
- package/esm/components/inputs/text-area.spec.d.ts.map +1 -0
- package/esm/components/inputs/text-area.spec.js +214 -0
- package/esm/components/inputs/text-area.spec.js.map +1 -0
- package/esm/components/loader.js +1 -1
- package/esm/components/loader.js.map +1 -1
- package/esm/components/loader.spec.d.ts +2 -0
- package/esm/components/loader.spec.d.ts.map +1 -0
- package/esm/components/loader.spec.js +251 -0
- package/esm/components/loader.spec.js.map +1 -0
- package/esm/components/modal.d.ts.map +1 -1
- package/esm/components/modal.js +11 -9
- package/esm/components/modal.js.map +1 -1
- package/esm/components/modal.spec.d.ts +2 -0
- package/esm/components/modal.spec.d.ts.map +1 -0
- package/esm/components/modal.spec.js +227 -0
- package/esm/components/modal.spec.js.map +1 -0
- package/esm/components/noty-list.d.ts.map +1 -1
- package/esm/components/noty-list.js +39 -40
- package/esm/components/noty-list.js.map +1 -1
- package/esm/components/noty-list.spec.d.ts +2 -0
- package/esm/components/noty-list.spec.d.ts.map +1 -0
- package/esm/components/noty-list.spec.js +486 -0
- package/esm/components/noty-list.spec.js.map +1 -0
- package/esm/components/paper.d.ts.map +1 -1
- package/esm/components/paper.js +15 -12
- package/esm/components/paper.js.map +1 -1
- package/esm/components/paper.spec.d.ts +2 -0
- package/esm/components/paper.spec.d.ts.map +1 -0
- package/esm/components/paper.spec.js +63 -0
- package/esm/components/paper.spec.js.map +1 -0
- package/esm/components/skeleton.js +1 -1
- package/esm/components/skeleton.js.map +1 -1
- package/esm/components/skeleton.spec.d.ts +2 -0
- package/esm/components/skeleton.spec.d.ts.map +1 -0
- package/esm/components/skeleton.spec.js +159 -0
- package/esm/components/skeleton.spec.js.map +1 -0
- package/esm/components/styles.spec.d.ts +2 -0
- package/esm/components/styles.spec.d.ts.map +1 -0
- package/esm/components/styles.spec.js +56 -0
- package/esm/components/styles.spec.js.map +1 -0
- package/esm/components/suggest/index.d.ts.map +1 -1
- package/esm/components/suggest/index.js +74 -83
- package/esm/components/suggest/index.js.map +1 -1
- package/esm/components/suggest/index.spec.d.ts +2 -0
- package/esm/components/suggest/index.spec.d.ts.map +1 -0
- package/esm/components/suggest/index.spec.js +515 -0
- package/esm/components/suggest/index.spec.js.map +1 -0
- package/esm/components/suggest/suggest-input.d.ts.map +1 -1
- package/esm/components/suggest/suggest-input.js +16 -17
- package/esm/components/suggest/suggest-input.js.map +1 -1
- package/esm/components/suggest/suggest-input.spec.d.ts +2 -0
- package/esm/components/suggest/suggest-input.spec.d.ts.map +1 -0
- package/esm/components/suggest/suggest-input.spec.js +138 -0
- package/esm/components/suggest/suggest-input.spec.js.map +1 -0
- package/esm/components/suggest/suggest-manager.spec.d.ts +2 -0
- package/esm/components/suggest/suggest-manager.spec.d.ts.map +1 -0
- package/esm/components/suggest/suggest-manager.spec.js +308 -0
- package/esm/components/suggest/suggest-manager.spec.js.map +1 -0
- package/esm/components/suggest/suggestion-list.d.ts.map +1 -1
- package/esm/components/suggest/suggestion-list.js +43 -48
- package/esm/components/suggest/suggestion-list.js.map +1 -1
- package/esm/components/suggest/suggestion-list.spec.d.ts +2 -0
- package/esm/components/suggest/suggestion-list.spec.d.ts.map +1 -0
- package/esm/components/suggest/suggestion-list.spec.js +252 -0
- package/esm/components/suggest/suggestion-list.spec.js.map +1 -0
- package/esm/components/tabs.d.ts.map +1 -1
- package/esm/components/tabs.js +32 -18
- package/esm/components/tabs.js.map +1 -1
- package/esm/components/tabs.spec.d.ts +2 -0
- package/esm/components/tabs.spec.d.ts.map +1 -0
- package/esm/components/tabs.spec.js +187 -0
- package/esm/components/tabs.spec.js.map +1 -0
- package/esm/components/wizard/index.d.ts.map +1 -1
- package/esm/components/wizard/index.js +10 -7
- package/esm/components/wizard/index.js.map +1 -1
- package/esm/components/wizard/index.spec.d.ts +2 -0
- package/esm/components/wizard/index.spec.d.ts.map +1 -0
- package/esm/components/wizard/index.spec.js +171 -0
- package/esm/components/wizard/index.spec.js.map +1 -0
- package/esm/services/collection-service.spec.js +391 -2
- package/esm/services/collection-service.spec.js.map +1 -1
- package/esm/services/css-variable-theme.d.ts.map +1 -1
- package/esm/services/css-variable-theme.js +21 -1
- package/esm/services/css-variable-theme.js.map +1 -1
- package/esm/services/css-variable-theme.spec.d.ts +2 -0
- package/esm/services/css-variable-theme.spec.d.ts.map +1 -0
- package/esm/services/css-variable-theme.spec.js +169 -0
- package/esm/services/css-variable-theme.spec.js.map +1 -0
- package/esm/services/default-palette.d.ts +4 -0
- package/esm/services/default-palette.d.ts.map +1 -1
- package/esm/services/default-palette.js +22 -0
- package/esm/services/default-palette.js.map +1 -1
- package/esm/services/theme-provider-service.d.ts +59 -1
- package/esm/services/theme-provider-service.d.ts.map +1 -1
- package/esm/services/theme-provider-service.js.map +1 -1
- package/esm/services/theme-provider-service.spec.d.ts +2 -0
- package/esm/services/theme-provider-service.spec.d.ts.map +1 -0
- package/esm/services/theme-provider-service.spec.js +166 -0
- package/esm/services/theme-provider-service.spec.js.map +1 -0
- package/package.json +2 -2
- package/src/components/animations.spec.ts +299 -0
- package/src/components/app-bar-link.spec.tsx +341 -0
- package/src/components/app-bar-link.tsx +21 -21
- package/src/components/app-bar.spec.tsx +142 -0
- package/src/components/app-bar.tsx +22 -22
- package/src/components/avatar.spec.tsx +146 -0
- package/src/components/avatar.tsx +17 -20
- package/src/components/button.spec.tsx +193 -0
- package/src/components/button.tsx +162 -197
- package/src/components/command-palette/command-palette-input.spec.tsx +320 -0
- package/src/components/command-palette/command-palette-input.tsx +19 -22
- package/src/components/command-palette/command-palette-manager.spec.ts +470 -0
- package/src/components/command-palette/command-palette-suggestion-list.spec.tsx +499 -0
- package/src/components/command-palette/command-palette-suggestion-list.tsx +42 -46
- package/src/components/command-palette/index.spec.tsx +684 -0
- package/src/components/command-palette/index.tsx +107 -136
- package/src/components/data-grid/body.spec.tsx +340 -0
- package/src/components/data-grid/body.tsx +1 -1
- package/src/components/data-grid/data-grid-row.spec.tsx +382 -0
- package/src/components/data-grid/data-grid-row.tsx +50 -82
- package/src/components/data-grid/data-grid.spec.tsx +939 -0
- package/src/components/data-grid/data-grid.tsx +38 -35
- package/src/components/data-grid/footer.spec.tsx +344 -0
- package/src/components/data-grid/footer.tsx +19 -19
- package/src/components/data-grid/header.spec.tsx +563 -0
- package/src/components/data-grid/header.tsx +53 -44
- package/src/components/data-grid/selection-cell.spec.tsx +150 -0
- package/src/components/data-grid/selection-cell.tsx +12 -6
- package/src/components/fab.spec.tsx +108 -0
- package/src/components/fab.tsx +10 -1
- package/src/components/form.spec.tsx +481 -0
- package/src/components/grid.spec.tsx +334 -0
- package/src/components/grid.tsx +57 -63
- package/src/components/inputs/autocomplete.spec.tsx +258 -0
- package/src/components/inputs/input.spec.tsx +808 -0
- package/src/components/inputs/input.tsx +153 -139
- package/src/components/inputs/text-area.spec.tsx +285 -0
- package/src/components/inputs/text-area.tsx +53 -79
- package/src/components/loader.spec.tsx +346 -0
- package/src/components/loader.tsx +1 -1
- package/src/components/modal.spec.tsx +304 -0
- package/src/components/modal.tsx +11 -9
- package/src/components/noty-list.spec.tsx +631 -0
- package/src/components/noty-list.tsx +39 -50
- package/src/components/paper.spec.tsx +72 -0
- package/src/components/paper.tsx +15 -13
- package/src/components/skeleton.spec.tsx +219 -0
- package/src/components/skeleton.tsx +1 -1
- package/src/components/styles.spec.ts +70 -0
- package/src/components/suggest/index.spec.tsx +861 -0
- package/src/components/suggest/index.tsx +74 -101
- package/src/components/suggest/suggest-input.spec.tsx +181 -0
- package/src/components/suggest/suggest-input.tsx +16 -24
- package/src/components/suggest/suggest-manager.spec.ts +409 -0
- package/src/components/suggest/suggestion-list.spec.tsx +334 -0
- package/src/components/suggest/suggestion-list.tsx +43 -48
- package/src/components/tabs.spec.tsx +236 -0
- package/src/components/tabs.tsx +33 -21
- package/src/components/wizard/index.spec.tsx +224 -0
- package/src/components/wizard/index.tsx +10 -9
- package/src/services/collection-service.spec.ts +492 -3
- package/src/services/css-variable-theme.spec.ts +204 -0
- package/src/services/css-variable-theme.ts +21 -1
- package/src/services/default-palette.ts +22 -0
- package/src/services/theme-provider-service.spec.ts +195 -0
- package/src/services/theme-provider-service.ts +60 -2
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
import { beforeEach, describe, expect, it } from 'vitest';
|
|
2
|
+
import { RgbColor, ThemeProviderService } from './theme-provider-service.js';
|
|
3
|
+
describe('theme-provider-service', () => {
|
|
4
|
+
describe('RgbColor', () => {
|
|
5
|
+
describe('constructor', () => {
|
|
6
|
+
it('should create RgbColor with r, g, b values', () => {
|
|
7
|
+
const color = new RgbColor(255, 128, 64);
|
|
8
|
+
expect(color.r).toBe(255);
|
|
9
|
+
expect(color.g).toBe(128);
|
|
10
|
+
expect(color.b).toBe(64);
|
|
11
|
+
expect(color.a).toBe(1);
|
|
12
|
+
});
|
|
13
|
+
it('should create RgbColor with alpha value', () => {
|
|
14
|
+
const color = new RgbColor(255, 128, 64, 0.5);
|
|
15
|
+
expect(color.r).toBe(255);
|
|
16
|
+
expect(color.g).toBe(128);
|
|
17
|
+
expect(color.b).toBe(64);
|
|
18
|
+
expect(color.a).toBe(0.5);
|
|
19
|
+
});
|
|
20
|
+
it('should default alpha to 1', () => {
|
|
21
|
+
const color = new RgbColor(100, 100, 100);
|
|
22
|
+
expect(color.a).toBe(1);
|
|
23
|
+
});
|
|
24
|
+
});
|
|
25
|
+
describe('update', () => {
|
|
26
|
+
it('should update r value and return self', () => {
|
|
27
|
+
const color = new RgbColor(100, 100, 100);
|
|
28
|
+
const result = color.update('r', 200);
|
|
29
|
+
expect(result).toBe(color);
|
|
30
|
+
expect(color.r).toBe(200);
|
|
31
|
+
});
|
|
32
|
+
it('should update g value', () => {
|
|
33
|
+
const color = new RgbColor(100, 100, 100);
|
|
34
|
+
color.update('g', 150);
|
|
35
|
+
expect(color.g).toBe(150);
|
|
36
|
+
});
|
|
37
|
+
it('should update b value', () => {
|
|
38
|
+
const color = new RgbColor(100, 100, 100);
|
|
39
|
+
color.update('b', 50);
|
|
40
|
+
expect(color.b).toBe(50);
|
|
41
|
+
});
|
|
42
|
+
it('should update a value', () => {
|
|
43
|
+
const color = new RgbColor(100, 100, 100, 1);
|
|
44
|
+
color.update('a', 0.7);
|
|
45
|
+
expect(color.a).toBe(0.7);
|
|
46
|
+
});
|
|
47
|
+
it('should allow chained updates', () => {
|
|
48
|
+
const color = new RgbColor(0, 0, 0);
|
|
49
|
+
color.update('r', 255).update('g', 128).update('b', 64);
|
|
50
|
+
expect(color.r).toBe(255);
|
|
51
|
+
expect(color.g).toBe(128);
|
|
52
|
+
expect(color.b).toBe(64);
|
|
53
|
+
});
|
|
54
|
+
});
|
|
55
|
+
describe('toString', () => {
|
|
56
|
+
it('should return rgba format string', () => {
|
|
57
|
+
const color = new RgbColor(255, 128, 64, 0.5);
|
|
58
|
+
expect(color.toString()).toBe('rgba(255,128,64,0.5)');
|
|
59
|
+
});
|
|
60
|
+
it('should handle full opacity', () => {
|
|
61
|
+
const color = new RgbColor(0, 0, 0, 1);
|
|
62
|
+
expect(color.toString()).toBe('rgba(0,0,0,1)');
|
|
63
|
+
});
|
|
64
|
+
it('should handle zero alpha', () => {
|
|
65
|
+
const color = new RgbColor(255, 255, 255, 0);
|
|
66
|
+
expect(color.toString()).toBe('rgba(255,255,255,0)');
|
|
67
|
+
});
|
|
68
|
+
});
|
|
69
|
+
});
|
|
70
|
+
describe('ThemeProviderService', () => {
|
|
71
|
+
let service;
|
|
72
|
+
beforeEach(() => {
|
|
73
|
+
service = new ThemeProviderService();
|
|
74
|
+
});
|
|
75
|
+
describe('getRgbFromColorString', () => {
|
|
76
|
+
it('should parse 6-digit hex color', () => {
|
|
77
|
+
const result = service.getRgbFromColorString('#ff8040');
|
|
78
|
+
expect(result.r).toBe(255);
|
|
79
|
+
expect(result.g).toBe(128);
|
|
80
|
+
expect(result.b).toBe(64);
|
|
81
|
+
});
|
|
82
|
+
it('should parse 6-digit hex color with lowercase', () => {
|
|
83
|
+
const result = service.getRgbFromColorString('#3f51b5');
|
|
84
|
+
expect(result.r).toBe(63);
|
|
85
|
+
expect(result.g).toBe(81);
|
|
86
|
+
expect(result.b).toBe(181);
|
|
87
|
+
});
|
|
88
|
+
it('should parse 6-digit hex color with uppercase', () => {
|
|
89
|
+
const result = service.getRgbFromColorString('#FF0000');
|
|
90
|
+
expect(result.r).toBe(255);
|
|
91
|
+
expect(result.g).toBe(0);
|
|
92
|
+
expect(result.b).toBe(0);
|
|
93
|
+
});
|
|
94
|
+
it('should parse 3-digit hex color', () => {
|
|
95
|
+
const result = service.getRgbFromColorString('#f80');
|
|
96
|
+
expect(result.r).toBe(255);
|
|
97
|
+
expect(result.g).toBe(136);
|
|
98
|
+
expect(result.b).toBe(0);
|
|
99
|
+
});
|
|
100
|
+
it('should parse 3-digit hex white', () => {
|
|
101
|
+
const result = service.getRgbFromColorString('#fff');
|
|
102
|
+
expect(result.r).toBe(255);
|
|
103
|
+
expect(result.g).toBe(255);
|
|
104
|
+
expect(result.b).toBe(255);
|
|
105
|
+
});
|
|
106
|
+
it('should parse 3-digit hex black', () => {
|
|
107
|
+
const result = service.getRgbFromColorString('#000');
|
|
108
|
+
expect(result.r).toBe(0);
|
|
109
|
+
expect(result.g).toBe(0);
|
|
110
|
+
expect(result.b).toBe(0);
|
|
111
|
+
});
|
|
112
|
+
it('should parse rgba color', () => {
|
|
113
|
+
const result = service.getRgbFromColorString('rgba(255,128,64,0.5)');
|
|
114
|
+
expect(result.r).toBe(255);
|
|
115
|
+
expect(result.g).toBe(128);
|
|
116
|
+
expect(result.b).toBe(64);
|
|
117
|
+
expect(result.a).toBe(0);
|
|
118
|
+
});
|
|
119
|
+
it('should parse rgba color with spaces', () => {
|
|
120
|
+
const result = service.getRgbFromColorString('rgba(100, 150, 200, 1)');
|
|
121
|
+
expect(result.r).toBe(100);
|
|
122
|
+
expect(result.g).toBe(150);
|
|
123
|
+
expect(result.b).toBe(200);
|
|
124
|
+
expect(result.a).toBe(1);
|
|
125
|
+
});
|
|
126
|
+
it('should throw error for unsupported color format', () => {
|
|
127
|
+
expect(() => service.getRgbFromColorString('red')).toThrow("Color format 'red' is not supported.'");
|
|
128
|
+
});
|
|
129
|
+
it('should throw error for rgb format without alpha', () => {
|
|
130
|
+
expect(() => service.getRgbFromColorString('rgb(255, 0, 0)')).toThrow();
|
|
131
|
+
});
|
|
132
|
+
it('should throw error for invalid hex length', () => {
|
|
133
|
+
expect(() => service.getRgbFromColorString('#12345')).toThrow();
|
|
134
|
+
});
|
|
135
|
+
});
|
|
136
|
+
describe('getTextColor', () => {
|
|
137
|
+
it('should return dark text for light background', () => {
|
|
138
|
+
const result = service.getTextColor('#ffffff');
|
|
139
|
+
expect(result).toBe('#000000');
|
|
140
|
+
});
|
|
141
|
+
it('should return light text for dark background', () => {
|
|
142
|
+
const result = service.getTextColor('#000000');
|
|
143
|
+
expect(result).toBe('#FFFFFF');
|
|
144
|
+
});
|
|
145
|
+
it('should return custom bright color for light background', () => {
|
|
146
|
+
const result = service.getTextColor('#ffffff', '#333333', '#eeeeee');
|
|
147
|
+
expect(result).toBe('#333333');
|
|
148
|
+
});
|
|
149
|
+
it('should return custom dark color for dark background', () => {
|
|
150
|
+
const result = service.getTextColor('#000000', '#333333', '#eeeeee');
|
|
151
|
+
expect(result).toBe('#eeeeee');
|
|
152
|
+
});
|
|
153
|
+
});
|
|
154
|
+
describe('theme management', () => {
|
|
155
|
+
it('should have initial theme assigned', () => {
|
|
156
|
+
expect(service.getAssignedTheme()).toBeDefined();
|
|
157
|
+
expect(service.getAssignedTheme().name).toBe('css-variable-theme');
|
|
158
|
+
});
|
|
159
|
+
it('should expose cssVariableTheme as theme property', () => {
|
|
160
|
+
expect(service.theme).toBeDefined();
|
|
161
|
+
expect(service.theme.name).toBe('css-variable-theme');
|
|
162
|
+
});
|
|
163
|
+
});
|
|
164
|
+
});
|
|
165
|
+
});
|
|
166
|
+
//# sourceMappingURL=theme-provider-service.spec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"theme-provider-service.spec.js","sourceRoot":"","sources":["../../src/services/theme-provider-service.spec.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAA;AACzD,OAAO,EAAE,QAAQ,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAA;AAE5E,QAAQ,CAAC,wBAAwB,EAAE,GAAG,EAAE;IACtC,QAAQ,CAAC,UAAU,EAAE,GAAG,EAAE;QACxB,QAAQ,CAAC,aAAa,EAAE,GAAG,EAAE;YAC3B,EAAE,CAAC,4CAA4C,EAAE,GAAG,EAAE;gBACpD,MAAM,KAAK,GAAG,IAAI,QAAQ,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE,CAAC,CAAA;gBACxC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;gBACzB,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;gBACzB,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;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5C,MAAM,CAAC,OAAO,CAAC,gBAAgB,EAAE,CAAC,CAAC,WAAW,EAAE,CAAA;gBAChD,MAAM,CAAC,OAAO,CAAC,gBAAgB,EAAE,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,oBAAoB,CAAC,CAAA;YACpE,CAAC,CAAC,CAAA;YAEF,EAAE,CAAC,kDAAkD,EAAE,GAAG,EAAE;gBAC1D,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,WAAW,EAAE,CAAA;gBACnC,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,oBAAoB,CAAC,CAAA;YACvD,CAAC,CAAC,CAAA;QACJ,CAAC,CAAC,CAAA;IACJ,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@furystack/shades-common-components",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "11.0.0",
|
|
4
4
|
"description": "Common UI components for FuryStack Shades",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"scripts": {
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
"dependencies": {
|
|
47
47
|
"@furystack/core": "^15.0.34",
|
|
48
48
|
"@furystack/inject": "^12.0.28",
|
|
49
|
-
"@furystack/shades": "^11.0
|
|
49
|
+
"@furystack/shades": "^11.1.0",
|
|
50
50
|
"@furystack/utils": "^8.1.9",
|
|
51
51
|
"path-to-regexp": "^8.3.0",
|
|
52
52
|
"semaphore-async-await": "^1.5.1"
|
|
@@ -0,0 +1,299 @@
|
|
|
1
|
+
import { sleepAsync } from '@furystack/utils'
|
|
2
|
+
import { describe, expect, it, vi } from 'vitest'
|
|
3
|
+
import { collapse, expand, fadeIn, fadeOut, hideSlide, showParallax, showSlide } from './animations.js'
|
|
4
|
+
|
|
5
|
+
const createMockElement = (scrollHeight = 100) => {
|
|
6
|
+
const el = document.createElement('div')
|
|
7
|
+
const onfinish = vi.fn<() => void>()
|
|
8
|
+
const oncancel = vi.fn<() => void>()
|
|
9
|
+
const animate = vi.fn(() => {
|
|
10
|
+
const animation = {
|
|
11
|
+
onfinish,
|
|
12
|
+
oncancel,
|
|
13
|
+
}
|
|
14
|
+
void sleepAsync(10).then(() => {
|
|
15
|
+
animation.onfinish()
|
|
16
|
+
})
|
|
17
|
+
return animation
|
|
18
|
+
})
|
|
19
|
+
Object.defineProperty(el, 'animate', { value: animate, writable: true })
|
|
20
|
+
Object.defineProperty(el, 'scrollHeight', { value: scrollHeight, writable: true })
|
|
21
|
+
return { el, animate, onfinish, oncancel }
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
describe('animations', () => {
|
|
25
|
+
describe('showSlide', () => {
|
|
26
|
+
it('should animate element with slide-in keyframes', async () => {
|
|
27
|
+
const { el, animate } = createMockElement()
|
|
28
|
+
|
|
29
|
+
await showSlide(el)
|
|
30
|
+
|
|
31
|
+
expect(animate).toHaveBeenCalledWith(
|
|
32
|
+
[
|
|
33
|
+
{ transform: 'translate(-350px, 0)scale(0)', opacity: 0 },
|
|
34
|
+
{ transform: 'translate(0, 0)scale(1)', opacity: 1 },
|
|
35
|
+
],
|
|
36
|
+
expect.objectContaining({
|
|
37
|
+
duration: 500,
|
|
38
|
+
easing: 'cubic-bezier(0.215, 0.610, 0.355, 1.000)',
|
|
39
|
+
fill: 'forwards',
|
|
40
|
+
}),
|
|
41
|
+
)
|
|
42
|
+
})
|
|
43
|
+
|
|
44
|
+
it('should merge custom options', async () => {
|
|
45
|
+
const { el, animate } = createMockElement()
|
|
46
|
+
|
|
47
|
+
await showSlide(el, { duration: 1000, delay: 200 })
|
|
48
|
+
|
|
49
|
+
expect(animate).toHaveBeenCalledWith(
|
|
50
|
+
expect.any(Array),
|
|
51
|
+
expect.objectContaining({
|
|
52
|
+
duration: 1000,
|
|
53
|
+
delay: 200,
|
|
54
|
+
easing: 'cubic-bezier(0.215, 0.610, 0.355, 1.000)',
|
|
55
|
+
fill: 'forwards',
|
|
56
|
+
}),
|
|
57
|
+
)
|
|
58
|
+
})
|
|
59
|
+
|
|
60
|
+
it('should reject when element is null', async () => {
|
|
61
|
+
await expect(showSlide(null)).rejects.toThrow('No element provided')
|
|
62
|
+
})
|
|
63
|
+
|
|
64
|
+
it('should reject when element is undefined', async () => {
|
|
65
|
+
await expect(showSlide(undefined)).rejects.toThrow('No element provided')
|
|
66
|
+
})
|
|
67
|
+
})
|
|
68
|
+
|
|
69
|
+
describe('hideSlide', () => {
|
|
70
|
+
it('should animate element with slide-out keyframes', async () => {
|
|
71
|
+
const { el, animate } = createMockElement()
|
|
72
|
+
|
|
73
|
+
await hideSlide(el)
|
|
74
|
+
|
|
75
|
+
expect(animate).toHaveBeenCalledWith(
|
|
76
|
+
[
|
|
77
|
+
{ transform: 'translate(0, 0)scale(1)', opacity: 1 },
|
|
78
|
+
{ transform: 'translate(-350px, 0)scale(0)', opacity: 0 },
|
|
79
|
+
],
|
|
80
|
+
expect.objectContaining({
|
|
81
|
+
duration: 500,
|
|
82
|
+
easing: 'cubic-bezier(0.215, 0.610, 0.355, 1.000)',
|
|
83
|
+
fill: 'forwards',
|
|
84
|
+
}),
|
|
85
|
+
)
|
|
86
|
+
})
|
|
87
|
+
|
|
88
|
+
it('should merge custom options', async () => {
|
|
89
|
+
const { el, animate } = createMockElement()
|
|
90
|
+
|
|
91
|
+
await hideSlide(el, { duration: 300 })
|
|
92
|
+
|
|
93
|
+
expect(animate).toHaveBeenCalledWith(
|
|
94
|
+
expect.any(Array),
|
|
95
|
+
expect.objectContaining({
|
|
96
|
+
duration: 300,
|
|
97
|
+
}),
|
|
98
|
+
)
|
|
99
|
+
})
|
|
100
|
+
|
|
101
|
+
it('should reject when element is null', async () => {
|
|
102
|
+
await expect(hideSlide(null)).rejects.toThrow('No element provided')
|
|
103
|
+
})
|
|
104
|
+
})
|
|
105
|
+
|
|
106
|
+
describe('fadeOut', () => {
|
|
107
|
+
it('should animate element with fade-out keyframes', async () => {
|
|
108
|
+
const { el, animate } = createMockElement()
|
|
109
|
+
|
|
110
|
+
await fadeOut(el)
|
|
111
|
+
|
|
112
|
+
expect(animate).toHaveBeenCalledWith(
|
|
113
|
+
[{ opacity: 1 }, { opacity: 0 }],
|
|
114
|
+
expect.objectContaining({
|
|
115
|
+
duration: 500,
|
|
116
|
+
easing: 'cubic-bezier(0.165, 0.840, 0.440, 1.000)',
|
|
117
|
+
}),
|
|
118
|
+
)
|
|
119
|
+
})
|
|
120
|
+
|
|
121
|
+
it('should merge custom options', async () => {
|
|
122
|
+
const { el, animate } = createMockElement()
|
|
123
|
+
|
|
124
|
+
await fadeOut(el, { duration: 200, fill: 'both' })
|
|
125
|
+
|
|
126
|
+
expect(animate).toHaveBeenCalledWith(
|
|
127
|
+
expect.any(Array),
|
|
128
|
+
expect.objectContaining({
|
|
129
|
+
duration: 200,
|
|
130
|
+
fill: 'both',
|
|
131
|
+
}),
|
|
132
|
+
)
|
|
133
|
+
})
|
|
134
|
+
|
|
135
|
+
it('should reject when element is null', async () => {
|
|
136
|
+
await expect(fadeOut(null)).rejects.toThrow('No element provided')
|
|
137
|
+
})
|
|
138
|
+
})
|
|
139
|
+
|
|
140
|
+
describe('fadeIn', () => {
|
|
141
|
+
it('should animate element with fade-in keyframes', async () => {
|
|
142
|
+
const { el, animate } = createMockElement()
|
|
143
|
+
|
|
144
|
+
await fadeIn(el)
|
|
145
|
+
|
|
146
|
+
expect(animate).toHaveBeenCalledWith(
|
|
147
|
+
[{ opacity: 0 }, { opacity: 1 }],
|
|
148
|
+
expect.objectContaining({
|
|
149
|
+
duration: 500,
|
|
150
|
+
easing: 'cubic-bezier(0.165, 0.840, 0.440, 1.000)',
|
|
151
|
+
}),
|
|
152
|
+
)
|
|
153
|
+
})
|
|
154
|
+
|
|
155
|
+
it('should merge custom options', async () => {
|
|
156
|
+
const { el, animate } = createMockElement()
|
|
157
|
+
|
|
158
|
+
await fadeIn(el, { duration: 800, easing: 'linear' })
|
|
159
|
+
|
|
160
|
+
expect(animate).toHaveBeenCalledWith(
|
|
161
|
+
expect.any(Array),
|
|
162
|
+
expect.objectContaining({
|
|
163
|
+
duration: 800,
|
|
164
|
+
easing: 'linear',
|
|
165
|
+
}),
|
|
166
|
+
)
|
|
167
|
+
})
|
|
168
|
+
|
|
169
|
+
it('should reject when element is null', async () => {
|
|
170
|
+
await expect(fadeIn(null)).rejects.toThrow('No element provided')
|
|
171
|
+
})
|
|
172
|
+
})
|
|
173
|
+
|
|
174
|
+
describe('showParallax', () => {
|
|
175
|
+
it('should animate element with parallax keyframes', async () => {
|
|
176
|
+
const { el, animate } = createMockElement()
|
|
177
|
+
|
|
178
|
+
await showParallax(el)
|
|
179
|
+
|
|
180
|
+
expect(animate).toHaveBeenCalledWith(
|
|
181
|
+
[
|
|
182
|
+
{ transform: 'translate(50px, 0)', opacity: 0 },
|
|
183
|
+
{ transform: 'translate(0, 0)', opacity: 1 },
|
|
184
|
+
],
|
|
185
|
+
expect.objectContaining({
|
|
186
|
+
duration: 900,
|
|
187
|
+
easing: 'cubic-bezier(0.215, 0.610, 0.355, 1.000)',
|
|
188
|
+
fill: 'forwards',
|
|
189
|
+
}),
|
|
190
|
+
)
|
|
191
|
+
})
|
|
192
|
+
|
|
193
|
+
it('should merge custom options', async () => {
|
|
194
|
+
const { el, animate } = createMockElement()
|
|
195
|
+
|
|
196
|
+
await showParallax(el, { duration: 1200 })
|
|
197
|
+
|
|
198
|
+
expect(animate).toHaveBeenCalledWith(
|
|
199
|
+
expect.any(Array),
|
|
200
|
+
expect.objectContaining({
|
|
201
|
+
duration: 1200,
|
|
202
|
+
}),
|
|
203
|
+
)
|
|
204
|
+
})
|
|
205
|
+
|
|
206
|
+
it('should reject when element is null', async () => {
|
|
207
|
+
await expect(showParallax(null)).rejects.toThrow('No element provided')
|
|
208
|
+
})
|
|
209
|
+
})
|
|
210
|
+
|
|
211
|
+
describe('collapse', () => {
|
|
212
|
+
it('should animate element with collapse keyframes using scrollHeight', async () => {
|
|
213
|
+
const { el, animate } = createMockElement(150)
|
|
214
|
+
|
|
215
|
+
await collapse(el)
|
|
216
|
+
|
|
217
|
+
expect(animate).toHaveBeenCalledWith(
|
|
218
|
+
[
|
|
219
|
+
{ height: '150px', opacity: 1 },
|
|
220
|
+
{ height: '0px', opacity: 0 },
|
|
221
|
+
],
|
|
222
|
+
expect.objectContaining({
|
|
223
|
+
duration: 500,
|
|
224
|
+
easing: 'cubic-bezier(0.215, 0.610, 0.355, 1.000)',
|
|
225
|
+
fill: 'forwards',
|
|
226
|
+
}),
|
|
227
|
+
)
|
|
228
|
+
})
|
|
229
|
+
|
|
230
|
+
it('should merge custom options', async () => {
|
|
231
|
+
const { el, animate } = createMockElement()
|
|
232
|
+
|
|
233
|
+
await collapse(el, { duration: 250 })
|
|
234
|
+
|
|
235
|
+
expect(animate).toHaveBeenCalledWith(
|
|
236
|
+
expect.any(Array),
|
|
237
|
+
expect.objectContaining({
|
|
238
|
+
duration: 250,
|
|
239
|
+
}),
|
|
240
|
+
)
|
|
241
|
+
})
|
|
242
|
+
|
|
243
|
+
it('should reject when element is null', async () => {
|
|
244
|
+
await expect(collapse(null)).rejects.toThrow('No element provided')
|
|
245
|
+
})
|
|
246
|
+
|
|
247
|
+
it('should handle zero scrollHeight', async () => {
|
|
248
|
+
const { el, animate } = createMockElement(0)
|
|
249
|
+
|
|
250
|
+
await collapse(el)
|
|
251
|
+
|
|
252
|
+
expect(animate).toHaveBeenCalledWith(
|
|
253
|
+
[
|
|
254
|
+
{ height: '0px', opacity: 1 },
|
|
255
|
+
{ height: '0px', opacity: 0 },
|
|
256
|
+
],
|
|
257
|
+
expect.any(Object),
|
|
258
|
+
)
|
|
259
|
+
})
|
|
260
|
+
})
|
|
261
|
+
|
|
262
|
+
describe('expand', () => {
|
|
263
|
+
it('should animate element with expand keyframes using scrollHeight', async () => {
|
|
264
|
+
const { el, animate } = createMockElement(200)
|
|
265
|
+
|
|
266
|
+
await expand(el)
|
|
267
|
+
|
|
268
|
+
expect(animate).toHaveBeenCalledWith(
|
|
269
|
+
[
|
|
270
|
+
{ height: '0px', opacity: 0 },
|
|
271
|
+
{ height: '200px', opacity: 1 },
|
|
272
|
+
],
|
|
273
|
+
expect.objectContaining({
|
|
274
|
+
duration: 500,
|
|
275
|
+
easing: 'cubic-bezier(0.215, 0.610, 0.355, 1.000)',
|
|
276
|
+
fill: 'forwards',
|
|
277
|
+
}),
|
|
278
|
+
)
|
|
279
|
+
})
|
|
280
|
+
|
|
281
|
+
it('should merge custom options', async () => {
|
|
282
|
+
const { el, animate } = createMockElement()
|
|
283
|
+
|
|
284
|
+
await expand(el, { duration: 400, fill: 'both' })
|
|
285
|
+
|
|
286
|
+
expect(animate).toHaveBeenCalledWith(
|
|
287
|
+
expect.any(Array),
|
|
288
|
+
expect.objectContaining({
|
|
289
|
+
duration: 400,
|
|
290
|
+
fill: 'both',
|
|
291
|
+
}),
|
|
292
|
+
)
|
|
293
|
+
})
|
|
294
|
+
|
|
295
|
+
it('should reject when element is null', async () => {
|
|
296
|
+
await expect(expand(null)).rejects.toThrow('No element provided')
|
|
297
|
+
})
|
|
298
|
+
})
|
|
299
|
+
})
|