@tecsinapse/cortex-react 2.3.0-beta.0 → 2.3.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.
Files changed (109) hide show
  1. package/dist/cjs/components/Accordion/Root.js +6 -0
  2. package/dist/cjs/components/Accordion/Trigger.js +33 -13
  3. package/dist/cjs/components/Autocomplete/GroupedOptions.js +42 -0
  4. package/dist/cjs/components/Autocomplete/Option.js +40 -0
  5. package/dist/cjs/components/Autocomplete/Options.js +36 -0
  6. package/dist/cjs/components/Autocomplete/Popover.js +34 -0
  7. package/dist/cjs/components/Autocomplete/Root.js +40 -0
  8. package/dist/cjs/components/Autocomplete/Trigger.js +47 -0
  9. package/dist/cjs/components/Autocomplete/context.js +7 -0
  10. package/dist/cjs/components/Autocomplete/index.js +19 -0
  11. package/dist/cjs/components/Avatar.js +1 -1
  12. package/dist/cjs/components/Breadcrumbs/BreadcrumbItem.js +1 -1
  13. package/dist/cjs/components/Calendar/CalendarGrid.js +1 -1
  14. package/dist/cjs/components/ColorPicker.js +9 -18
  15. package/dist/cjs/components/Kanban.js +1 -1
  16. package/dist/cjs/components/PhoneInput/Option.js +2 -2
  17. package/dist/cjs/components/PhoneInput/Options.js +3 -0
  18. package/dist/cjs/components/PhoneInput/Popover.js +1 -1
  19. package/dist/cjs/components/PhoneInput/Trigger.js +3 -0
  20. package/dist/cjs/components/Popover/Content.js +1 -1
  21. package/dist/cjs/components/ScrollableDigitSelector.js +1 -1
  22. package/dist/cjs/components/Select/Popover.js +1 -1
  23. package/dist/cjs/components/Skeleton.js +1 -1
  24. package/dist/cjs/components/Stepper/Root.js +1 -1
  25. package/dist/cjs/components/TimePicker/TimePickerInput.js +1 -1
  26. package/dist/cjs/components/TimePicker/TimePickerSelector.js +2 -2
  27. package/dist/cjs/components/Uploader/Dropzone.js +3 -3
  28. package/dist/cjs/components/Uploader/Files.js +2 -2
  29. package/dist/cjs/components/Uploader/Manager.js +2 -2
  30. package/dist/cjs/components/Uploader/Modal.js +1 -1
  31. package/dist/cjs/components/Uploader/Upload.js +2 -2
  32. package/dist/cjs/hooks/useAutocompleteGroupedOptions.js +35 -0
  33. package/dist/cjs/hooks/useAutocompleteOptions.js +35 -0
  34. package/dist/cjs/hooks/useFileUpload.js +3 -3
  35. package/dist/cjs/index.js +4 -2
  36. package/dist/cjs/provider/ManagerContext.js +3 -0
  37. package/dist/cjs/styles/calendar-cell.js +5 -5
  38. package/dist/cjs/styles/date-picker-input-base.js +1 -1
  39. package/dist/cjs/styles/date-segment.js +2 -2
  40. package/dist/cjs/styles/groupButton.js +3 -3
  41. package/dist/cjs/styles/menubar.js +8 -8
  42. package/dist/cjs/styles/progressBar.js +1 -1
  43. package/dist/cjs/styles/stepNodeVariants.js +2 -2
  44. package/dist/cjs/styles/time-field-input.js +1 -1
  45. package/dist/esm/components/Accordion/Root.js +6 -0
  46. package/dist/esm/components/Accordion/Trigger.js +33 -13
  47. package/dist/esm/components/Autocomplete/GroupedOptions.js +40 -0
  48. package/dist/esm/components/Autocomplete/Option.js +38 -0
  49. package/dist/esm/components/Autocomplete/Options.js +34 -0
  50. package/dist/esm/components/Autocomplete/Popover.js +32 -0
  51. package/dist/esm/components/Autocomplete/Root.js +38 -0
  52. package/dist/esm/components/Autocomplete/Trigger.js +45 -0
  53. package/dist/esm/components/Autocomplete/context.js +5 -0
  54. package/dist/esm/components/Autocomplete/index.js +17 -0
  55. package/dist/esm/components/Avatar.js +1 -1
  56. package/dist/esm/components/Breadcrumbs/BreadcrumbItem.js +1 -1
  57. package/dist/esm/components/Calendar/CalendarGrid.js +1 -1
  58. package/dist/esm/components/ColorPicker.js +9 -18
  59. package/dist/esm/components/Kanban.js +1 -1
  60. package/dist/esm/components/PhoneInput/Option.js +2 -2
  61. package/dist/esm/components/PhoneInput/Options.js +3 -0
  62. package/dist/esm/components/PhoneInput/Popover.js +1 -1
  63. package/dist/esm/components/PhoneInput/Trigger.js +3 -0
  64. package/dist/esm/components/Popover/Content.js +1 -1
  65. package/dist/esm/components/ScrollableDigitSelector.js +1 -1
  66. package/dist/esm/components/Select/Popover.js +1 -1
  67. package/dist/esm/components/Skeleton.js +1 -1
  68. package/dist/esm/components/Stepper/Root.js +1 -1
  69. package/dist/esm/components/TimePicker/TimePickerInput.js +1 -1
  70. package/dist/esm/components/TimePicker/TimePickerSelector.js +2 -2
  71. package/dist/esm/components/Uploader/Dropzone.js +3 -3
  72. package/dist/esm/components/Uploader/Files.js +2 -2
  73. package/dist/esm/components/Uploader/Manager.js +2 -2
  74. package/dist/esm/components/Uploader/Modal.js +1 -1
  75. package/dist/esm/components/Uploader/Upload.js +2 -2
  76. package/dist/esm/hooks/useAutocompleteGroupedOptions.js +33 -0
  77. package/dist/esm/hooks/useAutocompleteOptions.js +33 -0
  78. package/dist/esm/hooks/useFileUpload.js +3 -3
  79. package/dist/esm/index.js +1 -0
  80. package/dist/esm/provider/ManagerContext.js +3 -0
  81. package/dist/esm/styles/calendar-cell.js +5 -5
  82. package/dist/esm/styles/date-picker-input-base.js +1 -1
  83. package/dist/esm/styles/date-segment.js +2 -2
  84. package/dist/esm/styles/groupButton.js +3 -3
  85. package/dist/esm/styles/menubar.js +8 -8
  86. package/dist/esm/styles/progressBar.js +1 -1
  87. package/dist/esm/styles/stepNodeVariants.js +2 -2
  88. package/dist/esm/styles/time-field-input.js +1 -1
  89. package/dist/types/components/Accordion/Root.d.ts +1 -1
  90. package/dist/types/components/Accordion/Trigger.d.ts +1 -1
  91. package/dist/types/components/Accordion/index.d.ts +2 -2
  92. package/dist/types/components/Accordion/types.d.ts +3 -0
  93. package/dist/types/components/Autocomplete/GroupedOptions.d.ts +2 -0
  94. package/dist/types/components/Autocomplete/Option.d.ts +2 -0
  95. package/dist/types/components/Autocomplete/Options.d.ts +2 -0
  96. package/dist/types/components/Autocomplete/Popover.d.ts +2 -0
  97. package/dist/types/components/Autocomplete/Root.d.ts +2 -0
  98. package/dist/types/components/Autocomplete/Trigger.d.ts +2 -0
  99. package/dist/types/components/Autocomplete/context.d.ts +10 -0
  100. package/dist/types/components/Autocomplete/index.d.ts +9 -0
  101. package/dist/types/components/Autocomplete/types.d.ts +50 -0
  102. package/dist/types/components/Uploader/Manager.d.ts +1 -1
  103. package/dist/types/components/Uploader/index.d.ts +1 -1
  104. package/dist/types/components/Uploader/types.d.ts +1 -1
  105. package/dist/types/components/index.d.ts +1 -0
  106. package/dist/types/hooks/useAutocompleteGroupedOptions.d.ts +9 -0
  107. package/dist/types/hooks/useAutocompleteOptions.d.ts +9 -0
  108. package/dist/types/hooks/useFileUpload.d.ts +2 -2
  109. package/package.json +3 -3
@@ -15,7 +15,7 @@ const Manager = ({
15
15
  files,
16
16
  onDelete,
17
17
  uploadProgressText = "Upload(s) in progress",
18
- uploadSuccessText = "Upload(s) completed",
18
+ uploadResultText = "Upload(s) completed",
19
19
  onClose
20
20
  }) => {
21
21
  const {
@@ -47,7 +47,7 @@ const Manager = ({
47
47
  children: min ? /* @__PURE__ */ jsxRuntime.jsx(io5.IoChevronUp, {}) : /* @__PURE__ */ jsxRuntime.jsx(io5.IoChevronDown, {})
48
48
  }
49
49
  ),
50
- /* @__PURE__ */ jsxRuntime.jsx("h3", { "data-testid": "upload-progress", className: "font-bold text-h4", children: isLoading ? uploadProgressText : uploadSuccessText }),
50
+ /* @__PURE__ */ jsxRuntime.jsx("h3", { "data-testid": "upload-progress", children: isLoading ? uploadProgressText : uploadResultText }),
51
51
  /* @__PURE__ */ jsxRuntime.jsx(
52
52
  Button.Button,
53
53
  {
@@ -18,7 +18,7 @@ const Modal = ({
18
18
  {
19
19
  open,
20
20
  onClose,
21
- className: "flex flex-col bg-surface-base rounded-mili min-w-[70vw] max-w-[95vh] max-h-[95vh] overflow-auto text-default",
21
+ className: "flex flex-col bg-secondary-xlight rounded-mili min-w-[70vw] max-w-[95vh] max-h-[95vh] overflow-auto",
22
22
  children: [
23
23
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex w-full items-center justify-between mb-deca", children: [
24
24
  /* @__PURE__ */ jsxRuntime.jsx("h2", { className: "text-deca font-semibold ml-tera flex-1 text-center", children: title }),
@@ -105,8 +105,8 @@ const Folder = ({ name, subItems }) => {
105
105
  );
106
106
  const intent = React.useMemo(() => {
107
107
  if (loading) return "info";
108
- if ((subItems ?? []).some((item) => item.status === "error") && (subItems ?? []).some((item) => item.status === "success")) {
109
- return "warning";
108
+ if ((subItems ?? []).some((item) => item.status === "error")) {
109
+ return "error";
110
110
  }
111
111
  return "success";
112
112
  }, [subItems]);
@@ -0,0 +1,35 @@
1
+ 'use strict';
2
+
3
+ var React = require('react');
4
+
5
+ const useAutocompleteGroupedOptions = ({
6
+ options: _options
7
+ }) => {
8
+ const [options, setOptions] = React.useState();
9
+ const [isLoading, setIsLoading] = React.useState();
10
+ const [error, setError] = React.useState();
11
+ const initData = async (fetch) => {
12
+ setIsLoading(true);
13
+ try {
14
+ const result = await fetch();
15
+ if (result) {
16
+ setOptions(result ?? []);
17
+ }
18
+ } catch (e) {
19
+ setError(String(e));
20
+ } finally {
21
+ setIsLoading(false);
22
+ }
23
+ };
24
+ React.useEffect(() => {
25
+ if (typeof _options === "function") initData(_options);
26
+ else setOptions(_options);
27
+ }, [_options]);
28
+ return {
29
+ isLoading,
30
+ options,
31
+ error
32
+ };
33
+ };
34
+
35
+ exports.useAutocompleteGroupedOptions = useAutocompleteGroupedOptions;
@@ -0,0 +1,35 @@
1
+ 'use strict';
2
+
3
+ var React = require('react');
4
+
5
+ const useAutocompleteOptions = ({
6
+ options: _options
7
+ }) => {
8
+ const [options, setOptions] = React.useState();
9
+ const [isLoading, setIsLoading] = React.useState();
10
+ const [error, setError] = React.useState();
11
+ const initData = React.useCallback(async (fetch) => {
12
+ setIsLoading(true);
13
+ try {
14
+ const result = await fetch();
15
+ if (result) {
16
+ setOptions(result ?? []);
17
+ }
18
+ } catch (e) {
19
+ setError(String(e));
20
+ } finally {
21
+ setIsLoading(false);
22
+ }
23
+ }, []);
24
+ React.useEffect(() => {
25
+ if (typeof _options === "function") initData(_options);
26
+ else setOptions(_options);
27
+ }, [_options]);
28
+ return {
29
+ isLoading,
30
+ options,
31
+ error
32
+ };
33
+ };
34
+
35
+ exports.useAutocompleteOptions = useAutocompleteOptions;
@@ -30,7 +30,7 @@ const useFileUpload = ({
30
30
  noClick = false,
31
31
  ignoreRejections = false,
32
32
  uploadProgressText,
33
- uploadSuccessText
33
+ uploadResultText
34
34
  }) => {
35
35
  const {
36
36
  showManager,
@@ -100,10 +100,10 @@ const useFileUpload = ({
100
100
  onClose: closeManager,
101
101
  onDelete: handleRemoveFile,
102
102
  uploadProgressText,
103
- uploadSuccessText
103
+ uploadResultText
104
104
  });
105
105
  }
106
- }, [handleRemoveFile, closeManager]);
106
+ }, [handleRemoveFile, closeManager, uploadResultText]);
107
107
  const addMimeTypes = (key, acc) => {
108
108
  types.AcceptSpecificMap[key].forEach((mimeType) => {
109
109
  acc[mimeType] = [];
package/dist/cjs/index.js CHANGED
@@ -44,7 +44,8 @@ var TimeFieldInput = require('./components/TimePicker/TimeFieldInput.js');
44
44
  var Toggle = require('./components/Toggle.js');
45
45
  var Tooltip = require('./components/Tooltip.js');
46
46
  var index$7 = require('./components/Uploader/index.js');
47
- var index$8 = require('./components/PhoneInput/index.js');
47
+ var index$8 = require('./components/Autocomplete/index.js');
48
+ var index$9 = require('./components/PhoneInput/index.js');
48
49
  var useCalendar = require('./hooks/useCalendar.js');
49
50
  var useCalendarCell = require('./hooks/useCalendarCell.js');
50
51
  var useCalendarGrid = require('./hooks/useCalendarGrid.js');
@@ -128,7 +129,8 @@ exports.TimeFieldInput = TimeFieldInput.TimeFieldInput;
128
129
  exports.Toggle = Toggle.Toggle;
129
130
  exports.Tooltip = Tooltip.Tooltip;
130
131
  exports.Uploader = index$7.Uploader;
131
- exports.PhoneInput = index$8.PhoneInput;
132
+ exports.Autocomplete = index$8.Autocomplete;
133
+ exports.PhoneInput = index$9.PhoneInput;
132
134
  exports.useCalendar = useCalendar.useCalendar;
133
135
  exports.useCalendarCell = useCalendarCell.useCalendarCell;
134
136
  exports.useCalendarGrid = useCalendarGrid.useCalendarGrid;
@@ -66,6 +66,9 @@ require('../components/Tooltip.js');
66
66
  require('react-icons/hi2');
67
67
  require('react-icons/fa6');
68
68
  require('react-dom');
69
+ require('../components/Autocomplete/context.js');
70
+ require('../components/Autocomplete/Options.js');
71
+ require('../components/Autocomplete/GroupedOptions.js');
69
72
  require('../components/PhoneInput/Options.js');
70
73
  require('../components/PhoneInput/context.js');
71
74
  require('react-international-phone');
@@ -4,7 +4,7 @@ var tailwindVariants = require('tailwind-variants');
4
4
 
5
5
  const calendarCell = tailwindVariants.tv({
6
6
  slots: {
7
- cell: "text-center rounded-mili hover:bg-primary-light",
7
+ cell: "text-center rounded-mili text-black hover:bg-primary-light",
8
8
  button: "flex aspect-square items-center justify-center"
9
9
  },
10
10
  variants: {
@@ -15,17 +15,17 @@ const calendarCell = tailwindVariants.tv({
15
15
  },
16
16
  isSelected: {
17
17
  true: {
18
- cell: "bg-primary-medium border-2 border-primary-medium text-white hover:bg-primary-medium"
18
+ cell: "bg-primary-medium border-2 border-primary-medium text-on-primary hover:bg-primary-medium"
19
19
  }
20
20
  },
21
21
  isSelectionStart: {
22
22
  true: {
23
- cell: "bg-primary-medium border-2 border-primary-medium rounded-r-none text-white"
23
+ cell: "bg-primary-medium border-2 border-primary-medium rounded-r-none text-on-primary"
24
24
  }
25
25
  },
26
26
  isSelectionEnd: {
27
27
  true: {
28
- cell: "bg-primary-medium border-2 border-primary-medium rounded-l-none text-white"
28
+ cell: "bg-primary-medium border-2 border-primary-medium rounded-l-none text-on-primary"
29
29
  }
30
30
  },
31
31
  inRange: {
@@ -35,7 +35,7 @@ const calendarCell = tailwindVariants.tv({
35
35
  },
36
36
  isDisabled: {
37
37
  true: {
38
- cell: "text-content-minimal cursor-default hover:bg-surface-overlay",
38
+ cell: "text-secondary-light cursor-default hover:bg-white-500",
39
39
  button: "cursor-default"
40
40
  }
41
41
  }
@@ -9,7 +9,7 @@ const datePickerInputBase = tailwindVariants.tv({
9
9
  variants: {
10
10
  disabled: {
11
11
  true: {
12
- icon: "text-content-minimal cursor-default"
12
+ icon: "text-secondary-light cursor-default"
13
13
  }
14
14
  }
15
15
  }
@@ -4,12 +4,12 @@ var tailwindVariants = require('tailwind-variants');
4
4
 
5
5
  const dateSegment = tailwindVariants.tv({
6
6
  slots: {
7
- base: "focus:outline-none focus:bg-content-minimal"
7
+ base: "focus:outline-none focus:bg-secondary-light"
8
8
  },
9
9
  variants: {
10
10
  disabled: {
11
11
  true: {
12
- base: "text-content-minimal"
12
+ base: "text-secondary-light"
13
13
  }
14
14
  }
15
15
  }
@@ -4,12 +4,12 @@ var tailwindVariants = require('tailwind-variants');
4
4
 
5
5
  const groupButton = tailwindVariants.tv({
6
6
  slots: {
7
- button: "border-[1px] border-content-low px-centi py-mili items-center flex text-sub font-bold",
8
- inactive: "bg-surface-overlay text-content-low disabled:bg-content-minimal",
7
+ button: "border-[1px] border-secondary-medium px-centi py-mili items-center flex text-sub font-bold",
8
+ inactive: "bg-white text-secondary-medium disabled:bg-secondary-light",
9
9
  firstButton: "first:rounded-l-mili first:border-r-0",
10
10
  lastButton: "last:rounded-r-mili last:border-l-0",
11
11
  container: "flex flex-row h-[2rem]",
12
- active: "text-white bg-content-low"
12
+ active: "text-white bg-secondary-medium"
13
13
  }
14
14
  });
15
15
 
@@ -4,10 +4,10 @@ var tailwindVariants = require('tailwind-variants');
4
4
 
5
5
  const menubar = tailwindVariants.tv({
6
6
  slots: {
7
- header: "relative w-screen px-kilo py-deca flex flex-row md:justify-between bg-surface-overlay z-header sm:justify-start",
7
+ header: "relative w-screen px-kilo py-deca flex flex-row md:justify-between bg-white z-header sm:justify-start",
8
8
  left: "flex items-center w-fit",
9
9
  right: "flex items-center gap-x-deca hidden sm:flex",
10
- dropdown: "w-full bg-surface-overlay flex-1 shadow-default z-popover px-[8vw] absolute"
10
+ dropdown: "w-full bg-white flex-1 shadow-default z-popover px-[8vw] absolute"
11
11
  },
12
12
  variants: {
13
13
  show: {
@@ -21,7 +21,7 @@ const menubar = tailwindVariants.tv({
21
21
  const mostUsed = tailwindVariants.tv({
22
22
  slots: {
23
23
  container: "mb-kilo",
24
- label: "font-bold mb-centi text-default",
24
+ label: "font-bold mb-centi",
25
25
  containerList: "gap-x-kilo flex flex-row"
26
26
  }
27
27
  });
@@ -29,26 +29,26 @@ const mostUsedItem = tailwindVariants.tv({
29
29
  slots: {
30
30
  container: "flex-1 py-mili",
31
31
  title: "text-primary-medium font-bold text-base",
32
- category: "text-content-low text-label"
32
+ category: "text-secondary-medium text-label"
33
33
  }
34
34
  });
35
35
  const item = tailwindVariants.tv({
36
36
  slots: {
37
- container: "flex flex-row gap-x-deca items-center text-content-medium hover:cursor-pointer text-base",
37
+ container: "flex flex-row gap-x-deca items-center text-secondary-dark hover:cursor-pointer text-base",
38
38
  textBehavior: "hover:text-primary-medium",
39
39
  icon: "text-primary-medium hover:cursor-pointer"
40
40
  }
41
41
  });
42
42
  const category = tailwindVariants.tv({
43
43
  slots: {
44
- text: "mb-mili font-bold text-default",
45
- hr: "mb-mili border-0 h-px bg-content-high",
44
+ text: "mb-mili font-bold",
45
+ hr: "mb-mili border-0 h-px bg-secondary-light",
46
46
  container: "flex flex-col gap-y-mili"
47
47
  }
48
48
  });
49
49
  const subItem = tailwindVariants.tv({
50
50
  slots: {
51
- container: "pl-deca text-sub border-l-[1px] border-primary-medium text-content-medium hover:text-primary-medium cursor-pointer"
51
+ container: "pl-deca text-sub border-l-[1px] border-primary-medium text-secondary-dark hover:text-primary-medium cursor-pointer"
52
52
  }
53
53
  });
54
54
  const animate = tailwindVariants.tv({
@@ -5,7 +5,7 @@ var tailwindVariants = require('tailwind-variants');
5
5
  const ProgressVariants = tailwindVariants.tv({
6
6
  slots: {
7
7
  container: "relative",
8
- bar: "h-1.5 w-full overflow-hidden bg-content-inverse",
8
+ bar: "h-1.5 w-full overflow-hidden bg-secondary-xlight",
9
9
  progress: "w-full h-full rounded-mili"
10
10
  },
11
11
  variants: {
@@ -30,8 +30,8 @@ const StepNodeVariants = tailwindVariants.tv({
30
30
  content: "font-bold"
31
31
  },
32
32
  false: {
33
- content: "text-content-low",
34
- separator: "bg-content-minimal"
33
+ content: "text-secondary-medium",
34
+ separator: "bg-secondary-light"
35
35
  }
36
36
  },
37
37
  selected: {
@@ -9,7 +9,7 @@ const timePickerInputBase = tailwindVariants.tv({
9
9
  variants: {
10
10
  disabled: {
11
11
  true: {
12
- icon: "text-content-minimal cursor-default"
12
+ icon: "text-secondary-light cursor-default"
13
13
  }
14
14
  }
15
15
  }
@@ -8,6 +8,9 @@ const AccordionRoot = ({
8
8
  defaultOpen,
9
9
  label,
10
10
  floating,
11
+ showDivider,
12
+ showArrowBorder,
13
+ arrowPosition,
11
14
  onOpen,
12
15
  invertedArrow,
13
16
  onClose,
@@ -21,6 +24,9 @@ const AccordionRoot = ({
21
24
  floating,
22
25
  onOpen,
23
26
  onClose,
27
+ showDivider,
28
+ showArrowBorder,
29
+ arrowPosition,
24
30
  invertedArrow,
25
31
  direction
26
32
  }
@@ -5,7 +5,11 @@ import { useAccordionContext } from './context.js';
5
5
 
6
6
  const AccordionTrigger = ({
7
7
  label,
8
+ children,
8
9
  floating = false,
10
+ arrowPosition = "left",
11
+ showDivider = true,
12
+ showArrowBorder = true,
9
13
  /**
10
14
  * Only applied to trigger arrow
11
15
  */
@@ -16,9 +20,9 @@ const AccordionTrigger = ({
16
20
  direction = "horizontal"
17
21
  }) => {
18
22
  const { open, toggle } = useAccordionContext();
19
- if (!floating && !label) {
23
+ if (!floating && !label && !children) {
20
24
  throw new Error(
21
- "A label must be specified if the trigger is not floating variant"
25
+ "A label or children must be specified if the trigger is not floating variant"
22
26
  );
23
27
  }
24
28
  const action = () => {
@@ -33,24 +37,40 @@ const AccordionTrigger = ({
33
37
  "div",
34
38
  {
35
39
  className: clsx(
36
- "flex justify-between align-center border-content-minimal cursor-pointer",
40
+ "flex justify-between align-center cursor-pointer",
37
41
  { "mr-deca": floating && direction === "horizontal" },
38
42
  { "mb-deca": floating && direction === "vertical" },
39
- { "border-r flex-col px-mili": direction === "horizontal" },
40
- { "border-b py-mili": direction === "vertical" }
43
+ {
44
+ "border-r border-secondary-light flex-col px-mili": direction === "horizontal"
45
+ },
46
+ {
47
+ "border-b border-secondary-light py-mili": showDivider && direction === "vertical"
48
+ }
41
49
  ),
42
50
  onClick: action,
43
51
  children: [
52
+ !floating && arrowPosition === "right" && /* @__PURE__ */ jsx(
53
+ "span",
54
+ {
55
+ className: clsx({
56
+ "-rotate-180 [writing-mode:vertical-lr]": direction === "horizontal"
57
+ }),
58
+ children: children ?? label
59
+ }
60
+ ),
44
61
  /* @__PURE__ */ jsx(
45
62
  "div",
46
63
  {
47
64
  className: clsx(
48
- "rounded-mili border border-content-minimal flex align-center justify-center p-micro",
65
+ "rounded-mili flex align-center justify-center p-micro",
66
+ {
67
+ "absolute -translate-x-micro translate-y-deca bg-white": floating && direction === "horizontal"
68
+ },
49
69
  {
50
- "absolute -translate-x-micro translate-y-deca bg-surface-overlay": floating && direction === "horizontal"
70
+ "absolute -translate-y-micro translate-x-deca bg-white": floating && direction === "vertical"
51
71
  },
52
72
  {
53
- "absolute -translate-y-micro translate-x-deca bg-surface-overlay": floating && direction === "vertical"
73
+ "border border-secondary-light": showArrowBorder
54
74
  },
55
75
  className
56
76
  ),
@@ -58,7 +78,7 @@ const AccordionTrigger = ({
58
78
  LiaAngleRightSolid,
59
79
  {
60
80
  className: clsx(
61
- "text-content-low transition-transform duration-200",
81
+ "text-secondary-medium transition-transform duration-200",
62
82
  {
63
83
  "rotate-180": invertedArrow ? !open : open
64
84
  }
@@ -68,7 +88,7 @@ const AccordionTrigger = ({
68
88
  LiaAngleDownSolid,
69
89
  {
70
90
  className: clsx(
71
- "text-content-low transition-transform duration-200",
91
+ "text-secondary-medium transition-transform duration-200",
72
92
  {
73
93
  "rotate-180": invertedArrow ? !open : open
74
94
  }
@@ -77,15 +97,15 @@ const AccordionTrigger = ({
77
97
  )
78
98
  }
79
99
  ),
80
- !floating ? /* @__PURE__ */ jsx(
100
+ !floating && arrowPosition === "left" && /* @__PURE__ */ jsx(
81
101
  "span",
82
102
  {
83
103
  className: clsx({
84
104
  "-rotate-180 [writing-mode:vertical-lr]": direction === "horizontal"
85
105
  }),
86
- children: label
106
+ children: children ?? label
87
107
  }
88
- ) : null
108
+ )
89
109
  ]
90
110
  }
91
111
  );
@@ -0,0 +1,40 @@
1
+ import { jsx, jsxs } from 'react/jsx-runtime';
2
+ import { selectVariants } from '@tecsinapse/cortex-core';
3
+ import { useContext } from 'react';
4
+ import { AutocompleteOption } from './Option.js';
5
+ import { useAutocompleteGroupedOptions } from '../../hooks/useAutocompleteGroupedOptions.js';
6
+ import { SkeletonOptions } from '../Select/SkeletonOptions.js';
7
+ import { AutocompleteContext } from './context.js';
8
+
9
+ const { groupedTitle, list } = selectVariants();
10
+ const AutocompleteGroupedOptions = ({
11
+ onSelect,
12
+ groupedLabelExtractor,
13
+ options
14
+ }) => {
15
+ const { options: _options, isLoading } = useAutocompleteGroupedOptions({
16
+ options
17
+ });
18
+ const context = useContext(
19
+ AutocompleteContext
20
+ );
21
+ if (!context)
22
+ throw new Error(
23
+ "AutocompleteGroupedOptions must be used within AutocompleteRoot"
24
+ );
25
+ const { keyExtractor } = context;
26
+ return isLoading ? /* @__PURE__ */ jsx(SkeletonOptions, {}) : /* @__PURE__ */ jsx("ul", { role: "listbox", className: list(), children: [..._options ?? []].map(([key, value]) => /* @__PURE__ */ jsxs("div", { children: [
27
+ /* @__PURE__ */ jsx("span", { className: groupedTitle(), children: groupedLabelExtractor?.(key) }),
28
+ value.map((option) => /* @__PURE__ */ jsx(
29
+ AutocompleteOption,
30
+ {
31
+ grouped: true,
32
+ option,
33
+ onSelect
34
+ },
35
+ keyExtractor(option)
36
+ ))
37
+ ] }, key)) });
38
+ };
39
+
40
+ export { AutocompleteGroupedOptions };
@@ -0,0 +1,38 @@
1
+ import { jsx } from 'react/jsx-runtime';
2
+ import { option } from '@tecsinapse/cortex-core';
3
+ import { useContext, useCallback } from 'react';
4
+ import { AutocompleteContext } from './context.js';
5
+
6
+ const AutocompleteOption = ({
7
+ option: option$1,
8
+ onSelect,
9
+ grouped = false
10
+ }) => {
11
+ const context = useContext(
12
+ AutocompleteContext
13
+ );
14
+ if (!context)
15
+ throw new Error("AutocompleteOptions must be used within AutocompleteRoot");
16
+ const { setOpen, labelExtractor } = context;
17
+ const handleSelect = useCallback(
18
+ (option2) => {
19
+ setOpen(false);
20
+ onSelect?.(option2);
21
+ },
22
+ [onSelect, setOpen]
23
+ );
24
+ return /* @__PURE__ */ jsx(
25
+ "li",
26
+ {
27
+ onClick: () => handleSelect(option$1),
28
+ className: option({
29
+ selected: false,
30
+ grouped
31
+ }),
32
+ role: "option",
33
+ children: /* @__PURE__ */ jsx("span", { className: "truncate flex-1", children: labelExtractor(option$1) })
34
+ }
35
+ );
36
+ };
37
+
38
+ export { AutocompleteOption };
@@ -0,0 +1,34 @@
1
+ import { jsx } from 'react/jsx-runtime';
2
+ import { selectVariants } from '@tecsinapse/cortex-core';
3
+ import { useContext } from 'react';
4
+ import { AutocompleteOption } from './Option.js';
5
+ import { useAutocompleteOptions } from '../../hooks/useAutocompleteOptions.js';
6
+ import { SkeletonOptions } from '../Select/SkeletonOptions.js';
7
+ import { AutocompleteContext } from './context.js';
8
+
9
+ const { list } = selectVariants();
10
+ const AutocompleteOptions = ({
11
+ options,
12
+ onSelect,
13
+ children
14
+ }) => {
15
+ const context = useContext(
16
+ AutocompleteContext
17
+ );
18
+ if (!context)
19
+ throw new Error("AutocompleteOptions must be used within AutocompleteRoot");
20
+ const { keyExtractor } = context;
21
+ const { options: _options, isLoading } = useAutocompleteOptions({
22
+ options
23
+ });
24
+ return isLoading ? /* @__PURE__ */ jsx(SkeletonOptions, {}) : /* @__PURE__ */ jsx("ul", { role: "listbox", className: list(), children: children ?? _options?.map((option) => /* @__PURE__ */ jsx(
25
+ AutocompleteOption,
26
+ {
27
+ option,
28
+ onSelect
29
+ },
30
+ keyExtractor(option)
31
+ )) });
32
+ };
33
+
34
+ export { AutocompleteOptions };
@@ -0,0 +1,32 @@
1
+ import { jsx } from 'react/jsx-runtime';
2
+ import { useContext } from 'react';
3
+ import { FloatingPortal } from '@floating-ui/react';
4
+ import { Popover } from '../Popover/index.js';
5
+ import { AutocompleteContext } from './context.js';
6
+ import clsx from 'clsx';
7
+
8
+ const AutocompletePopover = ({
9
+ children,
10
+ className
11
+ }) => {
12
+ const context = useContext(AutocompleteContext);
13
+ if (!context)
14
+ throw new Error("AutocompletePopover must be used within AutocompleteRoot");
15
+ const { triggerWidth } = context;
16
+ return /* @__PURE__ */ jsx(FloatingPortal, { children: /* @__PURE__ */ jsx(
17
+ Popover.Content,
18
+ {
19
+ className: clsx(
20
+ "bg-white shadow-md rounded-md overflow-y-auto max-h-[30vh] outline-none z-9999",
21
+ className
22
+ ),
23
+ style: {
24
+ width: triggerWidth ? `${triggerWidth}px` : "auto"
25
+ },
26
+ initialFocus: -1,
27
+ children
28
+ }
29
+ ) });
30
+ };
31
+
32
+ export { AutocompletePopover };
@@ -0,0 +1,38 @@
1
+ import { jsx } from 'react/jsx-runtime';
2
+ import { useState } from 'react';
3
+ import { Popover } from '../Popover/index.js';
4
+ import { AutocompleteContext } from './context.js';
5
+
6
+ const AutocompleteRoot = ({
7
+ keyExtractor,
8
+ labelExtractor,
9
+ children
10
+ }) => {
11
+ const [triggerWidth, setTriggerWidth] = useState();
12
+ const [open, setOpen] = useState(false);
13
+ return /* @__PURE__ */ jsx(
14
+ AutocompleteContext.Provider,
15
+ {
16
+ value: {
17
+ open,
18
+ setOpen,
19
+ triggerWidth,
20
+ setTriggerWidth,
21
+ keyExtractor,
22
+ labelExtractor
23
+ },
24
+ children: /* @__PURE__ */ jsx(
25
+ Popover.Root,
26
+ {
27
+ placement: "bottom-start",
28
+ controlled: true,
29
+ isOpen: open,
30
+ setIsOpen: setOpen,
31
+ children: /* @__PURE__ */ jsx("div", { className: "relative w-full h-full", children })
32
+ }
33
+ )
34
+ }
35
+ );
36
+ };
37
+
38
+ export { AutocompleteRoot };