@firestitch/style 18.0.71 → 18.1.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.
@@ -0,0 +1,79 @@
1
+ import { OnDestroy } from '@angular/core';
2
+ import * as i0 from "@angular/core";
3
+ export type FsColorSchemeType = 'light' | 'dark' | 'system';
4
+ export type FsResolvedColorScheme = 'light' | 'dark';
5
+ /**
6
+ * The one switch behind every light/dark decision in every @firestitch package.
7
+ *
8
+ * WHY THIS IS ONE PROPERTY AND NOT A THEME CLASS. Packages express their two
9
+ * appearances with `light-dark()` in CSS, which picks off the `color-scheme`
10
+ * property. Setting it once on <html> re-paints every package at once -- chips,
11
+ * fields, dividers, menus -- with no class to agree on, no component to notify
12
+ * and no stylesheet to reload. Anything that reads the --fs-* tokens follows
13
+ * automatically, including components compiled into other packages.
14
+ *
15
+ * DECLARED, NOT DETECTED. `prefers-color-scheme` reports the DEVICE, and an app
16
+ * whose user chose Light on a dark phone would otherwise fight its own setting.
17
+ * So the media query is read for exactly one purpose -- reporting what "system"
18
+ * currently resolves to, via `resolvedColorScheme` -- and never to decide the
19
+ * setting itself. Choosing is the caller's job; this only applies the choice.
20
+ *
21
+ * NOTHING IS PERSISTED. The setting lives for the lifetime of the service, so a
22
+ * reload starts from the default. An app that wants the choice remembered stores
23
+ * it wherever it keeps its other preferences and calls `set()` on startup --
24
+ * which keeps this free of any opinion about storage, and keeps a package from
25
+ * writing to a key the application did not choose.
26
+ */
27
+ export declare class FsColorScheme implements OnDestroy {
28
+ private _document;
29
+ private _colorScheme;
30
+ private _systemDark;
31
+ private _mediaQuery;
32
+ private _mediaQueryListener;
33
+ constructor();
34
+ /**
35
+ * What was asked for -- 'light', 'dark' or 'system'. For what "system" is
36
+ * currently showing, read `resolved()`.
37
+ */
38
+ get colorScheme(): import("@angular/core").Signal<FsColorSchemeType>;
39
+ /**
40
+ * The appearance actually on screen, with 'system' resolved to what the
41
+ * operating system asks for. Tracks the OS live while set to 'system', so a
42
+ * caller rendering an icon or a label for the current appearance stays right
43
+ * without polling.
44
+ *
45
+ * A computed rather than a method so it can be handed to a template or an
46
+ * effect on its own -- `resolved` passed as a bare reference keeps working,
47
+ * where an unbound method would lose `this`.
48
+ */
49
+ resolved: import("@angular/core").Signal<FsResolvedColorScheme>;
50
+ set(colorScheme: FsColorSchemeType): void;
51
+ light(): void;
52
+ dark(): void;
53
+ system(): void;
54
+ /**
55
+ * Flips between light and dark. From 'system' it moves to whichever appearance
56
+ * is NOT showing, so the control always does what it says rather than landing
57
+ * on the appearance already on screen.
58
+ */
59
+ toggle(): void;
60
+ ngOnDestroy(): void;
61
+ /**
62
+ * Writes the property <html> rather than <body>: `color-scheme` also tells the
63
+ * browser what to paint the canvas, the scrollbars and the form controls it
64
+ * renders itself, and those follow the root element.
65
+ */
66
+ private _apply;
67
+ /**
68
+ * Kept current at all times, not only while set to 'system', so that switching
69
+ * to 'system' reports the right appearance immediately instead of waiting for
70
+ * the OS to next change.
71
+ *
72
+ * Guarded because matchMedia is absent when rendering on the server, where
73
+ * there is no device to ask.
74
+ */
75
+ private _watchSystem;
76
+ private _unwatchSystem;
77
+ static ɵfac: i0.ɵɵFactoryDeclaration<FsColorScheme, never>;
78
+ static ɵprov: i0.ɵɵInjectableDeclaration<FsColorScheme>;
79
+ }
@@ -0,0 +1,140 @@
1
+ import { DOCUMENT } from '@angular/common';
2
+ import { Injectable, computed, inject, signal } from '@angular/core';
3
+ import * as i0 from "@angular/core";
4
+ /**
5
+ * The `color-scheme` value written for each setting. "system" is `light dark`:
6
+ * NOT a third appearance, but both offered to the browser so it resolves the one
7
+ * the operating system asks for.
8
+ */
9
+ const COLOR_SCHEME_VALUES = {
10
+ light: 'light',
11
+ dark: 'dark',
12
+ system: 'light dark',
13
+ };
14
+ const DARK_QUERY = '(prefers-color-scheme: dark)';
15
+ /**
16
+ * The one switch behind every light/dark decision in every @firestitch package.
17
+ *
18
+ * WHY THIS IS ONE PROPERTY AND NOT A THEME CLASS. Packages express their two
19
+ * appearances with `light-dark()` in CSS, which picks off the `color-scheme`
20
+ * property. Setting it once on <html> re-paints every package at once -- chips,
21
+ * fields, dividers, menus -- with no class to agree on, no component to notify
22
+ * and no stylesheet to reload. Anything that reads the --fs-* tokens follows
23
+ * automatically, including components compiled into other packages.
24
+ *
25
+ * DECLARED, NOT DETECTED. `prefers-color-scheme` reports the DEVICE, and an app
26
+ * whose user chose Light on a dark phone would otherwise fight its own setting.
27
+ * So the media query is read for exactly one purpose -- reporting what "system"
28
+ * currently resolves to, via `resolvedColorScheme` -- and never to decide the
29
+ * setting itself. Choosing is the caller's job; this only applies the choice.
30
+ *
31
+ * NOTHING IS PERSISTED. The setting lives for the lifetime of the service, so a
32
+ * reload starts from the default. An app that wants the choice remembered stores
33
+ * it wherever it keeps its other preferences and calls `set()` on startup --
34
+ * which keeps this free of any opinion about storage, and keeps a package from
35
+ * writing to a key the application did not choose.
36
+ */
37
+ export class FsColorScheme {
38
+ _document = inject(DOCUMENT);
39
+ _colorScheme = signal('system');
40
+ _systemDark = signal(false);
41
+ _mediaQuery;
42
+ _mediaQueryListener;
43
+ constructor() {
44
+ this._watchSystem();
45
+ }
46
+ /**
47
+ * What was asked for -- 'light', 'dark' or 'system'. For what "system" is
48
+ * currently showing, read `resolved()`.
49
+ */
50
+ get colorScheme() {
51
+ return this._colorScheme.asReadonly();
52
+ }
53
+ /**
54
+ * The appearance actually on screen, with 'system' resolved to what the
55
+ * operating system asks for. Tracks the OS live while set to 'system', so a
56
+ * caller rendering an icon or a label for the current appearance stays right
57
+ * without polling.
58
+ *
59
+ * A computed rather than a method so it can be handed to a template or an
60
+ * effect on its own -- `resolved` passed as a bare reference keeps working,
61
+ * where an unbound method would lose `this`.
62
+ */
63
+ resolved = computed(() => {
64
+ const colorScheme = this._colorScheme();
65
+ if (colorScheme === 'system') {
66
+ return this._systemDark() ? 'dark' : 'light';
67
+ }
68
+ return colorScheme;
69
+ });
70
+ set(colorScheme) {
71
+ this._colorScheme.set(colorScheme);
72
+ this._apply();
73
+ }
74
+ light() {
75
+ this.set('light');
76
+ }
77
+ dark() {
78
+ this.set('dark');
79
+ }
80
+ system() {
81
+ this.set('system');
82
+ }
83
+ /**
84
+ * Flips between light and dark. From 'system' it moves to whichever appearance
85
+ * is NOT showing, so the control always does what it says rather than landing
86
+ * on the appearance already on screen.
87
+ */
88
+ toggle() {
89
+ this.set(this.resolved() === 'dark' ? 'light' : 'dark');
90
+ }
91
+ ngOnDestroy() {
92
+ this._unwatchSystem();
93
+ }
94
+ /**
95
+ * Writes the property <html> rather than <body>: `color-scheme` also tells the
96
+ * browser what to paint the canvas, the scrollbars and the form controls it
97
+ * renders itself, and those follow the root element.
98
+ */
99
+ _apply() {
100
+ const element = this._document?.documentElement;
101
+ if (!element) {
102
+ return;
103
+ }
104
+ element.style.setProperty('color-scheme', COLOR_SCHEME_VALUES[this._colorScheme()]);
105
+ }
106
+ /**
107
+ * Kept current at all times, not only while set to 'system', so that switching
108
+ * to 'system' reports the right appearance immediately instead of waiting for
109
+ * the OS to next change.
110
+ *
111
+ * Guarded because matchMedia is absent when rendering on the server, where
112
+ * there is no device to ask.
113
+ */
114
+ _watchSystem() {
115
+ const view = this._document?.defaultView;
116
+ if (!view?.matchMedia) {
117
+ return;
118
+ }
119
+ this._mediaQuery = view.matchMedia(DARK_QUERY);
120
+ this._systemDark.set(this._mediaQuery.matches);
121
+ this._mediaQueryListener = (event) => {
122
+ this._systemDark.set(event.matches);
123
+ };
124
+ this._mediaQuery.addEventListener('change', this._mediaQueryListener);
125
+ }
126
+ _unwatchSystem() {
127
+ if (this._mediaQuery && this._mediaQueryListener) {
128
+ this._mediaQuery.removeEventListener('change', this._mediaQueryListener);
129
+ this._mediaQuery = null;
130
+ this._mediaQueryListener = null;
131
+ }
132
+ }
133
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.7", ngImport: i0, type: FsColorScheme, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
134
+ static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.2.7", ngImport: i0, type: FsColorScheme, providedIn: 'root' });
135
+ }
136
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.7", ngImport: i0, type: FsColorScheme, decorators: [{
137
+ type: Injectable,
138
+ args: [{ providedIn: 'root' }]
139
+ }], ctorParameters: () => [] });
140
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY29sb3Itc2NoZW1lLnNlcnZpY2UuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi9zcmMvYXBwL3NlcnZpY2VzL2NvbG9yLXNjaGVtZS5zZXJ2aWNlLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sRUFBRSxRQUFRLEVBQUUsTUFBTSxpQkFBaUIsQ0FBQztBQUMzQyxPQUFPLEVBQUUsVUFBVSxFQUFhLFFBQVEsRUFBRSxNQUFNLEVBQUUsTUFBTSxFQUFFLE1BQU0sZUFBZSxDQUFDOztBQU1oRjs7OztHQUlHO0FBQ0gsTUFBTSxtQkFBbUIsR0FBc0M7SUFDN0QsS0FBSyxFQUFFLE9BQU87SUFDZCxJQUFJLEVBQUUsTUFBTTtJQUNaLE1BQU0sRUFBRSxZQUFZO0NBQ3JCLENBQUM7QUFFRixNQUFNLFVBQVUsR0FBRyw4QkFBOEIsQ0FBQztBQUVsRDs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7O0dBcUJHO0FBRUgsTUFBTSxPQUFPLGFBQWE7SUFFaEIsU0FBUyxHQUFHLE1BQU0sQ0FBQyxRQUFRLENBQUMsQ0FBQztJQUU3QixZQUFZLEdBQUcsTUFBTSxDQUFvQixRQUFRLENBQUMsQ0FBQztJQUNuRCxXQUFXLEdBQUcsTUFBTSxDQUFVLEtBQUssQ0FBQyxDQUFDO0lBRXJDLFdBQVcsQ0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1ZXJ5LmFkZEV2ZW50TGlzdGVuZXIoJ2NoYW5nZScsIHRoaXMuX21lZGlhUXVlcnlMaXN0ZW5lcik7XG4gIH1cblxuICBwcml2YXRlIF91bndhdGNoU3lzdGVtKCk6IHZvaWQge1xuICAgIGlmICh0aGlzLl9tZWRpYVF1ZXJ5ICYmIHRoaXMuX21lZGlhUXVlcnlMaXN0ZW5lcikge1xuICAgICAgdGhpcy5fbWVkaWFRdWVyeS5yZW1vdmVFdmVudExpc3RlbmVyKCdjaGFuZ2UnLCB0aGlzLl9tZWRpYVF1ZXJ5TGlzdGVuZXIpO1xuICAgICAgdGhpcy5fbWVkaWFRdWVyeSA9IG51bGw7XG4gICAgICB0aGlzLl9tZWRpYVF1ZXJ5TGlzdGVuZXIgPSBudWxsO1xuICAgIH1cbiAgfVxuXG59XG4iXX0=
@@ -1,6 +1,7 @@
1
1
  /**
2
- * @firestitch/style - Shared styles and variables.
2
+ * @firestitch/style - Shared styles, tokens and the colour scheme switch.
3
3
  * Import SCSS from '@firestitch/style/styles' or include in angular.json styles.
4
4
  */
5
- export const STYLE_VERSION = '18.0.54';
6
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicHVibGljX2FwaS5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9wdWJsaWNfYXBpLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBOzs7R0FHRztBQUNILE1BQU0sQ0FBQyxNQUFNLGFBQWEsR0FBRyxTQUFTLENBQUMiLCJzb3VyY2VzQ29udGVudCI6WyIvKipcbiAqIEBmaXJlc3RpdGNoL3N0eWxlIC0gU2hhcmVkIHN0eWxlcyBhbmQgdmFyaWFibGVzLlxuICogSW1wb3J0IFNDU1MgZnJvbSAnQGZpcmVzdGl0Y2gvc3R5bGUvc3R5bGVzJyBvciBpbmNsdWRlIGluIGFuZ3VsYXIuanNvbiBzdHlsZXMuXG4gKi9cbmV4cG9ydCBjb25zdCBTVFlMRV9WRVJTSU9OID0gJzE4LjAuNTQnO1xuIl19
5
+ // Services
6
+ export { FsColorScheme } from './app/services/color-scheme.service';
7
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicHVibGljX2FwaS5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9wdWJsaWNfYXBpLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBOzs7R0FHRztBQUVILFdBQVc7QUFDWCxPQUFPLEVBQUUsYUFBYSxFQUFFLE1BQU0scUNBQXFDLENBQUMiLCJzb3VyY2VzQ29udGVudCI6WyIvKipcbiAqIEBmaXJlc3RpdGNoL3N0eWxlIC0gU2hhcmVkIHN0eWxlcywgdG9rZW5zIGFuZCB0aGUgY29sb3VyIHNjaGVtZSBzd2l0Y2guXG4gKiBJbXBvcnQgU0NTUyBmcm9tICdAZmlyZXN0aXRjaC9zdHlsZS9zdHlsZXMnIG9yIGluY2x1ZGUgaW4gYW5ndWxhci5qc29uIHN0eWxlcy5cbiAqL1xuXG4vLyBTZXJ2aWNlc1xuZXhwb3J0IHsgRnNDb2xvclNjaGVtZSB9IGZyb20gJy4vYXBwL3NlcnZpY2VzL2NvbG9yLXNjaGVtZS5zZXJ2aWNlJztcblxuLy8gVHlwZXNcbmV4cG9ydCB0eXBlIHsgRnNDb2xvclNjaGVtZVR5cGUsIEZzUmVzb2x2ZWRDb2xvclNjaGVtZSB9IGZyb20gJy4vYXBwL3NlcnZpY2VzL2NvbG9yLXNjaGVtZS5zZXJ2aWNlJztcbiJdfQ==
@@ -1,12 +1,153 @@
1
+ import { DOCUMENT } from '@angular/common';
2
+ import * as i0 from '@angular/core';
3
+ import { inject, signal, computed, Injectable } from '@angular/core';
4
+
5
+ /**
6
+ * The `color-scheme` value written for each setting. "system" is `light dark`:
7
+ * NOT a third appearance, but both offered to the browser so it resolves the one
8
+ * the operating system asks for.
9
+ */
10
+ const COLOR_SCHEME_VALUES = {
11
+ light: 'light',
12
+ dark: 'dark',
13
+ system: 'light dark',
14
+ };
15
+ const DARK_QUERY = '(prefers-color-scheme: dark)';
16
+ /**
17
+ * The one switch behind every light/dark decision in every @firestitch package.
18
+ *
19
+ * WHY THIS IS ONE PROPERTY AND NOT A THEME CLASS. Packages express their two
20
+ * appearances with `light-dark()` in CSS, which picks off the `color-scheme`
21
+ * property. Setting it once on <html> re-paints every package at once -- chips,
22
+ * fields, dividers, menus -- with no class to agree on, no component to notify
23
+ * and no stylesheet to reload. Anything that reads the --fs-* tokens follows
24
+ * automatically, including components compiled into other packages.
25
+ *
26
+ * DECLARED, NOT DETECTED. `prefers-color-scheme` reports the DEVICE, and an app
27
+ * whose user chose Light on a dark phone would otherwise fight its own setting.
28
+ * So the media query is read for exactly one purpose -- reporting what "system"
29
+ * currently resolves to, via `resolvedColorScheme` -- and never to decide the
30
+ * setting itself. Choosing is the caller's job; this only applies the choice.
31
+ *
32
+ * NOTHING IS PERSISTED. The setting lives for the lifetime of the service, so a
33
+ * reload starts from the default. An app that wants the choice remembered stores
34
+ * it wherever it keeps its other preferences and calls `set()` on startup --
35
+ * which keeps this free of any opinion about storage, and keeps a package from
36
+ * writing to a key the application did not choose.
37
+ */
38
+ class FsColorScheme {
39
+ _document = inject(DOCUMENT);
40
+ _colorScheme = signal('system');
41
+ _systemDark = signal(false);
42
+ _mediaQuery;
43
+ _mediaQueryListener;
44
+ constructor() {
45
+ this._watchSystem();
46
+ }
47
+ /**
48
+ * What was asked for -- 'light', 'dark' or 'system'. For what "system" is
49
+ * currently showing, read `resolved()`.
50
+ */
51
+ get colorScheme() {
52
+ return this._colorScheme.asReadonly();
53
+ }
54
+ /**
55
+ * The appearance actually on screen, with 'system' resolved to what the
56
+ * operating system asks for. Tracks the OS live while set to 'system', so a
57
+ * caller rendering an icon or a label for the current appearance stays right
58
+ * without polling.
59
+ *
60
+ * A computed rather than a method so it can be handed to a template or an
61
+ * effect on its own -- `resolved` passed as a bare reference keeps working,
62
+ * where an unbound method would lose `this`.
63
+ */
64
+ resolved = computed(() => {
65
+ const colorScheme = this._colorScheme();
66
+ if (colorScheme === 'system') {
67
+ return this._systemDark() ? 'dark' : 'light';
68
+ }
69
+ return colorScheme;
70
+ });
71
+ set(colorScheme) {
72
+ this._colorScheme.set(colorScheme);
73
+ this._apply();
74
+ }
75
+ light() {
76
+ this.set('light');
77
+ }
78
+ dark() {
79
+ this.set('dark');
80
+ }
81
+ system() {
82
+ this.set('system');
83
+ }
84
+ /**
85
+ * Flips between light and dark. From 'system' it moves to whichever appearance
86
+ * is NOT showing, so the control always does what it says rather than landing
87
+ * on the appearance already on screen.
88
+ */
89
+ toggle() {
90
+ this.set(this.resolved() === 'dark' ? 'light' : 'dark');
91
+ }
92
+ ngOnDestroy() {
93
+ this._unwatchSystem();
94
+ }
95
+ /**
96
+ * Writes the property <html> rather than <body>: `color-scheme` also tells the
97
+ * browser what to paint the canvas, the scrollbars and the form controls it
98
+ * renders itself, and those follow the root element.
99
+ */
100
+ _apply() {
101
+ const element = this._document?.documentElement;
102
+ if (!element) {
103
+ return;
104
+ }
105
+ element.style.setProperty('color-scheme', COLOR_SCHEME_VALUES[this._colorScheme()]);
106
+ }
107
+ /**
108
+ * Kept current at all times, not only while set to 'system', so that switching
109
+ * to 'system' reports the right appearance immediately instead of waiting for
110
+ * the OS to next change.
111
+ *
112
+ * Guarded because matchMedia is absent when rendering on the server, where
113
+ * there is no device to ask.
114
+ */
115
+ _watchSystem() {
116
+ const view = this._document?.defaultView;
117
+ if (!view?.matchMedia) {
118
+ return;
119
+ }
120
+ this._mediaQuery = view.matchMedia(DARK_QUERY);
121
+ this._systemDark.set(this._mediaQuery.matches);
122
+ this._mediaQueryListener = (event) => {
123
+ this._systemDark.set(event.matches);
124
+ };
125
+ this._mediaQuery.addEventListener('change', this._mediaQueryListener);
126
+ }
127
+ _unwatchSystem() {
128
+ if (this._mediaQuery && this._mediaQueryListener) {
129
+ this._mediaQuery.removeEventListener('change', this._mediaQueryListener);
130
+ this._mediaQuery = null;
131
+ this._mediaQueryListener = null;
132
+ }
133
+ }
134
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.7", ngImport: i0, type: FsColorScheme, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
135
+ static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.2.7", ngImport: i0, type: FsColorScheme, providedIn: 'root' });
136
+ }
137
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.7", ngImport: i0, type: FsColorScheme, decorators: [{
138
+ type: Injectable,
139
+ args: [{ providedIn: 'root' }]
140
+ }], ctorParameters: () => [] });
141
+
1
142
  /**
2
- * @firestitch/style - Shared styles and variables.
143
+ * @firestitch/style - Shared styles, tokens and the colour scheme switch.
3
144
  * Import SCSS from '@firestitch/style/styles' or include in angular.json styles.
4
145
  */
5
- const STYLE_VERSION = '18.0.54';
146
+ // Services
6
147
 
7
148
  /**
8
149
  * Generated bundle index. Do not edit.
9
150
  */
10
151
 
11
- export { STYLE_VERSION };
152
+ export { FsColorScheme };
12
153
  //# sourceMappingURL=firestitch-style.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"firestitch-style.mjs","sources":["../../src/public_api.ts","../../src/firestitch-style.ts"],"sourcesContent":["/**\n * @firestitch/style - Shared styles and variables.\n * Import SCSS from '@firestitch/style/styles' or include in angular.json styles.\n */\nexport const STYLE_VERSION = '18.0.54';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public_api';\n"],"names":[],"mappings":"AAAA;;;AAGG;AACI,MAAM,aAAa,GAAG;;ACJ7B;;AAEG;;;;"}
1
+ {"version":3,"file":"firestitch-style.mjs","sources":["../../src/app/services/color-scheme.service.ts","../../src/public_api.ts","../../src/firestitch-style.ts"],"sourcesContent":["import { DOCUMENT } from '@angular/common';\nimport { Injectable, OnDestroy, computed, inject, signal } from '@angular/core';\n\n\nexport type FsColorSchemeType = 'light' | 'dark' | 'system';\nexport type FsResolvedColorScheme = 'light' | 'dark';\n\n/**\n * The `color-scheme` value written for each setting. \"system\" is `light dark`:\n * NOT a third appearance, but both offered to the browser so it resolves the one\n * the operating system asks for.\n */\nconst COLOR_SCHEME_VALUES: Record<FsColorSchemeType, string> = {\n light: 'light',\n dark: 'dark',\n system: 'light dark',\n};\n\nconst DARK_QUERY = '(prefers-color-scheme: dark)';\n\n/**\n * The one switch behind every light/dark decision in every @firestitch package.\n *\n * WHY THIS IS ONE PROPERTY AND NOT A THEME CLASS. Packages express their two\n * appearances with `light-dark()` in CSS, which picks off the `color-scheme`\n * property. Setting it once on <html> re-paints every package at once -- chips,\n * fields, dividers, menus -- with no class to agree on, no component to notify\n * and no stylesheet to reload. Anything that reads the --fs-* tokens follows\n * automatically, including components compiled into other packages.\n *\n * DECLARED, NOT DETECTED. `prefers-color-scheme` reports the DEVICE, and an app\n * whose user chose Light on a dark phone would otherwise fight its own setting.\n * So the media query is read for exactly one purpose -- reporting what \"system\"\n * currently resolves to, via `resolvedColorScheme` -- and never to decide the\n * setting itself. Choosing is the caller's job; this only applies the choice.\n *\n * NOTHING IS PERSISTED. The setting lives for the lifetime of the service, so a\n * reload starts from the default. An app that wants the choice remembered stores\n * it wherever it keeps its other preferences and calls `set()` on startup --\n * which keeps this free of any opinion about storage, and keeps a package from\n * writing to a key the application did not choose.\n */\n@Injectable({ providedIn: 'root' })\nexport class FsColorScheme implements OnDestroy {\n\n private _document = inject(DOCUMENT);\n\n private _colorScheme = signal<FsColorSchemeType>('system');\n private _systemDark = signal<boolean>(false);\n\n private _mediaQuery: MediaQueryList;\n private _mediaQueryListener: (event: MediaQueryListEvent) => void;\n\n constructor() {\n this._watchSystem();\n }\n\n /**\n * What was asked for -- 'light', 'dark' or 'system'. For what \"system\" is\n * currently showing, read `resolved()`.\n */\n public get colorScheme() {\n return this._colorScheme.asReadonly();\n }\n\n /**\n * The appearance actually on screen, with 'system' resolved to what the\n * operating system asks for. Tracks the OS live while set to 'system', so a\n * caller rendering an icon or a label for the current appearance stays right\n * without polling.\n *\n * A computed rather than a method so it can be handed to a template or an\n * effect on its own -- `resolved` passed as a bare reference keeps working,\n * where an unbound method would lose `this`.\n */\n public resolved = computed<FsResolvedColorScheme>(() => {\n const colorScheme = this._colorScheme();\n\n if (colorScheme === 'system') {\n return this._systemDark() ? 'dark' : 'light';\n }\n\n return colorScheme;\n });\n\n public set(colorScheme: FsColorSchemeType): void {\n this._colorScheme.set(colorScheme);\n this._apply();\n }\n\n public light(): void {\n this.set('light');\n }\n\n public dark(): void {\n this.set('dark');\n }\n\n public system(): void {\n this.set('system');\n }\n\n /**\n * Flips between light and dark. From 'system' it moves to whichever appearance\n * is NOT showing, so the control always does what it says rather than landing\n * on the appearance already on screen.\n */\n public toggle(): void {\n this.set(this.resolved() === 'dark' ? 'light' : 'dark');\n }\n\n public ngOnDestroy(): void {\n this._unwatchSystem();\n }\n\n /**\n * Writes the property <html> rather than <body>: `color-scheme` also tells the\n * browser what to paint the canvas, the scrollbars and the form controls it\n * renders itself, and those follow the root element.\n */\n private _apply(): void {\n const element = this._document?.documentElement;\n\n if (!element) {\n return;\n }\n\n element.style.setProperty('color-scheme', COLOR_SCHEME_VALUES[this._colorScheme()]);\n }\n\n /**\n * Kept current at all times, not only while set to 'system', so that switching\n * to 'system' reports the right appearance immediately instead of waiting for\n * the OS to next change.\n *\n * Guarded because matchMedia is absent when rendering on the server, where\n * there is no device to ask.\n */\n private _watchSystem(): void {\n const view = this._document?.defaultView;\n\n if (!view?.matchMedia) {\n return;\n }\n\n this._mediaQuery = view.matchMedia(DARK_QUERY);\n this._systemDark.set(this._mediaQuery.matches);\n\n this._mediaQueryListener = (event: MediaQueryListEvent) => {\n this._systemDark.set(event.matches);\n };\n\n this._mediaQuery.addEventListener('change', this._mediaQueryListener);\n }\n\n private _unwatchSystem(): void {\n if (this._mediaQuery && this._mediaQueryListener) {\n this._mediaQuery.removeEventListener('change', this._mediaQueryListener);\n this._mediaQuery = null;\n this._mediaQueryListener = null;\n }\n }\n\n}\n","/**\n * @firestitch/style - Shared styles, tokens and the colour scheme switch.\n * Import SCSS from '@firestitch/style/styles' or include in angular.json styles.\n */\n\n// Services\nexport { FsColorScheme } from './app/services/color-scheme.service';\n\n// Types\nexport type { FsColorSchemeType, FsResolvedColorScheme } from './app/services/color-scheme.service';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public_api';\n"],"names":[],"mappings":";;;;AAOA;;;;AAIG;AACH,MAAM,mBAAmB,GAAsC;AAC7D,IAAA,KAAK,EAAE,OAAO;AACd,IAAA,IAAI,EAAE,MAAM;AACZ,IAAA,MAAM,EAAE,YAAY;CACrB,CAAC;AAEF,MAAM,UAAU,GAAG,8BAA8B,CAAC;AAElD;;;;;;;;;;;;;;;;;;;;;AAqBG;MAEU,aAAa,CAAA;AAEhB,IAAA,SAAS,GAAG,MAAM,CAAC,QAAQ,CAAC,CAAC;AAE7B,IAAA,YAAY,GAAG,MAAM,CAAoB,QAAQ,CAAC,CAAC;AACnD,IAAA,WAAW,GAAG,MAAM,CAAU,KAAK,CAAC,CAAC;AAErC,IAAA,WAAW,CAAiB;AAC5B,IAAA,mBAAmB,CAAuC;AAElE,IAAA,WAAA,GAAA;QACE,IAAI,CAAC,YAAY,EAAE,CAAC;KACrB;AAED;;;AAGG;AACH,IAAA,IAAW,WAAW,GAAA;AACpB,QAAA,OAAO,IAAI,CAAC,YAAY,CAAC,UAAU,EAAE,CAAC;KACvC;AAED;;;;;;;;;AASG;AACI,IAAA,QAAQ,GAAG,QAAQ,CAAwB,MAAK;AACrD,QAAA,MAAM,WAAW,GAAG,IAAI,CAAC,YAAY,EAAE,CAAC;AAExC,QAAA,IAAI,WAAW,KAAK,QAAQ,EAAE;AAC5B,YAAA,OAAO,IAAI,CAAC,WAAW,EAAE,GAAG,MAAM,GAAG,OAAO,CAAC;SAC9C;AAED,QAAA,OAAO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AC,mBAAmB,GAAG,CAAC,KAA0B,KAAI;YACxD,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;AACtC,SAAC,CAAC;QAEF,IAAI,CAAC,WAAW,CAAC,gBAAgB,CAAC,QAAQ,EAAE,IAAI,CAAC,mBAAmB,CAAC,CAAC;KACvE;IAEO,cAAc,GAAA;QACpB,IAAI,IAAI,CAAC,WAAW,IAAI,IAAI,CAAC,mBAAmB,EAAE;YAChD,IAAI,CAAC,WAAW,CAAC,mBAAmB,CAAC,QAAQ,EAAE,IAAI,CAAC,mBAAmB,CAAC,CAAC;AACzE,YAAA,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC;AACxB,YAAA,IAAI,CAAC,mBAAmB,GAAG,IAAI,CAAC;SACjC;KACF;uGAtHU,aAAa,EAAA,IAAA,EAAA,EAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,UAAA,EAAA,CAAA,CAAA;AAAb,IAAA,OAAA,KAAA,GAAA,EAAA,CAAA,qBAAA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,QAAA,EAAA,QAAA,EAAA,EAAA,EAAA,IAAA,EAAA,aAAa,cADA,MAAM,EAAA,CAAA,CAAA;;2FACnB,aAAa,EAAA,UAAA,EAAA,CAAA;kBADzB,UAAU;mBAAC,EAAE,UAAU,EAAE,MAAM,EAAE,CAAA;;;AC1ClC;;;AAGG;AAEH;;ACLA;;AAEG;;;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@firestitch/style",
3
- "version": "18.0.71",
3
+ "version": "18.1.0",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/Firestitch/ngx-style"
package/public_api.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  /**
2
- * @firestitch/style - Shared styles and variables.
2
+ * @firestitch/style - Shared styles, tokens and the colour scheme switch.
3
3
  * Import SCSS from '@firestitch/style/styles' or include in angular.json styles.
4
4
  */
5
- export declare const STYLE_VERSION = "18.0.54";
5
+ export { FsColorScheme } from './app/services/color-scheme.service';
6
+ export type { FsColorSchemeType, FsResolvedColorScheme } from './app/services/color-scheme.service';
package/styles/_core.scss CHANGED
@@ -5,6 +5,7 @@
5
5
  @use 'overflow';
6
6
  @use 'typography';
7
7
  @use 'form-field';
8
+ @use 'form-controls';
8
9
  @use 'material';
9
10
 
10
11
 
@@ -17,6 +18,10 @@
17
18
  @include tokens.tokens();
18
19
  @include headings.headings();
19
20
  @include form-field.form-field();
21
+ // The selection controls - checkbox, radio, slide toggle, slider, chip. After
22
+ // form-field because it answers the same questions for the same family of
23
+ // inputs, and before material so an app's own Material overrides still win.
24
+ @include form-controls.form-controls();
20
25
  @include helpers.helpers();
21
26
  @include layout.layout();
22
27
  @include overflow.overflow();
@@ -0,0 +1,171 @@
1
+ // =============================================================================
2
+ // THE SELECTION CONTROLS
3
+ // =============================================================================
4
+ // Checkbox, radio, slide toggle, slider and chip.
5
+ //
6
+ // WHY THIS FILE EXISTS - Ray 2026-09-14. Material themes these five entirely
7
+ // through its own tokens, and an app on an M2 theme gets the LIGHT theme's
8
+ // values for all of them:
9
+ //
10
+ // --mat-checkbox-unselected-icon-color: rgba(0, 0, 0, 0.54)
11
+ // --mat-checkbox-label-text-color: rgba(0, 0, 0, 0.87)
12
+ // --mat-checkbox-selected-icon-color: var(--brand-primary-color)
13
+ //
14
+ // On a dark ground the first two are invisible - a black box outline and a black
15
+ // label on a dark surface, which is how a "Set as default" checkbox shipped
16
+ // looking disabled. The third is worse: it points at whatever name the app's
17
+ // palette happens to use, and an undefined custom property is invalid at
18
+ // computed-value time, so a CHECKED box renders unstyled rather than branded.
19
+ //
20
+ // Nothing here is app-specific. Every value is either the shared --fs-* contract
21
+ // or a light-dark() pair restating this package's own default, so an app that
22
+ // sets nothing still renders correctly in both schemes and an app that maps
23
+ // --fs-color-primary onto its brand gets its brand for free.
24
+ //
25
+ // ONE FILE FOR THE FAMILY, not one control at a time. These were fixed app-side
26
+ // one control at a time for years, which is why a project could have a correct
27
+ // select and an invisible checkbox in the same dialog. The five share three
28
+ // questions - what colour is the control unselected, selected, and what colour
29
+ // is its label - so they are answered together or they drift.
30
+ //
31
+ // GLOBAL, NOT SCOPED. These emit at :root like every other block in this
32
+ // package. A checkbox inside a dialog, menu or select panel renders in a CDK
33
+ // overlay attached to <body>, outside any app shell class, so a scoped block
34
+ // cannot reach it - the mistake that left dialog buttons unbranded.
35
+
36
+ @mixin form-controls() {
37
+ :root {
38
+ // =========================================================================
39
+ // CHECKBOX
40
+ // =========================================================================
41
+ // The unselected box is an OUTLINE, so it takes the hairline rather than a
42
+ // text colour: it is a drawn edge, and at text strength it reads as heavy.
43
+ --mat-checkbox-unselected-icon-color: var(--fs-hairline-strong, light-dark(rgba(0, 0, 0, 0.38), rgba(255, 255, 255, 0.38)));
44
+ --mat-checkbox-unselected-hover-icon-color: var(--fs-color-text-muted, light-dark(rgba(0, 0, 0, 0.54), #97A5A6));
45
+ --mat-checkbox-unselected-focus-icon-color: var(--fs-color-text-muted, light-dark(rgba(0, 0, 0, 0.54), #97A5A6));
46
+ --mat-checkbox-unselected-pressed-icon-color: var(--fs-color-text-muted, light-dark(rgba(0, 0, 0, 0.54), #97A5A6));
47
+
48
+ // Checked: the brand fills the box and the checkmark sits on it. The
49
+ // checkmark reads the SURFACE colour rather than white, so it stays legible
50
+ // if an app maps --fs-color-primary to a pale brand.
51
+ --mat-checkbox-selected-icon-color: var(--fs-color-primary, #1B474E);
52
+ --mat-checkbox-selected-hover-icon-color: var(--fs-color-primary, #1B474E);
53
+ --mat-checkbox-selected-focus-icon-color: var(--fs-color-primary, #1B474E);
54
+ --mat-checkbox-selected-checkmark-color: var(--fs-surface-background, light-dark(#FFFFFF, #232428));
55
+
56
+ --mat-checkbox-label-text-color: var(--fs-color-text, light-dark(rgba(0, 0, 0, 0.87), #E8EDEC));
57
+ --mat-checkbox-disabled-label-color: var(--fs-color-text-faint, light-dark(rgba(0, 0, 0, 0.38), #6A7779));
58
+ --mat-checkbox-disabled-unselected-icon-color: var(--fs-hairline, light-dark(#f0f0f0, rgba(255, 255, 255, 0.22)));
59
+ --mat-checkbox-disabled-selected-icon-color: var(--fs-hairline-strong, light-dark(rgba(0, 0, 0, 0.38), rgba(255, 255, 255, 0.38)));
60
+
61
+ // The wash under a hover or press. Translucent, never a fixed grey: it takes
62
+ // its tone from whatever is behind it and so reads in both schemes.
63
+ --mat-checkbox-unselected-hover-state-layer-color: var(--fs-color-hover, light-dark(rgba(0, 0, 0, 0.04), rgba(255, 255, 255, 0.08)));
64
+ --mat-checkbox-unselected-pressed-state-layer-color: var(--fs-color-hover, light-dark(rgba(0, 0, 0, 0.04), rgba(255, 255, 255, 0.08)));
65
+ --mat-checkbox-selected-hover-state-layer-color: var(--fs-color-selected, light-dark(rgba(0, 0, 0, 0.08), rgba(255, 255, 255, 0.12)));
66
+ --mat-checkbox-selected-pressed-state-layer-color: var(--fs-color-selected, light-dark(rgba(0, 0, 0, 0.08), rgba(255, 255, 255, 0.12)));
67
+
68
+ // =========================================================================
69
+ // RADIO
70
+ // =========================================================================
71
+ // Same three questions as the checkbox, same answers - the two controls
72
+ // differ in shape and in whether they are exclusive, never in colour.
73
+ --mat-radio-unselected-icon-color: var(--fs-hairline-strong, light-dark(rgba(0, 0, 0, 0.38), rgba(255, 255, 255, 0.38)));
74
+ --mat-radio-unselected-hover-icon-color: var(--fs-color-text-muted, light-dark(rgba(0, 0, 0, 0.54), #97A5A6));
75
+ --mat-radio-unselected-focus-icon-color: var(--fs-color-text-muted, light-dark(rgba(0, 0, 0, 0.54), #97A5A6));
76
+ --mat-radio-unselected-pressed-icon-color: var(--fs-color-text-muted, light-dark(rgba(0, 0, 0, 0.54), #97A5A6));
77
+
78
+ --mat-radio-selected-icon-color: var(--fs-color-primary, #1B474E);
79
+ --mat-radio-selected-hover-icon-color: var(--fs-color-primary, #1B474E);
80
+ --mat-radio-selected-focus-icon-color: var(--fs-color-primary, #1B474E);
81
+ --mat-radio-selected-pressed-icon-color: var(--fs-color-primary, #1B474E);
82
+
83
+ --mat-radio-label-text-color: var(--fs-color-text, light-dark(rgba(0, 0, 0, 0.87), #E8EDEC));
84
+ --mat-radio-disabled-label-color: var(--fs-color-text-faint, light-dark(rgba(0, 0, 0, 0.38), #6A7779));
85
+ --mat-radio-disabled-unselected-icon-color: var(--fs-hairline, light-dark(#f0f0f0, rgba(255, 255, 255, 0.22)));
86
+ --mat-radio-disabled-selected-icon-color: var(--fs-hairline-strong, light-dark(rgba(0, 0, 0, 0.38), rgba(255, 255, 255, 0.38)));
87
+ --mat-radio-ripple-color: var(--fs-color-hover, light-dark(rgba(0, 0, 0, 0.04), rgba(255, 255, 255, 0.08)));
88
+ --mat-radio-checked-ripple-color: var(--fs-color-selected, light-dark(rgba(0, 0, 0, 0.08), rgba(255, 255, 255, 0.12)));
89
+
90
+ // =========================================================================
91
+ // SLIDE TOGGLE
92
+ // =========================================================================
93
+ // The toggle is a TRACK with a HANDLE on it, so "unselected" is two colours
94
+ // rather than one: the track is the hairline it sits in, and the handle is
95
+ // the muted ink so it reads as an object on that track rather than a hole.
96
+ --mat-slide-toggle-unselected-track-color: var(--fs-hairline, light-dark(#f0f0f0, rgba(255, 255, 255, 0.22)));
97
+ --mat-slide-toggle-unselected-hover-track-color: var(--fs-hairline, light-dark(#f0f0f0, rgba(255, 255, 255, 0.22)));
98
+ --mat-slide-toggle-unselected-focus-track-color: var(--fs-hairline, light-dark(#f0f0f0, rgba(255, 255, 255, 0.22)));
99
+ --mat-slide-toggle-unselected-pressed-track-color: var(--fs-hairline, light-dark(#f0f0f0, rgba(255, 255, 255, 0.22)));
100
+ --mat-slide-toggle-unselected-handle-color: var(--fs-color-text-muted, light-dark(rgba(0, 0, 0, 0.54), #97A5A6));
101
+ --mat-slide-toggle-unselected-hover-handle-color: var(--fs-color-text, light-dark(rgba(0, 0, 0, 0.87), #E8EDEC));
102
+ --mat-slide-toggle-unselected-focus-handle-color: var(--fs-color-text, light-dark(rgba(0, 0, 0, 0.87), #E8EDEC));
103
+ --mat-slide-toggle-unselected-pressed-handle-color: var(--fs-color-text, light-dark(rgba(0, 0, 0, 0.87), #E8EDEC));
104
+ --mat-slide-toggle-unselected-icon-color: var(--fs-surface-background, light-dark(#FFFFFF, #232428));
105
+
106
+ // Selected: the brand fills the track, and the handle goes to the surface
107
+ // colour so it reads as a light knob on a coloured rail in both schemes.
108
+ --mat-slide-toggle-selected-track-color: var(--fs-color-primary, #1B474E);
109
+ --mat-slide-toggle-selected-hover-track-color: var(--fs-color-primary, #1B474E);
110
+ --mat-slide-toggle-selected-focus-track-color: var(--fs-color-primary, #1B474E);
111
+ --mat-slide-toggle-selected-pressed-track-color: var(--fs-color-primary, #1B474E);
112
+ --mat-slide-toggle-selected-handle-color: var(--fs-surface-background, light-dark(#FFFFFF, #232428));
113
+ --mat-slide-toggle-selected-hover-handle-color: var(--fs-surface-background, light-dark(#FFFFFF, #232428));
114
+ --mat-slide-toggle-selected-focus-handle-color: var(--fs-surface-background, light-dark(#FFFFFF, #232428));
115
+ --mat-slide-toggle-selected-pressed-handle-color: var(--fs-surface-background, light-dark(#FFFFFF, #232428));
116
+ --mat-slide-toggle-selected-icon-color: var(--fs-color-primary, #1B474E);
117
+
118
+ --mat-slide-toggle-label-text-color: var(--fs-color-text, light-dark(rgba(0, 0, 0, 0.87), #E8EDEC));
119
+ --mat-slide-toggle-disabled-label-text-color: var(--fs-color-text-faint, light-dark(rgba(0, 0, 0, 0.38), #6A7779));
120
+ --mat-slide-toggle-disabled-unselected-track-outline-color: var(--fs-hairline, light-dark(#f0f0f0, rgba(255, 255, 255, 0.22)));
121
+ --mat-slide-toggle-selected-focus-state-layer-color: var(--fs-color-selected, light-dark(rgba(0, 0, 0, 0.08), rgba(255, 255, 255, 0.12)));
122
+ --mat-slide-toggle-selected-hover-state-layer-color: var(--fs-color-selected, light-dark(rgba(0, 0, 0, 0.08), rgba(255, 255, 255, 0.12)));
123
+ --mat-slide-toggle-unselected-focus-state-layer-color: var(--fs-color-hover, light-dark(rgba(0, 0, 0, 0.04), rgba(255, 255, 255, 0.08)));
124
+ --mat-slide-toggle-unselected-hover-state-layer-color: var(--fs-color-hover, light-dark(rgba(0, 0, 0, 0.04), rgba(255, 255, 255, 0.08)));
125
+
126
+ // =========================================================================
127
+ // SLIDER
128
+ // =========================================================================
129
+ // The ACTIVE track is the brand, the INACTIVE track is the hairline, and the
130
+ // handle matches the active track rather than the surface - a slider's knob
131
+ // is part of the value it is showing.
132
+ --mat-slider-active-track-color: var(--fs-color-primary, #1B474E);
133
+ --mat-slider-inactive-track-color: var(--fs-hairline-strong, light-dark(rgba(0, 0, 0, 0.38), rgba(255, 255, 255, 0.38)));
134
+ --mat-slider-handle-color: var(--fs-color-primary, #1B474E);
135
+ --mat-slider-hover-handle-color: var(--fs-color-primary, #1B474E);
136
+ --mat-slider-focus-handle-color: var(--fs-color-primary, #1B474E);
137
+ --mat-slider-disabled-active-track-color: var(--fs-hairline-strong, light-dark(rgba(0, 0, 0, 0.38), rgba(255, 255, 255, 0.38)));
138
+ --mat-slider-disabled-inactive-track-color: var(--fs-hairline, light-dark(#f0f0f0, rgba(255, 255, 255, 0.22)));
139
+ --mat-slider-disabled-handle-color: var(--fs-hairline-strong, light-dark(rgba(0, 0, 0, 0.38), rgba(255, 255, 255, 0.38)));
140
+ --mat-slider-ripple-color: var(--fs-color-selected, light-dark(rgba(0, 0, 0, 0.08), rgba(255, 255, 255, 0.12)));
141
+ --mat-slider-hover-state-layer-color: var(--fs-color-hover, light-dark(rgba(0, 0, 0, 0.04), rgba(255, 255, 255, 0.08)));
142
+ --mat-slider-focus-state-layer-color: var(--fs-color-selected, light-dark(rgba(0, 0, 0, 0.08), rgba(255, 255, 255, 0.12)));
143
+
144
+ // The value bubble is a floating surface, so it takes the RAISED surface and
145
+ // the ink that reads on it.
146
+ --mat-slider-label-container-color: var(--fs-surface-background, light-dark(#FFFFFF, #232428));
147
+ --mat-slider-label-label-text-color: var(--fs-color-text, light-dark(rgba(0, 0, 0, 0.87), #E8EDEC));
148
+
149
+ // =========================================================================
150
+ // CHIP
151
+ // =========================================================================
152
+ // A chip is a SURFACE with a label, not an outline with a tint, so the flat
153
+ // (unselected) chip takes the hover wash rather than the page ground - that
154
+ // is what separates it from whatever it sits on without a border.
155
+ --mat-chip-elevated-container-color: var(--fs-color-hover, light-dark(rgba(0, 0, 0, 0.04), rgba(255, 255, 255, 0.08)));
156
+ --mat-chip-label-text-color: var(--fs-color-text, light-dark(rgba(0, 0, 0, 0.87), #E8EDEC));
157
+ --mat-chip-outline-color: var(--fs-hairline-strong, light-dark(rgba(0, 0, 0, 0.38), rgba(255, 255, 255, 0.38)));
158
+ --mat-chip-focus-outline-color: var(--fs-color-primary, #1B474E);
159
+
160
+ --mat-chip-elevated-selected-container-color: var(--fs-color-primary, #1B474E);
161
+ --mat-chip-selected-label-text-color: var(--fs-surface-background, light-dark(#FFFFFF, #232428));
162
+ --mat-chip-selected-trailing-icon-color: var(--fs-surface-background, light-dark(#FFFFFF, #232428));
163
+
164
+ --mat-chip-disabled-label-text-color: var(--fs-color-text-faint, light-dark(rgba(0, 0, 0, 0.38), #6A7779));
165
+ --mat-chip-disabled-outline-color: var(--fs-hairline, light-dark(#f0f0f0, rgba(255, 255, 255, 0.22)));
166
+ --mat-chip-hover-state-layer-color: var(--fs-color-hover, light-dark(rgba(0, 0, 0, 0.04), rgba(255, 255, 255, 0.08)));
167
+ --mat-chip-focus-state-layer-color: var(--fs-color-selected, light-dark(rgba(0, 0, 0, 0.08), rgba(255, 255, 255, 0.12)));
168
+ --mat-chip-selected-hover-state-layer-color: var(--fs-color-selected, light-dark(rgba(0, 0, 0, 0.08), rgba(255, 255, 255, 0.12)));
169
+ --mat-chip-selected-focus-state-layer-color: var(--fs-color-selected, light-dark(rgba(0, 0, 0, 0.08), rgba(255, 255, 255, 0.12)));
170
+ }
171
+ }
@@ -42,13 +42,24 @@
42
42
  // Tokens are set/read under both the v18/v19 --mdc-* names and the
43
43
  // v20+ --mat-form-field-* names so consumers on Material 18-22 all work.
44
44
  .mat-mdc-form-field.mat-form-field-appearance-fill {
45
- --mdc-filled-text-field-container-color: white;
46
- --mdc-filled-text-field-disabled-container-color: #F5F5F5;
47
- --mat-form-field-filled-container-color: white;
48
- --mat-form-field-filled-disabled-container-color: #F5F5F5;
45
+ // THE FILL GROUND, IN BOTH APPEARANCES. These were flat `white` and
46
+ // `#F5F5F5`, declared on the field element itself -- which outranks any
47
+ // :root override a consumer writes, because a custom property declared on
48
+ // the matching element always beats one inherited from the document root.
49
+ // So a host app could not correct these from outside; they had to be fixed
50
+ // here.
51
+ //
52
+ // The light values are unchanged (white, #F5F5F5 as the light half of each
53
+ // pair), so nothing about the light appearance moves. Only the dark half is
54
+ // new, and light-dark() picks between them off the `color-scheme` the host
55
+ // declares -- no class, no input, no media query.
56
+ --mdc-filled-text-field-container-color: var(--fs-surface-background, light-dark(#FFFFFF, #232428));
57
+ --mdc-filled-text-field-disabled-container-color: var(--fs-color-hover, light-dark(#F5F5F5, rgba(255, 255, 255, 0.08)));
58
+ --mat-form-field-filled-container-color: var(--fs-surface-background, light-dark(#FFFFFF, #232428));
59
+ --mat-form-field-filled-disabled-container-color: var(--fs-color-hover, light-dark(#F5F5F5, rgba(255, 255, 255, 0.08)));
49
60
 
50
61
  .mat-mdc-text-field-wrapper {
51
- border: 1px solid var(--mdc-outlined-text-field-outline-color, var(--mat-form-field-outlined-outline-color, rgba(0, 0, 0, 0.38)));
62
+ border: 1px solid var(--mdc-outlined-text-field-outline-color, var(--mat-form-field-outlined-outline-color, rgb(127 127 127 / 38%)));
52
63
  border-radius: var(--mdc-outlined-text-field-container-shape, var(--mat-form-field-outlined-container-shape, 4px));
53
64
  }
54
65
 
@@ -62,7 +73,10 @@
62
73
 
63
74
  &:hover:not(.mat-focused):not(.mat-form-field-invalid):not(.mat-form-field-disabled) {
64
75
  .mat-mdc-text-field-wrapper {
65
- border-color: var(--mdc-outlined-text-field-hover-outline-color, var(--mat-form-field-outlined-hover-outline-color, rgba(0, 0, 0, 0.87)));
76
+ // The last-resort fallback is a PAIR, not a flat black: this renders
77
+ // when @firestitch/style's material layer is absent, and a black hover
78
+ // border on a dark ground reads as a hole punched in the field.
79
+ border-color: var(--mdc-outlined-text-field-hover-outline-color, var(--mat-form-field-outlined-hover-outline-color, light-dark(rgba(0, 0, 0, 0.87), #E8EDEC)));
66
80
  }
67
81
  }
68
82
 
@@ -95,7 +109,7 @@
95
109
  }
96
110
 
97
111
  &.mat-form-field-disabled .mat-mdc-text-field-wrapper {
98
- border-color: var(--mdc-outlined-text-field-disabled-outline-color, var(--mat-form-field-outlined-disabled-outline-color, rgba(0, 0, 0, 0.06)));
112
+ border-color: var(--mdc-outlined-text-field-disabled-outline-color, var(--mat-form-field-outlined-disabled-outline-color, light-dark(rgba(0, 0, 0, 0.06), rgba(255, 255, 255, 0.12))));
99
113
  }
100
114
  }
101
115
 
@@ -41,12 +41,25 @@
41
41
  --fs-color-text-muted: light-dark(rgba(0, 0, 0, 0.54), #97A5A6);
42
42
  --fs-color-text-faint: light-dark(rgba(0, 0, 0, 0.38), #6A7779);
43
43
 
44
- // ===== SURFACES =====
45
- // The ground a component sits on, and the surface it draws for itself.
46
- // `raised` is for the surface that floats above the page — a menu panel, a
47
- // dropdown — which on a dark ground must be LIGHTER, not darker.
48
- --fs-color-surface: light-dark(#FFFFFF, #232428);
49
- --fs-color-surface-raised: light-dark(#FFFFFF, #292A2F);
44
+ // ===== SURFACE =====
45
+ // ONE surface colour for everything that is a surface: a page, a dialog, a
46
+ // card, a menu panel, a dropdown, a bottom sheet. They are all the same kind
47
+ // of thing, so they take the same colour and the app reads as one material.
48
+ //
49
+ // THERE IS DELIBERATELY NO `raised` VARIANT — Ray 2026-09-14. There used to
50
+ // be --fs-color-surface (#232428) and --fs-color-surface-raised (#292A2F),
51
+ // the second six luminance steps lighter so a floating panel read as above
52
+ // the page on a dark ground. Both were #FFFFFF in light mode, so the
53
+ // distinction only ever existed in dark, and it bought a difference nobody
54
+ // had asked for while forcing every consumer to decide which of two nearly
55
+ // identical greys it wanted — and to get it wrong silently, because the
56
+ // fallbacks differ.
57
+ //
58
+ // Elevation is not a colour problem. A surface that must read as floating
59
+ // separates with a shadow, a hairline or a blur; if a genuine need for a
60
+ // second surface colour appears later, add it then, with the case that
61
+ // justifies it. Do not reintroduce `raised` as a default.
62
+ --fs-surface-background: light-dark(#FFFFFF, #232428);
50
63
 
51
64
  // ===== LINES =====
52
65
  // The hairline does most of the structural work: chip outlines, dividers,
@@ -55,6 +68,28 @@
55
68
  --fs-hairline: light-dark(#f0f0f0, rgba(255, 255, 255, 0.22));
56
69
  --fs-hairline-strong: light-dark(rgba(0, 0, 0, 0.38), rgba(255, 255, 255, 0.38));
57
70
 
71
+ // ===== BRAND =====
72
+ // The application's own colour, and the one name a package reads to render
73
+ // anything "primary": a selected filter chip's outline and text, an active
74
+ // state, an accent rule.
75
+ //
76
+ // A PACKAGE NEVER READS AN APPLICATION'S OWN NAME. Apps carry their brand
77
+ // under whatever name they like -- set at runtime from a setting, hardcoded
78
+ // in a palette, derived from a theme -- and the app maps that onto this one
79
+ // name at its root:
80
+ //
81
+ // :root { --fs-color-primary: var(--my-app-brand-colour); }
82
+ //
83
+ // so nothing inside a package has to know the application exists. Leaving it
84
+ // unmapped is fine: the default below is a neutral slate that reads on both
85
+ // grounds, so a package renders sensibly in an app that has set nothing.
86
+ //
87
+ // NOT PER-SCHEME BY DEFAULT. A brand colour is picked to work on its own
88
+ // ground, so this is a single value rather than a light-dark() pair -- an app
89
+ // whose brand does need to shift between schemes maps it to a pair of its own
90
+ // when it sets the name above.
91
+ --fs-color-primary: #1B474E;
92
+
58
93
  // ===== FEEDBACK =====
59
94
  // The wash under a hovered or pressed surface. A package must never express
60
95
  // hover as filter: brightness() — that DARKENS, which is right on a white
@@ -18,7 +18,24 @@
18
18
  --mat-dialog-supporting-text-color: #{variables.$body-color};
19
19
 
20
20
  --mdc-elevated-card-container-shape: 12px;
21
+ // FIELD OUTLINE, PLACEHOLDER AND HOVER, IN BOTH APPEARANCES.
22
+ //
23
+ // The resting outline is deliberately a NEUTRAL grey at 38% -- it reads on a
24
+ // white page and on a dark one without needing a pair, which is why it is
25
+ // stated once rather than through light-dark().
26
+ //
27
+ // The rest cannot do that. Material's light theme emits them as flat blacks
28
+ // (rgba(0,0,0,.6) for the placeholder and the hover label, rgba(0,0,0,.87)
29
+ // for the hover outline), and black on a dark ground is invisible -- the
30
+ // placeholder disappears and the hover border reads as a hole. Each keeps
31
+ // its current light value as the light half, so nothing about the light
32
+ // appearance changes; only the dark half is new.
21
33
  --mdc-outlined-text-field-outline-color: rgb(127 127 127 / 38%);
34
+ --mdc-outlined-text-field-hover-outline-color: var(--fs-color-text, light-dark(rgba(0, 0, 0, 0.87), #E8EDEC));
35
+ --mdc-outlined-text-field-input-text-placeholder-color: var(--fs-color-text-muted, light-dark(rgba(0, 0, 0, 0.6), #97A5A6));
36
+ --mdc-filled-text-field-input-text-placeholder-color: var(--fs-color-text-muted, light-dark(rgba(0, 0, 0, 0.6), #97A5A6));
37
+ --mdc-outlined-text-field-hover-label-text-color: var(--fs-color-text-muted, light-dark(rgba(0, 0, 0, 0.6), #97A5A6));
38
+ --mdc-filled-text-field-hover-label-text-color: var(--fs-color-text-muted, light-dark(rgba(0, 0, 0, 0.6), #97A5A6));
22
39
 
23
40
  /*
24
41
  * Buttons < Angular 20