489 lines
12 KiB
JavaScript
489 lines
12 KiB
JavaScript
import { jsx } from "react/jsx-runtime";
|
|
import { Slot } from "@radix-ui/react-slot";
|
|
import { cva } from "class-variance-authority";
|
|
import { clsx } from "clsx";
|
|
import { twMerge } from "tailwind-merge";
|
|
function cn(...inputs) {
|
|
return twMerge(clsx(inputs));
|
|
}
|
|
const buttonVariants = cva(
|
|
"inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-[color,box-shadow] disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 [&_svg]:shrink-0 outline-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive",
|
|
{
|
|
variants: {
|
|
variant: {
|
|
default: "bg-primary text-primary-foreground shadow-xs hover:bg-primary/90",
|
|
destructive: "bg-destructive text-white shadow-xs hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40",
|
|
outline: "border border-input bg-background shadow-xs hover:bg-accent hover:text-accent-foreground",
|
|
secondary: "bg-secondary text-secondary-foreground shadow-xs hover:bg-secondary/80",
|
|
ghost: "hover:bg-accent hover:text-accent-foreground",
|
|
link: "text-primary underline-offset-4 hover:underline"
|
|
},
|
|
size: {
|
|
default: "h-9 px-4 py-2 has-[>svg]:px-3",
|
|
sm: "h-8 rounded-md px-3 has-[>svg]:px-2.5",
|
|
lg: "h-10 rounded-md px-6 has-[>svg]:px-4",
|
|
icon: "size-9"
|
|
}
|
|
},
|
|
defaultVariants: {
|
|
variant: "default",
|
|
size: "default"
|
|
}
|
|
}
|
|
);
|
|
function Button({
|
|
className,
|
|
variant,
|
|
size,
|
|
asChild = false,
|
|
...props
|
|
}) {
|
|
const Comp = asChild ? Slot : "button";
|
|
return /* @__PURE__ */ jsx(
|
|
Comp,
|
|
{
|
|
"data-slot": "button",
|
|
className: cn(buttonVariants({ variant, size, className })),
|
|
...props
|
|
}
|
|
);
|
|
}
|
|
let urlDefaults = {};
|
|
const queryParams = (options) => {
|
|
if (!options || !options.query && !options.mergeQuery) {
|
|
return "";
|
|
}
|
|
const query = options.query ?? options.mergeQuery;
|
|
const includeExisting = options.mergeQuery !== void 0;
|
|
const getValue = (value) => {
|
|
if (value === true) {
|
|
return "1";
|
|
}
|
|
if (value === false) {
|
|
return "0";
|
|
}
|
|
return value.toString();
|
|
};
|
|
const params = new URLSearchParams(
|
|
includeExisting && typeof window !== "undefined" ? window.location.search : ""
|
|
);
|
|
for (const key in query) {
|
|
if (query[key] === void 0 || query[key] === null) {
|
|
params.delete(key);
|
|
continue;
|
|
}
|
|
if (Array.isArray(query[key])) {
|
|
if (params.has(`${key}[]`)) {
|
|
params.delete(`${key}[]`);
|
|
}
|
|
query[key].forEach((value) => {
|
|
params.append(`${key}[]`, value.toString());
|
|
});
|
|
} else if (typeof query[key] === "object") {
|
|
params.forEach((_, paramKey) => {
|
|
if (paramKey.startsWith(`${key}[`)) {
|
|
params.delete(paramKey);
|
|
}
|
|
});
|
|
for (const subKey in query[key]) {
|
|
if (typeof query[key][subKey] === "undefined") {
|
|
continue;
|
|
}
|
|
if (["string", "number", "boolean"].includes(
|
|
typeof query[key][subKey]
|
|
)) {
|
|
params.set(
|
|
`${key}[${subKey}]`,
|
|
getValue(query[key][subKey])
|
|
);
|
|
}
|
|
}
|
|
} else {
|
|
params.set(key, getValue(query[key]));
|
|
}
|
|
}
|
|
const str = params.toString();
|
|
return str.length > 0 ? `?${str}` : "";
|
|
};
|
|
const applyUrlDefaults = (existing) => {
|
|
const existingParams = { ...existing ?? {} };
|
|
for (const key in urlDefaults) {
|
|
if (existingParams[key] === void 0 && urlDefaults[key] !== void 0) {
|
|
existingParams[key] = urlDefaults[key];
|
|
}
|
|
}
|
|
return existingParams;
|
|
};
|
|
const login = (options) => ({
|
|
url: login.url(options),
|
|
method: "get"
|
|
});
|
|
login.definition = {
|
|
methods: ["get", "head"],
|
|
url: "/login"
|
|
};
|
|
login.url = (options) => {
|
|
return login.definition.url + queryParams(options);
|
|
};
|
|
login.get = (options) => ({
|
|
url: login.url(options),
|
|
method: "get"
|
|
});
|
|
login.head = (options) => ({
|
|
url: login.url(options),
|
|
method: "head"
|
|
});
|
|
const loginForm = (options) => ({
|
|
action: login.url(options),
|
|
method: "get"
|
|
});
|
|
loginForm.get = (options) => ({
|
|
action: login.url(options),
|
|
method: "get"
|
|
});
|
|
loginForm.head = (options) => ({
|
|
action: login.url({
|
|
[options?.mergeQuery ? "mergeQuery" : "query"]: {
|
|
_method: "HEAD",
|
|
...options?.query ?? options?.mergeQuery ?? {}
|
|
}
|
|
}),
|
|
method: "get"
|
|
});
|
|
login.form = loginForm;
|
|
const logout = (options) => ({
|
|
url: logout.url(options),
|
|
method: "post"
|
|
});
|
|
logout.definition = {
|
|
methods: ["post"],
|
|
url: "/logout"
|
|
};
|
|
logout.url = (options) => {
|
|
return logout.definition.url + queryParams(options);
|
|
};
|
|
logout.post = (options) => ({
|
|
url: logout.url(options),
|
|
method: "post"
|
|
});
|
|
const logoutForm = (options) => ({
|
|
action: logout.url(options),
|
|
method: "post"
|
|
});
|
|
logoutForm.post = (options) => ({
|
|
action: logout.url(options),
|
|
method: "post"
|
|
});
|
|
logout.form = logoutForm;
|
|
const home = (options) => ({
|
|
url: home.url(options),
|
|
method: "get"
|
|
});
|
|
home.definition = {
|
|
methods: ["get", "head"],
|
|
url: "/"
|
|
};
|
|
home.url = (options) => {
|
|
return home.definition.url + queryParams(options);
|
|
};
|
|
home.get = (options) => ({
|
|
url: home.url(options),
|
|
method: "get"
|
|
});
|
|
home.head = (options) => ({
|
|
url: home.url(options),
|
|
method: "head"
|
|
});
|
|
const homeForm = (options) => ({
|
|
action: home.url(options),
|
|
method: "get"
|
|
});
|
|
homeForm.get = (options) => ({
|
|
action: home.url(options),
|
|
method: "get"
|
|
});
|
|
homeForm.head = (options) => ({
|
|
action: home.url({
|
|
[options?.mergeQuery ? "mergeQuery" : "query"]: {
|
|
_method: "HEAD",
|
|
...options?.query ?? options?.mergeQuery ?? {}
|
|
}
|
|
}),
|
|
method: "get"
|
|
});
|
|
home.form = homeForm;
|
|
const about = (options) => ({
|
|
url: about.url(options),
|
|
method: "get"
|
|
});
|
|
about.definition = {
|
|
methods: ["get", "head"],
|
|
url: "/about-us"
|
|
};
|
|
about.url = (options) => {
|
|
return about.definition.url + queryParams(options);
|
|
};
|
|
about.get = (options) => ({
|
|
url: about.url(options),
|
|
method: "get"
|
|
});
|
|
about.head = (options) => ({
|
|
url: about.url(options),
|
|
method: "head"
|
|
});
|
|
const aboutForm = (options) => ({
|
|
action: about.url(options),
|
|
method: "get"
|
|
});
|
|
aboutForm.get = (options) => ({
|
|
action: about.url(options),
|
|
method: "get"
|
|
});
|
|
aboutForm.head = (options) => ({
|
|
action: about.url({
|
|
[options?.mergeQuery ? "mergeQuery" : "query"]: {
|
|
_method: "HEAD",
|
|
...options?.query ?? options?.mergeQuery ?? {}
|
|
}
|
|
}),
|
|
method: "get"
|
|
});
|
|
about.form = aboutForm;
|
|
const artOfWeaving = (options) => ({
|
|
url: artOfWeaving.url(options),
|
|
method: "get"
|
|
});
|
|
artOfWeaving.definition = {
|
|
methods: ["get", "head"],
|
|
url: "/art-of-weaving"
|
|
};
|
|
artOfWeaving.url = (options) => {
|
|
return artOfWeaving.definition.url + queryParams(options);
|
|
};
|
|
artOfWeaving.get = (options) => ({
|
|
url: artOfWeaving.url(options),
|
|
method: "get"
|
|
});
|
|
artOfWeaving.head = (options) => ({
|
|
url: artOfWeaving.url(options),
|
|
method: "head"
|
|
});
|
|
const artOfWeavingForm = (options) => ({
|
|
action: artOfWeaving.url(options),
|
|
method: "get"
|
|
});
|
|
artOfWeavingForm.get = (options) => ({
|
|
action: artOfWeaving.url(options),
|
|
method: "get"
|
|
});
|
|
artOfWeavingForm.head = (options) => ({
|
|
action: artOfWeaving.url({
|
|
[options?.mergeQuery ? "mergeQuery" : "query"]: {
|
|
_method: "HEAD",
|
|
...options?.query ?? options?.mergeQuery ?? {}
|
|
}
|
|
}),
|
|
method: "get"
|
|
});
|
|
artOfWeaving.form = artOfWeavingForm;
|
|
const contact = (options) => ({
|
|
url: contact.url(options),
|
|
method: "get"
|
|
});
|
|
contact.definition = {
|
|
methods: ["get", "head"],
|
|
url: "/contact"
|
|
};
|
|
contact.url = (options) => {
|
|
return contact.definition.url + queryParams(options);
|
|
};
|
|
contact.get = (options) => ({
|
|
url: contact.url(options),
|
|
method: "get"
|
|
});
|
|
contact.head = (options) => ({
|
|
url: contact.url(options),
|
|
method: "head"
|
|
});
|
|
const contactForm = (options) => ({
|
|
action: contact.url(options),
|
|
method: "get"
|
|
});
|
|
contactForm.get = (options) => ({
|
|
action: contact.url(options),
|
|
method: "get"
|
|
});
|
|
contactForm.head = (options) => ({
|
|
action: contact.url({
|
|
[options?.mergeQuery ? "mergeQuery" : "query"]: {
|
|
_method: "HEAD",
|
|
...options?.query ?? options?.mergeQuery ?? {}
|
|
}
|
|
}),
|
|
method: "get"
|
|
});
|
|
contact.form = contactForm;
|
|
const faq = (options) => ({
|
|
url: faq.url(options),
|
|
method: "get"
|
|
});
|
|
faq.definition = {
|
|
methods: ["get", "head"],
|
|
url: "/faq"
|
|
};
|
|
faq.url = (options) => {
|
|
return faq.definition.url + queryParams(options);
|
|
};
|
|
faq.get = (options) => ({
|
|
url: faq.url(options),
|
|
method: "get"
|
|
});
|
|
faq.head = (options) => ({
|
|
url: faq.url(options),
|
|
method: "head"
|
|
});
|
|
const faqForm = (options) => ({
|
|
action: faq.url(options),
|
|
method: "get"
|
|
});
|
|
faqForm.get = (options) => ({
|
|
action: faq.url(options),
|
|
method: "get"
|
|
});
|
|
faqForm.head = (options) => ({
|
|
action: faq.url({
|
|
[options?.mergeQuery ? "mergeQuery" : "query"]: {
|
|
_method: "HEAD",
|
|
...options?.query ?? options?.mergeQuery ?? {}
|
|
}
|
|
}),
|
|
method: "get"
|
|
});
|
|
faq.form = faqForm;
|
|
const gallery = (options) => ({
|
|
url: gallery.url(options),
|
|
method: "get"
|
|
});
|
|
gallery.definition = {
|
|
methods: ["get", "head"],
|
|
url: "/gallery"
|
|
};
|
|
gallery.url = (options) => {
|
|
return gallery.definition.url + queryParams(options);
|
|
};
|
|
gallery.get = (options) => ({
|
|
url: gallery.url(options),
|
|
method: "get"
|
|
});
|
|
gallery.head = (options) => ({
|
|
url: gallery.url(options),
|
|
method: "head"
|
|
});
|
|
const galleryForm = (options) => ({
|
|
action: gallery.url(options),
|
|
method: "get"
|
|
});
|
|
galleryForm.get = (options) => ({
|
|
action: gallery.url(options),
|
|
method: "get"
|
|
});
|
|
galleryForm.head = (options) => ({
|
|
action: gallery.url({
|
|
[options?.mergeQuery ? "mergeQuery" : "query"]: {
|
|
_method: "HEAD",
|
|
...options?.query ?? options?.mergeQuery ?? {}
|
|
}
|
|
}),
|
|
method: "get"
|
|
});
|
|
gallery.form = galleryForm;
|
|
const bespoke = (options) => ({
|
|
url: bespoke.url(options),
|
|
method: "get"
|
|
});
|
|
bespoke.definition = {
|
|
methods: ["get", "head"],
|
|
url: "/bespoke"
|
|
};
|
|
bespoke.url = (options) => {
|
|
return bespoke.definition.url + queryParams(options);
|
|
};
|
|
bespoke.get = (options) => ({
|
|
url: bespoke.url(options),
|
|
method: "get"
|
|
});
|
|
bespoke.head = (options) => ({
|
|
url: bespoke.url(options),
|
|
method: "head"
|
|
});
|
|
const bespokeForm = (options) => ({
|
|
action: bespoke.url(options),
|
|
method: "get"
|
|
});
|
|
bespokeForm.get = (options) => ({
|
|
action: bespoke.url(options),
|
|
method: "get"
|
|
});
|
|
bespokeForm.head = (options) => ({
|
|
action: bespoke.url({
|
|
[options?.mergeQuery ? "mergeQuery" : "query"]: {
|
|
_method: "HEAD",
|
|
...options?.query ?? options?.mergeQuery ?? {}
|
|
}
|
|
}),
|
|
method: "get"
|
|
});
|
|
bespoke.form = bespokeForm;
|
|
const register = (options) => ({
|
|
url: register.url(options),
|
|
method: "get"
|
|
});
|
|
register.definition = {
|
|
methods: ["get", "head"],
|
|
url: "/register"
|
|
};
|
|
register.url = (options) => {
|
|
return register.definition.url + queryParams(options);
|
|
};
|
|
register.get = (options) => ({
|
|
url: register.url(options),
|
|
method: "get"
|
|
});
|
|
register.head = (options) => ({
|
|
url: register.url(options),
|
|
method: "head"
|
|
});
|
|
const registerForm = (options) => ({
|
|
action: register.url(options),
|
|
method: "get"
|
|
});
|
|
registerForm.get = (options) => ({
|
|
action: register.url(options),
|
|
method: "get"
|
|
});
|
|
registerForm.head = (options) => ({
|
|
action: register.url({
|
|
[options?.mergeQuery ? "mergeQuery" : "query"]: {
|
|
_method: "HEAD",
|
|
...options?.query ?? options?.mergeQuery ?? {}
|
|
}
|
|
}),
|
|
method: "get"
|
|
});
|
|
register.form = registerForm;
|
|
export {
|
|
Button as B,
|
|
applyUrlDefaults as a,
|
|
logout as b,
|
|
cn as c,
|
|
contact as d,
|
|
about as e,
|
|
artOfWeaving as f,
|
|
faq as g,
|
|
home as h,
|
|
bespoke as i,
|
|
login as l,
|
|
queryParams as q,
|
|
register as r
|
|
};
|