lawgic-dev-kit 0.20.8 → 0.21.4
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/_virtual/index6.js +2 -2
- package/dist/_virtual/index7.js +2 -2
- package/dist/components/atoms/SelectInput/SelectInput.d.ts +1 -1
- package/dist/components/atoms/SelectInput/SelectInput.js +81 -74
- package/dist/components/atoms/SelectInput/SelectInput.types.d.ts +7 -2
- package/dist/components/atoms/SidebarButton/SidebarButton.js +7 -7
- package/dist/components/atoms/UncontrolledSelector/UncontrolledSelector.d.ts +5 -2
- package/dist/components/atoms/UncontrolledSelector/UncontrolledSelector.js +56 -53
- package/dist/lawgic-dev-kit.css +1 -1
- package/dist/lawgic-dev-kit.umd.js +44 -44
- package/dist/node_modules/prop-types/node_modules/react-is/index.js +1 -1
- package/dist/node_modules/toposort/index.js +1 -1
- package/dist/src/components/atoms/SelectInput/SelectInput.d.ts +4 -0
- package/dist/src/components/atoms/SelectInput/SelectInput.types.d.ts +29 -0
- package/dist/src/components/atoms/UncontrolledSelector/UncontrolledSelector.d.ts +21 -0
- package/dist/src/types/toast.d.ts +26 -0
- package/dist/types/toast.d.ts +2 -2
- package/dist/utils/toast.js +44 -40
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { __module as e } from "../../../../_virtual/
|
|
1
|
+
import { __module as e } from "../../../../_virtual/index6.js";
|
|
2
2
|
import { __require as o } from "./cjs/react-is.production.min.js";
|
|
3
3
|
import { __require as t } from "./cjs/react-is.development.js";
|
|
4
4
|
var r;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { FieldValues } from "react-hook-form";
|
|
2
|
+
import type { SelectInputProps } from "./SelectInput.types";
|
|
3
|
+
declare const SelectInput: <T extends FieldValues>({ options, name, control, label, placeholder, className, input, dropdownStyle, innerClassName }: SelectInputProps<T>) => import("react/jsx-runtime").JSX.Element;
|
|
4
|
+
export default SelectInput;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { Control, FieldValues, Path } from "react-hook-form";
|
|
2
|
+
export interface Option {
|
|
3
|
+
key: string;
|
|
4
|
+
label: string;
|
|
5
|
+
expandedLabel?: string | React.ReactNode;
|
|
6
|
+
}
|
|
7
|
+
export interface SelectInputProps<T extends FieldValues> {
|
|
8
|
+
options: Option[];
|
|
9
|
+
name: Path<T>;
|
|
10
|
+
control: Control<T>;
|
|
11
|
+
label?: string;
|
|
12
|
+
placeholder?: string;
|
|
13
|
+
input?: boolean;
|
|
14
|
+
className?: string;
|
|
15
|
+
innerClassName?: string;
|
|
16
|
+
dropdownStyle?: React.CSSProperties;
|
|
17
|
+
}
|
|
18
|
+
export interface SelectInputFieldProps {
|
|
19
|
+
options: Option[];
|
|
20
|
+
value: Option | null;
|
|
21
|
+
onChange: (option: Option | null) => void;
|
|
22
|
+
label?: string;
|
|
23
|
+
placeholder?: string;
|
|
24
|
+
error?: string;
|
|
25
|
+
input?: boolean;
|
|
26
|
+
className?: string;
|
|
27
|
+
innerClassName?: string;
|
|
28
|
+
dropdownStyle?: React.CSSProperties;
|
|
29
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
interface Option {
|
|
3
|
+
value: number | string;
|
|
4
|
+
label: string | React.ReactNode;
|
|
5
|
+
expandedLabel?: string | React.ReactNode;
|
|
6
|
+
}
|
|
7
|
+
interface UncontrolledSelectorProps {
|
|
8
|
+
value: number | string;
|
|
9
|
+
onChange: (value: number | string) => void;
|
|
10
|
+
options: Option[];
|
|
11
|
+
placeholder?: string;
|
|
12
|
+
label?: string;
|
|
13
|
+
error?: string;
|
|
14
|
+
disabled?: boolean;
|
|
15
|
+
allowSearch?: boolean;
|
|
16
|
+
className?: string;
|
|
17
|
+
innerClassName?: string;
|
|
18
|
+
dropdownStyle?: React.CSSProperties;
|
|
19
|
+
}
|
|
20
|
+
declare const UncontrolledSelector: React.FC<UncontrolledSelectorProps>;
|
|
21
|
+
export default UncontrolledSelector;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export type ToastContent = React.ReactNode;
|
|
2
|
+
export type ToastPosition = "top-left" | "top-right" | "top-center" | "bottom-left" | "bottom-right" | "bottom-center";
|
|
3
|
+
export interface ToastOptions {
|
|
4
|
+
duration?: number;
|
|
5
|
+
position?: ToastPosition;
|
|
6
|
+
}
|
|
7
|
+
export type ToastType = "success" | "error" | "warning" | "info" | "loading";
|
|
8
|
+
export interface ToastMethods {
|
|
9
|
+
success: (content: ToastContent, options?: ToastOptions) => void;
|
|
10
|
+
error: (content: ToastContent, options?: ToastOptions) => void;
|
|
11
|
+
warning: (content: ToastContent, options?: ToastOptions) => void;
|
|
12
|
+
info: (content: ToastContent, options?: ToastOptions) => void;
|
|
13
|
+
loading: (messages: {
|
|
14
|
+
loading: ToastContent;
|
|
15
|
+
success: ToastContent;
|
|
16
|
+
error: ToastContent;
|
|
17
|
+
}, options?: ToastOptions) => {
|
|
18
|
+
resolve: (value?: unknown) => void;
|
|
19
|
+
reject: (reason?: unknown) => void;
|
|
20
|
+
};
|
|
21
|
+
async: (promise: Promise<unknown>, messages: {
|
|
22
|
+
loading: ToastContent;
|
|
23
|
+
success: ToastContent;
|
|
24
|
+
error: ToastContent;
|
|
25
|
+
}, options?: ToastOptions) => void;
|
|
26
|
+
}
|
package/dist/types/toast.d.ts
CHANGED
|
@@ -15,8 +15,8 @@ export interface ToastMethods {
|
|
|
15
15
|
success: ToastContent;
|
|
16
16
|
error: ToastContent;
|
|
17
17
|
}, options?: ToastOptions) => {
|
|
18
|
-
resolve: () => void;
|
|
19
|
-
reject: () => void;
|
|
18
|
+
resolve: (value?: unknown) => void;
|
|
19
|
+
reject: (reason?: unknown) => void;
|
|
20
20
|
};
|
|
21
21
|
async: (promise: Promise<unknown>, messages: {
|
|
22
22
|
loading: ToastContent;
|
package/dist/utils/toast.js
CHANGED
|
@@ -12,11 +12,11 @@ import "../components/atoms/ImageProfileInput/ImageProfileInput.validators.js";
|
|
|
12
12
|
import h from "../components/atoms/Toast/Toast.js";
|
|
13
13
|
import "fuse.js";
|
|
14
14
|
const m = [];
|
|
15
|
-
function l(
|
|
15
|
+
function l(t = "bottom-center") {
|
|
16
16
|
var o;
|
|
17
|
-
if (!m.find((
|
|
18
|
-
const
|
|
19
|
-
switch (
|
|
17
|
+
if (!m.find((e) => e.id === t)) {
|
|
18
|
+
const e = document.createElement("div");
|
|
19
|
+
switch (e.classList.add(
|
|
20
20
|
"fixed",
|
|
21
21
|
"z-[99999]",
|
|
22
22
|
"flex",
|
|
@@ -24,48 +24,48 @@ function l(e = "bottom-center") {
|
|
|
24
24
|
"items-center",
|
|
25
25
|
"w-fit",
|
|
26
26
|
"min-w-[18rem]"
|
|
27
|
-
),
|
|
27
|
+
), e.style.setProperty("z-index", "99999"), t) {
|
|
28
28
|
case "top-left":
|
|
29
|
-
|
|
29
|
+
e.classList.add("top-8", "left-8");
|
|
30
30
|
break;
|
|
31
31
|
case "top-right":
|
|
32
|
-
|
|
32
|
+
e.classList.add("top-8", "right-8");
|
|
33
33
|
break;
|
|
34
34
|
case "bottom-left":
|
|
35
|
-
|
|
35
|
+
e.classList.add("bottom-8", "left-8");
|
|
36
36
|
break;
|
|
37
37
|
case "bottom-right":
|
|
38
|
-
|
|
38
|
+
e.classList.add("bottom-8", "right-8");
|
|
39
39
|
break;
|
|
40
40
|
case "top-center":
|
|
41
|
-
|
|
41
|
+
e.classList.add("top-8", "left-1/2", "-translate-x-1/2");
|
|
42
42
|
break;
|
|
43
43
|
case "bottom-center":
|
|
44
44
|
default:
|
|
45
|
-
|
|
45
|
+
e.classList.add(
|
|
46
46
|
"bottom-8",
|
|
47
47
|
"left-1/2",
|
|
48
48
|
"-translate-x-1/2"
|
|
49
49
|
);
|
|
50
50
|
}
|
|
51
|
-
m.push({ id:
|
|
51
|
+
m.push({ id: t, element: e }), document.body.appendChild(e);
|
|
52
52
|
}
|
|
53
|
-
return (o = m.find((
|
|
53
|
+
return (o = m.find((e) => e.id === t)) == null ? void 0 : o.element;
|
|
54
54
|
}
|
|
55
|
-
function
|
|
55
|
+
function a(t, o = "success", { position: e = "top-right", duration: i = 3e3 } = {}) {
|
|
56
56
|
import("react-dom/client").then(({ createRoot: n }) => {
|
|
57
|
-
const s = l(
|
|
57
|
+
const s = l(e);
|
|
58
58
|
if (!s) return;
|
|
59
|
-
const r = document.createElement("div"),
|
|
60
|
-
|
|
59
|
+
const r = document.createElement("div"), c = n(r), f = () => {
|
|
60
|
+
c.unmount(), s.removeChild(r);
|
|
61
61
|
};
|
|
62
|
-
|
|
62
|
+
c.render(
|
|
63
63
|
/* @__PURE__ */ d.jsx(
|
|
64
64
|
h,
|
|
65
65
|
{
|
|
66
|
-
content:
|
|
66
|
+
content: t,
|
|
67
67
|
type: o,
|
|
68
|
-
duration:
|
|
68
|
+
duration: i,
|
|
69
69
|
onClose: f
|
|
70
70
|
}
|
|
71
71
|
)
|
|
@@ -74,45 +74,49 @@ function c(e, o = "success", { position: t = "top-right", duration: a = 3e3 } =
|
|
|
74
74
|
}, 10);
|
|
75
75
|
});
|
|
76
76
|
}
|
|
77
|
-
const p = (
|
|
78
|
-
import("react-dom/client").then(({ createRoot:
|
|
79
|
-
const n = l(
|
|
77
|
+
const p = (t, o, e = {}) => {
|
|
78
|
+
import("react-dom/client").then(({ createRoot: i }) => {
|
|
79
|
+
const n = l(e.position);
|
|
80
80
|
if (!n) return;
|
|
81
|
-
const s = document.createElement("div"), r =
|
|
81
|
+
const s = document.createElement("div"), r = i(s), c = () => {
|
|
82
82
|
r.unmount(), n.removeChild(s);
|
|
83
83
|
};
|
|
84
84
|
r.render(
|
|
85
85
|
/* @__PURE__ */ d.jsx(
|
|
86
86
|
u,
|
|
87
87
|
{
|
|
88
|
-
promise:
|
|
88
|
+
promise: t,
|
|
89
89
|
messages: o,
|
|
90
|
-
options:
|
|
91
|
-
onClose:
|
|
90
|
+
options: e,
|
|
91
|
+
onClose: c
|
|
92
92
|
}
|
|
93
93
|
)
|
|
94
94
|
), n.prepend(s), setTimeout(() => {
|
|
95
95
|
s.classList.add("mt-[0.5rem]");
|
|
96
96
|
}, 10);
|
|
97
97
|
});
|
|
98
|
-
}, b = (
|
|
99
|
-
let
|
|
100
|
-
},
|
|
98
|
+
}, b = (t, o = {}) => {
|
|
99
|
+
let e = () => {
|
|
100
|
+
}, i = () => {
|
|
101
101
|
};
|
|
102
102
|
const n = new Promise((s, r) => {
|
|
103
|
-
|
|
103
|
+
e = s, i = r;
|
|
104
104
|
});
|
|
105
|
-
return p(n,
|
|
106
|
-
resolve:
|
|
107
|
-
|
|
105
|
+
return p(n, t, o), {
|
|
106
|
+
resolve: (s) => {
|
|
107
|
+
typeof s == "string" && (t.success = s), e(s);
|
|
108
|
+
},
|
|
109
|
+
reject: (s) => {
|
|
110
|
+
typeof s == "string" && (t.error = s), i(s);
|
|
111
|
+
}
|
|
108
112
|
};
|
|
109
113
|
}, F = {
|
|
110
|
-
success: (
|
|
111
|
-
error: (
|
|
112
|
-
warning: (
|
|
113
|
-
info: (
|
|
114
|
-
async: (
|
|
115
|
-
loading: (
|
|
114
|
+
success: (t, o = {}) => a(t, "success", o),
|
|
115
|
+
error: (t, o = {}) => a(t, "error", o),
|
|
116
|
+
warning: (t, o = {}) => a(t, "warning", o),
|
|
117
|
+
info: (t, o = {}) => a(t, "info", o),
|
|
118
|
+
async: (t, o, e = {}) => p(t, o, e),
|
|
119
|
+
loading: (t, o = {}) => b(t, o)
|
|
116
120
|
};
|
|
117
121
|
export {
|
|
118
122
|
p as showToastAsync,
|