@getaster/elements 0.0.0-stage → 0.1.0-preview.1
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 +202 -0
- package/NOTICE +10 -0
- package/README.md +6 -2
- package/bin/aster-theme-check.js +317 -0
- package/dist/base/drag.d.ts +45 -0
- package/dist/base/drag.js +139 -0
- package/dist/base/element.d.ts +51 -0
- package/dist/base/element.js +133 -0
- package/dist/breadcrumbs/breadcrumbs.d.ts +23 -0
- package/dist/breadcrumbs/breadcrumbs.js +51 -0
- package/dist/button/button.d.ts +37 -0
- package/dist/button/button.js +108 -0
- package/dist/caret/caret-group.d.ts +14 -0
- package/dist/caret/caret-group.js +71 -0
- package/dist/carousel/carousel.d.ts +28 -0
- package/dist/carousel/carousel.js +134 -0
- package/dist/component/component.d.ts +73 -0
- package/dist/component/component.js +190 -0
- package/dist/component/echarts.d.ts +46 -0
- package/dist/component/echarts.js +95 -0
- package/dist/composition/authoring.d.ts +157 -0
- package/dist/composition/authoring.js +291 -0
- package/dist/composition/builtins.d.ts +1130 -0
- package/dist/composition/builtins.js +318 -0
- package/dist/composition/command-bar.d.ts +18 -0
- package/dist/composition/command-bar.js +34 -0
- package/dist/composition/commands.d.ts +14 -0
- package/dist/composition/commands.js +59 -0
- package/dist/composition/composite.d.ts +48 -0
- package/dist/composition/composite.js +409 -0
- package/dist/composition/contracts.d.ts +63 -0
- package/dist/composition/contracts.js +97 -0
- package/dist/composition/definition.d.ts +94 -0
- package/dist/composition/definition.js +291 -0
- package/dist/composition/element.d.ts +35 -0
- package/dist/composition/element.js +51 -0
- package/dist/composition/registry.d.ts +83 -0
- package/dist/composition/registry.js +99 -0
- package/dist/composition/schema.d.ts +9 -0
- package/dist/composition/schema.js +139 -0
- package/dist/composition/sessions.d.ts +15 -0
- package/dist/composition/sessions.js +61 -0
- package/dist/dashboard/dashboard.d.ts +26 -0
- package/dist/dashboard/dashboard.js +296 -0
- package/dist/dashboard/layout.d.ts +19 -0
- package/dist/dashboard/layout.js +48 -0
- package/dist/dashboard/widget.d.ts +42 -0
- package/dist/dashboard/widget.js +165 -0
- package/dist/date/calendar.d.ts +34 -0
- package/dist/date/calendar.js +137 -0
- package/dist/date/date-field.d.ts +18 -0
- package/dist/date/date-field.js +81 -0
- package/dist/date/dates.d.ts +22 -0
- package/dist/date/dates.js +80 -0
- package/dist/dialog/dialog.d.ts +23 -0
- package/dist/dialog/dialog.js +70 -0
- package/dist/field/bound-field.d.ts +55 -0
- package/dist/field/bound-field.js +139 -0
- package/dist/field/check.d.ts +11 -0
- package/dist/field/check.js +26 -0
- package/dist/field/composite-field.d.ts +35 -0
- package/dist/field/composite-field.js +88 -0
- package/dist/field/field.d.ts +29 -0
- package/dist/field/field.js +75 -0
- package/dist/field/input.d.ts +15 -0
- package/dist/field/input.js +18 -0
- package/dist/field/number-field.d.ts +33 -0
- package/dist/field/number-field.js +179 -0
- package/dist/field/numeric.d.ts +4 -0
- package/dist/field/numeric.js +57 -0
- package/dist/field/values.d.ts +14 -0
- package/dist/field/values.js +60 -0
- package/dist/filter/filter-builder.d.ts +18 -0
- package/dist/filter/filter-builder.js +305 -0
- package/dist/form/controls.d.ts +20 -0
- package/dist/form/controls.js +34 -0
- package/dist/form/form.d.ts +46 -0
- package/dist/form/form.js +85 -0
- package/dist/format.d.ts +10 -0
- package/dist/format.js +57 -0
- package/dist/grid/filters.d.ts +16 -0
- package/dist/grid/filters.js +66 -0
- package/dist/grid/grid.d.ts +209 -0
- package/dist/grid/grid.js +2587 -0
- package/dist/grid/rows.d.ts +32 -0
- package/dist/grid/rows.js +89 -0
- package/dist/grid/view.d.ts +69 -0
- package/dist/grid/view.js +172 -0
- package/dist/index.d.ts +63 -0
- package/dist/index.js +61 -0
- package/dist/layout/stack.d.ts +112 -0
- package/dist/layout/stack.js +21 -0
- package/dist/list-edit/list-edit.d.ts +42 -0
- package/dist/list-edit/list-edit.js +220 -0
- package/dist/listbox/listbox.d.ts +45 -0
- package/dist/listbox/listbox.js +187 -0
- package/dist/menu/menu.d.ts +55 -0
- package/dist/menu/menu.js +286 -0
- package/dist/motion.d.ts +8 -0
- package/dist/motion.js +23 -0
- package/dist/overlay/anchor.d.ts +18 -0
- package/dist/overlay/anchor.js +41 -0
- package/dist/picker/options.d.ts +59 -0
- package/dist/picker/options.js +97 -0
- package/dist/picker/picker.d.ts +46 -0
- package/dist/picker/picker.js +492 -0
- package/dist/picker/tree-choices.d.ts +38 -0
- package/dist/picker/tree-choices.js +72 -0
- package/dist/picker/tree-picker.d.ts +29 -0
- package/dist/picker/tree-picker.js +282 -0
- package/dist/progress/policy.d.ts +5 -0
- package/dist/progress/policy.js +28 -0
- package/dist/progress/status.d.ts +20 -0
- package/dist/progress/status.js +38 -0
- package/dist/rule/operators.d.ts +8 -0
- package/dist/rule/operators.js +9 -0
- package/dist/rule/rule-editor.d.ts +57 -0
- package/dist/rule/rule-editor.js +290 -0
- package/dist/section/accordion.d.ts +24 -0
- package/dist/section/accordion.js +90 -0
- package/dist/section/section.d.ts +30 -0
- package/dist/section/section.js +99 -0
- package/dist/select/choice-element.d.ts +20 -0
- package/dist/select/choice-element.js +55 -0
- package/dist/select/choice.d.ts +34 -0
- package/dist/select/choice.js +122 -0
- package/dist/select/many.d.ts +13 -0
- package/dist/select/many.js +20 -0
- package/dist/select/select.d.ts +16 -0
- package/dist/select/select.js +40 -0
- package/dist/sidebar/sidebar.d.ts +47 -0
- package/dist/sidebar/sidebar.js +105 -0
- package/dist/slicer/slicer.d.ts +26 -0
- package/dist/slicer/slicer.js +140 -0
- package/dist/split/split.d.ts +41 -0
- package/dist/split/split.js +237 -0
- package/dist/styles/contract.d.ts +36 -0
- package/dist/styles/contract.js +39 -0
- package/dist/switch/switch.d.ts +22 -0
- package/dist/switch/switch.js +69 -0
- package/dist/tabs/tabs.d.ts +30 -0
- package/dist/tabs/tabs.js +202 -0
- package/dist/tile-grid/scroll.d.ts +9 -0
- package/dist/tile-grid/scroll.js +21 -0
- package/dist/tile-grid/tile-grid.d.ts +64 -0
- package/dist/tile-grid/tile-grid.js +734 -0
- package/dist/toast/toast.d.ts +25 -0
- package/dist/toast/toast.js +92 -0
- package/dist/tree/navigator.d.ts +41 -0
- package/dist/tree/navigator.js +228 -0
- package/dist/window/chrome.d.ts +3 -0
- package/dist/window/chrome.js +7 -0
- package/dist/window/window.d.ts +46 -0
- package/dist/window/window.js +347 -0
- package/dist/window/workspace.d.ts +29 -0
- package/dist/window/workspace.js +137 -0
- package/package.json +45 -4
- package/styles/aster-ui.css +1147 -0
- package/styles/base.css +88 -0
- package/styles/contract.ts +41 -0
- package/styles/elements.css +1058 -0
- package/styles/harbour.css +126 -0
- package/styles/lamplight.css +118 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
package/NOTICE
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
Aster UI
|
|
2
|
+
Copyright 2026 Aster UI contributors
|
|
3
|
+
|
|
4
|
+
Aster UI source and the separately supplied OData mock WebAssembly binary are
|
|
5
|
+
licensed under the Apache License, Version 2.0. Third-party components retain
|
|
6
|
+
their respective licenses. The binary's attribution inventory and license texts
|
|
7
|
+
are supplied in packages/mock/wasm/; packages include those notices when shipped.
|
|
8
|
+
|
|
9
|
+
Geist and IBM Plex Mono fonts retain their SIL Open Font License notices.
|
|
10
|
+
ECharts is an optional separately loaded third-party runtime.
|
package/README.md
CHANGED
|
@@ -1,3 +1,7 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @getaster/elements
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Aster UI elements.
|
|
4
|
+
|
|
5
|
+
Documentation: https://ui.getaster.now/docs/guide/library.html
|
|
6
|
+
|
|
7
|
+
Licensed under Apache-2.0. See LICENSE and NOTICE.
|
|
@@ -0,0 +1,317 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// @bun
|
|
3
|
+
|
|
4
|
+
// packages/elements/tools/aster-theme-check.ts
|
|
5
|
+
import { readFileSync } from "fs";
|
|
6
|
+
|
|
7
|
+
// packages/elements/src/styles/contract.ts
|
|
8
|
+
var TOKENS = {
|
|
9
|
+
type: [
|
|
10
|
+
"font-ui",
|
|
11
|
+
"font-figure",
|
|
12
|
+
"font-size",
|
|
13
|
+
"line",
|
|
14
|
+
"weight",
|
|
15
|
+
"weight-strong",
|
|
16
|
+
"weight-label",
|
|
17
|
+
"figure-settings",
|
|
18
|
+
"title-settings",
|
|
19
|
+
"heading-settings",
|
|
20
|
+
"prose-settings"
|
|
21
|
+
],
|
|
22
|
+
surfaces: ["page", "surface", "sunk", "pane", "backdrop", "frame", "texture", "texture-blend", "texture-opacity"],
|
|
23
|
+
text: ["text", "text-2", "text-3"],
|
|
24
|
+
edges: ["rule", "rule-2", "mark-ring"],
|
|
25
|
+
accent: ["accent", "accent-hi", "accent-soft", "on-accent", "accent-sheen", "focus", "focus-offset", "indicator"],
|
|
26
|
+
status: ["positive", "negative", "caution"],
|
|
27
|
+
identity: ["identity-l", "identity-c"],
|
|
28
|
+
elevation: ["shadow", "highlight", "ring", "e1", "e2", "e3", "well", "scrim", "press"],
|
|
29
|
+
shape: ["r-ctl", "r-card", "r-pop", "r-dialog"],
|
|
30
|
+
motion: ["ease", "t-morph", "t-ink", "t-micro", "t-caret", "t-scheme"],
|
|
31
|
+
toast: ["toast-bg", "toast-text", "toast-action", "toast-mark"],
|
|
32
|
+
light: ["lamp", "glow", "lamp-bulb"]
|
|
33
|
+
};
|
|
34
|
+
var TOKEN_NAMES = Object.values(TOKENS).flat().map((t) => `--aster-${t}`);
|
|
35
|
+
var DENSITY = ["ctl", "ctl-tight", "pad-y", "row-y", "pad", "gap"];
|
|
36
|
+
var DENSITY_NAMES = DENSITY.map((t) => `--aster-${t}`);
|
|
37
|
+
|
|
38
|
+
// packages/elements/tools/theme-check.ts
|
|
39
|
+
var PAIRS = [
|
|
40
|
+
["text", "surface", 4.5],
|
|
41
|
+
["text", "page", 4.5],
|
|
42
|
+
["text", "sunk", 4.5],
|
|
43
|
+
["text-2", "surface", 4.5],
|
|
44
|
+
["text-2", "sunk", 4.5],
|
|
45
|
+
["text-2", "page", 4.5],
|
|
46
|
+
["text-3", "surface", 4.5],
|
|
47
|
+
["text-3", "page", 4.5],
|
|
48
|
+
["text", "accent-soft", 4.5],
|
|
49
|
+
["text-2", "accent-soft", 4.5],
|
|
50
|
+
["text-3", "accent-soft", 4.5],
|
|
51
|
+
["accent", "surface", 4.5],
|
|
52
|
+
["on-accent", "accent", 4.5],
|
|
53
|
+
["on-accent", "accent-hi", 4.5],
|
|
54
|
+
["negative", "surface", 4.5],
|
|
55
|
+
["positive", "surface", 3],
|
|
56
|
+
["caution", "surface", 3],
|
|
57
|
+
["focus", "surface", 3],
|
|
58
|
+
["indicator", "surface", 3],
|
|
59
|
+
["toast-text", "toast-bg", 4.5],
|
|
60
|
+
["toast-action", "toast-bg", 4.5]
|
|
61
|
+
];
|
|
62
|
+
function identities(css) {
|
|
63
|
+
const text = css.replace(/\/\*[\s\S]*?\*\//g, "");
|
|
64
|
+
const found = new Map;
|
|
65
|
+
for (const m of text.matchAll(/([^{}]+)\{([^{}]*)\}/g)) {
|
|
66
|
+
const selector = m[1].trim();
|
|
67
|
+
if (selector.startsWith("@") || !selector.includes(":root"))
|
|
68
|
+
continue;
|
|
69
|
+
const name = /\[data-identity="([^"]+)"\]/.exec(selector)?.[1] ?? "";
|
|
70
|
+
const dark = /\[data-scheme="dark"\]/.test(selector);
|
|
71
|
+
let entry = found.get(name);
|
|
72
|
+
if (!entry)
|
|
73
|
+
found.set(name, entry = { light: new Map, dark: new Map });
|
|
74
|
+
for (const d of declarations(m[2]))
|
|
75
|
+
(dark ? entry.dark : entry.light).set(d[0], d[1]);
|
|
76
|
+
}
|
|
77
|
+
return [...found].map(([name, e]) => ({ name, light: e.light, dark: e.dark }));
|
|
78
|
+
}
|
|
79
|
+
function declarations(body) {
|
|
80
|
+
const out = [];
|
|
81
|
+
for (const m of body.matchAll(/(--[\w-]+)\s*:\s*((?:url\("[^"]*"\)|[^;])+);?/g))
|
|
82
|
+
out.push([m[1], m[2].trim()]);
|
|
83
|
+
return out;
|
|
84
|
+
}
|
|
85
|
+
function check(identity) {
|
|
86
|
+
const errors = [];
|
|
87
|
+
const warnings = [];
|
|
88
|
+
const known = new Set(TOKEN_NAMES);
|
|
89
|
+
const missing = TOKEN_NAMES.filter((t) => !identity.light.has(t));
|
|
90
|
+
if (missing.length)
|
|
91
|
+
errors.push({ scheme: "light", message: `missing ${missing.join(", ")}` });
|
|
92
|
+
for (const [scheme, values] of [["light", identity.light], ["dark", identity.dark]]) {
|
|
93
|
+
const unknown = [...values.keys()].filter((t) => t.startsWith("--aster-") && !known.has(t));
|
|
94
|
+
if (unknown.length)
|
|
95
|
+
errors.push({ scheme, message: `not in the contract (misspelt?): ${unknown.join(", ")}` });
|
|
96
|
+
}
|
|
97
|
+
const schemes = [["light", new Map(identity.light)]];
|
|
98
|
+
if (identity.dark.size)
|
|
99
|
+
schemes.push(["dark", new Map([...identity.light, ...identity.dark])]);
|
|
100
|
+
for (const [scheme, values] of schemes) {
|
|
101
|
+
for (const [fg, bg, min] of PAIRS) {
|
|
102
|
+
const background = resolve(values, `--aster-${bg}`, new Set);
|
|
103
|
+
const foreground = resolve(values, `--aster-${fg}`, new Set);
|
|
104
|
+
if (!background || !foreground) {
|
|
105
|
+
const which = [!foreground ? fg : "", !background ? bg : ""].filter(Boolean).join(" and ");
|
|
106
|
+
warnings.push({ scheme, message: `can't evaluate ${which} to check ${fg} on ${bg}` });
|
|
107
|
+
continue;
|
|
108
|
+
}
|
|
109
|
+
const surface = resolve(values, "--aster-surface", new Set) ?? WHITE;
|
|
110
|
+
const under = over(background, over(surface, WHITE));
|
|
111
|
+
const ratio = contrast(over(foreground, under), under);
|
|
112
|
+
if (ratio + 0.000000001 < min)
|
|
113
|
+
errors.push({ scheme, message: `${fg} on ${bg} is ${ratio.toFixed(2)}:1; needs ${min}:1` });
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
return { identity: identity.name || "default", errors, warnings };
|
|
117
|
+
}
|
|
118
|
+
var WHITE = { r: 1, g: 1, b: 1, a: 1 };
|
|
119
|
+
function resolve(values, name, seen) {
|
|
120
|
+
if (seen.has(name))
|
|
121
|
+
return;
|
|
122
|
+
seen.add(name);
|
|
123
|
+
const value = values.get(name);
|
|
124
|
+
return value === undefined ? undefined : parseColor(value, (n) => resolve(values, n, new Set(seen)));
|
|
125
|
+
}
|
|
126
|
+
function parseColor(text, lookup = () => {
|
|
127
|
+
return;
|
|
128
|
+
}) {
|
|
129
|
+
const t = text.trim();
|
|
130
|
+
const v = /^var\((--[\w-]+)\)$/.exec(t);
|
|
131
|
+
if (v)
|
|
132
|
+
return lookup(v[1]);
|
|
133
|
+
if (t === "transparent")
|
|
134
|
+
return { r: 0, g: 0, b: 0, a: 0 };
|
|
135
|
+
const hex = /^#([0-9a-f]{3,8})$/i.exec(t)?.[1];
|
|
136
|
+
if (hex)
|
|
137
|
+
return parseHex(hex);
|
|
138
|
+
const fn = /^([a-z-]+)\((.*)\)$/is.exec(t);
|
|
139
|
+
if (!fn)
|
|
140
|
+
return;
|
|
141
|
+
const [, name, args] = fn;
|
|
142
|
+
switch (name.toLowerCase()) {
|
|
143
|
+
case "rgb":
|
|
144
|
+
case "rgba": {
|
|
145
|
+
const n = args.split(/[\s,/]+/).filter(Boolean).map((p) => p.endsWith("%") ? parseFloat(p) / 100 : parseFloat(p));
|
|
146
|
+
if (n.length < 3 || n.some(Number.isNaN))
|
|
147
|
+
return;
|
|
148
|
+
return { r: n[0] / 255, g: n[1] / 255, b: n[2] / 255, a: n[3] ?? 1 };
|
|
149
|
+
}
|
|
150
|
+
case "oklch":
|
|
151
|
+
return oklch(args, lookup);
|
|
152
|
+
case "color-mix":
|
|
153
|
+
return colorMix(args, lookup);
|
|
154
|
+
default:
|
|
155
|
+
return;
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
function parseHex(h) {
|
|
159
|
+
const full = h.length <= 4 ? [...h].map((c) => c + c).join("") : h;
|
|
160
|
+
if (full.length !== 6 && full.length !== 8)
|
|
161
|
+
return;
|
|
162
|
+
const n = (i) => parseInt(full.slice(i, i + 2), 16) / 255;
|
|
163
|
+
return { r: n(0), g: n(2), b: n(4), a: full.length === 8 ? n(6) : 1 };
|
|
164
|
+
}
|
|
165
|
+
function oklch(args, lookup) {
|
|
166
|
+
const [main, alphaText] = splitAlpha(args);
|
|
167
|
+
const alpha = alphaText === undefined ? undefined : number(alphaText);
|
|
168
|
+
const from = /^from\s+(var\([^)]*\)|#[0-9a-f]+|\w+\([^)]*\))\s+(.*)$/i.exec(main);
|
|
169
|
+
if (from) {
|
|
170
|
+
const base = parseColor(from[1], lookup);
|
|
171
|
+
if (!base)
|
|
172
|
+
return;
|
|
173
|
+
const [l, c, h] = toOklch(base);
|
|
174
|
+
const parts = splitTop(from[2]);
|
|
175
|
+
if (parts.length !== 3)
|
|
176
|
+
return;
|
|
177
|
+
const channel = (p, own, key) => {
|
|
178
|
+
if (p === key)
|
|
179
|
+
return own;
|
|
180
|
+
const calc = new RegExp(`^calc\\(${key}\\s*([+-])\\s*([\\d.]+)\\)$`).exec(p);
|
|
181
|
+
return calc ? own + (calc[1] === "+" ? 1 : -1) * Number(calc[2]) : number(p);
|
|
182
|
+
};
|
|
183
|
+
const L = channel(parts[0], l, "l");
|
|
184
|
+
const C = channel(parts[1], c, "c");
|
|
185
|
+
const H = channel(parts[2], h, "h");
|
|
186
|
+
if ([L, C, H].some((x) => x === undefined || Number.isNaN(x)))
|
|
187
|
+
return;
|
|
188
|
+
return { ...fromOklch(L, C, H), a: alpha ?? base.a };
|
|
189
|
+
}
|
|
190
|
+
const parts = main.split(/\s+/).filter(Boolean);
|
|
191
|
+
if (parts.length !== 3)
|
|
192
|
+
return;
|
|
193
|
+
const L = parts[0].endsWith("%") ? parseFloat(parts[0]) / 100 : number(parts[0]);
|
|
194
|
+
const C = number(parts[1]);
|
|
195
|
+
const H = parts[2] === "none" ? 0 : number(parts[2]);
|
|
196
|
+
if ([L, C, H, alpha].some((x) => x !== undefined && Number.isNaN(x)) || L === undefined || C === undefined || H === undefined)
|
|
197
|
+
return;
|
|
198
|
+
return { ...fromOklch(L, C, H), a: alpha ?? 1 };
|
|
199
|
+
}
|
|
200
|
+
function colorMix(args, lookup) {
|
|
201
|
+
const parts = splitTop(args, ",");
|
|
202
|
+
if (parts.length !== 3 || parts[0].trim() !== "in srgb")
|
|
203
|
+
return;
|
|
204
|
+
const item = (p) => {
|
|
205
|
+
const m = /^(.*?)\s+([\d.]+)%$/.exec(p.trim());
|
|
206
|
+
return { color: parseColor(m ? m[1] : p, lookup), pct: m ? Number(m[2]) / 100 : undefined };
|
|
207
|
+
};
|
|
208
|
+
const a = item(parts[1]);
|
|
209
|
+
const b = item(parts[2]);
|
|
210
|
+
if (!a.color || !b.color)
|
|
211
|
+
return;
|
|
212
|
+
const pa = a.pct ?? (b.pct === undefined ? 0.5 : 1 - b.pct);
|
|
213
|
+
const pb = b.pct ?? 1 - pa;
|
|
214
|
+
const alpha = a.color.a * pa + b.color.a * pb;
|
|
215
|
+
if (alpha === 0)
|
|
216
|
+
return { r: 0, g: 0, b: 0, a: 0 };
|
|
217
|
+
const mix = (x, y) => (x * a.color.a * pa + y * b.color.a * pb) / alpha;
|
|
218
|
+
return { r: mix(a.color.r, b.color.r), g: mix(a.color.g, b.color.g), b: mix(a.color.b, b.color.b), a: alpha };
|
|
219
|
+
}
|
|
220
|
+
function splitAlpha(args) {
|
|
221
|
+
let depth = 0;
|
|
222
|
+
for (let i = args.length - 1;i >= 0; i--) {
|
|
223
|
+
const ch = args[i];
|
|
224
|
+
if (ch === ")")
|
|
225
|
+
depth++;
|
|
226
|
+
else if (ch === "(")
|
|
227
|
+
depth--;
|
|
228
|
+
else if (ch === "/" && depth === 0)
|
|
229
|
+
return [args.slice(0, i).trim(), args.slice(i + 1).trim()];
|
|
230
|
+
}
|
|
231
|
+
return [args.trim(), undefined];
|
|
232
|
+
}
|
|
233
|
+
function splitTop(text, sep = " ") {
|
|
234
|
+
const out = [];
|
|
235
|
+
let depth = 0;
|
|
236
|
+
let cur = "";
|
|
237
|
+
for (const ch of text) {
|
|
238
|
+
if (ch === "(")
|
|
239
|
+
depth++;
|
|
240
|
+
if (ch === ")")
|
|
241
|
+
depth--;
|
|
242
|
+
if (depth === 0 && (sep === " " ? /\s/.test(ch) : ch === sep)) {
|
|
243
|
+
if (cur.trim())
|
|
244
|
+
out.push(cur.trim());
|
|
245
|
+
cur = "";
|
|
246
|
+
} else
|
|
247
|
+
cur += ch;
|
|
248
|
+
}
|
|
249
|
+
if (cur.trim())
|
|
250
|
+
out.push(cur.trim());
|
|
251
|
+
return out;
|
|
252
|
+
}
|
|
253
|
+
function number(p) {
|
|
254
|
+
const n = p.endsWith("%") ? parseFloat(p) / 100 : parseFloat(p);
|
|
255
|
+
return Number.isNaN(n) ? undefined : n;
|
|
256
|
+
}
|
|
257
|
+
function fromOklch(L, C, H) {
|
|
258
|
+
const h = H * Math.PI / 180;
|
|
259
|
+
const a = C * Math.cos(h);
|
|
260
|
+
const b = C * Math.sin(h);
|
|
261
|
+
const l = (L + 0.3963377774 * a + 0.2158037573 * b) ** 3;
|
|
262
|
+
const m = (L - 0.1055613458 * a - 0.0638541728 * b) ** 3;
|
|
263
|
+
const s = (L - 0.0894841775 * a - 1.291485548 * b) ** 3;
|
|
264
|
+
const lin = [
|
|
265
|
+
4.0767416621 * l - 3.3077115913 * m + 0.2309699292 * s,
|
|
266
|
+
-1.2684380046 * l + 2.6097574011 * m - 0.3413193965 * s,
|
|
267
|
+
-0.0041960863 * l - 0.7034186147 * m + 1.707614701 * s
|
|
268
|
+
].map((x) => encode(Math.min(1, Math.max(0, x))));
|
|
269
|
+
return { r: lin[0], g: lin[1], b: lin[2] };
|
|
270
|
+
}
|
|
271
|
+
function toOklch(c) {
|
|
272
|
+
const [r, g, b] = [decode(c.r), decode(c.g), decode(c.b)];
|
|
273
|
+
const l = Math.cbrt(0.4122214708 * r + 0.5363325363 * g + 0.0514459929 * b);
|
|
274
|
+
const m = Math.cbrt(0.2119034982 * r + 0.6806995451 * g + 0.1073969566 * b);
|
|
275
|
+
const s = Math.cbrt(0.0883024619 * r + 0.2817188376 * g + 0.6299787005 * b);
|
|
276
|
+
const L = 0.2104542553 * l + 0.793617785 * m - 0.0040720468 * s;
|
|
277
|
+
const A = 1.9779984951 * l - 2.428592205 * m + 0.4505937099 * s;
|
|
278
|
+
const B = 0.0259040371 * l + 0.7827717662 * m - 0.808675766 * s;
|
|
279
|
+
return [L, Math.hypot(A, B), (Math.atan2(B, A) * 180 / Math.PI + 360) % 360];
|
|
280
|
+
}
|
|
281
|
+
var decode = (x) => x <= 0.04045 ? x / 12.92 : ((x + 0.055) / 1.055) ** 2.4;
|
|
282
|
+
var encode = (x) => x <= 0.0031308 ? 12.92 * x : 1.055 * x ** (1 / 2.4) - 0.055;
|
|
283
|
+
function over(top, bottom) {
|
|
284
|
+
const mix = (x, y) => x * top.a + y * (1 - top.a);
|
|
285
|
+
return { r: mix(top.r, bottom.r), g: mix(top.g, bottom.g), b: mix(top.b, bottom.b), a: 1 };
|
|
286
|
+
}
|
|
287
|
+
function contrast(a, b) {
|
|
288
|
+
const lum = (c) => 0.2126 * decode(c.r) + 0.7152 * decode(c.g) + 0.0722 * decode(c.b);
|
|
289
|
+
const [x, y] = [lum(a), lum(b)].sort((p, q) => q - p);
|
|
290
|
+
return (x + 0.05) / (y + 0.05);
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
// packages/elements/tools/aster-theme-check.ts
|
|
294
|
+
var files = process.argv.slice(2);
|
|
295
|
+
if (files.length === 0) {
|
|
296
|
+
console.error("usage: aster-theme-check <theme.css>\u2026");
|
|
297
|
+
process.exit(2);
|
|
298
|
+
}
|
|
299
|
+
var failed = false;
|
|
300
|
+
for (const file of files) {
|
|
301
|
+
const found = identities(readFileSync(file, "utf8"));
|
|
302
|
+
if (found.length === 0) {
|
|
303
|
+
console.log(`\u2717 ${file}: no :root rule with --aster- tokens`);
|
|
304
|
+
failed = true;
|
|
305
|
+
}
|
|
306
|
+
for (const identity of found) {
|
|
307
|
+
const report = check(identity);
|
|
308
|
+
const ok = report.errors.length === 0;
|
|
309
|
+
failed ||= !ok;
|
|
310
|
+
console.log(`${ok ? "\u2713" : "\u2717"} ${file}, identity ${report.identity}`);
|
|
311
|
+
for (const e of report.errors)
|
|
312
|
+
console.log(` \u2717 ${e.scheme}: ${e.message}`);
|
|
313
|
+
for (const w of report.warnings)
|
|
314
|
+
console.log(` ! ${w.scheme}: ${w.message}`);
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
process.exit(failed ? 1 : 0);
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pointer drags that work on touch screens too.
|
|
3
|
+
*
|
|
4
|
+
* A mouse lifts a drag once it moves `distance` pixels. A touch or pen
|
|
5
|
+
* lifts it by holding still for `HOLD_MS`; moving more than `HOLD_SLOP`
|
|
6
|
+
* first is a scroll, left to the browser, and the press is forgotten.
|
|
7
|
+
* `touch-action` is fixed when a touch starts, so it stays at the default
|
|
8
|
+
* (scrolling works everywhere) and a lifted drag holds the page still by
|
|
9
|
+
* cancelling its `touchmove`s instead. While a drag is lifted, its
|
|
10
|
+
* scroller follows it near the top and bottom edges.
|
|
11
|
+
*
|
|
12
|
+
* Moves are listened for on the document by pointer id, so they keep
|
|
13
|
+
* arriving when the row under the finger is re-rendered away; only a mouse
|
|
14
|
+
* takes pointer capture.
|
|
15
|
+
*/
|
|
16
|
+
/** How long a touch or pen holds still to lift a drag. */
|
|
17
|
+
export declare const HOLD_MS = 400;
|
|
18
|
+
/** How far a held touch or pen may drift and still be holding still. */
|
|
19
|
+
export declare const HOLD_SLOP = 8;
|
|
20
|
+
export interface DragOptions {
|
|
21
|
+
/** How far a mouse moves before the drag lifts. */
|
|
22
|
+
readonly distance: number;
|
|
23
|
+
/** A mouse's distance counts only up and down. */
|
|
24
|
+
readonly vertical?: boolean;
|
|
25
|
+
/** Takes a mouse's pointer capture once the drag lifts. */
|
|
26
|
+
readonly capture: Element;
|
|
27
|
+
/** Scrolls as a lifted pointer nears its edges; by default the nearest scrolling ancestor of `capture`. */
|
|
28
|
+
readonly scroller?: () => Element | null;
|
|
29
|
+
/** Height at the scroller's top that isn't part of it (a sticky header). */
|
|
30
|
+
readonly inset?: () => number;
|
|
31
|
+
/** Escape during the press cancels it. */
|
|
32
|
+
readonly escape?: boolean;
|
|
33
|
+
}
|
|
34
|
+
export interface DragHandlers {
|
|
35
|
+
/** The press became a drag; `move` follows straight away with the pointer's place. */
|
|
36
|
+
lift(): void;
|
|
37
|
+
/** Where the pointer is while lifted, including after an auto-scroll moved the content under it. */
|
|
38
|
+
move(x: number, y: number): void;
|
|
39
|
+
/** A lifted drag ended: dropped where the pointer let go, or cancelled. */
|
|
40
|
+
end(drop: boolean): void;
|
|
41
|
+
}
|
|
42
|
+
/** Whether a press lifts by holding still (touch, pen) rather than by moving (mouse). */
|
|
43
|
+
export declare function holds(e: PointerEvent): boolean;
|
|
44
|
+
/** Follows the press `down` until it lifts a drag and ends, or turns out to be a tap or a scroll. */
|
|
45
|
+
export declare function pressDrag(down: PointerEvent, options: DragOptions, handlers: DragHandlers): void;
|