@seedgrid/fe-components 0.2.4 → 0.2.7

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.
Files changed (85) hide show
  1. package/package.json +3 -2
  2. package/dist/buttons/SgSpeedDial.d.ts +0 -40
  3. package/dist/buttons/SgSpeedDial.d.ts.map +0 -1
  4. package/dist/buttons/SgSpeedDial.js +0 -149
  5. package/dist/clock/SgClock.d.ts +0 -28
  6. package/dist/clock/SgClock.d.ts.map +0 -1
  7. package/dist/clock/SgClock.js +0 -280
  8. package/dist/clock/SgTimeProvider.d.ts +0 -13
  9. package/dist/clock/SgTimeProvider.d.ts.map +0 -1
  10. package/dist/clock/SgTimeProvider.js +0 -44
  11. package/dist/clock/themes/SgClockThemePicker.d.ts +0 -14
  12. package/dist/clock/themes/SgClockThemePicker.d.ts.map +0 -1
  13. package/dist/clock/themes/SgClockThemePicker.js +0 -71
  14. package/dist/clock/themes/SgClockThemePreview.d.ts +0 -7
  15. package/dist/clock/themes/SgClockThemePreview.d.ts.map +0 -1
  16. package/dist/clock/themes/SgClockThemePreview.js +0 -11
  17. package/dist/clock/themes/builtins.d.ts +0 -3
  18. package/dist/clock/themes/builtins.d.ts.map +0 -1
  19. package/dist/clock/themes/builtins.js +0 -241
  20. package/dist/clock/themes/index.d.ts +0 -9
  21. package/dist/clock/themes/index.d.ts.map +0 -1
  22. package/dist/clock/themes/index.js +0 -7
  23. package/dist/clock/themes/provider.d.ts +0 -19
  24. package/dist/clock/themes/provider.d.ts.map +0 -1
  25. package/dist/clock/themes/provider.js +0 -54
  26. package/dist/clock/themes/registry.d.ts +0 -9
  27. package/dist/clock/themes/registry.d.ts.map +0 -1
  28. package/dist/clock/themes/registry.js +0 -25
  29. package/dist/clock/themes/renderTheme.d.ts +0 -7
  30. package/dist/clock/themes/renderTheme.d.ts.map +0 -1
  31. package/dist/clock/themes/renderTheme.js +0 -41
  32. package/dist/clock/themes/types.d.ts +0 -21
  33. package/dist/clock/themes/types.d.ts.map +0 -1
  34. package/dist/clock/themes/types.js +0 -1
  35. package/dist/clock/themes/urlThemeCache.d.ts +0 -2
  36. package/dist/clock/themes/urlThemeCache.d.ts.map +0 -1
  37. package/dist/clock/themes/urlThemeCache.js +0 -11
  38. package/dist/clock/themes/useDarkFlag.d.ts +0 -2
  39. package/dist/clock/themes/useDarkFlag.d.ts.map +0 -1
  40. package/dist/clock/themes/useDarkFlag.js +0 -14
  41. package/dist/commons/SgButton.d.ts +0 -39
  42. package/dist/commons/SgButton.d.ts.map +0 -1
  43. package/dist/commons/SgButton.js +0 -116
  44. package/dist/commons/SgPopup.d.ts +0 -42
  45. package/dist/commons/SgPopup.d.ts.map +0 -1
  46. package/dist/commons/SgPopup.js +0 -218
  47. package/dist/inputs/FloatingInput.d.ts +0 -13
  48. package/dist/inputs/FloatingInput.d.ts.map +0 -1
  49. package/dist/inputs/FloatingInput.js +0 -53
  50. package/dist/inputs/FloatingSelect.d.ts +0 -15
  51. package/dist/inputs/FloatingSelect.d.ts.map +0 -1
  52. package/dist/inputs/FloatingSelect.js +0 -52
  53. package/dist/inputs/FloatingTextArea.d.ts +0 -11
  54. package/dist/inputs/FloatingTextArea.d.ts.map +0 -1
  55. package/dist/inputs/FloatingTextArea.js +0 -34
  56. package/dist/inputs/InputBirthDate.d.ts +0 -13
  57. package/dist/inputs/InputBirthDate.d.ts.map +0 -1
  58. package/dist/inputs/InputBirthDate.js +0 -46
  59. package/dist/inputs/InputDate.d.ts +0 -8
  60. package/dist/inputs/InputDate.d.ts.map +0 -1
  61. package/dist/inputs/InputDate.js +0 -23
  62. package/dist/inputs/InputEmail.d.ts +0 -14
  63. package/dist/inputs/InputEmail.d.ts.map +0 -1
  64. package/dist/inputs/InputEmail.js +0 -43
  65. package/dist/inputs/InputPassword.d.ts +0 -12
  66. package/dist/inputs/InputPassword.d.ts.map +0 -1
  67. package/dist/inputs/InputPassword.js +0 -42
  68. package/dist/inputs/MaskedInputs.d.ts +0 -27
  69. package/dist/inputs/MaskedInputs.d.ts.map +0 -1
  70. package/dist/inputs/MaskedInputs.js +0 -161
  71. package/dist/inputs/SgInputCEP.d.ts +0 -33
  72. package/dist/inputs/SgInputCEP.d.ts.map +0 -1
  73. package/dist/inputs/SgInputCEP.js +0 -117
  74. package/dist/inputs/SgInputFone.d.ts +0 -15
  75. package/dist/inputs/SgInputFone.d.ts.map +0 -1
  76. package/dist/inputs/SgInputFone.js +0 -60
  77. package/dist/inputs/SgInputMasked.d.ts +0 -27
  78. package/dist/inputs/SgInputMasked.d.ts.map +0 -1
  79. package/dist/inputs/SgInputMasked.js +0 -161
  80. package/dist/layout/GroupBox.d.ts +0 -10
  81. package/dist/layout/GroupBox.d.ts.map +0 -1
  82. package/dist/layout/GroupBox.js +0 -14
  83. /package/dist/wizard/{SGWizard.d.ts → SgWizard.d.ts} +0 -0
  84. /package/dist/wizard/{SGWizard.d.ts.map → SgWizard.d.ts.map} +0 -0
  85. /package/dist/wizard/{SGWizard.js → SgWizard.js} +0 -0
@@ -1,39 +0,0 @@
1
- import * as React from "react";
2
- type Severity = "primary" | "secondary" | "success" | "info" | "warning" | "help" | "danger" | "plain";
3
- type Appearance = "solid" | "flat" | "outline" | "ghost" | "text";
4
- type Size = "sm" | "md" | "lg";
5
- type Shape = "default" | "rounded";
6
- export type SgButtonCustomColors = {
7
- bg?: string;
8
- fg?: string;
9
- border?: string;
10
- hoverBg?: string;
11
- hoverFg?: string;
12
- hoverBorder?: string;
13
- activeBg?: string;
14
- ring?: string;
15
- };
16
- export type SgButtonProps = Omit<React.ButtonHTMLAttributes<HTMLButtonElement>, "color"> & {
17
- severity?: Severity;
18
- appearance?: Appearance;
19
- size?: Size;
20
- shape?: Shape;
21
- raised?: boolean;
22
- leftIcon?: React.ReactNode;
23
- rightIcon?: React.ReactNode;
24
- loading?: boolean;
25
- customColors?: SgButtonCustomColors;
26
- };
27
- export declare const SgButton: React.ForwardRefExoticComponent<Omit<React.ButtonHTMLAttributes<HTMLButtonElement>, "color"> & {
28
- severity?: Severity;
29
- appearance?: Appearance;
30
- size?: Size;
31
- shape?: Shape;
32
- raised?: boolean;
33
- leftIcon?: React.ReactNode;
34
- rightIcon?: React.ReactNode;
35
- loading?: boolean;
36
- customColors?: SgButtonCustomColors;
37
- } & React.RefAttributes<HTMLButtonElement>>;
38
- export {};
39
- //# sourceMappingURL=SgButton.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"SgButton.d.ts","sourceRoot":"","sources":["../../src/commons/SgButton.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,KAAK,QAAQ,GACT,SAAS,GACT,WAAW,GACX,SAAS,GACT,MAAM,GACN,SAAS,GACT,MAAM,GACN,QAAQ,GACR,OAAO,CAAC;AAEZ,KAAK,UAAU,GAAG,OAAO,GAAG,MAAM,GAAG,SAAS,GAAG,OAAO,GAAG,MAAM,CAAC;AAElE,KAAK,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;AAE/B,KAAK,KAAK,GAAG,SAAS,GAAG,SAAS,CAAC;AAEnC,MAAM,MAAM,oBAAoB,GAAG;IACjC,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG,IAAI,CAAC,KAAK,CAAC,oBAAoB,CAAC,iBAAiB,CAAC,EAAE,OAAO,CAAC,GAAG;IACzF,QAAQ,CAAC,EAAE,QAAQ,CAAC;IACpB,UAAU,CAAC,EAAE,UAAU,CAAC;IACxB,IAAI,CAAC,EAAE,IAAI,CAAC;IACZ,KAAK,CAAC,EAAE,KAAK,CAAC;IACd,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC3B,SAAS,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC5B,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,YAAY,CAAC,EAAE,oBAAoB,CAAC;CACrC,CAAC;AAsIF,eAAO,MAAM,QAAQ;eA/IR,QAAQ;iBACN,UAAU;WAChB,IAAI;YACH,KAAK;aACJ,OAAO;eACL,KAAK,CAAC,SAAS;gBACd,KAAK,CAAC,SAAS;cACjB,OAAO;mBACF,oBAAoB;2CAuMpC,CAAC"}
@@ -1,116 +0,0 @@
1
- "use client";
2
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
- import * as React from "react";
4
- function cn(...parts) {
5
- return parts.filter(Boolean).join(" ");
6
- }
7
- const PRESET = {
8
- primary: {
9
- bg: "#1d4ed8",
10
- fg: "#ffffff",
11
- border: "#1d4ed8",
12
- hoverBg: "#1e40af",
13
- ring: "rgba(29,78,216,.35)"
14
- },
15
- secondary: {
16
- bg: "#64748b",
17
- fg: "#ffffff",
18
- border: "#64748b",
19
- hoverBg: "#475569",
20
- ring: "rgba(100,116,139,.35)"
21
- },
22
- success: {
23
- bg: "#65a30d",
24
- fg: "#ffffff",
25
- border: "#65a30d",
26
- hoverBg: "#4d7c0f",
27
- ring: "rgba(101,163,13,.35)"
28
- },
29
- info: {
30
- bg: "#0284c7",
31
- fg: "#ffffff",
32
- border: "#0284c7",
33
- hoverBg: "#0369a1",
34
- ring: "rgba(2,132,199,.35)"
35
- },
36
- warning: {
37
- bg: "#f59e0b",
38
- fg: "#111827",
39
- border: "#f59e0b",
40
- hoverBg: "#d97706",
41
- ring: "rgba(245,158,11,.35)"
42
- },
43
- help: {
44
- bg: "#9333ea",
45
- fg: "#ffffff",
46
- border: "#9333ea",
47
- hoverBg: "#7e22ce",
48
- ring: "rgba(147,51,234,.35)"
49
- },
50
- danger: {
51
- bg: "#dc2626",
52
- fg: "#ffffff",
53
- border: "#dc2626",
54
- hoverBg: "#b91c1c",
55
- ring: "rgba(220,38,38,.35)"
56
- },
57
- plain: {
58
- bg: "#e5e7eb",
59
- fg: "#111827",
60
- border: "#d1d5db",
61
- hoverBg: "#d1d5db",
62
- ring: "rgba(17,24,39,.20)"
63
- }
64
- };
65
- const SIZE = {
66
- sm: { h: "h-8", px: "px-3", text: "text-sm", gap: "gap-2", icon: "size-4", radius: "rounded-md" },
67
- md: { h: "h-10", px: "px-4", text: "text-sm", gap: "gap-2", icon: "size-4", radius: "rounded-lg" },
68
- lg: { h: "h-12", px: "px-5", text: "text-base", gap: "gap-2.5", icon: "size-5", radius: "rounded-xl" }
69
- };
70
- function buildVars(severity, custom) {
71
- const base = PRESET[severity];
72
- const merged = {
73
- bg: custom?.bg ?? base.bg,
74
- fg: custom?.fg ?? base.fg,
75
- border: custom?.border ?? base.border,
76
- hoverBg: custom?.hoverBg ?? base.hoverBg,
77
- hoverFg: custom?.hoverFg ?? (custom?.fg ?? base.fg),
78
- hoverBorder: custom?.hoverBorder ?? (custom?.border ?? base.border),
79
- activeBg: custom?.activeBg ?? (custom?.hoverBg ?? base.hoverBg),
80
- ring: custom?.ring ?? base.ring
81
- };
82
- return {
83
- ["--sg-btn-bg"]: merged.bg,
84
- ["--sg-btn-fg"]: merged.fg,
85
- ["--sg-btn-border"]: merged.border,
86
- ["--sg-btn-hover-bg"]: merged.hoverBg,
87
- ["--sg-btn-hover-fg"]: merged.hoverFg,
88
- ["--sg-btn-hover-border"]: merged.hoverBorder,
89
- ["--sg-btn-active-bg"]: merged.activeBg,
90
- ["--sg-btn-ring"]: merged.ring
91
- };
92
- }
93
- function appearanceClass(appearance) {
94
- switch (appearance) {
95
- case "solid":
96
- return cn("bg-[var(--sg-btn-bg)] text-[var(--sg-btn-fg)] border border-[var(--sg-btn-border)]", "hover:bg-[var(--sg-btn-hover-bg)] hover:text-[var(--sg-btn-hover-fg)] hover:border-[var(--sg-btn-hover-border)]", "active:bg-[var(--sg-btn-active-bg)]");
97
- case "flat":
98
- return cn("bg-[var(--sg-btn-bg)] text-[var(--sg-btn-fg)] border border-transparent", "hover:bg-[var(--sg-btn-hover-bg)] hover:text-[var(--sg-btn-hover-fg)]", "active:bg-[var(--sg-btn-active-bg)]");
99
- case "outline":
100
- return cn("bg-transparent text-[var(--sg-btn-bg)] border border-[var(--sg-btn-border)]", "hover:bg-[color-mix(in_srgb,var(--sg-btn-bg)_12%,transparent)]", "active:bg-[color-mix(in_srgb,var(--sg-btn-bg)_18%,transparent)]");
101
- case "ghost":
102
- return cn("bg-transparent text-[var(--sg-btn-bg)] border border-transparent", "hover:bg-[color-mix(in_srgb,var(--sg-btn-bg)_10%,transparent)]", "active:bg-[color-mix(in_srgb,var(--sg-btn-bg)_16%,transparent)]");
103
- case "text":
104
- return cn("bg-transparent text-[var(--sg-btn-bg)] border border-transparent", "hover:underline underline-offset-4");
105
- }
106
- }
107
- export const SgButton = React.forwardRef(({ severity = "primary", appearance = "solid", size = "md", shape = "default", raised = false, leftIcon, rightIcon, loading = false, disabled, className, children, style, customColors, type = "button", ...rest }, ref) => {
108
- const isDisabled = Boolean(disabled || loading);
109
- const isIconOnly = !children && (leftIcon || rightIcon);
110
- const s = SIZE[size];
111
- return (_jsx("button", { ref: ref, type: type, disabled: isDisabled, style: { ...buildVars(severity, customColors), ...style }, className: cn("inline-flex items-center justify-center select-none whitespace-nowrap", "font-medium", "transition-[background-color,color,border-color,box-shadow,transform] duration-150", "focus-visible:outline-none focus-visible:ring-4 focus-visible:ring-[var(--sg-btn-ring)]", "disabled:opacity-60 disabled:cursor-not-allowed", s.h, isIconOnly ? "aspect-square" : s.px, s.text, s.gap, shape === "rounded" ? "rounded-full" : s.radius, appearanceClass(appearance), raised && appearance !== "text" ? "shadow-sm hover:shadow-md active:shadow-sm" : false, !isDisabled && appearance !== "text" ? "active:translate-y-[0.5px]" : false, className), ...rest, children: loading ? (_jsxs("span", { className: cn("inline-flex items-center", s.gap), children: [_jsx(Spinner, { className: s.icon }), children ? _jsx("span", { children: children }) : null] })) : (_jsxs("span", { className: cn("inline-flex items-center", s.gap), children: [leftIcon ? _jsx("span", { className: cn("shrink-0", s.icon), children: leftIcon }) : null, children ? _jsx("span", { children: children }) : null, rightIcon ? _jsx("span", { className: cn("shrink-0", s.icon), children: rightIcon }) : null] })) }));
112
- });
113
- SgButton.displayName = "SgButton";
114
- function Spinner({ className }) {
115
- return (_jsxs("svg", { className: cn("animate-spin", className), viewBox: "0 0 24 24", fill: "none", "aria-hidden": "true", children: [_jsx("circle", { cx: "12", cy: "12", r: "9", stroke: "currentColor", strokeOpacity: "0.25", strokeWidth: "3" }), _jsx("path", { d: "M21 12a9 9 0 0 0-9-9", stroke: "currentColor", strokeWidth: "3", strokeLinecap: "round" })] }));
116
- }
@@ -1,42 +0,0 @@
1
- import * as React from "react";
2
- export type SgPopupPlacement = "auto" | "top" | "right" | "bottom" | "left";
3
- export type SgPopupPreferPlacement = "top" | "right" | "bottom" | "left";
4
- export type SgPopupAlign = "start" | "center" | "end";
5
- export type SgPopupSeverity = "primary" | "secondary" | "success" | "info" | "warning" | "help" | "danger" | "plain";
6
- export type SgPopupAction = {
7
- icon?: React.ReactNode;
8
- label: string;
9
- hint?: string;
10
- severity?: SgPopupSeverity;
11
- disabled?: boolean;
12
- closeOnClick?: boolean;
13
- onClick?: () => void;
14
- };
15
- export type SgPopupProps = {
16
- title?: string;
17
- subtitle?: string;
18
- open?: boolean;
19
- onOpenChange?: (open: boolean) => void;
20
- defaultOpen?: boolean;
21
- onOpen?: () => void;
22
- onClose?: () => void;
23
- anchorRef: React.RefObject<HTMLElement>;
24
- placement?: SgPopupPlacement;
25
- preferPlacement?: SgPopupPreferPlacement;
26
- align?: SgPopupAlign;
27
- offset?: number;
28
- padding?: number;
29
- closeOnOutsideClick?: boolean;
30
- closeOnEscape?: boolean;
31
- className?: string;
32
- style?: React.CSSProperties;
33
- zIndex?: number;
34
- minWidth?: number | string;
35
- actions?: SgPopupAction[];
36
- children?: React.ReactNode;
37
- };
38
- export declare function SgPopup(props: Readonly<SgPopupProps>): React.ReactPortal | null;
39
- export declare namespace SgPopup {
40
- var displayName: string;
41
- }
42
- //# sourceMappingURL=SgPopup.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"SgPopup.d.ts","sourceRoot":"","sources":["../../src/commons/SgPopup.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAmB/B,MAAM,MAAM,gBAAgB,GAAG,MAAM,GAAG,KAAK,GAAG,OAAO,GAAG,QAAQ,GAAG,MAAM,CAAC;AAC5E,MAAM,MAAM,sBAAsB,GAAG,KAAK,GAAG,OAAO,GAAG,QAAQ,GAAG,MAAM,CAAC;AACzE,MAAM,MAAM,YAAY,GAAG,OAAO,GAAG,QAAQ,GAAG,KAAK,CAAC;AAEtD,MAAM,MAAM,eAAe,GACvB,SAAS,GACT,WAAW,GACX,SAAS,GACT,MAAM,GACN,SAAS,GACT,MAAM,GACN,QAAQ,GACR,OAAO,CAAC;AAEZ,MAAM,MAAM,aAAa,GAAG;IAC1B,IAAI,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IACvB,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,eAAe,CAAC;IAC3B,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;CACtB,CAAC;AAEF,MAAM,MAAM,YAAY,GAAG;IACzB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,YAAY,CAAC,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,CAAC;IACvC,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,MAAM,CAAC,EAAE,MAAM,IAAI,CAAC;IACpB,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IAErB,SAAS,EAAE,KAAK,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC;IAExC,SAAS,CAAC,EAAE,gBAAgB,CAAC;IAC7B,eAAe,CAAC,EAAE,sBAAsB,CAAC;IACzC,KAAK,CAAC,EAAE,YAAY,CAAC;IACrB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B,aAAa,CAAC,EAAE,OAAO,CAAC;IAExB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC;IAC5B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IAE3B,OAAO,CAAC,EAAE,aAAa,EAAE,CAAC;IAC1B,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;CAC5B,CAAC;AAwHF,wBAAgB,OAAO,CAAC,KAAK,EAAE,QAAQ,CAAC,YAAY,CAAC,4BAwLpD;yBAxLe,OAAO"}
@@ -1,218 +0,0 @@
1
- "use client";
2
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
- import * as React from "react";
4
- import { createPortal } from "react-dom";
5
- function cn(...parts) {
6
- return parts.filter(Boolean).join(" ");
7
- }
8
- function clamp(value, min, max) {
9
- return Math.max(min, Math.min(value, max));
10
- }
11
- function useEvent(fn) {
12
- const ref = React.useRef(fn);
13
- React.useEffect(() => {
14
- ref.current = fn;
15
- }, [fn]);
16
- return React.useCallback((...args) => ref.current?.(...args), []);
17
- }
18
- const ACTION_CLS = {
19
- primary: "text-primary-foreground bg-primary hover:brightness-95",
20
- secondary: "text-secondary-foreground bg-secondary hover:brightness-95",
21
- success: "text-white bg-emerald-600 hover:brightness-95",
22
- info: "text-white bg-sky-600 hover:brightness-95",
23
- warning: "text-white bg-amber-600 hover:brightness-95",
24
- help: "text-white bg-violet-600 hover:brightness-95",
25
- danger: "text-destructive-foreground bg-destructive hover:brightness-95",
26
- plain: "text-foreground bg-muted hover:bg-muted/80"
27
- };
28
- const ACTION_DEFAULT_CLS = "text-foreground bg-transparent hover:bg-muted/80";
29
- function computeAlignedLeft(anchor, popup, align) {
30
- if (align === "start")
31
- return anchor.left;
32
- if (align === "center")
33
- return anchor.left + anchor.width / 2 - popup.width / 2;
34
- return anchor.right - popup.width;
35
- }
36
- function computeAlignedTop(anchor, popup, align) {
37
- if (align === "start")
38
- return anchor.top;
39
- if (align === "center")
40
- return anchor.top + anchor.height / 2 - popup.height / 2;
41
- return anchor.bottom - popup.height;
42
- }
43
- function chooseAutoPlacement(opts) {
44
- const { anchor, popup, offset, prefer, viewportW, viewportH } = opts;
45
- const space = {
46
- right: viewportW - anchor.right,
47
- left: anchor.left,
48
- bottom: viewportH - anchor.bottom,
49
- top: anchor.top
50
- };
51
- const fits = (placement) => {
52
- if (placement === "left" || placement === "right") {
53
- return space[placement] >= popup.width + offset;
54
- }
55
- return space[placement] >= popup.height + offset;
56
- };
57
- const opposite = {
58
- right: "left",
59
- left: "right",
60
- top: "bottom",
61
- bottom: "top"
62
- };
63
- const candidates = [
64
- prefer,
65
- opposite[prefer],
66
- "bottom",
67
- "top",
68
- "right",
69
- "left"
70
- ];
71
- return candidates.find(fits) ?? prefer;
72
- }
73
- function computePosition(opts) {
74
- const { anchor, popup, placement, preferPlacement, align, offset, padding } = opts;
75
- const vw = window.innerWidth;
76
- const vh = window.innerHeight;
77
- const finalPlacement = placement === "auto"
78
- ? chooseAutoPlacement({
79
- anchor,
80
- popup,
81
- offset,
82
- prefer: preferPlacement,
83
- viewportW: vw,
84
- viewportH: vh
85
- })
86
- : placement;
87
- let top = 0;
88
- let left = 0;
89
- if (finalPlacement === "right") {
90
- left = anchor.right + offset;
91
- top = computeAlignedTop(anchor, popup, align);
92
- }
93
- else if (finalPlacement === "left") {
94
- left = anchor.left - popup.width - offset;
95
- top = computeAlignedTop(anchor, popup, align);
96
- }
97
- else if (finalPlacement === "bottom") {
98
- top = anchor.bottom + offset;
99
- left = computeAlignedLeft(anchor, popup, align);
100
- }
101
- else {
102
- top = anchor.top - popup.height - offset;
103
- left = computeAlignedLeft(anchor, popup, align);
104
- }
105
- left = clamp(left, padding, vw - popup.width - padding);
106
- top = clamp(top, padding, vh - popup.height - padding);
107
- return { top, left };
108
- }
109
- export function SgPopup(props) {
110
- const { title, subtitle, open, onOpenChange, defaultOpen = false, onOpen, onClose, anchorRef, placement = "auto", preferPlacement = "right", align = "start", offset = 8, padding = 8, closeOnOutsideClick = true, closeOnEscape = true, className, style, zIndex = 60, minWidth = 180, actions, children } = props;
111
- const isControlled = typeof open === "boolean";
112
- const [internalOpen, setInternalOpen] = React.useState(defaultOpen);
113
- const isOpen = isControlled ? open : internalOpen;
114
- const setOpen = React.useCallback((next) => {
115
- if (!isControlled)
116
- setInternalOpen(next);
117
- onOpenChange?.(next);
118
- }, [isControlled, onOpenChange]);
119
- const onOpenEvt = useEvent(onOpen);
120
- const onCloseEvt = useEvent(onClose);
121
- const prevOpen = React.useRef(isOpen);
122
- React.useEffect(() => {
123
- if (prevOpen.current !== isOpen) {
124
- if (isOpen)
125
- onOpenEvt?.();
126
- else
127
- onCloseEvt?.();
128
- prevOpen.current = isOpen;
129
- }
130
- }, [isOpen, onOpenEvt, onCloseEvt]);
131
- const panelRef = React.useRef(null);
132
- const [pos, setPos] = React.useState(null);
133
- const recompute = React.useCallback(() => {
134
- const anchorEl = anchorRef.current;
135
- const panelEl = panelRef.current;
136
- if (!anchorEl || !panelEl)
137
- return;
138
- const anchorRect = anchorEl.getBoundingClientRect();
139
- const popupRect = panelEl.getBoundingClientRect();
140
- const next = computePosition({
141
- anchor: anchorRect,
142
- popup: popupRect,
143
- placement,
144
- preferPlacement,
145
- align,
146
- offset,
147
- padding
148
- });
149
- setPos({ top: next.top, left: next.left });
150
- }, [anchorRef, placement, preferPlacement, align, offset, padding]);
151
- React.useLayoutEffect(() => {
152
- if (!isOpen)
153
- return;
154
- recompute();
155
- const raf = requestAnimationFrame(recompute);
156
- return () => cancelAnimationFrame(raf);
157
- }, [isOpen, recompute]);
158
- React.useEffect(() => {
159
- if (!isOpen)
160
- return;
161
- const onResize = () => recompute();
162
- const onScroll = () => recompute();
163
- window.addEventListener("resize", onResize);
164
- window.addEventListener("scroll", onScroll, { passive: true, capture: true });
165
- return () => {
166
- window.removeEventListener("resize", onResize);
167
- window.removeEventListener("scroll", onScroll, true);
168
- };
169
- }, [isOpen, recompute]);
170
- React.useEffect(() => {
171
- if (!isOpen)
172
- return;
173
- const onDown = (e) => {
174
- if (!closeOnOutsideClick)
175
- return;
176
- const panel = panelRef.current;
177
- const anchor = anchorRef.current;
178
- const target = e.target;
179
- if (panel && panel.contains(target))
180
- return;
181
- if (anchor && anchor.contains(target))
182
- return;
183
- setOpen(false);
184
- };
185
- const onKey = (e) => {
186
- if (!closeOnEscape)
187
- return;
188
- if (e.key === "Escape")
189
- setOpen(false);
190
- };
191
- document.addEventListener("mousedown", onDown);
192
- document.addEventListener("keydown", onKey);
193
- return () => {
194
- document.removeEventListener("mousedown", onDown);
195
- document.removeEventListener("keydown", onKey);
196
- };
197
- }, [isOpen, closeOnOutsideClick, closeOnEscape, setOpen, anchorRef]);
198
- const close = React.useCallback(() => setOpen(false), [setOpen]);
199
- if (!isOpen)
200
- return null;
201
- const body = (_jsxs("div", { ref: panelRef, className: cn("fixed overflow-hidden rounded-md border border-border bg-background shadow-lg", "min-w-[180px]", className), style: {
202
- zIndex,
203
- top: pos?.top ?? -9999,
204
- left: pos?.left ?? -9999,
205
- minWidth,
206
- ...style
207
- }, role: "dialog", "aria-modal": "false", children: [title ? (_jsx("div", { className: "bg-primary px-3 py-2 text-xs font-medium text-primary-foreground", children: title })) : null, subtitle ? (_jsx("div", { className: "border-b border-border bg-background px-3 py-2 text-xs text-muted-foreground", children: subtitle })) : null, children ? _jsx("div", { className: "p-2", children: children }) : null, actions && actions.length > 0 ? (_jsx("div", { className: cn(children ? "border-t border-border" : "", "p-1"), children: actions.map((a, idx) => {
208
- const hasSeverity = a.severity !== undefined;
209
- const sev = a.severity ?? "plain";
210
- return (_jsx("button", { type: "button", disabled: a.disabled, title: a.hint, className: cn("w-full select-none rounded px-3 py-2 text-left text-sm", "transition-[filter,background-color] duration-150", "disabled:opacity-50 disabled:cursor-not-allowed", idx > 0 ? "border-t border-border" : "", hasSeverity ? ACTION_CLS[sev] : ACTION_DEFAULT_CLS), onClick: () => {
211
- a.onClick?.();
212
- if (a.closeOnClick ?? true)
213
- close();
214
- }, children: _jsxs("span", { className: "inline-flex items-center gap-2", children: [a.icon ? _jsx("span", { className: "inline-flex", children: a.icon }) : null, _jsx("span", { children: a.label })] }) }, idx));
215
- }) })) : null] }));
216
- return createPortal(body, document.body);
217
- }
218
- SgPopup.displayName = "SgPopup";
@@ -1,13 +0,0 @@
1
- import React from "react";
2
- export type SgFloatingInputProps = {
3
- id: string;
4
- label: string;
5
- error?: string;
6
- type?: React.HTMLInputTypeAttribute;
7
- placeholder?: string;
8
- className?: string;
9
- labelClassName?: string;
10
- inputProps: React.InputHTMLAttributes<HTMLInputElement>;
11
- };
12
- export declare function SgFloatingInput(props: SgFloatingInputProps): import("react/jsx-runtime").JSX.Element;
13
- //# sourceMappingURL=FloatingInput.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"FloatingInput.d.ts","sourceRoot":"","sources":["../../src/inputs/FloatingInput.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,MAAM,MAAM,oBAAoB,GAAG;IACjC,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,KAAK,CAAC,sBAAsB,CAAC;IACpC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,UAAU,EAAE,KAAK,CAAC,mBAAmB,CAAC,gBAAgB,CAAC,CAAC;CACzD,CAAC;AAOF,wBAAgB,eAAe,CAAC,KAAK,EAAE,oBAAoB,2CAwE1D"}
@@ -1,53 +0,0 @@
1
- "use client";
2
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
- import React from "react";
4
- function ErrorText(props) {
5
- if (!props.message)
6
- return null;
7
- return _jsx("p", { className: "text-xs text-red-600", children: props.message });
8
- }
9
- export function SgFloatingInput(props) {
10
- const placeholder = props.placeholder ?? props.label;
11
- const inputRef = React.useRef(null);
12
- const [isFilled, setIsFilled] = React.useState(() => {
13
- const value = props.inputProps.value ?? props.inputProps.defaultValue ?? "";
14
- return String(value).length > 0;
15
- });
16
- React.useEffect(() => {
17
- const next = (inputRef.current?.value ?? "").length > 0;
18
- if (next !== isFilled)
19
- setIsFilled(next);
20
- });
21
- React.useEffect(() => {
22
- if (props.inputProps.value === undefined)
23
- return;
24
- setIsFilled(String(props.inputProps.value ?? "").length > 0);
25
- }, [props.inputProps.value]);
26
- const setRefs = React.useCallback((node) => {
27
- inputRef.current = node;
28
- const ref = props.inputProps.ref;
29
- if (!ref)
30
- return;
31
- if (typeof ref === "function") {
32
- ref(node);
33
- }
34
- else if (typeof ref === "object") {
35
- ref.current = node;
36
- }
37
- }, [props.inputProps]);
38
- const handleChange = (event) => {
39
- setIsFilled(event.currentTarget.value.length > 0);
40
- props.inputProps.onChange?.(event);
41
- };
42
- const handleBlur = (event) => {
43
- setIsFilled(event.currentTarget.value.length > 0);
44
- props.inputProps.onBlur?.(event);
45
- };
46
- return (_jsxs("div", { children: [_jsxs("div", { className: "relative", children: [_jsx("input", { id: props.id, type: props.type ?? "text", placeholder: placeholder, className: props.className ??
47
- "peer h-11 w-full rounded-md border border-border bg-white px-3 pt-4 text-sm shadow-sm placeholder-transparent focus:border-[hsl(var(--primary))] focus:outline-none focus:ring-2 focus:ring-[hsl(var(--primary)/0.25)]", ...props.inputProps, ref: setRefs, onChange: handleChange, onBlur: handleBlur }), _jsx("label", { htmlFor: props.id, className: [
48
- "absolute left-3 bg-white px-1 transition-all",
49
- isFilled ? "-top-2 text-xs text-[hsl(var(--primary))]" : "top-3 text-sm text-foreground/60",
50
- "peer-focus:-top-2 peer-focus:text-xs peer-focus:text-[hsl(var(--primary))]",
51
- props.labelClassName ?? ""
52
- ].join(" "), children: props.label })] }), _jsx(ErrorText, { message: props.error })] }));
53
- }
@@ -1,15 +0,0 @@
1
- import React from "react";
2
- export type SgFloatingSelectProps = {
3
- id: string;
4
- label: string;
5
- error?: string;
6
- className?: string;
7
- options: Array<{
8
- value: string;
9
- label: string;
10
- }>;
11
- selectProps: React.SelectHTMLAttributes<HTMLSelectElement>;
12
- alwaysFloat?: boolean;
13
- };
14
- export declare function SgFloatingSelect(props: SgFloatingSelectProps): import("react/jsx-runtime").JSX.Element;
15
- //# sourceMappingURL=FloatingSelect.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"FloatingSelect.d.ts","sourceRoot":"","sources":["../../src/inputs/FloatingSelect.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,MAAM,MAAM,qBAAqB,GAAG;IAClC,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,KAAK,CAAC;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IACjD,WAAW,EAAE,KAAK,CAAC,oBAAoB,CAAC,iBAAiB,CAAC,CAAC;IAC3D,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB,CAAC;AAOF,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,qBAAqB,2CA4F5D"}
@@ -1,52 +0,0 @@
1
- "use client";
2
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
- import React from "react";
4
- function ErrorText(props) {
5
- if (!props.message)
6
- return null;
7
- return _jsx("p", { className: "text-xs text-red-600", children: props.message });
8
- }
9
- export function SgFloatingSelect(props) {
10
- const selectRef = React.useRef(null);
11
- const [isFilled, setIsFilled] = React.useState(() => {
12
- const value = props.selectProps.value ?? props.selectProps.defaultValue ?? "";
13
- return String(value).length > 0;
14
- });
15
- React.useEffect(() => {
16
- const next = (selectRef.current?.value ?? "").length > 0;
17
- if (next !== isFilled)
18
- setIsFilled(next);
19
- });
20
- React.useEffect(() => {
21
- if (props.selectProps.value === undefined)
22
- return;
23
- setIsFilled(String(props.selectProps.value ?? "").length > 0);
24
- }, [props.selectProps.value]);
25
- const setRefs = React.useCallback((node) => {
26
- selectRef.current = node;
27
- const ref = props.selectProps.ref;
28
- if (!ref)
29
- return;
30
- if (typeof ref === "function") {
31
- ref(node);
32
- }
33
- else if (typeof ref === "object") {
34
- ref.current = node;
35
- }
36
- }, [props.selectProps]);
37
- const handleChange = (event) => {
38
- setIsFilled(event.currentTarget.value.length > 0);
39
- props.selectProps.onChange?.(event);
40
- };
41
- const handleBlur = (event) => {
42
- setIsFilled(event.currentTarget.value.length > 0);
43
- props.selectProps.onBlur?.(event);
44
- };
45
- const alwaysFloat = props.alwaysFloat ?? (props.selectProps?.["data-floating"] === "always");
46
- return (_jsxs("div", { children: [_jsxs("div", { className: "relative", children: [alwaysFloat ? (_jsx("label", { htmlFor: props.id, className: "pointer-events-none absolute left-3 top-0 z-10 -translate-y-1/2 bg-white px-1 text-[11px] font-medium leading-none text-foreground/70", children: props.label })) : null, _jsxs("select", { id: props.id, className: props.className ??
47
- "peer h-11 w-full rounded-md border border-border bg-white px-3 pt-4 text-sm shadow-sm focus:border-[hsl(var(--primary))] focus:outline-none focus:ring-2 focus:ring-[hsl(var(--primary)/0.25)]", ...props.selectProps, ref: setRefs, onChange: handleChange, onBlur: handleBlur, children: [_jsx("option", { value: "", children: "Selecione" }), props.options.map((opt) => (_jsx("option", { value: opt.value, children: opt.label }, opt.value)))] }), alwaysFloat ? (_jsx("label", { htmlFor: props.id, className: "sr-only", children: props.label })) : (_jsx("label", { htmlFor: props.id, className: [
48
- "absolute left-3 bg-white px-1 transition-all",
49
- isFilled ? "-top-2 text-xs text-[hsl(var(--primary))]" : "top-3 text-sm text-foreground/60",
50
- "peer-focus:-top-2 peer-focus:text-xs peer-focus:text-[hsl(var(--primary))]"
51
- ].join(" "), children: props.label }))] }), _jsx(ErrorText, { message: props.error })] }));
52
- }
@@ -1,11 +0,0 @@
1
- import React from "react";
2
- export type SgFloatingTextAreaProps = {
3
- id: string;
4
- label: string;
5
- error?: string;
6
- placeholder?: string;
7
- className?: string;
8
- textareaProps: React.TextareaHTMLAttributes<HTMLTextAreaElement>;
9
- };
10
- export declare function SgFloatingTextArea(props: SgFloatingTextAreaProps): import("react/jsx-runtime").JSX.Element;
11
- //# sourceMappingURL=FloatingTextArea.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"FloatingTextArea.d.ts","sourceRoot":"","sources":["../../src/inputs/FloatingTextArea.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,MAAM,MAAM,uBAAuB,GAAG;IACpC,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,aAAa,EAAE,KAAK,CAAC,sBAAsB,CAAC,mBAAmB,CAAC,CAAC;CAClE,CAAC;AAOF,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,uBAAuB,2CAkDhE"}
@@ -1,34 +0,0 @@
1
- "use client";
2
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
- import React from "react";
4
- function ErrorText(props) {
5
- if (!props.message)
6
- return null;
7
- return _jsx("p", { className: "text-xs text-red-600", children: props.message });
8
- }
9
- export function SgFloatingTextArea(props) {
10
- const placeholder = props.placeholder ?? props.label;
11
- const [isFilled, setIsFilled] = React.useState(() => {
12
- const value = props.textareaProps.value ?? props.textareaProps.defaultValue ?? "";
13
- return String(value).length > 0;
14
- });
15
- React.useEffect(() => {
16
- if (props.textareaProps.value === undefined)
17
- return;
18
- setIsFilled(String(props.textareaProps.value ?? "").length > 0);
19
- }, [props.textareaProps.value]);
20
- const handleChange = (event) => {
21
- setIsFilled(event.currentTarget.value.length > 0);
22
- props.textareaProps.onChange?.(event);
23
- };
24
- const handleBlur = (event) => {
25
- setIsFilled(event.currentTarget.value.length > 0);
26
- props.textareaProps.onBlur?.(event);
27
- };
28
- return (_jsxs("div", { children: [_jsxs("div", { className: "relative", children: [_jsx("textarea", { id: props.id, placeholder: placeholder, className: props.className ??
29
- "peer min-h-[120px] w-full rounded-md border border-border bg-white px-3 pt-5 text-sm shadow-sm placeholder-transparent focus:border-[hsl(var(--primary))] focus:outline-none focus:ring-2 focus:ring-[hsl(var(--primary)/0.25)]", ...props.textareaProps, onChange: handleChange, onBlur: handleBlur }), _jsx("label", { htmlFor: props.id, className: [
30
- "absolute left-3 bg-white px-1 transition-all",
31
- isFilled ? "-top-2 text-xs text-[hsl(var(--primary))]" : "top-3 text-sm text-foreground/60",
32
- "peer-focus:-top-2 peer-focus:text-xs peer-focus:text-[hsl(var(--primary))]"
33
- ].join(" "), children: props.label })] }), _jsx(ErrorText, { message: props.error })] }));
34
- }
@@ -1,13 +0,0 @@
1
- import { type SgInputDateProps } from "./InputDate";
2
- import { type BirthDatePolicy } from "../validators";
3
- export type SgInputBirthDateProps = Omit<SgInputDateProps, "maxDate" | "minDate"> & BirthDatePolicy & {
4
- maxDate?: string | Date;
5
- minDate?: string | Date;
6
- onValidation?: (message: string | null) => void;
7
- required?: boolean;
8
- requiredMessage?: string;
9
- validateOnBlur?: boolean;
10
- error?: string;
11
- };
12
- export declare function SgInputBirthDate(props: SgInputBirthDateProps): import("react/jsx-runtime").JSX.Element;
13
- //# sourceMappingURL=InputBirthDate.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"InputBirthDate.d.ts","sourceRoot":"","sources":["../../src/inputs/InputBirthDate.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAe,KAAK,gBAAgB,EAAE,MAAM,aAAa,CAAC;AACjE,OAAO,EAAqB,KAAK,eAAe,EAAE,MAAM,eAAe,CAAC;AAExE,MAAM,MAAM,qBAAqB,GAAG,IAAI,CAAC,gBAAgB,EAAE,SAAS,GAAG,SAAS,CAAC,GAC/E,eAAe,GAAG;IAChB,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,YAAY,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,KAAK,IAAI,CAAC;IAChD,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC;AAEJ,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,qBAAqB,2CAyD5D"}