@tecsinapse/cortex-react 1.13.0-beta.1 → 1.13.0-beta.3
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/cjs/components/Select/CustomOption.js +31 -0
- package/dist/cjs/components/Select/Options.js +15 -10
- package/dist/cjs/components/Select/index.js +3 -1
- package/dist/esm/components/Select/CustomOption.js +29 -0
- package/dist/esm/components/Select/Options.js +16 -11
- package/dist/esm/components/Select/index.js +3 -1
- package/dist/types/components/Select/CustomOption.d.ts +3 -0
- package/dist/types/components/Select/Options.d.ts +1 -1
- package/dist/types/components/Select/index.d.ts +2 -1
- package/dist/types/components/Select/types.d.ts +5 -1
- package/package.json +2 -2
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var React = require('react');
|
|
4
|
+
var context = require('./context.js');
|
|
5
|
+
var cortexCore = require('@tecsinapse/cortex-core');
|
|
6
|
+
|
|
7
|
+
const SelectCustomOption = ({
|
|
8
|
+
option,
|
|
9
|
+
onSelectOption,
|
|
10
|
+
grouped = false,
|
|
11
|
+
children
|
|
12
|
+
}) => {
|
|
13
|
+
const { keyExtractor, value } = React.useContext(context.SelectContext);
|
|
14
|
+
return /* @__PURE__ */ React.createElement(
|
|
15
|
+
"li",
|
|
16
|
+
{
|
|
17
|
+
onClick: (e) => {
|
|
18
|
+
e.preventDefault();
|
|
19
|
+
onSelectOption(option);
|
|
20
|
+
},
|
|
21
|
+
className: cortexCore.option({
|
|
22
|
+
selected: value && keyExtractor(value) === keyExtractor(option),
|
|
23
|
+
grouped
|
|
24
|
+
}),
|
|
25
|
+
role: "option"
|
|
26
|
+
},
|
|
27
|
+
children
|
|
28
|
+
);
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
exports.SelectCustomOption = SelectCustomOption;
|
|
@@ -18,26 +18,31 @@ var context = require('./context.js');
|
|
|
18
18
|
const { list } = cortexCore.selectVariants();
|
|
19
19
|
const SelectOptions = ({
|
|
20
20
|
onSelect,
|
|
21
|
-
options
|
|
21
|
+
options,
|
|
22
|
+
children
|
|
22
23
|
}) => {
|
|
23
24
|
const { keyExtractor } = React.useContext(context.SelectContext);
|
|
24
25
|
const { setIsOpen } = Context.usePopoverContext();
|
|
25
26
|
const { options: _options, isLoading } = useSelectOptions.useSelectOptions({ options });
|
|
26
27
|
const handleSelect = React.useCallback(
|
|
27
28
|
(option) => {
|
|
28
|
-
onSelect(option);
|
|
29
|
+
onSelect?.(option);
|
|
29
30
|
setIsOpen?.(false);
|
|
30
31
|
},
|
|
31
32
|
[onSelect]
|
|
32
33
|
);
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
34
|
+
const defaultOptions = React.useMemo(
|
|
35
|
+
() => _options?.map((option) => /* @__PURE__ */ React.createElement(
|
|
36
|
+
Option.SelectOption,
|
|
37
|
+
{
|
|
38
|
+
option,
|
|
39
|
+
key: keyExtractor(option),
|
|
40
|
+
onSelectOption: handleSelect
|
|
41
|
+
}
|
|
42
|
+
)) ?? [],
|
|
43
|
+
[_options, keyExtractor, handleSelect]
|
|
44
|
+
);
|
|
45
|
+
return isLoading ? /* @__PURE__ */ React.createElement(SkeletonOptions.SkeletonOptions, null) : /* @__PURE__ */ React.createElement("ul", { role: "select", className: list() }, children ?? defaultOptions);
|
|
41
46
|
};
|
|
42
47
|
|
|
43
48
|
exports.SelectOptions = SelectOptions;
|
|
@@ -10,6 +10,7 @@ var Options = require('./Options.js');
|
|
|
10
10
|
var Popover = require('./Popover.js');
|
|
11
11
|
var Root = require('./Root.js');
|
|
12
12
|
var Trigger = require('./Trigger.js');
|
|
13
|
+
var CustomOption = require('./CustomOption.js');
|
|
13
14
|
|
|
14
15
|
const Select = {
|
|
15
16
|
Root: Root.SelectRoot,
|
|
@@ -21,7 +22,8 @@ const Select = {
|
|
|
21
22
|
MultiOptions: MultiOptions.SelectMultiOptions,
|
|
22
23
|
MultiGroupedOptions: MultiGroupedOptions.SelectMultiGroupedOptions,
|
|
23
24
|
MultiOption: MultiOption.SelectMultiOption,
|
|
24
|
-
MultiCheckAllOptions: MultiCheckAllOptions.SelectMultiCheckAllOptions
|
|
25
|
+
MultiCheckAllOptions: MultiCheckAllOptions.SelectMultiCheckAllOptions,
|
|
26
|
+
CustomOption: CustomOption.SelectCustomOption
|
|
25
27
|
};
|
|
26
28
|
|
|
27
29
|
exports.Select = Select;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import React__default, { useContext } from 'react';
|
|
2
|
+
import { SelectContext } from './context.js';
|
|
3
|
+
import { option } from '@tecsinapse/cortex-core';
|
|
4
|
+
|
|
5
|
+
const SelectCustomOption = ({
|
|
6
|
+
option: option$1,
|
|
7
|
+
onSelectOption,
|
|
8
|
+
grouped = false,
|
|
9
|
+
children
|
|
10
|
+
}) => {
|
|
11
|
+
const { keyExtractor, value } = useContext(SelectContext);
|
|
12
|
+
return /* @__PURE__ */ React__default.createElement(
|
|
13
|
+
"li",
|
|
14
|
+
{
|
|
15
|
+
onClick: (e) => {
|
|
16
|
+
e.preventDefault();
|
|
17
|
+
onSelectOption(option$1);
|
|
18
|
+
},
|
|
19
|
+
className: option({
|
|
20
|
+
selected: value && keyExtractor(value) === keyExtractor(option$1),
|
|
21
|
+
grouped
|
|
22
|
+
}),
|
|
23
|
+
role: "option"
|
|
24
|
+
},
|
|
25
|
+
children
|
|
26
|
+
);
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export { SelectCustomOption };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { selectVariants } from '@tecsinapse/cortex-core';
|
|
2
|
-
import React__default, { useContext, useCallback } from 'react';
|
|
2
|
+
import React__default, { useContext, useCallback, useMemo } from 'react';
|
|
3
3
|
import '@internationalized/date';
|
|
4
4
|
import 'react-aria';
|
|
5
5
|
import 'react-stately';
|
|
@@ -16,26 +16,31 @@ import { SelectContext } from './context.js';
|
|
|
16
16
|
const { list } = selectVariants();
|
|
17
17
|
const SelectOptions = ({
|
|
18
18
|
onSelect,
|
|
19
|
-
options
|
|
19
|
+
options,
|
|
20
|
+
children
|
|
20
21
|
}) => {
|
|
21
22
|
const { keyExtractor } = useContext(SelectContext);
|
|
22
23
|
const { setIsOpen } = usePopoverContext();
|
|
23
24
|
const { options: _options, isLoading } = useSelectOptions({ options });
|
|
24
25
|
const handleSelect = useCallback(
|
|
25
26
|
(option) => {
|
|
26
|
-
onSelect(option);
|
|
27
|
+
onSelect?.(option);
|
|
27
28
|
setIsOpen?.(false);
|
|
28
29
|
},
|
|
29
30
|
[onSelect]
|
|
30
31
|
);
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
32
|
+
const defaultOptions = useMemo(
|
|
33
|
+
() => _options?.map((option) => /* @__PURE__ */ React__default.createElement(
|
|
34
|
+
SelectOption,
|
|
35
|
+
{
|
|
36
|
+
option,
|
|
37
|
+
key: keyExtractor(option),
|
|
38
|
+
onSelectOption: handleSelect
|
|
39
|
+
}
|
|
40
|
+
)) ?? [],
|
|
41
|
+
[_options, keyExtractor, handleSelect]
|
|
42
|
+
);
|
|
43
|
+
return isLoading ? /* @__PURE__ */ React__default.createElement(SkeletonOptions, null) : /* @__PURE__ */ React__default.createElement("ul", { role: "select", className: list() }, children ?? defaultOptions);
|
|
39
44
|
};
|
|
40
45
|
|
|
41
46
|
export { SelectOptions };
|
|
@@ -8,6 +8,7 @@ import { SelectOptions } from './Options.js';
|
|
|
8
8
|
import { SelectPopover } from './Popover.js';
|
|
9
9
|
import { SelectRoot } from './Root.js';
|
|
10
10
|
import { SelectTrigger } from './Trigger.js';
|
|
11
|
+
import { SelectCustomOption } from './CustomOption.js';
|
|
11
12
|
|
|
12
13
|
const Select = {
|
|
13
14
|
Root: SelectRoot,
|
|
@@ -19,7 +20,8 @@ const Select = {
|
|
|
19
20
|
MultiOptions: SelectMultiOptions,
|
|
20
21
|
MultiGroupedOptions: SelectMultiGroupedOptions,
|
|
21
22
|
MultiOption: SelectMultiOption,
|
|
22
|
-
MultiCheckAllOptions: SelectMultiCheckAllOptions
|
|
23
|
+
MultiCheckAllOptions: SelectMultiCheckAllOptions,
|
|
24
|
+
CustomOption: SelectCustomOption
|
|
23
25
|
};
|
|
24
26
|
|
|
25
27
|
export { Select };
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { SelectOptionsProps } from './types';
|
|
3
|
-
export declare const SelectOptions: <T>({ onSelect, options, }: SelectOptionsProps<T>) => React.JSX.Element;
|
|
3
|
+
export declare const SelectOptions: <T>({ onSelect, options, children, }: SelectOptionsProps<T>) => React.JSX.Element;
|
|
@@ -2,12 +2,13 @@ export declare const Select: {
|
|
|
2
2
|
Root: <T>({ children, value, keyExtractor, labelExtractor, className, }: import("./types").SelectRootProps<T>) => import("react").JSX.Element;
|
|
3
3
|
Trigger: ({ label, placeholder, disabled, multiLabelSelected, ...rest }: import("./types").SelectTriggerProps) => import("react").JSX.Element;
|
|
4
4
|
Popover: ({ children }: import("./types").SelectPopoverProps) => import("react").JSX.Element;
|
|
5
|
-
Options: <T>({ onSelect, options, }: import("./types").SelectOptionsProps<T>) => import("react").JSX.Element;
|
|
5
|
+
Options: <T>({ onSelect, options, children, }: import("./types").SelectOptionsProps<T>) => import("react").JSX.Element;
|
|
6
6
|
GroupedOptions: <T>({ onSelect, groupedLabelExtractor, options, }: import("./types").SelectGroupedOptionsProps<T>) => import("react").JSX.Element;
|
|
7
7
|
Option: <T>({ onSelectOption, option, grouped, }: import("./types").SelectOptionProps<T>) => import("react").JSX.Element;
|
|
8
8
|
MultiOptions: <T>({ onSelect, options, children, }: import("./types").SelectMultiOptionsProps<T>) => import("react").JSX.Element;
|
|
9
9
|
MultiGroupedOptions: <T>({ onSelect, groupedLabelExtractor, options, children, }: import("./types").SelectMultiGroupedOptionsProps<T>) => import("react").JSX.Element;
|
|
10
10
|
MultiOption: <T>({ onSelectOption, option, grouped, }: import("./types").SelectMultiOptionProps<T>) => import("react").JSX.Element;
|
|
11
11
|
MultiCheckAllOptions: <T>({ checkAllLabel, }: import("./types").SelectMultiCheckAllOptionsProps) => import("react").JSX.Element;
|
|
12
|
+
CustomOption: <T>({ option, onSelectOption, grouped, children, }: import("./types").CustomOptionProps<T>) => import("react").JSX.Element;
|
|
12
13
|
};
|
|
13
14
|
export * from './types';
|
|
@@ -32,9 +32,13 @@ export interface SelectOptionProps<T> {
|
|
|
32
32
|
onSelectOption: (option: T) => void;
|
|
33
33
|
grouped?: boolean;
|
|
34
34
|
}
|
|
35
|
+
export interface CustomOptionProps<T> extends SelectOptionProps<T> {
|
|
36
|
+
children?: ReactNode;
|
|
37
|
+
}
|
|
35
38
|
export interface SelectOptionsProps<T> {
|
|
36
39
|
options?: T[] | (() => Promise<T[]>);
|
|
37
|
-
onSelect
|
|
40
|
+
onSelect?: (value: T) => void;
|
|
41
|
+
children?: ReactNode;
|
|
38
42
|
}
|
|
39
43
|
export interface SelectPopoverProps {
|
|
40
44
|
children: ReactNode;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tecsinapse/cortex-react",
|
|
3
|
-
"version": "1.13.0-beta.
|
|
3
|
+
"version": "1.13.0-beta.3",
|
|
4
4
|
"description": "React components based in @tecsinapse/cortex-core",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "dist/esm/index.js",
|
|
@@ -47,5 +47,5 @@
|
|
|
47
47
|
"react-icons": ">=5.2.0",
|
|
48
48
|
"tailwind": ">=3.3.0"
|
|
49
49
|
},
|
|
50
|
-
"gitHead": "
|
|
50
|
+
"gitHead": "75b36ad4ff1d3db75ca3bde576583870440b53ea"
|
|
51
51
|
}
|