tintora 1.1.0 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +16 -0
- package/dist/Alert/Alert2.cjs +1 -0
- package/dist/Alert/Alert2.js +73 -0
- package/dist/Avatar/Avatar2.cjs +1 -0
- package/dist/Avatar/Avatar2.js +23 -0
- package/dist/Avatar/utils.cjs +1 -0
- package/dist/Avatar/utils.js +8 -0
- package/dist/BottomSheet/BottomSheet2.cjs +1 -0
- package/dist/BottomSheet/BottomSheet2.js +51 -0
- package/dist/Button/Button2.cjs +1 -0
- package/dist/Button/Button2.js +42 -0
- package/dist/Card/Card2.cjs +1 -0
- package/dist/Card/Card2.js +20 -0
- package/dist/Checkbox/Checkbox2.cjs +1 -0
- package/dist/Checkbox/Checkbox2.js +52 -0
- package/dist/Chip/Chip2.cjs +1 -0
- package/dist/Chip/Chip2.js +15 -0
- package/dist/Dot/Dot2.cjs +1 -0
- package/dist/Dot/Dot2.js +15 -0
- package/dist/Drawer/Drawer2.cjs +1 -0
- package/dist/Drawer/Drawer2.js +33 -0
- package/dist/IconButton/IconButton2.cjs +1 -0
- package/dist/IconButton/IconButton2.js +27 -0
- package/dist/Link/Link.d.ts +23 -0
- package/dist/Link/Link2.cjs +1 -0
- package/dist/Link/Link2.js +12 -0
- package/dist/Modal/Modal2.cjs +1 -0
- package/dist/Modal/Modal2.js +71 -0
- package/dist/Popover/Popover2.cjs +1 -0
- package/dist/Popover/Popover2.js +70 -0
- package/dist/ProgressBar/ProgressBar2.cjs +1 -0
- package/dist/ProgressBar/ProgressBar2.js +40 -0
- package/dist/Radio/Radio2.cjs +1 -0
- package/dist/Radio/Radio2.js +27 -0
- package/dist/Radio/RadioContext.cjs +1 -0
- package/dist/Radio/RadioContext.js +11 -0
- package/dist/Radio/RadioGroup.cjs +1 -0
- package/dist/Radio/RadioGroup.js +26 -0
- package/dist/SearchInput/SearchInput2.cjs +1 -0
- package/dist/SearchInput/SearchInput2.js +30 -0
- package/dist/Select/Select2.cjs +1 -0
- package/dist/Select/Select2.js +128 -0
- package/dist/Select/SelectContext.cjs +1 -0
- package/dist/Select/SelectContext.js +10 -0
- package/dist/Select/SelectOption.cjs +1 -0
- package/dist/Select/SelectOption.js +20 -0
- package/dist/SettingsRow/SettingsRow2.cjs +1 -0
- package/dist/SettingsRow/SettingsRow2.js +22 -0
- package/dist/Skeleton/Skeleton2.cjs +1 -0
- package/dist/Skeleton/Skeleton2.js +21 -0
- package/dist/Spinner/Spinner2.cjs +1 -0
- package/dist/Spinner/Spinner2.js +47 -0
- package/dist/Switch/Switch2.cjs +1 -0
- package/dist/Switch/Switch2.js +29 -0
- package/dist/Tabs/Tab.cjs +1 -0
- package/dist/Tabs/Tab.js +22 -0
- package/dist/Tabs/Tabs2.cjs +1 -0
- package/dist/Tabs/Tabs2.js +40 -0
- package/dist/Tabs/TabsContext.cjs +1 -0
- package/dist/Tabs/TabsContext.js +11 -0
- package/dist/Tag/Tag2.cjs +1 -0
- package/dist/Tag/Tag2.js +13 -0
- package/dist/TextField/TextField2.cjs +1 -0
- package/dist/TextField/TextField2.js +34 -0
- package/dist/Toast/Toast2.cjs +1 -0
- package/dist/Toast/Toast2.js +74 -0
- package/dist/Toast/ToastIcons.cjs +1 -0
- package/dist/Toast/ToastIcons.js +77 -0
- package/dist/Toggle/Toggle2.cjs +1 -0
- package/dist/Toggle/Toggle2.js +57 -0
- package/dist/Toggle/ToggleContext.cjs +1 -0
- package/dist/Toggle/ToggleContext.js +11 -0
- package/dist/Toggle/ToggleItem.cjs +1 -0
- package/dist/Toggle/ToggleItem.js +21 -0
- package/dist/Tooltip/Tooltip2.cjs +1 -0
- package/dist/Tooltip/Tooltip2.js +66 -0
- package/dist/hooks/useCheckedState.cjs +1 -0
- package/dist/hooks/useCheckedState.js +13 -0
- package/dist/hooks/useEscapeKey.cjs +1 -0
- package/dist/hooks/useEscapeKey.js +15 -0
- package/dist/hooks/useLatest.cjs +1 -0
- package/dist/hooks/useLatest.js +10 -0
- package/dist/hooks/useOutsidePress.cjs +1 -0
- package/dist/hooks/useOutsidePress.js +19 -0
- package/dist/hooks/useTopLayerPosition.cjs +1 -0
- package/dist/hooks/useTopLayerPosition.js +25 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +32 -1294
- package/dist/tintora.css +1 -1
- package/dist/utils/clsx.cjs +1 -0
- package/dist/utils/clsx.d.ts +9 -0
- package/dist/utils/clsx.js +6 -0
- package/dist/utils/outside.cjs +1 -0
- package/dist/utils/outside.js +8 -0
- package/dist/utils/placement.cjs +1 -0
- package/dist/utils/placement.js +53 -0
- package/package.json +5 -4
package/README.md
CHANGED
|
@@ -68,6 +68,21 @@ Tintora is dark by default and follows the OS preference. Force a theme with `da
|
|
|
68
68
|
|
|
69
69
|
Colours, radii, type and shadows are CSS custom properties prefixed `--tintora-`, so you can override them in your own CSS.
|
|
70
70
|
|
|
71
|
+
### Server Components
|
|
72
|
+
|
|
73
|
+
Components that use hooks or context ship with `'use client'`, and the rest (`Alert`, `Button`, `Card`, `Chip`, `Dot`, `IconButton`, `Link`, `SearchInput`, `SettingsRow`, `Skeleton`, `Spinner`, `Tag`) are plain. So you can import any of them in a Next.js Server Component without adding the directive yourself:
|
|
74
|
+
|
|
75
|
+
```tsx
|
|
76
|
+
// app/loading.tsx, a Server Component
|
|
77
|
+
import { Spinner } from 'tintora';
|
|
78
|
+
|
|
79
|
+
export default function Loading() {
|
|
80
|
+
return <Spinner />;
|
|
81
|
+
}
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
Props passed from a Server Component must be serialisable, so event handlers (`onClick`, `onClose`) belong in a Client Component.
|
|
85
|
+
|
|
71
86
|
### Controlled overlays
|
|
72
87
|
|
|
73
88
|
Modal, Drawer, BottomSheet and Popover are controlled: your state owns `open`.
|
|
@@ -113,6 +128,7 @@ Every component has a story with all its variants in the [Storybook](https://fel
|
|
|
113
128
|
| ------------ | ------------------------------------------------------------------------------ |
|
|
114
129
|
| `Button` | `primary`, `secondary`, `outline` and `ghost`, with icons and a loading state. |
|
|
115
130
|
| `IconButton` | A round, field or nav button with an icon and a required `aria-label`. |
|
|
131
|
+
| `Link` | An `<a>`, or any component via `as` (e.g. Next's `Link`), in Tintora's style. |
|
|
116
132
|
| `Chip` | A pill button, or a toggle when `selected` is set. |
|
|
117
133
|
| `Toggle` | A two-option segmented control (`ToggleItem`), such as light and dark. |
|
|
118
134
|
| `Tabs` | A tab list (`Tab`), as a segmented pill or an underline. Arrow-key navigation. |
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=require("../utils/clsx.cjs");;/* empty css */let t=require("react/jsx-runtime");var n={info:(0,t.jsx)(`path`,{d:`M12 22a10 10 0 1 0 0-20 10 10 0 0 0 0 20zM12 16v-4M12 8h.01`}),success:(0,t.jsx)(`path`,{d:`M12 22a10 10 0 1 0 0-20 10 10 0 0 0 0 20zM8 12.5l2.7 2.7L16 9.8`}),warning:(0,t.jsx)(`path`,{d:`M10.3 3.9L1.8 18a2 2 0 0 0 1.7 3h17a2 2 0 0 0 1.7-3L13.7 3.9a2 2 0 0 0-3.4 0zM12 9v4M12 17h.01`}),error:(0,t.jsx)(`path`,{d:`M12 22a10 10 0 1 0 0-20 10 10 0 0 0 0 20zM15 9l-6 6M9 9l6 6`})},r=({status:e})=>(0,t.jsx)(`svg`,{width:`22`,height:`22`,viewBox:`0 0 24 24`,fill:`none`,stroke:`var(--tintora-status-${e}-fg)`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,style:{flex:`0 0 auto`,marginTop:1},children:n[e]});function i({status:n=`info`,variant:i=`alert`,title:a,children:o,action:s,onDismiss:c,className:l,...u}){return(0,t.jsxs)(`div`,{...u,role:i===`alert`&&n===`error`?`alert`:`status`,className:e.clsx(`tintora-alert`,i===`announcement`?`tintora-alert--announcement`:`tintora-alert--${n}`,l),children:[i===`alert`&&(0,t.jsx)(r,{status:n}),(0,t.jsxs)(`div`,{className:e.clsx(`tintora-alert__content`,i===`announcement`&&`tintora-alert__content--announcement`),children:[a&&(0,t.jsx)(`span`,{className:`tintora-alert__content__title`,children:a}),o&&(0,t.jsx)(`span`,{className:`tintora-alert__content__sub-title`,children:o}),s&&(0,t.jsx)(`button`,{type:`button`,onClick:s.onClick,className:e.clsx(`tintora-alert__content__action`,i===`alert`&&`tintora-alert__content__action--${n}`),children:s.label})]}),i===`alert`&&c&&(0,t.jsx)(`button`,{type:`button`,"aria-label":`Dismiss`,className:`tintora-alert__close`,onClick:c,children:(0,t.jsx)(`svg`,{width:`16`,height:`16`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,"aria-hidden":`true`,children:(0,t.jsx)(`path`,{d:`M18 6L6 18M6 6l12 12`})})})]})}exports.Alert=i;
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { clsx as e } from "../utils/clsx.js";
|
|
2
|
+
/* empty css */
|
|
3
|
+
import { jsx as t, jsxs as n } from "react/jsx-runtime";
|
|
4
|
+
//#region src/Alert/Alert.tsx
|
|
5
|
+
var r = {
|
|
6
|
+
info: /* @__PURE__ */ t("path", { d: "M12 22a10 10 0 1 0 0-20 10 10 0 0 0 0 20zM12 16v-4M12 8h.01" }),
|
|
7
|
+
success: /* @__PURE__ */ t("path", { d: "M12 22a10 10 0 1 0 0-20 10 10 0 0 0 0 20zM8 12.5l2.7 2.7L16 9.8" }),
|
|
8
|
+
warning: /* @__PURE__ */ t("path", { d: "M10.3 3.9L1.8 18a2 2 0 0 0 1.7 3h17a2 2 0 0 0 1.7-3L13.7 3.9a2 2 0 0 0-3.4 0zM12 9v4M12 17h.01" }),
|
|
9
|
+
error: /* @__PURE__ */ t("path", { d: "M12 22a10 10 0 1 0 0-20 10 10 0 0 0 0 20zM15 9l-6 6M9 9l6 6" })
|
|
10
|
+
}, i = ({ status: e }) => /* @__PURE__ */ t("svg", {
|
|
11
|
+
width: "22",
|
|
12
|
+
height: "22",
|
|
13
|
+
viewBox: "0 0 24 24",
|
|
14
|
+
fill: "none",
|
|
15
|
+
stroke: `var(--tintora-status-${e}-fg)`,
|
|
16
|
+
strokeWidth: "2",
|
|
17
|
+
strokeLinecap: "round",
|
|
18
|
+
strokeLinejoin: "round",
|
|
19
|
+
"aria-hidden": "true",
|
|
20
|
+
style: {
|
|
21
|
+
flex: "0 0 auto",
|
|
22
|
+
marginTop: 1
|
|
23
|
+
},
|
|
24
|
+
children: r[e]
|
|
25
|
+
});
|
|
26
|
+
function a({ status: r = "info", variant: a = "alert", title: o, children: s, action: c, onDismiss: l, className: u, ...d }) {
|
|
27
|
+
return /* @__PURE__ */ n("div", {
|
|
28
|
+
...d,
|
|
29
|
+
role: a === "alert" && r === "error" ? "alert" : "status",
|
|
30
|
+
className: e("tintora-alert", a === "announcement" ? "tintora-alert--announcement" : `tintora-alert--${r}`, u),
|
|
31
|
+
children: [
|
|
32
|
+
a === "alert" && /* @__PURE__ */ t(i, { status: r }),
|
|
33
|
+
/* @__PURE__ */ n("div", {
|
|
34
|
+
className: e("tintora-alert__content", a === "announcement" && "tintora-alert__content--announcement"),
|
|
35
|
+
children: [
|
|
36
|
+
o && /* @__PURE__ */ t("span", {
|
|
37
|
+
className: "tintora-alert__content__title",
|
|
38
|
+
children: o
|
|
39
|
+
}),
|
|
40
|
+
s && /* @__PURE__ */ t("span", {
|
|
41
|
+
className: "tintora-alert__content__sub-title",
|
|
42
|
+
children: s
|
|
43
|
+
}),
|
|
44
|
+
c && /* @__PURE__ */ t("button", {
|
|
45
|
+
type: "button",
|
|
46
|
+
onClick: c.onClick,
|
|
47
|
+
className: e("tintora-alert__content__action", a === "alert" && `tintora-alert__content__action--${r}`),
|
|
48
|
+
children: c.label
|
|
49
|
+
})
|
|
50
|
+
]
|
|
51
|
+
}),
|
|
52
|
+
a === "alert" && l && /* @__PURE__ */ t("button", {
|
|
53
|
+
type: "button",
|
|
54
|
+
"aria-label": "Dismiss",
|
|
55
|
+
className: "tintora-alert__close",
|
|
56
|
+
onClick: l,
|
|
57
|
+
children: /* @__PURE__ */ t("svg", {
|
|
58
|
+
width: "16",
|
|
59
|
+
height: "16",
|
|
60
|
+
viewBox: "0 0 24 24",
|
|
61
|
+
fill: "none",
|
|
62
|
+
stroke: "currentColor",
|
|
63
|
+
strokeWidth: "2",
|
|
64
|
+
strokeLinecap: "round",
|
|
65
|
+
"aria-hidden": "true",
|
|
66
|
+
children: /* @__PURE__ */ t("path", { d: "M18 6L6 18M6 6l12 12" })
|
|
67
|
+
})
|
|
68
|
+
})
|
|
69
|
+
]
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
//#endregion
|
|
73
|
+
export { a as Alert };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use client";const e=require("../utils/clsx.cjs");;/* empty css */const t=require("./utils.cjs");let n=require("react/jsx-runtime"),r=require("react");function i({name:i,src:a,size:o=`medium`,className:s,...c}){let[l,u]=(0,r.useState)(),d=!!a&&a!==l;return(0,n.jsx)(`span`,{role:`img`,"aria-label":i,...c,className:e.clsx(`tintora-avatar`,`tintora-avatar--${o}`,s),children:d?(0,n.jsx)(`img`,{src:a,alt:``,onError:()=>u(a)}):t.getCapitalFirstLetters(i)})}exports.Avatar=i;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { clsx as e } from "../utils/clsx.js";
|
|
3
|
+
/* empty css */
|
|
4
|
+
import { getCapitalFirstLetters as t } from "./utils.js";
|
|
5
|
+
import { jsx as n } from "react/jsx-runtime";
|
|
6
|
+
import { useState as r } from "react";
|
|
7
|
+
//#region src/Avatar/Avatar.tsx
|
|
8
|
+
function i({ name: i, src: a, size: o = "medium", className: s, ...c }) {
|
|
9
|
+
let [l, u] = r(), d = !!a && a !== l;
|
|
10
|
+
return /* @__PURE__ */ n("span", {
|
|
11
|
+
role: "img",
|
|
12
|
+
"aria-label": i,
|
|
13
|
+
...c,
|
|
14
|
+
className: e("tintora-avatar", `tintora-avatar--${o}`, s),
|
|
15
|
+
children: d ? /* @__PURE__ */ n("img", {
|
|
16
|
+
src: a,
|
|
17
|
+
alt: "",
|
|
18
|
+
onError: () => u(a)
|
|
19
|
+
}) : t(i)
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
//#endregion
|
|
23
|
+
export { i as Avatar };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function e(e){if(!e.length)return``;let t=e.trim().split(/\s+/).map(e=>e.match(/\p{L}\p{M}*/u)?.[0]).filter(e=>!!e);return`${t[0]??``}${t.length>1?t.at(-1)??``:``}`.toLocaleUpperCase()}exports.getCapitalFirstLetters=e;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
//#region src/Avatar/utils.ts
|
|
2
|
+
function e(e) {
|
|
3
|
+
if (!e.length) return "";
|
|
4
|
+
let t = e.trim().split(/\s+/).map((e) => e.match(/\p{L}\p{M}*/u)?.[0]).filter((e) => !!e);
|
|
5
|
+
return `${t[0] ?? ""}${t.length > 1 ? t.at(-1) ?? "" : ""}`.toLocaleUpperCase();
|
|
6
|
+
}
|
|
7
|
+
//#endregion
|
|
8
|
+
export { e as getCapitalFirstLetters };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use client";const e=require("../utils/clsx.cjs"),t=require("../Drawer/Drawer2.cjs");;/* empty css */let n=require("react/jsx-runtime"),r=require("react");function i({title:i,children:a,className:o,...s}){let c=(0,r.useId)();return(0,n.jsxs)(t.Drawer,{...s,from:`bottom`,"aria-labelledby":c,className:e.clsx(`tintora-bottom-sheet`,o),children:[(0,n.jsx)(`span`,{className:`tintora-bottom-sheet__grabber`,"aria-hidden":`true`}),(0,n.jsx)(`div`,{id:c,className:`tintora-bottom-sheet__title`,children:i}),a]})}function a({selected:t=!1,className:r,children:i,...a}){return(0,n.jsxs)(`button`,{type:`button`,...a,"aria-pressed":t,className:e.clsx(`tintora-bottom-sheet__option`,r),children:[(0,n.jsx)(`span`,{children:i}),(0,n.jsx)(`svg`,{className:`tintora-bottom-sheet__check`,width:`18`,height:`18`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.4`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:(0,n.jsx)(`path`,{d:`M5 12.5l4.5 4.5L19 7.5`})})]})}exports.BottomSheet=i,exports.BottomSheetOption=a;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { clsx as e } from "../utils/clsx.js";
|
|
3
|
+
import { Drawer as t } from "../Drawer/Drawer2.js";
|
|
4
|
+
/* empty css */
|
|
5
|
+
import { jsx as n, jsxs as r } from "react/jsx-runtime";
|
|
6
|
+
import { useId as i } from "react";
|
|
7
|
+
//#region src/BottomSheet/BottomSheet.tsx
|
|
8
|
+
function a({ title: a, children: o, className: s, ...c }) {
|
|
9
|
+
let l = i();
|
|
10
|
+
return /* @__PURE__ */ r(t, {
|
|
11
|
+
...c,
|
|
12
|
+
from: "bottom",
|
|
13
|
+
"aria-labelledby": l,
|
|
14
|
+
className: e("tintora-bottom-sheet", s),
|
|
15
|
+
children: [
|
|
16
|
+
/* @__PURE__ */ n("span", {
|
|
17
|
+
className: "tintora-bottom-sheet__grabber",
|
|
18
|
+
"aria-hidden": "true"
|
|
19
|
+
}),
|
|
20
|
+
/* @__PURE__ */ n("div", {
|
|
21
|
+
id: l,
|
|
22
|
+
className: "tintora-bottom-sheet__title",
|
|
23
|
+
children: a
|
|
24
|
+
}),
|
|
25
|
+
o
|
|
26
|
+
]
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
function o({ selected: t = !1, className: i, children: a, ...o }) {
|
|
30
|
+
return /* @__PURE__ */ r("button", {
|
|
31
|
+
type: "button",
|
|
32
|
+
...o,
|
|
33
|
+
"aria-pressed": t,
|
|
34
|
+
className: e("tintora-bottom-sheet__option", i),
|
|
35
|
+
children: [/* @__PURE__ */ n("span", { children: a }), /* @__PURE__ */ n("svg", {
|
|
36
|
+
className: "tintora-bottom-sheet__check",
|
|
37
|
+
width: "18",
|
|
38
|
+
height: "18",
|
|
39
|
+
viewBox: "0 0 24 24",
|
|
40
|
+
fill: "none",
|
|
41
|
+
stroke: "currentColor",
|
|
42
|
+
strokeWidth: "2.4",
|
|
43
|
+
strokeLinecap: "round",
|
|
44
|
+
strokeLinejoin: "round",
|
|
45
|
+
"aria-hidden": "true",
|
|
46
|
+
children: /* @__PURE__ */ n("path", { d: "M5 12.5l4.5 4.5L19 7.5" })
|
|
47
|
+
})]
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
//#endregion
|
|
51
|
+
export { a as BottomSheet, o as BottomSheetOption };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=require("../utils/clsx.cjs"),t=require("../Spinner/Spinner2.cjs");;/* empty css */let n=require("react/jsx-runtime");function r({children:r,className:i,variant:a,disabled:o,leadingIcon:s,trailingIcon:c,size:l=`medium`,type:u=`button`,loading:d=!1,fullWidth:f=!1,...p}){return(0,n.jsxs)(`button`,{type:u,className:e.clsx(`tintora-button`,`tintora-button--${a}`,`tintora-button--${l}`,{"tintora-button--leading-icon":!!s||d,"tintora-button--loading":d,"tintora-button--trailing-icon":!!c,"tintora-button--full-width":f},i),disabled:o||d,"aria-busy":d||void 0,...p,children:[d&&(0,n.jsx)(`span`,{className:`tintora-button__icon`,"aria-hidden":`true`,children:(0,n.jsx)(t.Spinner,{size:`small`,color:`current`})}),!d&&s&&(0,n.jsx)(`span`,{className:`tintora-button__icon`,"aria-hidden":`true`,children:s}),r,c&&(0,n.jsx)(`span`,{className:`tintora-button__icon`,"aria-hidden":`true`,children:c})]})}exports.Button=r;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { clsx as e } from "../utils/clsx.js";
|
|
2
|
+
import { Spinner as t } from "../Spinner/Spinner2.js";
|
|
3
|
+
/* empty css */
|
|
4
|
+
import { jsx as n, jsxs as r } from "react/jsx-runtime";
|
|
5
|
+
//#region src/Button/Button.tsx
|
|
6
|
+
function i({ children: i, className: a, variant: o, disabled: s, leadingIcon: c, trailingIcon: l, size: u = "medium", type: d = "button", loading: f = !1, fullWidth: p = !1, ...m }) {
|
|
7
|
+
return /* @__PURE__ */ r("button", {
|
|
8
|
+
type: d,
|
|
9
|
+
className: e("tintora-button", `tintora-button--${o}`, `tintora-button--${u}`, {
|
|
10
|
+
"tintora-button--leading-icon": !!c || f,
|
|
11
|
+
"tintora-button--loading": f,
|
|
12
|
+
"tintora-button--trailing-icon": !!l,
|
|
13
|
+
"tintora-button--full-width": p
|
|
14
|
+
}, a),
|
|
15
|
+
disabled: s || f,
|
|
16
|
+
"aria-busy": f || void 0,
|
|
17
|
+
...m,
|
|
18
|
+
children: [
|
|
19
|
+
f && /* @__PURE__ */ n("span", {
|
|
20
|
+
className: "tintora-button__icon",
|
|
21
|
+
"aria-hidden": "true",
|
|
22
|
+
children: /* @__PURE__ */ n(t, {
|
|
23
|
+
size: "small",
|
|
24
|
+
color: "current"
|
|
25
|
+
})
|
|
26
|
+
}),
|
|
27
|
+
!f && c && /* @__PURE__ */ n("span", {
|
|
28
|
+
className: "tintora-button__icon",
|
|
29
|
+
"aria-hidden": "true",
|
|
30
|
+
children: c
|
|
31
|
+
}),
|
|
32
|
+
i,
|
|
33
|
+
l && /* @__PURE__ */ n("span", {
|
|
34
|
+
className: "tintora-button__icon",
|
|
35
|
+
"aria-hidden": "true",
|
|
36
|
+
children: l
|
|
37
|
+
})
|
|
38
|
+
]
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
//#endregion
|
|
42
|
+
export { i as Button };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=require("../utils/clsx.cjs");;/* empty css */let t=require("react/jsx-runtime");function n({as:n=`article`,variant:r=`surface`,className:i,...a}){return(0,t.jsx)(n,{...a,className:e.clsx(`tintora-card`,`tintora-card--${r}`,i)})}function r({selected:n=!1,className:r,...i}){return(0,t.jsx)(`button`,{...i,type:`button`,"aria-pressed":n,className:e.clsx(`tintora-card`,`tintora-card--surface`,`tintora-card--selectable`,n&&`tintora-card--selected`,r)})}exports.Card=n,exports.SelectableCard=r;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { clsx as e } from "../utils/clsx.js";
|
|
2
|
+
/* empty css */
|
|
3
|
+
import { jsx as t } from "react/jsx-runtime";
|
|
4
|
+
//#region src/Card/Card.tsx
|
|
5
|
+
function n({ as: n = "article", variant: r = "surface", className: i, ...a }) {
|
|
6
|
+
return /* @__PURE__ */ t(n, {
|
|
7
|
+
...a,
|
|
8
|
+
className: e("tintora-card", `tintora-card--${r}`, i)
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
function r({ selected: n = !1, className: r, ...i }) {
|
|
12
|
+
return /* @__PURE__ */ t("button", {
|
|
13
|
+
...i,
|
|
14
|
+
type: "button",
|
|
15
|
+
"aria-pressed": n,
|
|
16
|
+
className: e("tintora-card", "tintora-card--surface", "tintora-card--selectable", n && "tintora-card--selected", r)
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
//#endregion
|
|
20
|
+
export { n as Card, r as SelectableCard };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use client";const e=require("../utils/clsx.cjs"),t=require("../hooks/useCheckedState.cjs");;/* empty css */let n=require("react/jsx-runtime"),r=require("react");function i({checked:i,defaultChecked:a,onCheckedChange:o,indeterminate:s=!1,className:c,...l}){let u=(0,r.useRef)(null),d=t.useCheckedState({checked:i,defaultChecked:a,onCheckedChange:o});return(0,r.useLayoutEffect)(()=>{u.current&&(u.current.indeterminate=s)}),(0,n.jsxs)(`span`,{className:e.clsx(`tintora-checkbox`,c),children:[(0,n.jsx)(`input`,{...l,ref:u,type:`checkbox`,className:`tintora-checkbox__input`,checked:d.checked,onChange:d.onChange}),(0,n.jsxs)(`span`,{className:`tintora-checkbox__box`,"aria-hidden":`true`,children:[(0,n.jsx)(`svg`,{className:`tintora-checkbox__check`,width:`14`,height:`14`,viewBox:`0 0 24 24`,fill:`none`,strokeWidth:`3.2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:(0,n.jsx)(`path`,{d:`M5 12.5l4.5 4.5L19 7.5`})}),(0,n.jsx)(`svg`,{className:`tintora-checkbox__dash`,width:`14`,height:`14`,viewBox:`0 0 24 24`,fill:`none`,strokeWidth:`3.2`,strokeLinecap:`round`,children:(0,n.jsx)(`path`,{d:`M6 12h12`})})]})]})}exports.Checkbox=i;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { clsx as e } from "../utils/clsx.js";
|
|
3
|
+
import { useCheckedState as t } from "../hooks/useCheckedState.js";
|
|
4
|
+
/* empty css */
|
|
5
|
+
import { jsx as n, jsxs as r } from "react/jsx-runtime";
|
|
6
|
+
import { useLayoutEffect as i, useRef as a } from "react";
|
|
7
|
+
//#region src/Checkbox/Checkbox.tsx
|
|
8
|
+
function o({ checked: o, defaultChecked: s, onCheckedChange: c, indeterminate: l = !1, className: u, ...d }) {
|
|
9
|
+
let f = a(null), p = t({
|
|
10
|
+
checked: o,
|
|
11
|
+
defaultChecked: s,
|
|
12
|
+
onCheckedChange: c
|
|
13
|
+
});
|
|
14
|
+
return i(() => {
|
|
15
|
+
f.current && (f.current.indeterminate = l);
|
|
16
|
+
}), /* @__PURE__ */ r("span", {
|
|
17
|
+
className: e("tintora-checkbox", u),
|
|
18
|
+
children: [/* @__PURE__ */ n("input", {
|
|
19
|
+
...d,
|
|
20
|
+
ref: f,
|
|
21
|
+
type: "checkbox",
|
|
22
|
+
className: "tintora-checkbox__input",
|
|
23
|
+
checked: p.checked,
|
|
24
|
+
onChange: p.onChange
|
|
25
|
+
}), /* @__PURE__ */ r("span", {
|
|
26
|
+
className: "tintora-checkbox__box",
|
|
27
|
+
"aria-hidden": "true",
|
|
28
|
+
children: [/* @__PURE__ */ n("svg", {
|
|
29
|
+
className: "tintora-checkbox__check",
|
|
30
|
+
width: "14",
|
|
31
|
+
height: "14",
|
|
32
|
+
viewBox: "0 0 24 24",
|
|
33
|
+
fill: "none",
|
|
34
|
+
strokeWidth: "3.2",
|
|
35
|
+
strokeLinecap: "round",
|
|
36
|
+
strokeLinejoin: "round",
|
|
37
|
+
children: /* @__PURE__ */ n("path", { d: "M5 12.5l4.5 4.5L19 7.5" })
|
|
38
|
+
}), /* @__PURE__ */ n("svg", {
|
|
39
|
+
className: "tintora-checkbox__dash",
|
|
40
|
+
width: "14",
|
|
41
|
+
height: "14",
|
|
42
|
+
viewBox: "0 0 24 24",
|
|
43
|
+
fill: "none",
|
|
44
|
+
strokeWidth: "3.2",
|
|
45
|
+
strokeLinecap: "round",
|
|
46
|
+
children: /* @__PURE__ */ n("path", { d: "M6 12h12" })
|
|
47
|
+
})]
|
|
48
|
+
})]
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
//#endregion
|
|
52
|
+
export { o as Checkbox };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=require("../utils/clsx.cjs");;/* empty css */let t=require("react/jsx-runtime");function n({children:n,selected:r,className:i,"aria-pressed":a,...o}){return(0,t.jsx)(`button`,{...o,type:`button`,className:e.clsx(`tintora-chip`,i),"aria-pressed":r??a,children:n})}exports.Chip=n;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { clsx as e } from "../utils/clsx.js";
|
|
2
|
+
/* empty css */
|
|
3
|
+
import { jsx as t } from "react/jsx-runtime";
|
|
4
|
+
//#region src/Chip/Chip.tsx
|
|
5
|
+
function n({ children: n, selected: r, className: i, "aria-pressed": a, ...o }) {
|
|
6
|
+
return /* @__PURE__ */ t("button", {
|
|
7
|
+
...o,
|
|
8
|
+
type: "button",
|
|
9
|
+
className: e("tintora-chip", i),
|
|
10
|
+
"aria-pressed": r ?? a,
|
|
11
|
+
children: n
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
//#endregion
|
|
15
|
+
export { n as Chip };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=require("../utils/clsx.cjs");;/* empty css */let t=require("react/jsx-runtime");function n({variant:n=`unread`,label:r,className:i,...a}){return(0,t.jsx)(`span`,{...a,className:e.clsx(`tintora-dot`,`tintora-dot--${n}`,i),role:r?`img`:void 0,"aria-label":r,"aria-hidden":!r||void 0})}exports.Dot=n;
|
package/dist/Dot/Dot2.js
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { clsx as e } from "../utils/clsx.js";
|
|
2
|
+
/* empty css */
|
|
3
|
+
import { jsx as t } from "react/jsx-runtime";
|
|
4
|
+
//#region src/Dot/Dot.tsx
|
|
5
|
+
function n({ variant: n = "unread", label: r, className: i, ...a }) {
|
|
6
|
+
return /* @__PURE__ */ t("span", {
|
|
7
|
+
...a,
|
|
8
|
+
className: e("tintora-dot", `tintora-dot--${n}`, i),
|
|
9
|
+
role: r ? "img" : void 0,
|
|
10
|
+
"aria-label": r,
|
|
11
|
+
"aria-hidden": !r || void 0
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
//#endregion
|
|
15
|
+
export { n as Dot };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use client";const e=require("../utils/clsx.cjs"),t=require("../utils/outside.cjs");;/* empty css */let n=require("react/jsx-runtime"),r=require("react");var i=e=>typeof e==`number`?`${e}px`:e;function a({open:a,from:o=`right`,width:s,height:c,children:l,onClose:u,className:d,...f}){let p=(0,r.useRef)(null);(0,r.useEffect)(()=>{let e=p.current;e&&(a&&!e.open?(e.showModal(),e.querySelector(`[data-autofocus]`)?.focus()):!a&&e.open&&e.close())},[a]);let m={...f.style,...s!==void 0&&{"--tintora-drawer-width":i(s)},...c!==void 0&&{"--tintora-drawer-height":i(c)}};return(0,n.jsx)(`dialog`,{...f,ref:p,className:e.clsx(`tintora-drawer`,`tintora-drawer--from-${o}`,d),onCancel:e=>{e.preventDefault(),u()},onClick:e=>t.isOutsideElementClicked(e,u),style:m,children:l})}exports.Drawer=a;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { clsx as e } from "../utils/clsx.js";
|
|
3
|
+
import { isOutsideElementClicked as t } from "../utils/outside.js";
|
|
4
|
+
/* empty css */
|
|
5
|
+
import { jsx as n } from "react/jsx-runtime";
|
|
6
|
+
import { useEffect as r, useRef as i } from "react";
|
|
7
|
+
//#region src/Drawer/Drawer.tsx
|
|
8
|
+
var a = (e) => typeof e == "number" ? `${e}px` : e;
|
|
9
|
+
function o({ open: o, from: s = "right", width: c, height: l, children: u, onClose: d, className: f, ...p }) {
|
|
10
|
+
let m = i(null);
|
|
11
|
+
r(() => {
|
|
12
|
+
let e = m.current;
|
|
13
|
+
e && (o && !e.open ? (e.showModal(), e.querySelector("[data-autofocus]")?.focus()) : !o && e.open && e.close());
|
|
14
|
+
}, [o]);
|
|
15
|
+
let h = {
|
|
16
|
+
...p.style,
|
|
17
|
+
...c !== void 0 && { "--tintora-drawer-width": a(c) },
|
|
18
|
+
...l !== void 0 && { "--tintora-drawer-height": a(l) }
|
|
19
|
+
};
|
|
20
|
+
return /* @__PURE__ */ n("dialog", {
|
|
21
|
+
...p,
|
|
22
|
+
ref: m,
|
|
23
|
+
className: e("tintora-drawer", `tintora-drawer--from-${s}`, f),
|
|
24
|
+
onCancel: (e) => {
|
|
25
|
+
e.preventDefault(), d();
|
|
26
|
+
},
|
|
27
|
+
onClick: (e) => t(e, d),
|
|
28
|
+
style: h,
|
|
29
|
+
children: u
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
//#endregion
|
|
33
|
+
export { o as Drawer };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=require("../utils/clsx.cjs"),t=require("../Button/Button2.cjs");;/* empty css */let n=require("react/jsx-runtime");var r={round:`secondary`,field:`secondary`,nav:`ghost`};function i({icon:i,variant:a=`round`,size:o,selected:s,className:c,...l}){let u=a===`round`?o??`large`:void 0;return(0,n.jsx)(t.Button,{...l,variant:r[a],"aria-current":s?`page`:void 0,className:e.clsx(`tintora-icon-button`,`tintora-icon-button--${a}`,u&&`tintora-icon-button--${u}`,c),...u&&{size:u},children:(0,n.jsx)(`span`,{className:`tintora-icon-button__icon`,"aria-hidden":`true`,children:i})})}exports.IconButton=i;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { clsx as e } from "../utils/clsx.js";
|
|
2
|
+
import { Button as t } from "../Button/Button2.js";
|
|
3
|
+
/* empty css */
|
|
4
|
+
import { jsx as n } from "react/jsx-runtime";
|
|
5
|
+
//#region src/IconButton/IconButton.tsx
|
|
6
|
+
var r = {
|
|
7
|
+
round: "secondary",
|
|
8
|
+
field: "secondary",
|
|
9
|
+
nav: "ghost"
|
|
10
|
+
};
|
|
11
|
+
function i({ icon: i, variant: a = "round", size: o, selected: s, className: c, ...l }) {
|
|
12
|
+
let u = a === "round" ? o ?? "large" : void 0;
|
|
13
|
+
return /* @__PURE__ */ n(t, {
|
|
14
|
+
...l,
|
|
15
|
+
variant: r[a],
|
|
16
|
+
"aria-current": s ? "page" : void 0,
|
|
17
|
+
className: e("tintora-icon-button", `tintora-icon-button--${a}`, u && `tintora-icon-button--${u}`, c),
|
|
18
|
+
...u && { size: u },
|
|
19
|
+
children: /* @__PURE__ */ n("span", {
|
|
20
|
+
className: "tintora-icon-button__icon",
|
|
21
|
+
"aria-hidden": "true",
|
|
22
|
+
children: i
|
|
23
|
+
})
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
//#endregion
|
|
27
|
+
export { i as IconButton };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { ComponentPropsWithoutRef, ElementType } from 'react';
|
|
2
|
+
import './Link.css';
|
|
3
|
+
export type LinkProps<C extends ElementType = 'a'> = {
|
|
4
|
+
/**
|
|
5
|
+
* What to render: `'a'`, or a router's link such as Next's `Link`. Its own
|
|
6
|
+
* props (`href`, `to`, `prefetch`, ...) are then accepted and type-checked.
|
|
7
|
+
* @default 'a'
|
|
8
|
+
*/
|
|
9
|
+
as?: C;
|
|
10
|
+
/**
|
|
11
|
+
* `accent` and `white` are coloured and underlined. `transparent` applies
|
|
12
|
+
* no style (it inherits the colour and has no underline), for wrapping a
|
|
13
|
+
* card or any block; only the keyboard focus ring stays.
|
|
14
|
+
* @default 'accent'
|
|
15
|
+
*/
|
|
16
|
+
variant?: 'accent' | 'white' | 'transparent';
|
|
17
|
+
className?: string;
|
|
18
|
+
} & Omit<ComponentPropsWithoutRef<C>, 'as' | 'variant' | 'className'>;
|
|
19
|
+
/**
|
|
20
|
+
* Tintora's link style on an `<a>`, or on any component that takes
|
|
21
|
+
* `className` and `children`, so a router link keeps client-side navigation.
|
|
22
|
+
*/
|
|
23
|
+
export declare function Link<C extends ElementType = 'a'>({ as, variant, className, ...props }: LinkProps<C>): import("react").JSX.Element;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=require("../utils/clsx.cjs");;/* empty css */let t=require("react/jsx-runtime");function n({as:n,variant:r=`accent`,className:i,...a}){return(0,t.jsx)(n??`a`,{...a,className:e.clsx(`tintora-link`,`tintora-link--${r}`,i)})}exports.Link=n;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { clsx as e } from "../utils/clsx.js";
|
|
2
|
+
/* empty css */
|
|
3
|
+
import { jsx as t } from "react/jsx-runtime";
|
|
4
|
+
//#region src/Link/Link.tsx
|
|
5
|
+
function n({ as: n, variant: r = "accent", className: i, ...a }) {
|
|
6
|
+
return /* @__PURE__ */ t(n ?? "a", {
|
|
7
|
+
...a,
|
|
8
|
+
className: e("tintora-link", `tintora-link--${r}`, i)
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
//#endregion
|
|
12
|
+
export { n as Link };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use client";const e=require("../utils/clsx.cjs"),t=require("../utils/outside.cjs"),n=require("../IconButton/IconButton2.cjs");;/* empty css */let r=require("react/jsx-runtime"),i=require("react");var a=()=>(0,r.jsx)(`svg`,{width:`16`,height:`16`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,children:(0,r.jsx)(`path`,{d:`M18 6L6 18M6 6l12 12`})});function o({open:o,onClose:s,title:c,description:l,icon:u,status:d=`info`,actions:f,size:p=`md`,align:m=`start`,role:h=`dialog`,closeButton:g=!0,className:_,children:v,...y}){let b=(0,i.useRef)(null),x=(0,i.useId)(),S=(0,i.useId)();return(0,i.useEffect)(()=>{let e=b.current;e&&(o&&!e.open?(e.showModal(),e.querySelector(`[data-autofocus]`)?.focus()):!o&&e.open&&e.close())},[o]),(0,r.jsxs)(`dialog`,{...y,ref:b,role:h,"aria-labelledby":x,"aria-describedby":l?S:void 0,className:e.clsx(`tintora-modal`,`tintora-modal--${p}`,m===`center`&&`tintora-modal--center`,_),onCancel:e=>{e.preventDefault(),s()},onClick:e=>{h===`dialog`&&t.isOutsideElementClicked(e,s)},children:[u&&(0,r.jsx)(`span`,{className:e.clsx(`tintora-modal__icon`,`tintora-modal__icon--${d}`),"aria-hidden":`true`,children:u}),(0,r.jsxs)(`div`,{className:`tintora-modal__text`,children:[(0,r.jsx)(`h2`,{id:x,className:`tintora-modal__title`,children:c}),l&&(0,r.jsx)(`p`,{id:S,className:`tintora-modal__description`,children:l})]}),g&&(0,r.jsx)(n.IconButton,{className:`tintora-modal__close`,size:`medium`,"aria-label":`Close`,icon:(0,r.jsx)(a,{}),onClick:s}),v,f&&(0,r.jsx)(`div`,{className:`tintora-modal__actions`,children:f})]})}exports.Modal=o;
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { clsx as e } from "../utils/clsx.js";
|
|
3
|
+
import { isOutsideElementClicked as t } from "../utils/outside.js";
|
|
4
|
+
import { IconButton as n } from "../IconButton/IconButton2.js";
|
|
5
|
+
/* empty css */
|
|
6
|
+
import { jsx as r, jsxs as i } from "react/jsx-runtime";
|
|
7
|
+
import { useEffect as a, useId as o, useRef as s } from "react";
|
|
8
|
+
//#region src/Modal/Modal.tsx
|
|
9
|
+
var c = () => /* @__PURE__ */ r("svg", {
|
|
10
|
+
width: "16",
|
|
11
|
+
height: "16",
|
|
12
|
+
viewBox: "0 0 24 24",
|
|
13
|
+
fill: "none",
|
|
14
|
+
stroke: "currentColor",
|
|
15
|
+
strokeWidth: "2",
|
|
16
|
+
strokeLinecap: "round",
|
|
17
|
+
children: /* @__PURE__ */ r("path", { d: "M18 6L6 18M6 6l12 12" })
|
|
18
|
+
});
|
|
19
|
+
function l({ open: l, onClose: u, title: d, description: f, icon: p, status: m = "info", actions: h, size: g = "md", align: _ = "start", role: v = "dialog", closeButton: y = !0, className: b, children: x, ...S }) {
|
|
20
|
+
let C = s(null), w = o(), T = o();
|
|
21
|
+
return a(() => {
|
|
22
|
+
let e = C.current;
|
|
23
|
+
e && (l && !e.open ? (e.showModal(), e.querySelector("[data-autofocus]")?.focus()) : !l && e.open && e.close());
|
|
24
|
+
}, [l]), /* @__PURE__ */ i("dialog", {
|
|
25
|
+
...S,
|
|
26
|
+
ref: C,
|
|
27
|
+
role: v,
|
|
28
|
+
"aria-labelledby": w,
|
|
29
|
+
"aria-describedby": f ? T : void 0,
|
|
30
|
+
className: e("tintora-modal", `tintora-modal--${g}`, _ === "center" && "tintora-modal--center", b),
|
|
31
|
+
onCancel: (e) => {
|
|
32
|
+
e.preventDefault(), u();
|
|
33
|
+
},
|
|
34
|
+
onClick: (e) => {
|
|
35
|
+
v === "dialog" && t(e, u);
|
|
36
|
+
},
|
|
37
|
+
children: [
|
|
38
|
+
p && /* @__PURE__ */ r("span", {
|
|
39
|
+
className: e("tintora-modal__icon", `tintora-modal__icon--${m}`),
|
|
40
|
+
"aria-hidden": "true",
|
|
41
|
+
children: p
|
|
42
|
+
}),
|
|
43
|
+
/* @__PURE__ */ i("div", {
|
|
44
|
+
className: "tintora-modal__text",
|
|
45
|
+
children: [/* @__PURE__ */ r("h2", {
|
|
46
|
+
id: w,
|
|
47
|
+
className: "tintora-modal__title",
|
|
48
|
+
children: d
|
|
49
|
+
}), f && /* @__PURE__ */ r("p", {
|
|
50
|
+
id: T,
|
|
51
|
+
className: "tintora-modal__description",
|
|
52
|
+
children: f
|
|
53
|
+
})]
|
|
54
|
+
}),
|
|
55
|
+
y && /* @__PURE__ */ r(n, {
|
|
56
|
+
className: "tintora-modal__close",
|
|
57
|
+
size: "medium",
|
|
58
|
+
"aria-label": "Close",
|
|
59
|
+
icon: /* @__PURE__ */ r(c, {}),
|
|
60
|
+
onClick: u
|
|
61
|
+
}),
|
|
62
|
+
x,
|
|
63
|
+
h && /* @__PURE__ */ r("div", {
|
|
64
|
+
className: "tintora-modal__actions",
|
|
65
|
+
children: h
|
|
66
|
+
})
|
|
67
|
+
]
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
//#endregion
|
|
71
|
+
export { l as Modal };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use client";const e=require("../utils/clsx.cjs"),t=require("../hooks/useEscapeKey.cjs"),n=require("../hooks/useOutsidePress.cjs"),r=require("../hooks/useTopLayerPosition.cjs"),i=require("../utils/placement.cjs");;/* empty css */let a=require("react/jsx-runtime"),o=require("react");var s=[`button:not([disabled])`,`[href]`,`input:not([disabled])`,`select:not([disabled])`,`textarea:not([disabled])`,`[tabindex]:not([tabindex="-1"])`].join(`, `);function c({open:c,onOpenChange:l,trigger:u,title:d,children:f,role:p=`dialog`,size:m=`md`,placement:h=`bottom`,className:g}){let _=(0,o.useId)(),v=(0,o.useRef)(null),y=(0,o.useRef)(null),b=(0,o.useRef)(!1),x=()=>l(!1);t.useEscapeKey(c,x),n.useOutsidePress(c,v,x);let S=e=>{u.props.onClick?.(e),e.defaultPrevented||l(!c)},C=r.useTopLayerPosition(c,y,()=>{let e=y.current,t=v.current?.firstElementChild;return!e||!t?null:i.getPosition(t.getBoundingClientRect(),{width:e.offsetWidth,height:e.offsetHeight},h,void 0,{gap:12})},[h,d,f]),w=C?{top:C.top,left:C.left,"--tintora-popover-arrow-offset":`${C.arrowOffset}px`}:{visibility:`hidden`},T=C!==null;return(0,o.useLayoutEffect)(()=>{let e=y.current;c&&T&&e&&(e.querySelector(`[data-autofocus]`)??e.querySelector(s)??e).focus()},[c,T]),(0,o.useEffect)(()=>{if(b.current&&!c){let e=document.activeElement;(!e||e===document.body)&&v.current?.querySelector(`*`)?.focus()}b.current=c},[c]),(0,a.jsxs)(`span`,{ref:v,className:`tintora-popover-root`,children:[(0,o.cloneElement)(u,{"aria-haspopup":`dialog`,"aria-expanded":c,"aria-controls":c?_:void 0,onClick:S}),c&&(0,a.jsx)(`div`,{id:_,ref:y,role:p,"aria-label":d,popover:`manual`,tabIndex:-1,className:e.clsx(`tintora-popover`,`tintora-popover--${m}`,`tintora-popover--${C?.placement??h}`,g),style:w,children:f})]})}exports.Popover=c;
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { clsx as e } from "../utils/clsx.js";
|
|
3
|
+
import { useEscapeKey as t } from "../hooks/useEscapeKey.js";
|
|
4
|
+
import { useOutsidePress as n } from "../hooks/useOutsidePress.js";
|
|
5
|
+
import { useTopLayerPosition as r } from "../hooks/useTopLayerPosition.js";
|
|
6
|
+
import { getPosition as i } from "../utils/placement.js";
|
|
7
|
+
/* empty css */
|
|
8
|
+
import { jsx as a, jsxs as o } from "react/jsx-runtime";
|
|
9
|
+
import { cloneElement as s, useEffect as c, useId as l, useLayoutEffect as u, useRef as d } from "react";
|
|
10
|
+
//#region src/Popover/Popover.tsx
|
|
11
|
+
var f = [
|
|
12
|
+
"button:not([disabled])",
|
|
13
|
+
"[href]",
|
|
14
|
+
"input:not([disabled])",
|
|
15
|
+
"select:not([disabled])",
|
|
16
|
+
"textarea:not([disabled])",
|
|
17
|
+
"[tabindex]:not([tabindex=\"-1\"])"
|
|
18
|
+
].join(", ");
|
|
19
|
+
function p({ open: p, onOpenChange: m, trigger: h, title: g, children: _, role: v = "dialog", size: y = "md", placement: b = "bottom", className: x }) {
|
|
20
|
+
let S = l(), C = d(null), w = d(null), T = d(!1), E = () => m(!1);
|
|
21
|
+
t(p, E), n(p, C, E);
|
|
22
|
+
let D = (e) => {
|
|
23
|
+
h.props.onClick?.(e), e.defaultPrevented || m(!p);
|
|
24
|
+
}, O = r(p, w, () => {
|
|
25
|
+
let e = w.current, t = C.current?.firstElementChild;
|
|
26
|
+
return !e || !t ? null : i(t.getBoundingClientRect(), {
|
|
27
|
+
width: e.offsetWidth,
|
|
28
|
+
height: e.offsetHeight
|
|
29
|
+
}, b, void 0, { gap: 12 });
|
|
30
|
+
}, [
|
|
31
|
+
b,
|
|
32
|
+
g,
|
|
33
|
+
_
|
|
34
|
+
]), k = O ? {
|
|
35
|
+
top: O.top,
|
|
36
|
+
left: O.left,
|
|
37
|
+
"--tintora-popover-arrow-offset": `${O.arrowOffset}px`
|
|
38
|
+
} : { visibility: "hidden" }, A = O !== null;
|
|
39
|
+
return u(() => {
|
|
40
|
+
let e = w.current;
|
|
41
|
+
p && A && e && (e.querySelector("[data-autofocus]") ?? e.querySelector(f) ?? e).focus();
|
|
42
|
+
}, [p, A]), c(() => {
|
|
43
|
+
if (T.current && !p) {
|
|
44
|
+
let e = document.activeElement;
|
|
45
|
+
(!e || e === document.body) && C.current?.querySelector("*")?.focus();
|
|
46
|
+
}
|
|
47
|
+
T.current = p;
|
|
48
|
+
}, [p]), /* @__PURE__ */ o("span", {
|
|
49
|
+
ref: C,
|
|
50
|
+
className: "tintora-popover-root",
|
|
51
|
+
children: [s(h, {
|
|
52
|
+
"aria-haspopup": "dialog",
|
|
53
|
+
"aria-expanded": p,
|
|
54
|
+
"aria-controls": p ? S : void 0,
|
|
55
|
+
onClick: D
|
|
56
|
+
}), p && /* @__PURE__ */ a("div", {
|
|
57
|
+
id: S,
|
|
58
|
+
ref: w,
|
|
59
|
+
role: v,
|
|
60
|
+
"aria-label": g,
|
|
61
|
+
popover: "manual",
|
|
62
|
+
tabIndex: -1,
|
|
63
|
+
className: e("tintora-popover", `tintora-popover--${y}`, `tintora-popover--${O?.placement ?? b}`, x),
|
|
64
|
+
style: k,
|
|
65
|
+
children: _
|
|
66
|
+
})]
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
//#endregion
|
|
70
|
+
export { p as Popover };
|