@regardio/react 0.5.7 → 0.7.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/dist/background-slideshow/index.d.mts +34 -0
- package/dist/background-slideshow/index.mjs +110 -0
- package/dist/blurry-gradient/index.d.mts +16 -0
- package/dist/blurry-gradient/index.mjs +93 -0
- package/dist/button/index.d.mts +2 -0
- package/dist/button/index.mjs +3 -0
- package/dist/button-BiSQpBbc.mjs +129 -0
- package/dist/carousel/index.d.mts +74 -0
- package/dist/carousel/index.mjs +136 -0
- package/dist/checkbox/index.d.mts +28 -0
- package/dist/checkbox/index.mjs +70 -0
- package/dist/checkbox-group/index.d.mts +16 -0
- package/dist/checkbox-group/index.mjs +29 -0
- package/dist/chunk-BTpB_u-K.mjs +18 -0
- package/dist/countdown/index.d.mts +4 -0
- package/dist/countdown/index.mjs +58 -0
- package/dist/field/index.d.mts +68 -0
- package/dist/field/index.mjs +115 -0
- package/dist/fieldset/index.d.mts +34 -0
- package/dist/fieldset/index.mjs +61 -0
- package/dist/form/index.d.mts +21 -0
- package/dist/form/index.mjs +31 -0
- package/dist/generic-error/index.d.mts +44 -0
- package/dist/generic-error/index.mjs +57 -0
- package/dist/grid/index.d.mts +101 -0
- package/dist/grid/index.mjs +219 -0
- package/dist/heading/index.d.mts +27 -0
- package/dist/heading/index.mjs +28 -0
- package/dist/highlight/index.d.mts +17 -0
- package/dist/highlight/index.mjs +35 -0
- package/dist/hooks/use-current-route-data.d.mts +8 -0
- package/dist/hooks/use-current-route-data.mjs +22 -0
- package/dist/hooks/{use-focus-search.d.ts → use-focus-search.d.mts} +4 -3
- package/dist/hooks/use-focus-search.mjs +23 -0
- package/dist/hooks/use-matches-data.d.mts +10 -0
- package/dist/hooks/use-matches-data.mjs +23 -0
- package/dist/hooks/use-media-query.d.mts +9 -0
- package/dist/hooks/use-media-query.mjs +28 -0
- package/dist/hooks/use-mobile.d.mts +4 -0
- package/dist/hooks/use-mobile.mjs +22 -0
- package/dist/hooks/use-nonce.d.mts +6 -0
- package/dist/hooks/use-nonce.mjs +13 -0
- package/dist/hooks/use-orientation.d.mts +12 -0
- package/dist/hooks/use-orientation.mjs +32 -0
- package/dist/hooks/use-user.d.mts +53 -0
- package/dist/hooks/use-user.mjs +39 -0
- package/dist/icon-button/index.d.mts +28 -0
- package/dist/icon-button/index.mjs +36 -0
- package/dist/if/index.d.mts +13 -0
- package/dist/if/index.mjs +21 -0
- package/dist/iframe/index.d.mts +11 -0
- package/dist/iframe/index.mjs +15 -0
- package/dist/index-Bj5_XfEC.d.mts +29 -0
- package/dist/index-C_evL5vG.d.mts +35 -0
- package/dist/input/index.d.mts +2 -0
- package/dist/input/index.mjs +3 -0
- package/dist/input-CtR6aRVi.mjs +73 -0
- package/dist/link/index.d.mts +71 -0
- package/dist/link/index.mjs +129 -0
- package/dist/list/index.d.mts +72 -0
- package/dist/list/index.mjs +54 -0
- package/dist/markdown-container/index.d.mts +23 -0
- package/dist/markdown-container/index.mjs +71 -0
- package/dist/password-input/index.d.mts +23 -0
- package/dist/password-input/index.mjs +92 -0
- package/dist/picture/index.d.mts +39 -0
- package/dist/picture/index.mjs +3 -0
- package/dist/picture-DkX3W5zl.mjs +69 -0
- package/dist/protected-email/index.d.mts +24 -0
- package/dist/protected-email/index.mjs +37 -0
- package/dist/radio/index.d.mts +28 -0
- package/dist/radio/index.mjs +72 -0
- package/dist/radio-group/index.d.mts +16 -0
- package/dist/radio-group/index.mjs +29 -0
- package/dist/slider/index.d.mts +63 -0
- package/dist/slider/index.mjs +133 -0
- package/dist/switch/index.d.mts +29 -0
- package/dist/switch/index.mjs +87 -0
- package/dist/text/index.d.mts +25 -0
- package/dist/text/index.mjs +32 -0
- package/dist/text-EQC4zJbE.mjs +52 -0
- package/dist/toggle/index.d.mts +25 -0
- package/dist/toggle/index.mjs +82 -0
- package/dist/utils/author/index.d.mts +4 -0
- package/dist/utils/author/index.mjs +26 -0
- package/dist/utils/text/{index.d.ts → index.d.mts} +9 -8
- package/dist/utils/text/index.mjs +3 -0
- package/package.json +131 -83
- package/src/background-slideshow/background-slideshow.tsx +1 -2
- package/src/blurry-gradient/blurry-gradient.tsx +1 -1
- package/src/button/button.stories.tsx +161 -0
- package/src/button/button.test.tsx +73 -0
- package/src/button/button.tsx +118 -0
- package/src/button/index.ts +2 -0
- package/src/carousel/carousel-content.tsx +17 -14
- package/src/carousel/carousel-item.tsx +18 -18
- package/src/carousel/carousel-next.tsx +22 -17
- package/src/carousel/carousel-previous.tsx +22 -17
- package/src/carousel/carousel-root.tsx +91 -86
- package/src/checkbox/checkbox.stories.tsx +118 -0
- package/src/checkbox/checkbox.tsx +102 -0
- package/src/checkbox/index.ts +2 -0
- package/src/checkbox-group/checkbox-group.tsx +40 -0
- package/src/checkbox-group/index.ts +2 -0
- package/src/countdown/countdown.tsx +1 -1
- package/src/field/field.stories.tsx +105 -0
- package/src/field/field.test.tsx +61 -0
- package/src/field/field.tsx +186 -0
- package/src/field/index.ts +12 -0
- package/src/fieldset/fieldset.stories.tsx +204 -0
- package/src/fieldset/fieldset.test.tsx +63 -0
- package/src/fieldset/fieldset.tsx +86 -0
- package/src/fieldset/index.ts +7 -0
- package/src/form/form.stories.tsx +230 -0
- package/src/form/form.test.tsx +68 -0
- package/src/form/form.tsx +38 -0
- package/src/form/index.ts +2 -0
- package/src/generic-error/generic-error.tsx +2 -3
- package/src/grid/grid-item.tsx +77 -36
- package/src/grid/grid-root.tsx +49 -22
- package/src/heading/heading.tsx +7 -3
- package/src/highlight/highlight.tsx +1 -1
- package/src/hooks/use-current-route-data.ts +4 -2
- package/src/hooks/use-focus-search.ts +3 -1
- package/src/hooks/use-matches-data.ts +2 -0
- package/src/hooks/use-media-query.ts +2 -0
- package/src/hooks/use-mobile.ts +3 -1
- package/src/hooks/use-nonce.ts +3 -3
- package/src/hooks/use-orientation.ts +2 -0
- package/src/hooks/use-user.tsx +3 -2
- package/src/icon-button/icon-button.stories.tsx +128 -7
- package/src/icon-button/icon-button.test.tsx +152 -0
- package/src/icon-button/icon-button.tsx +43 -9
- package/src/if/if.tsx +3 -1
- package/src/input/index.ts +2 -0
- package/src/input/input.stories.tsx +151 -0
- package/src/input/input.test.tsx +65 -0
- package/src/input/input.tsx +113 -0
- package/src/link/link.tsx +4 -3
- package/src/list/list-item.tsx +10 -13
- package/src/list/list-root-context.ts +3 -3
- package/src/list/list-root.tsx +10 -13
- package/src/password-input/index.ts +1 -1
- package/src/password-input/password-input.tsx +104 -27
- package/src/protected-email/protected-email.tsx +6 -1
- package/src/radio/index.ts +2 -0
- package/src/radio/radio.tsx +103 -0
- package/src/radio-group/index.ts +2 -0
- package/src/radio-group/radio-group.tsx +40 -0
- package/src/slider/index.ts +18 -0
- package/src/slider/slider.tsx +201 -0
- package/src/switch/index.ts +2 -0
- package/src/switch/switch.stories.tsx +118 -0
- package/src/switch/switch.tsx +112 -0
- package/src/text/text.tsx +6 -1
- package/src/toggle/index.ts +2 -0
- package/src/toggle/toggle.stories.tsx +232 -0
- package/src/toggle/toggle.test.tsx +149 -0
- package/src/toggle/toggle.tsx +88 -0
- package/src/utils/text/text.tsx +8 -16
- package/dist/background-slideshow/index.d.ts +0 -24
- package/dist/background-slideshow/index.js +0 -165
- package/dist/blurry-gradient/index.d.ts +0 -16
- package/dist/blurry-gradient/index.js +0 -128
- package/dist/carousel/index.d.ts +0 -36
- package/dist/carousel/index.js +0 -171
- package/dist/countdown/index.d.ts +0 -5
- package/dist/countdown/index.js +0 -73
- package/dist/generic-error/index.d.ts +0 -43
- package/dist/generic-error/index.js +0 -47
- package/dist/grid/index.d.ts +0 -1196
- package/dist/grid/index.js +0 -239
- package/dist/heading/index.d.ts +0 -24
- package/dist/heading/index.js +0 -99
- package/dist/highlight/index.d.ts +0 -13
- package/dist/highlight/index.js +0 -59
- package/dist/hooks/use-current-route-data.d.ts +0 -7
- package/dist/hooks/use-current-route-data.js +0 -16
- package/dist/hooks/use-focus-search.js +0 -19
- package/dist/hooks/use-matches-data.d.ts +0 -9
- package/dist/hooks/use-matches-data.js +0 -15
- package/dist/hooks/use-media-query.d.ts +0 -8
- package/dist/hooks/use-media-query.js +0 -20
- package/dist/hooks/use-mobile.d.ts +0 -3
- package/dist/hooks/use-mobile.js +0 -19
- package/dist/hooks/use-nonce.d.ts +0 -7
- package/dist/hooks/use-nonce.js +0 -8
- package/dist/hooks/use-orientation.d.ts +0 -11
- package/dist/hooks/use-orientation.js +0 -29
- package/dist/hooks/use-user.d.ts +0 -50
- package/dist/hooks/use-user.js +0 -25
- package/dist/icon-button/index.d.ts +0 -9
- package/dist/icon-button/index.js +0 -17
- package/dist/if/index.d.ts +0 -10
- package/dist/if/index.js +0 -24
- package/dist/iframe/index.d.ts +0 -10
- package/dist/iframe/index.js +0 -17
- package/dist/link/index.d.ts +0 -55
- package/dist/link/index.js +0 -195
- package/dist/list/index.d.ts +0 -69
- package/dist/list/index.js +0 -65
- package/dist/markdown-container/index.d.ts +0 -22
- package/dist/markdown-container/index.js +0 -128
- package/dist/password-input/index.d.ts +0 -11
- package/dist/password-input/index.js +0 -46
- package/dist/picture/index.d.ts +0 -38
- package/dist/picture/index.js +0 -68
- package/dist/protected-email/index.d.ts +0 -20
- package/dist/protected-email/index.js +0 -30
- package/dist/text/index.d.ts +0 -20
- package/dist/text/index.js +0 -38
- package/dist/utils/author/index.d.ts +0 -3
- package/dist/utils/author/index.js +0 -33
- package/dist/utils/text/index.js +0 -73
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { n as replaceSpecialChars } from "../text-EQC4zJbE.mjs";
|
|
2
|
+
import { cn } from "@regardio/tailwind/utils";
|
|
3
|
+
import { jsx } from "react/jsx-runtime";
|
|
4
|
+
import { MDXProvider } from "@mdx-js/react";
|
|
5
|
+
import Markdown from "markdown-to-jsx";
|
|
6
|
+
|
|
7
|
+
//#region src/markdown-container/markdown-container.tsx
|
|
8
|
+
const doubleNewlineRegex = /\n\n+/;
|
|
9
|
+
function processTextOutsideMDXComponents(text, locale) {
|
|
10
|
+
const mdxTagRegex = /(<\/?[A-Za-z][^>]*>)/g;
|
|
11
|
+
return text.split(mdxTagRegex).map((part) => mdxTagRegex.test(part) ? part : replaceSpecialChars(part, locale)).join("");
|
|
12
|
+
}
|
|
13
|
+
function transformLink(to) {
|
|
14
|
+
const targetDomainSubstring = "regard";
|
|
15
|
+
if (typeof to === "string") try {
|
|
16
|
+
const url = new URL(to);
|
|
17
|
+
if (url.hostname.includes(targetDomainSubstring)) return url.pathname + (url.search ?? "") + (url.hash ?? "");
|
|
18
|
+
return to;
|
|
19
|
+
} catch {
|
|
20
|
+
return to;
|
|
21
|
+
}
|
|
22
|
+
else if (to?.pathname) return to.pathname + (to.search ?? "") + (to.hash ?? "");
|
|
23
|
+
return "";
|
|
24
|
+
}
|
|
25
|
+
const truncateText = (text, maxSentences, maxCharacters, maxParagraphs) => {
|
|
26
|
+
if (maxSentences === void 0 && maxCharacters === void 0 && maxParagraphs === void 0) return text;
|
|
27
|
+
const paragraphs = text.split(doubleNewlineRegex);
|
|
28
|
+
let truncatedText = "";
|
|
29
|
+
let charCount = 0;
|
|
30
|
+
let sentenceCount = 0;
|
|
31
|
+
let paragraphCount = 0;
|
|
32
|
+
for (const paragraph of paragraphs) {
|
|
33
|
+
if (maxParagraphs !== void 0 && paragraphCount >= maxParagraphs) break;
|
|
34
|
+
const sentenceRegex = /(?<!\.\.\.)(?<!\b\w\.)\.(?:\s+|\n+)/g;
|
|
35
|
+
const parts = paragraph.split(sentenceRegex);
|
|
36
|
+
const delimiters = paragraph.match(sentenceRegex) || [];
|
|
37
|
+
for (let i = 0; i < parts.length; i++) {
|
|
38
|
+
const part = parts[i];
|
|
39
|
+
const delimiter = delimiters[i] || "";
|
|
40
|
+
if (part !== void 0) if ((maxSentences === void 0 || sentenceCount < maxSentences) && (maxCharacters === void 0 || charCount + part.length + delimiter.length <= maxCharacters)) {
|
|
41
|
+
truncatedText += part + delimiter;
|
|
42
|
+
charCount += part.length + delimiter.length;
|
|
43
|
+
if (delimiter.includes(".")) sentenceCount++;
|
|
44
|
+
} else break;
|
|
45
|
+
}
|
|
46
|
+
paragraphCount++;
|
|
47
|
+
if (maxSentences !== void 0 && sentenceCount >= maxSentences || maxCharacters !== void 0 && charCount >= maxCharacters) break;
|
|
48
|
+
if (paragraphCount < paragraphs.length) truncatedText += "\n\n";
|
|
49
|
+
}
|
|
50
|
+
return truncatedText.trim();
|
|
51
|
+
};
|
|
52
|
+
const MarkdownContainer = (props) => {
|
|
53
|
+
let processedText = processTextOutsideMDXComponents(props.children?.toString() || "", props.locale);
|
|
54
|
+
if (Number.isInteger(props.sentences) || Number.isInteger(props.characters) || Number.isInteger(props.paragraphs)) processedText = truncateText(processedText, props.sentences, props.characters, props.paragraphs);
|
|
55
|
+
return /* @__PURE__ */ jsx(MDXProvider, {
|
|
56
|
+
components: props.mdxComponents,
|
|
57
|
+
children: /* @__PURE__ */ jsx(Markdown, {
|
|
58
|
+
className: cn("markdown", props.className),
|
|
59
|
+
options: {
|
|
60
|
+
disableParsingRawHTML: false,
|
|
61
|
+
forceWrapper: true,
|
|
62
|
+
tagfilter: false,
|
|
63
|
+
...props.markdownOverrides ? { overrides: props.markdownOverrides } : {}
|
|
64
|
+
},
|
|
65
|
+
children: processedText
|
|
66
|
+
})
|
|
67
|
+
});
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
//#endregion
|
|
71
|
+
export { MarkdownContainer, transformLink };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { t as Input } from "../index-Bj5_XfEC.mjs";
|
|
2
|
+
|
|
3
|
+
//#region src/password-input/password-input.d.ts
|
|
4
|
+
declare const passwordInputVariants: {
|
|
5
|
+
readonly default: readonly [];
|
|
6
|
+
readonly withToggle: readonly [];
|
|
7
|
+
};
|
|
8
|
+
type PasswordInputVariant = keyof typeof passwordInputVariants;
|
|
9
|
+
interface PasswordInputProps extends Omit<React.ComponentProps<typeof Input>, "type" | "variant"> {
|
|
10
|
+
className?: string;
|
|
11
|
+
variant?: PasswordInputVariant;
|
|
12
|
+
inputVariant?: "default" | "error" | "success";
|
|
13
|
+
showToggle?: boolean;
|
|
14
|
+
}
|
|
15
|
+
declare const PasswordInput: ({
|
|
16
|
+
className,
|
|
17
|
+
variant,
|
|
18
|
+
inputVariant,
|
|
19
|
+
showToggle,
|
|
20
|
+
...props
|
|
21
|
+
}: PasswordInputProps) => React.JSX.Element;
|
|
22
|
+
//#endregion
|
|
23
|
+
export { PasswordInput, type PasswordInputProps };
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { t as Button } from "../button-BiSQpBbc.mjs";
|
|
2
|
+
import { t as Input } from "../input-CtR6aRVi.mjs";
|
|
3
|
+
import { useState } from "react";
|
|
4
|
+
import { tv } from "@regardio/tailwind/utils";
|
|
5
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
6
|
+
|
|
7
|
+
//#region src/password-input/password-input.tsx
|
|
8
|
+
const passwordInput = tv({
|
|
9
|
+
base: ["relative"],
|
|
10
|
+
defaultVariants: { variant: "default" },
|
|
11
|
+
variants: { variant: {
|
|
12
|
+
default: [],
|
|
13
|
+
withToggle: []
|
|
14
|
+
} }
|
|
15
|
+
});
|
|
16
|
+
const toggleButton = tv({ base: [
|
|
17
|
+
"absolute",
|
|
18
|
+
"right-3",
|
|
19
|
+
"top-1/2",
|
|
20
|
+
"-translate-y-1/2",
|
|
21
|
+
"flex",
|
|
22
|
+
"h-5",
|
|
23
|
+
"w-5",
|
|
24
|
+
"cursor-pointer",
|
|
25
|
+
"items-center",
|
|
26
|
+
"justify-center",
|
|
27
|
+
"text-gray-500",
|
|
28
|
+
"hover:text-gray-700",
|
|
29
|
+
"focus:outline-none",
|
|
30
|
+
"focus:ring-2",
|
|
31
|
+
"focus:ring-blue-500",
|
|
32
|
+
"focus:ring-offset-2",
|
|
33
|
+
"rounded",
|
|
34
|
+
"transition-colors",
|
|
35
|
+
"duration-200"
|
|
36
|
+
] });
|
|
37
|
+
const PasswordInput = ({ className, variant = "default", inputVariant = "default", showToggle = true, ...props }) => {
|
|
38
|
+
const [showPassword, setShowPassword] = useState(false);
|
|
39
|
+
const togglePasswordVisibility = () => {
|
|
40
|
+
setShowPassword(!showPassword);
|
|
41
|
+
};
|
|
42
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
43
|
+
className: passwordInput({
|
|
44
|
+
className,
|
|
45
|
+
variant
|
|
46
|
+
}),
|
|
47
|
+
children: [/* @__PURE__ */ jsx(Input, {
|
|
48
|
+
autoComplete: "off",
|
|
49
|
+
className: showToggle ? "pr-10" : "",
|
|
50
|
+
type: showPassword ? "text" : "password",
|
|
51
|
+
variant: inputVariant,
|
|
52
|
+
...props
|
|
53
|
+
}), showToggle && /* @__PURE__ */ jsx(Button, {
|
|
54
|
+
"aria-label": showPassword ? "Hide password" : "Show password",
|
|
55
|
+
className: toggleButton(),
|
|
56
|
+
onClick: togglePasswordVisibility,
|
|
57
|
+
size: "sm",
|
|
58
|
+
variant: "ghost",
|
|
59
|
+
children: showPassword ? /* @__PURE__ */ jsx("svg", {
|
|
60
|
+
className: "h-4 w-4",
|
|
61
|
+
fill: "none",
|
|
62
|
+
stroke: "currentColor",
|
|
63
|
+
viewBox: "0 0 24 24",
|
|
64
|
+
children: /* @__PURE__ */ jsx("path", {
|
|
65
|
+
d: "M13.875 18.825A10.05 10.05 0 0112 19c-4.478 0-8.268-2.943-9.543-7a9.97 9.97 0 011.563-3.029m5.858.908a3 3 0 114.243 4.243M9.878 9.878l4.242 4.242M9.88 9.88l-3.29-3.29m7.532 7.532l3.29 3.29M3 3l3.59 3.59m0 0A9.953 9.953 0 0112 5c4.478 0 8.268 2.943 9.543 7a10.025 10.025 0 01-4.132 5.411m0 0L21 21",
|
|
66
|
+
strokeLinecap: "round",
|
|
67
|
+
strokeLinejoin: "round",
|
|
68
|
+
strokeWidth: 2
|
|
69
|
+
})
|
|
70
|
+
}) : /* @__PURE__ */ jsxs("svg", {
|
|
71
|
+
className: "h-4 w-4",
|
|
72
|
+
fill: "none",
|
|
73
|
+
stroke: "currentColor",
|
|
74
|
+
viewBox: "0 0 24 24",
|
|
75
|
+
children: [/* @__PURE__ */ jsx("path", {
|
|
76
|
+
d: "M15 12a3 3 0 11-6 0 3 3 0 016 0z",
|
|
77
|
+
strokeLinecap: "round",
|
|
78
|
+
strokeLinejoin: "round",
|
|
79
|
+
strokeWidth: 2
|
|
80
|
+
}), /* @__PURE__ */ jsx("path", {
|
|
81
|
+
d: "M2.458 12C3.732 7.943 7.523 5 12 5c4.478 0 8.268 2.943 9.542 7-1.274 4.057-5.064 7-9.542 7-4.477 0-8.268-2.943-9.542-7z",
|
|
82
|
+
strokeLinecap: "round",
|
|
83
|
+
strokeLinejoin: "round",
|
|
84
|
+
strokeWidth: 2
|
|
85
|
+
})]
|
|
86
|
+
})
|
|
87
|
+
})]
|
|
88
|
+
});
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
//#endregion
|
|
92
|
+
export { PasswordInput };
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
|
|
3
|
+
//#region src/picture/picture.d.ts
|
|
4
|
+
declare const screenSizeVariants: {
|
|
5
|
+
readonly lg: 1280;
|
|
6
|
+
readonly max: 1920;
|
|
7
|
+
readonly md: 960;
|
|
8
|
+
readonly min: 360;
|
|
9
|
+
readonly sm: 640;
|
|
10
|
+
readonly xl: 1600;
|
|
11
|
+
readonly xs: 480;
|
|
12
|
+
};
|
|
13
|
+
type ImageFormat = {
|
|
14
|
+
size: string;
|
|
15
|
+
width: number;
|
|
16
|
+
};
|
|
17
|
+
interface PictureProps {
|
|
18
|
+
alt: string;
|
|
19
|
+
baseUrl: string;
|
|
20
|
+
className?: string;
|
|
21
|
+
formats?: ImageFormat[];
|
|
22
|
+
imgClassName?: string;
|
|
23
|
+
placeholder?: string;
|
|
24
|
+
sizes?: string;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Generic Picture component that works with any image provider
|
|
28
|
+
*
|
|
29
|
+
* @param alt - Alt text for the image
|
|
30
|
+
* @param baseUrl - Base URL with optional placeholder (e.g., 'https://example.com/images/{format}/image.jpg')
|
|
31
|
+
* @param className - Optional class for the picture element
|
|
32
|
+
* @param formats - Custom formats with size and width
|
|
33
|
+
* @param imgClassName - Optional class for the img element
|
|
34
|
+
* @param placeholder - Placeholder to replace in baseUrl (default: '{format}')
|
|
35
|
+
* @param sizes - Custom sizes attribute
|
|
36
|
+
*/
|
|
37
|
+
declare const Picture: React.FC<PictureProps>;
|
|
38
|
+
//#endregion
|
|
39
|
+
export { type ImageFormat, Picture, type PictureProps, screenSizeVariants };
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { cn } from "@regardio/tailwind/utils";
|
|
2
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
|
|
4
|
+
//#region src/picture/picture.tsx
|
|
5
|
+
const screenSizeVariants = {
|
|
6
|
+
lg: 1280,
|
|
7
|
+
max: 1920,
|
|
8
|
+
md: 960,
|
|
9
|
+
min: 360,
|
|
10
|
+
sm: 640,
|
|
11
|
+
xl: 1600,
|
|
12
|
+
xs: 480
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* Generic Picture component that works with any image provider
|
|
16
|
+
*
|
|
17
|
+
* @param alt - Alt text for the image
|
|
18
|
+
* @param baseUrl - Base URL with optional placeholder (e.g., 'https://example.com/images/{format}/image.jpg')
|
|
19
|
+
* @param className - Optional class for the picture element
|
|
20
|
+
* @param formats - Custom formats with size and width
|
|
21
|
+
* @param imgClassName - Optional class for the img element
|
|
22
|
+
* @param placeholder - Placeholder to replace in baseUrl (default: '{format}')
|
|
23
|
+
* @param sizes - Custom sizes attribute
|
|
24
|
+
*/
|
|
25
|
+
const Picture = ({ alt, baseUrl, className, formats, imgClassName, placeholder = "{format}", sizes = "(max-width: 480px) 480px, (max-width: 768px) 600px, (max-width: 1200px) 1024px, 1920px" }) => {
|
|
26
|
+
const imageFormats = formats || [
|
|
27
|
+
{
|
|
28
|
+
size: "480x360",
|
|
29
|
+
width: 480
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
size: "600x600",
|
|
33
|
+
width: 600
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
size: "1024x768",
|
|
37
|
+
width: 1024
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
size: "1920x1440",
|
|
41
|
+
width: 1920
|
|
42
|
+
}
|
|
43
|
+
];
|
|
44
|
+
if (imageFormats.length === 0) return null;
|
|
45
|
+
if (imageFormats.length === 1 && imageFormats[0]?.size === "" || !baseUrl.includes(placeholder)) return /* @__PURE__ */ jsx("img", {
|
|
46
|
+
alt,
|
|
47
|
+
className: cn(className, imgClassName),
|
|
48
|
+
src: baseUrl
|
|
49
|
+
});
|
|
50
|
+
const srcSet = imageFormats.map(({ size, width }) => {
|
|
51
|
+
return `${baseUrl.replace(placeholder, size)} ${width}w`;
|
|
52
|
+
}).join(", ");
|
|
53
|
+
const defaultFormat = imageFormats[0];
|
|
54
|
+
const defaultSrc = defaultFormat ? baseUrl.replace(placeholder, defaultFormat.size) : baseUrl;
|
|
55
|
+
return /* @__PURE__ */ jsxs("picture", {
|
|
56
|
+
className,
|
|
57
|
+
children: [/* @__PURE__ */ jsx("source", {
|
|
58
|
+
sizes,
|
|
59
|
+
srcSet
|
|
60
|
+
}), /* @__PURE__ */ jsx("img", {
|
|
61
|
+
alt,
|
|
62
|
+
className: cn(imgClassName),
|
|
63
|
+
src: defaultSrc
|
|
64
|
+
})]
|
|
65
|
+
});
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
//#endregion
|
|
69
|
+
export { screenSizeVariants as n, Picture as t };
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
//#region src/protected-email/protected-email.d.ts
|
|
2
|
+
interface ProtectedEmailProps {
|
|
3
|
+
username: string;
|
|
4
|
+
domain: string;
|
|
5
|
+
text?: string;
|
|
6
|
+
className?: string;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* ProtectedEmail component that obfuscates email addresses to protect from scrapers.
|
|
10
|
+
* The email is only assembled client-side with JavaScript, making it harder for scrapers to extract.
|
|
11
|
+
*
|
|
12
|
+
* @param username - The part before the @ symbol
|
|
13
|
+
* @param domain - The part after the @ symbol
|
|
14
|
+
* @param text - Optional display text (defaults to username(at)domain)
|
|
15
|
+
* @param className - Optional CSS class name
|
|
16
|
+
*/
|
|
17
|
+
declare function ProtectedEmail({
|
|
18
|
+
username,
|
|
19
|
+
domain,
|
|
20
|
+
text,
|
|
21
|
+
className
|
|
22
|
+
}: ProtectedEmailProps): React.JSX.Element;
|
|
23
|
+
//#endregion
|
|
24
|
+
export { ProtectedEmail, type ProtectedEmailProps };
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { useEffect, useState } from "react";
|
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
|
3
|
+
|
|
4
|
+
//#region src/protected-email/protected-email.tsx
|
|
5
|
+
/**
|
|
6
|
+
* ProtectedEmail component that obfuscates email addresses to protect from scrapers.
|
|
7
|
+
* The email is only assembled client-side with JavaScript, making it harder for scrapers to extract.
|
|
8
|
+
*
|
|
9
|
+
* @param username - The part before the @ symbol
|
|
10
|
+
* @param domain - The part after the @ symbol
|
|
11
|
+
* @param text - Optional display text (defaults to username(at)domain)
|
|
12
|
+
* @param className - Optional CSS class name
|
|
13
|
+
*/
|
|
14
|
+
function ProtectedEmail({ username, domain, text, className }) {
|
|
15
|
+
const [mounted, setMounted] = useState(false);
|
|
16
|
+
useEffect(() => {
|
|
17
|
+
setMounted(true);
|
|
18
|
+
}, []);
|
|
19
|
+
const fallbackText = text || `${username}(at)${domain}`;
|
|
20
|
+
const handleClick = (e) => {
|
|
21
|
+
if (mounted) {
|
|
22
|
+
window.location.href = `mailto:${username}@${domain}`;
|
|
23
|
+
e.preventDefault();
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
return /* @__PURE__ */ jsx("a", {
|
|
27
|
+
"aria-label": `Email address: ${username} at ${domain}`,
|
|
28
|
+
className,
|
|
29
|
+
"data-email-protected": "true",
|
|
30
|
+
href: mounted ? "#email-protected" : void 0,
|
|
31
|
+
onClick: handleClick,
|
|
32
|
+
children: fallbackText
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
//#endregion
|
|
37
|
+
export { ProtectedEmail };
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { ComponentProps } from "react";
|
|
2
|
+
import { Radio as Radio$1 } from "@base-ui/react/radio";
|
|
3
|
+
|
|
4
|
+
//#region src/radio/radio.d.ts
|
|
5
|
+
type RadioSize = "sm" | "md" | "lg";
|
|
6
|
+
interface RadioRootProps extends Omit<ComponentProps<typeof Radio$1.Root>, "className"> {
|
|
7
|
+
className?: string;
|
|
8
|
+
size?: RadioSize;
|
|
9
|
+
}
|
|
10
|
+
interface RadioIndicatorProps extends Omit<ComponentProps<typeof Radio$1.Indicator>, "className"> {
|
|
11
|
+
className?: string;
|
|
12
|
+
}
|
|
13
|
+
declare const RadioRoot: ({
|
|
14
|
+
className,
|
|
15
|
+
size,
|
|
16
|
+
...props
|
|
17
|
+
}: RadioRootProps) => React.JSX.Element;
|
|
18
|
+
declare const RadioIndicator: ({
|
|
19
|
+
className,
|
|
20
|
+
children,
|
|
21
|
+
...props
|
|
22
|
+
}: RadioIndicatorProps) => React.JSX.Element;
|
|
23
|
+
declare const Radio: {
|
|
24
|
+
Indicator: typeof RadioIndicator;
|
|
25
|
+
Root: typeof RadioRoot;
|
|
26
|
+
};
|
|
27
|
+
//#endregion
|
|
28
|
+
export { Radio, RadioIndicator, type RadioIndicatorProps, RadioRoot, type RadioRootProps, type RadioSize };
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { tv } from "@regardio/tailwind/utils";
|
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
|
3
|
+
import { Radio as Radio$1 } from "@base-ui/react/radio";
|
|
4
|
+
|
|
5
|
+
//#region src/radio/radio.tsx
|
|
6
|
+
const radioRoot = tv({
|
|
7
|
+
base: [
|
|
8
|
+
"h-4",
|
|
9
|
+
"w-4",
|
|
10
|
+
"rounded-full",
|
|
11
|
+
"border",
|
|
12
|
+
"border-gray-300",
|
|
13
|
+
"bg-white",
|
|
14
|
+
"focus:outline-none",
|
|
15
|
+
"focus:ring-2",
|
|
16
|
+
"focus:ring-blue-500",
|
|
17
|
+
"focus:ring-offset-2",
|
|
18
|
+
"disabled:cursor-not-allowed",
|
|
19
|
+
"disabled:opacity-50",
|
|
20
|
+
"data-[checked]:bg-blue-600",
|
|
21
|
+
"data-[checked]:border-blue-600",
|
|
22
|
+
"transition-colors",
|
|
23
|
+
"duration-200",
|
|
24
|
+
"cursor-pointer"
|
|
25
|
+
],
|
|
26
|
+
defaultVariants: { size: "md" },
|
|
27
|
+
variants: { size: {
|
|
28
|
+
lg: ["h-5", "w-5"],
|
|
29
|
+
md: ["h-4", "w-4"],
|
|
30
|
+
sm: ["h-3", "w-3"]
|
|
31
|
+
} }
|
|
32
|
+
});
|
|
33
|
+
const radioIndicator = tv({ base: [
|
|
34
|
+
"flex",
|
|
35
|
+
"items-center",
|
|
36
|
+
"justify-center",
|
|
37
|
+
"text-white",
|
|
38
|
+
"data-[unchecked]:invisible"
|
|
39
|
+
] });
|
|
40
|
+
const RadioRoot = ({ className, size = "md", ...props }) => {
|
|
41
|
+
return /* @__PURE__ */ jsx(Radio$1.Root, {
|
|
42
|
+
className: radioRoot({
|
|
43
|
+
className,
|
|
44
|
+
size
|
|
45
|
+
}),
|
|
46
|
+
...props
|
|
47
|
+
});
|
|
48
|
+
};
|
|
49
|
+
const RadioIndicator = ({ className, children, ...props }) => {
|
|
50
|
+
return /* @__PURE__ */ jsx(Radio$1.Indicator, {
|
|
51
|
+
className: radioIndicator({ className }),
|
|
52
|
+
...props,
|
|
53
|
+
children: children || /* @__PURE__ */ jsx("svg", {
|
|
54
|
+
fill: "currentColor",
|
|
55
|
+
height: "8",
|
|
56
|
+
viewBox: "0 0 8 8",
|
|
57
|
+
width: "8",
|
|
58
|
+
children: /* @__PURE__ */ jsx("circle", {
|
|
59
|
+
cx: "4",
|
|
60
|
+
cy: "4",
|
|
61
|
+
r: "3"
|
|
62
|
+
})
|
|
63
|
+
})
|
|
64
|
+
});
|
|
65
|
+
};
|
|
66
|
+
const Radio = {
|
|
67
|
+
Indicator: RadioIndicator,
|
|
68
|
+
Root: RadioRoot
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
//#endregion
|
|
72
|
+
export { Radio, RadioIndicator, RadioRoot };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { ComponentProps } from "react";
|
|
2
|
+
import { RadioGroup as RadioGroup$1 } from "@base-ui/react/radio-group";
|
|
3
|
+
|
|
4
|
+
//#region src/radio-group/radio-group.d.ts
|
|
5
|
+
type RadioGroupOrientation = "horizontal" | "vertical";
|
|
6
|
+
interface RadioGroupProps extends Omit<ComponentProps<typeof RadioGroup$1>, "className"> {
|
|
7
|
+
className?: string;
|
|
8
|
+
orientation?: RadioGroupOrientation;
|
|
9
|
+
}
|
|
10
|
+
declare const RadioGroup: ({
|
|
11
|
+
className,
|
|
12
|
+
orientation,
|
|
13
|
+
...props
|
|
14
|
+
}: RadioGroupProps) => React.JSX.Element;
|
|
15
|
+
//#endregion
|
|
16
|
+
export { RadioGroup, type RadioGroupOrientation, type RadioGroupProps };
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { tv } from "@regardio/tailwind/utils";
|
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
|
3
|
+
import { RadioGroup as RadioGroup$1 } from "@base-ui/react/radio-group";
|
|
4
|
+
|
|
5
|
+
//#region src/radio-group/radio-group.tsx
|
|
6
|
+
const radioGroup = tv({
|
|
7
|
+
base: [
|
|
8
|
+
"flex",
|
|
9
|
+
"flex-col",
|
|
10
|
+
"gap-2"
|
|
11
|
+
],
|
|
12
|
+
defaultVariants: { orientation: "vertical" },
|
|
13
|
+
variants: { orientation: {
|
|
14
|
+
horizontal: ["flex-row", "gap-4"],
|
|
15
|
+
vertical: ["flex-col", "gap-2"]
|
|
16
|
+
} }
|
|
17
|
+
});
|
|
18
|
+
const RadioGroup = ({ className, orientation = "vertical", ...props }) => {
|
|
19
|
+
return /* @__PURE__ */ jsx(RadioGroup$1, {
|
|
20
|
+
className: radioGroup({
|
|
21
|
+
className,
|
|
22
|
+
orientation
|
|
23
|
+
}),
|
|
24
|
+
...props
|
|
25
|
+
});
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
//#endregion
|
|
29
|
+
export { RadioGroup };
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { ComponentProps } from "react";
|
|
2
|
+
import { Slider as Slider$1 } from "@base-ui/react/slider";
|
|
3
|
+
|
|
4
|
+
//#region src/slider/slider.d.ts
|
|
5
|
+
type SliderSize = "sm" | "md" | "lg";
|
|
6
|
+
interface SliderRootProps extends Omit<ComponentProps<typeof Slider$1.Root>, "className"> {
|
|
7
|
+
className?: string;
|
|
8
|
+
size?: SliderSize;
|
|
9
|
+
}
|
|
10
|
+
interface SliderControlProps extends Omit<ComponentProps<typeof Slider$1.Control>, "className"> {
|
|
11
|
+
className?: string;
|
|
12
|
+
}
|
|
13
|
+
interface SliderTrackProps extends Omit<ComponentProps<typeof Slider$1.Track>, "className"> {
|
|
14
|
+
className?: string;
|
|
15
|
+
size?: SliderSize;
|
|
16
|
+
}
|
|
17
|
+
interface SliderIndicatorProps extends Omit<ComponentProps<typeof Slider$1.Indicator>, "className"> {
|
|
18
|
+
className?: string;
|
|
19
|
+
}
|
|
20
|
+
interface SliderThumbProps extends Omit<ComponentProps<typeof Slider$1.Thumb>, "className"> {
|
|
21
|
+
className?: string;
|
|
22
|
+
size?: SliderSize;
|
|
23
|
+
}
|
|
24
|
+
interface SliderValueProps extends Omit<ComponentProps<typeof Slider$1.Value>, "className"> {
|
|
25
|
+
className?: string;
|
|
26
|
+
}
|
|
27
|
+
declare const SliderRoot: ({
|
|
28
|
+
className,
|
|
29
|
+
size,
|
|
30
|
+
...props
|
|
31
|
+
}: SliderRootProps) => React.JSX.Element;
|
|
32
|
+
declare const SliderControl: ({
|
|
33
|
+
className,
|
|
34
|
+
...props
|
|
35
|
+
}: SliderControlProps) => React.JSX.Element;
|
|
36
|
+
declare const SliderTrack: ({
|
|
37
|
+
className,
|
|
38
|
+
size,
|
|
39
|
+
...props
|
|
40
|
+
}: SliderTrackProps) => React.JSX.Element;
|
|
41
|
+
declare const SliderIndicator: ({
|
|
42
|
+
className,
|
|
43
|
+
...props
|
|
44
|
+
}: SliderIndicatorProps) => React.JSX.Element;
|
|
45
|
+
declare const SliderThumb: ({
|
|
46
|
+
className,
|
|
47
|
+
size,
|
|
48
|
+
...props
|
|
49
|
+
}: SliderThumbProps) => React.JSX.Element;
|
|
50
|
+
declare const SliderValue: ({
|
|
51
|
+
className,
|
|
52
|
+
...props
|
|
53
|
+
}: SliderValueProps) => React.JSX.Element;
|
|
54
|
+
declare const Slider: {
|
|
55
|
+
Control: typeof SliderControl;
|
|
56
|
+
Indicator: typeof SliderIndicator;
|
|
57
|
+
Root: typeof SliderRoot;
|
|
58
|
+
Thumb: typeof SliderThumb;
|
|
59
|
+
Track: typeof SliderTrack;
|
|
60
|
+
Value: typeof SliderValue;
|
|
61
|
+
};
|
|
62
|
+
//#endregion
|
|
63
|
+
export { Slider, SliderControl, type SliderControlProps, SliderIndicator, type SliderIndicatorProps, SliderRoot, type SliderRootProps, type SliderSize, SliderThumb, type SliderThumbProps, SliderTrack, type SliderTrackProps, SliderValue, type SliderValueProps };
|