@g4rcez/components 0.0.38 → 0.0.39
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/index.css +1 -1
- package/dist/index.js +201 -10
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +3609 -3600
- package/dist/index.mjs.map +1 -1
- package/dist/index.umd.js +40 -40
- package/dist/index.umd.js.map +1 -1
- package/dist/preset.tailwind.d.ts +10 -0
- package/dist/preset.tailwind.d.ts.map +1 -0
- package/dist/preset.tailwind.js +53 -0
- package/dist/src/components/core/button.d.ts +16 -0
- package/dist/src/components/core/button.d.ts.map +1 -0
- package/dist/src/components/core/button.js +43 -0
- package/dist/src/components/core/polymorph.d.ts +10 -0
- package/dist/src/components/core/polymorph.d.ts.map +1 -0
- package/dist/src/components/core/polymorph.js +8 -0
- package/dist/src/components/core/resizable.d.ts +3 -0
- package/dist/src/components/core/resizable.d.ts.map +1 -0
- package/dist/src/components/core/resizable.js +50 -0
- package/dist/src/components/core/tag.d.ts +19 -0
- package/dist/src/components/core/tag.d.ts.map +1 -0
- package/dist/src/components/core/tag.js +45 -0
- package/dist/src/components/display/alert.d.ts +19 -0
- package/dist/src/components/display/alert.d.ts.map +1 -0
- package/dist/src/components/display/alert.js +34 -0
- package/dist/src/components/display/calendar.d.ts +42 -0
- package/dist/src/components/display/calendar.d.ts.map +1 -0
- package/dist/src/components/display/calendar.js +215 -0
- package/dist/src/components/display/card.d.ts +10 -0
- package/dist/src/components/display/card.d.ts.map +1 -0
- package/dist/src/components/display/card.js +8 -0
- package/dist/src/components/display/list.d.ts +16 -0
- package/dist/src/components/display/list.d.ts.map +1 -0
- package/dist/src/components/display/list.js +31 -0
- package/dist/src/components/display/notifications.d.ts +25 -0
- package/dist/src/components/display/notifications.d.ts.map +1 -0
- package/dist/src/components/display/notifications.js +70 -0
- package/dist/src/components/display/stats.d.ts +10 -0
- package/dist/src/components/display/stats.d.ts.map +1 -0
- package/dist/src/components/display/stats.js +5 -0
- package/dist/src/components/display/step.d.ts +14 -0
- package/dist/src/components/display/step.d.ts.map +1 -0
- package/dist/src/components/display/step.js +59 -0
- package/dist/src/components/display/tabs.d.ts +20 -0
- package/dist/src/components/display/tabs.d.ts.map +1 -0
- package/dist/src/components/display/tabs.js +67 -0
- package/dist/src/components/display/timeline.d.ts +32 -0
- package/dist/src/components/display/timeline.d.ts.map +1 -0
- package/dist/src/components/display/timeline.js +21 -0
- package/dist/src/components/floating/dropdown.d.ts +14 -0
- package/dist/src/components/floating/dropdown.d.ts.map +1 -0
- package/dist/src/components/floating/dropdown.js +39 -0
- package/dist/src/components/floating/expand.d.ts +9 -0
- package/dist/src/components/floating/expand.d.ts.map +1 -0
- package/dist/src/components/floating/expand.js +25 -0
- package/dist/src/components/floating/menu.d.ts +52 -0
- package/dist/src/components/floating/menu.d.ts.map +1 -0
- package/dist/src/components/floating/menu.js +126 -0
- package/dist/src/components/floating/modal.d.ts +19 -0
- package/dist/src/components/floating/modal.d.ts.map +1 -0
- package/dist/src/components/floating/modal.js +102 -0
- package/dist/src/components/floating/toolbar.d.ts +6 -0
- package/dist/src/components/floating/toolbar.d.ts.map +1 -0
- package/dist/src/components/floating/toolbar.js +4 -0
- package/dist/src/components/floating/tooltip.d.ts +12 -0
- package/dist/src/components/floating/tooltip.d.ts.map +1 -0
- package/dist/src/components/floating/tooltip.js +28 -0
- package/dist/src/components/form/autocomplete.d.ts +17 -0
- package/dist/src/components/form/autocomplete.d.ts.map +1 -0
- package/dist/src/components/form/autocomplete.js +152 -0
- package/dist/src/components/form/checkbox.d.ts +11 -0
- package/dist/src/components/form/checkbox.d.ts.map +1 -0
- package/dist/src/components/form/checkbox.js +8 -0
- package/dist/src/components/form/date-picker.d.ts +61 -0
- package/dist/src/components/form/date-picker.d.ts.map +1 -0
- package/dist/src/components/form/date-picker.js +78 -0
- package/dist/src/components/form/file-upload.d.ts +12 -0
- package/dist/src/components/form/file-upload.d.ts.map +1 -0
- package/dist/src/components/form/file-upload.js +62 -0
- package/dist/src/components/form/form.d.ts +4 -0
- package/dist/src/components/form/form.d.ts.map +1 -0
- package/dist/src/components/form/form.js +28 -0
- package/dist/src/components/form/input-field.d.ts +30 -0
- package/dist/src/components/form/input-field.d.ts.map +1 -0
- package/dist/src/components/form/input-field.js +14 -0
- package/dist/src/components/form/input.d.ts +9 -0
- package/dist/src/components/form/input.d.ts.map +1 -0
- package/dist/src/components/form/input.js +38 -0
- package/dist/src/components/form/radiobox.d.ts +7 -0
- package/dist/src/components/form/radiobox.d.ts.map +1 -0
- package/dist/src/components/form/radiobox.js +7 -0
- package/dist/src/components/form/select.d.ts +13 -0
- package/dist/src/components/form/select.d.ts.map +1 -0
- package/dist/src/components/form/select.js +33 -0
- package/dist/src/components/form/switch.d.ts +8 -0
- package/dist/src/components/form/switch.d.ts.map +1 -0
- package/dist/src/components/form/switch.js +39 -0
- package/dist/src/components/form/task-list.d.ts +3 -0
- package/dist/src/components/form/task-list.d.ts.map +1 -0
- package/dist/src/components/form/task-list.js +26 -0
- package/dist/src/components/form/transfer-list.d.ts +14 -0
- package/dist/src/components/form/transfer-list.d.ts.map +1 -0
- package/dist/src/components/form/transfer-list.js +21 -0
- package/dist/src/components/index.d.ts +30 -0
- package/dist/src/components/index.d.ts.map +1 -0
- package/dist/src/components/index.js +29 -0
- package/dist/src/components/table/filter.d.ts +41 -0
- package/dist/src/components/table/filter.d.ts.map +1 -0
- package/dist/src/components/table/filter.js +91 -0
- package/dist/src/components/table/group.d.ts +17 -0
- package/dist/src/components/table/group.d.ts.map +1 -0
- package/dist/src/components/table/group.js +43 -0
- package/dist/src/components/table/index.d.ts +38 -0
- package/dist/src/components/table/index.d.ts.map +1 -0
- package/dist/src/components/table/index.js +145 -0
- package/dist/src/components/table/metadata.d.ts +3 -0
- package/dist/src/components/table/metadata.d.ts.map +1 -0
- package/dist/src/components/table/metadata.js +10 -0
- package/dist/src/components/table/pagination.d.ts +3 -0
- package/dist/src/components/table/pagination.d.ts.map +1 -0
- package/dist/src/components/table/pagination.js +43 -0
- package/dist/src/components/table/sort.d.ts +28 -0
- package/dist/src/components/table/sort.d.ts.map +1 -0
- package/dist/src/components/table/sort.js +79 -0
- package/dist/src/components/table/table-lib.d.ts +122 -0
- package/dist/src/components/table/table-lib.d.ts.map +1 -0
- package/dist/src/components/table/table-lib.js +51 -0
- package/dist/src/components/table/thead.d.ts +8 -0
- package/dist/src/components/table/thead.d.ts.map +1 -0
- package/dist/src/components/table/thead.js +29 -0
- package/dist/src/constants.d.ts +3 -0
- package/dist/src/constants.d.ts.map +1 -0
- package/dist/src/constants.js +2 -0
- package/dist/src/hooks/use-callback-ref.d.ts +3 -0
- package/dist/src/hooks/use-callback-ref.d.ts.map +1 -0
- package/dist/src/hooks/use-callback-ref.js +8 -0
- package/dist/src/hooks/use-click-outside.d.ts +3 -0
- package/dist/src/hooks/use-click-outside.d.ts.map +1 -0
- package/dist/src/hooks/use-click-outside.js +17 -0
- package/dist/src/hooks/use-debounce.d.ts +4 -0
- package/dist/src/hooks/use-debounce.d.ts.map +1 -0
- package/dist/src/hooks/use-debounce.js +12 -0
- package/dist/src/hooks/use-form.d.ts +41 -0
- package/dist/src/hooks/use-form.d.ts.map +1 -0
- package/dist/src/hooks/use-form.js +169 -0
- package/dist/src/hooks/use-hover.d.ts +3 -0
- package/dist/src/hooks/use-hover.d.ts.map +1 -0
- package/dist/src/hooks/use-hover.js +18 -0
- package/dist/src/hooks/use-media-query.d.ts +2 -0
- package/dist/src/hooks/use-media-query.d.ts.map +1 -0
- package/dist/src/hooks/use-media-query.js +25 -0
- package/dist/src/hooks/use-mutable-state.d.ts +2 -0
- package/dist/src/hooks/use-mutable-state.d.ts.map +1 -0
- package/dist/src/hooks/use-mutable-state.js +8 -0
- package/dist/src/hooks/use-on-event.d.ts +4 -0
- package/dist/src/hooks/use-on-event.d.ts.map +1 -0
- package/dist/src/hooks/use-on-event.js +7 -0
- package/dist/src/hooks/use-parent.d.ts +3 -0
- package/dist/src/hooks/use-parent.d.ts.map +1 -0
- package/dist/src/hooks/use-parent.js +21 -0
- package/dist/src/hooks/use-previous.d.ts +2 -0
- package/dist/src/hooks/use-previous.d.ts.map +1 -0
- package/dist/src/hooks/use-previous.js +8 -0
- package/dist/src/hooks/use-reactive.d.ts +2 -0
- package/dist/src/hooks/use-reactive.d.ts.map +1 -0
- package/dist/src/hooks/use-reactive.js +8 -0
- package/dist/src/hooks/use-stable-ref.d.ts +2 -0
- package/dist/src/hooks/use-stable-ref.d.ts.map +1 -0
- package/dist/src/hooks/use-stable-ref.js +8 -0
- package/dist/src/hooks/use-translate-context.d.ts +103 -0
- package/dist/src/hooks/use-translate-context.d.ts.map +1 -0
- package/dist/src/hooks/use-translate-context.js +63 -0
- package/dist/src/index.d.ts +12 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/index.js +10 -0
- package/dist/src/lib/dom.d.ts +9 -0
- package/dist/src/lib/dom.d.ts.map +1 -0
- package/dist/src/lib/dom.js +34 -0
- package/dist/src/lib/fns.d.ts +7 -0
- package/dist/src/lib/fns.d.ts.map +1 -0
- package/dist/src/lib/fns.js +26 -0
- package/dist/src/styles/design-tokens.d.ts +19 -0
- package/dist/src/styles/design-tokens.d.ts.map +1 -0
- package/dist/src/styles/design-tokens.js +52 -0
- package/dist/src/styles/theme.d.ts +4 -0
- package/dist/src/styles/theme.d.ts.map +1 -0
- package/dist/src/styles/theme.js +294 -0
- package/dist/src/styles/theme.types.d.ts +101 -0
- package/dist/src/styles/theme.types.d.ts.map +1 -0
- package/dist/src/styles/theme.types.js +1 -0
- package/dist/src/types.d.ts +10 -0
- package/dist/src/types.d.ts.map +1 -0
- package/dist/src/types.js +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Config } from "tailwindcss";
|
|
2
|
+
import { createDesignTokens, parsers } from "./src/styles/design-tokens";
|
|
3
|
+
import { defaultDarkTheme } from "./src/styles/theme";
|
|
4
|
+
export declare const css: (template: {
|
|
5
|
+
raw: readonly string[] | ArrayLike<string>;
|
|
6
|
+
}, ...substitutions: any[]) => string;
|
|
7
|
+
declare const config: Partial<Config>;
|
|
8
|
+
export { createDesignTokens, parsers, defaultDarkTheme };
|
|
9
|
+
export default config;
|
|
10
|
+
//# sourceMappingURL=preset.tailwind.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"preset.tailwind.d.ts","sourceRoot":"","sources":["../preset.tailwind.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAErC,OAAO,EAAE,kBAAkB,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAC;AACzE,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAItD,eAAO,MAAM,GAAG;;qCAAa,CAAC;AAI9B,QAAA,MAAM,MAAM,EAAE,OAAO,CAAC,MAAM,CA2C3B,CAAC;AAEF,OAAO,EAAE,kBAAkB,EAAE,OAAO,EAAE,gBAAgB,EAAE,CAAC;AAEzD,eAAe,MAAM,CAAC"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import forms from "@tailwindcss/forms";
|
|
2
|
+
import plugin from "tailwindcss/plugin";
|
|
3
|
+
import { createDesignTokens, parsers } from "./src/styles/design-tokens";
|
|
4
|
+
import { defaultDarkTheme } from "./src/styles/theme";
|
|
5
|
+
const COLORS = createDesignTokens(defaultDarkTheme.colors, parsers.formatWithVar("hsla"));
|
|
6
|
+
export const css = String.raw;
|
|
7
|
+
const spacing = createDesignTokens(defaultDarkTheme.spacing, parsers.cssVariable);
|
|
8
|
+
const config = {
|
|
9
|
+
theme: {
|
|
10
|
+
extend: {
|
|
11
|
+
transitionTimingFunction: {
|
|
12
|
+
DEFAULT: "cubic-bezier(0,0,.58,1)",
|
|
13
|
+
normal: "cubic-bezier(.25,.1,.25,1)",
|
|
14
|
+
},
|
|
15
|
+
spacing,
|
|
16
|
+
transitionDuration: { DEFAULT: "375ms" },
|
|
17
|
+
minWidth: { xs: "20rem", screen: "100vh" },
|
|
18
|
+
borderRadius: createDesignTokens(defaultDarkTheme.rounded, parsers.cssVariable),
|
|
19
|
+
fill: COLORS,
|
|
20
|
+
colors: COLORS,
|
|
21
|
+
placeholderColor: COLORS,
|
|
22
|
+
borderColors: Object.assign(Object.assign({}, COLORS), { DEFAULT: COLORS.card.border }),
|
|
23
|
+
zIndex: {
|
|
24
|
+
normal: "1",
|
|
25
|
+
tooltip: "13",
|
|
26
|
+
floating: "12",
|
|
27
|
+
overlay: "11",
|
|
28
|
+
navbar: "10",
|
|
29
|
+
calendar: "2",
|
|
30
|
+
},
|
|
31
|
+
boxShadow: {
|
|
32
|
+
floating: "rgba(15, 15, 15, 0.1) 0px 0px 0px 1px, rgba(15, 15, 15, 0.1) 0px 3px 6px, rgba(15, 15, 15, 0.2) 0px 5px 12px",
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
plugins: [
|
|
37
|
+
forms({ strategy: "class" }),
|
|
38
|
+
plugin(function ({ addVariant }) {
|
|
39
|
+
addVariant("link", ["&:hover", "&:active"]);
|
|
40
|
+
addVariant("landing", ["&"]);
|
|
41
|
+
addVariant("group-assert", [`:merge(.group):valid:has(.input:valid:not(:placeholder-shown)) &`]);
|
|
42
|
+
addVariant("group-error", [
|
|
43
|
+
`:merge(.group):invalid:has(.input:not(:focus):invalid[data-initialized=true]) &`,
|
|
44
|
+
`:merge(.group[data-error=true]:has(.input[data-initialized=true])) &`,
|
|
45
|
+
`:merge(.group[data-error=true][data-interactive=true]):has(.input) &`,
|
|
46
|
+
`:merge(.group[data-error=true][data-interactive=true]):has(.input[data-initialized=true]) &`,
|
|
47
|
+
]);
|
|
48
|
+
addVariant("group-checkbox-checked", [`:merge(&:has(.form-checkbox[type=checkbox]:checked))`]);
|
|
49
|
+
}),
|
|
50
|
+
],
|
|
51
|
+
};
|
|
52
|
+
export { createDesignTokens, parsers, defaultDarkTheme };
|
|
53
|
+
export default config;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { type VariantProps } from "class-variance-authority";
|
|
2
|
+
import React from "react";
|
|
3
|
+
import { type Label } from "../../types";
|
|
4
|
+
import { PolymorphicProps } from "./polymorph";
|
|
5
|
+
declare const buttonVariants: (props?: ({
|
|
6
|
+
size?: "big" | "small" | "min" | "default" | "icon" | null | undefined;
|
|
7
|
+
rounded?: "circle" | "default" | "rough" | "squared" | null | undefined;
|
|
8
|
+
theme?: "main" | "disabled" | "loading" | "raw" | "danger" | "info" | "neutral" | "primary" | "secondary" | "success" | "warn" | null | undefined;
|
|
9
|
+
} & import("class-variance-authority/dist/types").ClassProp) | undefined) => string;
|
|
10
|
+
export type ButtonProps<T extends React.ElementType = "button"> = PolymorphicProps<VariantProps<typeof buttonVariants> & Partial<{
|
|
11
|
+
icon: Label;
|
|
12
|
+
loading: boolean;
|
|
13
|
+
}>, T>;
|
|
14
|
+
export declare const Button: <T extends React.ElementType = "button">(props: ButtonProps<T>) => any;
|
|
15
|
+
export {};
|
|
16
|
+
//# sourceMappingURL=button.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"button.d.ts","sourceRoot":"","sources":["../../../../src/components/core/button.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAO,KAAK,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAClE,OAAO,KAAqB,MAAM,OAAO,CAAC;AAE1C,OAAO,EAAE,KAAK,KAAK,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAa,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAE1D,QAAA,MAAM,cAAc;;;;mFAiCnB,CAAC;AAEF,MAAM,MAAM,WAAW,CAAC,CAAC,SAAS,KAAK,CAAC,WAAW,GAAG,QAAQ,IAAI,gBAAgB,CAC9E,YAAY,CAAC,OAAO,cAAc,CAAC,GAAG,OAAO,CAAC;IAAE,IAAI,EAAE,KAAK,CAAC;IAAC,OAAO,EAAE,OAAO,CAAA;CAAE,CAAC,EAChF,CAAC,CACJ,CAAC;AAEF,eAAO,MAAM,MAAM,EAAE,CAAC,CAAC,SAAS,KAAK,CAAC,WAAW,GAAG,QAAQ,EAAE,KAAK,EAAE,WAAW,CAAC,CAAC,CAAC,KAAK,GAsB7E,CAAC"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { __rest } from "tslib";
|
|
2
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { cva } from "class-variance-authority";
|
|
4
|
+
import { forwardRef } from "react";
|
|
5
|
+
import { css } from "../../lib/dom";
|
|
6
|
+
import { Polymorph } from "./polymorph";
|
|
7
|
+
const buttonVariants = cva("inline-flex duration-500 enabled:hover:bg-opacity-70 data-[loading=true]:opacity-30 data-[loading=true]:animate-pulse gap-1.5 border-2 border-transparent items-center justify-center align-middle cursor-pointer whitespace-nowrap font-medium transition-colors ease-in disabled:cursor-not-allowed disabled:bg-opacity-40 disabled:text-opacity-80 focus-visible:outline-none focus-visible:ring-4 focus-visible:ring-ring ease-normal", {
|
|
8
|
+
variants: {
|
|
9
|
+
size: {
|
|
10
|
+
default: "h-10 px-4 py-2",
|
|
11
|
+
big: "h-12 px-6 py-4",
|
|
12
|
+
small: "h-8 p-2 text-sm",
|
|
13
|
+
min: "h-7 px-2 py-1 text-sm",
|
|
14
|
+
icon: "p-1",
|
|
15
|
+
},
|
|
16
|
+
rounded: {
|
|
17
|
+
rough: "rounded-sm",
|
|
18
|
+
default: "rounded-button",
|
|
19
|
+
squared: "rounded-none",
|
|
20
|
+
circle: "rounded-full aspect-square",
|
|
21
|
+
},
|
|
22
|
+
theme: {
|
|
23
|
+
raw: "",
|
|
24
|
+
danger: "bg-button-danger-bg text-button-danger-text",
|
|
25
|
+
disabled: "bg-disabled duration-700 opacity-70",
|
|
26
|
+
info: "bg-button-info-bg text-button-info-text",
|
|
27
|
+
loading: "animate-pulse bg-disabled duration-700 opacity-70",
|
|
28
|
+
main: "bg-primary text-primary-foreground",
|
|
29
|
+
neutral: "bg-transparent border border-card-border",
|
|
30
|
+
primary: "bg-button-primary-bg text-button-primary-text",
|
|
31
|
+
secondary: "bg-button-secondary-bg text-button-secondary-text",
|
|
32
|
+
success: "bg-button-success-bg text-button-success-text",
|
|
33
|
+
warn: "bg-button-warn-bg text-button-warn-text",
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
defaultVariants: { theme: "main", size: "default", rounded: "default" },
|
|
37
|
+
});
|
|
38
|
+
export const Button = forwardRef(function Button(_a, ref) {
|
|
39
|
+
var _b;
|
|
40
|
+
var { className, icon, loading, theme, type = "button", size, rounded } = _a, props = __rest(_a, ["className", "icon", "loading", "theme", "type", "size", "rounded"]);
|
|
41
|
+
const disabled = loading || props.disabled;
|
|
42
|
+
return (_jsxs(Polymorph, Object.assign({}, props, { ref: ref, type: type, "data-theme": theme, "data-loading": loading, disabled: disabled, "aria-busy": disabled || loading, as: (_b = props.as) !== null && _b !== void 0 ? _b : "button", onClick: disabled ? undefined : props.onClick, className: css(buttonVariants({ size, rounded, theme }), className), children: [icon, props.children] })));
|
|
43
|
+
});
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { Override } from "../../types";
|
|
3
|
+
type Polymorphism<T extends React.ElementType> = React.PropsWithChildren<{
|
|
4
|
+
as?: T;
|
|
5
|
+
}>;
|
|
6
|
+
type Props<T extends React.ElementType = React.ElementType> = Polymorphism<T> & Omit<React.ComponentPropsWithRef<T>, keyof Polymorphism<T>>;
|
|
7
|
+
export type PolymorphicProps<P extends {}, T extends React.ElementType = React.ElementType> = Omit<T extends string ? Override<React.ComponentProps<T> & Props<T>, P> : Override<Props<T>, P>, keyof Polymorphism<T>> & Polymorphism<T>;
|
|
8
|
+
export declare const Polymorph: React.ForwardRefExoticComponent<Omit<Props<React.ElementType<any, keyof React.JSX.IntrinsicElements>>, "ref"> & React.RefAttributes<any>>;
|
|
9
|
+
export {};
|
|
10
|
+
//# sourceMappingURL=polymorph.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"polymorph.d.ts","sourceRoot":"","sources":["../../../../src/components/core/polymorph.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAqB,MAAM,OAAO,CAAC;AAC1C,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAEvC,KAAK,YAAY,CAAC,CAAC,SAAS,KAAK,CAAC,WAAW,IAAI,KAAK,CAAC,iBAAiB,CAAC;IAAE,EAAE,CAAC,EAAE,CAAC,CAAA;CAAE,CAAC,CAAC;AAErF,KAAK,KAAK,CAAC,CAAC,SAAS,KAAK,CAAC,WAAW,GAAG,KAAK,CAAC,WAAW,IAAI,YAAY,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,qBAAqB,CAAC,CAAC,CAAC,EAAE,MAAM,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC;AAE5I,MAAM,MAAM,gBAAgB,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,SAAS,KAAK,CAAC,WAAW,GAAG,KAAK,CAAC,WAAW,IAAI,IAAI,CAC9F,CAAC,SAAS,MAAM,GAAG,QAAQ,CAAC,KAAK,CAAC,cAAc,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAC1F,MAAM,YAAY,CAAC,CAAC,CAAC,CACxB,GACG,YAAY,CAAC,CAAC,CAAC,CAAC;AAEpB,eAAO,MAAM,SAAS,2IAGpB,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { __rest } from "tslib";
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import { forwardRef } from "react";
|
|
4
|
+
export const Polymorph = forwardRef(function Polymorph(_a, ref) {
|
|
5
|
+
var { as } = _a, props = __rest(_a, ["as"]);
|
|
6
|
+
const Component = as || "span";
|
|
7
|
+
return _jsx(Component, Object.assign({}, props, { ref: ref }));
|
|
8
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resizable.d.ts","sourceRoot":"","sources":["../../../../src/components/core/resizable.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAuC,MAAM,OAAO,CAAC;AAoD5D,eAAO,MAAM,SAAS,iBAAkB,KAAK,CAAC,iBAAiB,4CAQ9D,CAAC"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import { motion, useMotionValue } from "framer-motion";
|
|
4
|
+
import { useEffect, useMemo, useState } from "react";
|
|
5
|
+
import { isSsr } from "../../lib/fns";
|
|
6
|
+
const defaultState = {
|
|
7
|
+
x: 0,
|
|
8
|
+
y: 0,
|
|
9
|
+
width: 0,
|
|
10
|
+
height: 0,
|
|
11
|
+
top: 0,
|
|
12
|
+
left: 0,
|
|
13
|
+
bottom: 0,
|
|
14
|
+
right: 0,
|
|
15
|
+
};
|
|
16
|
+
const useElementRect = () => {
|
|
17
|
+
const [element, ref] = useState(null);
|
|
18
|
+
const motion = useMotionValue(defaultState);
|
|
19
|
+
const observer = useMemo(() => isSsr()
|
|
20
|
+
? null
|
|
21
|
+
: new window.ResizeObserver((entries) => {
|
|
22
|
+
if (entries[0]) {
|
|
23
|
+
const rect = entries[0].contentRect;
|
|
24
|
+
motion.set({
|
|
25
|
+
x: rect.x,
|
|
26
|
+
y: rect.y,
|
|
27
|
+
width: rect.width,
|
|
28
|
+
height: rect.height,
|
|
29
|
+
top: rect.top,
|
|
30
|
+
left: rect.left,
|
|
31
|
+
bottom: rect.bottom,
|
|
32
|
+
right: rect.right,
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
}), []);
|
|
36
|
+
useEffect(() => {
|
|
37
|
+
if (!element)
|
|
38
|
+
return;
|
|
39
|
+
if (observer === null)
|
|
40
|
+
return;
|
|
41
|
+
observer.observe(element);
|
|
42
|
+
return () => observer.disconnect();
|
|
43
|
+
}, [element]);
|
|
44
|
+
return [ref, motion];
|
|
45
|
+
};
|
|
46
|
+
export const Resizable = ({ children }) => {
|
|
47
|
+
const [ref, bounds] = useElementRect();
|
|
48
|
+
const h = bounds.get().height;
|
|
49
|
+
return (_jsx(motion.div, { animate: { height: h > 0 ? h : "auto" }, children: _jsx("div", { ref: ref, children: children }) }));
|
|
50
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { type VariantProps } from "class-variance-authority";
|
|
2
|
+
import React from "react";
|
|
3
|
+
import { Label } from "../../types";
|
|
4
|
+
import { PolymorphicProps } from "./polymorph";
|
|
5
|
+
declare const indicatorVariant: (props?: ({
|
|
6
|
+
theme?: "main" | "danger" | "info" | "secondary" | "success" | "warn" | null | undefined;
|
|
7
|
+
} & import("class-variance-authority/dist/types").ClassProp) | undefined) => string;
|
|
8
|
+
declare const tagVariants: (props?: ({
|
|
9
|
+
size?: "big" | "small" | "default" | "icon" | null | undefined;
|
|
10
|
+
theme?: "disabled" | "loading" | "danger" | "info" | "neutral" | "primary" | "secondary" | "success" | "warn" | null | undefined;
|
|
11
|
+
} & import("class-variance-authority/dist/types").ClassProp) | undefined) => string;
|
|
12
|
+
export type TagProps<T extends React.ElementType = "span"> = PolymorphicProps<VariantProps<typeof tagVariants> & Partial<{
|
|
13
|
+
icon: Label;
|
|
14
|
+
loading: boolean;
|
|
15
|
+
indicator: VariantProps<typeof indicatorVariant>["theme"];
|
|
16
|
+
}>, T>;
|
|
17
|
+
export declare const Tag: <T extends React.ElementType = "span">(props: TagProps<T>) => any;
|
|
18
|
+
export {};
|
|
19
|
+
//# sourceMappingURL=tag.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tag.d.ts","sourceRoot":"","sources":["../../../../src/components/core/tag.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAO,KAAK,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAClE,OAAO,KAAqB,MAAM,OAAO,CAAC;AAE1C,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACpC,OAAO,EAAa,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAE1D,QAAA,MAAM,gBAAgB;;mFAWpB,CAAC;AAEH,QAAA,MAAM,WAAW;;;mFAqBf,CAAC;AAEH,MAAM,MAAM,QAAQ,CAAC,CAAC,SAAS,KAAK,CAAC,WAAW,GAAG,MAAM,IAAI,gBAAgB,CACzE,YAAY,CAAC,OAAO,WAAW,CAAC,GAC5B,OAAO,CAAC;IACJ,IAAI,EAAE,KAAK,CAAC;IACZ,OAAO,EAAE,OAAO,CAAC;IACjB,SAAS,EAAE,YAAY,CAAC,OAAO,gBAAgB,CAAC,CAAC,OAAO,CAAC,CAAC;CAC7D,CAAC,EACN,CAAC,CACJ,CAAC;AAEF,eAAO,MAAM,GAAG,EAAE,CAAC,CAAC,SAAS,KAAK,CAAC,WAAW,GAAG,MAAM,EAAE,KAAK,EAAE,QAAQ,CAAC,CAAC,CAAC,KAAK,GAWrE,CAAC"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { __rest } from "tslib";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { cva } from "class-variance-authority";
|
|
4
|
+
import { forwardRef } from "react";
|
|
5
|
+
import { css } from "../../lib/dom";
|
|
6
|
+
import { Polymorph } from "./polymorph";
|
|
7
|
+
const indicatorVariant = cva("size-2.5 aspect-square rounded-full border-0", {
|
|
8
|
+
variants: {
|
|
9
|
+
theme: {
|
|
10
|
+
warn: "bg-warn",
|
|
11
|
+
info: "bg-info",
|
|
12
|
+
main: "bg-primary",
|
|
13
|
+
danger: "bg-danger",
|
|
14
|
+
success: "bg-success",
|
|
15
|
+
secondary: "bg-secondary",
|
|
16
|
+
},
|
|
17
|
+
},
|
|
18
|
+
});
|
|
19
|
+
const tagVariants = cva("inline-flex rounded-pill gap-1.5 border-2 border-transparent items-center justify-center align-middle whitespace-nowrap", {
|
|
20
|
+
variants: {
|
|
21
|
+
size: {
|
|
22
|
+
icon: "p-1",
|
|
23
|
+
big: "h-12 px-6 py-4",
|
|
24
|
+
default: "h-8 px-4 py-2",
|
|
25
|
+
small: "h-6 p-2 px-3 text-sm",
|
|
26
|
+
},
|
|
27
|
+
theme: {
|
|
28
|
+
primary: "bg-tag-primary-bg text-tag-primary-text",
|
|
29
|
+
danger: "bg-tag-danger-bg text-tag-danger-text",
|
|
30
|
+
info: "bg-tag-info-bg text-tag-info-text",
|
|
31
|
+
success: "bg-tag-success-bg text-tag-success-text",
|
|
32
|
+
secondary: "bg-tag-secondary-bg text-tag-secondary-text",
|
|
33
|
+
warn: "bg-tag-warn-bg text-tag-warn-text",
|
|
34
|
+
neutral: "bg-transparent border border-card-border",
|
|
35
|
+
disabled: "bg-disabled duration-700 opacity-70",
|
|
36
|
+
loading: "animate-pulse bg-disabled duration-700 opacity-70",
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
defaultVariants: { theme: "primary", size: "default" },
|
|
40
|
+
});
|
|
41
|
+
export const Tag = forwardRef(function Tag(_a, ref) {
|
|
42
|
+
var _b;
|
|
43
|
+
var { className, indicator = undefined, icon, loading, theme, size } = _a, props = __rest(_a, ["className", "indicator", "icon", "loading", "theme", "size"]);
|
|
44
|
+
return (_jsxs(Polymorph, Object.assign({}, props, { ref: ref, "data-theme": theme, as: (_b = props.as) !== null && _b !== void 0 ? _b : "span", className: css(tagVariants({ size, theme }), className), children: [indicator ? _jsx("span", { className: indicatorVariant({ theme: indicator }) }) : null, icon, props.children] })));
|
|
45
|
+
});
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { type VariantProps } from "class-variance-authority";
|
|
2
|
+
import { HTMLMotionProps } from "framer-motion";
|
|
3
|
+
import React, { PropsWithChildren } from "react";
|
|
4
|
+
import { PolymorphicProps } from "../core/polymorph";
|
|
5
|
+
type CollapseProps = {
|
|
6
|
+
open: boolean;
|
|
7
|
+
} & HTMLMotionProps<"section">;
|
|
8
|
+
export declare const Collapse: (props: PropsWithChildren<CollapseProps>) => import("react/jsx-runtime").JSX.Element;
|
|
9
|
+
declare const alertVariants: (props?: ({
|
|
10
|
+
theme?: "danger" | "info" | "neutral" | "success" | null | undefined;
|
|
11
|
+
} & import("class-variance-authority/dist/types").ClassProp) | undefined) => string;
|
|
12
|
+
export type AlertProps<T extends React.ElementType = "div"> = PolymorphicProps<VariantProps<typeof alertVariants> & Partial<{
|
|
13
|
+
container: string;
|
|
14
|
+
open?: boolean;
|
|
15
|
+
onClose: (nextState: boolean) => void;
|
|
16
|
+
}>, T>;
|
|
17
|
+
export declare const Alert: <T extends React.ElementType = "div">(props: AlertProps<T>) => any;
|
|
18
|
+
export {};
|
|
19
|
+
//# sourceMappingURL=alert.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"alert.d.ts","sourceRoot":"","sources":["../../../../src/components/display/alert.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAO,KAAK,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAClE,OAAO,EAAE,eAAe,EAAU,MAAM,eAAe,CAAC;AAExD,OAAO,KAAK,EAAE,EAAc,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAE7D,OAAO,EAAa,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAahE,KAAK,aAAa,GAAG;IAAE,IAAI,EAAE,OAAO,CAAA;CAAE,GAAG,eAAe,CAAC,SAAS,CAAC,CAAC;AAEpE,eAAO,MAAM,QAAQ,UAAW,iBAAiB,CAAC,aAAa,CAAC,4CAgB/D,CAAC;AAEF,QAAA,MAAM,aAAa;;mFAUjB,CAAC;AAEH,MAAM,MAAM,UAAU,CAAC,CAAC,SAAS,KAAK,CAAC,WAAW,GAAG,KAAK,IAAI,gBAAgB,CAC1E,YAAY,CAAC,OAAO,aAAa,CAAC,GAC9B,OAAO,CAAC;IACJ,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,OAAO,EAAE,CAAC,SAAS,EAAE,OAAO,KAAK,IAAI,CAAC;CACzC,CAAC,EACN,CAAC,CACJ,CAAC;AAEF,eAAO,MAAM,KAAK,EAAE,CAAC,CAAC,SAAS,KAAK,CAAC,WAAW,GAAG,KAAK,EAAE,KAAK,EAAE,UAAU,CAAC,CAAC,CAAC,KAAK,GAuCxE,CAAC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { __rest } from "tslib";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { cva } from "class-variance-authority";
|
|
4
|
+
import { motion } from "framer-motion";
|
|
5
|
+
import { CheckCircleIcon, CircleAlertIcon, InfoIcon, XIcon } from "lucide-react";
|
|
6
|
+
import { forwardRef } from "react";
|
|
7
|
+
import { css } from "../../lib/dom";
|
|
8
|
+
import { Polymorph } from "../core/polymorph";
|
|
9
|
+
const variants = {
|
|
10
|
+
true: { opacity: 1, height: "auto" },
|
|
11
|
+
false: { opacity: [0.7, 0.3, 0], height: 0 },
|
|
12
|
+
};
|
|
13
|
+
const transition = {
|
|
14
|
+
type: "tween",
|
|
15
|
+
duration: 0.7,
|
|
16
|
+
ease: [0.04, 0.62, 0.23, 0.98],
|
|
17
|
+
};
|
|
18
|
+
export const Collapse = (props) => (_jsx(motion.section, Object.assign({}, props, { layout: true, layoutRoot: true, layoutScroll: true, initial: false, animate: props.open.toString(), "aria-hidden": !props.open, className: props.className, exit: variants.false, transition: transition, variants: variants, children: props.children })));
|
|
19
|
+
const alertVariants = cva("px-4 py-4 border relative rounded-lg text-sm", {
|
|
20
|
+
variants: {
|
|
21
|
+
theme: {
|
|
22
|
+
neutral: "border-border bg-background",
|
|
23
|
+
danger: "text-danger-contrast bg-danger/10 border-danger/50",
|
|
24
|
+
success: "text-success-foreground bg-success/10 border-success/50",
|
|
25
|
+
info: "text-info bg-info/10 border-info/50",
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
defaultVariants: { theme: "neutral" },
|
|
29
|
+
});
|
|
30
|
+
export const Alert = forwardRef(function Alert(_a, ref) {
|
|
31
|
+
var _b;
|
|
32
|
+
var { className, theme, onClose, open = true } = _a, props = __rest(_a, ["className", "theme", "onClose", "open"]);
|
|
33
|
+
return (_jsx("div", { "data-open": !!open, "aria-hidden": !open, className: "pointer-events-none isolate data-[open=true]:pointer-events-auto data-[open=true]:mb-4", children: _jsx(Collapse, { "data-open": !!open, open: !!open, children: _jsxs(Polymorph, Object.assign({}, props, { className: css(alertVariants({ theme }), className), ref: ref, "data-theme": theme, role: "alert", as: (_b = props.as) !== null && _b !== void 0 ? _b : "div", children: [_jsxs("h4", { className: "mb-2 flex items-center gap-2", children: [theme === "success" ? _jsx(CheckCircleIcon, { size: 20 }) : null, theme === "info" ? _jsx(InfoIcon, { size: 20 }) : null, theme === "danger" ? _jsx(CircleAlertIcon, { size: 20 }) : null, _jsx("span", { className: "tracking-3 text-balance text-lg font-semibold", children: props.title })] }), props.children, onClose !== undefined ? (_jsx("button", { type: "button", onClick: () => onClose(false), className: "duration-300 ease-in-out absolute right-3 top-3 text-foreground transition-colors hover:text-danger", children: _jsx(XIcon, { size: 20 }) })) : null] })) }) }));
|
|
34
|
+
});
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { Locales } from "the-mask-input";
|
|
3
|
+
type Range = {
|
|
4
|
+
from?: Date;
|
|
5
|
+
to?: Date;
|
|
6
|
+
};
|
|
7
|
+
type OnChangeDate = (d: Date | undefined) => void;
|
|
8
|
+
type OnChangeRange = (d: Range | undefined) => void;
|
|
9
|
+
export type CalendarProps<T extends "date" | "range" | undefined = undefined> = Partial<{
|
|
10
|
+
locale: Locales;
|
|
11
|
+
markToday: boolean;
|
|
12
|
+
rangeMode: boolean;
|
|
13
|
+
changeOnlyOnClick: boolean;
|
|
14
|
+
onChangeMonth: (d: Date) => void;
|
|
15
|
+
onChangeYear: (d: Date) => void;
|
|
16
|
+
RenderOnDay: React.FC<{
|
|
17
|
+
date: Date;
|
|
18
|
+
}>;
|
|
19
|
+
disabledDate: (date: Date) => boolean;
|
|
20
|
+
styles: Partial<{
|
|
21
|
+
day: string;
|
|
22
|
+
week: string;
|
|
23
|
+
weekDay: string;
|
|
24
|
+
dayFrame: string;
|
|
25
|
+
calendar: string;
|
|
26
|
+
}>;
|
|
27
|
+
} & (T extends "date" ? {
|
|
28
|
+
date: Date;
|
|
29
|
+
onChange: OnChangeDate;
|
|
30
|
+
} : T extends "range" ? {
|
|
31
|
+
range: Range;
|
|
32
|
+
onChange: OnChangeRange;
|
|
33
|
+
} : {}) & ({
|
|
34
|
+
date: Date;
|
|
35
|
+
onChange: OnChangeDate;
|
|
36
|
+
} | {
|
|
37
|
+
range: Range;
|
|
38
|
+
onChange: OnChangeRange;
|
|
39
|
+
})>;
|
|
40
|
+
export declare const Calendar: ({ RenderOnDay, changeOnlyOnClick, disabledDate, locale, markToday, onChangeMonth, onChangeYear, rangeMode, onChange, styles, ...props }: CalendarProps) => import("react/jsx-runtime").JSX.Element;
|
|
41
|
+
export {};
|
|
42
|
+
//# sourceMappingURL=calendar.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"calendar.d.ts","sourceRoot":"","sources":["../../../../src/components/display/calendar.tsx"],"names":[],"mappings":"AAsBA,OAAO,KAAuC,MAAM,OAAO,CAAC;AAE5D,OAAqB,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAqBvD,KAAK,KAAK,GAAG;IAAE,IAAI,CAAC,EAAE,IAAI,CAAC;IAAC,EAAE,CAAC,EAAE,IAAI,CAAA;CAAE,CAAC;AAExC,KAAK,YAAY,GAAG,CAAC,CAAC,EAAE,IAAI,GAAG,SAAS,KAAK,IAAI,CAAC;AAElD,KAAK,aAAa,GAAG,CAAC,CAAC,EAAE,KAAK,GAAG,SAAS,KAAK,IAAI,CAAC;AAEpD,MAAM,MAAM,aAAa,CAAC,CAAC,SAAS,MAAM,GAAG,OAAO,GAAG,SAAS,GAAG,SAAS,IAAI,OAAO,CACnF;IACI,MAAM,EAAE,OAAO,CAAC;IAChB,SAAS,EAAE,OAAO,CAAC;IACnB,SAAS,EAAE,OAAO,CAAC;IACnB,iBAAiB,EAAE,OAAO,CAAC;IAC3B,aAAa,EAAE,CAAC,CAAC,EAAE,IAAI,KAAK,IAAI,CAAC;IACjC,YAAY,EAAE,CAAC,CAAC,EAAE,IAAI,KAAK,IAAI,CAAC;IAChC,WAAW,EAAE,KAAK,CAAC,EAAE,CAAC;QAAE,IAAI,EAAE,IAAI,CAAA;KAAE,CAAC,CAAC;IACtC,YAAY,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,OAAO,CAAC;IACtC,MAAM,EAAE,OAAO,CAAC;QACZ,GAAG,EAAE,MAAM,CAAC;QACZ,IAAI,EAAE,MAAM,CAAC;QACb,OAAO,EAAE,MAAM,CAAC;QAChB,QAAQ,EAAE,MAAM,CAAC;QACjB,QAAQ,EAAE,MAAM,CAAC;KACpB,CAAC,CAAC;CACN,GAAG,CAAC,CAAC,SAAS,MAAM,GAAG;IAAE,IAAI,EAAE,IAAI,CAAC;IAAC,QAAQ,EAAE,YAAY,CAAA;CAAE,GAAG,CAAC,SAAS,OAAO,GAAG;IAAE,KAAK,EAAE,KAAK,CAAC;IAAC,QAAQ,EAAE,aAAa,CAAA;CAAE,GAAG,EAAE,CAAC,GAChI,CAAC;IAAE,IAAI,EAAE,IAAI,CAAC;IAAC,QAAQ,EAAE,YAAY,CAAA;CAAE,GAAG;IAAE,KAAK,EAAE,KAAK,CAAC;IAAC,QAAQ,EAAE,aAAa,CAAA;CAAE,CAAC,CAC3F,CAAC;AAoDF,eAAO,MAAM,QAAQ,4IAYlB,aAAa,4CAgRf,CAAC"}
|
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { __rest } from "tslib";
|
|
3
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
4
|
+
import { addDays, addMonths, addWeeks, addYears, eachDayOfInterval, endOfWeek, isAfter, isBefore, isSameMonth, isToday, startOfDay, startOfMonth, startOfWeek, subDays, subMonths, subWeeks, subYears, } from "date-fns";
|
|
5
|
+
import { AnimatePresence, motion, MotionConfig } from "framer-motion";
|
|
6
|
+
import { ChevronLeftIcon, ChevronRightIcon } from "lucide-react";
|
|
7
|
+
import { useEffect, useRef } from "react";
|
|
8
|
+
import { Is } from "sidekicker";
|
|
9
|
+
import TheMaskInput from "the-mask-input";
|
|
10
|
+
import { useReducer } from "use-typed-reducer";
|
|
11
|
+
import { useDebounce } from "../../hooks/use-debounce";
|
|
12
|
+
import { useTranslations } from "../../hooks/use-translate-context";
|
|
13
|
+
import { css } from "../../lib/dom";
|
|
14
|
+
import { splitInto } from "../../lib/fns";
|
|
15
|
+
const transition = { type: "spring", bounce: 0.3, duration: 0.6 };
|
|
16
|
+
const dir = (mod) => (n = 1) => ({ x: `${100 * mod * n}%`, opacity: 0.25 });
|
|
17
|
+
const variants = {
|
|
18
|
+
middle: { x: "0%", opacity: 1 },
|
|
19
|
+
enter: dir(1),
|
|
20
|
+
exit: dir(-1),
|
|
21
|
+
};
|
|
22
|
+
const removeImmediately = { exit: { visibility: "hidden" } };
|
|
23
|
+
const createDays = (month) => {
|
|
24
|
+
const start = startOfWeek(startOfMonth(month));
|
|
25
|
+
return eachDayOfInterval({ start, end: addDays(start, 41) });
|
|
26
|
+
};
|
|
27
|
+
const formatMonth = (d, locale) => d.toLocaleDateString(locale, { month: "long" });
|
|
28
|
+
const getOptionsMonth = (date, locale) => Array.from({ length: 12 }).map((_, i) => {
|
|
29
|
+
const month = startOfMonth(new Date(date).setMonth(i));
|
|
30
|
+
const label = formatMonth(month, locale);
|
|
31
|
+
return (_jsx("option", { value: label, "data-index": i, children: label }, label));
|
|
32
|
+
});
|
|
33
|
+
const onChangeUsingKeyboard = {
|
|
34
|
+
ArrowLeft: (date, duration) => (duration === "days" ? subDays(date, 1) : subMonths(date, 1)),
|
|
35
|
+
ArrowRight: (date, duration) => (duration === "days" ? addDays(date, 1) : addMonths(date, 1)),
|
|
36
|
+
ArrowUp: (date, duration) => (duration === "days" ? subWeeks(date, 1) : subYears(date, 1)),
|
|
37
|
+
ArrowDown: (date, duration) => (duration === "days" ? addWeeks(date, 1) : addYears(date, 1)),
|
|
38
|
+
};
|
|
39
|
+
const focusDate = (origin, root, next, delay = 0) => {
|
|
40
|
+
const d = next.toISOString();
|
|
41
|
+
const select = () => {
|
|
42
|
+
var _a;
|
|
43
|
+
if (!!(origin === null || origin === void 0 ? void 0 : origin.dataset.focustrap)) {
|
|
44
|
+
const el = (_a = root.current) === null || _a === void 0 ? void 0 : _a.querySelector(`button[data-focustrap="${origin === null || origin === void 0 ? void 0 : origin.dataset.focustrap}"]`);
|
|
45
|
+
return setTimeout(() => el === null || el === void 0 ? void 0 : el.focus({ preventScroll: false }), delay);
|
|
46
|
+
}
|
|
47
|
+
if (root.current) {
|
|
48
|
+
const element = root.current.querySelector(`button[data-date="${d}"]`);
|
|
49
|
+
if (element)
|
|
50
|
+
return element.focus({ preventScroll: false });
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
if (delay === 0)
|
|
54
|
+
select();
|
|
55
|
+
setTimeout(select, delay);
|
|
56
|
+
};
|
|
57
|
+
const formatYear = (now) => now.getFullYear().toString().padStart(4, "0");
|
|
58
|
+
const inRange = (start, middle, end) => {
|
|
59
|
+
if (start === undefined || end === undefined)
|
|
60
|
+
return false;
|
|
61
|
+
return isAfter(middle, start) && isBefore(middle, end);
|
|
62
|
+
};
|
|
63
|
+
export const Calendar = (_a) => {
|
|
64
|
+
var { RenderOnDay, changeOnlyOnClick = false, disabledDate, locale, markToday = true, onChangeMonth, onChangeYear, rangeMode = false, onChange, styles } = _a, props = __rest(_a, ["RenderOnDay", "changeOnlyOnClick", "disabledDate", "locale", "markToday", "onChangeMonth", "onChangeYear", "rangeMode", "onChange", "styles"]);
|
|
65
|
+
const translate = useTranslations();
|
|
66
|
+
const root = useRef(null);
|
|
67
|
+
const { date, range } = props;
|
|
68
|
+
const now = date || new Date();
|
|
69
|
+
const monthClicked = useRef(null);
|
|
70
|
+
const [state, dispatch] = useReducer({
|
|
71
|
+
date: now,
|
|
72
|
+
isAnimating: false,
|
|
73
|
+
year: formatYear(now),
|
|
74
|
+
months: getOptionsMonth(now, locale),
|
|
75
|
+
direction: undefined,
|
|
76
|
+
range: { from: range === null || range === void 0 ? void 0 : range.from, to: range === null || range === void 0 ? void 0 : range.to },
|
|
77
|
+
selectMode: (rangeMode ? "from" : undefined),
|
|
78
|
+
week: eachDayOfInterval({ start: startOfWeek(now), end: endOfWeek(now) }),
|
|
79
|
+
}, (get) => ({
|
|
80
|
+
onChangeYear: (year) => ({ year }),
|
|
81
|
+
setToday: () => ({ date: startOfDay(new Date()) }),
|
|
82
|
+
onExitComplete: () => {
|
|
83
|
+
focusDate(monthClicked.current || null, root, get.state().date, 200);
|
|
84
|
+
monthClicked.current = null;
|
|
85
|
+
return { isAnimating: false };
|
|
86
|
+
},
|
|
87
|
+
date: (callback) => {
|
|
88
|
+
const newDate = callback(get.state().date);
|
|
89
|
+
return { date: newDate, year: formatYear(newDate) };
|
|
90
|
+
},
|
|
91
|
+
nextMonth: (e) => {
|
|
92
|
+
monthClicked.current = e.currentTarget;
|
|
93
|
+
const state = get.state();
|
|
94
|
+
if (state.isAnimating)
|
|
95
|
+
return state;
|
|
96
|
+
const date = addMonths(state.date, 1);
|
|
97
|
+
return { date, isAnimating: true, direction: 1, year: formatYear(date) };
|
|
98
|
+
},
|
|
99
|
+
previousMonth: (e) => {
|
|
100
|
+
monthClicked.current = e.currentTarget;
|
|
101
|
+
const state = get.state();
|
|
102
|
+
if (state.isAnimating)
|
|
103
|
+
return state;
|
|
104
|
+
const date = subMonths(state.date, 1);
|
|
105
|
+
return { date, isAnimating: true, direction: -1, year: formatYear(date) };
|
|
106
|
+
},
|
|
107
|
+
onSelectDate: (e) => {
|
|
108
|
+
const state = get.state();
|
|
109
|
+
const isRangeMode = e.currentTarget.dataset.range === "true";
|
|
110
|
+
const d = e.currentTarget.dataset.date || "";
|
|
111
|
+
const date = new Date(d);
|
|
112
|
+
return {
|
|
113
|
+
date,
|
|
114
|
+
year: formatYear(date),
|
|
115
|
+
selectMode: state.selectMode === undefined ? undefined : state.selectMode === "from" ? "to" : "from",
|
|
116
|
+
range: !isRangeMode
|
|
117
|
+
? state.range
|
|
118
|
+
: {
|
|
119
|
+
from: state.selectMode === "from" ? date : state.range.from,
|
|
120
|
+
to: state.selectMode === "to" ? date : state.range.to,
|
|
121
|
+
},
|
|
122
|
+
};
|
|
123
|
+
},
|
|
124
|
+
onChangeMonth: (e) => {
|
|
125
|
+
const value = e.target.value;
|
|
126
|
+
const array = Array.from(e.target.options);
|
|
127
|
+
const month = array.find((x) => x.value === value);
|
|
128
|
+
const state = get.state();
|
|
129
|
+
if (month) {
|
|
130
|
+
const i = month.dataset.index || "";
|
|
131
|
+
const d = new Date(get.state().date);
|
|
132
|
+
d.setMonth(+i);
|
|
133
|
+
return Object.assign(Object.assign({}, state), { date: d, year: formatYear(d) });
|
|
134
|
+
}
|
|
135
|
+
return state;
|
|
136
|
+
},
|
|
137
|
+
onKeyDown: (e) => {
|
|
138
|
+
const key = e.key;
|
|
139
|
+
const state = get.state();
|
|
140
|
+
if (key in onChangeUsingKeyboard) {
|
|
141
|
+
if (key === "ArrowUp" || key === "ArrowDown")
|
|
142
|
+
e.preventDefault();
|
|
143
|
+
const prev = get.state().date;
|
|
144
|
+
const date = Is.keyof(onChangeUsingKeyboard, key) ? onChangeUsingKeyboard[key](prev, e.shiftKey ? "month" : "days") : null;
|
|
145
|
+
if (date !== null) {
|
|
146
|
+
focusDate(e.target, root, date);
|
|
147
|
+
return Object.assign(Object.assign({}, state), { date, year: formatYear(date) });
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
return get.state();
|
|
151
|
+
},
|
|
152
|
+
}), {
|
|
153
|
+
props: { onChangeMonth, onChangeYear },
|
|
154
|
+
postMiddleware: [
|
|
155
|
+
(state, _, args) => {
|
|
156
|
+
var _a, _b;
|
|
157
|
+
const isValidMethod = args.method === "onChangeMonth" || args.method === "previousMonth" || args.method === "nextMonth";
|
|
158
|
+
if (isValidMethod)
|
|
159
|
+
(_b = (_a = args.props).onChangeMonth) === null || _b === void 0 ? void 0 : _b.call(_a, state.date);
|
|
160
|
+
return state;
|
|
161
|
+
},
|
|
162
|
+
(state, _, args) => {
|
|
163
|
+
var _a, _b;
|
|
164
|
+
const isValidMethod = args.method === "onChangeYear";
|
|
165
|
+
if (isValidMethod)
|
|
166
|
+
(_b = (_a = args.props).onChangeYear) === null || _b === void 0 ? void 0 : _b.call(_a, state.date);
|
|
167
|
+
return state;
|
|
168
|
+
},
|
|
169
|
+
(state, _, args) => {
|
|
170
|
+
const isValidMethod = args.method === "onSelectDate" || args.method === "setToday" || args.method === "onKeyDown";
|
|
171
|
+
if (rangeMode && isValidMethod && changeOnlyOnClick) {
|
|
172
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(state.range);
|
|
173
|
+
return state;
|
|
174
|
+
}
|
|
175
|
+
if (isValidMethod && changeOnlyOnClick)
|
|
176
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(state.date);
|
|
177
|
+
return state;
|
|
178
|
+
},
|
|
179
|
+
],
|
|
180
|
+
});
|
|
181
|
+
const zip = splitInto(createDays(state.date), 7);
|
|
182
|
+
const currentAsString = state.date.toISOString();
|
|
183
|
+
const monthString = formatMonth(state.date, locale);
|
|
184
|
+
useEffect(() => {
|
|
185
|
+
if (!changeOnlyOnClick)
|
|
186
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(state.date);
|
|
187
|
+
}, [currentAsString]);
|
|
188
|
+
const defer = useDebounce((y) => {
|
|
189
|
+
dispatch.date((prev) => {
|
|
190
|
+
const d = new Date(prev);
|
|
191
|
+
d.setFullYear(+y);
|
|
192
|
+
return d;
|
|
193
|
+
});
|
|
194
|
+
}, 1200);
|
|
195
|
+
const internalOnChangeYear = (e) => {
|
|
196
|
+
const value = e.currentTarget.value;
|
|
197
|
+
dispatch.onChangeYear(value);
|
|
198
|
+
onChangeYear === null || onChangeYear === void 0 ? void 0 : onChangeYear(new Date(value));
|
|
199
|
+
defer(value);
|
|
200
|
+
};
|
|
201
|
+
return (_jsx(MotionConfig, { transition: transition, children: _jsxs("div", { ref: root, className: css("relative overflow-hidden", styles === null || styles === void 0 ? void 0 : styles.calendar), children: [_jsx("div", { className: "flex flex-col justify-center rounded text-center", children: _jsx(AnimatePresence, { initial: false, mode: "popLayout", custom: state.direction, onExitComplete: dispatch.onExitComplete, children: _jsxs(motion.div, { initial: "enter", animate: "middle", exit: "exit", children: [_jsxs("header", { className: "relative flex justify-between", children: [_jsx(motion.button, { layout: true, "data-focustrap": "prev", variants: removeImmediately, onClick: dispatch.previousMonth, className: "z-calendar rounded-full p-1.5 hover:bg-primary", children: _jsx(ChevronLeftIcon, { className: "h-4 w-4" }) }), _jsx(motion.span, { layout: true, variants: variants, custom: state.direction, className: "absolute inset-0 isolate z-normal flex items-center justify-center font-semibold", children: _jsxs("span", { className: "flex w-fit items-center justify-center gap-0.5 py-1", children: [_jsx("select", { style: { width: `${monthString.length}ch` }, value: monthString, onChange: dispatch.onChangeMonth, className: "w-fit cursor-pointer appearance-none bg-transparent capitalize proportional-nums hover:text-primary", children: state.months }), _jsx(TheMaskInput, { mask: "int", value: state.year, maxLength: 4, placeholder: "YYYY", onChange: internalOnChangeYear, style: { width: `${state.year.length}ch` }, className: "w-16 cursor-pointer appearance-none bg-transparent hover:text-primary" })] }) }), _jsx(motion.button, { layout: true, "data-focustrap": "next", variants: removeImmediately, className: "z-calendar rounded-full p-1.5 hover:bg-primary", onClick: dispatch.nextMonth, children: _jsx(ChevronRightIcon, { className: "h-4 w-4" }) }), _jsx("div", { className: "absolute inset-0", style: {
|
|
202
|
+
backgroundImage: "linear-gradient(to right, hsla(var(--card-background)) 15%, transparent 30%, transparent 70%, hsla(var(--card-background)) 85%)",
|
|
203
|
+
} })] }), _jsxs(motion.table, { className: "mt-2 table min-w-full table-auto border-0", children: [_jsx("thead", { children: _jsx("tr", { children: state.week.map((dayOfWeek) => (_jsx("th", { className: css("py-2 text-sm font-medium capitalize", styles === null || styles === void 0 ? void 0 : styles.weekDay), children: dayOfWeek.toLocaleDateString(locale, { weekday: "short" }) }, dayOfWeek.toString()))) }) }), _jsx(motion.tbody, { layout: true, variants: variants, custom: state.direction, onKeyDown: dispatch.onKeyDown, className: css(styles === null || styles === void 0 ? void 0 : styles.week), children: zip.map((week, index) => (_jsx("tr", { className: styles === null || styles === void 0 ? void 0 : styles.week, children: week.map((day) => {
|
|
204
|
+
var _a, _b, _c, _d;
|
|
205
|
+
const key = day.toISOString();
|
|
206
|
+
const isSelected = rangeMode
|
|
207
|
+
? key === ((_a = range === null || range === void 0 ? void 0 : range.to) === null || _a === void 0 ? void 0 : _a.toISOString()) || key === ((_b = range === null || range === void 0 ? void 0 : range.from) === null || _b === void 0 ? void 0 : _b.toISOString())
|
|
208
|
+
: key === (date === null || date === void 0 ? void 0 : date.toISOString());
|
|
209
|
+
const today = isToday(day) && markToday;
|
|
210
|
+
const disabledByFn = (disabledDate === null || disabledDate === void 0 ? void 0 : disabledDate(day)) || false;
|
|
211
|
+
const disableDate = !isSameMonth(day, state.date) || disabledByFn;
|
|
212
|
+
const isInRange = rangeMode ? inRange(range === null || range === void 0 ? void 0 : range.from, day, range === null || range === void 0 ? void 0 : range.to) : false;
|
|
213
|
+
return (_jsxs("td", { align: "center", className: css("relative", styles === null || styles === void 0 ? void 0 : styles.dayFrame), children: [_jsxs("button", { type: "button", "data-date": key, disabled: disabledByFn, "data-range": rangeMode, onClick: dispatch.onSelectDate, "data-view": state.date.getMonth().toString(), className: css(`flex size-10 items-center justify-center rounded-full font-semibold proportional-nums disabled:cursor-not-allowed ${today ? "text-primary" : ""} ${disableDate ? "text-disabled" : ""} ${isSelected ? "bg-primary text-primary-foreground" : ""}`, styles === null || styles === void 0 ? void 0 : styles.day, isInRange ? "size-10 border border-dashed border-card-border" : ""), children: [day.getDate(), isSelected && ((_c = state.range.from) === null || _c === void 0 ? void 0 : _c.toISOString()) === key ? (_jsx("span", { className: "absolute -top-2 left-0 h-full w-full", children: _jsx("span", { className: "text-xs", children: translate.calendarFromDate }) })) : null, isSelected && ((_d = state.range.to) === null || _d === void 0 ? void 0 : _d.toISOString()) === key ? (_jsx("span", { className: "absolute -top-2 left-0 h-full w-full", children: _jsx("span", { className: "text-xs", children: translate.calendarToDate }) })) : null] }), RenderOnDay ? _jsx(RenderOnDay, { date: day }) : null] }, key));
|
|
214
|
+
}) }, `week-${week.length}-${index}`))) })] })] }, monthString) }) }), _jsx("footer", { className: "mt-2 text-center text-primary", children: _jsx("button", { className: "duration-300 transition-transform hover:scale-105", type: "button", onClick: dispatch.setToday, children: "Today" }) })] }) }));
|
|
215
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import React, { PropsWithChildren } from "react";
|
|
2
|
+
import { Label, Override } from "../../types";
|
|
3
|
+
import { PolymorphicProps } from "../core/polymorph";
|
|
4
|
+
export type CardProps = PolymorphicProps<Override<React.ComponentProps<"div">, {
|
|
5
|
+
title?: Label;
|
|
6
|
+
container?: string;
|
|
7
|
+
header?: React.ReactElement | null;
|
|
8
|
+
}>, "div">;
|
|
9
|
+
export declare const Card: ({ children, title, as, container, header, className, ...props }: PropsWithChildren<CardProps>) => import("react/jsx-runtime").JSX.Element;
|
|
10
|
+
//# sourceMappingURL=card.d.ts.map
|