@g4rcez/components 0.0.1 → 0.0.3
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/package.json +11 -2
- package/.idea/bigweld.iml +0 -12
- package/.idea/codeStyles/Project.xml +0 -72
- package/.idea/codeStyles/codeStyleConfig.xml +0 -5
- package/.idea/inspectionProfiles/Project_Default.xml +0 -30
- package/.idea/jsLibraryMappings.xml +0 -6
- package/.idea/modules.xml +0 -8
- package/.idea/prettier.xml +0 -7
- package/.idea/reason.xml +0 -6
- package/.idea/vcs.xml +0 -6
- package/.prettierrc.json +0 -13
- package/app/client-table.tsx +0 -35
- package/app/favicon.ico +0 -0
- package/app/layout.tsx +0 -39
- package/app/page.tsx +0 -72
- package/docs/README.md +0 -36
- package/docs/next.config.mjs +0 -4
- package/docs/package.json +0 -28
- package/docs/pnpm-lock.yaml +0 -1030
- package/docs/postcss.config.mjs +0 -8
- package/docs/public/next.svg +0 -1
- package/docs/public/vercel.svg +0 -1
- package/docs/src/app/favicon.ico +0 -0
- package/docs/src/app/globals.css +0 -33
- package/docs/src/app/layout.tsx +0 -22
- package/docs/src/app/page.tsx +0 -10
- package/docs/tailwind.config.ts +0 -15
- package/docs/tsconfig.json +0 -26
- package/next-env.d.ts +0 -5
- package/next.config.mjs +0 -4
- package/postcss.config.mjs +0 -8
- package/public/next.svg +0 -1
- package/public/vercel.svg +0 -1
- package/src/components/core/button.tsx +0 -91
- package/src/components/core/polymorph.tsx +0 -17
- package/src/components/display/card.tsx +0 -8
- package/src/components/floating/dropdown.tsx +0 -93
- package/src/components/floating/tooltip.tsx +0 -67
- package/src/components/form/autocomplete.tsx +0 -222
- package/src/components/form/file-upload.tsx +0 -129
- package/src/components/form/form.tsx +0 -28
- package/src/components/form/input-field.tsx +0 -105
- package/src/components/form/input.tsx +0 -73
- package/src/components/form/select.tsx +0 -58
- package/src/components/form/switch.tsx +0 -40
- package/src/components/index.ts +0 -14
- package/src/components/table/filter.tsx +0 -186
- package/src/components/table/group.tsx +0 -123
- package/src/components/table/index.tsx +0 -207
- package/src/components/table/metadata.tsx +0 -55
- package/src/components/table/sort.tsx +0 -141
- package/src/components/table/table-lib.ts +0 -130
- package/src/components/table/thead.tsx +0 -108
- package/src/hooks/use-form.ts +0 -155
- package/src/hooks/use-previous.ts +0 -9
- package/src/hooks/use-reactive.ts +0 -10
- package/src/index.css +0 -37
- package/src/index.ts +0 -6
- package/src/lib/dom.ts +0 -27
- package/src/lib/fns.ts +0 -23
- package/src/styles/dark.json +0 -66
- package/src/styles/design-tokens.ts +0 -57
- package/src/styles/light.json +0 -49
- package/src/types.ts +0 -11
- package/styles.config.ts +0 -42
- package/tailwind.config.ts +0 -11
- package/tsconfig.json +0 -55
- package/tsconfig.lib.json +0 -50
- package/tsconfig.lib.tsbuildinfo +0 -1
- package/tsconfig.tailwind.json +0 -32
- package/tsconfig.tsbuildinfo +0 -1
- package/vite.config.mts +0 -39
|
@@ -1,108 +0,0 @@
|
|
|
1
|
-
import { AnimatePresence, Reorder, TargetAndTransition } from "framer-motion";
|
|
2
|
-
import { PlusIcon, SearchIcon } from "lucide-react";
|
|
3
|
-
import { Dropdown } from "~/components/floating/dropdown";
|
|
4
|
-
import { useReactive } from "~/hooks/use-reactive";
|
|
5
|
-
import { ColumnHeaderFilter, createFilterFromCol } from "./filter";
|
|
6
|
-
import { SorterHead } from "./sort";
|
|
7
|
-
import { Col, getLabel, TableOperationProps } from "./table-lib";
|
|
8
|
-
|
|
9
|
-
type TableHeaderProps<T extends {}> = {
|
|
10
|
-
headers: Col<T>[];
|
|
11
|
-
} & Pick<TableOperationProps<T>, "filters" | "setFilters" | "setCols" | "setSorters" | "sorters">;
|
|
12
|
-
|
|
13
|
-
const targetTransitionAnimate: TargetAndTransition = { opacity: 1 };
|
|
14
|
-
|
|
15
|
-
const whileDrag: TargetAndTransition = { opacity: 0.75, backgroundColor: "#a1a1aa" };
|
|
16
|
-
|
|
17
|
-
const exit: TargetAndTransition = { opacity: 0, transition: { duration: 0.4, type: "spring" } };
|
|
18
|
-
|
|
19
|
-
type HeaderChildProps<T extends {}> = {
|
|
20
|
-
header: Col<T>;
|
|
21
|
-
} & Pick<TableOperationProps<T>, "filters" | "setFilters" | "sorters" | "setSorters">;
|
|
22
|
-
|
|
23
|
-
const HeaderChild = <T extends {}>(props: HeaderChildProps<T>) => {
|
|
24
|
-
const ownFilters = props.filters.filter((x) => x.name === props.header.id);
|
|
25
|
-
return (
|
|
26
|
-
<Reorder.Item
|
|
27
|
-
{...(props.header.thProps as {})}
|
|
28
|
-
as="th"
|
|
29
|
-
exit={exit}
|
|
30
|
-
initial={false}
|
|
31
|
-
dragSnapToOrigin
|
|
32
|
-
dragDirectionLock
|
|
33
|
-
value={props.header}
|
|
34
|
-
whileDrag={whileDrag}
|
|
35
|
-
animate={targetTransitionAnimate}
|
|
36
|
-
className={`hidden px-2 py-4 first:table-cell md:table-cell ${props.header.thProps?.className ?? ""}`}
|
|
37
|
-
>
|
|
38
|
-
<span className="flex items-center justify-between">
|
|
39
|
-
<span className="flex items-center gap-1">
|
|
40
|
-
<Dropdown
|
|
41
|
-
arrow
|
|
42
|
-
trigger={<SearchIcon size={14} />}
|
|
43
|
-
onChange={(opened) => {
|
|
44
|
-
if (!opened) return;
|
|
45
|
-
props.setFilters((prev) => prev.concat(createFilterFromCol(props.header, {})));
|
|
46
|
-
}}
|
|
47
|
-
>
|
|
48
|
-
Filter by: {getLabel(props.header)}
|
|
49
|
-
{(ownFilters.length === 0) === null ? null : (
|
|
50
|
-
<ul>
|
|
51
|
-
{ownFilters.map((filter) => (
|
|
52
|
-
<li key={`thead-filter-${filter.id}`} className="my-1">
|
|
53
|
-
<ColumnHeaderFilter filter={filter} set={props.setFilters} />
|
|
54
|
-
</li>
|
|
55
|
-
))}
|
|
56
|
-
<li>
|
|
57
|
-
<button
|
|
58
|
-
onClick={() => props.setFilters((prev) => prev.concat(createFilterFromCol(props.header)))}
|
|
59
|
-
className="text-primary-muted flex items-center"
|
|
60
|
-
>
|
|
61
|
-
<PlusIcon size={14} /> Add
|
|
62
|
-
</button>
|
|
63
|
-
</li>
|
|
64
|
-
</ul>
|
|
65
|
-
)}
|
|
66
|
-
</Dropdown>
|
|
67
|
-
<span className="pointer-events-auto text-balance text-base">{props.header.thead}</span>
|
|
68
|
-
<SorterHead col={props.header} setSorters={props.setSorters} sorters={props.sorters} />
|
|
69
|
-
</span>
|
|
70
|
-
</span>
|
|
71
|
-
</Reorder.Item>
|
|
72
|
-
);
|
|
73
|
-
};
|
|
74
|
-
|
|
75
|
-
export const TableHeader = <T extends {}>(props: TableHeaderProps<T>) => {
|
|
76
|
-
const [headers, setHeaders] = useReactive<Col<T>[]>(props.headers);
|
|
77
|
-
|
|
78
|
-
const onPointerUp = () => props.setCols(headers);
|
|
79
|
-
|
|
80
|
-
return (
|
|
81
|
-
<Reorder.Group
|
|
82
|
-
as="tr"
|
|
83
|
-
axis="x"
|
|
84
|
-
drag
|
|
85
|
-
layout
|
|
86
|
-
layoutRoot
|
|
87
|
-
layoutScroll
|
|
88
|
-
initial={false}
|
|
89
|
-
values={headers}
|
|
90
|
-
onReorder={setHeaders}
|
|
91
|
-
onPointerUp={onPointerUp}
|
|
92
|
-
className="bg-table-background border-none text-lg"
|
|
93
|
-
>
|
|
94
|
-
<AnimatePresence>
|
|
95
|
-
{headers.map((header) => (
|
|
96
|
-
<HeaderChild<T>
|
|
97
|
-
key={`header-child-item-${header.id as string}`}
|
|
98
|
-
setFilters={props.setFilters}
|
|
99
|
-
filters={props.filters}
|
|
100
|
-
setSorters={props.setSorters}
|
|
101
|
-
sorters={props.sorters}
|
|
102
|
-
header={header}
|
|
103
|
-
/>
|
|
104
|
-
))}
|
|
105
|
-
</AnimatePresence>
|
|
106
|
-
</Reorder.Group>
|
|
107
|
-
);
|
|
108
|
-
};
|
package/src/hooks/use-form.ts
DELETED
|
@@ -1,155 +0,0 @@
|
|
|
1
|
-
import { parse } from "qs";
|
|
2
|
-
import React, { useCallback, useEffect, useRef, useState } from "react";
|
|
3
|
-
import { AllPaths, Is, setPath } from "sidekicker";
|
|
4
|
-
import { z, ZodArray, ZodNumber } from "zod";
|
|
5
|
-
import { formReset } from "~/components/form/form";
|
|
6
|
-
import { InputProps } from "~/components/form/input";
|
|
7
|
-
import { SelectProps } from "~/components/form/select";
|
|
8
|
-
|
|
9
|
-
const sort = (a: string, b: string) => a.localeCompare(b);
|
|
10
|
-
|
|
11
|
-
const options = {
|
|
12
|
-
sort,
|
|
13
|
-
allowDots: true,
|
|
14
|
-
charset: "utf-8",
|
|
15
|
-
parseArrays: true,
|
|
16
|
-
plainObjects: true,
|
|
17
|
-
charsetSentinel: true,
|
|
18
|
-
allowPrototypes: false,
|
|
19
|
-
depth: Number.MAX_SAFE_INTEGER,
|
|
20
|
-
arrayLimit: Number.MAX_SAFE_INTEGER,
|
|
21
|
-
parameterLimit: Number.MAX_SAFE_INTEGER,
|
|
22
|
-
} as const;
|
|
23
|
-
|
|
24
|
-
export const formToJson = (form: HTMLFormElement): any => {
|
|
25
|
-
const formData = new FormData(form);
|
|
26
|
-
const urlSearchParams = new URLSearchParams(formData as any);
|
|
27
|
-
return parse(urlSearchParams.toString(), options) as never;
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
export const convertPath = (path: string) => path.replace("[", ".").replace("]", "").split(".");
|
|
31
|
-
|
|
32
|
-
export const getSchemaShape = <T extends z.ZodObject<any>>(name: string, schema: T) =>
|
|
33
|
-
convertPath(name).reduce((acc, el) => {
|
|
34
|
-
if (el === "") return acc;
|
|
35
|
-
const shape = acc.shape?.[el] || acc;
|
|
36
|
-
return shape instanceof ZodArray ? shape.element : shape;
|
|
37
|
-
}, schema);
|
|
38
|
-
|
|
39
|
-
const getValueByType = (e: HTMLInputElement) => {
|
|
40
|
-
if (e.type === "checkbox") return e.checked;
|
|
41
|
-
if (e.type === "number") return e.valueAsNumber;
|
|
42
|
-
return e.value;
|
|
43
|
-
};
|
|
44
|
-
|
|
45
|
-
type CustomOnInvalid = (args: { form: HTMLFormElement; errors: Record<string, string> }) => any;
|
|
46
|
-
|
|
47
|
-
type CustomOnSubmit<T> = (args: { json: T; form: HTMLFormElement; reset: () => void; event: React.FormEvent<HTMLFormElement> }) => any;
|
|
48
|
-
|
|
49
|
-
export const useForm = <T extends z.ZodObject<any>>(schema: T) => {
|
|
50
|
-
const [errors, setErrors] = useState<Record<string, string | undefined> | null>(null);
|
|
51
|
-
const ref = useRef<Record<string, { element: HTMLElement; schema: z.ZodType }>>({});
|
|
52
|
-
|
|
53
|
-
const select = <Props extends SelectProps>(name: AllPaths<z.infer<T>>, props?: Props): Props => {
|
|
54
|
-
const validator = getSchemaShape(name, schema);
|
|
55
|
-
return {
|
|
56
|
-
...props,
|
|
57
|
-
name,
|
|
58
|
-
id: name,
|
|
59
|
-
error: errors?.[name],
|
|
60
|
-
ref: (e: HTMLSelectElement) => {
|
|
61
|
-
if (e === null) return;
|
|
62
|
-
ref.current[name] = { element: e, schema: validator };
|
|
63
|
-
},
|
|
64
|
-
} as any;
|
|
65
|
-
};
|
|
66
|
-
|
|
67
|
-
const input = <Props extends InputProps>(name: AllPaths<z.infer<T>>, props?: Props): Props => {
|
|
68
|
-
const validator = getSchemaShape(name, schema);
|
|
69
|
-
return {
|
|
70
|
-
...props,
|
|
71
|
-
name,
|
|
72
|
-
id: name,
|
|
73
|
-
type: Is.instance(validator, ZodNumber) ? "number" : props?.type ?? "text",
|
|
74
|
-
error: errors?.[name],
|
|
75
|
-
ref: (e: HTMLInputElement) => {
|
|
76
|
-
if (e === null) return;
|
|
77
|
-
ref.current[name] = { element: e, schema: validator };
|
|
78
|
-
},
|
|
79
|
-
} as any;
|
|
80
|
-
};
|
|
81
|
-
|
|
82
|
-
useEffect(() => {
|
|
83
|
-
const events = Object.values(ref.current).map((input) => {
|
|
84
|
-
const validation = input.schema.safeParse(getValueByType(input.element as any));
|
|
85
|
-
const onBlurField = (e: any) => {
|
|
86
|
-
const validation = input.schema.safeParse(getValueByType(e.target));
|
|
87
|
-
const html = input.element as HTMLInputElement;
|
|
88
|
-
const name = html.name;
|
|
89
|
-
if (validation.success) {
|
|
90
|
-
html.setCustomValidity("");
|
|
91
|
-
return setErrors((prev) => {
|
|
92
|
-
const { [name]: removed, ...rest } = prev || {};
|
|
93
|
-
return rest === null || Is.empty(rest) ? null : rest;
|
|
94
|
-
});
|
|
95
|
-
}
|
|
96
|
-
if (html.required) {
|
|
97
|
-
const errorMessage = validation.error.issues[0].message;
|
|
98
|
-
html.setCustomValidity(errorMessage);
|
|
99
|
-
setErrors((prev) => ({ ...prev, [name]: errorMessage }));
|
|
100
|
-
}
|
|
101
|
-
};
|
|
102
|
-
const event = input.element.tagName === "INPUT" ? "blur" : "change";
|
|
103
|
-
input.element.addEventListener(event, onBlurField);
|
|
104
|
-
return {
|
|
105
|
-
input,
|
|
106
|
-
hasInitialError: (input.element as HTMLInputElement).required ? !validation.success : false,
|
|
107
|
-
unsubscribe: () => input.element.removeEventListener(event, onBlurField),
|
|
108
|
-
};
|
|
109
|
-
});
|
|
110
|
-
const hasErrors = events.some((x) => x.hasInitialError);
|
|
111
|
-
if (hasErrors) setErrors((prev) => (prev === null ? {} : prev));
|
|
112
|
-
return () => events.forEach((item) => item.unsubscribe());
|
|
113
|
-
});
|
|
114
|
-
|
|
115
|
-
const onInvalid = useCallback(
|
|
116
|
-
(exec?: CustomOnInvalid) => (event: React.FormEvent<HTMLFormElement>) => {
|
|
117
|
-
event.preventDefault();
|
|
118
|
-
const form = event.currentTarget;
|
|
119
|
-
const validationErrors = Object.values(ref.current).reduce((acc, input) => {
|
|
120
|
-
const field = input.element as HTMLInputElement;
|
|
121
|
-
const validation = input.schema.safeParse(getValueByType(field));
|
|
122
|
-
if (validation.success) return acc;
|
|
123
|
-
const errorMessage = validation.error.issues[0].message;
|
|
124
|
-
field.setAttribute("data-initialized", "true");
|
|
125
|
-
return { ...acc, [field.name]: errorMessage };
|
|
126
|
-
}, {});
|
|
127
|
-
const e = Is.empty(validationErrors) ? null : {};
|
|
128
|
-
setErrors(e);
|
|
129
|
-
exec?.({ form, errors: e || {} });
|
|
130
|
-
},
|
|
131
|
-
[]
|
|
132
|
-
);
|
|
133
|
-
|
|
134
|
-
const onSubmit = useCallback(
|
|
135
|
-
(exec: CustomOnSubmit<z.infer<T>>) => (event: React.FormEvent<HTMLFormElement>) => {
|
|
136
|
-
event.preventDefault();
|
|
137
|
-
const form = event.currentTarget;
|
|
138
|
-
let json = formToJson(form);
|
|
139
|
-
Array.from(form.elements).forEach((field) => {
|
|
140
|
-
if (field.tagName === "SELECT") {
|
|
141
|
-
const input = field as HTMLSelectElement;
|
|
142
|
-
json = setPath<any>(json as any, input.name, input.value);
|
|
143
|
-
}
|
|
144
|
-
if (field.tagName === "INPUT") {
|
|
145
|
-
const input = field as HTMLInputElement;
|
|
146
|
-
json = setPath<any>(json as any, input.name, getValueByType(input));
|
|
147
|
-
}
|
|
148
|
-
});
|
|
149
|
-
exec({ form, json, event, reset: () => formReset(form) });
|
|
150
|
-
},
|
|
151
|
-
[]
|
|
152
|
-
);
|
|
153
|
-
|
|
154
|
-
return { input, select, onSubmit, errors, onInvalid, disabled: errors !== null };
|
|
155
|
-
};
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { useEffect, useState } from "react";
|
|
2
|
-
|
|
3
|
-
export const useReactive = <T extends unknown>(t: T, initial?: T) => {
|
|
4
|
-
const [state, setState] = useState(() => (initial ? initial : t));
|
|
5
|
-
useEffect(() => {
|
|
6
|
-
setState(t);
|
|
7
|
-
}, [t]);
|
|
8
|
-
return [state, setState] as const;
|
|
9
|
-
};
|
|
10
|
-
|
package/src/index.css
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
@tailwind base;
|
|
2
|
-
@tailwind components;
|
|
3
|
-
@tailwind utilities;
|
|
4
|
-
|
|
5
|
-
select.select {
|
|
6
|
-
@apply appearance-none pr-10 bg-no-repeat;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
input::-webkit-outer-spin-button,
|
|
10
|
-
input::-webkit-inner-spin-button {
|
|
11
|
-
-webkit-appearance: none;
|
|
12
|
-
margin: 0;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
input[type="number"] {
|
|
16
|
-
-moz-appearance: textfield;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
input[type="color"],
|
|
20
|
-
input[type="date"],
|
|
21
|
-
input[type="datetime"],
|
|
22
|
-
input[type="datetime-local"],
|
|
23
|
-
input[type="email"],
|
|
24
|
-
input[type="month"],
|
|
25
|
-
input[type="number"],
|
|
26
|
-
input[type="password"],
|
|
27
|
-
input[type="search"],
|
|
28
|
-
input[type="tel"],
|
|
29
|
-
input[type="text"],
|
|
30
|
-
input[type="time"],
|
|
31
|
-
input[type="url"],
|
|
32
|
-
input[type="week"],
|
|
33
|
-
select,
|
|
34
|
-
select:focus,
|
|
35
|
-
textarea {
|
|
36
|
-
@apply text-base;
|
|
37
|
-
}
|
package/src/index.ts
DELETED
package/src/lib/dom.ts
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { ClassValue, clsx } from "clsx";
|
|
2
|
-
import { twMerge } from "tailwind-merge";
|
|
3
|
-
import React, { LegacyRef, MutableRefObject, RefCallback } from "react";
|
|
4
|
-
|
|
5
|
-
export const mergeRefs =
|
|
6
|
-
<T extends any = any>(...refs: Array<MutableRefObject<T> | LegacyRef<T> | undefined | null>): RefCallback<T> =>
|
|
7
|
-
(value) => {
|
|
8
|
-
refs.forEach((ref) => {
|
|
9
|
-
if (typeof ref === "function") {
|
|
10
|
-
ref(value);
|
|
11
|
-
} else if (ref !== null) {
|
|
12
|
-
(ref as MutableRefObject<T | null>).current = value;
|
|
13
|
-
}
|
|
14
|
-
});
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
export const isReactComponent = (a: any): a is React.FC => {
|
|
18
|
-
if (a.$$typeof === Symbol.for("react.forward_ref")) {
|
|
19
|
-
return true;
|
|
20
|
-
}
|
|
21
|
-
if (a.$$typeof === Symbol.for("react.fragment")) {
|
|
22
|
-
return true;
|
|
23
|
-
}
|
|
24
|
-
return a.$$typeof === Symbol.for("react.element");
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
export const css = (...styles: ClassValue[]) => twMerge(clsx(styles));
|
package/src/lib/fns.ts
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { AllPaths } from "sidekicker";
|
|
2
|
-
|
|
3
|
-
export const uuid = (): string =>
|
|
4
|
-
"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (c) => {
|
|
5
|
-
let r = (Math.random() * 16) | 0;
|
|
6
|
-
let v = c == "x" ? r : (r & 0x3) | 0x8;
|
|
7
|
-
return v.toString(16);
|
|
8
|
-
});
|
|
9
|
-
|
|
10
|
-
const travel = (path: string, regexp: RegExp, obj: any) =>
|
|
11
|
-
path
|
|
12
|
-
.split(regexp)
|
|
13
|
-
.filter(Boolean)
|
|
14
|
-
.reduce((res, key) => (res !== null && res !== undefined ? (res as any)[key] : res), obj);
|
|
15
|
-
|
|
16
|
-
const regexPaths = { basic: /[,[\]]+?/, extend: /[,[\].]+?/ };
|
|
17
|
-
|
|
18
|
-
export const path = <T extends {}, K extends AllPaths<T>>(obj: T, path: K) => {
|
|
19
|
-
const result = travel(path, regexPaths.basic, obj) || travel(path, regexPaths.extend, obj);
|
|
20
|
-
return result === undefined || result === obj ? undefined : result;
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
export const isSsr = () => typeof window === 'undefined';
|
package/src/styles/dark.json
DELETED
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "dark",
|
|
3
|
-
"spacing": {
|
|
4
|
-
"base": "1rem",
|
|
5
|
-
"lg": "1.5rem",
|
|
6
|
-
"sm": "0.75rem"
|
|
7
|
-
},
|
|
8
|
-
"colors": {
|
|
9
|
-
"foreground": "#f8fafc",
|
|
10
|
-
"background": "#191817",
|
|
11
|
-
"accent": "#0ea5e9",
|
|
12
|
-
"disabled": "#52525b",
|
|
13
|
-
"primary": {
|
|
14
|
-
"foreground": "#f8fafc",
|
|
15
|
-
"DEFAULT": "#0ea5e9",
|
|
16
|
-
"subtle": "#bae6fd",
|
|
17
|
-
"hover": "#0284c7"
|
|
18
|
-
},
|
|
19
|
-
"secondary": {
|
|
20
|
-
"DEFAULT": "#475569",
|
|
21
|
-
"subtle": "#cbd5e1",
|
|
22
|
-
"hover": "#334155"
|
|
23
|
-
},
|
|
24
|
-
"info": {
|
|
25
|
-
"DEFAULT": "#3b82f6",
|
|
26
|
-
"subtle": "#93c5fd",
|
|
27
|
-
"hover": "#1d4ed8"
|
|
28
|
-
},
|
|
29
|
-
"danger": {
|
|
30
|
-
"DEFAULT": "#ef4444",
|
|
31
|
-
"subtle": "#fca5a5",
|
|
32
|
-
"hover": "#dc2626"
|
|
33
|
-
},
|
|
34
|
-
"success": {
|
|
35
|
-
"DEFAULT": "#10b981",
|
|
36
|
-
"subtle": "#6ee7b7",
|
|
37
|
-
"hover": "#047857"
|
|
38
|
-
},
|
|
39
|
-
"input": {
|
|
40
|
-
"border": "#52525b",
|
|
41
|
-
"placeholder": "#94a3b8",
|
|
42
|
-
"mask-error": "#fca5a5",
|
|
43
|
-
"switch-bg": "#171717",
|
|
44
|
-
"switch": "#fff"
|
|
45
|
-
},
|
|
46
|
-
"card": {
|
|
47
|
-
"background": "#27272a",
|
|
48
|
-
"border": "#3f3f46",
|
|
49
|
-
"overlay": "#00000080"
|
|
50
|
-
},
|
|
51
|
-
"floating": {
|
|
52
|
-
"background": "#252525",
|
|
53
|
-
"border": "#3f3f46",
|
|
54
|
-
"overlay": "#00000080"
|
|
55
|
-
},
|
|
56
|
-
"tooltip": {
|
|
57
|
-
"background": "#141414",
|
|
58
|
-
"border": "#27272a"
|
|
59
|
-
},
|
|
60
|
-
"table": {
|
|
61
|
-
"background": "#27272a",
|
|
62
|
-
"border": "#52525b",
|
|
63
|
-
"row": "#3f3f46"
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
}
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
type DesignTokens = {
|
|
2
|
-
[K in string]: string | DesignTokens;
|
|
3
|
-
};
|
|
4
|
-
|
|
5
|
-
type Token = { key: string; value: string };
|
|
6
|
-
|
|
7
|
-
type DesignTokensParser = (value: string, key: string, combine: string) => string;
|
|
8
|
-
|
|
9
|
-
type DesignTokensBuilder = (value: string, key: string, combine: string) => Token;
|
|
10
|
-
|
|
11
|
-
export const parsers = {
|
|
12
|
-
cssVariable: (_, __, k) => `var(--${k})`,
|
|
13
|
-
rgba: (value) => `rgba(${value})`,
|
|
14
|
-
rgb: (value) => `rgb(${value})`,
|
|
15
|
-
hsl: (value) => `hsl(${value})`,
|
|
16
|
-
hsla: (value) => `hsla(${value})`,
|
|
17
|
-
hex: (value) => value,
|
|
18
|
-
raw: (value) => value,
|
|
19
|
-
} satisfies Record<string, DesignTokensParser>;
|
|
20
|
-
|
|
21
|
-
export const reduceTokens = <T extends DesignTokens>(colors: T, parse: DesignTokensBuilder, prefix: string = "", append: string = ""): Token[] =>
|
|
22
|
-
Object.entries(colors).reduce<Token[]>((acc, [key, value]) => {
|
|
23
|
-
const combine = append === "" ? `${prefix}${key}` : `${append}-${key}`;
|
|
24
|
-
if (typeof value === "string") {
|
|
25
|
-
const k = append === "" ? `${prefix}${key}` : key;
|
|
26
|
-
return acc.concat(parse(value, k, combine));
|
|
27
|
-
}
|
|
28
|
-
return acc.concat(reduceTokens(value, parse, prefix, combine));
|
|
29
|
-
}, []);
|
|
30
|
-
|
|
31
|
-
export const createDesignTokens = <T extends DesignTokens>(colors: T, parse: DesignTokensParser, prefix: string = "", append: string = ""): T =>
|
|
32
|
-
Object.entries(colors).reduce<T>((acc, [key, value]) => {
|
|
33
|
-
const combine = append === "" ? `${prefix}${key}` : `${append}-${key}`;
|
|
34
|
-
if (typeof value === "string") {
|
|
35
|
-
const k = append === "" ? `${prefix}${key}` : key;
|
|
36
|
-
return { ...acc, [k]: parse(value, key, combine) };
|
|
37
|
-
}
|
|
38
|
-
return {
|
|
39
|
-
...acc,
|
|
40
|
-
[key]: createDesignTokens(value, parse, prefix, combine),
|
|
41
|
-
};
|
|
42
|
-
}, {} as T);
|
|
43
|
-
|
|
44
|
-
const modifiers = {
|
|
45
|
-
default: (variables: string) => `:root { ${variables} }`,
|
|
46
|
-
dark: (variables: string) => `html.dark {${variables}}`,
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
const createStyleContent = (tokens: Token[], modifier: (str: string) => string) => {
|
|
50
|
-
const content = tokens.map((token) => `${token.key}: ${token.value}`).join(";");
|
|
51
|
-
return modifier(content);
|
|
52
|
-
};
|
|
53
|
-
|
|
54
|
-
export const createStyles = {
|
|
55
|
-
default: (tokens: Token[]) => createStyleContent(tokens, modifiers.default),
|
|
56
|
-
dark: (tokens: Token[]) => createStyleContent(tokens, modifiers.dark),
|
|
57
|
-
};
|
package/src/styles/light.json
DELETED
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "dark",
|
|
3
|
-
"spacing": {
|
|
4
|
-
"base": "1rem",
|
|
5
|
-
"lg": "1.5rem",
|
|
6
|
-
"sm": "0.75rem"
|
|
7
|
-
},
|
|
8
|
-
"colors": {
|
|
9
|
-
"background": "#f1f5f9",
|
|
10
|
-
"foreground": "#334155",
|
|
11
|
-
"accent": "#0ea5e9",
|
|
12
|
-
"primary": {
|
|
13
|
-
"foreground": "#334155",
|
|
14
|
-
"DEFAULT": "#0ea5e9",
|
|
15
|
-
"subtle": "#7dd3fc",
|
|
16
|
-
"hover": "#0284c7"
|
|
17
|
-
},
|
|
18
|
-
"secondary": {
|
|
19
|
-
"DEFAULT": "#475569",
|
|
20
|
-
"subtle": "#cbd5e1",
|
|
21
|
-
"hover": "#334155"
|
|
22
|
-
},
|
|
23
|
-
"info": {
|
|
24
|
-
"DEFAULT": "#3b82f6",
|
|
25
|
-
"subtle": "#93c5fd",
|
|
26
|
-
"hover": "#1d4ed8"
|
|
27
|
-
},
|
|
28
|
-
"danger": {
|
|
29
|
-
"DEFAULT": "#ef4444",
|
|
30
|
-
"subtle": "#fca5a5",
|
|
31
|
-
"hover": "#dc2626"
|
|
32
|
-
},
|
|
33
|
-
"success": {
|
|
34
|
-
"DEFAULT": "#10b981",
|
|
35
|
-
"subtle": "#6ee7b7",
|
|
36
|
-
"hover": "#047857"
|
|
37
|
-
},
|
|
38
|
-
"input": {
|
|
39
|
-
"border": "#d1d5db",
|
|
40
|
-
"placeholder": "#94a3b8",
|
|
41
|
-
"mask-error": "#fca5a5"
|
|
42
|
-
},
|
|
43
|
-
"card": {
|
|
44
|
-
"background": "#ffffff",
|
|
45
|
-
"border": "#cbd5e1",
|
|
46
|
-
"overlay": "#00000080"
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
}
|
package/src/types.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import React,{ Dispatch, ReactElement, ReactNode, SetStateAction } from "react";
|
|
2
|
-
|
|
3
|
-
export type Label = React.ReactNode | React.ReactElement | string;
|
|
4
|
-
|
|
5
|
-
export type Merge<T> = { [K in keyof T]: T[K] } & {};
|
|
6
|
-
|
|
7
|
-
export type Override<Source, New> = Omit<Source, keyof New> & New;
|
|
8
|
-
|
|
9
|
-
export type SetState<T> = Dispatch<SetStateAction<T>>;
|
|
10
|
-
|
|
11
|
-
export type POJO = Record<string, any>
|
package/styles.config.ts
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import { Config } from "tailwindcss";
|
|
2
|
-
import plugin from "tailwindcss/plugin";
|
|
3
|
-
import DarkMode from "./src/styles/dark.json";
|
|
4
|
-
import { createDesignTokens, parsers } from "./src/styles/design-tokens";
|
|
5
|
-
|
|
6
|
-
const COLORS = createDesignTokens(DarkMode.colors, parsers.cssVariable);
|
|
7
|
-
|
|
8
|
-
const css = String.raw;
|
|
9
|
-
|
|
10
|
-
const config: Partial<Config> = {
|
|
11
|
-
theme: {
|
|
12
|
-
transitionTimingFunction: { DEFAULT: "cubic-bezier(1,.43,.36,.67)" },
|
|
13
|
-
transitionDuration: { DEFAULT: "375ms" },
|
|
14
|
-
extend: {
|
|
15
|
-
fill: COLORS,
|
|
16
|
-
colors: COLORS,
|
|
17
|
-
borderColors: COLORS,
|
|
18
|
-
placeholderColor: COLORS,
|
|
19
|
-
zIndex: {
|
|
20
|
-
floating: "10",
|
|
21
|
-
},
|
|
22
|
-
boxShadow: {
|
|
23
|
-
floating: "rgba(15, 15, 15, 0.1) 0px 0px 0px 1px, rgba(15, 15, 15, 0.2) 0px 3px 6px, rgba(15, 15, 15, 0.4) 0px 9px 24px"
|
|
24
|
-
}
|
|
25
|
-
},
|
|
26
|
-
},
|
|
27
|
-
plugins: [
|
|
28
|
-
plugin(function ({ addVariant }) {
|
|
29
|
-
addVariant("link", ["&:hover", "&:active"]);
|
|
30
|
-
addVariant("landing", ["&"]);
|
|
31
|
-
addVariant("group-assert", [css`:merge(.group):valid:has(.input:valid:not(:placeholder-shown)) &`]);
|
|
32
|
-
addVariant("group-error", [
|
|
33
|
-
css`:merge(.group):invalid:has(.input:not(:focus):invalid[data-initialized=true]) &`,
|
|
34
|
-
css`:merge(.group[data-error=true][data-interactive=true]):has(.input[data-initialized=true]) &`,
|
|
35
|
-
css`:merge(.group[data-error=true][data-interactive=true]):has(.input) &`,
|
|
36
|
-
css`:merge(.group[data-error=true]:has(.input[data-initialized=true])) &`,
|
|
37
|
-
]);
|
|
38
|
-
}),
|
|
39
|
-
],
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
export default config;
|
package/tailwind.config.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import type { Config } from "tailwindcss";
|
|
2
|
-
import preset from "./styles.config";
|
|
3
|
-
|
|
4
|
-
const content = process.env.NODE_ENV === "production"
|
|
5
|
-
|
|
6
|
-
const config: Config = {
|
|
7
|
-
presets: [preset],
|
|
8
|
-
content: ["./app/**/*.{js,ts,jsx,tsx,mdx}", "./src/**/*.{js,ts,jsx,tsx,mdx}"],
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
export default config;
|
package/tsconfig.json
DELETED
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
"allowJs": false,
|
|
4
|
-
"allowSyntheticDefaultImports": true,
|
|
5
|
-
"allowUmdGlobalAccess": false,
|
|
6
|
-
"allowUnreachableCode": false,
|
|
7
|
-
"allowUnusedLabels": false,
|
|
8
|
-
"alwaysStrict": true,
|
|
9
|
-
"declaration": true,
|
|
10
|
-
"declarationDir": "./dist",
|
|
11
|
-
"declarationMap": true,
|
|
12
|
-
"emitDeclarationOnly": true,
|
|
13
|
-
"esModuleInterop": true,
|
|
14
|
-
"forceConsistentCasingInFileNames": true,
|
|
15
|
-
"isolatedModules": true,
|
|
16
|
-
"jsx": "preserve",
|
|
17
|
-
"lib": [
|
|
18
|
-
"dom",
|
|
19
|
-
"dom.iterable",
|
|
20
|
-
"esnext"
|
|
21
|
-
],
|
|
22
|
-
"module": "esnext",
|
|
23
|
-
"moduleResolution": "node",
|
|
24
|
-
"noFallthroughCasesInSwitch": true,
|
|
25
|
-
"noImplicitAny": true,
|
|
26
|
-
"resolveJsonModule": true,
|
|
27
|
-
"skipLibCheck": true,
|
|
28
|
-
"strict": true,
|
|
29
|
-
"strictBindCallApply": true,
|
|
30
|
-
"strictFunctionTypes": true,
|
|
31
|
-
"strictNullChecks": true,
|
|
32
|
-
"strictPropertyInitialization": true,
|
|
33
|
-
"target": "ES2015",
|
|
34
|
-
"paths": {
|
|
35
|
-
"~/*": [
|
|
36
|
-
"./src/*"
|
|
37
|
-
]
|
|
38
|
-
},
|
|
39
|
-
"noEmit": true,
|
|
40
|
-
"incremental": true,
|
|
41
|
-
"plugins": [
|
|
42
|
-
{
|
|
43
|
-
"name": "next"
|
|
44
|
-
}
|
|
45
|
-
]
|
|
46
|
-
},
|
|
47
|
-
"include": [
|
|
48
|
-
"./src",
|
|
49
|
-
".next/types/**/*.ts"
|
|
50
|
-
],
|
|
51
|
-
"exclude": [
|
|
52
|
-
"node_modules",
|
|
53
|
-
"docs"
|
|
54
|
-
]
|
|
55
|
-
}
|