@tecsinapse/cortex-react 1.3.0-beta.30 → 1.3.0-beta.31
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.
|
@@ -7,10 +7,14 @@ var index = require('../Popover/index.js');
|
|
|
7
7
|
var context = require('./context.js');
|
|
8
8
|
|
|
9
9
|
const { button } = cortexCore.selectVariants();
|
|
10
|
-
const SelectTrigger = ({
|
|
10
|
+
const SelectTrigger = ({
|
|
11
|
+
label,
|
|
12
|
+
placeholder,
|
|
13
|
+
disabled
|
|
14
|
+
}) => {
|
|
11
15
|
const { value, labelExtractor } = React.useContext(context.SelectContext);
|
|
12
|
-
const
|
|
13
|
-
if (value?.length === 0 || !value) return label;
|
|
16
|
+
const _placeholder = React.useMemo(() => {
|
|
17
|
+
if (value?.length === 0 || !value) return placeholder ?? label;
|
|
14
18
|
if (value?.length === 1) return labelExtractor(value[0]);
|
|
15
19
|
if (value?.length > 1) return `${value.length} items selected`;
|
|
16
20
|
return labelExtractor(value);
|
|
@@ -22,7 +26,7 @@ const SelectTrigger = ({ label, disabled }) => {
|
|
|
22
26
|
disabled,
|
|
23
27
|
role: "button"
|
|
24
28
|
},
|
|
25
|
-
/* @__PURE__ */ React.createElement("span", { "data-testid": "select-placeholder" },
|
|
29
|
+
/* @__PURE__ */ React.createElement("span", { "data-testid": "select-placeholder" }, _placeholder),
|
|
26
30
|
/* @__PURE__ */ React.createElement(io5.IoChevronDownOutline, null)
|
|
27
31
|
));
|
|
28
32
|
};
|
|
@@ -5,10 +5,14 @@ import { Popover } from '../Popover/index.js';
|
|
|
5
5
|
import { SelectContext } from './context.js';
|
|
6
6
|
|
|
7
7
|
const { button } = selectVariants();
|
|
8
|
-
const SelectTrigger = ({
|
|
8
|
+
const SelectTrigger = ({
|
|
9
|
+
label,
|
|
10
|
+
placeholder,
|
|
11
|
+
disabled
|
|
12
|
+
}) => {
|
|
9
13
|
const { value, labelExtractor } = useContext(SelectContext);
|
|
10
|
-
const
|
|
11
|
-
if (value?.length === 0 || !value) return label;
|
|
14
|
+
const _placeholder = useMemo(() => {
|
|
15
|
+
if (value?.length === 0 || !value) return placeholder ?? label;
|
|
12
16
|
if (value?.length === 1) return labelExtractor(value[0]);
|
|
13
17
|
if (value?.length > 1) return `${value.length} items selected`;
|
|
14
18
|
return labelExtractor(value);
|
|
@@ -20,7 +24,7 @@ const SelectTrigger = ({ label, disabled }) => {
|
|
|
20
24
|
disabled,
|
|
21
25
|
role: "button"
|
|
22
26
|
},
|
|
23
|
-
/* @__PURE__ */ React__default.createElement("span", { "data-testid": "select-placeholder" },
|
|
27
|
+
/* @__PURE__ */ React__default.createElement("span", { "data-testid": "select-placeholder" }, _placeholder),
|
|
24
28
|
/* @__PURE__ */ React__default.createElement(IoChevronDownOutline, null)
|
|
25
29
|
));
|
|
26
30
|
};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { SelectTriggerProps } from './types';
|
|
2
|
-
export declare const SelectTrigger: ({ label, disabled }: SelectTriggerProps) => JSX.Element;
|
|
2
|
+
export declare const SelectTrigger: ({ label, placeholder, disabled, }: SelectTriggerProps) => JSX.Element;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export declare const Select: {
|
|
2
2
|
Root: <T>({ children, value, keyExtractor, labelExtractor, }: import("./types").SelectRootProps<T>) => JSX.Element;
|
|
3
|
-
Trigger: ({ label, disabled }: import("./types").SelectTriggerProps) => JSX.Element;
|
|
3
|
+
Trigger: ({ label, placeholder, disabled, }: import("./types").SelectTriggerProps) => JSX.Element;
|
|
4
4
|
Popover: ({ children }: import("./types").SelectPopoverProps) => JSX.Element;
|
|
5
5
|
Options: <T_1>({ onSelect, options, }: import("./types").SelectOptionsProps<T_1>) => JSX.Element;
|
|
6
6
|
GroupedOptions: <T_2>({ onSelect, groupedLabelExtractor, options, }: import("./types").SelectGroupedOptionsProps<T_2>) => JSX.Element;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tecsinapse/cortex-react",
|
|
3
|
-
"version": "1.3.0-beta.
|
|
3
|
+
"version": "1.3.0-beta.31",
|
|
4
4
|
"description": "React components based in @tecsinapse/cortex-core",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "dist/esm/index.js",
|
|
@@ -43,5 +43,5 @@
|
|
|
43
43
|
"react-dom": ">=18.0.0",
|
|
44
44
|
"tailwind": ">=3.3.0"
|
|
45
45
|
},
|
|
46
|
-
"gitHead": "
|
|
46
|
+
"gitHead": "cac77d615452fa145511f48fe32c76d4e10f79b1"
|
|
47
47
|
}
|