@tecsinapse/cortex-react 1.13.0-beta.3 → 1.13.0

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.
@@ -18,31 +18,26 @@ var context = require('./context.js');
18
18
  const { list } = cortexCore.selectVariants();
19
19
  const SelectOptions = ({
20
20
  onSelect,
21
- options,
22
- children
21
+ options
23
22
  }) => {
24
23
  const { keyExtractor } = React.useContext(context.SelectContext);
25
24
  const { setIsOpen } = Context.usePopoverContext();
26
25
  const { options: _options, isLoading } = useSelectOptions.useSelectOptions({ options });
27
26
  const handleSelect = React.useCallback(
28
27
  (option) => {
29
- onSelect?.(option);
28
+ onSelect(option);
30
29
  setIsOpen?.(false);
31
30
  },
32
31
  [onSelect]
33
32
  );
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);
33
+ return isLoading ? /* @__PURE__ */ React.createElement(SkeletonOptions.SkeletonOptions, null) : /* @__PURE__ */ React.createElement("ul", { role: "select", className: list() }, _options?.map((option) => /* @__PURE__ */ React.createElement(
34
+ Option.SelectOption,
35
+ {
36
+ option,
37
+ key: keyExtractor(option),
38
+ onSelectOption: handleSelect
39
+ }
40
+ )));
46
41
  };
47
42
 
48
43
  exports.SelectOptions = SelectOptions;
@@ -10,7 +10,6 @@ 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');
14
13
 
15
14
  const Select = {
16
15
  Root: Root.SelectRoot,
@@ -22,8 +21,7 @@ const Select = {
22
21
  MultiOptions: MultiOptions.SelectMultiOptions,
23
22
  MultiGroupedOptions: MultiGroupedOptions.SelectMultiGroupedOptions,
24
23
  MultiOption: MultiOption.SelectMultiOption,
25
- MultiCheckAllOptions: MultiCheckAllOptions.SelectMultiCheckAllOptions,
26
- CustomOption: CustomOption.SelectCustomOption
24
+ MultiCheckAllOptions: MultiCheckAllOptions.SelectMultiCheckAllOptions
27
25
  };
28
26
 
29
27
  exports.Select = Select;
@@ -1,5 +1,5 @@
1
1
  import { selectVariants } from '@tecsinapse/cortex-core';
2
- import React__default, { useContext, useCallback, useMemo } from 'react';
2
+ import React__default, { useContext, useCallback } from 'react';
3
3
  import '@internationalized/date';
4
4
  import 'react-aria';
5
5
  import 'react-stately';
@@ -16,31 +16,26 @@ import { SelectContext } from './context.js';
16
16
  const { list } = selectVariants();
17
17
  const SelectOptions = ({
18
18
  onSelect,
19
- options,
20
- children
19
+ options
21
20
  }) => {
22
21
  const { keyExtractor } = useContext(SelectContext);
23
22
  const { setIsOpen } = usePopoverContext();
24
23
  const { options: _options, isLoading } = useSelectOptions({ options });
25
24
  const handleSelect = useCallback(
26
25
  (option) => {
27
- onSelect?.(option);
26
+ onSelect(option);
28
27
  setIsOpen?.(false);
29
28
  },
30
29
  [onSelect]
31
30
  );
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);
31
+ return isLoading ? /* @__PURE__ */ React__default.createElement(SkeletonOptions, null) : /* @__PURE__ */ React__default.createElement("ul", { role: "select", className: list() }, _options?.map((option) => /* @__PURE__ */ React__default.createElement(
32
+ SelectOption,
33
+ {
34
+ option,
35
+ key: keyExtractor(option),
36
+ onSelectOption: handleSelect
37
+ }
38
+ )));
44
39
  };
45
40
 
46
41
  export { SelectOptions };
@@ -8,7 +8,6 @@ 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';
12
11
 
13
12
  const Select = {
14
13
  Root: SelectRoot,
@@ -20,8 +19,7 @@ const Select = {
20
19
  MultiOptions: SelectMultiOptions,
21
20
  MultiGroupedOptions: SelectMultiGroupedOptions,
22
21
  MultiOption: SelectMultiOption,
23
- MultiCheckAllOptions: SelectMultiCheckAllOptions,
24
- CustomOption: SelectCustomOption
22
+ MultiCheckAllOptions: SelectMultiCheckAllOptions
25
23
  };
26
24
 
27
25
  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, children, }: SelectOptionsProps<T>) => React.JSX.Element;
3
+ export declare const SelectOptions: <T>({ onSelect, options, }: SelectOptionsProps<T>) => React.JSX.Element;
@@ -2,13 +2,12 @@ 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, children, }: import("./types").SelectOptionsProps<T>) => import("react").JSX.Element;
5
+ Options: <T>({ onSelect, options, }: 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;
13
12
  };
14
13
  export * from './types';
@@ -32,13 +32,9 @@ 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
- }
38
35
  export interface SelectOptionsProps<T> {
39
36
  options?: T[] | (() => Promise<T[]>);
40
- onSelect?: (value: T) => void;
41
- children?: ReactNode;
37
+ onSelect: (value: T) => void;
42
38
  }
43
39
  export interface SelectPopoverProps {
44
40
  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",
3
+ "version": "1.13.0",
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": "75b36ad4ff1d3db75ca3bde576583870440b53ea"
50
+ "gitHead": "2161799fe52315370cbe2b5b10e2245c232a5ee1"
51
51
  }
@@ -1,31 +0,0 @@
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;
@@ -1,29 +0,0 @@
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,3 +0,0 @@
1
- import React from 'react';
2
- import { CustomOptionProps } from './types';
3
- export declare const SelectCustomOption: <T>({ option, onSelectOption, grouped, children, }: CustomOptionProps<T>) => React.JSX.Element;