@kanso-labs/kanso-ui-core 0.6.2 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -41,11 +41,14 @@ const productTheme = defineProductTheme({
41
41
  Every colour that reads a product role follows it, `primary` and `focus-ring`
42
42
  among them. `defineProductTheme` holds the colours to Kanso's contrast targets,
43
43
  WCAG 2's 4.5:1 for text and 3:1 for the rest, in both schemes, and throws a
44
- `ProductThemeError` naming each pair that misses one. The theme it returns holds
45
- `light` and `dark`, every property at its value in that scheme, and `changes`,
46
- every colour that follows a product role, those it leaves at the default
47
- included, so a scope setting them replaces any product around it. Both
48
- libraries' `ThemeScope` is to take it as `productTheme`.
44
+ `ProductThemeError` naming each pair that misses one. That includes a
45
+ `spotlightTonal` whose `onSpotlight` label misses 4.5:1 under the hover or
46
+ pressed layer: leave `spotlightTonal` out to have one worked out, or pick one
47
+ that holds 4.5:1 under the pressed layer. The theme it returns holds `light` and
48
+ `dark`, every property at its value in that scheme, and `changes`, every colour
49
+ that follows a product role, those it leaves at the default included, so a scope
50
+ setting them replaces any product around it. Both libraries' `ThemeScope` is to
51
+ take it as `productTheme`.
49
52
 
50
53
  ## Development
51
54
 
@@ -65,7 +68,10 @@ mise exec node@"$(awk '/^nodejs/{print $2}' .tool-versions)" -- npm install
65
68
 
66
69
  ## License
67
70
 
68
- [MIT](LICENSE.md)
71
+ [MIT](LICENSE.md). The glyph paths are Google's Material Design icons, under the
72
+ Apache License, Version 2.0; [THIRD_PARTY_NOTICES.md](THIRD_PARTY_NOTICES.md)
73
+ carries their attribution and the licence's text, and is published with the
74
+ package.
69
75
 
70
76
  [build-shield]:
71
77
  https://img.shields.io/github/actions/workflow/status/kanso-labs/kanso-ui-core/build.yaml?branch=main&label=Build
@@ -0,0 +1,216 @@
1
+ # Third-party notices
2
+
3
+ `@kanso-labs/kanso-ui-core` is published under the MIT License, in `LICENSE.md`.
4
+ It also carries work of others, under their own licences, listed here.
5
+
6
+ ## Material Design icons
7
+
8
+ The glyph paths in `./glyphs`, from `src/glyphs.ts`, are path data from the
9
+ filled 24px set of Google's Material Design icons,
10
+ <https://github.com/google/material-design-icons>, used under the Apache
11
+ License, Version 2.0, whose full text follows.
12
+
13
+ ```text
14
+
15
+ Apache License
16
+ Version 2.0, January 2004
17
+ http://www.apache.org/licenses/
18
+
19
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
20
+
21
+ 1. Definitions.
22
+
23
+ "License" shall mean the terms and conditions for use, reproduction,
24
+ and distribution as defined by Sections 1 through 9 of this document.
25
+
26
+ "Licensor" shall mean the copyright owner or entity authorized by
27
+ the copyright owner that is granting the License.
28
+
29
+ "Legal Entity" shall mean the union of the acting entity and all
30
+ other entities that control, are controlled by, or are under common
31
+ control with that entity. For the purposes of this definition,
32
+ "control" means (i) the power, direct or indirect, to cause the
33
+ direction or management of such entity, whether by contract or
34
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
35
+ outstanding shares, or (iii) beneficial ownership of such entity.
36
+
37
+ "You" (or "Your") shall mean an individual or Legal Entity
38
+ exercising permissions granted by this License.
39
+
40
+ "Source" form shall mean the preferred form for making modifications,
41
+ including but not limited to software source code, documentation
42
+ source, and configuration files.
43
+
44
+ "Object" form shall mean any form resulting from mechanical
45
+ transformation or translation of a Source form, including but
46
+ not limited to compiled object code, generated documentation,
47
+ and conversions to other media types.
48
+
49
+ "Work" shall mean the work of authorship, whether in Source or
50
+ Object form, made available under the License, as indicated by a
51
+ copyright notice that is included in or attached to the work
52
+ (an example is provided in the Appendix below).
53
+
54
+ "Derivative Works" shall mean any work, whether in Source or Object
55
+ form, that is based on (or derived from) the Work and for which the
56
+ editorial revisions, annotations, elaborations, or other modifications
57
+ represent, as a whole, an original work of authorship. For the purposes
58
+ of this License, Derivative Works shall not include works that remain
59
+ separable from, or merely link (or bind by name) to the interfaces of,
60
+ the Work and Derivative Works thereof.
61
+
62
+ "Contribution" shall mean any work of authorship, including
63
+ the original version of the Work and any modifications or additions
64
+ to that Work or Derivative Works thereof, that is intentionally
65
+ submitted to Licensor for inclusion in the Work by the copyright owner
66
+ or by an individual or Legal Entity authorized to submit on behalf of
67
+ the copyright owner. For the purposes of this definition, "submitted"
68
+ means any form of electronic, verbal, or written communication sent
69
+ to the Licensor or its representatives, including but not limited to
70
+ communication on electronic mailing lists, source code control systems,
71
+ and issue tracking systems that are managed by, or on behalf of, the
72
+ Licensor for the purpose of discussing and improving the Work, but
73
+ excluding communication that is conspicuously marked or otherwise
74
+ designated in writing by the copyright owner as "Not a Contribution."
75
+
76
+ "Contributor" shall mean Licensor and any individual or Legal Entity
77
+ on behalf of whom a Contribution has been received by Licensor and
78
+ subsequently incorporated within the Work.
79
+
80
+ 2. Grant of Copyright License. Subject to the terms and conditions of
81
+ this License, each Contributor hereby grants to You a perpetual,
82
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
83
+ copyright license to reproduce, prepare Derivative Works of,
84
+ publicly display, publicly perform, sublicense, and distribute the
85
+ Work and such Derivative Works in Source or Object form.
86
+
87
+ 3. Grant of Patent License. Subject to the terms and conditions of
88
+ this License, each Contributor hereby grants to You a perpetual,
89
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
90
+ (except as stated in this section) patent license to make, have made,
91
+ use, offer to sell, sell, import, and otherwise transfer the Work,
92
+ where such license applies only to those patent claims licensable
93
+ by such Contributor that are necessarily infringed by their
94
+ Contribution(s) alone or by combination of their Contribution(s)
95
+ with the Work to which such Contribution(s) was submitted. If You
96
+ institute patent litigation against any entity (including a
97
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
98
+ or a Contribution incorporated within the Work constitutes direct
99
+ or contributory patent infringement, then any patent licenses
100
+ granted to You under this License for that Work shall terminate
101
+ as of the date such litigation is filed.
102
+
103
+ 4. Redistribution. You may reproduce and distribute copies of the
104
+ Work or Derivative Works thereof in any medium, with or without
105
+ modifications, and in Source or Object form, provided that You
106
+ meet the following conditions:
107
+
108
+ (a) You must give any other recipients of the Work or
109
+ Derivative Works a copy of this License; and
110
+
111
+ (b) You must cause any modified files to carry prominent notices
112
+ stating that You changed the files; and
113
+
114
+ (c) You must retain, in the Source form of any Derivative Works
115
+ that You distribute, all copyright, patent, trademark, and
116
+ attribution notices from the Source form of the Work,
117
+ excluding those notices that do not pertain to any part of
118
+ the Derivative Works; and
119
+
120
+ (d) If the Work includes a "NOTICE" text file as part of its
121
+ distribution, then any Derivative Works that You distribute must
122
+ include a readable copy of the attribution notices contained
123
+ within such NOTICE file, excluding those notices that do not
124
+ pertain to any part of the Derivative Works, in at least one
125
+ of the following places: within a NOTICE text file distributed
126
+ as part of the Derivative Works; within the Source form or
127
+ documentation, if provided along with the Derivative Works; or,
128
+ within a display generated by the Derivative Works, if and
129
+ wherever such third-party notices normally appear. The contents
130
+ of the NOTICE file are for informational purposes only and
131
+ do not modify the License. You may add Your own attribution
132
+ notices within Derivative Works that You distribute, alongside
133
+ or as an addendum to the NOTICE text from the Work, provided
134
+ that such additional attribution notices cannot be construed
135
+ as modifying the License.
136
+
137
+ You may add Your own copyright statement to Your modifications and
138
+ may provide additional or different license terms and conditions
139
+ for use, reproduction, or distribution of Your modifications, or
140
+ for any such Derivative Works as a whole, provided Your use,
141
+ reproduction, and distribution of the Work otherwise complies with
142
+ the conditions stated in this License.
143
+
144
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
145
+ any Contribution intentionally submitted for inclusion in the Work
146
+ by You to the Licensor shall be under the terms and conditions of
147
+ this License, without any additional terms or conditions.
148
+ Notwithstanding the above, nothing herein shall supersede or modify
149
+ the terms of any separate license agreement you may have executed
150
+ with Licensor regarding such Contributions.
151
+
152
+ 6. Trademarks. This License does not grant permission to use the trade
153
+ names, trademarks, service marks, or product names of the Licensor,
154
+ except as required for reasonable and customary use in describing the
155
+ origin of the Work and reproducing the content of the NOTICE file.
156
+
157
+ 7. Disclaimer of Warranty. Unless required by applicable law or
158
+ agreed to in writing, Licensor provides the Work (and each
159
+ Contributor provides its Contributions) on an "AS IS" BASIS,
160
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
161
+ implied, including, without limitation, any warranties or conditions
162
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
163
+ PARTICULAR PURPOSE. You are solely responsible for determining the
164
+ appropriateness of using or redistributing the Work and assume any
165
+ risks associated with Your exercise of permissions under this License.
166
+
167
+ 8. Limitation of Liability. In no event and under no legal theory,
168
+ whether in tort (including negligence), contract, or otherwise,
169
+ unless required by applicable law (such as deliberate and grossly
170
+ negligent acts) or agreed to in writing, shall any Contributor be
171
+ liable to You for damages, including any direct, indirect, special,
172
+ incidental, or consequential damages of any character arising as a
173
+ result of this License or out of the use or inability to use the
174
+ Work (including but not limited to damages for loss of goodwill,
175
+ work stoppage, computer failure or malfunction, or any and all
176
+ other commercial damages or losses), even if such Contributor
177
+ has been advised of the possibility of such damages.
178
+
179
+ 9. Accepting Warranty or Additional Liability. While redistributing
180
+ the Work or Derivative Works thereof, You may choose to offer,
181
+ and charge a fee for, acceptance of support, warranty, indemnity,
182
+ or other liability obligations and/or rights consistent with this
183
+ License. However, in accepting such obligations, You may act only
184
+ on Your own behalf and on Your sole responsibility, not on behalf
185
+ of any other Contributor, and only if You agree to indemnify,
186
+ defend, and hold each Contributor harmless for any liability
187
+ incurred by, or claims asserted against, such Contributor by reason
188
+ of your accepting any such warranty or additional liability.
189
+
190
+ END OF TERMS AND CONDITIONS
191
+
192
+ APPENDIX: How to apply the Apache License to your work.
193
+
194
+ To apply the Apache License to your work, attach the following
195
+ boilerplate notice, with the fields enclosed by brackets "[]"
196
+ replaced with your own identifying information. (Don't include
197
+ the brackets!) The text should be enclosed in the appropriate
198
+ comment syntax for the file format. We also recommend that a
199
+ file or class name and description of purpose be included on the
200
+ same "printed page" as the copyright notice for easier
201
+ identification within third-party archives.
202
+
203
+ Copyright [yyyy] [name of copyright owner]
204
+
205
+ Licensed under the Apache License, Version 2.0 (the "License");
206
+ you may not use this file except in compliance with the License.
207
+ You may obtain a copy of the License at
208
+
209
+ http://www.apache.org/licenses/LICENSE-2.0
210
+
211
+ Unless required by applicable law or agreed to in writing, software
212
+ distributed under the License is distributed on an "AS IS" BASIS,
213
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
214
+ See the License for the specific language governing permissions and
215
+ limitations under the License.
216
+ ```
package/dist/glyphs.d.ts CHANGED
@@ -30,6 +30,11 @@ declare const clockPath = "M11.99 2C6.47 2 2 6.48 2 12s4.47 10 9.99 10C17.52 22
30
30
  declare const closePath = "M19 6.41 17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z";
31
31
  /** An exclamation mark in a filled circle; see `checkCirclePath`. */
32
32
  declare const errorPath = "M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm1 15h-2v-2h2v2zm0-4h-2V7h2v6z";
33
+ /**
34
+ * A lowercase i in a filled circle, for a message that informs rather than
35
+ * warns; see `checkCirclePath`.
36
+ */
37
+ declare const infoPath = "M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm1 15h-2v-6h2v6zm0-8h-2V7h2v2z";
33
38
  /** A keyboard, which switches a picker to typed entry. */
34
39
  declare const keyboardPath = "M20 5H4c-1.1 0-1.99.9-1.99 2L2 17c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V7c0-1.1-.9-2-2-2zm0 12H4V7h16v10zm-9-9h2v2h-2zm0 3h2v2h-2zM8 8h2v2H8zm0 3h2v2H8zm-3 0h2v2H5zm0-3h2v2H5zm3 6h8v2H8zm6-3h2v2h-2zm0-3h2v2h-2zm3 3h2v2h-2zm0-3h2v2h-2z";
35
40
  /**
@@ -43,4 +48,10 @@ declare const personPath = "M12 12c2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4 1.79
43
48
  declare const plusPath = "M19 13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z";
44
49
  /** A magnifier, as a search field shows. */
45
50
  declare const searchPath = "M15.5 14h-.79l-.28-.27A6.471 6.471 0 0 0 16 9.5 6.5 6.5 0 1 0 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z";
46
- export { arrowBackPath, arrowDownwardPath, arrowDropDownPath, arrowUpwardPath, calendarPath, checkCirclePath, checkPath, chevronDownPath, chevronEndPath, clockPath, closePath, errorPath, gridSize, keyboardPath, minusPath, personPath, plusPath, searchPath };
51
+ /**
52
+ * An exclamation mark in a filled triangle, for a message that warns. Its
53
+ * outline is its own, so it differs from `errorPath` by its shape as well as by
54
+ * its colour.
55
+ */
56
+ declare const warningPath = "M1 21h22L12 2 1 21zm12-3h-2v-2h2v2zm0-4h-2v-4h2v4z";
57
+ export { arrowBackPath, arrowDownwardPath, arrowDropDownPath, arrowUpwardPath, calendarPath, checkCirclePath, checkPath, chevronDownPath, chevronEndPath, clockPath, closePath, errorPath, gridSize, infoPath, keyboardPath, minusPath, personPath, plusPath, searchPath, warningPath };
package/dist/glyphs.js CHANGED
@@ -31,6 +31,11 @@ const clockPath = "M11.99 2C6.47 2 2 6.48 2 12s4.47 10 9.99 10C17.52 22 22 17.52
31
31
  const closePath = "M19 6.41 17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z";
32
32
  /** An exclamation mark in a filled circle; see `checkCirclePath`. */
33
33
  const errorPath = "M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm1 15h-2v-2h2v2zm0-4h-2V7h2v6z";
34
+ /**
35
+ * A lowercase i in a filled circle, for a message that informs rather than
36
+ * warns; see `checkCirclePath`.
37
+ */
38
+ const infoPath = "M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm1 15h-2v-6h2v6zm0-8h-2V7h2v2z";
34
39
  /** A keyboard, which switches a picker to typed entry. */
35
40
  const keyboardPath = "M20 5H4c-1.1 0-1.99.9-1.99 2L2 17c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V7c0-1.1-.9-2-2-2zm0 12H4V7h16v10zm-9-9h2v2h-2zm0 3h2v2h-2zM8 8h2v2H8zm0 3h2v2H8zm-3 0h2v2H5zm0-3h2v2H5zm3 6h8v2H8zm6-3h2v2h-2zm0-3h2v2h-2zm3 3h2v2h-2zm0-3h2v2h-2z";
36
41
  /**
@@ -44,6 +49,12 @@ const personPath = "M12 12c2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4 1.79 4 4 4zm
44
49
  const plusPath = "M19 13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z";
45
50
  /** A magnifier, as a search field shows. */
46
51
  const searchPath = "M15.5 14h-.79l-.28-.27A6.471 6.471 0 0 0 16 9.5 6.5 6.5 0 1 0 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z";
47
- export { arrowBackPath, arrowDownwardPath, arrowDropDownPath, arrowUpwardPath, calendarPath, checkCirclePath, checkPath, chevronDownPath, chevronEndPath, clockPath, closePath, errorPath, gridSize, keyboardPath, minusPath, personPath, plusPath, searchPath };
52
+ /**
53
+ * An exclamation mark in a filled triangle, for a message that warns. Its
54
+ * outline is its own, so it differs from `errorPath` by its shape as well as by
55
+ * its colour.
56
+ */
57
+ const warningPath = "M1 21h22L12 2 1 21zm12-3h-2v-2h2v2zm0-4h-2v-4h2v4z";
58
+ export { arrowBackPath, arrowDownwardPath, arrowDropDownPath, arrowUpwardPath, calendarPath, checkCirclePath, checkPath, chevronDownPath, chevronEndPath, clockPath, closePath, errorPath, gridSize, infoPath, keyboardPath, minusPath, personPath, plusPath, searchPath, warningPath };
48
59
 
49
60
  //# sourceMappingURL=glyphs.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"glyphs.js","names":[],"sources":["../src/glyphs.ts"],"sourcesContent":["// The glyphs both libraries draw inside their own controls, as path data: the\n// check and the dash a checkbox shows, the plus and minus a stepper shows, the\n// magnifier and the cross a search field shows, and the rest below. Each is a\n// Material Symbols path on its 24-unit grid, and neither library writes one of\n// its own.\n//\n// Only the data is published. Each library draws the paths its own way, an\n// inline SVG on the web and react-native-svg on native, and decides there\n// whether a glyph mirrors in a right-to-left layout, since that is how a glyph\n// is drawn rather than what it is. A glyph a call site wants for itself is an\n// icon, which both libraries take as a node; nothing here is offered for that.\n\n/** The side of the square grid every path below is drawn on. */\nconst gridSize = 24\n\n/** An arrow pointing back, at the page a view returns to. */\nconst arrowBackPath =\n 'M20 11H7.83l5.59-5.59L12 4l-8 8 8 8 1.41-1.41L7.83 13H20v-2z'\n\n/** An arrow pointing down, for a column sorted in descending order. */\nconst arrowDownwardPath =\n 'M20 12l-1.41-1.41L13 16.17V4h-2v12.17l-5.58-5.59L4 12l8 8 8-8z'\n\n/** A small solid triangle pointing down, at the list a menu button opens. */\nconst arrowDropDownPath = 'M7 10l5 5 5-5z'\n\n/** An arrow pointing up, for a column sorted in ascending order. */\nconst arrowUpwardPath =\n 'M4 12l1.41 1.41L11 7.83V20h2V7.83l5.58 5.59L20 12l-8-8-8 8z'\n\n/** A calendar, which a date is picked from. */\nconst calendarPath =\n 'M19 4h-1V2h-2v2H8V2H6v2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2V6a2 2 0 0 0-2-2zm0 16H5V10h14v10zm0-12H5V6h14v2z'\n\n/**\n * A check in a filled circle. It shares its outline with `errorPath`, so the\n * two differ by the mark inside rather than by their colour alone.\n */\nconst checkCirclePath =\n 'M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm-2 15-5-5 1.41-1.41L10 14.17l7.59-7.59L19 8l-9 9z'\n\n/** A check mark, as a selected checkbox shows. */\nconst checkPath = 'M9 16.17 4.83 12l-1.42 1.41L9 19 21 7l-1.41-1.41z'\n\n/** A chevron pointing down, at the menu a button opens. */\nconst chevronDownPath = 'M16.59 8.59 12 13.17 7.41 8.59 6 10l6 6 6-6z'\n\n/**\n * A chevron pointing onward, at what an item opens, such as a submenu. It is\n * drawn pointing right, the onward direction in a left-to-right layout.\n */\nconst chevronEndPath = 'M10 6 8.59 7.41 13.17 12l-4.58 4.59L10 18l6-6z'\n\n/** A clock face, which a time is picked from. */\nconst clockPath =\n 'M11.99 2C6.47 2 2 6.48 2 12s4.47 10 9.99 10C17.52 22 22 17.52 22 12S17.52 2 11.99 2zM12 20c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8zm.5-13H11v6l5.25 3.15.75-1.23-4.5-2.67z'\n\n/** A cross, which closes or clears. */\nconst closePath =\n 'M19 6.41 17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z'\n\n/** An exclamation mark in a filled circle; see `checkCirclePath`. */\nconst errorPath =\n 'M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm1 15h-2v-2h2v2zm0-4h-2V7h2v6z'\n\n/** A keyboard, which switches a picker to typed entry. */\nconst keyboardPath =\n 'M20 5H4c-1.1 0-1.99.9-1.99 2L2 17c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V7c0-1.1-.9-2-2-2zm0 12H4V7h16v10zm-9-9h2v2h-2zm0 3h2v2h-2zM8 8h2v2H8zm0 3h2v2H8zm-3 0h2v2H5zm0-3h2v2H5zm3 6h8v2H8zm6-3h2v2h-2zm0-3h2v2h-2zm3 3h2v2h-2zm0-3h2v2h-2z'\n\n/**\n * A horizontal rule, which stands both for a partly selected checkbox and for\n * a stepper's decrement.\n */\nconst minusPath = 'M19 13H5v-2h14v2z'\n\n/** Material Design's anonymous person, a head over shoulders. */\nconst personPath =\n 'M12 12c2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4 1.79 4 4 4zm0 2c-2.67 0-8 1.34-8 4v2h16v-2c0-2.66-5.33-4-8-4z'\n\n/** A plus, as a stepper's increment shows. */\nconst plusPath = 'M19 13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z'\n\n/** A magnifier, as a search field shows. */\nconst searchPath =\n 'M15.5 14h-.79l-.28-.27A6.471 6.471 0 0 0 16 9.5 6.5 6.5 0 1 0 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z'\n\nexport {\n arrowBackPath,\n arrowDownwardPath,\n arrowDropDownPath,\n arrowUpwardPath,\n calendarPath,\n checkCirclePath,\n checkPath,\n chevronDownPath,\n chevronEndPath,\n clockPath,\n closePath,\n errorPath,\n gridSize,\n keyboardPath,\n minusPath,\n personPath,\n plusPath,\n searchPath,\n}\n"],"mappings":";;AAaA,MAAM,WAAW;;AAGjB,MAAM,gBACJ;;AAGF,MAAM,oBACJ;;AAGF,MAAM,oBAAoB;;AAG1B,MAAM,kBACJ;;AAGF,MAAM,eACJ;;;;;AAMF,MAAM,kBACJ;;AAGF,MAAM,YAAY;;AAGlB,MAAM,kBAAkB;;;;;AAMxB,MAAM,iBAAiB;;AAGvB,MAAM,YACJ;;AAGF,MAAM,YACJ;;AAGF,MAAM,YACJ;;AAGF,MAAM,eACJ;;;;;AAMF,MAAM,YAAY;;AAGlB,MAAM,aACJ;;AAGF,MAAM,WAAW;;AAGjB,MAAM,aACJ"}
1
+ {"version":3,"file":"glyphs.js","names":[],"sources":["../src/glyphs.ts"],"sourcesContent":["// The glyphs both libraries draw inside their own controls, as path data: the\n// check and the dash a checkbox shows, the plus and minus a stepper shows, the\n// magnifier and the cross a search field shows, and the rest below. Each is a\n// Material Symbols path on its 24-unit grid, and neither library writes one of\n// its own.\n//\n// The paths are Google's, from the filled 24px set of the Material Design icons\n// (https://github.com/google/material-design-icons), used under the Apache\n// License, Version 2.0. THIRD_PARTY_NOTICES.md, published with the package,\n// carries the attribution and the licence's full text.\n//\n// Only the data is published. Each library draws the paths its own way, an\n// inline SVG on the web and react-native-svg on native, and decides there\n// whether a glyph mirrors in a right-to-left layout, since that is how a glyph\n// is drawn rather than what it is. A glyph a call site wants for itself is an\n// icon, which both libraries take as a node; nothing here is offered for that.\n\n/** The side of the square grid every path below is drawn on. */\nconst gridSize = 24\n\n/** An arrow pointing back, at the page a view returns to. */\nconst arrowBackPath =\n 'M20 11H7.83l5.59-5.59L12 4l-8 8 8 8 1.41-1.41L7.83 13H20v-2z'\n\n/** An arrow pointing down, for a column sorted in descending order. */\nconst arrowDownwardPath =\n 'M20 12l-1.41-1.41L13 16.17V4h-2v12.17l-5.58-5.59L4 12l8 8 8-8z'\n\n/** A small solid triangle pointing down, at the list a menu button opens. */\nconst arrowDropDownPath = 'M7 10l5 5 5-5z'\n\n/** An arrow pointing up, for a column sorted in ascending order. */\nconst arrowUpwardPath =\n 'M4 12l1.41 1.41L11 7.83V20h2V7.83l5.58 5.59L20 12l-8-8-8 8z'\n\n/** A calendar, which a date is picked from. */\nconst calendarPath =\n 'M19 4h-1V2h-2v2H8V2H6v2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2V6a2 2 0 0 0-2-2zm0 16H5V10h14v10zm0-12H5V6h14v2z'\n\n/**\n * A check in a filled circle. It shares its outline with `errorPath`, so the\n * two differ by the mark inside rather than by their colour alone.\n */\nconst checkCirclePath =\n 'M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm-2 15-5-5 1.41-1.41L10 14.17l7.59-7.59L19 8l-9 9z'\n\n/** A check mark, as a selected checkbox shows. */\nconst checkPath = 'M9 16.17 4.83 12l-1.42 1.41L9 19 21 7l-1.41-1.41z'\n\n/** A chevron pointing down, at the menu a button opens. */\nconst chevronDownPath = 'M16.59 8.59 12 13.17 7.41 8.59 6 10l6 6 6-6z'\n\n/**\n * A chevron pointing onward, at what an item opens, such as a submenu. It is\n * drawn pointing right, the onward direction in a left-to-right layout.\n */\nconst chevronEndPath = 'M10 6 8.59 7.41 13.17 12l-4.58 4.59L10 18l6-6z'\n\n/** A clock face, which a time is picked from. */\nconst clockPath =\n 'M11.99 2C6.47 2 2 6.48 2 12s4.47 10 9.99 10C17.52 22 22 17.52 22 12S17.52 2 11.99 2zM12 20c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8zm.5-13H11v6l5.25 3.15.75-1.23-4.5-2.67z'\n\n/** A cross, which closes or clears. */\nconst closePath =\n 'M19 6.41 17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z'\n\n/** An exclamation mark in a filled circle; see `checkCirclePath`. */\nconst errorPath =\n 'M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm1 15h-2v-2h2v2zm0-4h-2V7h2v6z'\n\n/**\n * A lowercase i in a filled circle, for a message that informs rather than\n * warns; see `checkCirclePath`.\n */\nconst infoPath =\n 'M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm1 15h-2v-6h2v6zm0-8h-2V7h2v2z'\n\n/** A keyboard, which switches a picker to typed entry. */\nconst keyboardPath =\n 'M20 5H4c-1.1 0-1.99.9-1.99 2L2 17c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V7c0-1.1-.9-2-2-2zm0 12H4V7h16v10zm-9-9h2v2h-2zm0 3h2v2h-2zM8 8h2v2H8zm0 3h2v2H8zm-3 0h2v2H5zm0-3h2v2H5zm3 6h8v2H8zm6-3h2v2h-2zm0-3h2v2h-2zm3 3h2v2h-2zm0-3h2v2h-2z'\n\n/**\n * A horizontal rule, which stands both for a partly selected checkbox and for\n * a stepper's decrement.\n */\nconst minusPath = 'M19 13H5v-2h14v2z'\n\n/** Material Design's anonymous person, a head over shoulders. */\nconst personPath =\n 'M12 12c2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4 1.79 4 4 4zm0 2c-2.67 0-8 1.34-8 4v2h16v-2c0-2.66-5.33-4-8-4z'\n\n/** A plus, as a stepper's increment shows. */\nconst plusPath = 'M19 13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z'\n\n/** A magnifier, as a search field shows. */\nconst searchPath =\n 'M15.5 14h-.79l-.28-.27A6.471 6.471 0 0 0 16 9.5 6.5 6.5 0 1 0 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z'\n\n/**\n * An exclamation mark in a filled triangle, for a message that warns. Its\n * outline is its own, so it differs from `errorPath` by its shape as well as by\n * its colour.\n */\nconst warningPath = 'M1 21h22L12 2 1 21zm12-3h-2v-2h2v2zm0-4h-2v-4h2v4z'\n\nexport {\n arrowBackPath,\n arrowDownwardPath,\n arrowDropDownPath,\n arrowUpwardPath,\n calendarPath,\n checkCirclePath,\n checkPath,\n chevronDownPath,\n chevronEndPath,\n clockPath,\n closePath,\n errorPath,\n gridSize,\n infoPath,\n keyboardPath,\n minusPath,\n personPath,\n plusPath,\n searchPath,\n warningPath,\n}\n"],"mappings":";;AAkBA,MAAM,WAAW;;AAGjB,MAAM,gBACJ;;AAGF,MAAM,oBACJ;;AAGF,MAAM,oBAAoB;;AAG1B,MAAM,kBACJ;;AAGF,MAAM,eACJ;;;;;AAMF,MAAM,kBACJ;;AAGF,MAAM,YAAY;;AAGlB,MAAM,kBAAkB;;;;;AAMxB,MAAM,iBAAiB;;AAGvB,MAAM,YACJ;;AAGF,MAAM,YACJ;;AAGF,MAAM,YACJ;;;;;AAMF,MAAM,WACJ;;AAGF,MAAM,eACJ;;;;;AAMF,MAAM,YAAY;;AAGlB,MAAM,aACJ;;AAGF,MAAM,WAAW;;AAGjB,MAAM,aACJ;;;;;;AAOF,MAAM,cAAc"}
package/dist/index.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- import { a as ProductThemeError, c as KuiTheme, d as dark, f as light, i as ProductTheme, l as ProductRole, n as ProductColors, o as Scheme, p as productRoles, r as ProductPalette, s as defineProductTheme, t as ContrastFailure, u as breakpoints } from "./product-theme-B_5X3tl7.js";
1
+ import { a as ProductThemeError, c as KuiTheme, d as dark, f as light, i as ProductTheme, l as ProductRole, n as ProductColors, o as Scheme, p as productRoles, r as ProductPalette, s as defineProductTheme, t as ContrastFailure, u as breakpoints } from "./product-theme-3Lr4V69h.js";
2
2
  export { type ContrastFailure, type KuiTheme, type ProductColors, type ProductPalette, type ProductRole, type ProductTheme, ProductThemeError, type Scheme, breakpoints, dark, defineProductTheme, light, productRoles };
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- export { t as ProductThemeError, r as breakpoints, i as dark, n as defineProductTheme, a as light, o as productRoles } from "./product-theme-BpaQ7tJd.js";
1
+ export { t as ProductThemeError, r as breakpoints, i as dark, n as defineProductTheme, a as light, o as productRoles } from "./product-theme-CUG5I7M_.js";
@@ -738,7 +738,11 @@ type ProductRole = (typeof productRoles)[number];
738
738
  type ContrastFailure = {
739
739
  /** The colour drawn, by its name without `--kui-color-`, such as `on-accent`. */
740
740
  readonly foreground: string;
741
- /** The colour the foreground is drawn on, `a over b` for a translucent `a` painted on `b`. */
741
+ /**
742
+ * The colour the foreground is drawn on: `a over b` for a translucent `a`
743
+ * painted on `b`, and `a at pressed` for `a` at the strength of Kanso's
744
+ * pressed state layer, as a control's hover and pressed states are drawn.
745
+ */
742
746
  readonly ground: string;
743
747
  /** The ratio it is drawn at. */
744
748
  readonly ratio: number;
@@ -747,8 +751,15 @@ type ContrastFailure = {
747
751
  /** WCAG 2's bar: 4.5 for text, 3 for everything else. */
748
752
  readonly target: number;
749
753
  };
750
- /** One scheme's product colours: a `#rrggbb` or `rgba()` value for every role. */
751
- type ProductColors = { readonly [Role in ProductRole]: string; };
754
+ /** The product role a palette may leave for defineProductTheme to work out. */
755
+ type OptionalRole = 'spotlightTonal';
756
+ /**
757
+ * One scheme's product colours: a `#rrggbb` or `rgba()` value for every role.
758
+ * `spotlightTonal` may be left out, and is then as much of `onSpotlight` mixed
759
+ * into `spotlight`, up to Kanso's 16%, as keeps `onSpotlight` at 4.5:1 on it
760
+ * under the pressed state layer.
761
+ */
762
+ type ProductColors = { readonly [Role in Exclude<ProductRole, OptionalRole>]: string; } & { readonly [Role in OptionalRole]?: string; };
752
763
  /** A product's colours in each scheme: what a product keeps as data. */
753
764
  type ProductPalette = {
754
765
  readonly dark: ProductColors;
@@ -787,6 +798,10 @@ declare class ProductThemeError extends Error {
787
798
  * the other Material Design roles that alias the accent included, and
788
799
  * everything else keeps its default.
789
800
  *
801
+ * A palette that leaves out `spotlightTonal` has it worked out: as much of
802
+ * `onSpotlight` mixed into `spotlight`, up to Kanso's 16%, as keeps
803
+ * `onSpotlight` at 4.5:1 on it under the pressed state layer.
804
+ *
790
805
  * The colours are held to Kanso's contrast targets, WCAG 2's 4.5:1 for text
791
806
  * and 3:1 for the rest, in both schemes, over the same pairs the base clears:
792
807
  * those Kanso's usage notes name and those both libraries draw. A palette
@@ -61,6 +61,16 @@ const kansoPairs = [
61
61
  "spotlight-tonal over spotlight",
62
62
  TEXT
63
63
  ],
64
+ [
65
+ "on-spotlight",
66
+ "on-spotlight at hover over spotlight-tonal over spotlight",
67
+ TEXT
68
+ ],
69
+ [
70
+ "on-spotlight",
71
+ "on-spotlight at pressed over spotlight-tonal over spotlight",
72
+ TEXT
73
+ ],
64
74
  [
65
75
  "on-spotlight-button",
66
76
  "spotlight-button",
@@ -295,10 +305,17 @@ function luminance([red, green, blue]) {
295
305
  });
296
306
  return .2126 * r + .7152 * g + .0722 * b;
297
307
  }
298
- /** A colour painted over an opaque ground, as the eye sees it. */
299
- function over(color, ground) {
300
- const [red, green, blue, alpha] = parseColor(color);
301
- const mix = (top, bottom) => top * alpha + bottom * (1 - alpha);
308
+ /**
309
+ * A colour painted over an opaque ground, as the screen draws it, at
310
+ * `opacity` of its own alpha: a state layer is its colour at the layer's
311
+ * strength. A browser composites each layer into 8 bits a channel, so each
312
+ * channel is rounded, and a stack of layers is rounded at every step: a ratio
313
+ * worked out in floating point can clear 4.5:1 while the colour drawn misses.
314
+ */
315
+ function over(color, ground, opacity = 1) {
316
+ const [red, green, blue, colorAlpha] = parseColor(color);
317
+ const alpha = colorAlpha * opacity;
318
+ const mix = (top, bottom) => Math.round(top * alpha + bottom * (1 - alpha));
302
319
  return [
303
320
  mix(red, ground[0]),
304
321
  mix(green, ground[1]),
@@ -341,18 +358,103 @@ function parseColor(color) {
341
358
  }
342
359
  throw new TypeError(`not a #rrggbb or rgba() colour: ${color}`);
343
360
  }
344
- /** A pair's ratio in a scheme, its ground resolved first. */
361
+ /**
362
+ * A pair's ratio in a scheme, its ground resolved first: each layer of
363
+ * `a over b over c` painted from the bottom up, and `a at hover` painted at
364
+ * the strength of Kanso's hover state layer.
365
+ */
345
366
  function ratioOf(scheme, foreground, ground) {
346
- const colorOf = (name) => {
347
- const value = scheme[`--kui-color-${name}`];
348
- if (value === void 0) throw new Error(`no colour ${name}`);
367
+ const valueOf = (property) => {
368
+ const value = scheme[property];
369
+ if (value === void 0) throw new Error(`no ${property}`);
349
370
  return value;
350
371
  };
351
- const [top = "", under = top] = ground.split(" over ");
352
- const base = parseColor(colorOf(under));
353
- const grounded = top === under ? base : over(colorOf(top), base);
372
+ const colorOf = (name) => valueOf(`--kui-color-${name}`);
373
+ const [bottom = ground, ...above] = ground.split(" over ").toReversed();
374
+ const grounded = above.reduce((under, layer) => {
375
+ const [name = layer, ...state] = layer.split(" at ");
376
+ const opacity = state.reduce((strength, step) => strength * Number(valueOf(`--kui-state-layer-opacity-kanso-${step}`)), 1);
377
+ return over(colorOf(name), under, opacity);
378
+ }, parseColor(colorOf(bottom)));
354
379
  return contrast(over(colorOf(foreground), grounded), grounded);
355
380
  }
381
+ const TONAL_STRENGTH = 160;
382
+ const AIM = 4.55;
383
+ function hexOf([red, green, blue]) {
384
+ return `#${[
385
+ red,
386
+ green,
387
+ blue
388
+ ].map((channel) => channel.toString(16).padStart(2, "0")).join("")}`;
389
+ }
390
+ /**
391
+ * A status colour a scheme inherits, as text on the scheme's own grounds: the
392
+ * colour itself where it clears 4.55:1 on every ground, and otherwise the
393
+ * least shade of it that does, mixed toward black on a ground lighter than
394
+ * the colour and toward white on a darker one, in thousandths, so the hue
395
+ * stays. Where even black or white misses, it is that, and the pairs name
396
+ * the miss.
397
+ */
398
+ function statusShade(color, grounds) {
399
+ const base = parseColor(color);
400
+ const under = grounds.map((ground) => parseColor(ground));
401
+ const toward = under.every((ground) => luminance(ground) >= luminance(base)) ? [
402
+ 0,
403
+ 0,
404
+ 0,
405
+ 1
406
+ ] : [
407
+ 255,
408
+ 255,
409
+ 255,
410
+ 1
411
+ ];
412
+ const shadeAt = (thousandths) => {
413
+ const strength = thousandths / 1e3;
414
+ const mix = (top, bottom) => Math.round(top * strength + bottom * (1 - strength));
415
+ return [
416
+ mix(toward[0], base[0]),
417
+ mix(toward[1], base[1]),
418
+ mix(toward[2], base[2]),
419
+ 1
420
+ ];
421
+ };
422
+ const clears = (shade) => under.every((ground) => contrast(shade, ground) >= AIM);
423
+ let thousandths = 0;
424
+ while (thousandths < 1e3 && !clears(shadeAt(thousandths))) thousandths += 1;
425
+ return thousandths === 0 ? color : hexOf(shadeAt(thousandths));
426
+ }
427
+ /**
428
+ * The spotlight's tonal fill for a scheme that sets no fill of its own: as
429
+ * much of `onSpotlight` mixed into `spotlight` as keeps `onSpotlight` at
430
+ * 4.55:1 on it with the pressed state layer, `pressed`, painted over it, up
431
+ * to Kanso's 16%: a margin over 4.5:1 for a browser that rounds a channel a
432
+ * step the other way. The hover layer is lighter than the pressed one, so
433
+ * the label clears it too. Where even the bare spotlight falls short of the
434
+ * aim under the pressed layer, the fill is the spotlight itself, and the
435
+ * pressed pair names a miss of 4.5:1.
436
+ */
437
+ function tonalFill(spotlight, onSpotlight, pressed) {
438
+ const ground = parseColor(spotlight);
439
+ const content = over(onSpotlight, ground);
440
+ const fillAt = (thousandths) => {
441
+ const strength = thousandths / 1e3;
442
+ const mix = (top, bottom) => Math.round(top * strength + bottom * (1 - strength));
443
+ return [
444
+ mix(content[0], ground[0]),
445
+ mix(content[1], ground[1]),
446
+ mix(content[2], ground[2]),
447
+ 1
448
+ ];
449
+ };
450
+ const clears = (fill) => {
451
+ const layer = over(onSpotlight, fill, pressed);
452
+ return contrast(over(onSpotlight, layer), layer) >= AIM;
453
+ };
454
+ let thousandths = TONAL_STRENGTH;
455
+ while (thousandths > 0 && !clears(fillAt(thousandths))) thousandths -= 1;
456
+ return hexOf(fillAt(thousandths));
457
+ }
356
458
  // src/tokens/defaults.ts
357
459
  /** Every property at its value in the light scheme, as `tokens.css` declares it. */
358
460
  const light = {
@@ -947,6 +1049,10 @@ const SCHEMES = ["light", "dark"];
947
1049
  * the other Material Design roles that alias the accent included, and
948
1050
  * everything else keeps its default.
949
1051
  *
1052
+ * A palette that leaves out `spotlightTonal` has it worked out: as much of
1053
+ * `onSpotlight` mixed into `spotlight`, up to Kanso's 16%, as keeps
1054
+ * `onSpotlight` at 4.5:1 on it under the pressed state layer.
1055
+ *
950
1056
  * The colours are held to Kanso's contrast targets, WCAG 2's 4.5:1 for text
951
1057
  * and 3:1 for the rest, in both schemes, over the same pairs the base clears:
952
1058
  * those Kanso's usage notes name and those both libraries draw. A palette
@@ -971,11 +1077,25 @@ function defineProductTheme(palette) {
971
1077
  const roles = productRoles;
972
1078
  const unknown = [...colors.keys()].filter((role) => !roles.includes(role));
973
1079
  if (unknown.length > 0) throw new TypeError(`${scheme} has no product role ${unknown.join(", ")}; the roles are ${roles.join(", ")}`);
974
- for (const role of productRoles) if (!isColor(colors.get(role))) throw new TypeError(`${scheme}.${role} takes a #rrggbb or rgba() colour, not ${String(colors.get(role))}`);
1080
+ for (const role of productRoles) {
1081
+ if (role === "spotlightTonal" && colors.get(role) === void 0) continue;
1082
+ if (!isColor(colors.get(role))) throw new TypeError(`${scheme}.${role} takes a #rrggbb or rgba() colour, not ${String(colors.get(role))}`);
1083
+ }
975
1084
  }
1085
+ const filled = (scheme) => {
1086
+ const colors = palette[scheme];
1087
+ return {
1088
+ ...colors,
1089
+ spotlightTonal: colors.spotlightTonal ?? tonalFill(colors.spotlight, colors.onSpotlight, Number(DEFAULTS[scheme]["--kui-state-layer-opacity-kanso-pressed"]))
1090
+ };
1091
+ };
1092
+ const resolved = {
1093
+ dark: filled("dark"),
1094
+ light: filled("light")
1095
+ };
976
1096
  const followed = (scheme) => ({
977
1097
  ...DEFAULTS[scheme],
978
- ...Object.fromEntries(Object.entries(productFollowers[scheme]).map(([property, from]) => [property, palette[from[0]][from[1]]]))
1098
+ ...Object.fromEntries(Object.entries(productFollowers[scheme]).map(([property, from]) => [property, resolved[from[0]][from[1]]]))
979
1099
  });
980
1100
  const maps = {
981
1101
  dark: followed("dark"),
@@ -1007,6 +1127,6 @@ function defineProductTheme(palette) {
1007
1127
  })
1008
1128
  });
1009
1129
  }
1010
- export { light as a, dark as i, defineProductTheme as n, productRoles as o, breakpoints as r, ProductThemeError as t };
1130
+ export { light as a, tonalFill as c, dark as i, defineProductTheme as n, productRoles as o, breakpoints as r, statusShade as s, ProductThemeError as t };
1011
1131
 
1012
- //# sourceMappingURL=product-theme-BpaQ7tJd.js.map
1132
+ //# sourceMappingURL=product-theme-CUG5I7M_.js.map