trepur_components 2.4.5 → 2.4.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.
- package/README.md +8 -0
- package/lib/components/Input/index.js +43 -31
- package/lib/components/Select/Select.stories.d.ts +2 -1
- package/lib/components/Select/index.d.ts +2 -1
- package/lib/components/Select/index.js +82 -83
- package/lib/styles/themes/paa.css +3 -3
- package/lib/styles/themes/penrithmrt.css +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -17,3 +17,11 @@ You will need to log into npm if you have not done so already
|
|
|
17
17
|
### `npm publish`
|
|
18
18
|
|
|
19
19
|
Publishes the new version of the package to npm - new version number to be updated in package.json before the publish is executed
|
|
20
|
+
|
|
21
|
+
## Adding a new theme
|
|
22
|
+
|
|
23
|
+
To add a new theme:
|
|
24
|
+
|
|
25
|
+
1. create a new css file in the src/styles/themes folder
|
|
26
|
+
2. ensure that line 1 of the css file contains the new themes name
|
|
27
|
+
3. add the file import for the new css file in the src/styles/globals.css files
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
import { jsx as n, jsxs as
|
|
1
|
+
import { jsx as n, jsxs as s } from "react/jsx-runtime";
|
|
2
2
|
import { forwardRef as o, useMemo as v, createContext as h, useContext as p } from "react";
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
import i from "clsx";
|
|
4
|
+
import { Icon as L } from "../Icon/index.js";
|
|
5
|
+
import { faCircleExclamation as w } from "@fortawesome/free-solid-svg-icons";
|
|
6
|
+
const u = h(null), f = o(({ children: r, className: a, errors: t, placeholder: l, ...e }, m) => {
|
|
7
|
+
const d = v(
|
|
6
8
|
() => ({
|
|
7
9
|
errors: t,
|
|
8
10
|
placeholder: l,
|
|
@@ -10,30 +12,30 @@ const s = h(null), x = o(({ children: r, className: a, errors: t, placeholder: l
|
|
|
10
12
|
}),
|
|
11
13
|
[t, e]
|
|
12
14
|
);
|
|
13
|
-
return /* @__PURE__ */ n(
|
|
15
|
+
return /* @__PURE__ */ n(u.Provider, { value: d, children: /* @__PURE__ */ n(
|
|
14
16
|
"div",
|
|
15
17
|
{
|
|
16
|
-
ref:
|
|
17
|
-
className:
|
|
18
|
+
ref: m,
|
|
19
|
+
className: i("grid grid-cols-1 gap-1 w-full rounded-md", a),
|
|
18
20
|
...e,
|
|
19
21
|
children: r
|
|
20
22
|
}
|
|
21
23
|
) });
|
|
22
|
-
}),
|
|
23
|
-
const { placeholder:
|
|
24
|
-
return /* @__PURE__ */
|
|
24
|
+
}), x = o(({ children: r, handleChange: a, onClick: t, onBlur: l, ...e }, m) => {
|
|
25
|
+
const { placeholder: d, value: I, errors: c } = p(u) || {};
|
|
26
|
+
return /* @__PURE__ */ s("div", { ref: m, className: "group/input relative isolate flex w-full", children: [
|
|
25
27
|
/* @__PURE__ */ n(
|
|
26
28
|
"input",
|
|
27
29
|
{
|
|
28
|
-
placeholder:
|
|
29
|
-
className:
|
|
30
|
+
placeholder: d,
|
|
31
|
+
className: i(
|
|
30
32
|
"h-10 border border-black rounded-md flex w-full bg-card px-3 py-1.5 text-sm placeholder:text-gray-500",
|
|
31
33
|
{
|
|
32
|
-
"border-border border": !
|
|
33
|
-
"border-red-600 border-2":
|
|
34
|
+
"border-border border": !c,
|
|
35
|
+
"border-red-600 border-2": c
|
|
34
36
|
}
|
|
35
37
|
),
|
|
36
|
-
value:
|
|
38
|
+
value: I,
|
|
37
39
|
readOnly: e.readOnly,
|
|
38
40
|
disabled: e.disabled,
|
|
39
41
|
autoComplete: e.autoComplete,
|
|
@@ -44,7 +46,7 @@ const s = h(null), x = o(({ children: r, className: a, errors: t, placeholder: l
|
|
|
44
46
|
required: e.required,
|
|
45
47
|
type: e.type,
|
|
46
48
|
name: e.name,
|
|
47
|
-
onChange: (
|
|
49
|
+
onChange: (g) => a == null ? void 0 : a(g.target.value),
|
|
48
50
|
onClick: t,
|
|
49
51
|
onBlur: l,
|
|
50
52
|
onFocus: e.onFocus
|
|
@@ -57,46 +59,56 @@ const s = h(null), x = o(({ children: r, className: a, errors: t, placeholder: l
|
|
|
57
59
|
"div",
|
|
58
60
|
{
|
|
59
61
|
ref: t,
|
|
60
|
-
className:
|
|
62
|
+
className: i(
|
|
61
63
|
"absolute right-1 top-1/2 my-auto -translate-y-1/2",
|
|
62
64
|
r
|
|
63
65
|
),
|
|
64
66
|
children: a
|
|
65
67
|
}
|
|
66
68
|
)
|
|
67
|
-
), y = o(({ className: r, children: a, required: t = !1 }, l) => /* @__PURE__ */
|
|
69
|
+
), y = o(({ className: r, children: a, required: t = !1 }, l) => /* @__PURE__ */ s(
|
|
68
70
|
"div",
|
|
69
71
|
{
|
|
70
72
|
ref: l,
|
|
71
|
-
className:
|
|
73
|
+
className: i("flex px-1 text-sm font-normal leading-5", r),
|
|
72
74
|
children: [
|
|
73
75
|
/* @__PURE__ */ n("p", { children: a }),
|
|
74
76
|
t && /* @__PURE__ */ n("p", { className: "text-sm font-normal", children: "*" })
|
|
75
77
|
]
|
|
76
78
|
}
|
|
77
|
-
)),
|
|
78
|
-
const { errors: t } = p(
|
|
79
|
-
return /* @__PURE__ */ n(
|
|
79
|
+
)), N = o(({ ...r }, a) => {
|
|
80
|
+
const { errors: t } = p(u) || {};
|
|
81
|
+
return t ? /* @__PURE__ */ n(
|
|
80
82
|
"div",
|
|
81
83
|
{
|
|
82
84
|
ref: a,
|
|
83
85
|
className: "text-sm pl-1 font-medium text-error-default",
|
|
84
86
|
...r,
|
|
85
|
-
children: t == null ? void 0 : t.map((l, e) => /* @__PURE__ */
|
|
87
|
+
children: t == null ? void 0 : t.map((l, e) => /* @__PURE__ */ s("div", { className: "gap-1 flex", children: [
|
|
88
|
+
/* @__PURE__ */ n(
|
|
89
|
+
L,
|
|
90
|
+
{
|
|
91
|
+
className: "my-auto text-error-default",
|
|
92
|
+
icon: w,
|
|
93
|
+
co: !0
|
|
94
|
+
}
|
|
95
|
+
),
|
|
96
|
+
/* @__PURE__ */ n("span", { className: "my-auto", children: l }, `error-msg-${e + 1}`)
|
|
97
|
+
] }))
|
|
86
98
|
}
|
|
87
|
-
);
|
|
99
|
+
) : null;
|
|
88
100
|
});
|
|
89
|
-
|
|
101
|
+
f.displayName = "Input";
|
|
90
102
|
b.displayName = "Input.Actions";
|
|
91
103
|
y.displayName = "Input.Label";
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
const
|
|
104
|
+
N.displayName = "Input.Validation";
|
|
105
|
+
x.displayName = "Input.Wrapper";
|
|
106
|
+
const W = Object.assign(f, {
|
|
95
107
|
Label: y,
|
|
96
|
-
Validation:
|
|
108
|
+
Validation: N,
|
|
97
109
|
Actions: b,
|
|
98
|
-
Wrapper:
|
|
110
|
+
Wrapper: x
|
|
99
111
|
});
|
|
100
112
|
export {
|
|
101
|
-
|
|
113
|
+
W as Input
|
|
102
114
|
};
|
|
@@ -3,7 +3,7 @@ import { Select } from '.';
|
|
|
3
3
|
|
|
4
4
|
declare const meta: {
|
|
5
5
|
title: string;
|
|
6
|
-
component: import('react').ForwardRefExoticComponent<import('react').HTMLAttributes<HTMLDivElement> & import('.').SelectContextProps & import('react').RefAttributes<HTMLDivElement>> & {
|
|
6
|
+
component: import('react').ForwardRefExoticComponent<import('react').HTMLAttributes<HTMLDivElement> & Omit<import('react').HTMLAttributes<HTMLDivElement> & import('../Input').InputContextProps & import('react').RefAttributes<HTMLDivElement>, "ref"> & import('.').SelectContextProps & import('react').RefAttributes<HTMLDivElement>> & {
|
|
7
7
|
Item: import('react').ForwardRefExoticComponent<import('react').HTMLAttributes<HTMLLIElement> & {
|
|
8
8
|
value: string;
|
|
9
9
|
} & import('react').RefAttributes<HTMLLIElement>>;
|
|
@@ -14,6 +14,7 @@ declare const meta: {
|
|
|
14
14
|
parameters: {};
|
|
15
15
|
args: {
|
|
16
16
|
label: string;
|
|
17
|
+
placeholder: string;
|
|
17
18
|
children: import("react/jsx-runtime").JSX.Element[];
|
|
18
19
|
};
|
|
19
20
|
};
|
|
@@ -10,9 +10,10 @@ export interface SelectContextProps {
|
|
|
10
10
|
internalValue?: string;
|
|
11
11
|
setInternalValue?: (val: string) => void;
|
|
12
12
|
label?: string;
|
|
13
|
+
placeholder?: string;
|
|
13
14
|
handleChange?: (e: any) => void;
|
|
14
15
|
}
|
|
15
|
-
declare const Select: import('react').ForwardRefExoticComponent<HTMLAttributes<HTMLDivElement> & SelectContextProps & import('react').RefAttributes<HTMLDivElement>> & {
|
|
16
|
+
declare const Select: import('react').ForwardRefExoticComponent<HTMLAttributes<HTMLDivElement> & Omit<HTMLAttributes<HTMLDivElement> & import('../Input').InputContextProps & import('react').RefAttributes<HTMLDivElement>, "ref"> & SelectContextProps & import('react').RefAttributes<HTMLDivElement>> & {
|
|
16
17
|
Item: import('react').ForwardRefExoticComponent<HTMLAttributes<HTMLLIElement> & {
|
|
17
18
|
value: string;
|
|
18
19
|
} & import('react').RefAttributes<HTMLLIElement>>;
|
|
@@ -1,154 +1,153 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { forwardRef as i, useState as
|
|
3
|
-
import
|
|
1
|
+
import { jsx as l, jsxs as I } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef as i, useState as y, useCallback as x, useEffect as E, createContext as H, useContext as p } from "react";
|
|
3
|
+
import d from "clsx";
|
|
4
4
|
import { Input as m } from "../Input/index.js";
|
|
5
|
-
import { Card as
|
|
5
|
+
import { Card as P } from "../Card/index.js";
|
|
6
6
|
import { Button as v } from "../Button/index.js";
|
|
7
|
-
import { faCaretDown as
|
|
8
|
-
const
|
|
7
|
+
import { faCaretDown as R } from "@fortawesome/fontawesome-free-solid";
|
|
8
|
+
const u = H(null), w = i(
|
|
9
9
|
({
|
|
10
|
-
id:
|
|
11
|
-
open:
|
|
12
|
-
defaultOpen:
|
|
10
|
+
id: o,
|
|
11
|
+
open: r,
|
|
12
|
+
defaultOpen: a,
|
|
13
13
|
onOpenChange: t,
|
|
14
14
|
onChange: e,
|
|
15
|
-
className:
|
|
16
|
-
children:
|
|
15
|
+
className: n,
|
|
16
|
+
children: c,
|
|
17
17
|
loading: f,
|
|
18
|
-
label:
|
|
19
|
-
|
|
18
|
+
label: z,
|
|
19
|
+
placeholder: B,
|
|
20
|
+
...D
|
|
20
21
|
}) => {
|
|
21
|
-
const [
|
|
22
|
-
(
|
|
23
|
-
|
|
22
|
+
const [M, V] = y(r ?? a), [S, b] = y(""), N = x(
|
|
23
|
+
(s) => {
|
|
24
|
+
V(s), t == null || t(s);
|
|
24
25
|
},
|
|
25
26
|
[t]
|
|
26
|
-
),
|
|
27
|
+
), h = {
|
|
27
28
|
loading: f,
|
|
28
|
-
label:
|
|
29
|
-
|
|
29
|
+
label: z,
|
|
30
|
+
placeholder: B,
|
|
31
|
+
open: M,
|
|
30
32
|
setOpen: N,
|
|
31
33
|
internalValue: S,
|
|
32
34
|
setInternalValue: b
|
|
33
35
|
};
|
|
34
|
-
|
|
35
|
-
() => N(
|
|
36
|
-
[
|
|
36
|
+
E(
|
|
37
|
+
() => N(r ?? a ?? !1),
|
|
38
|
+
[r, a, N]
|
|
37
39
|
);
|
|
38
|
-
const
|
|
39
|
-
(
|
|
40
|
-
S.includes(
|
|
40
|
+
const A = x(
|
|
41
|
+
(s) => {
|
|
42
|
+
alert(s), S.includes(s) ? (b(""), e == null || e("")) : (b(s), e == null || e(s));
|
|
41
43
|
},
|
|
42
44
|
[S, e]
|
|
43
45
|
);
|
|
44
|
-
return /* @__PURE__ */
|
|
45
|
-
/* @__PURE__ */
|
|
46
|
-
|
|
46
|
+
return /* @__PURE__ */ l(u.Provider, { value: h, children: /* @__PURE__ */ I("div", { className: "relative", children: [
|
|
47
|
+
/* @__PURE__ */ l(
|
|
48
|
+
j,
|
|
47
49
|
{
|
|
48
|
-
id:
|
|
49
|
-
className:
|
|
50
|
-
onChange: () =>
|
|
51
|
-
...
|
|
52
|
-
children:
|
|
50
|
+
id: o,
|
|
51
|
+
className: n,
|
|
52
|
+
onChange: () => A,
|
|
53
|
+
...D,
|
|
54
|
+
children: c
|
|
53
55
|
}
|
|
54
56
|
),
|
|
55
|
-
/* @__PURE__ */
|
|
57
|
+
/* @__PURE__ */ l(k, { children: c })
|
|
56
58
|
] }) });
|
|
57
59
|
}
|
|
58
|
-
),
|
|
59
|
-
const { open: t, setOpen: e } = p(
|
|
60
|
-
return /* @__PURE__ */
|
|
60
|
+
), W = i(({ className: o, ...r }, a) => {
|
|
61
|
+
const { open: t, setOpen: e } = p(u) || {};
|
|
62
|
+
return /* @__PURE__ */ l(
|
|
61
63
|
v,
|
|
62
64
|
{
|
|
63
|
-
ref:
|
|
64
|
-
className:
|
|
65
|
+
ref: a,
|
|
66
|
+
className: o,
|
|
65
67
|
"aria-label": "toggle open",
|
|
66
68
|
onClick: () => e == null ? void 0 : e(!t),
|
|
67
69
|
variant: "ghost",
|
|
68
70
|
size: "sm",
|
|
69
|
-
...
|
|
70
|
-
children: /* @__PURE__ */
|
|
71
|
+
...r,
|
|
72
|
+
children: /* @__PURE__ */ l(
|
|
71
73
|
v.Icon,
|
|
72
74
|
{
|
|
73
|
-
className:
|
|
75
|
+
className: d("transition-transform duration-300 ease-in-out", {
|
|
74
76
|
"rotate-180 transform": t
|
|
75
77
|
}),
|
|
76
|
-
icon:
|
|
78
|
+
icon: R
|
|
77
79
|
}
|
|
78
80
|
)
|
|
79
81
|
}
|
|
80
82
|
);
|
|
81
|
-
}), L = i(({ className:
|
|
82
|
-
const { open:
|
|
83
|
+
}), L = i(({ className: o, children: r }, a) => /* @__PURE__ */ l(m.Label, { className: o, ref: a, children: r })), j = i(({ className: o, ...r }, a) => {
|
|
84
|
+
const { open: t, setOpen: e, internalValue: n, label: c, placeholder: f } = p(u) || {};
|
|
83
85
|
return /* @__PURE__ */ I(
|
|
84
86
|
m,
|
|
85
87
|
{
|
|
86
|
-
className:
|
|
87
|
-
"w-full rounded-md bg-white caret-transparent ",
|
|
88
|
-
l
|
|
89
|
-
),
|
|
88
|
+
className: d("w-full rounded-md caret-transparent ", o),
|
|
90
89
|
ref: a,
|
|
91
|
-
"data-open":
|
|
92
|
-
placeholder:
|
|
93
|
-
value:
|
|
94
|
-
|
|
90
|
+
"data-open": t,
|
|
91
|
+
placeholder: f,
|
|
92
|
+
value: n ?? "",
|
|
93
|
+
...r,
|
|
95
94
|
children: [
|
|
96
|
-
/* @__PURE__ */
|
|
97
|
-
/* @__PURE__ */
|
|
95
|
+
/* @__PURE__ */ l(m.Label, { children: c }),
|
|
96
|
+
/* @__PURE__ */ l(
|
|
98
97
|
m.Wrapper,
|
|
99
98
|
{
|
|
100
|
-
onClick: () =>
|
|
101
|
-
onBlur: () =>
|
|
102
|
-
className:
|
|
99
|
+
onClick: () => e == null ? void 0 : e(!t),
|
|
100
|
+
onBlur: () => e == null ? void 0 : e(!1),
|
|
101
|
+
className: d(
|
|
103
102
|
"caret-transparent rounded hover:cursor-pointer data-[open=true]:border-primary data-[open=true]:ring-1 data-[open=true]:ring-primary",
|
|
104
|
-
|
|
103
|
+
o
|
|
105
104
|
),
|
|
106
|
-
children: /* @__PURE__ */
|
|
105
|
+
children: /* @__PURE__ */ l(m.Actions, { children: /* @__PURE__ */ l(W, {}) })
|
|
107
106
|
}
|
|
108
107
|
)
|
|
109
108
|
]
|
|
110
109
|
}
|
|
111
110
|
);
|
|
112
|
-
}),
|
|
113
|
-
const { open: e } = p(
|
|
114
|
-
return e ? /* @__PURE__ */
|
|
115
|
-
|
|
111
|
+
}), k = i(({ children: o, className: r, ...a }, t) => {
|
|
112
|
+
const { open: e } = p(u) || {};
|
|
113
|
+
return e ? /* @__PURE__ */ l(
|
|
114
|
+
P,
|
|
116
115
|
{
|
|
117
116
|
ref: t,
|
|
118
|
-
className:
|
|
119
|
-
"!
|
|
120
|
-
|
|
117
|
+
className: d(
|
|
118
|
+
"!rounded-md z-10 mt-0.5 absolute overflow-hidden !p-0 data-[state=open]:animate-in w-full data-[state=open]:fade-in-0",
|
|
119
|
+
r
|
|
121
120
|
),
|
|
122
|
-
...
|
|
123
|
-
children: /* @__PURE__ */
|
|
121
|
+
...a,
|
|
122
|
+
children: /* @__PURE__ */ l("ul", { children: o })
|
|
124
123
|
}
|
|
125
124
|
) : null;
|
|
126
|
-
}),
|
|
127
|
-
const { setInternalValue:
|
|
128
|
-
return /* @__PURE__ */
|
|
125
|
+
}), T = i(({ children: o, value: r, className: a, ...t }, e) => {
|
|
126
|
+
const { setInternalValue: n } = p(u) || {};
|
|
127
|
+
return /* @__PURE__ */ l(
|
|
129
128
|
"li",
|
|
130
129
|
{
|
|
131
130
|
ref: e,
|
|
132
|
-
className:
|
|
131
|
+
className: d(
|
|
133
132
|
"hover:cursor-pointer hover:bg-gray-100 w-full py-2 px-4",
|
|
134
|
-
|
|
133
|
+
a
|
|
135
134
|
),
|
|
136
|
-
value:
|
|
137
|
-
onMouseDown: (
|
|
135
|
+
value: r,
|
|
136
|
+
onMouseDown: (c) => n == null ? void 0 : n(c.target.innerHTML),
|
|
138
137
|
...t,
|
|
139
|
-
children:
|
|
138
|
+
children: o
|
|
140
139
|
}
|
|
141
140
|
);
|
|
142
141
|
});
|
|
143
142
|
w.displayName = "Select";
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
143
|
+
k.displayName = "Select.Content";
|
|
144
|
+
j.displayName = "Select.Trigger";
|
|
145
|
+
T.displayName = "Select.Item";
|
|
147
146
|
L.displayName = "Select.Label";
|
|
148
|
-
const
|
|
149
|
-
Item:
|
|
147
|
+
const U = Object.assign(w, {
|
|
148
|
+
Item: T,
|
|
150
149
|
Label: L
|
|
151
150
|
});
|
|
152
151
|
export {
|
|
153
|
-
|
|
152
|
+
U as Select
|
|
154
153
|
};
|
|
@@ -6,7 +6,7 @@ body.theme-paa {
|
|
|
6
6
|
--color-loading: #a3a3a3;
|
|
7
7
|
|
|
8
8
|
/* pill */
|
|
9
|
-
--color-error-default: #
|
|
9
|
+
--color-error-default: #b91c1c;
|
|
10
10
|
--color-warning-default: #a16207;
|
|
11
11
|
--color-success-default: #047857;
|
|
12
12
|
--color-info-default: #0369a1;
|
|
@@ -20,13 +20,13 @@ body.theme-paa {
|
|
|
20
20
|
--color-button-primary-active: #68a97b;
|
|
21
21
|
--color-button-primary-border: #68a97b;
|
|
22
22
|
--color-button-primary-bg: #68a97b;
|
|
23
|
-
--color-button-primary-text: #
|
|
23
|
+
--color-button-primary-text: #1d341e;
|
|
24
24
|
--color-button-primary-hover: #68a97b;
|
|
25
25
|
|
|
26
26
|
--color-button-secondary-active: #1d341e;
|
|
27
27
|
--color-button-secondary-border: #1d341e;
|
|
28
28
|
--color-button-secondary-bg: #1d341e;
|
|
29
|
-
--color-button-secondary-text: #
|
|
29
|
+
--color-button-secondary-text: #ede9d3;
|
|
30
30
|
--color-button-secondary-hover: #1d341e;
|
|
31
31
|
|
|
32
32
|
--color-button-ghost-active: #242424;
|