@arkyn/components 1.3.144 → 1.3.146

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.
@@ -1,5 +1,7 @@
1
1
  import { SelectProps } from "@arkyn/types";
2
2
  declare function getConfig(props: SelectProps, isFocused: boolean): {
3
+ isSearchable?: boolean;
4
+ onSearch?: (value: string) => void;
3
5
  name: string;
4
6
  value?: string;
5
7
  defaultValue?: string;
@@ -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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA4CxD;AAED,OAAO,EAAE,SAAS,EAAE,CAAC"}
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;AAQhD,OAAO,cAAc,CAAC;AAGtB,iBAAS,MAAM,CAAC,KAAK,EAAE,WAAW,2CA4IjC;AAED,OAAO,EAAE,MAAM,EAAE,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: [options.map(({ label, value }) => (_jsxs("div", { onClick: () => handleChangeValue({ label, value }), className: currentValue === value
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,2CAmBtD;AAED,OAAO,EAAE,aAAa,EAAE,CAAC"}
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,6 +1,6 @@
1
1
  {
2
2
  "name": "@arkyn/components",
3
- "version": "1.3.144",
3
+ "version": "1.3.146",
4
4
  "main": "./dist/bundle.js",
5
5
  "types": "./dist/index.d.ts",
6
6
  "author": "Lucas Gonçalves",
@@ -16,7 +16,6 @@ function getConfig(props: SelectProps, isFocused: boolean) {
16
16
  readOnly,
17
17
  onFocus,
18
18
  onBlur,
19
-
20
19
  title,
21
20
  style,
22
21
  closeOnSelect = true,
@@ -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
- {options.map(({ label, value }) => (
120
- <div
121
- key={value}
122
- onClick={() => handleChangeValue({ label, value })}
123
- className={
124
- currentValue === value
125
- ? "arkyn_select_option active"
126
- : "arkyn_select_option"
127
- }
128
- >
129
- {label} <Check />
130
- </div>
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