@tecsinapse/cortex-react 1.9.8 → 1.9.9

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.
@@ -10,6 +10,7 @@ const Node = ({
10
10
  isLast = false,
11
11
  segmented = false,
12
12
  selected = false,
13
+ interactive = true,
13
14
  children,
14
15
  className,
15
16
  ...rest
@@ -19,10 +20,11 @@ const Node = ({
19
20
  marked,
20
21
  isFirst,
21
22
  isLast,
22
- selected,
23
- disabled: rest.disabled
23
+ selected: selected && interactive,
24
+ disabled: rest.disabled,
25
+ interactive
24
26
  });
25
- return /* @__PURE__ */ React.createElement("button", { type: "button", className: container({ className }), ...rest }, /* @__PURE__ */ React.createElement("div", { className: content() }, children), segmented ? /* @__PURE__ */ React.createElement("div", { className: separator() }) : /* @__PURE__ */ React.createElement(React.Fragment, null));
27
+ return /* @__PURE__ */ React.createElement("button", { type: "button", className: container({ className }), ...rest }, children ? /* @__PURE__ */ React.createElement("div", { className: content() }, children) : /* @__PURE__ */ React.createElement(React.Fragment, null), segmented ? /* @__PURE__ */ React.createElement("div", { className: separator() }) : /* @__PURE__ */ React.createElement(React.Fragment, null));
26
28
  };
27
29
 
28
30
  exports.Node = Node;
@@ -2,8 +2,14 @@
2
2
 
3
3
  var React = require('react');
4
4
  var Node = require('./Node.js');
5
+ var clsx = require('clsx');
5
6
 
6
- const Root = ({ segmented = false, children }) => {
7
+ const Root = ({
8
+ segmented = false,
9
+ children,
10
+ className = "",
11
+ interactive = true
12
+ }) => {
7
13
  const initialSelectedIndex = React.useMemo(() => {
8
14
  let initialIndex = null;
9
15
  React.Children.forEach(children, (child, index) => {
@@ -20,12 +26,17 @@ const Root = ({ segmented = false, children }) => {
20
26
  () => React.Children.count(children),
21
27
  [children]
22
28
  );
23
- const handleNodeClick = React.useCallback((index, onClick) => {
24
- setSelectedNode(index);
25
- if (onClick) {
26
- onClick();
27
- }
28
- }, []);
29
+ const handleNodeClick = React.useCallback(
30
+ (index, onClick) => {
31
+ if (interactive) {
32
+ setSelectedNode(index);
33
+ if (onClick) {
34
+ onClick();
35
+ }
36
+ }
37
+ },
38
+ [interactive]
39
+ );
29
40
  const renderNode = React.useMemo(
30
41
  () => (child, index) => {
31
42
  if (React.isValidElement(child) && child.type === Node.Node) {
@@ -34,14 +45,24 @@ const Root = ({ segmented = false, children }) => {
34
45
  isLast: index === childrenCount - 1,
35
46
  selected: selectedNode === index,
36
47
  segmented,
48
+ interactive,
37
49
  onClick: () => handleNodeClick(index, child.props.onClick)
38
50
  });
39
51
  }
40
52
  return null;
41
53
  },
42
- [childrenCount, selectedNode, segmented]
54
+ [childrenCount, selectedNode, segmented, interactive]
55
+ );
56
+ return /* @__PURE__ */ React.createElement(
57
+ "div",
58
+ {
59
+ className: clsx(
60
+ "flex w-full space-x-2 bg-white p-4 pb-2 rounded-mili",
61
+ className
62
+ )
63
+ },
64
+ React.Children.map(children, renderNode)
43
65
  );
44
- return /* @__PURE__ */ React.createElement("div", { className: "flex w-full space-x-2 bg-white p-4 pb-2 rounded-mili" }, React.Children.map(children, renderNode));
45
66
  };
46
67
 
47
68
  exports.Root = Root;
@@ -5,7 +5,7 @@ var tailwindVariants = require('tailwind-variants');
5
5
  const StepNodeVariants = tailwindVariants.tv({
6
6
  slots: {
7
7
  container: "flex flex-col items-center justify-center text-center w-full max-w-[268px]",
8
- content: "flex p-mili text-center w-full text-sub justify-center font-bold cursor-pointer",
8
+ content: "flex p-mili text-center w-full text-sub justify-center font-bold",
9
9
  separator: "h-micro w-full"
10
10
  },
11
11
  variants: {
@@ -20,6 +20,11 @@ const StepNodeVariants = tailwindVariants.tv({
20
20
  separator: "bg-error-medium"
21
21
  }
22
22
  },
23
+ interactive: {
24
+ true: {
25
+ content: "cursor-pointer"
26
+ }
27
+ },
23
28
  marked: {
24
29
  true: {
25
30
  content: "font-bold"
@@ -8,6 +8,7 @@ const Node = ({
8
8
  isLast = false,
9
9
  segmented = false,
10
10
  selected = false,
11
+ interactive = true,
11
12
  children,
12
13
  className,
13
14
  ...rest
@@ -17,10 +18,11 @@ const Node = ({
17
18
  marked,
18
19
  isFirst,
19
20
  isLast,
20
- selected,
21
- disabled: rest.disabled
21
+ selected: selected && interactive,
22
+ disabled: rest.disabled,
23
+ interactive
22
24
  });
23
- return /* @__PURE__ */ React__default.createElement("button", { type: "button", className: container({ className }), ...rest }, /* @__PURE__ */ React__default.createElement("div", { className: content() }, children), segmented ? /* @__PURE__ */ React__default.createElement("div", { className: separator() }) : /* @__PURE__ */ React__default.createElement(React__default.Fragment, null));
25
+ return /* @__PURE__ */ React__default.createElement("button", { type: "button", className: container({ className }), ...rest }, children ? /* @__PURE__ */ React__default.createElement("div", { className: content() }, children) : /* @__PURE__ */ React__default.createElement(React__default.Fragment, null), segmented ? /* @__PURE__ */ React__default.createElement("div", { className: separator() }) : /* @__PURE__ */ React__default.createElement(React__default.Fragment, null));
24
26
  };
25
27
 
26
28
  export { Node };
@@ -1,7 +1,13 @@
1
1
  import React__default, { useMemo, useState, useCallback } from 'react';
2
2
  import { Node } from './Node.js';
3
+ import clsx from 'clsx';
3
4
 
4
- const Root = ({ segmented = false, children }) => {
5
+ const Root = ({
6
+ segmented = false,
7
+ children,
8
+ className = "",
9
+ interactive = true
10
+ }) => {
5
11
  const initialSelectedIndex = useMemo(() => {
6
12
  let initialIndex = null;
7
13
  React__default.Children.forEach(children, (child, index) => {
@@ -18,12 +24,17 @@ const Root = ({ segmented = false, children }) => {
18
24
  () => React__default.Children.count(children),
19
25
  [children]
20
26
  );
21
- const handleNodeClick = useCallback((index, onClick) => {
22
- setSelectedNode(index);
23
- if (onClick) {
24
- onClick();
25
- }
26
- }, []);
27
+ const handleNodeClick = useCallback(
28
+ (index, onClick) => {
29
+ if (interactive) {
30
+ setSelectedNode(index);
31
+ if (onClick) {
32
+ onClick();
33
+ }
34
+ }
35
+ },
36
+ [interactive]
37
+ );
27
38
  const renderNode = useMemo(
28
39
  () => (child, index) => {
29
40
  if (React__default.isValidElement(child) && child.type === Node) {
@@ -32,14 +43,24 @@ const Root = ({ segmented = false, children }) => {
32
43
  isLast: index === childrenCount - 1,
33
44
  selected: selectedNode === index,
34
45
  segmented,
46
+ interactive,
35
47
  onClick: () => handleNodeClick(index, child.props.onClick)
36
48
  });
37
49
  }
38
50
  return null;
39
51
  },
40
- [childrenCount, selectedNode, segmented]
52
+ [childrenCount, selectedNode, segmented, interactive]
53
+ );
54
+ return /* @__PURE__ */ React__default.createElement(
55
+ "div",
56
+ {
57
+ className: clsx(
58
+ "flex w-full space-x-2 bg-white p-4 pb-2 rounded-mili",
59
+ className
60
+ )
61
+ },
62
+ React__default.Children.map(children, renderNode)
41
63
  );
42
- return /* @__PURE__ */ React__default.createElement("div", { className: "flex w-full space-x-2 bg-white p-4 pb-2 rounded-mili" }, React__default.Children.map(children, renderNode));
43
64
  };
44
65
 
45
66
  export { Root };
@@ -3,7 +3,7 @@ import { tv } from 'tailwind-variants';
3
3
  const StepNodeVariants = tv({
4
4
  slots: {
5
5
  container: "flex flex-col items-center justify-center text-center w-full max-w-[268px]",
6
- content: "flex p-mili text-center w-full text-sub justify-center font-bold cursor-pointer",
6
+ content: "flex p-mili text-center w-full text-sub justify-center font-bold",
7
7
  separator: "h-micro w-full"
8
8
  },
9
9
  variants: {
@@ -18,6 +18,11 @@ const StepNodeVariants = tv({
18
18
  separator: "bg-error-medium"
19
19
  }
20
20
  },
21
+ interactive: {
22
+ true: {
23
+ content: "cursor-pointer"
24
+ }
25
+ },
21
26
  marked: {
22
27
  true: {
23
28
  content: "font-bold"
@@ -6,6 +6,7 @@ export interface StepNodeProps extends Omit<React.ButtonHTMLAttributes<HTMLButto
6
6
  isLast?: boolean;
7
7
  segmented?: boolean;
8
8
  selected?: boolean;
9
- children: React.ReactNode;
9
+ interactive?: boolean;
10
+ children?: React.ReactNode;
10
11
  }
11
- export declare const Node: ({ marked, intent, isFirst, isLast, segmented, selected, children, className, ...rest }: StepNodeProps) => JSX.Element;
12
+ export declare const Node: ({ marked, intent, isFirst, isLast, segmented, selected, interactive, children, className, ...rest }: StepNodeProps) => JSX.Element;
@@ -2,5 +2,7 @@ import React from 'react';
2
2
  export interface StepRootProps {
3
3
  children: React.ReactNode;
4
4
  segmented?: boolean;
5
+ className?: string;
6
+ interactive?: boolean;
5
7
  }
6
- export declare const Root: ({ segmented, children }: StepRootProps) => JSX.Element;
8
+ export declare const Root: ({ segmented, children, className, interactive, }: StepRootProps) => JSX.Element;
@@ -1,5 +1,5 @@
1
1
  /// <reference types="react" />
2
2
  export declare const Stepper: {
3
- Root: ({ segmented, children }: import("./Root").StepRootProps) => JSX.Element;
4
- Node: ({ marked, intent, isFirst, isLast, segmented, selected, children, className, ...rest }: import("./Node").StepNodeProps) => JSX.Element;
3
+ Root: ({ segmented, children, className, interactive, }: import("./Root").StepRootProps) => JSX.Element;
4
+ Node: ({ marked, intent, isFirst, isLast, segmented, selected, interactive, children, className, ...rest }: import("./Node").StepNodeProps) => JSX.Element;
5
5
  };
@@ -10,6 +10,11 @@ export declare const StepNodeVariants: import("tailwind-variants").TVReturnType<
10
10
  separator: string;
11
11
  };
12
12
  };
13
+ interactive: {
14
+ true: {
15
+ content: string;
16
+ };
17
+ };
13
18
  marked: {
14
19
  true: {
15
20
  content: string;
@@ -56,6 +61,11 @@ export declare const StepNodeVariants: import("tailwind-variants").TVReturnType<
56
61
  separator: string;
57
62
  };
58
63
  };
64
+ interactive: {
65
+ true: {
66
+ content: string;
67
+ };
68
+ };
59
69
  marked: {
60
70
  true: {
61
71
  content: string;
@@ -98,6 +108,11 @@ export declare const StepNodeVariants: import("tailwind-variants").TVReturnType<
98
108
  separator: string;
99
109
  };
100
110
  };
111
+ interactive: {
112
+ true: {
113
+ content: string;
114
+ };
115
+ };
101
116
  marked: {
102
117
  true: {
103
118
  content: string;
@@ -140,6 +155,11 @@ export declare const StepNodeVariants: import("tailwind-variants").TVReturnType<
140
155
  separator: string;
141
156
  };
142
157
  };
158
+ interactive: {
159
+ true: {
160
+ content: string;
161
+ };
162
+ };
143
163
  marked: {
144
164
  true: {
145
165
  content: string;
@@ -186,6 +206,11 @@ export declare const StepNodeVariants: import("tailwind-variants").TVReturnType<
186
206
  separator: string;
187
207
  };
188
208
  };
209
+ interactive: {
210
+ true: {
211
+ content: string;
212
+ };
213
+ };
189
214
  marked: {
190
215
  true: {
191
216
  content: string;
@@ -232,6 +257,11 @@ export declare const StepNodeVariants: import("tailwind-variants").TVReturnType<
232
257
  separator: string;
233
258
  };
234
259
  };
260
+ interactive: {
261
+ true: {
262
+ content: string;
263
+ };
264
+ };
235
265
  marked: {
236
266
  true: {
237
267
  content: string;
@@ -274,6 +304,11 @@ export declare const StepNodeVariants: import("tailwind-variants").TVReturnType<
274
304
  separator: string;
275
305
  };
276
306
  };
307
+ interactive: {
308
+ true: {
309
+ content: string;
310
+ };
311
+ };
277
312
  marked: {
278
313
  true: {
279
314
  content: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tecsinapse/cortex-react",
3
- "version": "1.9.8",
3
+ "version": "1.9.9",
4
4
  "description": "React components based in @tecsinapse/cortex-core",
5
5
  "license": "MIT",
6
6
  "main": "dist/esm/index.js",
@@ -20,7 +20,7 @@
20
20
  "dependencies": {
21
21
  "@floating-ui/react": "^0.26.18",
22
22
  "@internationalized/date": "*",
23
- "@tecsinapse/cortex-core": "0.4.5",
23
+ "@tecsinapse/cortex-core": "0.4.6",
24
24
  "clsx": "*",
25
25
  "currency.js": "~2.0.4",
26
26
  "react-aria": "^3.33.1",
@@ -48,5 +48,5 @@
48
48
  "react-dom": ">=18.0.0",
49
49
  "tailwind": ">=3.3.0"
50
50
  },
51
- "gitHead": "124fb7ca40505f46f5ae9cc577e026625a2d8497"
51
+ "gitHead": "b09eb691310bb40ea8e7481d2bdfece3c3b239ff"
52
52
  }