@velocity-astro/cms-ui 0.1.0-beta.1 → 0.1.0-beta.12
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/component-registry.json +93 -8
- package/dist/components/BarChart/BarChart.d.ts +23 -0
- package/dist/components/BarChart/BarChart.d.ts.map +1 -0
- package/dist/components/BarChart/BarChart.js +19 -0
- package/dist/components/BarChart/BarChart.js.map +1 -0
- package/dist/components/BarChart/BarChart.variants.d.ts +29 -0
- package/dist/components/BarChart/BarChart.variants.d.ts.map +1 -0
- package/dist/components/BarChart/BarChart.variants.js +81 -0
- package/dist/components/BarChart/BarChart.variants.js.map +1 -0
- package/dist/components/BarChart/index.d.ts +2 -0
- package/dist/components/BarChart/index.d.ts.map +1 -0
- package/dist/components/BarChart/index.js +2 -0
- package/dist/components/BarChart/index.js.map +1 -0
- package/dist/components/Button/Button.d.ts +6 -1
- package/dist/components/Button/Button.d.ts.map +1 -1
- package/dist/components/Button/Button.js +5 -3
- package/dist/components/Button/Button.js.map +1 -1
- package/dist/components/Button/Button.variants.d.ts +6 -1
- package/dist/components/Button/Button.variants.d.ts.map +1 -1
- package/dist/components/Button/Button.variants.js +13 -1
- package/dist/components/Button/Button.variants.js.map +1 -1
- package/dist/components/Card/Card.d.ts +3 -1
- package/dist/components/Card/Card.d.ts.map +1 -1
- package/dist/components/Card/Card.js +3 -3
- package/dist/components/Card/Card.js.map +1 -1
- package/dist/components/Card/Card.variants.d.ts +4 -1
- package/dist/components/Card/Card.variants.d.ts.map +1 -1
- package/dist/components/Card/Card.variants.js +6 -1
- package/dist/components/Card/Card.variants.js.map +1 -1
- package/dist/components/ColorPicker/ColorPicker.d.ts +30 -0
- package/dist/components/ColorPicker/ColorPicker.d.ts.map +1 -0
- package/dist/components/ColorPicker/ColorPicker.js +32 -0
- package/dist/components/ColorPicker/ColorPicker.js.map +1 -0
- package/dist/components/ColorPicker/ColorPicker.variants.d.ts +24 -0
- package/dist/components/ColorPicker/ColorPicker.variants.d.ts.map +1 -0
- package/dist/components/ColorPicker/ColorPicker.variants.js +42 -0
- package/dist/components/ColorPicker/ColorPicker.variants.js.map +1 -0
- package/dist/components/ColorPicker/index.d.ts +2 -0
- package/dist/components/ColorPicker/index.d.ts.map +1 -0
- package/dist/components/ColorPicker/index.js +2 -0
- package/dist/components/ColorPicker/index.js.map +1 -0
- package/dist/components/FileButton/FileButton.d.ts +3 -1
- package/dist/components/FileButton/FileButton.d.ts.map +1 -1
- package/dist/components/FileButton/FileButton.js +2 -2
- package/dist/components/FileButton/FileButton.js.map +1 -1
- package/dist/components/Grid/Grid.variants.d.ts +1 -0
- package/dist/components/Grid/Grid.variants.d.ts.map +1 -1
- package/dist/components/Grid/Grid.variants.js +4 -3
- package/dist/components/Grid/Grid.variants.js.map +1 -1
- package/dist/components/Heading/Heading.d.ts +1 -1
- package/dist/components/Heading/Heading.d.ts.map +1 -1
- package/dist/components/Heading/Heading.js +2 -2
- package/dist/components/Heading/Heading.js.map +1 -1
- package/dist/components/Heading/Heading.variants.d.ts +1 -0
- package/dist/components/Heading/Heading.variants.d.ts.map +1 -1
- package/dist/components/Heading/Heading.variants.js +2 -0
- package/dist/components/Heading/Heading.variants.js.map +1 -1
- package/dist/components/LoadingMark/LoadingMark.d.ts +11 -0
- package/dist/components/LoadingMark/LoadingMark.d.ts.map +1 -0
- package/dist/components/LoadingMark/LoadingMark.js +17 -0
- package/dist/components/LoadingMark/LoadingMark.js.map +1 -0
- package/dist/components/LoadingMark/LoadingMark.variants.d.ts +22 -0
- package/dist/components/LoadingMark/LoadingMark.variants.d.ts.map +1 -0
- package/dist/components/LoadingMark/LoadingMark.variants.js +18 -0
- package/dist/components/LoadingMark/LoadingMark.variants.js.map +1 -0
- package/dist/components/LoadingMark/index.d.ts +2 -0
- package/dist/components/LoadingMark/index.d.ts.map +1 -0
- package/dist/components/LoadingMark/index.js +2 -0
- package/dist/components/LoadingMark/index.js.map +1 -0
- package/dist/components/Logo/Logo.d.ts +10 -2
- package/dist/components/Logo/Logo.d.ts.map +1 -1
- package/dist/components/Logo/Logo.js +11 -3
- package/dist/components/Logo/Logo.js.map +1 -1
- package/dist/components/Logo/Logo.variants.d.ts +5 -2
- package/dist/components/Logo/Logo.variants.d.ts.map +1 -1
- package/dist/components/Logo/Logo.variants.js +10 -1
- package/dist/components/Logo/Logo.variants.js.map +1 -1
- package/dist/components/Meter/Meter.d.ts +13 -0
- package/dist/components/Meter/Meter.d.ts.map +1 -0
- package/dist/components/Meter/Meter.js +8 -0
- package/dist/components/Meter/Meter.js.map +1 -0
- package/dist/components/Meter/Meter.variants.d.ts +14 -0
- package/dist/components/Meter/Meter.variants.d.ts.map +1 -0
- package/dist/components/Meter/Meter.variants.js +39 -0
- package/dist/components/Meter/Meter.variants.js.map +1 -0
- package/dist/components/Meter/index.d.ts +2 -0
- package/dist/components/Meter/index.d.ts.map +1 -0
- package/dist/components/Meter/index.js +2 -0
- package/dist/components/Meter/index.js.map +1 -0
- package/dist/components/RichTextEditor/RichTextEditor.d.ts +8 -1
- package/dist/components/RichTextEditor/RichTextEditor.d.ts.map +1 -1
- package/dist/components/RichTextEditor/RichTextEditor.js +62 -17
- package/dist/components/RichTextEditor/RichTextEditor.js.map +1 -1
- package/dist/components/RichTextEditor/index.d.ts +1 -1
- package/dist/components/RichTextEditor/index.d.ts.map +1 -1
- package/dist/components/RichTextEditor/index.js.map +1 -1
- package/dist/components/Segmented/Segmented.d.ts +14 -1
- package/dist/components/Segmented/Segmented.d.ts.map +1 -1
- package/dist/components/Segmented/Segmented.js +14 -5
- package/dist/components/Segmented/Segmented.js.map +1 -1
- package/dist/components/Segmented/Segmented.variants.d.ts +14 -1
- package/dist/components/Segmented/Segmented.variants.d.ts.map +1 -1
- package/dist/components/Segmented/Segmented.variants.js +19 -3
- package/dist/components/Segmented/Segmented.variants.js.map +1 -1
- package/dist/components/Spotlight/Spotlight.d.ts +16 -0
- package/dist/components/Spotlight/Spotlight.d.ts.map +1 -0
- package/dist/components/Spotlight/Spotlight.js +28 -0
- package/dist/components/Spotlight/Spotlight.js.map +1 -0
- package/dist/components/Spotlight/Spotlight.variants.d.ts +8 -0
- package/dist/components/Spotlight/Spotlight.variants.d.ts.map +1 -0
- package/dist/components/Spotlight/Spotlight.variants.js +15 -0
- package/dist/components/Spotlight/Spotlight.variants.js.map +1 -0
- package/dist/components/Spotlight/index.d.ts +2 -0
- package/dist/components/Spotlight/index.d.ts.map +1 -0
- package/dist/components/Spotlight/index.js +2 -0
- package/dist/components/Spotlight/index.js.map +1 -0
- package/dist/components/Table/Table.d.ts +8 -1
- package/dist/components/Table/Table.d.ts.map +1 -1
- package/dist/components/Table/Table.js +4 -4
- package/dist/components/Table/Table.js.map +1 -1
- package/dist/components/Table/Table.variants.d.ts +6 -2
- package/dist/components/Table/Table.variants.d.ts.map +1 -1
- package/dist/components/Table/Table.variants.js +11 -5
- package/dist/components/Table/Table.variants.js.map +1 -1
- package/dist/components/index.d.ts +5 -0
- package/dist/components/index.d.ts.map +1 -1
- package/dist/components/index.js +5 -0
- package/dist/components/index.js.map +1 -1
- package/dist/components/scales.d.ts +2 -2
- package/dist/components/scales.d.ts.map +1 -1
- package/dist/components/scales.js +4 -2
- package/dist/components/scales.js.map +1 -1
- package/dist/patterns/AppShell/AppShell.d.ts +38 -8
- package/dist/patterns/AppShell/AppShell.d.ts.map +1 -1
- package/dist/patterns/AppShell/AppShell.js +46 -7
- package/dist/patterns/AppShell/AppShell.js.map +1 -1
- package/dist/patterns/AppShell/AppShell.variants.d.ts +89 -20
- package/dist/patterns/AppShell/AppShell.variants.d.ts.map +1 -1
- package/dist/patterns/AppShell/AppShell.variants.js +148 -23
- package/dist/patterns/AppShell/AppShell.variants.js.map +1 -1
- package/dist/patterns/AppShell/index.d.ts +1 -1
- package/dist/patterns/AppShell/index.d.ts.map +1 -1
- package/dist/patterns/AppShell/index.js.map +1 -1
- package/dist/patterns/CommandPalette/CommandPalette.d.ts +43 -0
- package/dist/patterns/CommandPalette/CommandPalette.d.ts.map +1 -0
- package/dist/patterns/CommandPalette/CommandPalette.js +19 -0
- package/dist/patterns/CommandPalette/CommandPalette.js.map +1 -0
- package/dist/patterns/CommandPalette/CommandPalette.variants.d.ts +18 -0
- package/dist/patterns/CommandPalette/CommandPalette.variants.d.ts.map +1 -0
- package/dist/patterns/CommandPalette/CommandPalette.variants.js +21 -0
- package/dist/patterns/CommandPalette/CommandPalette.variants.js.map +1 -0
- package/dist/patterns/CommandPalette/index.d.ts +2 -0
- package/dist/patterns/CommandPalette/index.d.ts.map +1 -0
- package/dist/patterns/CommandPalette/index.js +2 -0
- package/dist/patterns/CommandPalette/index.js.map +1 -0
- package/dist/patterns/ImagePicker/ImagePicker.d.ts +9 -1
- package/dist/patterns/ImagePicker/ImagePicker.d.ts.map +1 -1
- package/dist/patterns/ImagePicker/ImagePicker.js +13 -8
- package/dist/patterns/ImagePicker/ImagePicker.js.map +1 -1
- package/dist/patterns/OptionPicker/OptionPicker.d.ts +2 -0
- package/dist/patterns/OptionPicker/OptionPicker.d.ts.map +1 -1
- package/dist/patterns/OptionPicker/OptionPicker.js +8 -3
- package/dist/patterns/OptionPicker/OptionPicker.js.map +1 -1
- package/dist/patterns/OptionPicker/OptionPicker.variants.d.ts +10 -4
- package/dist/patterns/OptionPicker/OptionPicker.variants.d.ts.map +1 -1
- package/dist/patterns/OptionPicker/OptionPicker.variants.js +29 -6
- package/dist/patterns/OptionPicker/OptionPicker.variants.js.map +1 -1
- package/dist/patterns/Outline/Outline.d.ts +26 -0
- package/dist/patterns/Outline/Outline.d.ts.map +1 -0
- package/dist/patterns/Outline/Outline.js +21 -0
- package/dist/patterns/Outline/Outline.js.map +1 -0
- package/dist/patterns/Outline/Outline.variants.d.ts +11 -0
- package/dist/patterns/Outline/Outline.variants.d.ts.map +1 -0
- package/dist/patterns/Outline/Outline.variants.js +21 -0
- package/dist/patterns/Outline/Outline.variants.js.map +1 -0
- package/dist/patterns/Outline/index.d.ts +2 -0
- package/dist/patterns/Outline/index.d.ts.map +1 -0
- package/dist/patterns/Outline/index.js +2 -0
- package/dist/patterns/Outline/index.js.map +1 -0
- package/dist/patterns/PageHeader/PageHeader.d.ts +33 -4
- package/dist/patterns/PageHeader/PageHeader.d.ts.map +1 -1
- package/dist/patterns/PageHeader/PageHeader.js +31 -6
- package/dist/patterns/PageHeader/PageHeader.js.map +1 -1
- package/dist/patterns/PageHeader/PageHeader.variants.d.ts +23 -2
- package/dist/patterns/PageHeader/PageHeader.variants.d.ts.map +1 -1
- package/dist/patterns/PageHeader/PageHeader.variants.js +33 -2
- package/dist/patterns/PageHeader/PageHeader.variants.js.map +1 -1
- package/dist/patterns/PagePreview/PagePreview.d.ts +138 -4
- package/dist/patterns/PagePreview/PagePreview.d.ts.map +1 -1
- package/dist/patterns/PagePreview/PagePreview.js +159 -13
- package/dist/patterns/PagePreview/PagePreview.js.map +1 -1
- package/dist/patterns/PagePreview/PagePreview.variants.d.ts +15 -2
- package/dist/patterns/PagePreview/PagePreview.variants.d.ts.map +1 -1
- package/dist/patterns/PagePreview/PagePreview.variants.js +22 -6
- package/dist/patterns/PagePreview/PagePreview.variants.js.map +1 -1
- package/dist/patterns/PagePreview/index.d.ts +1 -1
- package/dist/patterns/PagePreview/index.d.ts.map +1 -1
- package/dist/patterns/PagePreview/index.js.map +1 -1
- package/dist/patterns/SaveBar/SaveBar.d.ts +20 -4
- package/dist/patterns/SaveBar/SaveBar.d.ts.map +1 -1
- package/dist/patterns/SaveBar/SaveBar.js +22 -4
- package/dist/patterns/SaveBar/SaveBar.js.map +1 -1
- package/dist/patterns/SaveBar/SaveBar.variants.d.ts +27 -5
- package/dist/patterns/SaveBar/SaveBar.variants.d.ts.map +1 -1
- package/dist/patterns/SaveBar/SaveBar.variants.js +39 -6
- package/dist/patterns/SaveBar/SaveBar.variants.js.map +1 -1
- package/dist/patterns/SectionList/SectionList.d.ts.map +1 -1
- package/dist/patterns/SectionList/SectionList.js +2 -2
- package/dist/patterns/SectionList/SectionList.js.map +1 -1
- package/dist/patterns/SectionList/SectionList.variants.d.ts +4 -1
- package/dist/patterns/SectionList/SectionList.variants.d.ts.map +1 -1
- package/dist/patterns/SectionList/SectionList.variants.js +5 -2
- package/dist/patterns/SectionList/SectionList.variants.js.map +1 -1
- package/dist/patterns/SiteWindow/SiteWindow.d.ts +20 -0
- package/dist/patterns/SiteWindow/SiteWindow.d.ts.map +1 -0
- package/dist/patterns/SiteWindow/SiteWindow.js +8 -0
- package/dist/patterns/SiteWindow/SiteWindow.js.map +1 -0
- package/dist/patterns/SiteWindow/SiteWindow.variants.d.ts +24 -0
- package/dist/patterns/SiteWindow/SiteWindow.variants.d.ts.map +1 -0
- package/dist/patterns/SiteWindow/SiteWindow.variants.js +25 -0
- package/dist/patterns/SiteWindow/SiteWindow.variants.js.map +1 -0
- package/dist/patterns/SiteWindow/index.d.ts +2 -0
- package/dist/patterns/SiteWindow/index.d.ts.map +1 -0
- package/dist/patterns/SiteWindow/index.js +2 -0
- package/dist/patterns/SiteWindow/index.js.map +1 -0
- package/dist/patterns/Split/Split.variants.d.ts +2 -2
- package/dist/patterns/Split/Split.variants.d.ts.map +1 -1
- package/dist/patterns/Split/Split.variants.js +2 -2
- package/dist/patterns/Split/Split.variants.js.map +1 -1
- package/dist/patterns/Welcome/Welcome.d.ts +18 -0
- package/dist/patterns/Welcome/Welcome.d.ts.map +1 -0
- package/dist/patterns/Welcome/Welcome.js +20 -0
- package/dist/patterns/Welcome/Welcome.js.map +1 -0
- package/dist/patterns/Welcome/Welcome.variants.d.ts +12 -0
- package/dist/patterns/Welcome/Welcome.variants.d.ts.map +1 -0
- package/dist/patterns/Welcome/Welcome.variants.js +12 -0
- package/dist/patterns/Welcome/Welcome.variants.js.map +1 -0
- package/dist/patterns/Welcome/index.d.ts +2 -0
- package/dist/patterns/Welcome/index.d.ts.map +1 -0
- package/dist/patterns/Welcome/index.js +2 -0
- package/dist/patterns/Welcome/index.js.map +1 -0
- package/dist/patterns/Workbench/Workbench.d.ts +35 -4
- package/dist/patterns/Workbench/Workbench.d.ts.map +1 -1
- package/dist/patterns/Workbench/Workbench.js +59 -4
- package/dist/patterns/Workbench/Workbench.js.map +1 -1
- package/dist/patterns/Workbench/Workbench.variants.d.ts +56 -4
- package/dist/patterns/Workbench/Workbench.variants.d.ts.map +1 -1
- package/dist/patterns/Workbench/Workbench.variants.js +111 -4
- package/dist/patterns/Workbench/Workbench.variants.js.map +1 -1
- package/dist/patterns/Workbench/index.d.ts +1 -1
- package/dist/patterns/Workbench/index.d.ts.map +1 -1
- package/dist/patterns/Workbench/index.js.map +1 -1
- package/dist/patterns/index.d.ts +4 -0
- package/dist/patterns/index.d.ts.map +1 -1
- package/dist/patterns/index.js +4 -0
- package/dist/patterns/index.js.map +1 -1
- package/dist/patterns/page-bar.d.ts +17 -0
- package/dist/patterns/page-bar.d.ts.map +1 -0
- package/dist/patterns/page-bar.js +22 -0
- package/dist/patterns/page-bar.js.map +1 -0
- package/package.json +2 -1
- package/src/styles.css +179 -0
- package/src/tokens/tokens.css +27 -1
|
@@ -1,42 +1,119 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
-
import { useEffect, useId, useRef } from 'react';
|
|
2
|
+
import { useEffect, useId, useRef, useState } from 'react';
|
|
3
3
|
import { createPortal } from 'react-dom';
|
|
4
|
-
import { pagePreviewBarClass,
|
|
4
|
+
import { pagePreviewBarClass, pagePreviewVariants, pagePreviewEmptyClass, pagePreviewFrameVariants, pagePreviewNoteClass, pagePreviewStageVariants, pagePreviewWidths, } from './PagePreview.variants.js';
|
|
5
5
|
/** How long the page waits after the last change before it is drawn again, in milliseconds. */
|
|
6
6
|
const PAUSE = 500;
|
|
7
7
|
/** The name both sides put on what they say to each other, so nothing else is taken for it. */
|
|
8
8
|
const SOURCE = 'velocity-cms';
|
|
9
|
+
/** How long after words were typed on the page a change of the draft is taken to be those words, in milliseconds. */
|
|
10
|
+
const OWN = 250;
|
|
11
|
+
/** How close a change of the draft and a section asked for must be to be one act, such as a section moved, in milliseconds. */
|
|
12
|
+
const TOGETHER = 100;
|
|
13
|
+
/** How much of a screen's width a pane must have for the page to be shown at the pane's own width. */
|
|
14
|
+
const NEARLY = 0.9;
|
|
15
|
+
/** What can be done to a section from the page itself. */
|
|
16
|
+
const ACTIONS = ['up', 'down', 'duplicate', 'remove', 'addBefore', 'addAfter'];
|
|
17
|
+
const ITEM_ACTIONS = ['up', 'down', 'duplicate', 'remove'];
|
|
9
18
|
/**
|
|
10
19
|
* A page of the site as it would look with what is in a form now, in a frame. The page is drawn
|
|
11
20
|
* by the site itself, so it looks exactly as it will; nothing of it is drawn here.
|
|
12
21
|
*/
|
|
13
|
-
export function PagePreview({ label, address, draft, note, toolbar, emptyText, onSectionPress, shownSectionId, width }) {
|
|
22
|
+
export function PagePreview({ label, address, draft, note, toolbar, action, emptyText, onSectionPress, shownSectionId, shownAt = 0, typable, onWords, tools, onSectionAction, onSectionMove, onSectionPicture, onSectionLink, onSectionItem, onSectionSwatch, onSectionSlot, onTextLink, onUndo, onRedo, onSave, escapes = 0, isBare = false, width }) {
|
|
14
23
|
const name = `preview-${useId().replaceAll(':', '')}`;
|
|
15
24
|
const form = useRef(null);
|
|
16
25
|
const frame = useRef(null);
|
|
17
26
|
const hasSent = useRef(false);
|
|
18
|
-
const
|
|
27
|
+
const places = typable === undefined ? undefined : JSON.stringify(typable);
|
|
28
|
+
const offered = tools === undefined ? undefined : JSON.stringify(tools);
|
|
29
|
+
const latest = useRef({ onSectionPress, shownSectionId, onWords, places, offered, onSectionAction, onSectionMove, onSectionPicture, onSectionLink, onSectionItem, onSectionSwatch, onSectionSlot, onTextLink, onUndo, onRedo, onSave });
|
|
19
30
|
useEffect(() => {
|
|
20
|
-
latest.current = { onSectionPress, shownSectionId };
|
|
31
|
+
latest.current = { onSectionPress, shownSectionId, onWords, places, offered, onSectionAction, onSectionMove, onSectionPicture, onSectionLink, onSectionItem, onSectionSwatch, onSectionSlot, onTextLink, onUndo, onRedo, onSave };
|
|
21
32
|
});
|
|
33
|
+
// When words were last typed on the page, and whether the page lacks a change made in the form.
|
|
34
|
+
const typedAt = useRef(0);
|
|
35
|
+
// When a button of the page's own tools was last pressed there.
|
|
36
|
+
const pressedAt = useRef(0);
|
|
37
|
+
const isBehind = useRef(false);
|
|
38
|
+
// When a section was last asked to be shown, and when the draft last changed. A page drawn again
|
|
39
|
+
// stays where the person left it, unless the change itself asked for a section: one just moved or added.
|
|
40
|
+
const askedAt = useRef(0);
|
|
41
|
+
const changedAt = useRef(0);
|
|
42
|
+
const hasDrawn = useRef(false);
|
|
22
43
|
// The first page is asked for at once. After that, a pause in the typing asks for the next.
|
|
23
44
|
useEffect(() => {
|
|
45
|
+
changedAt.current = Date.now();
|
|
24
46
|
if (address === undefined)
|
|
25
47
|
return;
|
|
26
48
|
const send = () => {
|
|
27
49
|
hasSent.current = true;
|
|
50
|
+
isBehind.current = false;
|
|
28
51
|
form.current?.submit();
|
|
29
52
|
};
|
|
30
53
|
if (!hasSent.current) {
|
|
31
54
|
send();
|
|
32
55
|
return;
|
|
33
56
|
}
|
|
57
|
+
// Words typed on the page are on the page already: drawing it again would take the caret away.
|
|
58
|
+
if (Date.now() - typedAt.current < OWN && !isBehind.current)
|
|
59
|
+
return;
|
|
60
|
+
isBehind.current = true;
|
|
61
|
+
// A button pressed on the page is one change, made: there is no typing to wait out.
|
|
62
|
+
if (Date.now() - pressedAt.current < TOGETHER * 5) {
|
|
63
|
+
pressedAt.current = 0;
|
|
64
|
+
send();
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
34
67
|
const waiting = setTimeout(send, PAUSE);
|
|
35
68
|
return () => clearTimeout(waiting);
|
|
36
69
|
}, [address, draft]);
|
|
37
|
-
|
|
70
|
+
// The page is drawn at the width of the screen it is tried on, whatever room the pane has: one
|
|
71
|
+
// wider than the pane is shown smaller, whole, never as the narrower layout that would fit.
|
|
72
|
+
const stage = useRef(null);
|
|
73
|
+
const [room, setRoom] = useState(null);
|
|
74
|
+
useEffect(() => {
|
|
75
|
+
const element = stage.current;
|
|
76
|
+
if (!element || typeof ResizeObserver === 'undefined')
|
|
77
|
+
return;
|
|
78
|
+
const measure = () => setRoom({ width: element.clientWidth, height: element.clientHeight });
|
|
79
|
+
const watching = new ResizeObserver(measure);
|
|
80
|
+
watching.observe(element);
|
|
81
|
+
measure();
|
|
82
|
+
return () => watching.disconnect();
|
|
83
|
+
}, [address === undefined]);
|
|
84
|
+
const wanted = pagePreviewWidths[width ?? 'full'];
|
|
85
|
+
// A pane nearly as wide shows the page at its own width instead: a little narrower reads better than a little smaller.
|
|
86
|
+
const fits = room === null || room.width <= 0 || room.width >= wanted * NEARLY;
|
|
87
|
+
const scale = fits ? 1 : room.width / wanted;
|
|
88
|
+
const isFitted = scale < 1;
|
|
89
|
+
// A page takes itself to be shown at its own size, so it is told only when that is not so, or no longer so.
|
|
90
|
+
const told = useRef(1);
|
|
91
|
+
const zoom = (to) => {
|
|
92
|
+
if (to === told.current)
|
|
93
|
+
return;
|
|
94
|
+
told.current = to;
|
|
95
|
+
frame.current?.contentWindow?.postMessage({ source: SOURCE, type: 'zoom', scale: to }, window.location.origin);
|
|
96
|
+
};
|
|
97
|
+
const scaleNow = useRef(scale);
|
|
98
|
+
useEffect(() => {
|
|
99
|
+
scaleNow.current = scale;
|
|
100
|
+
zoom(scale);
|
|
101
|
+
}, [scale]);
|
|
102
|
+
useEffect(() => {
|
|
103
|
+
if (escapes > 0)
|
|
104
|
+
frame.current?.contentWindow?.postMessage({ source: SOURCE, type: 'escape' }, window.location.origin);
|
|
105
|
+
}, [escapes]);
|
|
106
|
+
const show = (id, still = false) => {
|
|
38
107
|
if (id !== undefined)
|
|
39
|
-
frame.current?.contentWindow?.postMessage({ source: SOURCE, type: 'show', id }, window.location.origin);
|
|
108
|
+
frame.current?.contentWindow?.postMessage({ source: SOURCE, type: 'show', id, ...(still && { still }) }, window.location.origin);
|
|
109
|
+
};
|
|
110
|
+
const tell = (said) => {
|
|
111
|
+
if (said !== undefined)
|
|
112
|
+
frame.current?.contentWindow?.postMessage({ source: SOURCE, type: 'typable', places: JSON.parse(said) }, window.location.origin);
|
|
113
|
+
};
|
|
114
|
+
const offer = (said) => {
|
|
115
|
+
if (said !== undefined)
|
|
116
|
+
frame.current?.contentWindow?.postMessage({ source: SOURCE, type: 'tools', ...JSON.parse(said) }, window.location.origin);
|
|
40
117
|
};
|
|
41
118
|
// Only this site's own page, in this frame, is listened to.
|
|
42
119
|
useEffect(() => {
|
|
@@ -46,15 +123,84 @@ export function PagePreview({ label, address, draft, note, toolbar, emptyText, o
|
|
|
46
123
|
const said = event.data;
|
|
47
124
|
if (said?.source !== SOURCE)
|
|
48
125
|
return;
|
|
49
|
-
if (said.type === 'section' && typeof said.id === 'string')
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
126
|
+
if (said.type === 'section' && typeof said.id === 'string') {
|
|
127
|
+
if (typeof said.field === 'string')
|
|
128
|
+
latest.current.onSectionPress?.(said.id, said.field, said.form === true);
|
|
129
|
+
else
|
|
130
|
+
latest.current.onSectionPress?.(said.id);
|
|
131
|
+
}
|
|
132
|
+
if (said.type === 'words' && typeof said.id === 'string' && typeof said.field === 'string' && typeof said.words === 'string') {
|
|
133
|
+
typedAt.current = Date.now();
|
|
134
|
+
latest.current.onWords?.(said.id, said.field, said.words);
|
|
135
|
+
}
|
|
136
|
+
if (said.type === 'act' || said.type === 'move' || said.type === 'item' || said.type === 'swatch' || said.type === 'undo' || said.type === 'redo')
|
|
137
|
+
pressedAt.current = Date.now();
|
|
138
|
+
if (said.type === 'act' && typeof said.id === 'string') {
|
|
139
|
+
const action = ACTIONS.find((candidate) => candidate === said.action);
|
|
140
|
+
if (action)
|
|
141
|
+
latest.current.onSectionAction?.(said.id, action);
|
|
142
|
+
}
|
|
143
|
+
if (said.type === 'move' && typeof said.id === 'string' && (typeof said.before === 'string' || said.before === null)) {
|
|
144
|
+
if (typeof said.into === 'string')
|
|
145
|
+
latest.current.onSectionMove?.(said.id, said.before, said.into);
|
|
146
|
+
else
|
|
147
|
+
latest.current.onSectionMove?.(said.id, said.before);
|
|
148
|
+
}
|
|
149
|
+
if (said.type === 'slot' && typeof said.id === 'string' && typeof said.field === 'string') {
|
|
150
|
+
latest.current.onSectionSlot?.(said.id, said.field);
|
|
151
|
+
}
|
|
152
|
+
if (said.type === 'picture' && typeof said.id === 'string' && typeof said.field === 'string') {
|
|
153
|
+
latest.current.onSectionPicture?.(said.id, said.field);
|
|
154
|
+
}
|
|
155
|
+
if (said.type === 'link' && typeof said.id === 'string' && typeof said.field === 'string') {
|
|
156
|
+
latest.current.onSectionLink?.(said.id, said.field);
|
|
157
|
+
}
|
|
158
|
+
if (said.type === 'item' && typeof said.id === 'string' && typeof said.field === 'string' && typeof said.at === 'number') {
|
|
159
|
+
const action = ITEM_ACTIONS.find((candidate) => candidate === said.action);
|
|
160
|
+
if (action)
|
|
161
|
+
latest.current.onSectionItem?.(said.id, said.field, said.at, action);
|
|
162
|
+
}
|
|
163
|
+
if (said.type === 'swatch' && typeof said.id === 'string' && typeof said.field === 'string' && typeof said.value === 'string') {
|
|
164
|
+
latest.current.onSectionSwatch?.(said.id, said.field, said.value);
|
|
165
|
+
}
|
|
166
|
+
if (said.type === 'linkAsk' && typeof said.href === 'string') {
|
|
167
|
+
const page = frame.current?.contentWindow;
|
|
168
|
+
const answer = (href) => page?.postMessage({ source: SOURCE, type: 'linkAnswer', href }, window.location.origin);
|
|
169
|
+
if (latest.current.onTextLink)
|
|
170
|
+
latest.current.onTextLink(said.href, answer);
|
|
171
|
+
else
|
|
172
|
+
answer(null);
|
|
173
|
+
}
|
|
174
|
+
if (said.type === 'undo' || said.type === 'redo') {
|
|
175
|
+
// What the form holds next is not what the page shows, however lately words were typed there.
|
|
176
|
+
typedAt.current = 0;
|
|
177
|
+
if (said.type === 'undo')
|
|
178
|
+
latest.current.onUndo?.();
|
|
179
|
+
else
|
|
180
|
+
latest.current.onRedo?.();
|
|
181
|
+
}
|
|
182
|
+
if (said.type === 'save')
|
|
183
|
+
latest.current.onSave?.();
|
|
184
|
+
if (said.type === 'ready') {
|
|
185
|
+
told.current = 1;
|
|
186
|
+
zoom(scaleNow.current);
|
|
187
|
+
tell(latest.current.places);
|
|
188
|
+
offer(latest.current.offered);
|
|
189
|
+
// Outlined again, and brought into view only on the first page or when the change that drew this one asked for it.
|
|
190
|
+
show(latest.current.shownSectionId, hasDrawn.current && Math.abs(askedAt.current - changedAt.current) > TOGETHER);
|
|
191
|
+
hasDrawn.current = true;
|
|
192
|
+
askedAt.current = 0;
|
|
193
|
+
}
|
|
53
194
|
};
|
|
54
195
|
window.addEventListener('message', hear);
|
|
55
196
|
return () => window.removeEventListener('message', hear);
|
|
56
197
|
}, []);
|
|
57
|
-
useEffect(() =>
|
|
58
|
-
|
|
198
|
+
useEffect(() => {
|
|
199
|
+
askedAt.current = Date.now();
|
|
200
|
+
show(shownSectionId);
|
|
201
|
+
}, [shownSectionId, shownAt]);
|
|
202
|
+
useEffect(() => tell(places), [places]);
|
|
203
|
+
useEffect(() => offer(offered), [offered]);
|
|
204
|
+
return (_jsxs("div", { className: pagePreviewVariants({ isBare }), children: [(note !== undefined || toolbar !== undefined || action !== undefined) && (_jsxs("div", { className: pagePreviewBarClass, children: [action ?? _jsx("span", { className: pagePreviewNoteClass, children: note }), toolbar] })), _jsx("div", { ref: stage, className: pagePreviewStageVariants({ isFitted }), children: address === undefined ? (_jsx("p", { className: pagePreviewEmptyClass, children: emptyText })) : (_jsxs(_Fragment, { children: [createPortal(_jsx("form", { ref: form, method: "post", action: address, target: name, hidden: true, children: _jsx("input", { type: "hidden", name: "draft", value: draft, readOnly: true }) }), document.body), _jsx("iframe", { ref: frame, name: name, title: label, className: pagePreviewFrameVariants({ width, isFitted }), ...(isFitted && room !== null && { style: { width: `${wanted}px`, height: `${room.height / scale}px`, transform: `scale(${scale})` } }) })] })) })] }));
|
|
59
205
|
}
|
|
60
206
|
//# sourceMappingURL=PagePreview.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PagePreview.js","sourceRoot":"","sources":["../../../src/patterns/PagePreview/PagePreview.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,EAAkB,MAAM,OAAO,CAAC;AACjE,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,EACL,mBAAmB,EACnB,gBAAgB,EAChB,qBAAqB,EACrB,wBAAwB,EACxB,oBAAoB,EACpB,qBAAqB,GAEtB,MAAM,2BAA2B,CAAC;AAEnC,+FAA+F;AAC/F,MAAM,KAAK,GAAG,GAAG,CAAC;AAClB,+FAA+F;AAC/F,MAAM,MAAM,GAAG,cAAc,CAAC;AA8B9B;;;GAGG;AACH,MAAM,UAAU,WAAW,CAAC,EAAE,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,cAAc,EAAE,cAAc,EAAE,KAAK,EAAoB;IACtI,MAAM,IAAI,GAAG,WAAW,KAAK,EAAE,CAAC,UAAU,CAAC,GAAG,EAAE,EAAE,CAAC,EAAE,CAAC;IACtD,MAAM,IAAI,GAAG,MAAM,CAAkB,IAAI,CAAC,CAAC;IAC3C,MAAM,KAAK,GAAG,MAAM,CAAoB,IAAI,CAAC,CAAC;IAC9C,MAAM,OAAO,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;IAC9B,MAAM,MAAM,GAAG,MAAM,CAAC,EAAE,cAAc,EAAE,cAAc,EAAE,CAAC,CAAC;IAC1D,SAAS,CAAC,GAAG,EAAE;QACb,MAAM,CAAC,OAAO,GAAG,EAAE,cAAc,EAAE,cAAc,EAAE,CAAC;IACtD,CAAC,CAAC,CAAC;IAEH,4FAA4F;IAC5F,SAAS,CAAC,GAAG,EAAE;QACb,IAAI,OAAO,KAAK,SAAS;YAAE,OAAO;QAClC,MAAM,IAAI,GAAG,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AK,GAAG,EAAE,EAAE,CAAC,GACxI,IACD,CACJ,GACG,IACF,CACP,CAAC;AACJ,CAAC"}
|
|
@@ -1,12 +1,25 @@
|
|
|
1
1
|
import { type VariantProps } from 'class-variance-authority';
|
|
2
|
-
|
|
2
|
+
/** In a card of its own, or bare where what holds it is the frame already. */
|
|
3
|
+
export declare const pagePreviewVariants: (props?: ({
|
|
4
|
+
isBare?: boolean | null | undefined;
|
|
5
|
+
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
3
6
|
export declare const pagePreviewBarClass = "flex flex-wrap items-center justify-between gap-3 border-b border-border bg-background px-3 py-2";
|
|
4
7
|
export declare const pagePreviewNoteClass = "min-w-0 truncate text-sm text-foreground-muted";
|
|
5
|
-
|
|
8
|
+
/** A page shown smaller than it is starts at the pane's corner, and what it leaves over is cut off. */
|
|
9
|
+
export declare const pagePreviewStageVariants: (props?: ({
|
|
10
|
+
isFitted?: boolean | null | undefined;
|
|
11
|
+
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
12
|
+
/** The width, in pixels, of the screen each choice stands for. A pane narrower than that shows the page smaller. */
|
|
13
|
+
export declare const pagePreviewWidths: {
|
|
14
|
+
readonly phone: 384;
|
|
15
|
+
readonly tablet: 768;
|
|
16
|
+
readonly full: 1280;
|
|
17
|
+
};
|
|
6
18
|
export declare const pagePreviewEmptyClass = "m-auto max-w-sm px-6 text-center text-sm text-foreground-muted";
|
|
7
19
|
/** The page at the width of the screen it is tried on. Narrower than the pane, it stands in the middle with an edge each side. */
|
|
8
20
|
export declare const pagePreviewFrameVariants: (props?: ({
|
|
9
21
|
width?: "full" | "phone" | "tablet" | null | undefined;
|
|
22
|
+
isFitted?: boolean | null | undefined;
|
|
10
23
|
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
11
24
|
export type PagePreviewVariants = VariantProps<typeof pagePreviewFrameVariants>;
|
|
12
25
|
//# sourceMappingURL=PagePreview.variants.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PagePreview.variants.d.ts","sourceRoot":"","sources":["../../../src/patterns/PagePreview/PagePreview.variants.ts"],"names":[],"mappings":"AAAA,OAAO,EAAO,KAAK,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAElE,eAAO,MAAM,
|
|
1
|
+
{"version":3,"file":"PagePreview.variants.d.ts","sourceRoot":"","sources":["../../../src/patterns/PagePreview/PagePreview.variants.ts"],"names":[],"mappings":"AAAA,OAAO,EAAO,KAAK,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAElE,8EAA8E;AAC9E,eAAO,MAAM,mBAAmB;;8EAG9B,CAAC;AACH,eAAO,MAAM,mBAAmB,qGAAqG,CAAC;AACtI,eAAO,MAAM,oBAAoB,mDAAmD,CAAC;AACrF,uGAAuG;AACvG,eAAO,MAAM,wBAAwB;;8EAGnC,CAAC;AAEH,oHAAoH;AACpH,eAAO,MAAM,iBAAiB;;;;CAAmD,CAAC;AAClF,eAAO,MAAM,qBAAqB,mEAAmE,CAAC;AAEtG,kIAAkI;AAClI,eAAO,MAAM,wBAAwB;;;8EAenC,CAAC;AAEH,MAAM,MAAM,mBAAmB,GAAG,YAAY,CAAC,OAAO,wBAAwB,CAAC,CAAC"}
|
|
@@ -1,18 +1,34 @@
|
|
|
1
1
|
import { cva } from 'class-variance-authority';
|
|
2
|
-
|
|
2
|
+
/** In a card of its own, or bare where what holds it is the frame already. */
|
|
3
|
+
export const pagePreviewVariants = cva('flex h-full min-h-0 flex-col overflow-hidden bg-background-secondary', {
|
|
4
|
+
variants: { isBare: { true: '', false: 'rounded-lg border border-border' } },
|
|
5
|
+
defaultVariants: { isBare: false },
|
|
6
|
+
});
|
|
3
7
|
export const pagePreviewBarClass = 'flex flex-wrap items-center justify-between gap-3 border-b border-border bg-background px-3 py-2';
|
|
4
8
|
export const pagePreviewNoteClass = 'min-w-0 truncate text-sm text-foreground-muted';
|
|
5
|
-
|
|
9
|
+
/** A page shown smaller than it is starts at the pane's corner, and what it leaves over is cut off. */
|
|
10
|
+
export const pagePreviewStageVariants = cva('flex min-h-0 flex-1', {
|
|
11
|
+
variants: { isFitted: { true: 'justify-start overflow-hidden', false: 'justify-center' } },
|
|
12
|
+
defaultVariants: { isFitted: false },
|
|
13
|
+
});
|
|
14
|
+
/** The width, in pixels, of the screen each choice stands for. A pane narrower than that shows the page smaller. */
|
|
15
|
+
export const pagePreviewWidths = { phone: 384, tablet: 768, full: 1280 };
|
|
6
16
|
export const pagePreviewEmptyClass = 'm-auto max-w-sm px-6 text-center text-sm text-foreground-muted';
|
|
7
17
|
/** The page at the width of the screen it is tried on. Narrower than the pane, it stands in the middle with an edge each side. */
|
|
8
|
-
export const pagePreviewFrameVariants = cva('
|
|
18
|
+
export const pagePreviewFrameVariants = cva('bg-background', {
|
|
9
19
|
variants: {
|
|
10
20
|
width: {
|
|
11
|
-
phone: '
|
|
12
|
-
tablet: '
|
|
21
|
+
phone: 'border-x border-border',
|
|
22
|
+
tablet: 'border-x border-border',
|
|
13
23
|
full: '',
|
|
14
24
|
},
|
|
25
|
+
// Fitted, its size is the screen's own and it is shown smaller from its corner.
|
|
26
|
+
isFitted: { true: 'max-w-none shrink-0 origin-top-left', false: 'h-full w-full transition-all motion-base' },
|
|
15
27
|
},
|
|
16
|
-
|
|
28
|
+
compoundVariants: [
|
|
29
|
+
{ width: 'phone', isFitted: false, class: 'max-w-sm' },
|
|
30
|
+
{ width: 'tablet', isFitted: false, class: 'max-w-3xl' },
|
|
31
|
+
],
|
|
32
|
+
defaultVariants: { width: 'full', isFitted: false },
|
|
17
33
|
});
|
|
18
34
|
//# sourceMappingURL=PagePreview.variants.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PagePreview.variants.js","sourceRoot":"","sources":["../../../src/patterns/PagePreview/PagePreview.variants.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAqB,MAAM,0BAA0B,CAAC;AAElE,MAAM,CAAC,MAAM,
|
|
1
|
+
{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D,gBAAgB,EAAE;QAChB,EAAE,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,KAAK,EAAE,UAAU,EAAE;QACtD,EAAE,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,KAAK,EAAE,KAAK,EAAE,WAAW,EAAE;KACzD;IACD,eAAe,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,KAAK,EAAE;CACpD,CAAC,CAAC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { PagePreview, type PagePreviewProps } from './PagePreview.js';
|
|
1
|
+
export { PagePreview, type PageItemAction, type PagePreviewProps, type PageSectionAction, type PageSectionSwatches, type PageSectionTools } from './PagePreview.js';
|
|
2
2
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/patterns/PagePreview/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,KAAK,gBAAgB,EAAE,MAAM,kBAAkB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/patterns/PagePreview/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,KAAK,cAAc,EAAE,KAAK,gBAAgB,EAAE,KAAK,iBAAiB,EAAE,KAAK,mBAAmB,EAAE,KAAK,gBAAgB,EAAE,MAAM,kBAAkB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/patterns/PagePreview/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/patterns/PagePreview/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAuH,MAAM,kBAAkB,CAAC"}
|
|
@@ -1,6 +1,9 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type ReactNode } from 'react';
|
|
2
2
|
export interface SaveBarBack {
|
|
3
|
-
|
|
3
|
+
/** Where it goes. Left out, `onPress` says what going back does. */
|
|
4
|
+
readonly href?: string;
|
|
5
|
+
/** What going back does, where it is not another address: closing a view that took the window. */
|
|
6
|
+
readonly onPress?: () => void;
|
|
4
7
|
/** Where it goes, such as "Listings". */
|
|
5
8
|
readonly label: string;
|
|
6
9
|
}
|
|
@@ -11,11 +14,24 @@ export interface SaveBarProps {
|
|
|
11
14
|
readonly back?: SaveBarBack;
|
|
12
15
|
/** What is being edited. It becomes the page's level 1 heading. */
|
|
13
16
|
readonly title?: string;
|
|
14
|
-
/** Where the entry stands
|
|
17
|
+
/** Where the entry stands, such as a `Tag` saying Draft. Beside the title, on its one row. */
|
|
15
18
|
readonly status: ReactNode;
|
|
19
|
+
/**
|
|
20
|
+
* A few words more about it, such as "Saved 2 minutes ago", after the status. Shown from `lg` up, where the
|
|
21
|
+
* row has room for them; read out on every window, with the status.
|
|
22
|
+
*/
|
|
23
|
+
readonly note?: ReactNode;
|
|
16
24
|
/** The buttons, main action last. */
|
|
17
25
|
readonly actions: ReactNode;
|
|
26
|
+
/** In the middle of the bar, from `md` up: controls for what is shown, such as the widths of a page. */
|
|
27
|
+
readonly center?: ReactNode;
|
|
28
|
+
/**
|
|
29
|
+
* `screen` for the bar of an editing screen, drawn in the shell's bar inside `AppShell`. `section` for a
|
|
30
|
+
* form inside a screen that has its own header, where it stays at the top of that part. `window` for a
|
|
31
|
+
* bar across a whole window.
|
|
32
|
+
*/
|
|
33
|
+
readonly across?: 'screen' | 'section' | 'window';
|
|
18
34
|
}
|
|
19
35
|
/** The bar that stays at the top of an editing screen: the way back, what is being edited, its state and its save buttons. */
|
|
20
|
-
export declare function SaveBar({ label, back, title, status, actions }: SaveBarProps): import("react").JSX.Element;
|
|
36
|
+
export declare function SaveBar({ label, back, title, status, note, actions, center, across }: SaveBarProps): import("react").JSX.Element | null;
|
|
21
37
|
//# sourceMappingURL=SaveBar.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SaveBar.d.ts","sourceRoot":"","sources":["../../../src/patterns/SaveBar/SaveBar.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"SaveBar.d.ts","sourceRoot":"","sources":["../../../src/patterns/SaveBar/SaveBar.tsx"],"names":[],"mappings":"AACA,OAAO,EAAa,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAiBlD,MAAM,WAAW,WAAW;IAC1B,oEAAoE;IACpE,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB,kGAAkG;IAClG,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IAC9B,yCAAyC;IACzC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;CACxB;AAED,MAAM,WAAW,YAAY;IAC3B,oEAAoE;IACpE,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,qDAAqD;IACrD,QAAQ,CAAC,IAAI,CAAC,EAAE,WAAW,CAAC;IAC5B,mEAAmE;IACnE,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IACxB,8FAA8F;IAC9F,QAAQ,CAAC,MAAM,EAAE,SAAS,CAAC;IAC3B;;;OAGG;IACH,QAAQ,CAAC,IAAI,CAAC,EAAE,SAAS,CAAC;IAC1B,qCAAqC;IACrC,QAAQ,CAAC,OAAO,EAAE,SAAS,CAAC;IAC5B,wGAAwG;IACxG,QAAQ,CAAC,MAAM,CAAC,EAAE,SAAS,CAAC;IAC5B;;;;OAIG;IACH,QAAQ,CAAC,MAAM,CAAC,EAAE,QAAQ,GAAG,SAAS,GAAG,QAAQ,CAAC;CACnD;AAED,8HAA8H;AAC9H,wBAAgB,OAAO,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,MAAiB,EAAE,EAAE,YAAY,sCAuC7G"}
|
|
@@ -1,9 +1,27 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { ChevronLeft } from 'lucide-react';
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
3
|
+
import { useEffect } from 'react';
|
|
4
|
+
import { createPortal } from 'react-dom';
|
|
5
|
+
import { Button, Link } from 'react-aria-components';
|
|
6
|
+
import { saveBarActionsClass, saveBarBackClass, saveBarBackLabelClass, saveBarBackIconSize, saveBarCenterClass, saveBarHeadingVariants, saveBarNoteClass, saveBarStatusClass, saveBarTitleClass, saveBarVariants, } from './SaveBar.variants.js';
|
|
7
|
+
import { usePageBar, usePageBarBack } from '../page-bar.js';
|
|
5
8
|
/** The bar that stays at the top of an editing screen: the way back, what is being edited, its state and its save buttons. */
|
|
6
|
-
export function SaveBar({ label, back, title, status, actions }) {
|
|
7
|
-
|
|
9
|
+
export function SaveBar({ label, back, title, status, note, actions, center, across = 'screen' }) {
|
|
10
|
+
const shellBar = usePageBar();
|
|
11
|
+
const inShell = across === 'screen' && shellBar !== undefined;
|
|
12
|
+
// A bar that leads back has the way back where a phone shows the menu: the shell leaves its menu and search out there.
|
|
13
|
+
const leadsBack = usePageBarBack();
|
|
14
|
+
const isLeadingBack = inShell && back !== undefined;
|
|
15
|
+
useEffect(() => {
|
|
16
|
+
if (!isLeadingBack || leadsBack === undefined)
|
|
17
|
+
return;
|
|
18
|
+
leadsBack(true);
|
|
19
|
+
return () => leadsBack(false);
|
|
20
|
+
}, [isLeadingBack, leadsBack]);
|
|
21
|
+
// The shell is still drawing its bar: this one comes once there is a place for it.
|
|
22
|
+
if (inShell && shellBar === null)
|
|
23
|
+
return null;
|
|
24
|
+
const bar = (_jsxs("div", { role: "region", "aria-label": label, className: saveBarVariants({ across: inShell ? 'shell' : across }), children: [back?.href !== undefined && (_jsxs(Link, { href: back.href, className: saveBarBackClass, children: [_jsx(ChevronLeft, { "aria-hidden": true, size: saveBarBackIconSize }), _jsx("span", { className: saveBarBackLabelClass, children: back.label })] })), back !== undefined && back.href === undefined && (_jsxs(Button, { className: saveBarBackClass, ...(back.onPress && { onPress: back.onPress }), children: [_jsx(ChevronLeft, { "aria-hidden": true, size: saveBarBackIconSize }), _jsx("span", { className: saveBarBackLabelClass, children: back.label })] })), _jsxs("div", { className: saveBarHeadingVariants({ hasCenter: center !== undefined }), children: [title !== undefined && _jsx("h1", { className: saveBarTitleClass, children: title }), _jsxs("div", { className: saveBarStatusClass, "aria-live": "polite", children: [status, note !== undefined && _jsx("span", { className: saveBarNoteClass, children: note })] })] }), center !== undefined && _jsx("div", { className: saveBarCenterClass, children: center }), _jsx("div", { className: saveBarActionsClass, children: actions })] }));
|
|
25
|
+
return inShell && shellBar ? createPortal(bar, shellBar) : bar;
|
|
8
26
|
}
|
|
9
27
|
//# sourceMappingURL=SaveBar.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SaveBar.js","sourceRoot":"","sources":["../../../src/patterns/SaveBar/SaveBar.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"SaveBar.js","sourceRoot":"","sources":["../../../src/patterns/SaveBar/SaveBar.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,EAAE,SAAS,EAAkB,MAAM,OAAO,CAAC;AAClD,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,uBAAuB,CAAC;AACrD,OAAO,EACL,mBAAmB,EACnB,gBAAgB,EAChB,qBAAqB,EACrB,mBAAmB,EACnB,kBAAkB,EAClB,sBAAsB,EACtB,gBAAgB,EAChB,kBAAkB,EAClB,iBAAiB,EACjB,eAAe,GAChB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,UAAU,EAAE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,CAAC,IAAI,KAAK,SAAS,IAAI,CAChD,MAAC,MAAM,IAAC,SAAS,EAAE,gBAAgB,KAAM,CAAC,IAAI,CAAC,OAAO,IAAI,EAAE,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,CAAC,aAClF,KAAC,WAAW,yBAAa,IAAI,EAAE,mBAAmB,GAAI,EACtD,eAAM,SAAS,EAAE,qBAAqB,YAAG,IAAI,CAAC,KAAK,GAAQ,IACpD,CACV,EACD,eAAK,SAAS,EAAE,sBAAsB,CAAC,EAAE,SAAS,EAAE,MAAM,KAAK,SAAS,EAAE,CAAC,aACxE,KAAK,KAAK,SAAS,IAAI,aAAI,SAAS,EAAE,iBAAiB,YAAG,KAAK,GAAM,EACtE,eAAK,SAAS,EAAE,kBAAkB,eAAY,QAAQ,aACnD,MAAM,EACN,IAAI,KAAK,SAAS,IAAI,eAAM,SAAS,EAAE,gBAAgB,YAAG,IAAI,GAAQ,IACnE,IACF,EACL,MAAM,KAAK,SAAS,IAAI,cAAK,SAAS,EAAE,kBAAkB,YAAG,MAAM,GAAO,EAC3E,cAAK,SAAS,EAAE,mBAAmB,YAAG,OAAO,GAAO,IAChD,CACP,CAAC;IACF,OAAO,OAAO,IAAI,QAAQ,CAAC,CAAC,CAAC,YAAY,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC;AACjE,CAAC"}
|
|
@@ -1,9 +1,31 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* On a screen the bar stays at the top of the screen. Inside `AppShell` it is drawn in the shell's own
|
|
3
|
+
* bar, which already stays. Across a whole window it is the window's top edge.
|
|
4
|
+
* In the shell's bar and across a window it is one row, as on any phone: the way back, the title cut to fit,
|
|
5
|
+
* and buttons few enough to fit (a screen folds the rest into its menu there). On its own in a screen the
|
|
6
|
+
* buttons go under the title when the window has no room for them beside it, and never off its edge.
|
|
7
|
+
*/
|
|
8
|
+
export declare const saveBarVariants: (props?: ({
|
|
9
|
+
across?: "section" | "screen" | "shell" | "window" | null | undefined;
|
|
10
|
+
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
11
|
+
/** On a phone the way back is its arrow alone, and its words are read out. */
|
|
2
12
|
export declare const saveBarBackClass: string;
|
|
3
|
-
export declare const
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
13
|
+
export declare const saveBarBackLabelClass = "sr-only md:not-sr-only";
|
|
14
|
+
/**
|
|
15
|
+
* The title and its status on one row: the title is cut to fit, the status keeps its words. With something in
|
|
16
|
+
* the middle of the bar, the heading keeps to its words and the middle takes the room.
|
|
17
|
+
*/
|
|
18
|
+
export declare const saveBarHeadingVariants: (props?: ({
|
|
19
|
+
hasCenter?: boolean | null | undefined;
|
|
20
|
+
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
21
|
+
/** In the middle of the bar, from `md` up: the controls of what is shown, such as the widths of a page. */
|
|
22
|
+
export declare const saveBarCenterClass = "hidden min-w-0 flex-1 items-center justify-center md:flex";
|
|
23
|
+
export declare const saveBarTitleClass = "min-w-0 truncate text-lg font-semibold text-foreground";
|
|
24
|
+
export declare const saveBarStatusClass = "flex shrink-0 items-center gap-2 whitespace-nowrap";
|
|
25
|
+
/** The words after the status: from `lg` up, where the row has room. */
|
|
26
|
+
export declare const saveBarNoteClass = "sr-only text-sm text-foreground-muted lg:not-sr-only";
|
|
27
|
+
/** The buttons, the main one last. */
|
|
28
|
+
export declare const saveBarActionsClass = "flex max-w-full shrink-0 flex-wrap items-center justify-end gap-1 md:gap-2";
|
|
7
29
|
/** The size of the arrow on the way back, in pixels. */
|
|
8
30
|
export declare const saveBarBackIconSize = 16;
|
|
9
31
|
//# sourceMappingURL=SaveBar.variants.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SaveBar.variants.d.ts","sourceRoot":"","sources":["../../../src/patterns/SaveBar/SaveBar.variants.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"SaveBar.variants.d.ts","sourceRoot":"","sources":["../../../src/patterns/SaveBar/SaveBar.variants.ts"],"names":[],"mappings":"AAEA;;;;;;GAMG;AACH,eAAO,MAAM,eAAe;;8EAU1B,CAAC;AAEH,8EAA8E;AAC9E,eAAO,MAAM,gBAAgB,QAKlB,CAAC;AAEZ,eAAO,MAAM,qBAAqB,2BAA2B,CAAC;AAE9D;;;GAGG;AACH,eAAO,MAAM,sBAAsB;;8EAGjC,CAAC;AACH,2GAA2G;AAC3G,eAAO,MAAM,kBAAkB,8DAA8D,CAAC;AAC9F,eAAO,MAAM,iBAAiB,2DAA2D,CAAC;AAC1F,eAAO,MAAM,kBAAkB,uDAAuD,CAAC;AACvF,wEAAwE;AACxE,eAAO,MAAM,gBAAgB,yDAAyD,CAAC;AACvF,sCAAsC;AACtC,eAAO,MAAM,mBAAmB,+EAA+E,CAAC;AAEhH,wDAAwD;AACxD,eAAO,MAAM,mBAAmB,KAAK,CAAC"}
|
|
@@ -1,13 +1,46 @@
|
|
|
1
|
-
|
|
1
|
+
import { cva } from 'class-variance-authority';
|
|
2
|
+
/**
|
|
3
|
+
* On a screen the bar stays at the top of the screen. Inside `AppShell` it is drawn in the shell's own
|
|
4
|
+
* bar, which already stays. Across a whole window it is the window's top edge.
|
|
5
|
+
* In the shell's bar and across a window it is one row, as on any phone: the way back, the title cut to fit,
|
|
6
|
+
* and buttons few enough to fit (a screen folds the rest into its menu there). On its own in a screen the
|
|
7
|
+
* buttons go under the title when the window has no room for them beside it, and never off its edge.
|
|
8
|
+
*/
|
|
9
|
+
export const saveBarVariants = cva('flex items-center', {
|
|
10
|
+
variants: {
|
|
11
|
+
across: {
|
|
12
|
+
screen: 'sticky top-0 layer-sticky flex-wrap gap-x-4 gap-y-2 border-b border-border bg-background px-4 py-3 md:px-6',
|
|
13
|
+
shell: 'min-w-0 flex-1 gap-2 py-2 md:gap-4',
|
|
14
|
+
section: 'sticky top-0 layer-sticky flex-wrap gap-x-4 gap-y-2 border-b border-border bg-background px-4 py-3 md:px-6',
|
|
15
|
+
window: 'shrink-0 gap-2 border-b border-border bg-card px-3 py-2 md:gap-4',
|
|
16
|
+
},
|
|
17
|
+
},
|
|
18
|
+
defaultVariants: { across: 'screen' },
|
|
19
|
+
});
|
|
20
|
+
/** On a phone the way back is its arrow alone, and its words are read out. */
|
|
2
21
|
export const saveBarBackClass = [
|
|
3
|
-
'inline-flex h-8 shrink-0 items-center gap-1.5 rounded-md border border-border-strong bg-background
|
|
22
|
+
'inline-flex h-8 shrink-0 items-center justify-center gap-1.5 rounded-md border border-border-strong bg-background text-sm font-medium text-foreground',
|
|
23
|
+
'w-8 md:w-auto md:pr-3 md:pl-2',
|
|
4
24
|
'transition-colors motion-fast',
|
|
5
25
|
'outline-none data-hovered:bg-background-secondary data-focus-visible:ring-2 data-focus-visible:ring-ring',
|
|
6
26
|
].join(' ');
|
|
7
|
-
export const
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
27
|
+
export const saveBarBackLabelClass = 'sr-only md:not-sr-only';
|
|
28
|
+
/**
|
|
29
|
+
* The title and its status on one row: the title is cut to fit, the status keeps its words. With something in
|
|
30
|
+
* the middle of the bar, the heading keeps to its words and the middle takes the room.
|
|
31
|
+
*/
|
|
32
|
+
export const saveBarHeadingVariants = cva('flex min-w-0 items-center gap-3', {
|
|
33
|
+
variants: { hasCenter: { true: 'flex-1 md:flex-none md:shrink', false: 'flex-1 basis-0 md:basis-48' } },
|
|
34
|
+
defaultVariants: { hasCenter: false },
|
|
35
|
+
});
|
|
36
|
+
/** In the middle of the bar, from `md` up: the controls of what is shown, such as the widths of a page. */
|
|
37
|
+
export const saveBarCenterClass = 'hidden min-w-0 flex-1 items-center justify-center md:flex';
|
|
38
|
+
export const saveBarTitleClass = 'min-w-0 truncate text-lg font-semibold text-foreground';
|
|
39
|
+
export const saveBarStatusClass = 'flex shrink-0 items-center gap-2 whitespace-nowrap';
|
|
40
|
+
/** The words after the status: from `lg` up, where the row has room. */
|
|
41
|
+
export const saveBarNoteClass = 'sr-only text-sm text-foreground-muted lg:not-sr-only';
|
|
42
|
+
/** The buttons, the main one last. */
|
|
43
|
+
export const saveBarActionsClass = 'flex max-w-full shrink-0 flex-wrap items-center justify-end gap-1 md:gap-2';
|
|
11
44
|
/** The size of the arrow on the way back, in pixels. */
|
|
12
45
|
export const saveBarBackIconSize = 16;
|
|
13
46
|
//# sourceMappingURL=SaveBar.variants.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SaveBar.variants.js","sourceRoot":"","sources":["../../../src/patterns/SaveBar/SaveBar.variants.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,
|
|
1
|
+
{"version":3,"file":"SaveBar.variants.js","sourceRoot":"","sources":["../../../src/patterns/SaveBar/SaveBar.variants.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,0BAA0B,CAAC;AAE/C;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,GAAG,CAAC,mBAAmB,EAAE;IACtD,QAAQ,EAAE;QACR,MAAM,EAAE;YACN,MAAM,EAAE,4GAA4G;YACpH,KAAK,EAAE,oCAAoC;YAC3C,OAAO,EAAE,4GAA4G;YACrH,MAAM,EAAE,kEAAkE;SAC3E;KACF;IACD,eAAe,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAE;CACtC,CAAC,CAAC;AAEH,8EAA8E;AAC9E,MAAM,CAAC,MAAM,gBAAgB,GAAG;IAC9B,uJAAuJ;IACvJ,+BAA+B;IAC/B,+BAA+B;IAC/B,0GAA0G;CAC3G,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAEZ,MAAM,CAAC,MAAM,qBAAqB,GAAG,wBAAwB,CAAC;AAE9D;;;GAGG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,GAAG,CAAC,iCAAiC,EAAE;IAC3E,QAAQ,EAAE,EAAE,SAAS,EAAE,EAAE,IAAI,EAAE,+BAA+B,EAAE,KAAK,EAAE,4BAA4B,EAAE,EAAE;IACvG,eAAe,EAAE,EAAE,SAAS,EAAE,KAAK,EAAE;CACtC,CAAC,CAAC;AACH,2GAA2G;AAC3G,MAAM,CAAC,MAAM,kBAAkB,GAAG,2DAA2D,CAAC;AAC9F,MAAM,CAAC,MAAM,iBAAiB,GAAG,wDAAwD,CAAC;AAC1F,MAAM,CAAC,MAAM,kBAAkB,GAAG,oDAAoD,CAAC;AACvF,wEAAwE;AACxE,MAAM,CAAC,MAAM,gBAAgB,GAAG,sDAAsD,CAAC;AACvF,sCAAsC;AACtC,MAAM,CAAC,MAAM,mBAAmB,GAAG,4EAA4E,CAAC;AAEhH,wDAAwD;AACxD,MAAM,CAAC,MAAM,mBAAmB,GAAG,EAAE,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SectionList.d.ts","sourceRoot":"","sources":["../../../src/patterns/SectionList/SectionList.tsx"],"names":[],"mappings":"AAAA,OAAO,EAA+E,KAAK,UAAU,EAAE,MAAM,cAAc,CAAC;AAC5H,OAAO,EAAsC,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAI3E,OAAO,EAAQ,KAAK,UAAU,EAAE,MAAM,gCAAgC,CAAC;
|
|
1
|
+
{"version":3,"file":"SectionList.d.ts","sourceRoot":"","sources":["../../../src/patterns/SectionList/SectionList.tsx"],"names":[],"mappings":"AAAA,OAAO,EAA+E,KAAK,UAAU,EAAE,MAAM,cAAc,CAAC;AAC5H,OAAO,EAAsC,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAI3E,OAAO,EAAQ,KAAK,UAAU,EAAE,MAAM,gCAAgC,CAAC;AA4BvE,MAAM,WAAW,eAAe;IAC9B,uDAAuD;IACvD,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,oDAAoD;IACpD,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,+EAA+E;IAC/E,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;I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,CAAC,WAAW,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,MAAM,CAAC;IACnD,QAAQ,CAAC,aAAa,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,MAAM,CAAC;IACrD,QAAQ,CAAC,SAAS,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,MAAM,CAAC;IACjD,wEAAwE;IACxE,QAAQ,CAAC,SAAS,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,MAAM,CAAC;IACjD,qFAAqF;IACrF,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CACxC;AAED,mGAAmG;AACnG,wBAAgB,WAAW,CAAC,EAC1B,KAAK,EACL,WAAW,EACX,YAAY,EACZ,KAAK,EACL,OAAO,EACP,YAAY,EACZ,SAAS,EACT,QAAQ,EACR,KAAK,EACL,MAAc,EACd,MAAM,EACN,QAAQ,EACR,WAAW,EACX,aAAa,EACb,SAAS,EACT,SAAS,EACT,QAAQ,GACT,EAAE,gBAAgB,+BA8ClB"}
|
|
@@ -6,7 +6,7 @@ import { Button } from '../../components/Button/index.js';
|
|
|
6
6
|
import { IconButton } from '../../components/IconButton/index.js';
|
|
7
7
|
import { Menu } from '../../components/Menu/index.js';
|
|
8
8
|
import { Tag } from '../../components/Tag/index.js';
|
|
9
|
-
import { sectionActionsClass, sectionChevronClass, sectionDropLineClass, sectionGripClass, sectionHeaderClass, sectionHeadingClass, sectionIconSize, sectionIconVariants, sectionListAddClass, sectionListClass, sectionListDescriptionClass, sectionListEmptyClass, sectionListErrorClass, sectionListItemsClass, sectionListLabelClass, sectionPanelClass, sectionProblemClass, sectionSummaryClass, sectionTextClass, sectionTitleVariants, sectionTriggerClass, sectionVariants, } from './SectionList.variants.js';
|
|
9
|
+
import { sectionActionsClass, sectionChevronClass, sectionDropLineClass, sectionGripClass, sectionHeaderClass, sectionHeadingClass, sectionIconSize, sectionIconVariants, sectionListAddClass, sectionListClass, sectionListDescriptionClass, sectionListEmptyClass, sectionListErrorClass, sectionListItemsClass, sectionListLabelClass, sectionPanelClass, sectionProblemClass, sectionDetailClass, sectionSummaryClass, sectionTextClass, sectionTitleVariants, sectionTriggerClass, sectionVariants, } from './SectionList.variants.js';
|
|
10
10
|
/** Sections of different kinds in an order a person chooses. Each opens to show its own fields. */
|
|
11
11
|
export function SectionList({ label, description, errorMessage, items, openIds, onOpenChange, emptyText, addLabel, onAdd, isFull = false, onMove, onAction, moveUpLabel, moveDownLabel, moreLabel, dragLabel, revealId, }) {
|
|
12
12
|
const labelId = useId();
|
|
@@ -54,6 +54,6 @@ function SectionRow({ item, index, ids, isOpen, onOpenChange, onMove, onAction,
|
|
|
54
54
|
});
|
|
55
55
|
const tone = tag === undefined ? 'default' : 'quiet';
|
|
56
56
|
const Chevron = isOpen ? ChevronDown : ChevronRight;
|
|
57
|
-
return (_jsxs("li", { ref: row, "data-section": id, ...dropProps, children: [landing === 'before' && _jsx("div", { className: sectionDropLineClass }), _jsxs(Disclosure, { className: sectionVariants({ state: problem !== undefined ? 'problem' : landing === 'here' ? 'target' : isDragging ? 'dragging' : 'default' }), isExpanded: isOpen, onExpandedChange: (next) => onOpenChange(id, next), children: [_jsxs("div", { className: sectionHeaderClass, ...dragProps, children: [_jsx(AriaButton, { ...dragButtonProps, "aria-label": dragLabel(index + 1), className: sectionGripClass, children: _jsx(GripVertical, { "aria-hidden": true, size: sectionIconSize }) }), _jsx(Heading, { level: 3, className: sectionHeadingClass, children: _jsxs(AriaButton, { slot: "trigger", className: sectionTriggerClass, children: [_jsx(Chevron, { "aria-hidden": true, size: sectionIconSize, className: sectionChevronClass }), Icon && (_jsx("span", { className: sectionIconVariants({ tone }), children: _jsx(Icon, { "aria-hidden": true, size: sectionIconSize }) })), _jsxs("span", { className: sectionTextClass, children: [_jsx("span", { className: sectionTitleVariants({ tone }), children: title }), summary !== undefined && _jsx("span", { className: sectionSummaryClass, children: summary })
|
|
57
|
+
return (_jsxs("li", { ref: row, "data-section": id, ...dropProps, children: [landing === 'before' && _jsx("div", { className: sectionDropLineClass }), _jsxs(Disclosure, { className: sectionVariants({ state: problem !== undefined ? 'problem' : landing === 'here' ? 'target' : isDragging ? 'dragging' : 'default' }), isExpanded: isOpen, onExpandedChange: (next) => onOpenChange(id, next), children: [_jsxs("div", { className: sectionHeaderClass, ...dragProps, children: [_jsx(AriaButton, { ...dragButtonProps, "aria-label": dragLabel(index + 1), className: sectionGripClass, children: _jsx(GripVertical, { "aria-hidden": true, size: sectionIconSize }) }), _jsx(Heading, { level: 3, className: sectionHeadingClass, children: _jsxs(AriaButton, { slot: "trigger", className: sectionTriggerClass, children: [_jsx(Chevron, { "aria-hidden": true, size: sectionIconSize, className: sectionChevronClass }), Icon && (_jsx("span", { className: sectionIconVariants({ tone }), children: _jsx(Icon, { "aria-hidden": true, size: sectionIconSize }) })), _jsxs("span", { className: sectionTextClass, children: [_jsx("span", { className: sectionTitleVariants({ tone }), children: title }), (tag !== undefined || summary !== undefined) && (_jsxs("span", { className: sectionDetailClass, children: [summary !== undefined && _jsx("span", { className: sectionSummaryClass, children: summary }), tag !== undefined && _jsx(Tag, { children: tag })] }))] })] }) }), _jsxs("div", { className: sectionActionsClass, children: [_jsx(IconButton, { size: "sm", icon: ArrowUp, label: moveUpLabel(index + 1), isDisabled: index === 0, onPress: () => onMove(index, index - 1) }), _jsx(IconButton, { size: "sm", icon: ArrowDown, label: moveDownLabel(index + 1), isDisabled: index === ids.length - 1, onPress: () => onMove(index, index + 1) }), _jsx(Menu, { trigger: _jsx(IconButton, { size: "sm", icon: Ellipsis, label: moreLabel(index + 1) }), actions: actions, onAction: (action) => onAction(id, action) })] })] }), problem !== undefined && !isOpen && _jsx("p", { className: sectionProblemClass, children: problem }), _jsx(DisclosurePanel, { children: _jsx("div", { className: sectionPanelClass, children: content }) })] }), landing === 'after' && _jsx("div", { className: sectionDropLineClass })] }));
|
|
58
58
|
}
|
|
59
59
|
//# sourceMappingURL=SectionList.js.map
|