shelving 1.317.0 → 1.318.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/docs/llms-full.txt +23 -14
- package/docs/markup/AUTOLINK_RULE.md +2 -1
- package/docs/markup/ORDERED_RULE.md +1 -0
- package/docs/markup/UNORDERED_RULE.md +1 -0
- package/docs/markup.md +1 -1
- package/docs/ui/Notices.md +12 -6
- package/docs/ui/NoticesPosition.md +2 -2
- package/docs/ui/NoticesProps.md +2 -2
- package/docs/ui.md +2 -2
- package/markup/rule/link.d.ts +2 -1
- package/markup/rule/link.js +8 -3
- package/markup/rule/ordered.d.ts +1 -0
- package/markup/rule/ordered.js +12 -4
- package/markup/rule/unordered.d.ts +1 -0
- package/markup/rule/unordered.js +12 -4
- package/package.json +1 -1
- package/ui/notice/Notices.d.ts +6 -6
- package/ui/notice/Notices.js +5 -4
- package/ui/notice/Notices.md +9 -3
- package/ui/notice/Notices.module.css +7 -2
- package/ui/notice/Notices.tsx +9 -8
- package/ui/notice/NoticesTransition.module.css +69 -3
package/docs/llms-full.txt
CHANGED
|
@@ -10030,7 +10030,7 @@ If the text reaches you straight from a `StringSchema`-validated field it is alr
|
|
|
10030
10030
|
- [INLINE_RULE](markup/INLINE_RULE.md): Inline strong, emphasis, insert, delete, highlight.
|
|
10031
10031
|
- [LINEBREAK_RULE](markup/LINEBREAK_RULE.md): Hard linebreak (<br /> tag).
|
|
10032
10032
|
- [LINK_RULE](markup/LINK_RULE.md): Markdown-style link.
|
|
10033
|
-
- [AUTOLINK_RULE](markup/AUTOLINK_RULE.md): Autolinked URL starts with scheme: (any scheme in MarkupOptions.schemes) and matches an unlimited number of non-space characters.
|
|
10033
|
+
- [AUTOLINK_RULE](markup/AUTOLINK_RULE.md): Autolinked URL starts with scheme: (any scheme in MarkupOptions.schemes) and matches an unlimited number of non-space characters (except < and >).
|
|
10034
10034
|
- [ORDERED_RULE](markup/ORDERED_RULE.md): Ordered list.
|
|
10035
10035
|
- [PARAGRAPH_RULE](markup/PARAGRAPH_RULE.md): Paragraph.
|
|
10036
10036
|
- [SEPARATOR_RULE](markup/SEPARATOR_RULE.md): Separator (horizontal rule / thematic break).
|
|
@@ -10658,7 +10658,8 @@ new MarkupParser({ rules: [LINK_RULE] }).parse("[Google Maps](http://google.com/
|
|
|
10658
10658
|
- Kind: constant
|
|
10659
10659
|
- Import: `import { AUTOLINK_RULE } from "shelving/markup";`
|
|
10660
10660
|
|
|
10661
|
-
Autolinked URL starts with `scheme:` (any scheme in `MarkupOptions.schemes`) and matches an unlimited number of non-space characters.
|
|
10661
|
+
Autolinked URL starts with `scheme:` (any scheme in `MarkupOptions.schemes`) and matches an unlimited number of non-space characters (except `<` and `>`).
|
|
10662
|
+
- URL can be wrapped in `<>` angle brackets (the standard Markdown autolink syntax), e.g. `<http://google.com/maps>`. The brackets are not part of the link.
|
|
10662
10663
|
- If followed by space and then text in `()` round or `[]` square brackets that will be used as the title, e.g. `http://google.com/maps (Google Maps)` or `http://google.com/maps [Google Maps]` (this syntax is from Todoist and maybe other things too).
|
|
10663
10664
|
- If no title is specified a cleaned up version of the URL will be used, e.g. `google.com/maps`
|
|
10664
10665
|
- If link is not valid (using `new URL(url)` then unparsed text will be returned.
|
|
@@ -10682,6 +10683,7 @@ Ordered list.
|
|
|
10682
10683
|
- Line starting with number, followed by `.`, `)` or `:` character, then one or more space characters.
|
|
10683
10684
|
- No spaces can appear before the number character.
|
|
10684
10685
|
- Second-level list can be created by indenting with `\t` one tab.
|
|
10686
|
+
- Continuation lines can also be indented with spaces to the width of the number and its spaces, e.g. three spaces after `1. `, so a fenced code block can go inside an item.
|
|
10685
10687
|
- List block runs until a blank line that is not followed by another item or an indented continuation line.
|
|
10686
10688
|
- A list with blank lines between its items (or before a continuation paragraph) is "loose": its items are wrapped in `<p>` tags.
|
|
10687
10689
|
- Sparse lists are not supported.
|
|
@@ -10764,6 +10766,7 @@ Unordered list.
|
|
|
10764
10766
|
- Line starting with `-`, `*`, `•`, or `+` character followed by one or more space characters.
|
|
10765
10767
|
- No spaces can appear before the bullet character.
|
|
10766
10768
|
- Second-level list can be created by indenting with `\t` one tab.
|
|
10769
|
+
- Continuation lines can also be indented with spaces to the width of the bullet and its spaces, e.g. two spaces after `- `, so a fenced code block can go inside an item.
|
|
10767
10770
|
- List block runs until a blank line that is not followed by another item or an indented continuation line.
|
|
10768
10771
|
- A list with blank lines between its items (or before a continuation paragraph) is "loose": its items are wrapped in `<p>` tags.
|
|
10769
10772
|
- An item starting with `[ ]` or `[x]` (case-insensitive) is a todo item: a checkbox `<input>` plus the content wrapped in a `<label>` so clicking it toggles the checkbox.
|
|
@@ -20299,7 +20302,7 @@ The components below are listed in the index following this page; this is the sh
|
|
|
20299
20302
|
- [EmptyProps](ui/EmptyProps.md): Props for <Empty> — the message content plus an optional className.
|
|
20300
20303
|
- [MessageProps](ui/MessageProps.md): Props for <Message> — paragraph props plus colour and status styling variants.
|
|
20301
20304
|
- [NoticeProps](ui/NoticeProps.md): Props for <Notice> — flex/colour/status styling variants, optional children, and an optional icon.
|
|
20302
|
-
- [NoticesProps](ui/NoticesProps.md): Props for <Notices> — the
|
|
20305
|
+
- [NoticesProps](ui/NoticesProps.md): Props for <Notices> — the place for the list, and flex styling variants for the notices container.
|
|
20303
20306
|
- [HTMLProps](ui/HTMLProps.md): Props for <HTML> — initial Meta (language/root/app) plus the page children.
|
|
20304
20307
|
- [PageProps](ui/PageProps.md): Props for <Page> — per-page Meta (title, description, etc.) plus the page children.
|
|
20305
20308
|
- [NavigationProps](ui/NavigationProps.md): Props for <Navigation> — initial Meta (url/base) plus optional children.
|
|
@@ -20357,7 +20360,7 @@ The components below are listed in the index following this page; this is the sh
|
|
|
20357
20360
|
- [PopoverChildren](ui/PopoverChildren.md): Children tuple for Popover: a leading trigger node followed by the popover's contents.
|
|
20358
20361
|
- [TextFormatter](ui/TextFormatter.md): Formats a string for display in a text input.
|
|
20359
20362
|
- [Mapping](ui/Mapping.md): Dispatch table from a JSX.IntrinsicElements key to a renderer component.
|
|
20360
|
-
- [NoticesPosition](ui/NoticesPosition.md):
|
|
20363
|
+
- [NoticesPosition](ui/NoticesPosition.md): Place on the screen where <Notices> shows the list of notices: a corner, or the centre of the top or bottom edge.
|
|
20361
20364
|
- [RouteProps](ui/RouteProps.md): Props for a component that works as a route in the router.
|
|
20362
20365
|
- [RouteComponent](ui/RouteComponent.md): React component usable as a route value — a function or class component accepting RouteProps.
|
|
20363
20366
|
- [Route](ui/Route.md): Valid route values:
|
|
@@ -31267,12 +31270,12 @@ Shared loading `<Notice>` element showing the loading spinner.
|
|
|
31267
31270
|
- Kind: type
|
|
31268
31271
|
- Import: `import { NoticesPosition } from "shelving/ui";`
|
|
31269
31272
|
|
|
31270
|
-
|
|
31273
|
+
Place on the screen where `<Notices>` shows the list of notices: a corner, or the centre of the top or bottom edge.
|
|
31271
31274
|
|
|
31272
31275
|
## Signatures
|
|
31273
31276
|
|
|
31274
31277
|
```ts
|
|
31275
|
-
"top
|
|
31278
|
+
`${"top" | "bottom"}-${"left" | "center" | "right"}`
|
|
31276
31279
|
```
|
|
31277
31280
|
|
|
31278
31281
|
|
|
@@ -31284,7 +31287,7 @@ Corner of the screen where `<Notices>` shows the list of notices.
|
|
|
31284
31287
|
- Import: `import { NoticesProps } from "shelving/ui";`
|
|
31285
31288
|
- Extends: `FlexVariants`
|
|
31286
31289
|
|
|
31287
|
-
Props for `<Notices>` — the
|
|
31290
|
+
Props for `<Notices>` — the place for the list, and flex styling variants for the notices container.
|
|
31288
31291
|
|
|
31289
31292
|
## Signatures
|
|
31290
31293
|
|
|
@@ -31298,7 +31301,7 @@ Props for `<Notices>` — the corner for the list, and flex styling variants for
|
|
|
31298
31301
|
|
|
31299
31302
|
| Property | Type | Description |
|
|
31300
31303
|
| --- | --- | --- |
|
|
31301
|
-
| `position` | `NoticesPosition \| undefined` |
|
|
31304
|
+
| `position` | `NoticesPosition \| undefined` | Place on the screen for the list. New notices slide in from this side, or from the top or bottom edge for a centred list. Defaults to `"bottom-right"`. |
|
|
31302
31305
|
|
|
31303
31306
|
|
|
31304
31307
|
---
|
|
@@ -31311,8 +31314,8 @@ Props for `<Notices>` — the corner for the list, and flex styling variants for
|
|
|
31311
31314
|
Render the global list of notices and subscribe to incoming `"notice"` events.
|
|
31312
31315
|
- Listens for `"notice"` events on `window` (or that bubble up to `window`) and shows them in the global notice list.
|
|
31313
31316
|
- This is how e.g. `<Button>` and `<FormNotify>` components send notices into the global list.
|
|
31314
|
-
- Shows the list in the bottom-right corner, or in the
|
|
31315
|
-
- Each notice slides in and out in its own view transition, from the side of its corner. The other notices move to their new places in the same transition.
|
|
31317
|
+
- Shows the list in the bottom-right corner, or in the place that `position` sets.
|
|
31318
|
+
- Each notice slides in and out in its own view transition, from the side of its corner, or from the edge for a centred list. The other notices move to their new places in the same transition.
|
|
31316
31319
|
|
|
31317
31320
|
Renders the global list of active notices and subscribes to incoming `"notice"` events. It listens for `"notice"` events on `window` (dispatched by the `notify()` helpers) and shows each one as a `<Notice>` — this is how components like `<Button>` and `<FormNotify>` send notices into the global list.
|
|
31318
31321
|
|
|
@@ -31321,8 +31324,8 @@ Renders the global list of active notices and subscribes to incoming `"notice"`
|
|
|
31321
31324
|
- Mount `<Notices>` once near the root of your app. It renders at that point in the DOM and listens automatically — no context required.
|
|
31322
31325
|
- Notices auto-dismiss after a short delay unless they carry a `"loading"` status.
|
|
31323
31326
|
- Backed by the `NOTICES` store singleton; for advanced use you can keep a reference to a notice to update or close it manually.
|
|
31324
|
-
- The list shows in the bottom-right corner. Set `position` to `"top-left"`, `"top-right"`, `"bottom-left"`, or `"bottom-right"` to choose a different
|
|
31325
|
-
- Notices animate with [view transitions](https://developer.mozilla.org/en-US/docs/Web/API/View_Transition_API). A new notice slides in from the side of its corner, and a closed notice slides out to that side. The other notices move to their new places. A notice that changes in place (for example from loading to success) changes at once, with no animation.
|
|
31327
|
+
- The list shows in the bottom-right corner. Set `position` to `"top-left"`, `"top-center"`, `"top-right"`, `"bottom-left"`, `"bottom-center"`, or `"bottom-right"` to choose a different place.
|
|
31328
|
+
- Notices animate with [view transitions](https://developer.mozilla.org/en-US/docs/Web/API/View_Transition_API). A new notice slides in from the side of its corner, and a closed notice slides out to that side. In a centred list, notices slide in and out from the top or bottom edge. The other notices move to their new places. A notice that changes in place (for example from loading to success) changes at once, with no animation.
|
|
31326
31329
|
- With reduced motion, notices fade in and out in place, and the others move at once. A browser without view transitions shows the changes at once.
|
|
31327
31330
|
|
|
31328
31331
|
## Usage
|
|
@@ -31348,6 +31351,12 @@ Show the list in the top-left corner:
|
|
|
31348
31351
|
<Notices position="top-left" />
|
|
31349
31352
|
```
|
|
31350
31353
|
|
|
31354
|
+
Show the list at the top of the screen, in the centre:
|
|
31355
|
+
|
|
31356
|
+
```tsx
|
|
31357
|
+
<Notices position="top-center" />
|
|
31358
|
+
```
|
|
31359
|
+
|
|
31351
31360
|
Dispatch notices from anywhere — no context required:
|
|
31352
31361
|
|
|
31353
31362
|
```tsx
|
|
@@ -31377,7 +31386,7 @@ notice.close(); // Or close it immediately.
|
|
|
31377
31386
|
|
|
31378
31387
|
## Styling
|
|
31379
31388
|
|
|
31380
|
-
`Notices` positions the list in the
|
|
31389
|
+
`Notices` positions the list in the place that `position` sets. Each notice is only as wide as its content and is aligned to the side of that corner, or to the centre. The list is never wider than `--notices-width`, and keeps `--notices-offset` clear at both sides on a narrow screen. The offset also adds the safe area of the device (`env(safe-area-inset-*)`). Clicks pass through the gaps between notices to the page. Each item is a `<Notice>`, which has its own hooks. Override these hooks at `:root` (or any ancestor scope) to retheme.
|
|
31381
31390
|
|
|
31382
31391
|
| Variable | Styles | Default |
|
|
31383
31392
|
|---|---|---|
|
|
@@ -31401,7 +31410,7 @@ Notices({ position = "bottom-right", className, ...props }: NoticesProps): React
|
|
|
31401
31410
|
| Param | Type | Description |
|
|
31402
31411
|
| --- | --- | --- |
|
|
31403
31412
|
| `props` | `NoticesProps` | |
|
|
31404
|
-
| `.position` | `NoticesPosition \| undefined` |
|
|
31413
|
+
| `.position` | `NoticesPosition \| undefined` | Place on the screen for the list. New notices slide in from this side, or from the top or bottom edge for a centred list. Defaults to `"bottom-right"`. |
|
|
31405
31414
|
|
|
31406
31415
|
## Returns
|
|
31407
31416
|
|
|
@@ -3,7 +3,8 @@
|
|
|
3
3
|
- Kind: constant
|
|
4
4
|
- Import: `import { AUTOLINK_RULE } from "shelving/markup";`
|
|
5
5
|
|
|
6
|
-
Autolinked URL starts with `scheme:` (any scheme in `MarkupOptions.schemes`) and matches an unlimited number of non-space characters.
|
|
6
|
+
Autolinked URL starts with `scheme:` (any scheme in `MarkupOptions.schemes`) and matches an unlimited number of non-space characters (except `<` and `>`).
|
|
7
|
+
- URL can be wrapped in `<>` angle brackets (the standard Markdown autolink syntax), e.g. `<http://google.com/maps>`. The brackets are not part of the link.
|
|
7
8
|
- If followed by space and then text in `()` round or `[]` square brackets that will be used as the title, e.g. `http://google.com/maps (Google Maps)` or `http://google.com/maps [Google Maps]` (this syntax is from Todoist and maybe other things too).
|
|
8
9
|
- If no title is specified a cleaned up version of the URL will be used, e.g. `google.com/maps`
|
|
9
10
|
- If link is not valid (using `new URL(url)` then unparsed text will be returned.
|
|
@@ -7,6 +7,7 @@ Ordered list.
|
|
|
7
7
|
- Line starting with number, followed by `.`, `)` or `:` character, then one or more space characters.
|
|
8
8
|
- No spaces can appear before the number character.
|
|
9
9
|
- Second-level list can be created by indenting with `\t` one tab.
|
|
10
|
+
- Continuation lines can also be indented with spaces to the width of the number and its spaces, e.g. three spaces after `1. `, so a fenced code block can go inside an item.
|
|
10
11
|
- List block runs until a blank line that is not followed by another item or an indented continuation line.
|
|
11
12
|
- A list with blank lines between its items (or before a continuation paragraph) is "loose": its items are wrapped in `<p>` tags.
|
|
12
13
|
- Sparse lists are not supported.
|
|
@@ -7,6 +7,7 @@ Unordered list.
|
|
|
7
7
|
- Line starting with `-`, `*`, `•`, or `+` character followed by one or more space characters.
|
|
8
8
|
- No spaces can appear before the bullet character.
|
|
9
9
|
- Second-level list can be created by indenting with `\t` one tab.
|
|
10
|
+
- Continuation lines can also be indented with spaces to the width of the bullet and its spaces, e.g. two spaces after `- `, so a fenced code block can go inside an item.
|
|
10
11
|
- List block runs until a blank line that is not followed by another item or an indented continuation line.
|
|
11
12
|
- A list with blank lines between its items (or before a continuation paragraph) is "loose": its items are wrapped in `<p>` tags.
|
|
12
13
|
- An item starting with `[ ]` or `[x]` (case-insensitive) is a todo item: a checkbox `<input>` plus the content wrapped in a `<label>` so clicking it toggles the checkbox.
|
package/docs/markup.md
CHANGED
|
@@ -168,7 +168,7 @@ If the text reaches you straight from a `StringSchema`-validated field it is alr
|
|
|
168
168
|
- [INLINE_RULE](markup/INLINE_RULE.md): Inline strong, emphasis, insert, delete, highlight.
|
|
169
169
|
- [LINEBREAK_RULE](markup/LINEBREAK_RULE.md): Hard linebreak (<br /> tag).
|
|
170
170
|
- [LINK_RULE](markup/LINK_RULE.md): Markdown-style link.
|
|
171
|
-
- [AUTOLINK_RULE](markup/AUTOLINK_RULE.md): Autolinked URL starts with scheme: (any scheme in MarkupOptions.schemes) and matches an unlimited number of non-space characters.
|
|
171
|
+
- [AUTOLINK_RULE](markup/AUTOLINK_RULE.md): Autolinked URL starts with scheme: (any scheme in MarkupOptions.schemes) and matches an unlimited number of non-space characters (except < and >).
|
|
172
172
|
- [ORDERED_RULE](markup/ORDERED_RULE.md): Ordered list.
|
|
173
173
|
- [PARAGRAPH_RULE](markup/PARAGRAPH_RULE.md): Paragraph.
|
|
174
174
|
- [SEPARATOR_RULE](markup/SEPARATOR_RULE.md): Separator (horizontal rule / thematic break).
|
package/docs/ui/Notices.md
CHANGED
|
@@ -6,8 +6,8 @@
|
|
|
6
6
|
Render the global list of notices and subscribe to incoming `"notice"` events.
|
|
7
7
|
- Listens for `"notice"` events on `window` (or that bubble up to `window`) and shows them in the global notice list.
|
|
8
8
|
- This is how e.g. `<Button>` and `<FormNotify>` components send notices into the global list.
|
|
9
|
-
- Shows the list in the bottom-right corner, or in the
|
|
10
|
-
- Each notice slides in and out in its own view transition, from the side of its corner. The other notices move to their new places in the same transition.
|
|
9
|
+
- Shows the list in the bottom-right corner, or in the place that `position` sets.
|
|
10
|
+
- Each notice slides in and out in its own view transition, from the side of its corner, or from the edge for a centred list. The other notices move to their new places in the same transition.
|
|
11
11
|
|
|
12
12
|
Renders the global list of active notices and subscribes to incoming `"notice"` events. It listens for `"notice"` events on `window` (dispatched by the `notify()` helpers) and shows each one as a `<Notice>` — this is how components like `<Button>` and `<FormNotify>` send notices into the global list.
|
|
13
13
|
|
|
@@ -16,8 +16,8 @@ Renders the global list of active notices and subscribes to incoming `"notice"`
|
|
|
16
16
|
- Mount `<Notices>` once near the root of your app. It renders at that point in the DOM and listens automatically — no context required.
|
|
17
17
|
- Notices auto-dismiss after a short delay unless they carry a `"loading"` status.
|
|
18
18
|
- Backed by the `NOTICES` store singleton; for advanced use you can keep a reference to a notice to update or close it manually.
|
|
19
|
-
- The list shows in the bottom-right corner. Set `position` to `"top-left"`, `"top-right"`, `"bottom-left"`, or `"bottom-right"` to choose a different
|
|
20
|
-
- Notices animate with [view transitions](https://developer.mozilla.org/en-US/docs/Web/API/View_Transition_API). A new notice slides in from the side of its corner, and a closed notice slides out to that side. The other notices move to their new places. A notice that changes in place (for example from loading to success) changes at once, with no animation.
|
|
19
|
+
- The list shows in the bottom-right corner. Set `position` to `"top-left"`, `"top-center"`, `"top-right"`, `"bottom-left"`, `"bottom-center"`, or `"bottom-right"` to choose a different place.
|
|
20
|
+
- Notices animate with [view transitions](https://developer.mozilla.org/en-US/docs/Web/API/View_Transition_API). A new notice slides in from the side of its corner, and a closed notice slides out to that side. In a centred list, notices slide in and out from the top or bottom edge. The other notices move to their new places. A notice that changes in place (for example from loading to success) changes at once, with no animation.
|
|
21
21
|
- With reduced motion, notices fade in and out in place, and the others move at once. A browser without view transitions shows the changes at once.
|
|
22
22
|
|
|
23
23
|
## Usage
|
|
@@ -43,6 +43,12 @@ Show the list in the top-left corner:
|
|
|
43
43
|
<Notices position="top-left" />
|
|
44
44
|
```
|
|
45
45
|
|
|
46
|
+
Show the list at the top of the screen, in the centre:
|
|
47
|
+
|
|
48
|
+
```tsx
|
|
49
|
+
<Notices position="top-center" />
|
|
50
|
+
```
|
|
51
|
+
|
|
46
52
|
Dispatch notices from anywhere — no context required:
|
|
47
53
|
|
|
48
54
|
```tsx
|
|
@@ -72,7 +78,7 @@ notice.close(); // Or close it immediately.
|
|
|
72
78
|
|
|
73
79
|
## Styling
|
|
74
80
|
|
|
75
|
-
`Notices` positions the list in the
|
|
81
|
+
`Notices` positions the list in the place that `position` sets. Each notice is only as wide as its content and is aligned to the side of that corner, or to the centre. The list is never wider than `--notices-width`, and keeps `--notices-offset` clear at both sides on a narrow screen. The offset also adds the safe area of the device (`env(safe-area-inset-*)`). Clicks pass through the gaps between notices to the page. Each item is a `<Notice>`, which has its own hooks. Override these hooks at `:root` (or any ancestor scope) to retheme.
|
|
76
82
|
|
|
77
83
|
| Variable | Styles | Default |
|
|
78
84
|
|---|---|---|
|
|
@@ -96,7 +102,7 @@ Notices({ position = "bottom-right", className, ...props }: NoticesProps): React
|
|
|
96
102
|
| Param | Type | Description |
|
|
97
103
|
| --- | --- | --- |
|
|
98
104
|
| `props` | `NoticesProps` | |
|
|
99
|
-
| `.position` | `NoticesPosition \| undefined` |
|
|
105
|
+
| `.position` | `NoticesPosition \| undefined` | Place on the screen for the list. New notices slide in from this side, or from the top or bottom edge for a centred list. Defaults to `"bottom-right"`. |
|
|
100
106
|
|
|
101
107
|
## Returns
|
|
102
108
|
|
|
@@ -3,10 +3,10 @@
|
|
|
3
3
|
- Kind: type
|
|
4
4
|
- Import: `import { NoticesPosition } from "shelving/ui";`
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
Place on the screen where `<Notices>` shows the list of notices: a corner, or the centre of the top or bottom edge.
|
|
7
7
|
|
|
8
8
|
## Signatures
|
|
9
9
|
|
|
10
10
|
```ts
|
|
11
|
-
"top
|
|
11
|
+
`${"top" | "bottom"}-${"left" | "center" | "right"}`
|
|
12
12
|
```
|
package/docs/ui/NoticesProps.md
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
- Import: `import { NoticesProps } from "shelving/ui";`
|
|
5
5
|
- Extends: `FlexVariants`
|
|
6
6
|
|
|
7
|
-
Props for `<Notices>` — the
|
|
7
|
+
Props for `<Notices>` — the place for the list, and flex styling variants for the notices container.
|
|
8
8
|
|
|
9
9
|
## Signatures
|
|
10
10
|
|
|
@@ -18,4 +18,4 @@ Props for `<Notices>` — the corner for the list, and flex styling variants for
|
|
|
18
18
|
|
|
19
19
|
| Property | Type | Description |
|
|
20
20
|
| --- | --- | --- |
|
|
21
|
-
| `position` | `NoticesPosition \| undefined` |
|
|
21
|
+
| `position` | `NoticesPosition \| undefined` | Place on the screen for the list. New notices slide in from this side, or from the top or bottom edge for a centred list. Defaults to `"bottom-right"`. |
|
package/docs/ui.md
CHANGED
|
@@ -433,7 +433,7 @@ The components below are listed in the index following this page; this is the sh
|
|
|
433
433
|
- [EmptyProps](ui/EmptyProps.md): Props for <Empty> — the message content plus an optional className.
|
|
434
434
|
- [MessageProps](ui/MessageProps.md): Props for <Message> — paragraph props plus colour and status styling variants.
|
|
435
435
|
- [NoticeProps](ui/NoticeProps.md): Props for <Notice> — flex/colour/status styling variants, optional children, and an optional icon.
|
|
436
|
-
- [NoticesProps](ui/NoticesProps.md): Props for <Notices> — the
|
|
436
|
+
- [NoticesProps](ui/NoticesProps.md): Props for <Notices> — the place for the list, and flex styling variants for the notices container.
|
|
437
437
|
- [HTMLProps](ui/HTMLProps.md): Props for <HTML> — initial Meta (language/root/app) plus the page children.
|
|
438
438
|
- [PageProps](ui/PageProps.md): Props for <Page> — per-page Meta (title, description, etc.) plus the page children.
|
|
439
439
|
- [NavigationProps](ui/NavigationProps.md): Props for <Navigation> — initial Meta (url/base) plus optional children.
|
|
@@ -491,7 +491,7 @@ The components below are listed in the index following this page; this is the sh
|
|
|
491
491
|
- [PopoverChildren](ui/PopoverChildren.md): Children tuple for Popover: a leading trigger node followed by the popover's contents.
|
|
492
492
|
- [TextFormatter](ui/TextFormatter.md): Formats a string for display in a text input.
|
|
493
493
|
- [Mapping](ui/Mapping.md): Dispatch table from a JSX.IntrinsicElements key to a renderer component.
|
|
494
|
-
- [NoticesPosition](ui/NoticesPosition.md):
|
|
494
|
+
- [NoticesPosition](ui/NoticesPosition.md): Place on the screen where <Notices> shows the list of notices: a corner, or the centre of the top or bottom edge.
|
|
495
495
|
- [RouteProps](ui/RouteProps.md): Props for a component that works as a route in the router.
|
|
496
496
|
- [RouteComponent](ui/RouteComponent.md): React component usable as a route value — a function or class component accepting RouteProps.
|
|
497
497
|
- [Route](ui/Route.md): Valid route values:
|
package/markup/rule/link.d.ts
CHANGED
|
@@ -11,7 +11,8 @@
|
|
|
11
11
|
*/
|
|
12
12
|
export declare const LINK_RULE: import("../MarkupRule.js").MarkupRule;
|
|
13
13
|
/**
|
|
14
|
-
* Autolinked URL starts with `scheme:` (any scheme in `MarkupOptions.schemes`) and matches an unlimited number of non-space characters.
|
|
14
|
+
* Autolinked URL starts with `scheme:` (any scheme in `MarkupOptions.schemes`) and matches an unlimited number of non-space characters (except `<` and `>`).
|
|
15
|
+
* - URL can be wrapped in `<>` angle brackets (the standard Markdown autolink syntax), e.g. `<http://google.com/maps>`. The brackets are not part of the link.
|
|
15
16
|
* - If followed by space and then text in `()` round or `[]` square brackets that will be used as the title, e.g. `http://google.com/maps (Google Maps)` or `http://google.com/maps [Google Maps]` (this syntax is from Todoist and maybe other things too).
|
|
16
17
|
* - If no title is specified a cleaned up version of the URL will be used, e.g. `google.com/maps`
|
|
17
18
|
* - If link is not valid (using `new URL(url)` then unparsed text will be returned.
|
package/markup/rule/link.js
CHANGED
|
@@ -20,8 +20,13 @@ function _renderLink(key, { title, href }, parser) {
|
|
|
20
20
|
*/
|
|
21
21
|
export const LINK_RULE = createMarkupRule(getRegExp(/\[(?<title>[^\]\n]*?)\]\((?<href>[^)\n]*?)\)/), //
|
|
22
22
|
_renderLink, ["inline", "list"]);
|
|
23
|
+
/** Render an autolink from whichever of its two URL forms matched. */
|
|
24
|
+
function _renderAutolink(key, { angled, href = "", ...data }, parser) {
|
|
25
|
+
return _renderLink(key, { ...data, href: angled ?? href }, parser);
|
|
26
|
+
}
|
|
23
27
|
/**
|
|
24
|
-
* Autolinked URL starts with `scheme:` (any scheme in `MarkupOptions.schemes`) and matches an unlimited number of non-space characters.
|
|
28
|
+
* Autolinked URL starts with `scheme:` (any scheme in `MarkupOptions.schemes`) and matches an unlimited number of non-space characters (except `<` and `>`).
|
|
29
|
+
* - URL can be wrapped in `<>` angle brackets (the standard Markdown autolink syntax), e.g. `<http://google.com/maps>`. The brackets are not part of the link.
|
|
25
30
|
* - If followed by space and then text in `()` round or `[]` square brackets that will be used as the title, e.g. `http://google.com/maps (Google Maps)` or `http://google.com/maps [Google Maps]` (this syntax is from Todoist and maybe other things too).
|
|
26
31
|
* - If no title is specified a cleaned up version of the URL will be used, e.g. `google.com/maps`
|
|
27
32
|
* - If link is not valid (using `new URL(url)` then unparsed text will be returned.
|
|
@@ -32,5 +37,5 @@ _renderLink, ["inline", "list"]);
|
|
|
32
37
|
*/
|
|
33
38
|
export const AUTOLINK_RULE = createMarkupRule(
|
|
34
39
|
// Scheme length is bounded (`{3,64}?`) so a long run of letters with no `:` can't force O(n²) backtracking.
|
|
35
|
-
getRegExp(/(?<href>[a-z]{3,64}
|
|
36
|
-
|
|
40
|
+
getRegExp(/(?:<(?<angled>[a-z]{3,64}?:[^\s<>]+)>|(?<href>[a-z]{3,64}?:[^\s<>]+))(?: +(?:\((?<title>[^)\n]*?)\)))?/), //
|
|
41
|
+
_renderAutolink, ["inline", "list"]);
|
package/markup/rule/ordered.d.ts
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
* - Line starting with number, followed by `.`, `)` or `:` character, then one or more space characters.
|
|
4
4
|
* - No spaces can appear before the number character.
|
|
5
5
|
* - Second-level list can be created by indenting with `\t` one tab.
|
|
6
|
+
* - Continuation lines can also be indented with spaces to the width of the number and its spaces, e.g. three spaces after `1. `, so a fenced code block can go inside an item.
|
|
6
7
|
* - List block runs until a blank line that is not followed by another item or an indented continuation line.
|
|
7
8
|
* - A list with blank lines between its items (or before a continuation paragraph) is "loose": its items are wrapped in `<p>` tags.
|
|
8
9
|
* - Sparse lists are not supported.
|
package/markup/rule/ordered.js
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { createMarkupRule } from "../MarkupRule.js";
|
|
3
3
|
import { BLOCK_CONTENT_REGEXP, BLOCK_SPACE_REGEXP, BLOCK_START_REGEXP, createBlockRegExp, LINE_SPACE_REGEXP } from "../util/regexp.js";
|
|
4
|
-
const _INDENT = /^\t/gm; // Nesting is recognised with tabs only.
|
|
5
4
|
const _NUMBER = "\\d{1,9}[.):]"; // Number for a numbered list, e.g. `1.` or `2)` or `3:` followed by one or more spaces.
|
|
6
|
-
const _ITEM = new RegExp(`(?:^|\n)(${_NUMBER})(
|
|
5
|
+
const _ITEM = new RegExp(`(?:^|\n)(${_NUMBER})(?:(${LINE_SPACE_REGEXP}+)(${BLOCK_CONTENT_REGEXP}))?${BLOCK_SPACE_REGEXP}*(?=\n${_NUMBER}(?:\\s|$)|$)`, "g");
|
|
7
6
|
// End of a list block: the end of the string, or a blank line that is *not* followed by another
|
|
8
7
|
// item or an indented continuation line. A blank line before a new item or a continuation
|
|
9
8
|
// paragraph keeps the list going (a "loose" list); anything else ends the list.
|
|
@@ -16,6 +15,7 @@ const _LOOSE = new RegExp(`\\n${LINE_SPACE_REGEXP}*\\n`);
|
|
|
16
15
|
* - Line starting with number, followed by `.`, `)` or `:` character, then one or more space characters.
|
|
17
16
|
* - No spaces can appear before the number character.
|
|
18
17
|
* - Second-level list can be created by indenting with `\t` one tab.
|
|
18
|
+
* - Continuation lines can also be indented with spaces to the width of the number and its spaces, e.g. three spaces after `1. `, so a fenced code block can go inside an item.
|
|
19
19
|
* - List block runs until a blank line that is not followed by another item or an indented continuation line.
|
|
20
20
|
* - A list with blank lines between its items (or before a continuation paragraph) is "loose": its items are wrapped in `<p>` tags.
|
|
21
21
|
* - Sparse lists are not supported.
|
|
@@ -29,7 +29,15 @@ function* _getOrderedItems(list, parser) {
|
|
|
29
29
|
// Items of a loose list are parsed as blocks so `PARAGRAPH_RULE` wraps their content in `<p>`.
|
|
30
30
|
const context = _LOOSE.test(list) ? "block" : "list";
|
|
31
31
|
let key = 0;
|
|
32
|
-
for (const [_unused, number = "", item = ""] of list.matchAll(_ITEM)) {
|
|
33
|
-
yield (_jsx("li", { value: Number.parseInt(number, 10), children: parser.parse(item
|
|
32
|
+
for (const [_unused, number = "", space = "", item = ""] of list.matchAll(_ITEM)) {
|
|
33
|
+
yield (_jsx("li", { value: Number.parseInt(number, 10), children: parser.parse(_unindent(item, number.length + space.length), context) }, key++));
|
|
34
34
|
}
|
|
35
35
|
}
|
|
36
|
+
/**
|
|
37
|
+
* Remove one level of indent from each continuation line of a list item.
|
|
38
|
+
* - One tab is one level (used for nested lists).
|
|
39
|
+
* - Up to `width` spaces is one level, where `width` is the width of the item's marker plus its spaces (as in standard Markdown).
|
|
40
|
+
*/
|
|
41
|
+
function _unindent(item, width) {
|
|
42
|
+
return item.replace(new RegExp(`^(?:\\t| {1,${width}})`, "gm"), "");
|
|
43
|
+
}
|
|
@@ -5,6 +5,7 @@ import type { MarkupParser } from "../MarkupParser.js";
|
|
|
5
5
|
* - Line starting with `-`, `*`, `•`, or `+` character followed by one or more space characters.
|
|
6
6
|
* - No spaces can appear before the bullet character.
|
|
7
7
|
* - Second-level list can be created by indenting with `\t` one tab.
|
|
8
|
+
* - Continuation lines can also be indented with spaces to the width of the bullet and its spaces, e.g. two spaces after `- `, so a fenced code block can go inside an item.
|
|
8
9
|
* - List block runs until a blank line that is not followed by another item or an indented continuation line.
|
|
9
10
|
* - A list with blank lines between its items (or before a continuation paragraph) is "loose": its items are wrapped in `<p>` tags.
|
|
10
11
|
* - An item starting with `[ ]` or `[x]` (case-insensitive) is a todo item: a checkbox `<input>` plus the content wrapped in a `<label>` so clicking it toggles the checkbox.
|
package/markup/rule/unordered.js
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { createMarkupRule } from "../MarkupRule.js";
|
|
3
3
|
import { BLOCK_CONTENT_REGEXP, BLOCK_SPACE_REGEXP, BLOCK_START_REGEXP, createBlockRegExp, LINE_SPACE_REGEXP } from "../util/regexp.js";
|
|
4
|
-
const _INDENT = /^\t/gm; // Nesting is recognised with tabs only.
|
|
5
4
|
const _BULLET = "[-*•+]"; // Allowed bullet symbol.
|
|
6
|
-
const _ITEM = new RegExp(`(?:^|\n)${_BULLET}(
|
|
5
|
+
const _ITEM = new RegExp(`(?:^|\n)${_BULLET}(?:(${LINE_SPACE_REGEXP}+)(${BLOCK_CONTENT_REGEXP}))?${BLOCK_SPACE_REGEXP}*(?=\n${_BULLET}(?:\\s|$)|$)`, "g");
|
|
7
6
|
// A GitHub-style todo checkbox at the start of an item: `[ ]` (unchecked) or `[x]` (checked,
|
|
8
7
|
// case-insensitive), which must be followed by whitespace or the end of the item.
|
|
9
8
|
const _CHECKBOX = /^\[([ xX])\](?!\S)[^\n\S]*/;
|
|
@@ -19,6 +18,7 @@ const _LOOSE = new RegExp(`\\n${LINE_SPACE_REGEXP}*\\n`);
|
|
|
19
18
|
* - Line starting with `-`, `*`, `•`, or `+` character followed by one or more space characters.
|
|
20
19
|
* - No spaces can appear before the bullet character.
|
|
21
20
|
* - Second-level list can be created by indenting with `\t` one tab.
|
|
21
|
+
* - Continuation lines can also be indented with spaces to the width of the bullet and its spaces, e.g. two spaces after `- `, so a fenced code block can go inside an item.
|
|
22
22
|
* - List block runs until a blank line that is not followed by another item or an indented continuation line.
|
|
23
23
|
* - A list with blank lines between its items (or before a continuation paragraph) is "loose": its items are wrapped in `<p>` tags.
|
|
24
24
|
* - An item starting with `[ ]` or `[x]` (case-insensitive) is a todo item: a checkbox `<input>` plus the content wrapped in a `<label>` so clicking it toggles the checkbox.
|
|
@@ -33,8 +33,8 @@ export function* _getItems(list, parser) {
|
|
|
33
33
|
// Items of a loose list are parsed as blocks so `PARAGRAPH_RULE` wraps their content in `<p>`.
|
|
34
34
|
const context = _LOOSE.test(list) ? "block" : "list";
|
|
35
35
|
let key = 0;
|
|
36
|
-
for (const [_unused, raw = ""] of list.matchAll(_ITEM)) {
|
|
37
|
-
const item = raw
|
|
36
|
+
for (const [_unused, space = "", raw = ""] of list.matchAll(_ITEM)) {
|
|
37
|
+
const item = _unindent(raw, 1 + space.length);
|
|
38
38
|
// A todo item renders a checkbox; the `<label>` wrapping the content toggles it on click.
|
|
39
39
|
const checkbox = _CHECKBOX.exec(item);
|
|
40
40
|
if (checkbox) {
|
|
@@ -45,3 +45,11 @@ export function* _getItems(list, parser) {
|
|
|
45
45
|
}
|
|
46
46
|
}
|
|
47
47
|
}
|
|
48
|
+
/**
|
|
49
|
+
* Remove one level of indent from each continuation line of a list item.
|
|
50
|
+
* - One tab is one level (used for nested lists).
|
|
51
|
+
* - Up to `width` spaces is one level, where `width` is the width of the item's marker plus its spaces (as in standard Markdown).
|
|
52
|
+
*/
|
|
53
|
+
function _unindent(item, width) {
|
|
54
|
+
return item.replace(new RegExp(`^(?:\\t| {1,${width}})`, "gm"), "");
|
|
55
|
+
}
|
package/package.json
CHANGED
package/ui/notice/Notices.d.ts
CHANGED
|
@@ -2,19 +2,19 @@ import { type ReactElement } from "react";
|
|
|
2
2
|
import { type FlexVariants } from "../style/Flex.js";
|
|
3
3
|
import type { ClassProps } from "../util/props.js";
|
|
4
4
|
/**
|
|
5
|
-
*
|
|
5
|
+
* Place on the screen where `<Notices>` shows the list of notices: a corner, or the centre of the top or bottom edge.
|
|
6
6
|
*
|
|
7
7
|
* @see https://shelving.cc/ui/NoticesPosition
|
|
8
8
|
*/
|
|
9
|
-
export type NoticesPosition = "top
|
|
9
|
+
export type NoticesPosition = `${"top" | "bottom"}-${"left" | "center" | "right"}`;
|
|
10
10
|
/**
|
|
11
|
-
* Props for `<Notices>` — the
|
|
11
|
+
* Props for `<Notices>` — the place for the list, and flex styling variants for the notices container.
|
|
12
12
|
*
|
|
13
13
|
* @see https://shelving.cc/ui/NoticesProps
|
|
14
14
|
*/
|
|
15
15
|
export interface NoticesProps extends FlexVariants, ClassProps {
|
|
16
16
|
/**
|
|
17
|
-
*
|
|
17
|
+
* Place on the screen for the list. New notices slide in from this side, or from the top or bottom edge for a centred list.
|
|
18
18
|
* @default "bottom-right"
|
|
19
19
|
*/
|
|
20
20
|
position?: NoticesPosition | undefined;
|
|
@@ -23,8 +23,8 @@ export interface NoticesProps extends FlexVariants, ClassProps {
|
|
|
23
23
|
* Render the global list of notices and subscribe to incoming `"notice"` events.
|
|
24
24
|
* - Listens for `"notice"` events on `window` (or that bubble up to `window`) and shows them in the global notice list.
|
|
25
25
|
* - This is how e.g. `<Button>` and `<FormNotify>` components send notices into the global list.
|
|
26
|
-
* - Shows the list in the bottom-right corner, or in the
|
|
27
|
-
* - Each notice slides in and out in its own view transition, from the side of its corner. The other notices move to their new places in the same transition.
|
|
26
|
+
* - Shows the list in the bottom-right corner, or in the place that `position` sets.
|
|
27
|
+
* - Each notice slides in and out in its own view transition, from the side of its corner, or from the edge for a centred list. The other notices move to their new places in the same transition.
|
|
28
28
|
*
|
|
29
29
|
* @kind component
|
|
30
30
|
* @see https://shelving.cc/ui/Notices
|
package/ui/notice/Notices.js
CHANGED
|
@@ -13,8 +13,8 @@ const NOTICES_CLASS = getModuleClass(NOTICES_CSS, "notices");
|
|
|
13
13
|
* Render the global list of notices and subscribe to incoming `"notice"` events.
|
|
14
14
|
* - Listens for `"notice"` events on `window` (or that bubble up to `window`) and shows them in the global notice list.
|
|
15
15
|
* - This is how e.g. `<Button>` and `<FormNotify>` components send notices into the global list.
|
|
16
|
-
* - Shows the list in the bottom-right corner, or in the
|
|
17
|
-
* - Each notice slides in and out in its own view transition, from the side of its corner. The other notices move to their new places in the same transition.
|
|
16
|
+
* - Shows the list in the bottom-right corner, or in the place that `position` sets.
|
|
17
|
+
* - Each notice slides in and out in its own view transition, from the side of its corner, or from the edge for a centred list. The other notices move to their new places in the same transition.
|
|
18
18
|
*
|
|
19
19
|
* @kind component
|
|
20
20
|
* @see https://shelving.cc/ui/Notices
|
|
@@ -34,7 +34,8 @@ export function Notices({ position = "bottom-right", className, ...props }) {
|
|
|
34
34
|
*/
|
|
35
35
|
function NoticeItem({ notice, position }) {
|
|
36
36
|
const { children, status } = useTransitionValue(notice);
|
|
37
|
-
// New and closed notices slide from the side of the corner. A notice that changes in place is drawn from the corner itself.
|
|
38
|
-
const
|
|
37
|
+
// New and closed notices slide from the side of the corner, or from the edge when centred. A notice that changes in place is drawn from the corner itself.
|
|
38
|
+
const [vertical, horizontal] = position.split("-");
|
|
39
|
+
const side = horizontal === "center" ? vertical : horizontal;
|
|
39
40
|
return (_jsx(ViewTransition, { enter: getModuleClass(NOTICES_TRANSITION_CSS, `notice-${side}`), exit: getModuleClass(NOTICES_TRANSITION_CSS, `notice-${side}`), update: getModuleClass(NOTICES_TRANSITION_CSS, `notice-update-${position}`), children: _jsx(Notice, { status: status, children: children }) }));
|
|
40
41
|
}
|
package/ui/notice/Notices.md
CHANGED
|
@@ -7,8 +7,8 @@ Renders the global list of active notices and subscribes to incoming `"notice"`
|
|
|
7
7
|
- Mount `<Notices>` once near the root of your app. It renders at that point in the DOM and listens automatically — no context required.
|
|
8
8
|
- Notices auto-dismiss after a short delay unless they carry a `"loading"` status.
|
|
9
9
|
- Backed by the `NOTICES` store singleton; for advanced use you can keep a reference to a notice to update or close it manually.
|
|
10
|
-
- The list shows in the bottom-right corner. Set `position` to `"top-left"`, `"top-right"`, `"bottom-left"`, or `"bottom-right"` to choose a different
|
|
11
|
-
- Notices animate with [view transitions](https://developer.mozilla.org/en-US/docs/Web/API/View_Transition_API). A new notice slides in from the side of its corner, and a closed notice slides out to that side. The other notices move to their new places. A notice that changes in place (for example from loading to success) changes at once, with no animation.
|
|
10
|
+
- The list shows in the bottom-right corner. Set `position` to `"top-left"`, `"top-center"`, `"top-right"`, `"bottom-left"`, `"bottom-center"`, or `"bottom-right"` to choose a different place.
|
|
11
|
+
- Notices animate with [view transitions](https://developer.mozilla.org/en-US/docs/Web/API/View_Transition_API). A new notice slides in from the side of its corner, and a closed notice slides out to that side. In a centred list, notices slide in and out from the top or bottom edge. The other notices move to their new places. A notice that changes in place (for example from loading to success) changes at once, with no animation.
|
|
12
12
|
- With reduced motion, notices fade in and out in place, and the others move at once. A browser without view transitions shows the changes at once.
|
|
13
13
|
|
|
14
14
|
## Usage
|
|
@@ -34,6 +34,12 @@ Show the list in the top-left corner:
|
|
|
34
34
|
<Notices position="top-left" />
|
|
35
35
|
```
|
|
36
36
|
|
|
37
|
+
Show the list at the top of the screen, in the centre:
|
|
38
|
+
|
|
39
|
+
```tsx
|
|
40
|
+
<Notices position="top-center" />
|
|
41
|
+
```
|
|
42
|
+
|
|
37
43
|
Dispatch notices from anywhere — no context required:
|
|
38
44
|
|
|
39
45
|
```tsx
|
|
@@ -63,7 +69,7 @@ notice.close(); // Or close it immediately.
|
|
|
63
69
|
|
|
64
70
|
## Styling
|
|
65
71
|
|
|
66
|
-
`Notices` positions the list in the
|
|
72
|
+
`Notices` positions the list in the place that `position` sets. Each notice is only as wide as its content and is aligned to the side of that corner, or to the centre. The list is never wider than `--notices-width`, and keeps `--notices-offset` clear at both sides on a narrow screen. The offset also adds the safe area of the device (`env(safe-area-inset-*)`). Clicks pass through the gaps between notices to the page. Each item is a `<Notice>`, which has its own hooks. Override these hooks at `:root` (or any ancestor scope) to retheme.
|
|
67
73
|
|
|
68
74
|
| Variable | Styles | Default |
|
|
69
75
|
|---|---|---|
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
/* The list is as wide as `--notices-width`, so let clicks pass through the gaps to the page. */
|
|
18
18
|
pointer-events: none;
|
|
19
19
|
|
|
20
|
-
/* Each notice is only as wide as its content, and stays on the side of the list's corner. */
|
|
20
|
+
/* Each notice is only as wide as its content, and stays on the side of the list's corner, or in the centre. */
|
|
21
21
|
& > * {
|
|
22
22
|
inline-size: auto;
|
|
23
23
|
max-width: 100%;
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
}
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
-
/*
|
|
31
|
+
/* Places. The list keeps `--notices-offset` clear of the edges, plus the safe area of the device. */
|
|
32
32
|
.top {
|
|
33
33
|
top: calc(var(--notices-offset, var(--space-normal)) + env(safe-area-inset-top, 0px));
|
|
34
34
|
}
|
|
@@ -46,4 +46,9 @@
|
|
|
46
46
|
margin-left: auto;
|
|
47
47
|
align-items: flex-end;
|
|
48
48
|
}
|
|
49
|
+
|
|
50
|
+
.center {
|
|
51
|
+
margin-inline: auto;
|
|
52
|
+
align-items: center;
|
|
53
|
+
}
|
|
49
54
|
}
|
package/ui/notice/Notices.tsx
CHANGED
|
@@ -14,20 +14,20 @@ import NOTICES_TRANSITION_CSS from "./NoticesTransition.module.css";
|
|
|
14
14
|
const NOTICES_CLASS = getModuleClass(NOTICES_CSS, "notices");
|
|
15
15
|
|
|
16
16
|
/**
|
|
17
|
-
*
|
|
17
|
+
* Place on the screen where `<Notices>` shows the list of notices: a corner, or the centre of the top or bottom edge.
|
|
18
18
|
*
|
|
19
19
|
* @see https://shelving.cc/ui/NoticesPosition
|
|
20
20
|
*/
|
|
21
|
-
export type NoticesPosition = "top
|
|
21
|
+
export type NoticesPosition = `${"top" | "bottom"}-${"left" | "center" | "right"}`;
|
|
22
22
|
|
|
23
23
|
/**
|
|
24
|
-
* Props for `<Notices>` — the
|
|
24
|
+
* Props for `<Notices>` — the place for the list, and flex styling variants for the notices container.
|
|
25
25
|
*
|
|
26
26
|
* @see https://shelving.cc/ui/NoticesProps
|
|
27
27
|
*/
|
|
28
28
|
export interface NoticesProps extends FlexVariants, ClassProps {
|
|
29
29
|
/**
|
|
30
|
-
*
|
|
30
|
+
* Place on the screen for the list. New notices slide in from this side, or from the top or bottom edge for a centred list.
|
|
31
31
|
* @default "bottom-right"
|
|
32
32
|
*/
|
|
33
33
|
position?: NoticesPosition | undefined;
|
|
@@ -37,8 +37,8 @@ export interface NoticesProps extends FlexVariants, ClassProps {
|
|
|
37
37
|
* Render the global list of notices and subscribe to incoming `"notice"` events.
|
|
38
38
|
* - Listens for `"notice"` events on `window` (or that bubble up to `window`) and shows them in the global notice list.
|
|
39
39
|
* - This is how e.g. `<Button>` and `<FormNotify>` components send notices into the global list.
|
|
40
|
-
* - Shows the list in the bottom-right corner, or in the
|
|
41
|
-
* - Each notice slides in and out in its own view transition, from the side of its corner. The other notices move to their new places in the same transition.
|
|
40
|
+
* - Shows the list in the bottom-right corner, or in the place that `position` sets.
|
|
41
|
+
* - Each notice slides in and out in its own view transition, from the side of its corner, or from the edge for a centred list. The other notices move to their new places in the same transition.
|
|
42
42
|
*
|
|
43
43
|
* @kind component
|
|
44
44
|
* @see https://shelving.cc/ui/Notices
|
|
@@ -65,8 +65,9 @@ export function Notices({ position = "bottom-right", className, ...props }: Noti
|
|
|
65
65
|
*/
|
|
66
66
|
function NoticeItem({ notice, position }: { notice: NoticeStore<Status>; position: NoticesPosition }): ReactElement {
|
|
67
67
|
const { children, status } = useTransitionValue(notice);
|
|
68
|
-
// New and closed notices slide from the side of the corner. A notice that changes in place is drawn from the corner itself.
|
|
69
|
-
const
|
|
68
|
+
// New and closed notices slide from the side of the corner, or from the edge when centred. A notice that changes in place is drawn from the corner itself.
|
|
69
|
+
const [vertical, horizontal] = position.split("-");
|
|
70
|
+
const side = horizontal === "center" ? vertical : horizontal;
|
|
70
71
|
return (
|
|
71
72
|
<ViewTransition
|
|
72
73
|
enter={getModuleClass(NOTICES_TRANSITION_CSS, `notice-${side}`)}
|
|
@@ -22,6 +22,20 @@
|
|
|
22
22
|
}
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
+
@keyframes notice-from-top {
|
|
26
|
+
from {
|
|
27
|
+
opacity: 0;
|
|
28
|
+
transform: translateY(-100%);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
@keyframes notice-from-bottom {
|
|
33
|
+
from {
|
|
34
|
+
opacity: 0;
|
|
35
|
+
transform: translateY(100%);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
25
39
|
@keyframes notice-fade {
|
|
26
40
|
from {
|
|
27
41
|
opacity: 0;
|
|
@@ -29,7 +43,7 @@
|
|
|
29
43
|
}
|
|
30
44
|
|
|
31
45
|
/*
|
|
32
|
-
* A new notice slides in from the side of its corner, and a closed notice slides out
|
|
46
|
+
* A new notice slides in from the side of its corner (or from the edge for a centred list), and a closed notice slides out the same way.
|
|
33
47
|
* - `:only-child` stops Safari from also starting the animation on the missing image, which stops it later on the real one (see `FadeTransition.css`).
|
|
34
48
|
* - Longhands, not the `animation` shorthand: Bun rewrites `animation-name` to the hashed keyframes name but leaves a shorthand that holds a `var()` untouched.
|
|
35
49
|
*/
|
|
@@ -63,30 +77,66 @@
|
|
|
63
77
|
animation-fill-mode: both;
|
|
64
78
|
}
|
|
65
79
|
|
|
80
|
+
::view-transition-new(.notice-top):only-child {
|
|
81
|
+
animation-name: notice-from-top;
|
|
82
|
+
animation-duration: var(--notices-transition-duration);
|
|
83
|
+
animation-timing-function: ease-out;
|
|
84
|
+
animation-fill-mode: both;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
::view-transition-old(.notice-top):only-child {
|
|
88
|
+
animation-name: notice-from-top;
|
|
89
|
+
animation-duration: var(--notices-transition-duration);
|
|
90
|
+
animation-timing-function: ease-in;
|
|
91
|
+
animation-direction: reverse;
|
|
92
|
+
animation-fill-mode: both;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
::view-transition-new(.notice-bottom):only-child {
|
|
96
|
+
animation-name: notice-from-bottom;
|
|
97
|
+
animation-duration: var(--notices-transition-duration);
|
|
98
|
+
animation-timing-function: ease-out;
|
|
99
|
+
animation-fill-mode: both;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
::view-transition-old(.notice-bottom):only-child {
|
|
103
|
+
animation-name: notice-from-bottom;
|
|
104
|
+
animation-duration: var(--notices-transition-duration);
|
|
105
|
+
animation-timing-function: ease-in;
|
|
106
|
+
animation-direction: reverse;
|
|
107
|
+
animation-fill-mode: both;
|
|
108
|
+
}
|
|
109
|
+
|
|
66
110
|
/* The other notices move to their new places (the default group morph). */
|
|
67
111
|
::view-transition-group(.notice-update-top-left),
|
|
112
|
+
::view-transition-group(.notice-update-top-center),
|
|
68
113
|
::view-transition-group(.notice-update-top-right),
|
|
69
114
|
::view-transition-group(.notice-update-bottom-left),
|
|
115
|
+
::view-transition-group(.notice-update-bottom-center),
|
|
70
116
|
::view-transition-group(.notice-update-bottom-right) {
|
|
71
117
|
animation-duration: var(--notices-transition-duration);
|
|
72
118
|
}
|
|
73
119
|
|
|
74
120
|
/*
|
|
75
121
|
* A notice that changes in place does not animate: hide the old image, and show the new image at once at its own size.
|
|
76
|
-
* - The group still morphs between the old and new size, so the new image is drawn unscaled from the corner of the list, which does not move.
|
|
122
|
+
* - The group still morphs between the old and new size, so the new image is drawn unscaled from the corner (or the centre of the edge) of the list, which does not move.
|
|
77
123
|
* - For a notice that only moves, the old and new images are the same, so this changes nothing.
|
|
78
124
|
*/
|
|
79
125
|
::view-transition-old(.notice-update-top-left),
|
|
126
|
+
::view-transition-old(.notice-update-top-center),
|
|
80
127
|
::view-transition-old(.notice-update-top-right),
|
|
81
128
|
::view-transition-old(.notice-update-bottom-left),
|
|
129
|
+
::view-transition-old(.notice-update-bottom-center),
|
|
82
130
|
::view-transition-old(.notice-update-bottom-right) {
|
|
83
131
|
animation: none;
|
|
84
132
|
opacity: 0;
|
|
85
133
|
}
|
|
86
134
|
|
|
87
135
|
::view-transition-new(.notice-update-top-left),
|
|
136
|
+
::view-transition-new(.notice-update-top-center),
|
|
88
137
|
::view-transition-new(.notice-update-top-right),
|
|
89
138
|
::view-transition-new(.notice-update-bottom-left),
|
|
139
|
+
::view-transition-new(.notice-update-bottom-center),
|
|
90
140
|
::view-transition-new(.notice-update-bottom-right) {
|
|
91
141
|
animation: none;
|
|
92
142
|
width: auto;
|
|
@@ -97,6 +147,11 @@
|
|
|
97
147
|
inset: 0 auto auto 0;
|
|
98
148
|
}
|
|
99
149
|
|
|
150
|
+
::view-transition-new(.notice-update-top-center) {
|
|
151
|
+
inset: 0 0 auto;
|
|
152
|
+
margin-inline: auto;
|
|
153
|
+
}
|
|
154
|
+
|
|
100
155
|
::view-transition-new(.notice-update-top-right) {
|
|
101
156
|
inset: 0 0 auto auto;
|
|
102
157
|
}
|
|
@@ -105,6 +160,11 @@
|
|
|
105
160
|
inset: auto auto 0 0;
|
|
106
161
|
}
|
|
107
162
|
|
|
163
|
+
::view-transition-new(.notice-update-bottom-center) {
|
|
164
|
+
inset: auto 0 0;
|
|
165
|
+
margin-inline: auto;
|
|
166
|
+
}
|
|
167
|
+
|
|
108
168
|
::view-transition-new(.notice-update-bottom-right) {
|
|
109
169
|
inset: auto 0 0 auto;
|
|
110
170
|
}
|
|
@@ -114,13 +174,19 @@
|
|
|
114
174
|
::view-transition-new(.notice-left):only-child,
|
|
115
175
|
::view-transition-new(.notice-right):only-child,
|
|
116
176
|
::view-transition-old(.notice-left):only-child,
|
|
117
|
-
::view-transition-old(.notice-right):only-child
|
|
177
|
+
::view-transition-old(.notice-right):only-child,
|
|
178
|
+
::view-transition-new(.notice-top):only-child,
|
|
179
|
+
::view-transition-new(.notice-bottom):only-child,
|
|
180
|
+
::view-transition-old(.notice-top):only-child,
|
|
181
|
+
::view-transition-old(.notice-bottom):only-child {
|
|
118
182
|
animation-name: notice-fade;
|
|
119
183
|
}
|
|
120
184
|
|
|
121
185
|
::view-transition-group(.notice-update-top-left),
|
|
186
|
+
::view-transition-group(.notice-update-top-center),
|
|
122
187
|
::view-transition-group(.notice-update-top-right),
|
|
123
188
|
::view-transition-group(.notice-update-bottom-left),
|
|
189
|
+
::view-transition-group(.notice-update-bottom-center),
|
|
124
190
|
::view-transition-group(.notice-update-bottom-right) {
|
|
125
191
|
animation: none;
|
|
126
192
|
}
|