@ascribed/elements 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CONTRACT.md +225 -0
- package/LICENSE +373 -0
- package/README.md +82 -0
- package/css/style.css +299 -0
- package/dist/group.d.ts +3 -0
- package/dist/group.js +4 -0
- package/dist/group.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +16 -0
- package/dist/index.js.map +1 -0
- package/dist/tabs.d.ts +8 -0
- package/dist/tabs.js +169 -0
- package/dist/tabs.js.map +1 -0
- package/package.json +44 -0
package/CONTRACT.md
ADDED
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
# Element contract
|
|
2
|
+
|
|
3
|
+
The site output (SPEC §9.4) is markdown plus custom elements. This contract is the interface between the **site emitter**, which writes the elements, and the **element library**, `@ascribed/elements`, which implements them. For each element it gives the tag name, the attributes and what they mean, the expected children, and how it renders with and without JavaScript. The emitter writes exactly this markup; the library implements every element and attribute here, and none beyond them.
|
|
4
|
+
|
|
5
|
+
| Ascribe source | Site output | Library |
|
|
6
|
+
|---|---|---|
|
|
7
|
+
| `@note` | [`<ascribe-note>`](#1-ascribe-note) | CSS only |
|
|
8
|
+
| `@steps` | [`<ascribe-steps>`](#2-ascribe-steps) | CSS only |
|
|
9
|
+
| `@variant` group, several arms | [`<ascribe-tabs>`](#3-ascribe-tabs-and-ascribe-tab) with `<ascribe-tab>` | JavaScript (the only element that needs it, SPEC §9.7) |
|
|
10
|
+
| `@available`, badge or filter | [`<ascribe-availability>`](#4-ascribe-availability-and-ascribe-availability-target) with `<ascribe-availability-target>` | CSS only |
|
|
11
|
+
| `@details` | [`<details>`](#5-details) with `<summary>` | Optional CSS |
|
|
12
|
+
| Project widget | [An element named after the widget](#6-project-widgets), and `<ascribe-group>` for groups | The project's own; `<ascribe-group>` is the library's |
|
|
13
|
+
| Glossary term | [An ordinary link](#7-glossary-terms) | None |
|
|
14
|
+
|
|
15
|
+
A change to this contract changes the site emitter (`crates/tessera-emit`), the element library, and the site-render fixtures (`tests/render/`) together.
|
|
16
|
+
|
|
17
|
+
## 0. Rules for every element
|
|
18
|
+
|
|
19
|
+
**Light DOM, CSS, no behavior.** Elements render into the light DOM, so site styles apply and content stays visible to search engines and assistive technology (SPEC §9.7). They're styled with CSS and themed with custom properties whose names start with `--ascribe-`; phase 19 documents the list. Only `<ascribe-tabs>` runs JavaScript. Everything else must render meaningfully with the library's CSS and no script, and must stay readable with neither.
|
|
20
|
+
|
|
21
|
+
**How the emitter writes elements.** Custom elements are raw HTML blocks in CommonMark, so the layout matters:
|
|
22
|
+
|
|
23
|
+
- An element that **wraps markdown** is written as its opening tag alone on a line, a blank line, the markdown, a blank line, and its closing tag alone on a line (SPEC §9.4). Nested wrapping elements follow the same rule.
|
|
24
|
+
- An element that holds **no markdown** (`<ascribe-availability>`, an empty widget) is written as one HTML block: its lines are consecutive, with no blank line inside.
|
|
25
|
+
- Every element is separated from the blocks around it by a blank line, or starts or ends its container.
|
|
26
|
+
- Inside a list item or blockquote, every line carries the container's indentation or `>` markers, like any other block there.
|
|
27
|
+
- A list whose items hold an element is written loose, whatever it was in the source, because an element needs a blank line before it and CommonMark then reads the list as loose: its items render `<p>`. A list whose items hold no element keeps its tightness.
|
|
28
|
+
|
|
29
|
+
**Attribute values** are written in double quotes, with `&`, `<`, `>`, and `"` escaped as `&`, `<`, `>`, and `"`. Attributes appear in the order this contract lists them. An optional attribute with no value is left out, never written empty.
|
|
30
|
+
|
|
31
|
+
**Plain text of inline content.** Where an attribute holds a title or label written as inline markdown, its value is the inline content's text: phrases substituted (they already are, in the resolved page), code spans as their text, emphasis and links as their text, images as their alt text, raw inline HTML dropped, and line breaks as single spaces. So ``.Try the *new* `quill` CLI`` becomes `Try the new quill CLI`.
|
|
32
|
+
|
|
33
|
+
**Labels** come from the content model: note types' `label` (content-model.md §11), dimensions' and dimension values' `labels` (§7), and lifecycle states' `label` (§9). A value without a declared label is shown as itself.
|
|
34
|
+
|
|
35
|
+
## 1. `<ascribe-note>`
|
|
36
|
+
|
|
37
|
+
A callout (SPEC §4.5), from `@note` in all three forms.
|
|
38
|
+
|
|
39
|
+
| Attribute | Required | Meaning |
|
|
40
|
+
|---|---|---|
|
|
41
|
+
| `type` | yes | The note type, such as `tip`, or a type the project declares. Always written, including the default `note`. |
|
|
42
|
+
| `label` | yes | The note type's display label, such as `Tip`. |
|
|
43
|
+
| `heading` | no | The plain text of the note's title line (§0). It isn't called `title` because HTML's `title` attribute shows as a tooltip over the whole element. |
|
|
44
|
+
|
|
45
|
+
**Children:** the note's content, as markdown blocks. With a text primary (`@note: text`), a paragraph of that text; with no colon, the one block it binds; as a container, every block up to `@end`.
|
|
46
|
+
|
|
47
|
+
```html
|
|
48
|
+
<ascribe-note type="tip" label="Tip" heading="Try it without installing">
|
|
49
|
+
|
|
50
|
+
You can run Quill in the browser at play.quill.dev with no local setup.
|
|
51
|
+
|
|
52
|
+
</ascribe-note>
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
**Rendering, with or without JavaScript:** a block styled by `type`, with a heading line showing `label` followed by `: ` and `heading`, or `label` alone when there's no heading (so the type never depends on color), generated from the attributes by CSS (`::before` with `attr()`). Unknown types (a project's own) get the default note style, and are themed by selecting on `[type="…"]`. With no CSS, the content shows as ordinary blocks.
|
|
56
|
+
|
|
57
|
+
## 2. `<ascribe-steps>`
|
|
58
|
+
|
|
59
|
+
A procedure (SPEC §4.6).
|
|
60
|
+
|
|
61
|
+
**Attributes:** none.
|
|
62
|
+
|
|
63
|
+
**Children:** exactly one ordered list, the list `@steps` binds, with its items as the author wrote them (including a `start` number).
|
|
64
|
+
|
|
65
|
+
```html
|
|
66
|
+
<ascribe-steps>
|
|
67
|
+
|
|
68
|
+
1. Install the agent package.
|
|
69
|
+
2. Verify the install.
|
|
70
|
+
|
|
71
|
+
</ascribe-steps>
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
**Rendering, with or without JavaScript:** the list styled as numbered steps with CSS counters or list styling. With no CSS, an ordinary ordered list.
|
|
75
|
+
|
|
76
|
+
## 3. `<ascribe-tabs>` and `<ascribe-tab>`
|
|
77
|
+
|
|
78
|
+
A `@variant` group that keeps more than one arm in the build (SPEC §9.3, §9.4): every group under `switch`, and a group whose selection leaves several arms. A group reduced to one arm is written as that arm's content, with no element; a group with no arm left is removed.
|
|
79
|
+
|
|
80
|
+
### `<ascribe-tabs>`
|
|
81
|
+
|
|
82
|
+
| Attribute | Required | Meaning |
|
|
83
|
+
|---|---|---|
|
|
84
|
+
| `sync` | dimensional groups only | The dimension this group switches on. Groups with the same `sync` on a page switch together, and the reader's choice is remembered across pages. Labeled groups have no `sync` and never sync (SPEC §4.3: they're local to their page). |
|
|
85
|
+
|
|
86
|
+
**Choosing `sync`:** among the dimensions every surviving arm names, the first, in the content model's declaration order of `[dimensions]`, on which the arms' values differ; if the arms have the same values on every dimension they share, the first one they share. For the usual group, whose arms each name one dimension, it's that dimension.
|
|
87
|
+
|
|
88
|
+
**Children:** one `<ascribe-tab>` per surviving arm, in source order, and nothing else.
|
|
89
|
+
|
|
90
|
+
### `<ascribe-tab>`
|
|
91
|
+
|
|
92
|
+
| Attribute | Required | Meaning |
|
|
93
|
+
|---|---|---|
|
|
94
|
+
| `value` | dimensional arms only | The arm's values for the group's `sync` dimension, separated by single spaces: `npm`, or `npm pnpm` for an arm written `{pm=npm\|pnpm}`. Dimension values are names without spaces, so the list is unambiguous. |
|
|
95
|
+
| `label` | yes | What the tab is called. For a labeled arm, the plain text of its title (§0). For a dimensional arm, each of its attributes, in canonical order, as the labels of its values joined by ` / `, with attributes joined by `, `: `npm`, `Quill Cloud, npm`, `npm / pnpm`. |
|
|
96
|
+
|
|
97
|
+
**Children:** the arm's content, as markdown blocks.
|
|
98
|
+
|
|
99
|
+
````html
|
|
100
|
+
<ascribe-tabs sync="pm">
|
|
101
|
+
|
|
102
|
+
<ascribe-tab value="npm" label="npm">
|
|
103
|
+
|
|
104
|
+
```shell
|
|
105
|
+
npm install -g @quill/agent
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
</ascribe-tab>
|
|
109
|
+
|
|
110
|
+
<ascribe-tab value="pnpm" label="pnpm">
|
|
111
|
+
|
|
112
|
+
```shell
|
|
113
|
+
pnpm add -g @quill/agent
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
</ascribe-tab>
|
|
117
|
+
|
|
118
|
+
</ascribe-tabs>
|
|
119
|
+
````
|
|
120
|
+
|
|
121
|
+
### Rendering
|
|
122
|
+
|
|
123
|
+
**Without JavaScript** every tab shows, one after another, each introduced by its `label` (generated by CSS), so no content is hidden (SPEC §9.7).
|
|
124
|
+
|
|
125
|
+
**With JavaScript** the element follows the WAI-ARIA Authoring Practices tabs pattern:
|
|
126
|
+
|
|
127
|
+
- It inserts a tab list as its first child: an element with `role="tablist"` holding one `<button role="tab">` per tab, whose text is the tab's `label`. Each `<ascribe-tab>` gets `role="tabpanel"`, an `id` if it has none, and `aria-labelledby` pointing at its button; the buttons get `aria-controls`, `aria-selected`, and a roving `tabindex`.
|
|
128
|
+
- One tab shows at a time; the others get the `hidden` attribute.
|
|
129
|
+
- Left and Right arrows move between tabs and select them, wrapping at the ends; Home and End go to the first and last tab.
|
|
130
|
+
- **Initial selection:** for a group with `sync`, the first tab whose `value` contains the remembered value for that dimension; otherwise, and for labeled groups, the first tab.
|
|
131
|
+
- **Syncing:** selecting a tab in a group with `sync` records the first value in the tab's `value` as the choice for that dimension, then selects, in every `<ascribe-tabs>` on the page with the same `sync`, the first tab whose `value` contains it. A group with no matching tab keeps its selection.
|
|
132
|
+
- **Remembering:** the choice is stored in `localStorage` under the key `ascribe-tabs:<sync>`, such as `ascribe-tabs:pm`, and read when a group starts. Storage can be unavailable (private windows, blocked storage): every read and write is guarded, and without storage the choice lasts for the page only.
|
|
133
|
+
|
|
134
|
+
## 4. `<ascribe-availability>` and `<ascribe-availability-target>`
|
|
135
|
+
|
|
136
|
+
An availability annotation (SPEC §4.4, §9.4), in badge builds and, for content that survives, in filter builds (SPEC §9.3).
|
|
137
|
+
|
|
138
|
+
### `<ascribe-availability>`
|
|
139
|
+
|
|
140
|
+
| Attribute | Required | Meaning |
|
|
141
|
+
|---|---|---|
|
|
142
|
+
| `scope` | yes | What the annotation applies to: `section` (an `@available` at the top of a section), `block` (one bound to a block), or `page`. |
|
|
143
|
+
|
|
144
|
+
**Children:** one `<ascribe-availability-target>` per target of the effective spec (feature keys resolved), in the spec's order, separated by the text `; `. No markdown.
|
|
145
|
+
|
|
146
|
+
**Where it goes:**
|
|
147
|
+
|
|
148
|
+
- `section`: directly after the section's heading, as the next block.
|
|
149
|
+
- `block`: directly before the block it annotates, where the `@available` line was.
|
|
150
|
+
- `page`: the emitter doesn't write one. Page-level availability reaches the layout as frontmatter (SPEC §9.4, §9.6): `available` is a list with one entry per target, in the spec's order and with feature keys resolved, each holding this element's attributes and its text: `{ target, dimension, states: [...], versions: [...], text }`, with `versions` left out as the attribute is. A layout that shows it renders this element with `scope="page"`, one `<ascribe-availability-target>` per entry, joining `states` and `versions` with single spaces.
|
|
151
|
+
|
|
152
|
+
### `<ascribe-availability-target>`
|
|
153
|
+
|
|
154
|
+
| Attribute | Required | Meaning |
|
|
155
|
+
|---|---|---|
|
|
156
|
+
| `target` | yes | The target as the spec names it: a dimension value (`cloud`) or a dimension name (`deployment`, meaning all its values). |
|
|
157
|
+
| `dimension` | yes | The dimension the target belongs to, or the target itself when it's a dimension name. |
|
|
158
|
+
| `states` | yes | The target's lifecycle states in order, separated by single spaces: `ga` for a bare target, `preview`, or `preview ga deprecated` for a history. |
|
|
159
|
+
| `versions` | when the spec gives versions | The version each state starts at, in the same order, separated by single spaces: `3.4`, or `3.3 3.5 4.0`. A bare version (`self-managed 3.3`) is `states="ga" versions="3.3"`. Left out for a versionless target, and for a target given without versions. |
|
|
160
|
+
|
|
161
|
+
**Text content:** what a reader sees, built from labels (§0):
|
|
162
|
+
|
|
163
|
+
| Spec for the target | Text |
|
|
164
|
+
|---|---|
|
|
165
|
+
| `cloud` | `Quill Cloud (GA)` |
|
|
166
|
+
| `self-managed preview 3.4` | `Self-managed (preview, 3.4+)` |
|
|
167
|
+
| `self-managed 3.3` | `Self-managed (GA, 3.3+)` |
|
|
168
|
+
| `self-managed (preview 3.3, ga 3.5, deprecated 4.0)` | `Self-managed (preview 3.3, GA 3.5, deprecated 4.0)` |
|
|
169
|
+
|
|
170
|
+
That is: the target's label, then in parentheses either one state's label, followed by `, <version>+` if it has a version, or, for a history, each state's label and version separated by `, `. The plain-markdown output's availability line uses the same text per target.
|
|
171
|
+
|
|
172
|
+
```html
|
|
173
|
+
<ascribe-availability scope="section">
|
|
174
|
+
<ascribe-availability-target target="cloud" dimension="deployment" states="ga">Quill Cloud (GA)</ascribe-availability-target>; <ascribe-availability-target target="self-managed" dimension="deployment" states="preview" versions="3.4">Self-managed (preview, 3.4+)</ascribe-availability-target>
|
|
175
|
+
</ascribe-availability>
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
**Rendering, with or without JavaScript:** a line of badges styled by each target's last state (`[states$="deprecated"]` and so on), with a lead-in such as "Available:" from CSS generated content, which a site can restyle or translate. With no CSS, the text reads as a sentence: `Quill Cloud (GA); Self-managed (preview, 3.4+)`.
|
|
179
|
+
|
|
180
|
+
## 5. `<details>`
|
|
181
|
+
|
|
182
|
+
`@details` compiles to HTML's own `<details>` element (SPEC §9.4), which works without JavaScript everywhere.
|
|
183
|
+
|
|
184
|
+
- `<details>` has no attributes: it starts closed.
|
|
185
|
+
- Its first child is `<summary>`, on the line after `<details>`, holding the title line's inline content **rendered as HTML** (not plain text): `<summary>Show the <code>quill.yaml</code> reference</summary>`. Because `<details>` starts an HTML block, the emitter renders the title's markdown itself. An image in the title is written as its alt text, since a raw `<img>` there would get no image processing and its relative path wouldn't resolve.
|
|
186
|
+
- Then a blank line, the content as markdown blocks, a blank line, and `</details>`.
|
|
187
|
+
|
|
188
|
+
```html
|
|
189
|
+
<details>
|
|
190
|
+
<summary>Show the full configuration reference</summary>
|
|
191
|
+
|
|
192
|
+
The content.
|
|
193
|
+
|
|
194
|
+
</details>
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
The element library may style `details` and `summary`, and implements no element for them.
|
|
198
|
+
|
|
199
|
+
## 6. Project widgets
|
|
200
|
+
|
|
201
|
+
A project widget (SPEC §6) becomes a custom element whose tag is the widget's name (SPEC §9.4). Widget names are valid custom-element names: they contain a hyphen, and content-model.md §15 rejects names starting with `ascribe-` and HTML's reserved names. The project supplies the element's implementation; the element library doesn't.
|
|
202
|
+
|
|
203
|
+
**Attributes**, in this order:
|
|
204
|
+
|
|
205
|
+
1. `heading`: the plain text of the widget's title line, if it has one, named as on `<ascribe-note>`.
|
|
206
|
+
2. `primary`: an identifier primary, if the widget takes one and it's given. A text primary is content instead (below).
|
|
207
|
+
3. Each attribute in the widget's declaration, in declared order, with the value given or, if absent, its declared default. A value set's members are joined by single spaces; booleans are `true` or `false`; other values are their text. An attribute with neither a value nor a default is left out. A declaration can't use `heading`, `primary`, or HTML's global or event-handler attribute names (SPEC §7.2; content-model.md, `model-attribute-reserved`), so these never clash.
|
|
208
|
+
|
|
209
|
+
**Children and placement**, by the widget's form and binding (content-model.md §15):
|
|
210
|
+
|
|
211
|
+
| Widget | Element |
|
|
212
|
+
|---|---|
|
|
213
|
+
| Container form | Wraps the container's blocks |
|
|
214
|
+
| Line form with a text primary given | Wraps one paragraph of the primary text |
|
|
215
|
+
| `binding = "block"`, or `"heading-or-block"` away from a section's top | Wraps the block it binds |
|
|
216
|
+
| `binding = "heading"`, or `"heading-or-block"` at a section's top | Empty, directly after the section's heading |
|
|
217
|
+
| `binding = "self"` | Empty, where the directive was |
|
|
218
|
+
|
|
219
|
+
A wrapping widget follows §0's layout for elements that wrap markdown; an empty one is a single line: `<quill-labspace lab="first-sync"></quill-labspace>`.
|
|
220
|
+
|
|
221
|
+
**Groups:** the arms of a groupable widget's group become one element per arm, as above, wrapped in `<ascribe-group widget="<name>">`, which follows §0's layout. `<ascribe-group>` is part of the element library: it has no behavior and no styling beyond `display: block`, and exists so a project's CSS or script can find a group's arms together.
|
|
222
|
+
|
|
223
|
+
## 7. Glossary terms
|
|
224
|
+
|
|
225
|
+
There's no element for glossary terms. In the site output, an occurrence the glossary links (content-model.md §13) is an ordinary markdown link to the term's `link` target, as a route, with the term's definition as the link title: `[API key](/docs/reference/glossary/#api-key "A secret token that authenticates the Quill agent.")`. Terms without a `link` stay plain text (content-model.md Q7).
|
package/LICENSE
ADDED
|
@@ -0,0 +1,373 @@
|
|
|
1
|
+
Mozilla Public License Version 2.0
|
|
2
|
+
==================================
|
|
3
|
+
|
|
4
|
+
1. Definitions
|
|
5
|
+
--------------
|
|
6
|
+
|
|
7
|
+
1.1. "Contributor"
|
|
8
|
+
means each individual or legal entity that creates, contributes to
|
|
9
|
+
the creation of, or owns Covered Software.
|
|
10
|
+
|
|
11
|
+
1.2. "Contributor Version"
|
|
12
|
+
means the combination of the Contributions of others (if any) used
|
|
13
|
+
by a Contributor and that particular Contributor's Contribution.
|
|
14
|
+
|
|
15
|
+
1.3. "Contribution"
|
|
16
|
+
means Covered Software of a particular Contributor.
|
|
17
|
+
|
|
18
|
+
1.4. "Covered Software"
|
|
19
|
+
means Source Code Form to which the initial Contributor has attached
|
|
20
|
+
the notice in Exhibit A, the Executable Form of such Source Code
|
|
21
|
+
Form, and Modifications of such Source Code Form, in each case
|
|
22
|
+
including portions thereof.
|
|
23
|
+
|
|
24
|
+
1.5. "Incompatible With Secondary Licenses"
|
|
25
|
+
means
|
|
26
|
+
|
|
27
|
+
(a) that the initial Contributor has attached the notice described
|
|
28
|
+
in Exhibit B to the Covered Software; or
|
|
29
|
+
|
|
30
|
+
(b) that the Covered Software was made available under the terms of
|
|
31
|
+
version 1.1 or earlier of the License, but not also under the
|
|
32
|
+
terms of a Secondary License.
|
|
33
|
+
|
|
34
|
+
1.6. "Executable Form"
|
|
35
|
+
means any form of the work other than Source Code Form.
|
|
36
|
+
|
|
37
|
+
1.7. "Larger Work"
|
|
38
|
+
means a work that combines Covered Software with other material, in
|
|
39
|
+
a separate file or files, that is not Covered Software.
|
|
40
|
+
|
|
41
|
+
1.8. "License"
|
|
42
|
+
means this document.
|
|
43
|
+
|
|
44
|
+
1.9. "Licensable"
|
|
45
|
+
means having the right to grant, to the maximum extent possible,
|
|
46
|
+
whether at the time of the initial grant or subsequently, any and
|
|
47
|
+
all of the rights conveyed by this License.
|
|
48
|
+
|
|
49
|
+
1.10. "Modifications"
|
|
50
|
+
means any of the following:
|
|
51
|
+
|
|
52
|
+
(a) any file in Source Code Form that results from an addition to,
|
|
53
|
+
deletion from, or modification of the contents of Covered
|
|
54
|
+
Software; or
|
|
55
|
+
|
|
56
|
+
(b) any new file in Source Code Form that contains any Covered
|
|
57
|
+
Software.
|
|
58
|
+
|
|
59
|
+
1.11. "Patent Claims" of a Contributor
|
|
60
|
+
means any patent claim(s), including without limitation, method,
|
|
61
|
+
process, and apparatus claims, in any patent Licensable by such
|
|
62
|
+
Contributor that would be infringed, but for the grant of the
|
|
63
|
+
License, by the making, using, selling, offering for sale, having
|
|
64
|
+
made, import, or transfer of either its Contributions or its
|
|
65
|
+
Contributor Version.
|
|
66
|
+
|
|
67
|
+
1.12. "Secondary License"
|
|
68
|
+
means either the GNU General Public License, Version 2.0, the GNU
|
|
69
|
+
Lesser General Public License, Version 2.1, the GNU Affero General
|
|
70
|
+
Public License, Version 3.0, or any later versions of those
|
|
71
|
+
licenses.
|
|
72
|
+
|
|
73
|
+
1.13. "Source Code Form"
|
|
74
|
+
means the form of the work preferred for making modifications.
|
|
75
|
+
|
|
76
|
+
1.14. "You" (or "Your")
|
|
77
|
+
means an individual or a legal entity exercising rights under this
|
|
78
|
+
License. For legal entities, "You" includes any entity that
|
|
79
|
+
controls, is controlled by, or is under common control with You. For
|
|
80
|
+
purposes of this definition, "control" means (a) the power, direct
|
|
81
|
+
or indirect, to cause the direction or management of such entity,
|
|
82
|
+
whether by contract or otherwise, or (b) ownership of more than
|
|
83
|
+
fifty percent (50%) of the outstanding shares or beneficial
|
|
84
|
+
ownership of such entity.
|
|
85
|
+
|
|
86
|
+
2. License Grants and Conditions
|
|
87
|
+
--------------------------------
|
|
88
|
+
|
|
89
|
+
2.1. Grants
|
|
90
|
+
|
|
91
|
+
Each Contributor hereby grants You a world-wide, royalty-free,
|
|
92
|
+
non-exclusive license:
|
|
93
|
+
|
|
94
|
+
(a) under intellectual property rights (other than patent or trademark)
|
|
95
|
+
Licensable by such Contributor to use, reproduce, make available,
|
|
96
|
+
modify, display, perform, distribute, and otherwise exploit its
|
|
97
|
+
Contributions, either on an unmodified basis, with Modifications, or
|
|
98
|
+
as part of a Larger Work; and
|
|
99
|
+
|
|
100
|
+
(b) under Patent Claims of such Contributor to make, use, sell, offer
|
|
101
|
+
for sale, have made, import, and otherwise transfer either its
|
|
102
|
+
Contributions or its Contributor Version.
|
|
103
|
+
|
|
104
|
+
2.2. Effective Date
|
|
105
|
+
|
|
106
|
+
The licenses granted in Section 2.1 with respect to any Contribution
|
|
107
|
+
become effective for each Contribution on the date the Contributor first
|
|
108
|
+
distributes such Contribution.
|
|
109
|
+
|
|
110
|
+
2.3. Limitations on Grant Scope
|
|
111
|
+
|
|
112
|
+
The licenses granted in this Section 2 are the only rights granted under
|
|
113
|
+
this License. No additional rights or licenses will be implied from the
|
|
114
|
+
distribution or licensing of Covered Software under this License.
|
|
115
|
+
Notwithstanding Section 2.1(b) above, no patent license is granted by a
|
|
116
|
+
Contributor:
|
|
117
|
+
|
|
118
|
+
(a) for any code that a Contributor has removed from Covered Software;
|
|
119
|
+
or
|
|
120
|
+
|
|
121
|
+
(b) for infringements caused by: (i) Your and any other third party's
|
|
122
|
+
modifications of Covered Software, or (ii) the combination of its
|
|
123
|
+
Contributions with other software (except as part of its Contributor
|
|
124
|
+
Version); or
|
|
125
|
+
|
|
126
|
+
(c) under Patent Claims infringed by Covered Software in the absence of
|
|
127
|
+
its Contributions.
|
|
128
|
+
|
|
129
|
+
This License does not grant any rights in the trademarks, service marks,
|
|
130
|
+
or logos of any Contributor (except as may be necessary to comply with
|
|
131
|
+
the notice requirements in Section 3.4).
|
|
132
|
+
|
|
133
|
+
2.4. Subsequent Licenses
|
|
134
|
+
|
|
135
|
+
No Contributor makes additional grants as a result of Your choice to
|
|
136
|
+
distribute the Covered Software under a subsequent version of this
|
|
137
|
+
License (see Section 10.2) or under the terms of a Secondary License (if
|
|
138
|
+
permitted under the terms of Section 3.3).
|
|
139
|
+
|
|
140
|
+
2.5. Representation
|
|
141
|
+
|
|
142
|
+
Each Contributor represents that the Contributor believes its
|
|
143
|
+
Contributions are its original creation(s) or it has sufficient rights
|
|
144
|
+
to grant the rights to its Contributions conveyed by this License.
|
|
145
|
+
|
|
146
|
+
2.6. Fair Use
|
|
147
|
+
|
|
148
|
+
This License is not intended to limit any rights You have under
|
|
149
|
+
applicable copyright doctrines of fair use, fair dealing, or other
|
|
150
|
+
equivalents.
|
|
151
|
+
|
|
152
|
+
2.7. Conditions
|
|
153
|
+
|
|
154
|
+
Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted
|
|
155
|
+
in Section 2.1.
|
|
156
|
+
|
|
157
|
+
3. Responsibilities
|
|
158
|
+
-------------------
|
|
159
|
+
|
|
160
|
+
3.1. Distribution of Source Form
|
|
161
|
+
|
|
162
|
+
All distribution of Covered Software in Source Code Form, including any
|
|
163
|
+
Modifications that You create or to which You contribute, must be under
|
|
164
|
+
the terms of this License. You must inform recipients that the Source
|
|
165
|
+
Code Form of the Covered Software is governed by the terms of this
|
|
166
|
+
License, and how they can obtain a copy of this License. You may not
|
|
167
|
+
attempt to alter or restrict the recipients' rights in the Source Code
|
|
168
|
+
Form.
|
|
169
|
+
|
|
170
|
+
3.2. Distribution of Executable Form
|
|
171
|
+
|
|
172
|
+
If You distribute Covered Software in Executable Form then:
|
|
173
|
+
|
|
174
|
+
(a) such Covered Software must also be made available in Source Code
|
|
175
|
+
Form, as described in Section 3.1, and You must inform recipients of
|
|
176
|
+
the Executable Form how they can obtain a copy of such Source Code
|
|
177
|
+
Form by reasonable means in a timely manner, at a charge no more
|
|
178
|
+
than the cost of distribution to the recipient; and
|
|
179
|
+
|
|
180
|
+
(b) You may distribute such Executable Form under the terms of this
|
|
181
|
+
License, or sublicense it under different terms, provided that the
|
|
182
|
+
license for the Executable Form does not attempt to limit or alter
|
|
183
|
+
the recipients' rights in the Source Code Form under this License.
|
|
184
|
+
|
|
185
|
+
3.3. Distribution of a Larger Work
|
|
186
|
+
|
|
187
|
+
You may create and distribute a Larger Work under terms of Your choice,
|
|
188
|
+
provided that You also comply with the requirements of this License for
|
|
189
|
+
the Covered Software. If the Larger Work is a combination of Covered
|
|
190
|
+
Software with a work governed by one or more Secondary Licenses, and the
|
|
191
|
+
Covered Software is not Incompatible With Secondary Licenses, this
|
|
192
|
+
License permits You to additionally distribute such Covered Software
|
|
193
|
+
under the terms of such Secondary License(s), so that the recipient of
|
|
194
|
+
the Larger Work may, at their option, further distribute the Covered
|
|
195
|
+
Software under the terms of either this License or such Secondary
|
|
196
|
+
License(s).
|
|
197
|
+
|
|
198
|
+
3.4. Notices
|
|
199
|
+
|
|
200
|
+
You may not remove or alter the substance of any license notices
|
|
201
|
+
(including copyright notices, patent notices, disclaimers of warranty,
|
|
202
|
+
or limitations of liability) contained within the Source Code Form of
|
|
203
|
+
the Covered Software, except that You may alter any license notices to
|
|
204
|
+
the extent required to remedy known factual inaccuracies.
|
|
205
|
+
|
|
206
|
+
3.5. Application of Additional Terms
|
|
207
|
+
|
|
208
|
+
You may choose to offer, and to charge a fee for, warranty, support,
|
|
209
|
+
indemnity or liability obligations to one or more recipients of Covered
|
|
210
|
+
Software. However, You may do so only on Your own behalf, and not on
|
|
211
|
+
behalf of any Contributor. You must make it absolutely clear that any
|
|
212
|
+
such warranty, support, indemnity, or liability obligation is offered by
|
|
213
|
+
You alone, and You hereby agree to indemnify every Contributor for any
|
|
214
|
+
liability incurred by such Contributor as a result of warranty, support,
|
|
215
|
+
indemnity or liability terms You offer. You may include additional
|
|
216
|
+
disclaimers of warranty and limitations of liability specific to any
|
|
217
|
+
jurisdiction.
|
|
218
|
+
|
|
219
|
+
4. Inability to Comply Due to Statute or Regulation
|
|
220
|
+
---------------------------------------------------
|
|
221
|
+
|
|
222
|
+
If it is impossible for You to comply with any of the terms of this
|
|
223
|
+
License with respect to some or all of the Covered Software due to
|
|
224
|
+
statute, judicial order, or regulation then You must: (a) comply with
|
|
225
|
+
the terms of this License to the maximum extent possible; and (b)
|
|
226
|
+
describe the limitations and the code they affect. Such description must
|
|
227
|
+
be placed in a text file included with all distributions of the Covered
|
|
228
|
+
Software under this License. Except to the extent prohibited by statute
|
|
229
|
+
or regulation, such description must be sufficiently detailed for a
|
|
230
|
+
recipient of ordinary skill to be able to understand it.
|
|
231
|
+
|
|
232
|
+
5. Termination
|
|
233
|
+
--------------
|
|
234
|
+
|
|
235
|
+
5.1. The rights granted under this License will terminate automatically
|
|
236
|
+
if You fail to comply with any of its terms. However, if You become
|
|
237
|
+
compliant, then the rights granted under this License from a particular
|
|
238
|
+
Contributor are reinstated (a) provisionally, unless and until such
|
|
239
|
+
Contributor explicitly and finally terminates Your grants, and (b) on an
|
|
240
|
+
ongoing basis, if such Contributor fails to notify You of the
|
|
241
|
+
non-compliance by some reasonable means prior to 60 days after You have
|
|
242
|
+
come back into compliance. Moreover, Your grants from a particular
|
|
243
|
+
Contributor are reinstated on an ongoing basis if such Contributor
|
|
244
|
+
notifies You of the non-compliance by some reasonable means, this is the
|
|
245
|
+
first time You have received notice of non-compliance with this License
|
|
246
|
+
from such Contributor, and You become compliant prior to 30 days after
|
|
247
|
+
Your receipt of the notice.
|
|
248
|
+
|
|
249
|
+
5.2. If You initiate litigation against any entity by asserting a patent
|
|
250
|
+
infringement claim (excluding declaratory judgment actions,
|
|
251
|
+
counter-claims, and cross-claims) alleging that a Contributor Version
|
|
252
|
+
directly or indirectly infringes any patent, then the rights granted to
|
|
253
|
+
You by any and all Contributors for the Covered Software under Section
|
|
254
|
+
2.1 of this License shall terminate.
|
|
255
|
+
|
|
256
|
+
5.3. In the event of termination under Sections 5.1 or 5.2 above, all
|
|
257
|
+
end user license agreements (excluding distributors and resellers) which
|
|
258
|
+
have been validly granted by You or Your distributors under this License
|
|
259
|
+
prior to termination shall survive termination.
|
|
260
|
+
|
|
261
|
+
************************************************************************
|
|
262
|
+
* *
|
|
263
|
+
* 6. Disclaimer of Warranty *
|
|
264
|
+
* ------------------------- *
|
|
265
|
+
* *
|
|
266
|
+
* Covered Software is provided under this License on an "as is" *
|
|
267
|
+
* basis, without warranty of any kind, either expressed, implied, or *
|
|
268
|
+
* statutory, including, without limitation, warranties that the *
|
|
269
|
+
* Covered Software is free of defects, merchantable, fit for a *
|
|
270
|
+
* particular purpose or non-infringing. The entire risk as to the *
|
|
271
|
+
* quality and performance of the Covered Software is with You. *
|
|
272
|
+
* Should any Covered Software prove defective in any respect, You *
|
|
273
|
+
* (not any Contributor) assume the cost of any necessary servicing, *
|
|
274
|
+
* repair, or correction. This disclaimer of warranty constitutes an *
|
|
275
|
+
* essential part of this License. No use of any Covered Software is *
|
|
276
|
+
* authorized under this License except under this disclaimer. *
|
|
277
|
+
* *
|
|
278
|
+
************************************************************************
|
|
279
|
+
|
|
280
|
+
************************************************************************
|
|
281
|
+
* *
|
|
282
|
+
* 7. Limitation of Liability *
|
|
283
|
+
* -------------------------- *
|
|
284
|
+
* *
|
|
285
|
+
* Under no circumstances and under no legal theory, whether tort *
|
|
286
|
+
* (including negligence), contract, or otherwise, shall any *
|
|
287
|
+
* Contributor, or anyone who distributes Covered Software as *
|
|
288
|
+
* permitted above, be liable to You for any direct, indirect, *
|
|
289
|
+
* special, incidental, or consequential damages of any character *
|
|
290
|
+
* including, without limitation, damages for lost profits, loss of *
|
|
291
|
+
* goodwill, work stoppage, computer failure or malfunction, or any *
|
|
292
|
+
* and all other commercial damages or losses, even if such party *
|
|
293
|
+
* shall have been informed of the possibility of such damages. This *
|
|
294
|
+
* limitation of liability shall not apply to liability for death or *
|
|
295
|
+
* personal injury resulting from such party's negligence to the *
|
|
296
|
+
* extent applicable law prohibits such limitation. Some *
|
|
297
|
+
* jurisdictions do not allow the exclusion or limitation of *
|
|
298
|
+
* incidental or consequential damages, so this exclusion and *
|
|
299
|
+
* limitation may not apply to You. *
|
|
300
|
+
* *
|
|
301
|
+
************************************************************************
|
|
302
|
+
|
|
303
|
+
8. Litigation
|
|
304
|
+
-------------
|
|
305
|
+
|
|
306
|
+
Any litigation relating to this License may be brought only in the
|
|
307
|
+
courts of a jurisdiction where the defendant maintains its principal
|
|
308
|
+
place of business and such litigation shall be governed by laws of that
|
|
309
|
+
jurisdiction, without reference to its conflict-of-law provisions.
|
|
310
|
+
Nothing in this Section shall prevent a party's ability to bring
|
|
311
|
+
cross-claims or counter-claims.
|
|
312
|
+
|
|
313
|
+
9. Miscellaneous
|
|
314
|
+
----------------
|
|
315
|
+
|
|
316
|
+
This License represents the complete agreement concerning the subject
|
|
317
|
+
matter hereof. If any provision of this License is held to be
|
|
318
|
+
unenforceable, such provision shall be reformed only to the extent
|
|
319
|
+
necessary to make it enforceable. Any law or regulation which provides
|
|
320
|
+
that the language of a contract shall be construed against the drafter
|
|
321
|
+
shall not be used to construe this License against a Contributor.
|
|
322
|
+
|
|
323
|
+
10. Versions of the License
|
|
324
|
+
---------------------------
|
|
325
|
+
|
|
326
|
+
10.1. New Versions
|
|
327
|
+
|
|
328
|
+
Mozilla Foundation is the license steward. Except as provided in Section
|
|
329
|
+
10.3, no one other than the license steward has the right to modify or
|
|
330
|
+
publish new versions of this License. Each version will be given a
|
|
331
|
+
distinguishing version number.
|
|
332
|
+
|
|
333
|
+
10.2. Effect of New Versions
|
|
334
|
+
|
|
335
|
+
You may distribute the Covered Software under the terms of the version
|
|
336
|
+
of the License under which You originally received the Covered Software,
|
|
337
|
+
or under the terms of any subsequent version published by the license
|
|
338
|
+
steward.
|
|
339
|
+
|
|
340
|
+
10.3. Modified Versions
|
|
341
|
+
|
|
342
|
+
If you create software not governed by this License, and you want to
|
|
343
|
+
create a new license for such software, you may create and use a
|
|
344
|
+
modified version of this License if you rename the license and remove
|
|
345
|
+
any references to the name of the license steward (except to note that
|
|
346
|
+
such modified license differs from this License).
|
|
347
|
+
|
|
348
|
+
10.4. Distributing Source Code Form that is Incompatible With Secondary
|
|
349
|
+
Licenses
|
|
350
|
+
|
|
351
|
+
If You choose to distribute Source Code Form that is Incompatible With
|
|
352
|
+
Secondary Licenses under the terms of this version of the License, the
|
|
353
|
+
notice described in Exhibit B of this License must be attached.
|
|
354
|
+
|
|
355
|
+
Exhibit A - Source Code Form License Notice
|
|
356
|
+
-------------------------------------------
|
|
357
|
+
|
|
358
|
+
This Source Code Form is subject to the terms of the Mozilla Public
|
|
359
|
+
License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
360
|
+
file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
361
|
+
|
|
362
|
+
If it is not possible or desirable to put the notice in a particular
|
|
363
|
+
file, then You may include the notice in a location (such as a LICENSE
|
|
364
|
+
file in a relevant directory) where a recipient would be likely to look
|
|
365
|
+
for such a notice.
|
|
366
|
+
|
|
367
|
+
You may add additional accurate notices of copyright ownership.
|
|
368
|
+
|
|
369
|
+
Exhibit B - "Incompatible With Secondary Licenses" Notice
|
|
370
|
+
---------------------------------------------------------
|
|
371
|
+
|
|
372
|
+
This Source Code Form is "Incompatible With Secondary Licenses", as
|
|
373
|
+
defined by the Mozilla Public License, v. 2.0.
|
package/README.md
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
# @ascribed/elements
|
|
2
|
+
|
|
3
|
+
The custom elements [Ascribe](https://github.com/ascribed-dev/ascribe)'s site output uses. They implement
|
|
4
|
+
[CONTRACT.md](CONTRACT.md) exactly: `<ascribe-note>`, `<ascribe-steps>`,
|
|
5
|
+
`<ascribe-tabs>` with `<ascribe-tab>`, `<ascribe-availability>` with
|
|
6
|
+
`<ascribe-availability-target>`, and `<ascribe-group>`.
|
|
7
|
+
|
|
8
|
+
- Elements render into the light DOM and are styled by CSS.
|
|
9
|
+
- Only `<ascribe-tabs>` uses JavaScript. Without the script, every tab shows
|
|
10
|
+
with its label; nothing is hidden.
|
|
11
|
+
|
|
12
|
+
An Astro site gets them through `@ascribed/astro`, whose `<Elements />`
|
|
13
|
+
component loads the stylesheet and the script.
|
|
14
|
+
|
|
15
|
+
## Using it
|
|
16
|
+
|
|
17
|
+
```js
|
|
18
|
+
// Registers <ascribe-tabs>, <ascribe-tab>, and <ascribe-group>.
|
|
19
|
+
import "@ascribed/elements";
|
|
20
|
+
// The styles. Import this alone to style the elements without the script.
|
|
21
|
+
import "@ascribed/elements/style.css";
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
The CSS works with no script at all. A site can also link `css/style.css`
|
|
25
|
+
directly.
|
|
26
|
+
|
|
27
|
+
## Theming
|
|
28
|
+
|
|
29
|
+
Set any of these custom properties on `:root`, or on any ancestor of the
|
|
30
|
+
elements. Defaults are in `css/style.css`.
|
|
31
|
+
|
|
32
|
+
| Group | Properties |
|
|
33
|
+
|---|---|
|
|
34
|
+
| Type | `--ascribe-font-family`, `--ascribe-font-size-small`, `--ascribe-font-weight-strong` |
|
|
35
|
+
| Spacing and borders | `--ascribe-space`, `--ascribe-space-small`, `--ascribe-border-width`, `--ascribe-border-color`, `--ascribe-radius` |
|
|
36
|
+
| Surfaces and text | `--ascribe-text-color`, `--ascribe-muted-color`, `--ascribe-surface-color` |
|
|
37
|
+
| Notes | `--ascribe-<type>-color` and `--ascribe-<type>-background`, for `note`, `tip`, `important`, `warning`, and `caution` |
|
|
38
|
+
| Steps | `--ascribe-steps-color`, `--ascribe-steps-marker-size`, `--ascribe-steps-marker-text-color` |
|
|
39
|
+
| Tabs | `--ascribe-tab-color`, `--ascribe-tab-active-color`, `--ascribe-tab-focus-color`, `--ascribe-tab-hover-background` |
|
|
40
|
+
| Availability | `--ascribe-state-color` and `--ascribe-state-background`, and `--ascribe-state-<state>-color` and `--ascribe-state-<state>-background` for `ga`, `preview`, `beta`, `deprecated`, and `removed` |
|
|
41
|
+
|
|
42
|
+
### A project's own note types and lifecycle states
|
|
43
|
+
|
|
44
|
+
Notes and availability targets carry their type or states as attributes, so a
|
|
45
|
+
project styles its own by selecting on them. The elements take their colors
|
|
46
|
+
from `--_color` and `--_background`:
|
|
47
|
+
|
|
48
|
+
```css
|
|
49
|
+
ascribe-note[type="security"] {
|
|
50
|
+
--_color: #b62324;
|
|
51
|
+
--_background: #fff0f0;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
ascribe-availability-target[states="sunset"],
|
|
55
|
+
ascribe-availability-target[states$=" sunset"] {
|
|
56
|
+
--_color: #6e7781;
|
|
57
|
+
--_background: #eaeef2;
|
|
58
|
+
}
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
`states` lists a target's states in order and the last one styles the badge, so match it as a whole token, as above: `[states="x"], [states$=" x"]`. A bare `[states$="x"]` would also match a state named `pre-x`. Unknown types and states get the default (`note`, or the neutral state) style.
|
|
62
|
+
|
|
63
|
+
### Generated text
|
|
64
|
+
|
|
65
|
+
Headings and labels come from the elements' attributes through CSS generated
|
|
66
|
+
content, and the availability lead-in is `ascribe-availability::before`
|
|
67
|
+
(`"Available: "`). A site can restyle or translate them:
|
|
68
|
+
|
|
69
|
+
```css
|
|
70
|
+
ascribe-availability::before {
|
|
71
|
+
content: "Disponible : ";
|
|
72
|
+
}
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
## Tests
|
|
76
|
+
|
|
77
|
+
`pnpm --filter @ascribed/elements test` compiles the library and drives Chromium
|
|
78
|
+
through Playwright in Chromium, Firefox, and WebKit. Install them with
|
|
79
|
+
`pnpm --filter @ascribed/elements exec playwright-core install chromium firefox webkit`.
|
|
80
|
+
Chromium uses `/opt/pw-browsers/chromium` when present, or the binary in
|
|
81
|
+
`ASCRIBE_CHROMIUM`. `ASCRIBE_ENGINES=chromium` (a comma-separated subset) runs
|
|
82
|
+
fewer engines on a machine that can't install all three.
|
package/css/style.css
ADDED
|
@@ -0,0 +1,299 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* @ascribed/elements: styles for the Ascribe site output (CONTRACT.md).
|
|
3
|
+
*
|
|
4
|
+
* Everything here works without the script; only <ascribe-tabs> adds
|
|
5
|
+
* behavior. Theme it by setting the --ascribe-* custom properties (listed in
|
|
6
|
+
* README.md) on :root or any ancestor.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
:root {
|
|
10
|
+
/* Type */
|
|
11
|
+
--ascribe-font-family: inherit;
|
|
12
|
+
--ascribe-font-size-small: 0.875em;
|
|
13
|
+
--ascribe-font-weight-strong: 600;
|
|
14
|
+
|
|
15
|
+
/* Spacing, borders */
|
|
16
|
+
--ascribe-space: 1rem;
|
|
17
|
+
--ascribe-space-small: 0.5rem;
|
|
18
|
+
--ascribe-border-width: 1px;
|
|
19
|
+
--ascribe-border-color: #d0d7de;
|
|
20
|
+
--ascribe-radius: 0.375rem;
|
|
21
|
+
|
|
22
|
+
/* Surfaces and text */
|
|
23
|
+
--ascribe-text-color: inherit;
|
|
24
|
+
--ascribe-muted-color: #57606a;
|
|
25
|
+
--ascribe-surface-color: transparent;
|
|
26
|
+
|
|
27
|
+
/* Note types: an accent color and a tinted background each. */
|
|
28
|
+
--ascribe-note-color: #0969da;
|
|
29
|
+
--ascribe-note-background: #ddf4ff;
|
|
30
|
+
--ascribe-tip-color: #1a7f37;
|
|
31
|
+
--ascribe-tip-background: #dafbe1;
|
|
32
|
+
--ascribe-important-color: #8250df;
|
|
33
|
+
--ascribe-important-background: #fbefff;
|
|
34
|
+
--ascribe-warning-color: #9a6700;
|
|
35
|
+
--ascribe-warning-background: #fff8c5;
|
|
36
|
+
--ascribe-caution-color: #cf222e;
|
|
37
|
+
--ascribe-caution-background: #ffebe9;
|
|
38
|
+
|
|
39
|
+
/* Steps */
|
|
40
|
+
--ascribe-steps-color: #0969da;
|
|
41
|
+
--ascribe-steps-marker-size: 1.75rem;
|
|
42
|
+
--ascribe-steps-marker-text-color: #ffffff;
|
|
43
|
+
|
|
44
|
+
/* Tabs */
|
|
45
|
+
--ascribe-tab-color: #57606a;
|
|
46
|
+
--ascribe-tab-active-color: #0969da;
|
|
47
|
+
--ascribe-tab-focus-color: #0969da;
|
|
48
|
+
--ascribe-tab-hover-background: #f6f8fa;
|
|
49
|
+
|
|
50
|
+
/* Availability lifecycle states: an accent color and a background each. */
|
|
51
|
+
--ascribe-state-color: #57606a;
|
|
52
|
+
--ascribe-state-background: #eaeef2;
|
|
53
|
+
--ascribe-state-ga-color: #1a7f37;
|
|
54
|
+
--ascribe-state-ga-background: #dafbe1;
|
|
55
|
+
--ascribe-state-preview-color: #8250df;
|
|
56
|
+
--ascribe-state-preview-background: #fbefff;
|
|
57
|
+
--ascribe-state-beta-color: #0969da;
|
|
58
|
+
--ascribe-state-beta-background: #ddf4ff;
|
|
59
|
+
--ascribe-state-deprecated-color: #9a6700;
|
|
60
|
+
--ascribe-state-deprecated-background: #fff8c5;
|
|
61
|
+
--ascribe-state-removed-color: #cf222e;
|
|
62
|
+
--ascribe-state-removed-background: #ffebe9;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/* <ascribe-note> ---------------------------------------------------------- */
|
|
66
|
+
|
|
67
|
+
ascribe-note {
|
|
68
|
+
--_color: var(--ascribe-note-color);
|
|
69
|
+
--_background: var(--ascribe-note-background);
|
|
70
|
+
display: block;
|
|
71
|
+
margin-block: var(--ascribe-space);
|
|
72
|
+
padding: var(--ascribe-space-small) var(--ascribe-space);
|
|
73
|
+
border-inline-start: 0.25rem solid var(--_color);
|
|
74
|
+
border-radius: var(--ascribe-radius);
|
|
75
|
+
background: var(--_background);
|
|
76
|
+
color: var(--ascribe-text-color);
|
|
77
|
+
font-family: var(--ascribe-font-family);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
ascribe-note[type="tip"] {
|
|
81
|
+
--_color: var(--ascribe-tip-color);
|
|
82
|
+
--_background: var(--ascribe-tip-background);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
ascribe-note[type="important"] {
|
|
86
|
+
--_color: var(--ascribe-important-color);
|
|
87
|
+
--_background: var(--ascribe-important-background);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
ascribe-note[type="warning"] {
|
|
91
|
+
--_color: var(--ascribe-warning-color);
|
|
92
|
+
--_background: var(--ascribe-warning-background);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
ascribe-note[type="caution"] {
|
|
96
|
+
--_color: var(--ascribe-caution-color);
|
|
97
|
+
--_background: var(--ascribe-caution-background);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/* The heading line: `label: heading`, or `label` alone with no heading. */
|
|
101
|
+
ascribe-note::before {
|
|
102
|
+
content: attr(label);
|
|
103
|
+
display: block;
|
|
104
|
+
margin-bottom: var(--ascribe-space-small);
|
|
105
|
+
color: var(--_color);
|
|
106
|
+
font-weight: var(--ascribe-font-weight-strong);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
ascribe-note[heading]::before {
|
|
110
|
+
content: attr(label) ": " attr(heading);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
ascribe-note > :first-child {
|
|
114
|
+
margin-top: 0;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
ascribe-note > :last-child {
|
|
118
|
+
margin-bottom: 0;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
/* <ascribe-steps> --------------------------------------------------------- */
|
|
122
|
+
|
|
123
|
+
ascribe-steps {
|
|
124
|
+
display: block;
|
|
125
|
+
margin-block: var(--ascribe-space);
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
ascribe-steps > ol {
|
|
129
|
+
list-style: none;
|
|
130
|
+
margin: 0;
|
|
131
|
+
padding: 0;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
ascribe-steps > ol > li {
|
|
135
|
+
position: relative;
|
|
136
|
+
margin: 0;
|
|
137
|
+
padding: 0 0 var(--ascribe-space) calc(var(--ascribe-steps-marker-size) + var(--ascribe-space));
|
|
138
|
+
min-height: var(--ascribe-steps-marker-size);
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
ascribe-steps > ol > li::before {
|
|
142
|
+
/* `list-item` follows the list's own numbering, including `start`. */
|
|
143
|
+
content: counter(list-item);
|
|
144
|
+
position: absolute;
|
|
145
|
+
inset-block-start: 0;
|
|
146
|
+
inset-inline-start: 0;
|
|
147
|
+
box-sizing: border-box;
|
|
148
|
+
width: var(--ascribe-steps-marker-size);
|
|
149
|
+
height: var(--ascribe-steps-marker-size);
|
|
150
|
+
border-radius: 50%;
|
|
151
|
+
background: var(--ascribe-steps-color);
|
|
152
|
+
color: var(--ascribe-steps-marker-text-color);
|
|
153
|
+
font-size: var(--ascribe-font-size-small);
|
|
154
|
+
font-weight: var(--ascribe-font-weight-strong);
|
|
155
|
+
line-height: var(--ascribe-steps-marker-size);
|
|
156
|
+
text-align: center;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
ascribe-steps > ol > li::after {
|
|
160
|
+
content: "";
|
|
161
|
+
position: absolute;
|
|
162
|
+
inset-block: calc(var(--ascribe-steps-marker-size) + 0.25rem) 0.25rem;
|
|
163
|
+
inset-inline-start: calc(var(--ascribe-steps-marker-size) / 2);
|
|
164
|
+
border-inline-start: var(--ascribe-border-width) solid var(--ascribe-border-color);
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
ascribe-steps > ol > li:last-child::after {
|
|
168
|
+
display: none;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
/* <ascribe-tabs> ---------------------------------------------------------- */
|
|
172
|
+
|
|
173
|
+
ascribe-tabs {
|
|
174
|
+
display: block;
|
|
175
|
+
margin-block: var(--ascribe-space);
|
|
176
|
+
font-family: var(--ascribe-font-family);
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
ascribe-tab {
|
|
180
|
+
display: block;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
ascribe-tab[hidden] {
|
|
184
|
+
display: none;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
/* Without the script: every tab shows, introduced by its label. */
|
|
188
|
+
ascribe-tab::before {
|
|
189
|
+
content: attr(label);
|
|
190
|
+
display: block;
|
|
191
|
+
margin-top: var(--ascribe-space);
|
|
192
|
+
color: var(--ascribe-muted-color);
|
|
193
|
+
font-weight: var(--ascribe-font-weight-strong);
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
/* With the script: the tab list carries the labels. */
|
|
197
|
+
ascribe-tab[role="tabpanel"]::before {
|
|
198
|
+
display: none;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
ascribe-tab[role="tabpanel"] {
|
|
202
|
+
padding-top: var(--ascribe-space-small);
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
ascribe-tabs > [role="tablist"] {
|
|
206
|
+
display: flex;
|
|
207
|
+
flex-wrap: wrap;
|
|
208
|
+
gap: var(--ascribe-space-small);
|
|
209
|
+
border-bottom: var(--ascribe-border-width) solid var(--ascribe-border-color);
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
ascribe-tabs > [role="tablist"] > [role="tab"] {
|
|
213
|
+
margin: 0 0 calc(var(--ascribe-border-width) * -1);
|
|
214
|
+
padding: var(--ascribe-space-small) var(--ascribe-space);
|
|
215
|
+
border: 0;
|
|
216
|
+
border-bottom: 2px solid transparent;
|
|
217
|
+
border-radius: var(--ascribe-radius) var(--ascribe-radius) 0 0;
|
|
218
|
+
background: transparent;
|
|
219
|
+
color: var(--ascribe-tab-color);
|
|
220
|
+
font: inherit;
|
|
221
|
+
cursor: pointer;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
ascribe-tabs > [role="tablist"] > [role="tab"]:hover {
|
|
225
|
+
background: var(--ascribe-tab-hover-background);
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
ascribe-tabs > [role="tablist"] > [role="tab"][aria-selected="true"] {
|
|
229
|
+
border-bottom-color: var(--ascribe-tab-active-color);
|
|
230
|
+
color: var(--ascribe-tab-active-color);
|
|
231
|
+
font-weight: var(--ascribe-font-weight-strong);
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
ascribe-tabs > [role="tablist"] > [role="tab"]:focus-visible {
|
|
235
|
+
outline: 2px solid var(--ascribe-tab-focus-color);
|
|
236
|
+
outline-offset: -2px;
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
/* <ascribe-availability> -------------------------------------------------- */
|
|
240
|
+
|
|
241
|
+
ascribe-availability {
|
|
242
|
+
display: block;
|
|
243
|
+
margin-block: var(--ascribe-space-small);
|
|
244
|
+
color: var(--ascribe-muted-color);
|
|
245
|
+
font-family: var(--ascribe-font-family);
|
|
246
|
+
font-size: var(--ascribe-font-size-small);
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
/* The lead-in is generated content, so a site can restyle or translate it. */
|
|
250
|
+
ascribe-availability::before {
|
|
251
|
+
content: "Available: ";
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
ascribe-availability-target {
|
|
255
|
+
--_color: var(--ascribe-state-color);
|
|
256
|
+
--_background: var(--ascribe-state-background);
|
|
257
|
+
display: inline-block;
|
|
258
|
+
padding: 0.125rem 0.5rem;
|
|
259
|
+
border-radius: 999px;
|
|
260
|
+
background: var(--_background);
|
|
261
|
+
color: var(--_color);
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
/* Match the last state as a whole token: `$="ga"` alone would also match `pre-ga`. */
|
|
265
|
+
ascribe-availability-target[states="ga"],
|
|
266
|
+
ascribe-availability-target[states$=" ga"] {
|
|
267
|
+
--_color: var(--ascribe-state-ga-color);
|
|
268
|
+
--_background: var(--ascribe-state-ga-background);
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
ascribe-availability-target[states="preview"],
|
|
272
|
+
ascribe-availability-target[states$=" preview"] {
|
|
273
|
+
--_color: var(--ascribe-state-preview-color);
|
|
274
|
+
--_background: var(--ascribe-state-preview-background);
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
ascribe-availability-target[states="beta"],
|
|
278
|
+
ascribe-availability-target[states$=" beta"] {
|
|
279
|
+
--_color: var(--ascribe-state-beta-color);
|
|
280
|
+
--_background: var(--ascribe-state-beta-background);
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
ascribe-availability-target[states="deprecated"],
|
|
284
|
+
ascribe-availability-target[states$=" deprecated"] {
|
|
285
|
+
--_color: var(--ascribe-state-deprecated-color);
|
|
286
|
+
--_background: var(--ascribe-state-deprecated-background);
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
ascribe-availability-target[states="removed"],
|
|
290
|
+
ascribe-availability-target[states$=" removed"] {
|
|
291
|
+
--_color: var(--ascribe-state-removed-color);
|
|
292
|
+
--_background: var(--ascribe-state-removed-background);
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
/* <ascribe-group> --------------------------------------------------------- */
|
|
296
|
+
|
|
297
|
+
ascribe-group {
|
|
298
|
+
display: block;
|
|
299
|
+
}
|
package/dist/group.d.ts
ADDED
package/dist/group.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"group.js","sourceRoot":"","sources":["../src/group.ts"],"names":[],"mappings":"AAAA,oFAAoF;AACpF,MAAM,OAAO,YAAa,SAAQ,WAAW;CAAG"}
|
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
// @ascribed/elements: registers Ascribe's custom elements. Only
|
|
2
|
+
// <ascribe-tabs> has behavior; the rest are styled by the CSS file
|
|
3
|
+
// (`@ascribed/elements/style.css`), which works without this script.
|
|
4
|
+
import { AscribeGroup } from "./group.js";
|
|
5
|
+
import { AscribeTab, AscribeTabs } from "./tabs.js";
|
|
6
|
+
export { AscribeGroup, AscribeTab, AscribeTabs };
|
|
7
|
+
const registry = [
|
|
8
|
+
["ascribe-tabs", AscribeTabs],
|
|
9
|
+
["ascribe-tab", AscribeTab],
|
|
10
|
+
["ascribe-group", AscribeGroup],
|
|
11
|
+
];
|
|
12
|
+
for (const [name, constructor] of registry) {
|
|
13
|
+
if (!customElements.get(name))
|
|
14
|
+
customElements.define(name, constructor);
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,gEAAgE;AAChE,mEAAmE;AACnE,qEAAqE;AAErE,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC1C,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAEpD,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,WAAW,EAAE,CAAC;AAEjD,MAAM,QAAQ,GAAyC;IACrD,CAAC,cAAc,EAAE,WAAW,CAAC;IAC7B,CAAC,aAAa,EAAE,UAAU,CAAC;IAC3B,CAAC,eAAe,EAAE,YAAY,CAAC;CAChC,CAAC;AAEF,KAAK,MAAM,CAAC,IAAI,EAAE,WAAW,CAAC,IAAI,QAAQ,EAAE,CAAC;IAC3C,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,IAAI,CAAC;QAAE,cAAc,CAAC,MAAM,CAAC,IAAI,EAAE,WAAW,CAAC,CAAC;AAC1E,CAAC"}
|
package/dist/tabs.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/** A tab panel: one arm of a `@variant` group. Styled by CSS; no behavior. */
|
|
2
|
+
export declare class AscribeTab extends HTMLElement {
|
|
3
|
+
}
|
|
4
|
+
export declare class AscribeTabs extends HTMLElement {
|
|
5
|
+
#private;
|
|
6
|
+
connectedCallback(): void;
|
|
7
|
+
disconnectedCallback(): void;
|
|
8
|
+
}
|
package/dist/tabs.js
ADDED
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
// <ascribe-tabs> and <ascribe-tab> (CONTRACT.md §3): the library's only
|
|
2
|
+
// element with behavior. Without this script every tab shows with its label
|
|
3
|
+
// (CSS generated content); with it, the group follows the WAI-ARIA tabs
|
|
4
|
+
// pattern.
|
|
5
|
+
const STORAGE_PREFIX = "ascribe-tabs:";
|
|
6
|
+
/** Choices made this page load, for readers whose storage is unavailable. */
|
|
7
|
+
const pageChoices = new Map();
|
|
8
|
+
/** Every connected, initialized group with a `sync` attribute. */
|
|
9
|
+
const syncedGroups = new Set();
|
|
10
|
+
let idCounter = 0;
|
|
11
|
+
function readChoice(dimension) {
|
|
12
|
+
// This page's choices are always at least as fresh as storage, which a
|
|
13
|
+
// failed write leaves behind.
|
|
14
|
+
const chosen = pageChoices.get(dimension);
|
|
15
|
+
if (chosen !== undefined)
|
|
16
|
+
return chosen;
|
|
17
|
+
try {
|
|
18
|
+
return localStorage.getItem(STORAGE_PREFIX + dimension);
|
|
19
|
+
}
|
|
20
|
+
catch {
|
|
21
|
+
// Storage can be blocked or unavailable.
|
|
22
|
+
return null;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
function writeChoice(dimension, value) {
|
|
26
|
+
pageChoices.set(dimension, value);
|
|
27
|
+
try {
|
|
28
|
+
localStorage.setItem(STORAGE_PREFIX + dimension, value);
|
|
29
|
+
}
|
|
30
|
+
catch {
|
|
31
|
+
// The choice lasts for the page only.
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
function valuesOf(tab) {
|
|
35
|
+
return (tab.getAttribute("value") ?? "").split(/\s+/).filter(Boolean);
|
|
36
|
+
}
|
|
37
|
+
/** A tab panel: one arm of a `@variant` group. Styled by CSS; no behavior. */
|
|
38
|
+
export class AscribeTab extends HTMLElement {
|
|
39
|
+
}
|
|
40
|
+
export class AscribeTabs extends HTMLElement {
|
|
41
|
+
#tablist = null;
|
|
42
|
+
#tabs = [];
|
|
43
|
+
#buttons = [];
|
|
44
|
+
#selected = 0;
|
|
45
|
+
#ready = false;
|
|
46
|
+
connectedCallback() {
|
|
47
|
+
// A parser-created element is connected before its children are parsed.
|
|
48
|
+
if (document.readyState === "loading") {
|
|
49
|
+
document.addEventListener("DOMContentLoaded", () => this.#setup(), { once: true });
|
|
50
|
+
}
|
|
51
|
+
else {
|
|
52
|
+
this.#setup();
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
disconnectedCallback() {
|
|
56
|
+
this.#teardown();
|
|
57
|
+
}
|
|
58
|
+
#setup() {
|
|
59
|
+
if (!this.isConnected || this.#ready)
|
|
60
|
+
return;
|
|
61
|
+
this.#tabs = Array.from(this.children).filter((child) => child.localName === "ascribe-tab");
|
|
62
|
+
if (this.#tabs.length === 0)
|
|
63
|
+
return;
|
|
64
|
+
this.#ready = true;
|
|
65
|
+
const tablist = document.createElement("div");
|
|
66
|
+
tablist.setAttribute("role", "tablist");
|
|
67
|
+
this.#tablist = tablist;
|
|
68
|
+
this.#buttons = this.#tabs.map((tab) => {
|
|
69
|
+
if (!tab.id)
|
|
70
|
+
tab.id = `ascribe-tab-${++idCounter}`;
|
|
71
|
+
const button = document.createElement("button");
|
|
72
|
+
button.type = "button";
|
|
73
|
+
button.id = `${tab.id}-button`;
|
|
74
|
+
button.setAttribute("role", "tab");
|
|
75
|
+
button.setAttribute("aria-controls", tab.id);
|
|
76
|
+
button.textContent = tab.getAttribute("label") ?? "";
|
|
77
|
+
button.addEventListener("click", () => this.#choose(this.#buttons.indexOf(button)));
|
|
78
|
+
button.addEventListener("keydown", (event) => this.#onKeydown(event));
|
|
79
|
+
tablist.append(button);
|
|
80
|
+
tab.setAttribute("role", "tabpanel");
|
|
81
|
+
tab.setAttribute("aria-labelledby", button.id);
|
|
82
|
+
return button;
|
|
83
|
+
});
|
|
84
|
+
this.prepend(tablist);
|
|
85
|
+
const sync = this.getAttribute("sync");
|
|
86
|
+
let initial = 0;
|
|
87
|
+
if (sync !== null) {
|
|
88
|
+
syncedGroups.add(this);
|
|
89
|
+
const remembered = readChoice(sync);
|
|
90
|
+
const match = remembered === null ? -1 : this.#indexOfValue(remembered);
|
|
91
|
+
if (match >= 0)
|
|
92
|
+
initial = match;
|
|
93
|
+
}
|
|
94
|
+
this.#select(initial);
|
|
95
|
+
}
|
|
96
|
+
#teardown() {
|
|
97
|
+
if (!this.#ready)
|
|
98
|
+
return;
|
|
99
|
+
syncedGroups.delete(this);
|
|
100
|
+
this.#tablist?.remove();
|
|
101
|
+
for (const tab of this.#tabs) {
|
|
102
|
+
tab.removeAttribute("role");
|
|
103
|
+
tab.removeAttribute("aria-labelledby");
|
|
104
|
+
tab.removeAttribute("hidden");
|
|
105
|
+
}
|
|
106
|
+
this.#tablist = null;
|
|
107
|
+
this.#tabs = [];
|
|
108
|
+
this.#buttons = [];
|
|
109
|
+
this.#ready = false;
|
|
110
|
+
}
|
|
111
|
+
#indexOfValue(value) {
|
|
112
|
+
return this.#tabs.findIndex((tab) => valuesOf(tab).includes(value));
|
|
113
|
+
}
|
|
114
|
+
/** Select a tab without recording or syncing the choice. */
|
|
115
|
+
#select(index) {
|
|
116
|
+
this.#selected = index;
|
|
117
|
+
this.#tabs.forEach((tab, i) => {
|
|
118
|
+
tab.toggleAttribute("hidden", i !== index);
|
|
119
|
+
});
|
|
120
|
+
this.#buttons.forEach((button, i) => {
|
|
121
|
+
button.setAttribute("aria-selected", String(i === index));
|
|
122
|
+
button.tabIndex = i === index ? 0 : -1;
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
/** The reader picked a tab: select it and, for a synced group, tell the rest. */
|
|
126
|
+
#choose(index) {
|
|
127
|
+
this.#select(index);
|
|
128
|
+
const sync = this.getAttribute("sync");
|
|
129
|
+
const tab = this.#tabs[index];
|
|
130
|
+
const choice = tab ? valuesOf(tab)[0] : undefined;
|
|
131
|
+
if (sync === null || choice === undefined)
|
|
132
|
+
return;
|
|
133
|
+
writeChoice(sync, choice);
|
|
134
|
+
for (const group of syncedGroups) {
|
|
135
|
+
if (group !== this && group.getAttribute("sync") === sync)
|
|
136
|
+
group.#follow(choice);
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
/** Another group with the same `sync` made a choice; keep our selection if we have no match. */
|
|
140
|
+
#follow(value) {
|
|
141
|
+
const index = this.#indexOfValue(value);
|
|
142
|
+
if (index >= 0)
|
|
143
|
+
this.#select(index);
|
|
144
|
+
}
|
|
145
|
+
#onKeydown(event) {
|
|
146
|
+
const last = this.#tabs.length - 1;
|
|
147
|
+
let next;
|
|
148
|
+
switch (event.key) {
|
|
149
|
+
case "ArrowRight":
|
|
150
|
+
next = this.#selected === last ? 0 : this.#selected + 1;
|
|
151
|
+
break;
|
|
152
|
+
case "ArrowLeft":
|
|
153
|
+
next = this.#selected === 0 ? last : this.#selected - 1;
|
|
154
|
+
break;
|
|
155
|
+
case "Home":
|
|
156
|
+
next = 0;
|
|
157
|
+
break;
|
|
158
|
+
case "End":
|
|
159
|
+
next = last;
|
|
160
|
+
break;
|
|
161
|
+
default:
|
|
162
|
+
return;
|
|
163
|
+
}
|
|
164
|
+
event.preventDefault();
|
|
165
|
+
this.#choose(next);
|
|
166
|
+
this.#buttons[next]?.focus();
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
//# sourceMappingURL=tabs.js.map
|
package/dist/tabs.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tabs.js","sourceRoot":"","sources":["../src/tabs.ts"],"names":[],"mappings":"AAAA,wEAAwE;AACxE,4EAA4E;AAC5E,wEAAwE;AACxE,WAAW;AAEX,MAAM,cAAc,GAAG,eAAe,CAAC;AAEvC,6EAA6E;AAC7E,MAAM,WAAW,GAAG,IAAI,GAAG,EAAkB,CAAC;AAE9C,kEAAkE;AAClE,MAAM,YAAY,GAAG,IAAI,GAAG,EAAe,CAAC;AAE5C,IAAI,SAAS,GAAG,CAAC,CAAC;AAElB,SAAS,UAAU,CAAC,SAAiB;IACnC,uEAAuE;IACvE,8BAA8B;IAC9B,MAAM,MAAM,GAAG,WAAW,CAAC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R,KAAK,MAAM;gBACT,IAAI,GAAG,CAAC,CAAC;gBACT,MAAM;YACR,KAAK,KAAK;gBACR,IAAI,GAAG,IAAI,CAAC;gBACZ,MAAM;YACR;gBACE,OAAO;QACX,CAAC;QACD,KAAK,CAAC,cAAc,EAAE,CAAC;QACvB,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;QACnB,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,CAAC;IAC/B,CAAC;CACF"}
|
package/package.json
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@ascribed/elements",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Ascribe's web component library for the site output.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"license": "MPL-2.0",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "git+https://github.com/ascribed-dev/ascribe.git",
|
|
10
|
+
"directory": "packages/elements"
|
|
11
|
+
},
|
|
12
|
+
"homepage": "https://github.com/ascribed-dev/ascribe/tree/main/packages/elements#readme",
|
|
13
|
+
"bugs": "https://github.com/ascribed-dev/ascribe/issues",
|
|
14
|
+
"sideEffects": [
|
|
15
|
+
"./dist/index.js",
|
|
16
|
+
"*.css"
|
|
17
|
+
],
|
|
18
|
+
"files": [
|
|
19
|
+
"dist",
|
|
20
|
+
"css",
|
|
21
|
+
"CONTRACT.md",
|
|
22
|
+
"README.md"
|
|
23
|
+
],
|
|
24
|
+
"exports": {
|
|
25
|
+
".": {
|
|
26
|
+
"types": "./dist/index.d.ts",
|
|
27
|
+
"default": "./dist/index.js"
|
|
28
|
+
},
|
|
29
|
+
"./style.css": "./css/style.css"
|
|
30
|
+
},
|
|
31
|
+
"devDependencies": {
|
|
32
|
+
"@types/node": "^24.0.0",
|
|
33
|
+
"axe-core": "^4.10.0",
|
|
34
|
+
"playwright-core": "^1.50.0"
|
|
35
|
+
},
|
|
36
|
+
"publishConfig": {
|
|
37
|
+
"access": "public"
|
|
38
|
+
},
|
|
39
|
+
"scripts": {
|
|
40
|
+
"build": "tsc -p tsconfig.build.json",
|
|
41
|
+
"typecheck": "tsc --noEmit",
|
|
42
|
+
"test": "vitest run"
|
|
43
|
+
}
|
|
44
|
+
}
|