@monimesl/dot-renderer-react 1.0.0-beta.7 → 1.0.0-beta.9
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/dist/components/amount-input.js +1 -1
- package/dist/components/avatar.js +1 -1
- package/dist/components/box.js +8 -2
- package/dist/components/button.js +64 -14
- package/dist/components/carousel.js +65 -50
- package/dist/components/chip.js +3 -3
- package/dist/components/code-input.js +1 -1
- package/dist/components/detail-row.js +5 -5
- package/dist/components/disclosure.js +4 -4
- package/dist/components/empty-state.js +7 -6
- package/dist/components/feedback.js +7 -7
- package/dist/components/field-box.js +1 -1
- package/dist/components/field.js +5 -4
- package/dist/components/footer.js +6 -11
- package/dist/components/grid.js +20 -13
- package/dist/components/icon-button.js +1 -1
- package/dist/components/icon.js +32 -5
- package/dist/components/index.d.ts +2 -1
- package/dist/components/index.js +3 -1
- package/dist/components/input.js +1 -1
- package/dist/components/link.js +1 -1
- package/dist/components/list.js +11 -9
- package/dist/components/option.js +3 -3
- package/dist/components/padding.js +9 -10
- package/dist/components/pinned-bar.js +29 -0
- package/dist/components/pinned.d.ts +6 -0
- package/dist/components/pinned.js +26 -0
- package/dist/components/prose.js +23 -20
- package/dist/components/rich-text.js +30 -18
- package/dist/components/scroll.js +25 -8
- package/dist/components/select.js +1 -1
- package/dist/components/sheet.js +51 -45
- package/dist/components/side-room.js +5 -0
- package/dist/components/skeleton.js +1 -1
- package/dist/components/slider.js +3 -3
- package/dist/components/spinner.js +1 -1
- package/dist/components/stack.js +12 -8
- package/dist/components/stepper.js +3 -3
- package/dist/components/steps.js +17 -14
- package/dist/components/tabs.js +72 -26
- package/dist/components/text.js +12 -14
- package/dist/components/toast.js +3 -3
- package/dist/components/toggles.js +13 -9
- package/dist/components/tokens.d.ts +16 -0
- package/dist/components/tokens.js +20 -1
- package/dist/components/view.js +29 -15
- package/dist/index.d.ts +2 -1
- package/dist/index.js +2 -1
- package/dist/page-root.js +9 -3
- package/dist/pull-to-refresh.js +1 -1
- package/dist/root.js +4 -3
- package/dist/styles.css +1 -1
- package/dist/theme.d.ts +12 -1
- package/dist/theme.js +85 -15
- package/package.json +4 -4
package/dist/components/icon.js
CHANGED
|
@@ -1,24 +1,51 @@
|
|
|
1
|
-
import { useTheme } from "../theme.js";
|
|
2
1
|
import { ICON_SIZE } from "./tokens.js";
|
|
2
|
+
import { useTheme } from "../theme.js";
|
|
3
3
|
import { ICON_ARTWORK } from "./icon-artwork.js";
|
|
4
4
|
import { IconSvg } from "./icon-svg.js";
|
|
5
|
-
import {
|
|
5
|
+
import { textToneColor } from "./box.js";
|
|
6
6
|
import { jsx } from "react/jsx-runtime";
|
|
7
7
|
//#region src/components/icon.tsx
|
|
8
|
+
const ICON_PATH = /^statics\/(?!.*\.\.)[\w./-]+\.svg$/i;
|
|
9
|
+
const unknownIcons = /* @__PURE__ */ new Set();
|
|
8
10
|
function IconGraphic({ name, size, color }) {
|
|
9
|
-
|
|
11
|
+
const { icons } = useTheme();
|
|
12
|
+
if (Object.hasOwn(ICON_ARTWORK, name)) return /* @__PURE__ */ jsx(IconSvg, {
|
|
10
13
|
artwork: ICON_ARTWORK[name],
|
|
11
14
|
size,
|
|
12
15
|
color
|
|
13
16
|
});
|
|
17
|
+
const path = Object.hasOwn(icons, name) ? icons[name] : void 0;
|
|
18
|
+
if (path === void 0 || !ICON_PATH.test(path)) {
|
|
19
|
+
if (!unknownIcons.has(name)) {
|
|
20
|
+
unknownIcons.add(name);
|
|
21
|
+
console.warn(`The theme has no icon named "${name}". Add it to theme.icons in dot.ts.`);
|
|
22
|
+
}
|
|
23
|
+
return null;
|
|
24
|
+
}
|
|
25
|
+
const mask = `url("${path}") center / contain no-repeat`;
|
|
26
|
+
return /* @__PURE__ */ jsx("span", {
|
|
27
|
+
className: "dot-icon",
|
|
28
|
+
"aria-hidden": "true",
|
|
29
|
+
style: {
|
|
30
|
+
display: "inline-flex",
|
|
31
|
+
width: size,
|
|
32
|
+
height: size,
|
|
33
|
+
verticalAlign: "middle",
|
|
34
|
+
flexShrink: 0,
|
|
35
|
+
backgroundColor: color,
|
|
36
|
+
mask,
|
|
37
|
+
WebkitMask: mask
|
|
38
|
+
}
|
|
39
|
+
});
|
|
14
40
|
}
|
|
15
41
|
const Icon = ({ name, size = "medium", tone = "default" }) => {
|
|
16
|
-
const
|
|
42
|
+
const theme = useTheme();
|
|
17
43
|
if (!name) return null;
|
|
44
|
+
const color = textToneColor(tone, theme) ?? theme.colors.text;
|
|
18
45
|
return /* @__PURE__ */ jsx(IconGraphic, {
|
|
19
46
|
name,
|
|
20
47
|
size: ICON_SIZE[size],
|
|
21
|
-
color
|
|
48
|
+
color
|
|
22
49
|
});
|
|
23
50
|
};
|
|
24
51
|
//#endregion
|
|
@@ -17,6 +17,7 @@ import { Input } from "./input.js";
|
|
|
17
17
|
import { Link } from "./link.js";
|
|
18
18
|
import { List, ListItem } from "./list.js";
|
|
19
19
|
import { Option } from "./option.js";
|
|
20
|
+
import { Pinned } from "./pinned.js";
|
|
20
21
|
import { Bullet, BulletList, Prose, Quote } from "./prose.js";
|
|
21
22
|
import { QRCode } from "./qr-code.js";
|
|
22
23
|
import { RichText } from "./rich-text.js";
|
|
@@ -35,4 +36,4 @@ import { TextArea } from "./text-area.js";
|
|
|
35
36
|
import { Toast } from "./toast.js";
|
|
36
37
|
import { Checkbox, Radio, RadioGroup, Switch } from "./toggles.js";
|
|
37
38
|
import { View } from "./view.js";
|
|
38
|
-
export { AmountInput, Avatar, Badge, Bullet, BulletList, Button, Carousel, Checkbox, Chip, CodeInput, DetailRow, Disclosure, Divider, EmptyState, Footer, Grid, GridItem, Icon, Image, Input, Link, List, ListItem, Notice, Option, ProgressBar, Prose, QRCode, Quote, Radio, RadioGroup, RichText, Scroll, Select, Sheet, Skeleton, Slider, Spinner, Stack, Step, Stepper, Steps, Switch, Tab, Tabs, Text, TextArea, Toast, View };
|
|
39
|
+
export { AmountInput, Avatar, Badge, Bullet, BulletList, Button, Carousel, Checkbox, Chip, CodeInput, DetailRow, Disclosure, Divider, EmptyState, Footer, Grid, GridItem, Icon, Image, Input, Link, List, ListItem, Notice, Option, Pinned, ProgressBar, Prose, QRCode, Quote, Radio, RadioGroup, RichText, Scroll, Select, Sheet, Skeleton, Slider, Spinner, Stack, Step, Stepper, Steps, Switch, Tab, Tabs, Text, TextArea, Toast, View };
|
package/dist/components/index.js
CHANGED
|
@@ -19,6 +19,7 @@ import { Input } from "./input.js";
|
|
|
19
19
|
import { Link } from "./link.js";
|
|
20
20
|
import { List, ListItem } from "./list.js";
|
|
21
21
|
import { Option } from "./option.js";
|
|
22
|
+
import { Pinned } from "./pinned.js";
|
|
22
23
|
import { Bullet, BulletList, Prose, Quote } from "./prose.js";
|
|
23
24
|
import { QRCode } from "./qr-code.js";
|
|
24
25
|
import { Text } from "./text.js";
|
|
@@ -63,6 +64,7 @@ var components_exports = /* @__PURE__ */ __exportAll({
|
|
|
63
64
|
ListItem: () => ListItem,
|
|
64
65
|
Notice: () => Notice,
|
|
65
66
|
Option: () => Option,
|
|
67
|
+
Pinned: () => Pinned,
|
|
66
68
|
ProgressBar: () => ProgressBar,
|
|
67
69
|
Prose: () => Prose,
|
|
68
70
|
QRCode: () => QRCode,
|
|
@@ -89,4 +91,4 @@ var components_exports = /* @__PURE__ */ __exportAll({
|
|
|
89
91
|
View: () => View
|
|
90
92
|
});
|
|
91
93
|
//#endregion
|
|
92
|
-
export { AmountInput, Avatar, Badge, Bullet, BulletList, Button, Carousel, Checkbox, Chip, CodeInput, DetailRow, Disclosure, Divider, EmptyState, Footer, Grid, GridItem, Icon, Image, Input, Link, List, ListItem, Notice, Option, ProgressBar, Prose, QRCode, Quote, Radio, RadioGroup, RichText, Scroll, Select, Sheet, Skeleton, Slider, Spinner, Stack, Step, Stepper, Steps, Switch, Tab, Tabs, Text, TextArea, Toast, View, components_exports };
|
|
94
|
+
export { AmountInput, Avatar, Badge, Bullet, BulletList, Button, Carousel, Checkbox, Chip, CodeInput, DetailRow, Disclosure, Divider, EmptyState, Footer, Grid, GridItem, Icon, Image, Input, Link, List, ListItem, Notice, Option, Pinned, ProgressBar, Prose, QRCode, Quote, Radio, RadioGroup, RichText, Scroll, Select, Sheet, Skeleton, Slider, Spinner, Stack, Step, Stepper, Steps, Switch, Tab, Tabs, Text, TextArea, Toast, View, components_exports };
|
package/dist/components/input.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { useTheme } from "../theme.js";
|
|
2
1
|
import { ICON_SIZE, SPACE } from "./tokens.js";
|
|
2
|
+
import { useTheme } from "../theme.js";
|
|
3
3
|
import { Field } from "./field.js";
|
|
4
4
|
import { BARE_INPUT_STYLE, useFieldBox, useFieldNote } from "./field-box.js";
|
|
5
5
|
import { useTypedText } from "./typed-text.js";
|
package/dist/components/link.js
CHANGED
|
@@ -8,7 +8,7 @@ import { jsx } from "react/jsx-runtime";
|
|
|
8
8
|
const Link$1 = ({ href, tone, onTap, children }) => {
|
|
9
9
|
const { colors } = useTheme();
|
|
10
10
|
const style = {
|
|
11
|
-
color: tone ? toneColor(colors, tone) : colors.
|
|
11
|
+
color: tone ? toneColor(colors, tone) : colors.primaryText,
|
|
12
12
|
textDecorationLine: "underline",
|
|
13
13
|
textUnderlineOffset: "2px",
|
|
14
14
|
cursor: "pointer"
|
package/dist/components/list.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import { CARD_RADIUS_SCALE, CENTERED, ICON_SIZE, SHADOWS, WEIGHTS } from "./tokens.js";
|
|
1
2
|
import { useTheme } from "../theme.js";
|
|
2
|
-
import { CARD_RADIUS_SCALE, CENTERED, FONT_SIZE, ICON_SIZE, WEIGHTS } from "./tokens.js";
|
|
3
3
|
import { CHEVRON_RIGHT_ARTWORK } from "./icon-artwork.js";
|
|
4
4
|
import { IconSvg } from "./icon-svg.js";
|
|
5
5
|
import { insets, paddingStyle } from "./padding.js";
|
|
@@ -27,7 +27,8 @@ const ROW_SIZES = {
|
|
|
27
27
|
};
|
|
28
28
|
const ListSizeContext = createContext("sm");
|
|
29
29
|
const List$1 = ({ size = "sm", onEndReached, children, ...padding }) => {
|
|
30
|
-
const { colors, radius } = useTheme();
|
|
30
|
+
const { colors, radius, space, elevation, scheme } = useTheme();
|
|
31
|
+
const raised = elevation === "raised";
|
|
31
32
|
const listRef = useRef(null);
|
|
32
33
|
const lastRowReached = useRef(null);
|
|
33
34
|
useEffect(() => {
|
|
@@ -43,7 +44,7 @@ const List$1 = ({ size = "sm", onEndReached, children, ...padding }) => {
|
|
|
43
44
|
return () => observer.disconnect();
|
|
44
45
|
});
|
|
45
46
|
return /* @__PURE__ */ jsx(ListSizeContext.Provider, {
|
|
46
|
-
value: size,
|
|
47
|
+
value: Object.hasOwn(ROW_SIZES, size) ? size : "sm",
|
|
47
48
|
children: /* @__PURE__ */ jsx("ul", {
|
|
48
49
|
ref: listRef,
|
|
49
50
|
className: "dot-list",
|
|
@@ -51,11 +52,12 @@ const List$1 = ({ size = "sm", onEndReached, children, ...padding }) => {
|
|
|
51
52
|
display: "flex",
|
|
52
53
|
flexDirection: "column",
|
|
53
54
|
margin: 0,
|
|
54
|
-
...paddingStyle(padding),
|
|
55
|
+
...paddingStyle(padding, space),
|
|
55
56
|
overflow: "hidden",
|
|
56
57
|
listStyle: "none",
|
|
57
58
|
borderRadius: radius * CARD_RADIUS_SCALE,
|
|
58
|
-
border: `1px solid ${colors.border}`,
|
|
59
|
+
border: raised ? "none" : `1px solid ${colors.border}`,
|
|
60
|
+
boxShadow: raised ? SHADOWS[scheme].low : void 0,
|
|
59
61
|
background: colors.surface,
|
|
60
62
|
"--dot-list-divider": colors.border
|
|
61
63
|
},
|
|
@@ -64,7 +66,7 @@ const List$1 = ({ size = "sm", onEndReached, children, ...padding }) => {
|
|
|
64
66
|
});
|
|
65
67
|
};
|
|
66
68
|
const ListItem$1 = ({ title, subtitle, value, icon, image, onTap, children, ...padding }) => {
|
|
67
|
-
const { colors, radius } = useTheme();
|
|
69
|
+
const { colors, radius, space, fontSize } = useTheme();
|
|
68
70
|
const rowSize = ROW_SIZES[useContext(ListSizeContext)];
|
|
69
71
|
let leading = null;
|
|
70
72
|
if (image) leading = /* @__PURE__ */ jsx("img", {
|
|
@@ -112,7 +114,7 @@ const ListItem$1 = ({ title, subtitle, value, icon, image, onTap, children, ...p
|
|
|
112
114
|
children: title
|
|
113
115
|
}) : null, subtitle ? /* @__PURE__ */ jsx("span", {
|
|
114
116
|
style: {
|
|
115
|
-
fontSize:
|
|
117
|
+
fontSize: fontSize.caption,
|
|
116
118
|
lineHeight: "normal",
|
|
117
119
|
color: colors.subtle
|
|
118
120
|
},
|
|
@@ -138,11 +140,11 @@ const ListItem$1 = ({ title, subtitle, value, icon, image, onTap, children, ...p
|
|
|
138
140
|
display: "flex",
|
|
139
141
|
alignItems: "center",
|
|
140
142
|
gap: rowSize.gap,
|
|
141
|
-
...paddingStyle(padding, insets(rowSize.block, 16)),
|
|
143
|
+
...paddingStyle(padding, space, insets(rowSize.block, 16)),
|
|
142
144
|
width: "100%",
|
|
143
145
|
background: colors.surface,
|
|
144
146
|
color: colors.text,
|
|
145
|
-
fontSize:
|
|
147
|
+
fontSize: fontSize.body,
|
|
146
148
|
textAlign: "start"
|
|
147
149
|
};
|
|
148
150
|
return /* @__PURE__ */ jsx("li", {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import { ICON_SIZE, WEIGHTS } from "./tokens.js";
|
|
1
2
|
import { useTheme } from "../theme.js";
|
|
2
|
-
import { FONT_SIZE, ICON_SIZE, WEIGHTS } from "./tokens.js";
|
|
3
3
|
import { CHECK_ARTWORK } from "./icon-artwork.js";
|
|
4
4
|
import { IconSvg } from "./icon-svg.js";
|
|
5
5
|
import { OptionPlaceContext } from "./option-place.js";
|
|
@@ -7,7 +7,7 @@ import { useContext } from "react";
|
|
|
7
7
|
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
8
8
|
//#region src/components/option.tsx
|
|
9
9
|
const Option = ({ value, label }) => {
|
|
10
|
-
const { colors } = useTheme();
|
|
10
|
+
const { colors, fontSize } = useTheme();
|
|
11
11
|
const place = useContext(OptionPlaceContext);
|
|
12
12
|
const chosen = value !== void 0 && value === place.value;
|
|
13
13
|
if (place.inField) return chosen ? /* @__PURE__ */ jsx(Fragment$1, { children: label }) : null;
|
|
@@ -28,7 +28,7 @@ const Option = ({ value, label }) => {
|
|
|
28
28
|
borderBottom: `1px solid ${colors.border}`,
|
|
29
29
|
background: "transparent",
|
|
30
30
|
color: colors.text,
|
|
31
|
-
fontSize:
|
|
31
|
+
fontSize: fontSize.body,
|
|
32
32
|
fontWeight: chosen ? WEIGHTS.bold : WEIGHTS.regular,
|
|
33
33
|
textAlign: "start",
|
|
34
34
|
cursor: "pointer"
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { SPACE } from "./tokens.js";
|
|
2
1
|
//#region src/components/padding.ts
|
|
3
2
|
const NO_INSETS = {
|
|
4
3
|
top: 0,
|
|
@@ -14,21 +13,21 @@ function insets(block, inline = block) {
|
|
|
14
13
|
bottom: block
|
|
15
14
|
};
|
|
16
15
|
}
|
|
17
|
-
function paddingStyle(props, ownInsets = NO_INSETS) {
|
|
16
|
+
function paddingStyle(props, space, ownInsets = NO_INSETS) {
|
|
18
17
|
return {
|
|
19
|
-
paddingTop: sidePadding(props.paddingTop ?? props.padding, ownInsets.top),
|
|
20
|
-
paddingInlineStart: sidePadding(props.paddingStart ?? props.padding, ownInsets.start),
|
|
21
|
-
paddingInlineEnd: sidePadding(props.paddingEnd ?? props.padding, ownInsets.end),
|
|
22
|
-
paddingBottom: sidePadding(props.paddingBottom ?? props.padding, ownInsets.bottom)
|
|
18
|
+
paddingTop: sidePadding(props.paddingTop ?? props.padding, space, ownInsets.top),
|
|
19
|
+
paddingInlineStart: sidePadding(props.paddingStart ?? props.padding, space, ownInsets.start),
|
|
20
|
+
paddingInlineEnd: sidePadding(props.paddingEnd ?? props.padding, space, ownInsets.end),
|
|
21
|
+
paddingBottom: sidePadding(props.paddingBottom ?? props.padding, space, ownInsets.bottom)
|
|
23
22
|
};
|
|
24
23
|
}
|
|
25
|
-
function sidePadding(pageSpace, ownPixels) {
|
|
24
|
+
function sidePadding(pageSpace, space, ownPixels) {
|
|
26
25
|
if (pageSpace === void 0) return ownPixels;
|
|
27
|
-
return
|
|
26
|
+
return space[pageSpace];
|
|
28
27
|
}
|
|
29
28
|
const HOME_INDICATOR = "env(safe-area-inset-bottom, 0px)";
|
|
30
|
-
function pinnedPaddingStyle(props, ownInsets) {
|
|
31
|
-
const style = paddingStyle(props, ownInsets);
|
|
29
|
+
function pinnedPaddingStyle(props, space, ownInsets) {
|
|
30
|
+
const style = paddingStyle(props, space, ownInsets);
|
|
32
31
|
return {
|
|
33
32
|
...style,
|
|
34
33
|
paddingBottom: `calc(${style.paddingBottom}px + ${HOME_INDICATOR})`
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { insets, paddingStyle, pinnedPaddingStyle } from "./padding.js";
|
|
2
|
+
//#region src/components/pinned-bar.ts
|
|
3
|
+
const STATUS_BAR = "env(safe-area-inset-top, 0px)";
|
|
4
|
+
function pinnedBarStyle(edge, padding, space, ownInsets = insets(0)) {
|
|
5
|
+
let edgeStyle;
|
|
6
|
+
if (edge === "top") edgeStyle = {
|
|
7
|
+
...paddingStyle(padding, space, ownInsets),
|
|
8
|
+
top: STATUS_BAR
|
|
9
|
+
};
|
|
10
|
+
else edgeStyle = {
|
|
11
|
+
...pinnedPaddingStyle(padding, space, ownInsets),
|
|
12
|
+
bottom: 0,
|
|
13
|
+
marginTop: "auto"
|
|
14
|
+
};
|
|
15
|
+
return {
|
|
16
|
+
...edgeStyle,
|
|
17
|
+
position: "sticky",
|
|
18
|
+
zIndex: 1,
|
|
19
|
+
display: "flex",
|
|
20
|
+
flexDirection: "column",
|
|
21
|
+
alignSelf: "stretch",
|
|
22
|
+
marginInlineStart: "calc(-1 * var(--dot-view-start, 0px))",
|
|
23
|
+
marginInlineEnd: "calc(-1 * var(--dot-view-end, 0px))",
|
|
24
|
+
paddingInlineStart: `calc(var(--dot-view-start, 0px) + ${edgeStyle.paddingInlineStart}px)`,
|
|
25
|
+
paddingInlineEnd: `calc(var(--dot-view-end, 0px) + ${edgeStyle.paddingInlineEnd}px)`
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
//#endregion
|
|
29
|
+
export { pinnedBarStyle };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { useTheme } from "../theme.js";
|
|
2
|
+
import { backgroundColor } from "./box.js";
|
|
3
|
+
import { pinnedBarStyle } from "./pinned-bar.js";
|
|
4
|
+
import { jsx } from "react/jsx-runtime";
|
|
5
|
+
//#region src/components/pinned.tsx
|
|
6
|
+
const Pinned = ({ edge = "top", gap = "medium", background = "background", border = "none", children, ...padding }) => {
|
|
7
|
+
const theme = useTheme();
|
|
8
|
+
const { colors, space } = theme;
|
|
9
|
+
const style = {
|
|
10
|
+
...pinnedBarStyle(edge, padding, space),
|
|
11
|
+
gap: space[gap],
|
|
12
|
+
background: backgroundColor(background, theme)
|
|
13
|
+
};
|
|
14
|
+
if (border !== "none") {
|
|
15
|
+
const line = `1px solid ${border === "strong" ? colors.subtle : colors.border}`;
|
|
16
|
+
if (edge === "top") style.borderBottom = line;
|
|
17
|
+
else style.borderTop = line;
|
|
18
|
+
}
|
|
19
|
+
return /* @__PURE__ */ jsx("div", {
|
|
20
|
+
className: `dot-pinned dot-bar-${edge}`,
|
|
21
|
+
style,
|
|
22
|
+
children
|
|
23
|
+
});
|
|
24
|
+
};
|
|
25
|
+
//#endregion
|
|
26
|
+
export { Pinned };
|
package/dist/components/prose.js
CHANGED
|
@@ -1,29 +1,32 @@
|
|
|
1
|
+
import { SELECTABLE } from "./tokens.js";
|
|
1
2
|
import { useTheme } from "../theme.js";
|
|
2
|
-
import { FONT_SIZE, SELECTABLE } from "./tokens.js";
|
|
3
3
|
import { paddingStyle } from "./padding.js";
|
|
4
4
|
import { InsideProse } from "./prose-context.js";
|
|
5
5
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
6
6
|
//#region src/components/prose.tsx
|
|
7
7
|
const READING_WIDTH = 680;
|
|
8
|
-
const Prose = ({ children, ...padding }) =>
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
children
|
|
23
|
-
|
|
24
|
-
|
|
8
|
+
const Prose = ({ children, ...padding }) => {
|
|
9
|
+
const { space } = useTheme();
|
|
10
|
+
return /* @__PURE__ */ jsx("div", {
|
|
11
|
+
className: "dot-prose",
|
|
12
|
+
style: {
|
|
13
|
+
display: "flex",
|
|
14
|
+
flexDirection: "column",
|
|
15
|
+
gap: 12,
|
|
16
|
+
width: "100%",
|
|
17
|
+
maxWidth: READING_WIDTH,
|
|
18
|
+
marginInline: "auto",
|
|
19
|
+
...SELECTABLE,
|
|
20
|
+
...paddingStyle(padding, space)
|
|
21
|
+
},
|
|
22
|
+
children: /* @__PURE__ */ jsx(InsideProse.Provider, {
|
|
23
|
+
value: true,
|
|
24
|
+
children
|
|
25
|
+
})
|
|
26
|
+
});
|
|
27
|
+
};
|
|
25
28
|
const Quote = ({ cite, children }) => {
|
|
26
|
-
const { colors } = useTheme();
|
|
29
|
+
const { colors, fontSize } = useTheme();
|
|
27
30
|
return /* @__PURE__ */ jsxs("blockquote", {
|
|
28
31
|
className: "dot-quote",
|
|
29
32
|
style: {
|
|
@@ -37,7 +40,7 @@ const Quote = ({ cite, children }) => {
|
|
|
37
40
|
},
|
|
38
41
|
children: [children, cite && /* @__PURE__ */ jsxs("span", {
|
|
39
42
|
style: {
|
|
40
|
-
fontSize:
|
|
43
|
+
fontSize: fontSize.caption,
|
|
41
44
|
fontStyle: "normal",
|
|
42
45
|
color: colors.subtle
|
|
43
46
|
},
|
|
@@ -1,55 +1,67 @@
|
|
|
1
1
|
import { useTheme } from "../theme.js";
|
|
2
|
-
import { Divider } from "./divider.js";
|
|
3
|
-
import { Image } from "./image.js";
|
|
2
|
+
import { Divider as Divider$1 } from "./divider.js";
|
|
3
|
+
import { Image as Image$2 } from "./image.js";
|
|
4
4
|
import { isHttps } from "./https.js";
|
|
5
|
-
import { Link } from "./link.js";
|
|
6
|
-
import { Bullet, BulletList, Prose, Quote } from "./prose.js";
|
|
5
|
+
import { Link as Link$2 } from "./link.js";
|
|
6
|
+
import { Bullet as Bullet$1, BulletList as BulletList$1, Prose as Prose$2, Quote as Quote$1 } from "./prose.js";
|
|
7
7
|
import { parseMarkdown } from "../markdown.js";
|
|
8
|
-
import { Text } from "./text.js";
|
|
8
|
+
import { Text as Text$2 } from "./text.js";
|
|
9
|
+
import { withComponentDefaults } from "@monimesl/dot-core";
|
|
9
10
|
import { useMemo } from "react";
|
|
10
11
|
import { jsx } from "react/jsx-runtime";
|
|
11
12
|
//#region src/components/rich-text.tsx
|
|
13
|
+
function themed(name, Component) {
|
|
14
|
+
return function Themed(props) {
|
|
15
|
+
const { components } = useTheme();
|
|
16
|
+
const merged = withComponentDefaults(name, props, components);
|
|
17
|
+
return /* @__PURE__ */ jsx(Component, { ...merged });
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
const Image$1 = themed("Image", Image$2);
|
|
21
|
+
const Link$1 = themed("Link", Link$2);
|
|
22
|
+
const Prose$1 = themed("Prose", Prose$2);
|
|
23
|
+
const Text$1 = themed("Text", Text$2);
|
|
12
24
|
const HEADING_TEXT = {
|
|
13
25
|
1: { variant: "title" },
|
|
14
26
|
2: { variant: "subtitle" },
|
|
15
27
|
3: { weight: "bold" }
|
|
16
28
|
};
|
|
17
|
-
const RichText = ({ markdown }) => {
|
|
29
|
+
const RichText$1 = ({ markdown }) => {
|
|
18
30
|
const blocks = useMemo(() => parseMarkdown(markdown ?? ""), [markdown]);
|
|
19
|
-
return /* @__PURE__ */ jsx(Prose, { children: blocks.map(renderBlock) });
|
|
31
|
+
return /* @__PURE__ */ jsx(Prose$1, { children: blocks.map(renderBlock) });
|
|
20
32
|
};
|
|
21
33
|
function renderBlock(block, key) {
|
|
22
34
|
switch (block.kind) {
|
|
23
|
-
case "heading": return /* @__PURE__ */ jsx(Text, {
|
|
35
|
+
case "heading": return /* @__PURE__ */ jsx(Text$1, {
|
|
24
36
|
...HEADING_TEXT[block.level],
|
|
25
37
|
children: block.content.map(renderInline)
|
|
26
38
|
}, key);
|
|
27
|
-
case "paragraph": return /* @__PURE__ */ jsx(Text, { children: block.content.map(renderInline) }, key);
|
|
28
|
-
case "list": return /* @__PURE__ */ jsx(BulletList, {
|
|
39
|
+
case "paragraph": return /* @__PURE__ */ jsx(Text$1, { children: block.content.map(renderInline) }, key);
|
|
40
|
+
case "list": return /* @__PURE__ */ jsx(BulletList$1, {
|
|
29
41
|
ordered: block.ordered,
|
|
30
|
-
children: block.items.map((item, itemKey) => /* @__PURE__ */ jsx(Bullet, { children: item.map(renderBlock) }, itemKey))
|
|
42
|
+
children: block.items.map((item, itemKey) => /* @__PURE__ */ jsx(Bullet$1, { children: item.map(renderBlock) }, itemKey))
|
|
31
43
|
}, key);
|
|
32
|
-
case "quote": return /* @__PURE__ */ jsx(Quote, { children: block.blocks.map(renderBlock) }, key);
|
|
33
|
-
case "image": return /* @__PURE__ */ jsx(Image, {
|
|
44
|
+
case "quote": return /* @__PURE__ */ jsx(Quote$1, { children: block.blocks.map(renderBlock) }, key);
|
|
45
|
+
case "image": return /* @__PURE__ */ jsx(Image$1, {
|
|
34
46
|
src: block.src,
|
|
35
47
|
alt: block.alt
|
|
36
48
|
}, key);
|
|
37
|
-
case "rule": return /* @__PURE__ */ jsx(Divider, {}, key);
|
|
49
|
+
case "rule": return /* @__PURE__ */ jsx(Divider$1, {}, key);
|
|
38
50
|
}
|
|
39
51
|
}
|
|
40
52
|
function renderInline(inline, key) {
|
|
41
53
|
switch (inline.kind) {
|
|
42
54
|
case "text": return inline.text;
|
|
43
|
-
case "strong": return /* @__PURE__ */ jsx(Text, {
|
|
55
|
+
case "strong": return /* @__PURE__ */ jsx(Text$1, {
|
|
44
56
|
weight: "bold",
|
|
45
57
|
children: inline.children.map(renderInline)
|
|
46
58
|
}, key);
|
|
47
|
-
case "emphasis": return /* @__PURE__ */ jsx(Text, {
|
|
59
|
+
case "emphasis": return /* @__PURE__ */ jsx(Text$1, {
|
|
48
60
|
italic: true,
|
|
49
61
|
children: inline.children.map(renderInline)
|
|
50
62
|
}, key);
|
|
51
63
|
case "code": return /* @__PURE__ */ jsx(Code, { text: inline.text }, key);
|
|
52
|
-
case "link": return isHttps(inline.href) ? /* @__PURE__ */ jsx(Link, {
|
|
64
|
+
case "link": return isHttps(inline.href) ? /* @__PURE__ */ jsx(Link$1, {
|
|
53
65
|
href: inline.href,
|
|
54
66
|
children: inline.children.map(renderInline)
|
|
55
67
|
}, key) : inline.children.map(renderInline);
|
|
@@ -70,4 +82,4 @@ function Code({ text }) {
|
|
|
70
82
|
});
|
|
71
83
|
}
|
|
72
84
|
//#endregion
|
|
73
|
-
export { RichText };
|
|
85
|
+
export { RichText$1 as RichText };
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { SCROLL_SHADOW_ROOM, SHADOW_REACH } from "./tokens.js";
|
|
2
|
+
import { useTheme } from "../theme.js";
|
|
2
3
|
import { paddingStyle } from "./padding.js";
|
|
4
|
+
import { SideRoomContext } from "./side-room.js";
|
|
3
5
|
import { createEvent } from "@monimesl/dot-core";
|
|
4
|
-
import { useEffect, useRef } from "react";
|
|
6
|
+
import { useContext, useEffect, useRef } from "react";
|
|
5
7
|
import { jsx } from "react/jsx-runtime";
|
|
6
8
|
//#region src/components/scroll.tsx
|
|
7
9
|
const REST_DELAY_MS = 120;
|
|
@@ -9,8 +11,11 @@ const Scroll$1 = ({ gap = "medium", snap = "none", index, onChange, children, ..
|
|
|
9
11
|
const rowRef = useRef(null);
|
|
10
12
|
const reportedIndex = useRef(void 0);
|
|
11
13
|
const restTimer = useRef(void 0);
|
|
12
|
-
const
|
|
13
|
-
const
|
|
14
|
+
const { space, elevation } = useTheme();
|
|
15
|
+
const paddingCss = paddingStyle(padding, space);
|
|
16
|
+
const sideRoom = useContext(SideRoomContext) && elevation === "raised" ? SHADOW_REACH.sides : 0;
|
|
17
|
+
const startPadding = Number(paddingCss.paddingInlineStart) + sideRoom;
|
|
18
|
+
const endPadding = Number(paddingCss.paddingInlineEnd) + sideRoom;
|
|
14
19
|
useEffect(() => {
|
|
15
20
|
const element = rowRef.current;
|
|
16
21
|
if (index === void 0 || index === reportedIndex.current || !element) return;
|
|
@@ -43,10 +48,22 @@ const Scroll$1 = ({ gap = "medium", snap = "none", index, onChange, children, ..
|
|
|
43
48
|
}, REST_DELAY_MS);
|
|
44
49
|
} : void 0,
|
|
45
50
|
style: {
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
51
|
+
position: "relative",
|
|
52
|
+
display: "flex",
|
|
53
|
+
overflowX: "auto",
|
|
54
|
+
overflowY: "hidden",
|
|
55
|
+
overscrollBehaviorX: "contain",
|
|
56
|
+
scrollbarWidth: "none",
|
|
57
|
+
gap: space[gap],
|
|
58
|
+
paddingTop: Number(paddingCss.paddingTop) + SCROLL_SHADOW_ROOM.top,
|
|
59
|
+
paddingBottom: Number(paddingCss.paddingBottom) + SCROLL_SHADOW_ROOM.bottom,
|
|
60
|
+
paddingInlineStart: startPadding,
|
|
61
|
+
paddingInlineEnd: endPadding,
|
|
62
|
+
marginTop: -SCROLL_SHADOW_ROOM.top,
|
|
63
|
+
marginBottom: -SCROLL_SHADOW_ROOM.bottom,
|
|
64
|
+
marginInline: -sideRoom,
|
|
65
|
+
scrollPaddingInlineStart: startPadding,
|
|
66
|
+
scrollPaddingInlineEnd: endPadding,
|
|
50
67
|
scrollSnapType: snap === "none" ? void 0 : "x mandatory",
|
|
51
68
|
"--dot-scroll-snap": snap === "none" ? "none" : snap
|
|
52
69
|
},
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { useTheme } from "../theme.js";
|
|
2
1
|
import { ICON_SIZE, SPACE } from "./tokens.js";
|
|
2
|
+
import { useTheme } from "../theme.js";
|
|
3
3
|
import { Field } from "./field.js";
|
|
4
4
|
import { useFieldBox, useFieldNote } from "./field-box.js";
|
|
5
5
|
import { CHEVRON_DOWN_ARTWORK } from "./icon-artwork.js";
|
package/dist/components/sheet.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { CARD_RADIUS_SCALE, ICON_SIZE, SPACE, WEIGHTS } from "./tokens.js";
|
|
2
|
+
import { useTheme } from "../theme.js";
|
|
3
3
|
import { CLOSE_ARTWORK } from "./icon-artwork.js";
|
|
4
4
|
import { IconSvg } from "./icon-svg.js";
|
|
5
5
|
import { pinnedPaddingStyle } from "./padding.js";
|
|
@@ -14,7 +14,7 @@ import { createEvent } from "@monimesl/dot-core";
|
|
|
14
14
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
15
15
|
//#region src/components/sheet.tsx
|
|
16
16
|
const SheetPanel = ({ open, title, showCloseIcon = false, onClose, children, ...padding }) => {
|
|
17
|
-
const { colors, radius } = useTheme();
|
|
17
|
+
const { colors, radius, fontFamily, space, fontSize, headingFontFamily, headingWeight } = useTheme();
|
|
18
18
|
const container = usePortalContainer();
|
|
19
19
|
const cornerRadius = radius * CARD_RADIUS_SCALE;
|
|
20
20
|
return /* @__PURE__ */ jsx(DialogRoot, {
|
|
@@ -32,7 +32,7 @@ const SheetPanel = ({ open, title, showCloseIcon = false, onClose, children, ...
|
|
|
32
32
|
zIndex: 100,
|
|
33
33
|
background: "rgba(0, 0, 0, 0.4)"
|
|
34
34
|
}
|
|
35
|
-
}), /* @__PURE__ */
|
|
35
|
+
}), /* @__PURE__ */ jsx(DialogPopup, {
|
|
36
36
|
className: "dot-sheet",
|
|
37
37
|
"aria-label": title,
|
|
38
38
|
style: {
|
|
@@ -40,56 +40,62 @@ const SheetPanel = ({ open, title, showCloseIcon = false, onClose, children, ...
|
|
|
40
40
|
insetInline: 0,
|
|
41
41
|
bottom: 0,
|
|
42
42
|
zIndex: 101,
|
|
43
|
-
display: "flex",
|
|
44
|
-
flexDirection: "column",
|
|
45
|
-
gap: SPACE.medium,
|
|
46
43
|
maxHeight: "85vh",
|
|
47
44
|
overflowY: "auto",
|
|
48
|
-
...pinnedPaddingStyle(padding, {
|
|
49
|
-
top: 16,
|
|
50
|
-
start: 16,
|
|
51
|
-
end: 16,
|
|
52
|
-
bottom: 24
|
|
53
|
-
}),
|
|
54
45
|
borderTopLeftRadius: cornerRadius,
|
|
55
46
|
borderTopRightRadius: cornerRadius,
|
|
56
47
|
background: colors.surface,
|
|
57
48
|
color: colors.text,
|
|
58
|
-
fontFamily
|
|
49
|
+
fontFamily,
|
|
59
50
|
outline: "none"
|
|
60
51
|
},
|
|
61
|
-
children:
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
showCloseIcon ? /* @__PURE__ */ jsx(DialogClose, {
|
|
73
|
-
"aria-label": "Close",
|
|
74
|
-
style: {
|
|
75
|
-
position: "absolute",
|
|
76
|
-
top: 10,
|
|
77
|
-
insetInlineEnd: 10,
|
|
78
|
-
display: "flex",
|
|
79
|
-
padding: 4,
|
|
80
|
-
border: "none",
|
|
81
|
-
borderRadius: "50%",
|
|
82
|
-
background: "transparent",
|
|
83
|
-
cursor: "pointer"
|
|
84
|
-
},
|
|
85
|
-
children: /* @__PURE__ */ jsx(IconSvg, {
|
|
86
|
-
artwork: CLOSE_ARTWORK,
|
|
87
|
-
size: ICON_SIZE.medium,
|
|
88
|
-
color: colors.subtle
|
|
52
|
+
children: /* @__PURE__ */ jsxs("div", {
|
|
53
|
+
style: {
|
|
54
|
+
display: "flex",
|
|
55
|
+
flexDirection: "column",
|
|
56
|
+
gap: SPACE.medium,
|
|
57
|
+
overflow: "clip",
|
|
58
|
+
...pinnedPaddingStyle(padding, space, {
|
|
59
|
+
top: 16,
|
|
60
|
+
start: 16,
|
|
61
|
+
end: 16,
|
|
62
|
+
bottom: 24
|
|
89
63
|
})
|
|
90
|
-
}
|
|
91
|
-
children
|
|
92
|
-
|
|
64
|
+
},
|
|
65
|
+
children: [
|
|
66
|
+
title ? /* @__PURE__ */ jsx(DialogTitle, {
|
|
67
|
+
style: {
|
|
68
|
+
margin: 0,
|
|
69
|
+
fontSize: fontSize.body,
|
|
70
|
+
fontFamily: headingFontFamily,
|
|
71
|
+
fontWeight: WEIGHTS[headingWeight ?? "bold"],
|
|
72
|
+
lineHeight: "normal",
|
|
73
|
+
textAlign: "center"
|
|
74
|
+
},
|
|
75
|
+
children: title
|
|
76
|
+
}) : null,
|
|
77
|
+
showCloseIcon ? /* @__PURE__ */ jsx(DialogClose, {
|
|
78
|
+
"aria-label": "Close",
|
|
79
|
+
style: {
|
|
80
|
+
position: "absolute",
|
|
81
|
+
top: 10,
|
|
82
|
+
insetInlineEnd: 10,
|
|
83
|
+
display: "flex",
|
|
84
|
+
padding: 4,
|
|
85
|
+
border: "none",
|
|
86
|
+
borderRadius: "50%",
|
|
87
|
+
background: "transparent",
|
|
88
|
+
cursor: "pointer"
|
|
89
|
+
},
|
|
90
|
+
children: /* @__PURE__ */ jsx(IconSvg, {
|
|
91
|
+
artwork: CLOSE_ARTWORK,
|
|
92
|
+
size: ICON_SIZE.medium,
|
|
93
|
+
color: colors.subtle
|
|
94
|
+
})
|
|
95
|
+
}) : null,
|
|
96
|
+
children
|
|
97
|
+
]
|
|
98
|
+
})
|
|
93
99
|
})]
|
|
94
100
|
})
|
|
95
101
|
});
|