@aglyn/shared-ui-theme 1.0.0-beta.143
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/LICENSE +201 -0
- package/README.md +7 -0
- package/package.json +51 -0
- package/src/index.d.ts +34 -0
- package/src/index.js +50 -0
- package/src/index.js.map +1 -0
- package/src/lib/components/host-theme-provider.d.ts +84 -0
- package/src/lib/components/host-theme-provider.js +146 -0
- package/src/lib/components/host-theme-provider.js.map +1 -0
- package/src/lib/components/theme-css-var-provider.d.ts +44 -0
- package/src/lib/components/theme-css-var-provider.js +79 -0
- package/src/lib/components/theme-css-var-provider.js.map +1 -0
- package/src/lib/console.theme.d.ts +34 -0
- package/src/lib/console.theme.js +598 -0
- package/src/lib/console.theme.js.map +1 -0
- package/src/lib/constants.d.ts +72 -0
- package/src/lib/constants.js +85 -0
- package/src/lib/constants.js.map +1 -0
- package/src/lib/hocs/create-with-emotion-client-cache.d.ts +30 -0
- package/src/lib/hocs/create-with-emotion-client-cache.js +53 -0
- package/src/lib/hocs/create-with-emotion-client-cache.js.map +1 -0
- package/src/lib/hocs/create-with-theme-provider.d.ts +86 -0
- package/src/lib/hocs/create-with-theme-provider.js +231 -0
- package/src/lib/hocs/create-with-theme-provider.js.map +1 -0
- package/src/lib/tenant.theme.d.ts +58 -0
- package/src/lib/tenant.theme.js +282 -0
- package/src/lib/tenant.theme.js.map +1 -0
- package/src/lib/theme.types.d.ts +26 -0
- package/src/lib/theme.types.js +18 -0
- package/src/lib/theme.types.js.map +1 -0
- package/src/lib/util/accent-text.d.ts +187 -0
- package/src/lib/util/accent-text.js +277 -0
- package/src/lib/util/accent-text.js.map +1 -0
- package/src/lib/util/accessible-shade.d.ts +61 -0
- package/src/lib/util/accessible-shade.js +117 -0
- package/src/lib/util/accessible-shade.js.map +1 -0
- package/src/lib/util/color-scheme-hint.d.ts +68 -0
- package/src/lib/util/color-scheme-hint.js +69 -0
- package/src/lib/util/color-scheme-hint.js.map +1 -0
- package/src/lib/util/create-responsive-theme.d.ts +71 -0
- package/src/lib/util/create-responsive-theme.js +287 -0
- package/src/lib/util/create-responsive-theme.js.map +1 -0
- package/src/lib/util/emotion-cache.d.ts +81 -0
- package/src/lib/util/emotion-cache.js +79 -0
- package/src/lib/util/emotion-cache.js.map +1 -0
- package/src/lib/util/generate-component-class-keys.d.ts +41 -0
- package/src/lib/util/generate-component-class-keys.js +53 -0
- package/src/lib/util/generate-component-class-keys.js.map +1 -0
- package/src/lib/util/host-theme.d.ts +92 -0
- package/src/lib/util/host-theme.js +340 -0
- package/src/lib/util/host-theme.js.map +1 -0
- package/src/lib/util/layered-emotion-cache.d.ts +78 -0
- package/src/lib/util/layered-emotion-cache.js +90 -0
- package/src/lib/util/layered-emotion-cache.js.map +1 -0
- package/src/lib/util/merge-sx-props.d.ts +22 -0
- package/src/lib/util/merge-sx-props.js +27 -0
- package/src/lib/util/merge-sx-props.js.map +1 -0
- package/src/lib/util/scheme-route-segment.d.ts +95 -0
- package/src/lib/util/scheme-route-segment.js +101 -0
- package/src/lib/util/scheme-route-segment.js.map +1 -0
- package/src/lib/util/theme-editor-defaults.d.ts +41 -0
- package/src/lib/util/theme-editor-defaults.js +49 -0
- package/src/lib/util/theme-editor-defaults.js.map +1 -0
- package/src/lib/util/theme-editor-fields.d.ts +315 -0
- package/src/lib/util/theme-editor-fields.js +714 -0
- package/src/lib/util/theme-editor-fields.js.map +1 -0
- package/src/lib/util/theme-mode-cookie.d.ts +48 -0
- package/src/lib/util/theme-mode-cookie.js +48 -0
- package/src/lib/util/theme-mode-cookie.js.map +1 -0
- package/src/vendor/emotion.d.ts +18 -0
- package/src/vendor/emotion.js +22 -0
- package/src/vendor/emotion.js.map +1 -0
- package/src/vendor/jss.d.ts +18 -0
- package/src/vendor/jss.js +20 -0
- package/src/vendor/jss.js.map +1 -0
- package/src/vendor/mui.d.ts +282 -0
- package/src/vendor/mui.js +20 -0
- package/src/vendor/mui.js.map +1 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright [yyyy] [name of copyright owner]
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
package/README.md
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@aglyn/shared-ui-theme",
|
|
3
|
+
"version": "1.0.0-beta.143",
|
|
4
|
+
"license": "Apache-2.0",
|
|
5
|
+
"homepage": "https://aglyn.com",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "https://github.com/aglyn/aglyn.git",
|
|
9
|
+
"directory": "libs/shared/ui/theme"
|
|
10
|
+
},
|
|
11
|
+
"publishConfig": {
|
|
12
|
+
"access": "public",
|
|
13
|
+
"provenance": true
|
|
14
|
+
},
|
|
15
|
+
"type": "module",
|
|
16
|
+
"exports": {
|
|
17
|
+
".": {
|
|
18
|
+
"types": "./src/index.d.ts",
|
|
19
|
+
"default": "./src/index.js"
|
|
20
|
+
},
|
|
21
|
+
"./*": {
|
|
22
|
+
"types": "./src/lib/*.d.ts",
|
|
23
|
+
"default": "./src/lib/*.js"
|
|
24
|
+
},
|
|
25
|
+
"./package.json": "./package.json"
|
|
26
|
+
},
|
|
27
|
+
"dependencies": {
|
|
28
|
+
"@aglyn/shared-data-types": "1.0.0-beta.143",
|
|
29
|
+
"@aglyn/shared-util-tools": "1.0.0-beta.143",
|
|
30
|
+
"@aglyn/shared-util-vendor": "1.0.0-beta.143",
|
|
31
|
+
"@emotion/cache": "^11.14.0",
|
|
32
|
+
"@emotion/react": "11.14.0",
|
|
33
|
+
"@swc/helpers": "0.5.23",
|
|
34
|
+
"js-cookie": "^3.0.8",
|
|
35
|
+
"jss": "^10.10.0",
|
|
36
|
+
"jss-rtl": "^0.3.0",
|
|
37
|
+
"react-use": "^17.6.1"
|
|
38
|
+
},
|
|
39
|
+
"peerDependencies": {
|
|
40
|
+
"@mui/material": "^9.3.1",
|
|
41
|
+
"@mui/styles": "^6.4.8",
|
|
42
|
+
"@mui/system": "^9.2.0",
|
|
43
|
+
"@mui/types": "^9.1.1",
|
|
44
|
+
"@mui/utils": "^9.2.0",
|
|
45
|
+
"react": "^19.2.8"
|
|
46
|
+
},
|
|
47
|
+
"sideEffects": false,
|
|
48
|
+
"types": "./src/index.d.ts",
|
|
49
|
+
"module": "./src/index.js",
|
|
50
|
+
"main": "./src/index.js"
|
|
51
|
+
}
|
package/src/index.d.ts
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2023 Aglyn LLC
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
export * from './vendor/emotion';
|
|
18
|
+
export * from './vendor/mui';
|
|
19
|
+
export * from './lib/theme.types';
|
|
20
|
+
export * from './lib/constants';
|
|
21
|
+
export * from './lib/console.theme';
|
|
22
|
+
export * from './lib/tenant.theme';
|
|
23
|
+
export * from './lib/components/host-theme-provider';
|
|
24
|
+
export * from './lib/components/theme-css-var-provider';
|
|
25
|
+
export * from './lib/hocs/create-with-emotion-client-cache';
|
|
26
|
+
export * from './lib/hocs/create-with-theme-provider';
|
|
27
|
+
export * from './lib/util/accent-text';
|
|
28
|
+
export * from './lib/util/accessible-shade';
|
|
29
|
+
export * from './lib/util/create-responsive-theme';
|
|
30
|
+
export * from './lib/util/emotion-cache';
|
|
31
|
+
export * from './lib/util/generate-component-class-keys';
|
|
32
|
+
export * from './lib/util/host-theme';
|
|
33
|
+
export * from './lib/util/layered-emotion-cache';
|
|
34
|
+
export * from './lib/util/merge-sx-props';
|
package/src/index.js
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2023 Aglyn LLC
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/ export * from "./vendor/emotion.js";
|
|
17
|
+
// `./vendor/jss` is NOT re-exported (AGL-2682), for the reason AGL-2486
|
|
18
|
+
// recorded on the shared-util-vendor barrel and measured the same way. Its two
|
|
19
|
+
// exports are `JSS` (the whole `jss` namespace) and `jssRtl`, and NOTHING in
|
|
20
|
+
// the repo reads either of them from this index. The one real consumer,
|
|
21
|
+
// `libs/shared/ui/jsx/src/lib/components/sandbox-frame.tsx`, imports `jss` and
|
|
22
|
+
// `jss-rtl` from the packages directly — and that component is deliberately
|
|
23
|
+
// absent from the shared-ui-jsx barrel, so it never reaches a published page.
|
|
24
|
+
//
|
|
25
|
+
// What the `export *` did instead was put `jss-rtl` — and through it
|
|
26
|
+
// `rtl-css-js`, a full CSS property/value mirroring table — in front of every
|
|
27
|
+
// file that takes anything at all from this index, which on the tenant is the
|
|
28
|
+
// host theme, both theme providers and the emotion cache: everything a
|
|
29
|
+
// customer page renders. Measured -7.9 KB raw off the published route's eager
|
|
30
|
+
// chunk group. `sandbox-frame` is the pattern to copy: import `jss` and
|
|
31
|
+
// `jss-rtl` where they are used.
|
|
32
|
+
export * from "./vendor/mui.js";
|
|
33
|
+
export * from "./lib/theme.types.js";
|
|
34
|
+
export * from "./lib/constants.js";
|
|
35
|
+
export * from "./lib/console.theme.js";
|
|
36
|
+
export * from "./lib/tenant.theme.js";
|
|
37
|
+
export * from "./lib/components/host-theme-provider.js";
|
|
38
|
+
export * from "./lib/components/theme-css-var-provider.js";
|
|
39
|
+
export * from "./lib/hocs/create-with-emotion-client-cache.js";
|
|
40
|
+
export * from "./lib/hocs/create-with-theme-provider.js";
|
|
41
|
+
export * from "./lib/util/accent-text.js";
|
|
42
|
+
export * from "./lib/util/accessible-shade.js";
|
|
43
|
+
export * from "./lib/util/create-responsive-theme.js";
|
|
44
|
+
export * from "./lib/util/emotion-cache.js";
|
|
45
|
+
export * from "./lib/util/generate-component-class-keys.js";
|
|
46
|
+
export * from "./lib/util/host-theme.js";
|
|
47
|
+
export * from "./lib/util/layered-emotion-cache.js";
|
|
48
|
+
export * from "./lib/util/merge-sx-props.js";
|
|
49
|
+
|
|
50
|
+
//# sourceMappingURL=index.js.map
|
package/src/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../libs/shared/ui/theme/src/index.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2023 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport * from './vendor/emotion'\n// `./vendor/jss` is NOT re-exported (AGL-2682), for the reason AGL-2486\n// recorded on the shared-util-vendor barrel and measured the same way. Its two\n// exports are `JSS` (the whole `jss` namespace) and `jssRtl`, and NOTHING in\n// the repo reads either of them from this index. The one real consumer,\n// `libs/shared/ui/jsx/src/lib/components/sandbox-frame.tsx`, imports `jss` and\n// `jss-rtl` from the packages directly — and that component is deliberately\n// absent from the shared-ui-jsx barrel, so it never reaches a published page.\n//\n// What the `export *` did instead was put `jss-rtl` — and through it\n// `rtl-css-js`, a full CSS property/value mirroring table — in front of every\n// file that takes anything at all from this index, which on the tenant is the\n// host theme, both theme providers and the emotion cache: everything a\n// customer page renders. Measured -7.9 KB raw off the published route's eager\n// chunk group. `sandbox-frame` is the pattern to copy: import `jss` and\n// `jss-rtl` where they are used.\nexport * from './vendor/mui'\n\nexport * from './lib/theme.types'\nexport * from './lib/constants'\n\nexport * from './lib/console.theme'\nexport * from './lib/tenant.theme'\n\nexport * from './lib/components/host-theme-provider'\nexport * from './lib/components/theme-css-var-provider'\n\nexport * from './lib/hocs/create-with-emotion-client-cache'\nexport * from './lib/hocs/create-with-theme-provider'\n\nexport * from './lib/util/accent-text'\nexport * from './lib/util/accessible-shade'\nexport * from './lib/util/create-responsive-theme'\nexport * from './lib/util/emotion-cache'\nexport * from './lib/util/generate-component-class-keys'\nexport * from './lib/util/host-theme'\nexport * from './lib/util/layered-emotion-cache'\nexport * from './lib/util/merge-sx-props'\n"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAED,cAAc,sBAAkB;AAChC,wEAAwE;AACxE,+EAA+E;AAC/E,6EAA6E;AAC7E,wEAAwE;AACxE,+EAA+E;AAC/E,4EAA4E;AAC5E,8EAA8E;AAC9E,EAAE;AACF,qEAAqE;AACrE,8EAA8E;AAC9E,8EAA8E;AAC9E,uEAAuE;AACvE,8EAA8E;AAC9E,wEAAwE;AACxE,iCAAiC;AACjC,cAAc,kBAAc;AAE5B,cAAc,uBAAmB;AACjC,cAAc,qBAAiB;AAE/B,cAAc,yBAAqB;AACnC,cAAc,wBAAoB;AAElC,cAAc,0CAAsC;AACpD,cAAc,6CAAyC;AAEvD,cAAc,iDAA6C;AAC3D,cAAc,2CAAuC;AAErD,cAAc,4BAAwB;AACtC,cAAc,iCAA6B;AAC3C,cAAc,wCAAoC;AAClD,cAAc,8BAA0B;AACxC,cAAc,8CAA0C;AACxD,cAAc,2BAAuB;AACrC,cAAc,sCAAkC;AAChD,cAAc,+BAA2B"}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import type { HostTheme } from '@aglyn/shared-data-types';
|
|
2
|
+
import type { Theme, ThemeOptions } from '../../vendor/mui';
|
|
3
|
+
import { type ThemeMode } from '../hocs/create-with-theme-provider';
|
|
4
|
+
/**
|
|
5
|
+
* Carries the persisted host theme document from wherever it is fetched
|
|
6
|
+
* (e.g. Next page props) down to {@link HostThemeProvider}, which may live
|
|
7
|
+
* above the page tree in _app.
|
|
8
|
+
*/
|
|
9
|
+
export declare const HostThemeDocumentContext: import("react").Context<HostTheme>;
|
|
10
|
+
export declare function useHostThemeDocument(): HostTheme;
|
|
11
|
+
/**
|
|
12
|
+
* Which site an editor surface is rendering, for the layer BELOW the theme
|
|
13
|
+
* document: the base its overrides are layered onto (AGL-3068).
|
|
14
|
+
*
|
|
15
|
+
* The tenant reads the site from its route and needs no context. Every
|
|
16
|
+
* console surface that renders a site — the canvas, Preview, the element
|
|
17
|
+
* previews, the theme editor — is on a console route instead, so the site it
|
|
18
|
+
* is showing has to be said out loud, and said above them all: the components
|
|
19
|
+
* drawer sits OUTSIDE the besigner page, and a context provided inside the
|
|
20
|
+
* page cannot reach it.
|
|
21
|
+
*
|
|
22
|
+
* Undefined means "no site named", which `siteBaseOptions` reads as a
|
|
23
|
+
* customer site — the same answer the tenant gives a host it cannot match.
|
|
24
|
+
*/
|
|
25
|
+
export declare const HostSiteKeyContext: import("react").Context<string>;
|
|
26
|
+
/** The site key for the surface, for a theme base or a brand decision. */
|
|
27
|
+
export declare function useHostSiteKey(): string;
|
|
28
|
+
export type HostThemeProviderProps = {
|
|
29
|
+
/** Host theme document; falls back to {@link HostThemeDocumentContext} when omitted. */
|
|
30
|
+
theme?: HostTheme;
|
|
31
|
+
/** Theme(s) rendered when the host has no customization. A single theme is used for both schemes. */
|
|
32
|
+
fallback: Theme | [lightTheme: Theme, darkTheme: Theme];
|
|
33
|
+
/**
|
|
34
|
+
* Options the host's overrides are layered onto (AGL-1180). Supply the
|
|
35
|
+
* same brand theme `fallback` was built from: without it a host that sets
|
|
36
|
+
* one value loses the brand for every value it did NOT set, because the
|
|
37
|
+
* converter emits only what was explicitly customized and MUI fills the
|
|
38
|
+
* rest from its own stock palette.
|
|
39
|
+
*/
|
|
40
|
+
baseOptions?: ThemeOptions | [light: ThemeOptions, dark: ThemeOptions];
|
|
41
|
+
/** Extra options merged into both generated schemes (e.g. portal container defaults). */
|
|
42
|
+
themeOptions?: ThemeOptions;
|
|
43
|
+
/**
|
|
44
|
+
* The visitor's stored light/dark choice, resolved from the request's
|
|
45
|
+
* cookies by the server component above this one; `null` when they have
|
|
46
|
+
* chosen nothing. It is what the first render is built from, so a visitor
|
|
47
|
+
* who asked for dark gets dark in the first byte rather than a light page
|
|
48
|
+
* that repaints once React has hydrated. Omitted, the mode is read from
|
|
49
|
+
* `document.cookie`, which no server render can see.
|
|
50
|
+
*/
|
|
51
|
+
initialMode?: ThemeMode;
|
|
52
|
+
/**
|
|
53
|
+
* The DEVICE's light/dark preference, read from the request's
|
|
54
|
+
* `Sec-CH-Prefers-Color-Scheme` client hint by the server component above
|
|
55
|
+
* this one; `null` on a browser that sends no hint. It decides the scheme
|
|
56
|
+
* only for a visitor who has chosen nothing — `initialMode` outranks it —
|
|
57
|
+
* and it is what keeps "Device default" from meaning "light until the page
|
|
58
|
+
* has hydrated" on a dark device.
|
|
59
|
+
*/
|
|
60
|
+
initialDeviceMode?: ThemeMode;
|
|
61
|
+
disableCssBaseline?: boolean;
|
|
62
|
+
children?: JSX.Children;
|
|
63
|
+
};
|
|
64
|
+
/**
|
|
65
|
+
* Site-facing theme provider: renders children under the host's persisted
|
|
66
|
+
* MUI theme, resolving light/dark via the shared cookie +
|
|
67
|
+
* prefers-color-scheme mode state (same machinery as
|
|
68
|
+
* `createWithThemeProvider`, so `useThemeMode` toggles keep working).
|
|
69
|
+
*
|
|
70
|
+
* Both layers are decided before paint where the request can answer them: the
|
|
71
|
+
* explicit choice from `initialMode`, the device's own preference from
|
|
72
|
+
* `initialDeviceMode`. Neither has a CSS form to fall back on, because a site
|
|
73
|
+
* resolves its dark scheme in JS — a single-mode theme swapped between
|
|
74
|
+
* schemes, and node styles whose `@scheme dark` slices are merged against
|
|
75
|
+
* `palette.mode` — so a media query in a stylesheet could not make the
|
|
76
|
+
* decision instead. On a browser that sends no color-scheme client hint the
|
|
77
|
+
* device layer is unanswerable on the server and settles at hydration, which
|
|
78
|
+
* is why `useMediaQuery` remains the authority once there is one.
|
|
79
|
+
*/
|
|
80
|
+
export declare function HostThemeProvider(props: HostThemeProviderProps): import("react").JSX.Element;
|
|
81
|
+
export declare namespace HostThemeProvider {
|
|
82
|
+
var displayName: string;
|
|
83
|
+
}
|
|
84
|
+
export default HostThemeProvider;
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Aglyn LLC
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/ 'use client';
|
|
17
|
+
import { _ as _extends } from "@swc/helpers/_/_extends";
|
|
18
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
19
|
+
import { _isArr } from "@aglyn/shared-util-tools";
|
|
20
|
+
import { CssBaseline } from "@mui/material";
|
|
21
|
+
import { createContext, useContext, useMemo } from "react";
|
|
22
|
+
import { ThemeProvider } from "../../vendor/mui.js";
|
|
23
|
+
import { ThemeContextDispatch, useThemeModeState } from "../hocs/create-with-theme-provider.js";
|
|
24
|
+
import { createResponsiveTheme } from "../util/create-responsive-theme.js";
|
|
25
|
+
import { hasHostTheme, hostThemeToThemeOptions, mergeThemeOptions } from "../util/host-theme.js";
|
|
26
|
+
/**
|
|
27
|
+
* Carries the persisted host theme document from wherever it is fetched
|
|
28
|
+
* (e.g. Next page props) down to {@link HostThemeProvider}, which may live
|
|
29
|
+
* above the page tree in _app.
|
|
30
|
+
*/ export const HostThemeDocumentContext = /*#__PURE__*/ createContext(undefined);
|
|
31
|
+
export function useHostThemeDocument() {
|
|
32
|
+
return useContext(HostThemeDocumentContext);
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Which site an editor surface is rendering, for the layer BELOW the theme
|
|
36
|
+
* document: the base its overrides are layered onto (AGL-3068).
|
|
37
|
+
*
|
|
38
|
+
* The tenant reads the site from its route and needs no context. Every
|
|
39
|
+
* console surface that renders a site — the canvas, Preview, the element
|
|
40
|
+
* previews, the theme editor — is on a console route instead, so the site it
|
|
41
|
+
* is showing has to be said out loud, and said above them all: the components
|
|
42
|
+
* drawer sits OUTSIDE the besigner page, and a context provided inside the
|
|
43
|
+
* page cannot reach it.
|
|
44
|
+
*
|
|
45
|
+
* Undefined means "no site named", which `siteBaseOptions` reads as a
|
|
46
|
+
* customer site — the same answer the tenant gives a host it cannot match.
|
|
47
|
+
*/ export const HostSiteKeyContext = /*#__PURE__*/ createContext(undefined);
|
|
48
|
+
/** The site key for the surface, for a theme base or a brand decision. */ export function useHostSiteKey() {
|
|
49
|
+
return useContext(HostSiteKeyContext);
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Site-facing theme provider: renders children under the host's persisted
|
|
53
|
+
* MUI theme, resolving light/dark via the shared cookie +
|
|
54
|
+
* prefers-color-scheme mode state (same machinery as
|
|
55
|
+
* `createWithThemeProvider`, so `useThemeMode` toggles keep working).
|
|
56
|
+
*
|
|
57
|
+
* Both layers are decided before paint where the request can answer them: the
|
|
58
|
+
* explicit choice from `initialMode`, the device's own preference from
|
|
59
|
+
* `initialDeviceMode`. Neither has a CSS form to fall back on, because a site
|
|
60
|
+
* resolves its dark scheme in JS — a single-mode theme swapped between
|
|
61
|
+
* schemes, and node styles whose `@scheme dark` slices are merged against
|
|
62
|
+
* `palette.mode` — so a media query in a stylesheet could not make the
|
|
63
|
+
* decision instead. On a browser that sends no color-scheme client hint the
|
|
64
|
+
* device layer is unanswerable on the server and settles at hydration, which
|
|
65
|
+
* is why `useMediaQuery` remains the authority once there is one.
|
|
66
|
+
*/ export function HostThemeProvider(props) {
|
|
67
|
+
const { theme, fallback, baseOptions, themeOptions, initialMode, initialDeviceMode, disableCssBaseline, children } = props;
|
|
68
|
+
const contextTheme = useHostThemeDocument();
|
|
69
|
+
const hostTheme = theme != null ? theme : contextTheme;
|
|
70
|
+
const themeModeState = useThemeModeState(initialMode, initialDeviceMode);
|
|
71
|
+
const [[, themeMode], toggleThemeMode, cookieMode] = themeModeState;
|
|
72
|
+
const requested = themeMode === 'dark' ? 'dark' : 'light';
|
|
73
|
+
/**
|
|
74
|
+
* Dark follows the visitor unless the site switched it off.
|
|
75
|
+
*
|
|
76
|
+
* A site needs no dark design of its own to go dark: the platform's default
|
|
77
|
+
* dark palette (`consoleOptionsDark`, handed in as `baseOptions`) renders
|
|
78
|
+
* under whatever dark colors the site authored, by the same layering that
|
|
79
|
+
* gives it the brand palette in light (AGL-1180), and a host with no theme
|
|
80
|
+
* at all gets the dark fallback. Content that carries light-only hex
|
|
81
|
+
* backgrounds still reads badly under dark text tokens — that is a content
|
|
82
|
+
* choice, and the site owner makes it with `darkScheme: 'off'` in the theme
|
|
83
|
+
* editor, which keeps every visitor on light. The theme mode switcher reads
|
|
84
|
+
* the same answer and hides on such a site (AGL-2676).
|
|
85
|
+
*/ const canGoDark = (hostTheme == null ? void 0 : hostTheme.darkScheme) !== 'off';
|
|
86
|
+
const scheme = requested === 'dark' && !canGoDark ? 'light' : requested;
|
|
87
|
+
// The mode state plus whether this site can honor a dark request, so a
|
|
88
|
+
// visitor-facing control (the theme mode switcher) can tell a site that
|
|
89
|
+
// will never go dark from one that merely is not dark right now.
|
|
90
|
+
const modeContext = useMemo(()=>[
|
|
91
|
+
themeModeState[0],
|
|
92
|
+
toggleThemeMode,
|
|
93
|
+
cookieMode,
|
|
94
|
+
canGoDark
|
|
95
|
+
], [
|
|
96
|
+
themeModeState,
|
|
97
|
+
toggleThemeMode,
|
|
98
|
+
cookieMode,
|
|
99
|
+
canGoDark
|
|
100
|
+
]);
|
|
101
|
+
const activeTheme = useMemo(()=>{
|
|
102
|
+
var _ref;
|
|
103
|
+
if (!hasHostTheme(hostTheme)) {
|
|
104
|
+
const [light, dark] = _isArr(fallback) ? fallback : [
|
|
105
|
+
fallback,
|
|
106
|
+
fallback
|
|
107
|
+
];
|
|
108
|
+
return scheme === 'dark' ? dark : light;
|
|
109
|
+
}
|
|
110
|
+
// Layer the host's overrides onto the brand base rather than replacing
|
|
111
|
+
// it (AGL-1180) — otherwise customizing one value repaints every other
|
|
112
|
+
// slot in MUI's stock palette.
|
|
113
|
+
const [lightBase, darkBase] = _isArr(baseOptions) ? baseOptions : [
|
|
114
|
+
baseOptions,
|
|
115
|
+
baseOptions
|
|
116
|
+
];
|
|
117
|
+
const base = (_ref = scheme === 'dark' ? darkBase : lightBase) != null ? _ref : {};
|
|
118
|
+
const converted = mergeThemeOptions(base, hostThemeToThemeOptions(hostTheme, scheme));
|
|
119
|
+
return createResponsiveTheme({
|
|
120
|
+
themeOptions: _extends({}, converted, themeOptions, {
|
|
121
|
+
palette: _extends({}, converted.palette, themeOptions == null ? void 0 : themeOptions.palette),
|
|
122
|
+
components: _extends({}, converted.components, themeOptions == null ? void 0 : themeOptions.components)
|
|
123
|
+
})
|
|
124
|
+
});
|
|
125
|
+
}, [
|
|
126
|
+
hostTheme,
|
|
127
|
+
fallback,
|
|
128
|
+
baseOptions,
|
|
129
|
+
themeOptions,
|
|
130
|
+
scheme
|
|
131
|
+
]);
|
|
132
|
+
return /*#__PURE__*/ _jsx(ThemeContextDispatch.Provider, {
|
|
133
|
+
value: modeContext,
|
|
134
|
+
children: /*#__PURE__*/ _jsx(ThemeProvider, {
|
|
135
|
+
theme: activeTheme,
|
|
136
|
+
children: disableCssBaseline ? children : /*#__PURE__*/ _jsx(CssBaseline, {
|
|
137
|
+
enableColorScheme: true,
|
|
138
|
+
children: children
|
|
139
|
+
})
|
|
140
|
+
})
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
HostThemeProvider.displayName = 'HostThemeProvider';
|
|
144
|
+
export default HostThemeProvider;
|
|
145
|
+
|
|
146
|
+
//# sourceMappingURL=host-theme-provider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../../../libs/shared/ui/theme/src/lib/components/host-theme-provider.tsx"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n'use client'\n\nimport type { HostTheme } from '@aglyn/shared-data-types'\nimport { _isArr } from '@aglyn/shared-util-tools'\nimport { CssBaseline } from '@mui/material'\nimport { createContext, useContext, useMemo } from 'react'\nimport type { Theme, ThemeOptions } from '../../vendor/mui'\nimport { ThemeProvider } from '../../vendor/mui'\nimport {\n type ThemeMode,\n ThemeContextDispatch,\n type UseThemeMode,\n useThemeModeState,\n} from '../hocs/create-with-theme-provider'\nimport { createResponsiveTheme } from '../util/create-responsive-theme'\nimport {\n hasHostTheme,\n hostThemeToThemeOptions,\n mergeThemeOptions,\n} from '../util/host-theme'\n\n/**\n * Carries the persisted host theme document from wherever it is fetched\n * (e.g. Next page props) down to {@link HostThemeProvider}, which may live\n * above the page tree in _app.\n */\nexport const HostThemeDocumentContext = createContext<HostTheme | undefined>(\n undefined,\n)\n\nexport function useHostThemeDocument() {\n return useContext(HostThemeDocumentContext)\n}\n\n/**\n * Which site an editor surface is rendering, for the layer BELOW the theme\n * document: the base its overrides are layered onto (AGL-3068).\n *\n * The tenant reads the site from its route and needs no context. Every\n * console surface that renders a site — the canvas, Preview, the element\n * previews, the theme editor — is on a console route instead, so the site it\n * is showing has to be said out loud, and said above them all: the components\n * drawer sits OUTSIDE the besigner page, and a context provided inside the\n * page cannot reach it.\n *\n * Undefined means \"no site named\", which `siteBaseOptions` reads as a\n * customer site — the same answer the tenant gives a host it cannot match.\n */\nexport const HostSiteKeyContext = createContext<string | undefined>(undefined)\n\n/** The site key for the surface, for a theme base or a brand decision. */\nexport function useHostSiteKey() {\n return useContext(HostSiteKeyContext)\n}\n\nexport type HostThemeProviderProps = {\n /** Host theme document; falls back to {@link HostThemeDocumentContext} when omitted. */\n theme?: HostTheme\n /** Theme(s) rendered when the host has no customization. A single theme is used for both schemes. */\n fallback: Theme | [lightTheme: Theme, darkTheme: Theme]\n /**\n * Options the host's overrides are layered onto (AGL-1180). Supply the\n * same brand theme `fallback` was built from: without it a host that sets\n * one value loses the brand for every value it did NOT set, because the\n * converter emits only what was explicitly customized and MUI fills the\n * rest from its own stock palette.\n */\n baseOptions?: ThemeOptions | [light: ThemeOptions, dark: ThemeOptions]\n /** Extra options merged into both generated schemes (e.g. portal container defaults). */\n themeOptions?: ThemeOptions\n /**\n * The visitor's stored light/dark choice, resolved from the request's\n * cookies by the server component above this one; `null` when they have\n * chosen nothing. It is what the first render is built from, so a visitor\n * who asked for dark gets dark in the first byte rather than a light page\n * that repaints once React has hydrated. Omitted, the mode is read from\n * `document.cookie`, which no server render can see.\n */\n initialMode?: ThemeMode\n /**\n * The DEVICE's light/dark preference, read from the request's\n * `Sec-CH-Prefers-Color-Scheme` client hint by the server component above\n * this one; `null` on a browser that sends no hint. It decides the scheme\n * only for a visitor who has chosen nothing — `initialMode` outranks it —\n * and it is what keeps \"Device default\" from meaning \"light until the page\n * has hydrated\" on a dark device.\n */\n initialDeviceMode?: ThemeMode\n disableCssBaseline?: boolean\n children?: JSX.Children\n}\n\n/**\n * Site-facing theme provider: renders children under the host's persisted\n * MUI theme, resolving light/dark via the shared cookie +\n * prefers-color-scheme mode state (same machinery as\n * `createWithThemeProvider`, so `useThemeMode` toggles keep working).\n *\n * Both layers are decided before paint where the request can answer them: the\n * explicit choice from `initialMode`, the device's own preference from\n * `initialDeviceMode`. Neither has a CSS form to fall back on, because a site\n * resolves its dark scheme in JS — a single-mode theme swapped between\n * schemes, and node styles whose `@scheme dark` slices are merged against\n * `palette.mode` — so a media query in a stylesheet could not make the\n * decision instead. On a browser that sends no color-scheme client hint the\n * device layer is unanswerable on the server and settles at hydration, which\n * is why `useMediaQuery` remains the authority once there is one.\n */\nexport function HostThemeProvider(props: HostThemeProviderProps) {\n const {\n theme,\n fallback,\n baseOptions,\n themeOptions,\n initialMode,\n initialDeviceMode,\n disableCssBaseline,\n children,\n } = props\n const contextTheme = useHostThemeDocument()\n const hostTheme = theme ?? contextTheme\n const themeModeState = useThemeModeState(initialMode, initialDeviceMode)\n const [[, themeMode], toggleThemeMode, cookieMode] = themeModeState\n const requested = themeMode === 'dark' ? 'dark' : 'light'\n\n /**\n * Dark follows the visitor unless the site switched it off.\n *\n * A site needs no dark design of its own to go dark: the platform's default\n * dark palette (`consoleOptionsDark`, handed in as `baseOptions`) renders\n * under whatever dark colors the site authored, by the same layering that\n * gives it the brand palette in light (AGL-1180), and a host with no theme\n * at all gets the dark fallback. Content that carries light-only hex\n * backgrounds still reads badly under dark text tokens — that is a content\n * choice, and the site owner makes it with `darkScheme: 'off'` in the theme\n * editor, which keeps every visitor on light. The theme mode switcher reads\n * the same answer and hides on such a site (AGL-2676).\n */\n const canGoDark = hostTheme?.darkScheme !== 'off'\n const scheme = requested === 'dark' && !canGoDark ? 'light' : requested\n\n // The mode state plus whether this site can honor a dark request, so a\n // visitor-facing control (the theme mode switcher) can tell a site that\n // will never go dark from one that merely is not dark right now.\n const modeContext = useMemo<UseThemeMode>(\n () => [themeModeState[0], toggleThemeMode, cookieMode, canGoDark],\n [themeModeState, toggleThemeMode, cookieMode, canGoDark],\n )\n\n const activeTheme = useMemo<Theme>(() => {\n if (!hasHostTheme(hostTheme)) {\n const [light, dark] = _isArr(fallback) ? fallback : [fallback, fallback]\n return scheme === 'dark' ? dark : light\n }\n // Layer the host's overrides onto the brand base rather than replacing\n // it (AGL-1180) — otherwise customizing one value repaints every other\n // slot in MUI's stock palette.\n const [lightBase, darkBase] = _isArr(baseOptions)\n ? baseOptions\n : [baseOptions, baseOptions]\n const base = (scheme === 'dark' ? darkBase : lightBase) ?? {}\n const converted = mergeThemeOptions(\n base,\n hostThemeToThemeOptions(hostTheme, scheme),\n )\n return createResponsiveTheme({\n themeOptions: {\n ...converted,\n ...themeOptions,\n palette: { ...converted.palette, ...themeOptions?.palette },\n components: { ...converted.components, ...themeOptions?.components },\n },\n })\n }, [hostTheme, fallback, baseOptions, themeOptions, scheme])\n\n return (\n <ThemeContextDispatch.Provider value={modeContext}>\n <ThemeProvider theme={activeTheme}>\n {disableCssBaseline ? (\n children\n ) : (\n <CssBaseline enableColorScheme>{children}</CssBaseline>\n )}\n </ThemeProvider>\n </ThemeContextDispatch.Provider>\n )\n}\nHostThemeProvider.displayName = 'HostThemeProvider'\n\nexport default HostThemeProvider\n"],"names":["_isArr","CssBaseline","createContext","useContext","useMemo","ThemeProvider","ThemeContextDispatch","useThemeModeState","createResponsiveTheme","hasHostTheme","hostThemeToThemeOptions","mergeThemeOptions","HostThemeDocumentContext","undefined","useHostThemeDocument","HostSiteKeyContext","useHostSiteKey","HostThemeProvider","props","theme","fallback","baseOptions","themeOptions","initialMode","initialDeviceMode","disableCssBaseline","children","contextTheme","hostTheme","themeModeState","themeMode","toggleThemeMode","cookieMode","requested","canGoDark","darkScheme","scheme","modeContext","activeTheme","light","dark","lightBase","darkBase","base","converted","palette","components","Provider","value","enableColorScheme","displayName"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GACD;;;AAGA,SAASA,MAAM,QAAQ,2BAA0B;AACjD,SAASC,WAAW,QAAQ,gBAAe;AAC3C,SAASC,aAAa,EAAEC,UAAU,EAAEC,OAAO,QAAQ,QAAO;AAE1D,SAASC,aAAa,QAAQ,sBAAkB;AAChD,SAEEC,oBAAoB,EAEpBC,iBAAiB,QACZ,wCAAoC;AAC3C,SAASC,qBAAqB,QAAQ,qCAAiC;AACvE,SACEC,YAAY,EACZC,uBAAuB,EACvBC,iBAAiB,QACZ,wBAAoB;AAE3B;;;;CAIC,GACD,OAAO,MAAMC,yCAA2BV,cACtCW,WACD;AAED,OAAO,SAASC;IACd,OAAOX,WAAWS;AACpB;AAEA;;;;;;;;;;;;;CAaC,GACD,OAAO,MAAMG,mCAAqBb,cAAkCW,WAAU;AAE9E,wEAAwE,GACxE,OAAO,SAASG;IACd,OAAOb,WAAWY;AACpB;AAuCA;;;;;;;;;;;;;;;CAeC,GACD,OAAO,SAASE,kBAAkBC,KAA6B;IAC7D,MAAM,EACJC,KAAK,EACLC,QAAQ,EACRC,WAAW,EACXC,YAAY,EACZC,WAAW,EACXC,iBAAiB,EACjBC,kBAAkB,EAClBC,QAAQ,EACT,GAAGR;IACJ,MAAMS,eAAeb;IACrB,MAAMc,YAAYT,gBAAAA,QAASQ;IAC3B,MAAME,iBAAiBtB,kBAAkBgB,aAAaC;IACtD,MAAM,CAAC,GAAGM,UAAU,EAAEC,iBAAiBC,WAAW,GAAGH;IACrD,MAAMI,YAAYH,cAAc,SAAS,SAAS;IAElD;;;;;;;;;;;;GAYC,GACD,MAAMI,YAAYN,CAAAA,6BAAAA,UAAWO,UAAU,MAAK;IAC5C,MAAMC,SAASH,cAAc,UAAU,CAACC,YAAY,UAAUD;IAE9D,uEAAuE;IACvE,wEAAwE;IACxE,iEAAiE;IACjE,MAAMI,cAAcjC,QAClB,IAAM;YAACyB,cAAc,CAAC,EAAE;YAAEE;YAAiBC;YAAYE;SAAU,EACjE;QAACL;QAAgBE;QAAiBC;QAAYE;KAAU;IAG1D,MAAMI,cAAclC,QAAe;YAWnBgC;QAVd,IAAI,CAAC3B,aAAamB,YAAY;YAC5B,MAAM,CAACW,OAAOC,KAAK,GAAGxC,OAAOoB,YAAYA,WAAW;gBAACA;gBAAUA;aAAS;YACxE,OAAOgB,WAAW,SAASI,OAAOD;QACpC;QACA,uEAAuE;QACvE,uEAAuE;QACvE,+BAA+B;QAC/B,MAAM,CAACE,WAAWC,SAAS,GAAG1C,OAAOqB,eACjCA,cACA;YAACA;YAAaA;SAAY;QAC9B,MAAMsB,QAAQP,OAAAA,WAAW,SAASM,WAAWD,qBAA/BL,OAA6C,CAAC;QAC5D,MAAMQ,YAAYjC,kBAChBgC,MACAjC,wBAAwBkB,WAAWQ;QAErC,OAAO5B,sBAAsB;YAC3Bc,cAAc,aACTsB,WACAtB;gBACHuB,SAAS,aAAKD,UAAUC,OAAO,EAAKvB,gCAAAA,aAAcuB,OAAO;gBACzDC,YAAY,aAAKF,UAAUE,UAAU,EAAKxB,gCAAAA,aAAcwB,UAAU;;QAEtE;IACF,GAAG;QAAClB;QAAWR;QAAUC;QAAaC;QAAcc;KAAO;IAE3D,qBACE,KAAC9B,qBAAqByC,QAAQ;QAACC,OAAOX;kBACpC,cAAA,KAAChC;YAAcc,OAAOmB;sBACnBb,qBACCC,yBAEA,KAACzB;gBAAYgD,iBAAiB;0BAAEvB;;;;AAK1C;AACAT,kBAAkBiC,WAAW,GAAG;AAEhC,eAAejC,kBAAiB"}
|