@arkyn/components 1.3.144 → 1.3.146
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/bundle.js +36163 -13987
- package/dist/bundle.umd.cjs +707 -157
- package/dist/components/Select/getConfig.d.ts +2 -0
- package/dist/components/Select/getConfig.d.ts.map +1 -1
- package/dist/components/Select/index.d.ts.map +1 -1
- package/dist/components/Select/index.js +16 -4
- package/dist/provider/ToastProvider.d.ts.map +1 -1
- package/dist/provider/ToastProvider.js +26 -2
- package/package.json +1 -1
- package/src/components/Select/getConfig.tsx +0 -1
- package/src/components/Select/index.tsx +37 -16
- package/src/provider/ToastProvider.tsx +26 -2
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"getConfig.d.ts","sourceRoot":"","sources":["../../../src/components/Select/getConfig.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAK3C,iBAAS,SAAS,CAAC,KAAK,EAAE,WAAW,EAAE,SAAS,EAAE,OAAO
|
1
|
+
{"version":3,"file":"getConfig.d.ts","sourceRoot":"","sources":["../../../src/components/Select/getConfig.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAK3C,iBAAS,SAAS,CAAC,KAAK,EAAE,WAAW,EAAE,SAAS,EAAE,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA2CxD;AAED,OAAO,EAAE,SAAS,EAAE,CAAC"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/Select/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/Select/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAUhD,OAAO,cAAc,CAAC;AAEtB,iBAAS,MAAM,CAAC,KAAK,EAAE,WAAW,2CAgKjC;AAED,OAAO,EAAE,MAAM,EAAE,CAAC"}
|
@@ -1,16 +1,18 @@
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
2
|
-
import { Check, ChevronDown } from "lucide-react";
|
2
|
+
import { Check, ChevronDown, Search } from "lucide-react";
|
3
3
|
import { useRef, useState } from "react";
|
4
4
|
import { getConfig } from "./getConfig";
|
5
|
-
import "./styles.css";
|
6
5
|
import { useFormController } from "../../components/Form/FormController";
|
6
|
+
import { Input } from "../Input";
|
7
|
+
import "./styles.css";
|
7
8
|
function Select(props) {
|
9
|
+
const [search, setSearch] = useState("");
|
8
10
|
const [isFocused, setIsFocused] = useState(false);
|
9
11
|
const { inputRef, id, error } = useFormController();
|
10
12
|
const baseRef = useRef(null);
|
11
13
|
const ref = inputRef || baseRef;
|
12
14
|
const isError = props.isError || !!error;
|
13
|
-
const { disabled, title, style, className, prefix, iconSize, isLoading, LeftIcon, value: baseValue = null, defaultValue = "", onFocus, onBlur, Spinner, name, placeholder, onSelect, options, optionMaxHeight, closeOnSelect, ...rest } = getConfig({ ...props, id, isError }, isFocused);
|
15
|
+
const { disabled, title, style, className, prefix, iconSize, isLoading, LeftIcon, value: baseValue = null, defaultValue = "", onFocus, onBlur, Spinner, name, placeholder, onSelect, options, optionMaxHeight, closeOnSelect, isSearchable, onSearch, ...rest } = getConfig({ ...props, id, isError }, isFocused);
|
14
16
|
const [selectedValue, setSelectedValue] = useState(defaultValue);
|
15
17
|
function handleSectionClick() {
|
16
18
|
if (disabled || !ref?.current || isFocused)
|
@@ -53,7 +55,17 @@ function Select(props) {
|
|
53
55
|
if (isFocused && !currentLabel)
|
54
56
|
return false;
|
55
57
|
};
|
56
|
-
return (_jsxs(_Fragment, { children: [_jsxs("section", { title: title, style: style, onClick: handleSectionClick, className: `${className} placeholder_dark_${placeholderDark()}`, children: [prefix, LeftIcon && _jsx(LeftIcon, { size: iconSize, strokeWidth: 2.5 }), _jsx("input", { disabled: disabled, readOnly: true, placeholder: currentLabel || placeholder, onFocus: handleFocus, ...rest }), _jsx("input", { type: "hidden", ref: ref, name: name, value: currentValue || "", readOnly: true }), isFocused && (_jsxs("div", { className: "arkyn_select_content", style: { overflow: "auto", maxHeight: optionMaxHeight }, children: [
|
58
|
+
return (_jsxs(_Fragment, { children: [_jsxs("section", { title: title, style: style, onClick: handleSectionClick, className: `${className} placeholder_dark_${placeholderDark()}`, children: [prefix, LeftIcon && _jsx(LeftIcon, { size: iconSize, strokeWidth: 2.5 }), _jsx("input", { disabled: disabled, readOnly: true, placeholder: currentLabel || placeholder, onFocus: handleFocus, ...rest }), _jsx("input", { type: "hidden", ref: ref, name: name, value: currentValue || "", readOnly: true }), isFocused && (_jsxs("div", { className: "arkyn_select_content", style: { overflow: "auto", maxHeight: optionMaxHeight }, children: [isSearchable && (_jsx(Input, { type: "search", name: "search-select", variant: "underline", leftIcon: Search, onChange: (e) => setSearch(e.target.value) })), options
|
59
|
+
.filter((option) => {
|
60
|
+
if (props.onSearch)
|
61
|
+
return true;
|
62
|
+
if (!props.isSearchable)
|
63
|
+
return true;
|
64
|
+
if (option.label.toLowerCase().includes(search.toLowerCase()))
|
65
|
+
return true;
|
66
|
+
return false;
|
67
|
+
})
|
68
|
+
.map(({ label, value }) => (_jsxs("div", { onClick: () => handleChangeValue({ label, value }), className: currentValue === value
|
57
69
|
? "arkyn_select_option active"
|
58
70
|
: "arkyn_select_option", children: [label, " ", _jsx(Check, {})] }, value))), options.length <= 0 && _jsx("p", { children: "Sem op\u00E7\u00F5es dispon\u00EDveis" })] })), !isLoading && (_jsx(ChevronDown, { className: "arkyn_select_arrow", size: iconSize, strokeWidth: 2.5 })), isLoading && Spinner] }), isFocused && (_jsx("aside", { className: "arkyn_select_overlay", onClick: handleBlur }))] }));
|
59
71
|
}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"ToastProvider.d.ts","sourceRoot":"","sources":["../../src/provider/ToastProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAc,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAK9D,iBAAS,aAAa,CAAC,EAAE,QAAQ,EAAE,EAAE,kBAAkB,
|
1
|
+
{"version":3,"file":"ToastProvider.d.ts","sourceRoot":"","sources":["../../src/provider/ToastProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAc,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAK9D,iBAAS,aAAa,CAAC,EAAE,QAAQ,EAAE,EAAE,kBAAkB,2CA2CtD;AAED,OAAO,EAAE,aAAa,EAAE,CAAC"}
|
@@ -5,9 +5,33 @@ function ToastProvider({ children }) {
|
|
5
5
|
function showToast(props) {
|
6
6
|
switch (props.type) {
|
7
7
|
case "success":
|
8
|
-
return toast.success(props.message
|
8
|
+
return toast.success(props.message, {
|
9
|
+
style: {
|
10
|
+
background: "#10B981",
|
11
|
+
color: "#ffffff",
|
12
|
+
padding: "12px 16px",
|
13
|
+
fontSize: "14px",
|
14
|
+
fontWeight: 600,
|
15
|
+
},
|
16
|
+
iconTheme: {
|
17
|
+
primary: "#059669",
|
18
|
+
secondary: "#ffffff",
|
19
|
+
},
|
20
|
+
});
|
9
21
|
case "danger":
|
10
|
-
return toast.error(props.message
|
22
|
+
return toast.error(props.message, {
|
23
|
+
style: {
|
24
|
+
background: "#E11D48",
|
25
|
+
color: "#ffffff",
|
26
|
+
padding: "12px 16px",
|
27
|
+
fontSize: "14px",
|
28
|
+
fontWeight: 600,
|
29
|
+
},
|
30
|
+
iconTheme: {
|
31
|
+
primary: "#BE123C",
|
32
|
+
secondary: "#ffffff",
|
33
|
+
},
|
34
|
+
});
|
11
35
|
}
|
12
36
|
}
|
13
37
|
return (_jsxs(ToastContext.Provider, { value: { showToast }, children: [_jsx(Toaster, { position: "top-right", containerStyle: { zIndex: 999999999999999 } }), children] }));
|
package/package.json
CHANGED
@@ -1,15 +1,17 @@
|
|
1
1
|
import type { SelectProps } from "@arkyn/types";
|
2
2
|
import type { FocusEvent } from "react";
|
3
3
|
|
4
|
-
import { Check, ChevronDown } from "lucide-react";
|
4
|
+
import { Check, ChevronDown, Search } from "lucide-react";
|
5
5
|
import { useRef, useState } from "react";
|
6
6
|
|
7
7
|
import { getConfig } from "./getConfig";
|
8
8
|
|
9
|
-
import "./styles.css";
|
10
9
|
import { useFormController } from "../../components/Form/FormController";
|
10
|
+
import { Input } from "../Input";
|
11
|
+
import "./styles.css";
|
11
12
|
|
12
13
|
function Select(props: SelectProps) {
|
14
|
+
const [search, setSearch] = useState("");
|
13
15
|
const [isFocused, setIsFocused] = useState(false);
|
14
16
|
const { inputRef, id, error } = useFormController();
|
15
17
|
|
@@ -38,7 +40,8 @@ function Select(props: SelectProps) {
|
|
38
40
|
options,
|
39
41
|
optionMaxHeight,
|
40
42
|
closeOnSelect,
|
41
|
-
|
43
|
+
isSearchable,
|
44
|
+
onSearch,
|
42
45
|
...rest
|
43
46
|
} = getConfig({ ...props, id, isError }, isFocused);
|
44
47
|
|
@@ -116,19 +119,37 @@ function Select(props: SelectProps) {
|
|
116
119
|
className="arkyn_select_content"
|
117
120
|
style={{ overflow: "auto", maxHeight: optionMaxHeight }}
|
118
121
|
>
|
119
|
-
{
|
120
|
-
<
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
122
|
+
{isSearchable && (
|
123
|
+
<Input
|
124
|
+
type="search"
|
125
|
+
name="search-select"
|
126
|
+
variant="underline"
|
127
|
+
leftIcon={Search}
|
128
|
+
onChange={(e) => setSearch(e.target.value)}
|
129
|
+
/>
|
130
|
+
)}
|
131
|
+
|
132
|
+
{options
|
133
|
+
.filter((option) => {
|
134
|
+
if (props.onSearch) return true;
|
135
|
+
if (!props.isSearchable) return true;
|
136
|
+
if (option.label.toLowerCase().includes(search.toLowerCase()))
|
137
|
+
return true;
|
138
|
+
return false;
|
139
|
+
})
|
140
|
+
.map(({ label, value }) => (
|
141
|
+
<div
|
142
|
+
key={value}
|
143
|
+
onClick={() => handleChangeValue({ label, value })}
|
144
|
+
className={
|
145
|
+
currentValue === value
|
146
|
+
? "arkyn_select_option active"
|
147
|
+
: "arkyn_select_option"
|
148
|
+
}
|
149
|
+
>
|
150
|
+
{label} <Check />
|
151
|
+
</div>
|
152
|
+
))}
|
132
153
|
|
133
154
|
{options.length <= 0 && <p>Sem opções disponíveis</p>}
|
134
155
|
</div>
|
@@ -7,9 +7,33 @@ function ToastProvider({ children }: ToastProviderProps) {
|
|
7
7
|
function showToast(props: ToastProps) {
|
8
8
|
switch (props.type) {
|
9
9
|
case "success":
|
10
|
-
return toast.success(props.message
|
10
|
+
return toast.success(props.message, {
|
11
|
+
style: {
|
12
|
+
background: "#10B981",
|
13
|
+
color: "#ffffff",
|
14
|
+
padding: "12px 16px",
|
15
|
+
fontSize: "14px",
|
16
|
+
fontWeight: 600,
|
17
|
+
},
|
18
|
+
iconTheme: {
|
19
|
+
primary: "#059669",
|
20
|
+
secondary: "#ffffff",
|
21
|
+
},
|
22
|
+
});
|
11
23
|
case "danger":
|
12
|
-
return toast.error(props.message
|
24
|
+
return toast.error(props.message, {
|
25
|
+
style: {
|
26
|
+
background: "#E11D48",
|
27
|
+
color: "#ffffff",
|
28
|
+
padding: "12px 16px",
|
29
|
+
fontSize: "14px",
|
30
|
+
fontWeight: 600,
|
31
|
+
},
|
32
|
+
iconTheme: {
|
33
|
+
primary: "#BE123C",
|
34
|
+
secondary: "#ffffff",
|
35
|
+
},
|
36
|
+
});
|
13
37
|
}
|
14
38
|
}
|
15
39
|
|