@tecsinapse/cortex-react 1.2.2-beta.2 → 1.3.0-beta.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.
- package/dist/cjs/components/Button.js +10 -1
- package/dist/cjs/components/DateSegment.js +12 -0
- package/dist/cjs/components/TextArea.js +2 -0
- package/dist/cjs/components/TimeField.js +12 -0
- package/dist/cjs/components/TimeFieldInput.js +22 -0
- package/dist/cjs/hooks/useTimeField.js +32 -0
- package/dist/cjs/index.js +2 -0
- package/dist/esm/components/Button.js +10 -1
- package/dist/esm/components/DateSegment.js +10 -0
- package/dist/esm/components/TextArea.js +2 -0
- package/dist/esm/components/TimeField.js +10 -0
- package/dist/esm/components/TimeFieldInput.js +20 -0
- package/dist/esm/hooks/useTimeField.js +30 -0
- package/dist/esm/index.js +1 -0
- package/dist/types/components/DateSegment.d.ts +7 -0
- package/dist/types/components/Input.d.ts +1 -1
- package/dist/types/components/TimeField.d.ts +7 -0
- package/dist/types/components/TimeFieldInput.d.ts +10 -0
- package/dist/types/components/index.d.ts +1 -0
- package/dist/types/hooks/useTimeField.d.ts +7 -0
- package/dist/types/tests/Button.test.d.ts +1 -0
- package/dist/types/tests/DateSegment.test.d.ts +1 -0
- package/dist/types/tests/TextArea.test.d.ts +1 -0
- package/dist/types/tests/TimeField.test.d.ts +1 -0
- package/dist/types/tests/TimeFieldInput.test.d.ts +1 -0
- package/package.json +3 -3
|
@@ -5,7 +5,16 @@ var cortexCore = require('@tecsinapse/cortex-core');
|
|
|
5
5
|
|
|
6
6
|
const Button = React.forwardRef((props, ref) => {
|
|
7
7
|
const { variants, children, ...rest } = props;
|
|
8
|
-
return /* @__PURE__ */ React.createElement(
|
|
8
|
+
return /* @__PURE__ */ React.createElement(
|
|
9
|
+
"button",
|
|
10
|
+
{
|
|
11
|
+
className: cortexCore.button(variants),
|
|
12
|
+
ref,
|
|
13
|
+
"data-testid": "button",
|
|
14
|
+
...rest
|
|
15
|
+
},
|
|
16
|
+
children
|
|
17
|
+
);
|
|
9
18
|
});
|
|
10
19
|
|
|
11
20
|
exports.Button = Button;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var React = require('react');
|
|
4
|
+
var reactAria = require('react-aria');
|
|
5
|
+
|
|
6
|
+
const DateSegment = ({ segment, state }) => {
|
|
7
|
+
const ref = React.useRef(null);
|
|
8
|
+
const { segmentProps } = reactAria.useDateSegment(segment, state, ref);
|
|
9
|
+
return /* @__PURE__ */ React.createElement("div", { ...segmentProps, ref, className: "text-sub accent-transparent" }, segment.text);
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
exports.DateSegment = DateSegment;
|
|
@@ -14,6 +14,7 @@ const Box = React.forwardRef(
|
|
|
14
14
|
return /* @__PURE__ */ React.createElement("div", { className: "flex w-full flex-col" }, /* @__PURE__ */ React.createElement(
|
|
15
15
|
"textarea",
|
|
16
16
|
{
|
|
17
|
+
"data-testid": "textarea-box",
|
|
17
18
|
ref,
|
|
18
19
|
id: id ?? name,
|
|
19
20
|
name,
|
|
@@ -48,6 +49,7 @@ const Face = React.forwardRef(
|
|
|
48
49
|
{
|
|
49
50
|
ref,
|
|
50
51
|
className: clsx.clsx(cortexCore.input(variants), className),
|
|
52
|
+
"data-testid": "textarea-face",
|
|
51
53
|
id: "textarea-face",
|
|
52
54
|
...rest
|
|
53
55
|
},
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var React = require('react');
|
|
4
|
+
var DateSegment = require('./DateSegment.js');
|
|
5
|
+
var useTimeField = require('../hooks/useTimeField.js');
|
|
6
|
+
|
|
7
|
+
const TimeField = (props) => {
|
|
8
|
+
const { fieldProps, ref, state } = useTimeField.useTimeField(props);
|
|
9
|
+
return /* @__PURE__ */ React.createElement("div", { ...fieldProps, ref, className: "flex flex-row" }, state.segments.map((segment, i) => /* @__PURE__ */ React.createElement(DateSegment.DateSegment, { key: i, segment, state })));
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
module.exports = TimeField;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var React = require('react');
|
|
4
|
+
var Input = require('./Input.js');
|
|
5
|
+
var cortexCore = require('@tecsinapse/cortex-core');
|
|
6
|
+
var TimeField = require('./TimeField.js');
|
|
7
|
+
|
|
8
|
+
const TimeFieldInput = (props) => {
|
|
9
|
+
const { onChange, value, label, variants } = props;
|
|
10
|
+
return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(
|
|
11
|
+
Input.Input.Face,
|
|
12
|
+
{
|
|
13
|
+
variants,
|
|
14
|
+
className: "flex flex-row",
|
|
15
|
+
"data-testid": "time-field-input"
|
|
16
|
+
},
|
|
17
|
+
/* @__PURE__ */ React.createElement("span", { className: cortexCore.labelStyle({}) }, label),
|
|
18
|
+
/* @__PURE__ */ React.createElement("div", { className: cortexCore.inputBox("", label) }, /* @__PURE__ */ React.createElement(TimeField, { onChange, value }))
|
|
19
|
+
));
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
exports.TimeFieldInput = TimeFieldInput;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var React = require('react');
|
|
4
|
+
var reactAria = require('react-aria');
|
|
5
|
+
var reactStately = require('react-stately');
|
|
6
|
+
var date = require('@internationalized/date');
|
|
7
|
+
|
|
8
|
+
const useTimeField = (props) => {
|
|
9
|
+
const { value, onChange } = props;
|
|
10
|
+
const { locale } = reactAria.useLocale();
|
|
11
|
+
const state = reactStately.useTimeFieldState({
|
|
12
|
+
value: new date.Time(value?.hour, value?.minute),
|
|
13
|
+
onChange: (timeValue) => onChange({ hour: timeValue.hour, minute: timeValue.minute }),
|
|
14
|
+
locale
|
|
15
|
+
});
|
|
16
|
+
const ref = React.useRef(null);
|
|
17
|
+
const { fieldProps } = reactAria.useTimeField(
|
|
18
|
+
{
|
|
19
|
+
"aria-label": "time-field",
|
|
20
|
+
hourCycle: 24
|
|
21
|
+
},
|
|
22
|
+
state,
|
|
23
|
+
ref
|
|
24
|
+
);
|
|
25
|
+
return {
|
|
26
|
+
fieldProps,
|
|
27
|
+
ref,
|
|
28
|
+
state
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
exports.useTimeField = useTimeField;
|
package/dist/cjs/index.js
CHANGED
|
@@ -21,6 +21,7 @@ var Table = require('./components/Table.js');
|
|
|
21
21
|
var Tag = require('./components/Tag.js');
|
|
22
22
|
var TextArea = require('./components/TextArea.js');
|
|
23
23
|
var Toggle = require('./components/Toggle.js');
|
|
24
|
+
var TimeFieldInput = require('./components/TimeFieldInput.js');
|
|
24
25
|
var SnackbarSonner = require('./service/SnackbarSonner.js');
|
|
25
26
|
var useCalendar = require('./hooks/useCalendar.js');
|
|
26
27
|
var useCalendarCell = require('./hooks/useCalendarCell.js');
|
|
@@ -63,6 +64,7 @@ exports.Td = Table.Td;
|
|
|
63
64
|
exports.Tag = Tag.Tag;
|
|
64
65
|
exports.TextArea = TextArea.TextArea;
|
|
65
66
|
exports.Toggle = Toggle.Toggle;
|
|
67
|
+
exports.TimeFieldInput = TimeFieldInput.TimeFieldInput;
|
|
66
68
|
exports.SnackbarSonner = SnackbarSonner.SnackbarSonner;
|
|
67
69
|
exports.useCalendar = useCalendar.useCalendar;
|
|
68
70
|
exports.useCalendarCell = useCalendarCell.useCalendarCell;
|
|
@@ -3,7 +3,16 @@ import { button } from '@tecsinapse/cortex-core';
|
|
|
3
3
|
|
|
4
4
|
const Button = forwardRef((props, ref) => {
|
|
5
5
|
const { variants, children, ...rest } = props;
|
|
6
|
-
return /* @__PURE__ */ React.createElement(
|
|
6
|
+
return /* @__PURE__ */ React.createElement(
|
|
7
|
+
"button",
|
|
8
|
+
{
|
|
9
|
+
className: button(variants),
|
|
10
|
+
ref,
|
|
11
|
+
"data-testid": "button",
|
|
12
|
+
...rest
|
|
13
|
+
},
|
|
14
|
+
children
|
|
15
|
+
);
|
|
7
16
|
});
|
|
8
17
|
|
|
9
18
|
export { Button };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { useDateSegment } from 'react-aria';
|
|
3
|
+
|
|
4
|
+
const DateSegment = ({ segment, state }) => {
|
|
5
|
+
const ref = React.useRef(null);
|
|
6
|
+
const { segmentProps } = useDateSegment(segment, state, ref);
|
|
7
|
+
return /* @__PURE__ */ React.createElement("div", { ...segmentProps, ref, className: "text-sub accent-transparent" }, segment.text);
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
export { DateSegment };
|
|
@@ -12,6 +12,7 @@ const Box = React.forwardRef(
|
|
|
12
12
|
return /* @__PURE__ */ React.createElement("div", { className: "flex w-full flex-col" }, /* @__PURE__ */ React.createElement(
|
|
13
13
|
"textarea",
|
|
14
14
|
{
|
|
15
|
+
"data-testid": "textarea-box",
|
|
15
16
|
ref,
|
|
16
17
|
id: id ?? name,
|
|
17
18
|
name,
|
|
@@ -46,6 +47,7 @@ const Face = React.forwardRef(
|
|
|
46
47
|
{
|
|
47
48
|
ref,
|
|
48
49
|
className: clsx(input(variants), className),
|
|
50
|
+
"data-testid": "textarea-face",
|
|
49
51
|
id: "textarea-face",
|
|
50
52
|
...rest
|
|
51
53
|
},
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { DateSegment } from './DateSegment.js';
|
|
3
|
+
import { useTimeField } from '../hooks/useTimeField.js';
|
|
4
|
+
|
|
5
|
+
const TimeField = (props) => {
|
|
6
|
+
const { fieldProps, ref, state } = useTimeField(props);
|
|
7
|
+
return /* @__PURE__ */ React.createElement("div", { ...fieldProps, ref, className: "flex flex-row" }, state.segments.map((segment, i) => /* @__PURE__ */ React.createElement(DateSegment, { key: i, segment, state })));
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
export { TimeField as default };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Input } from './Input.js';
|
|
3
|
+
import { labelStyle, inputBox } from '@tecsinapse/cortex-core';
|
|
4
|
+
import TimeField from './TimeField.js';
|
|
5
|
+
|
|
6
|
+
const TimeFieldInput = (props) => {
|
|
7
|
+
const { onChange, value, label, variants } = props;
|
|
8
|
+
return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(
|
|
9
|
+
Input.Face,
|
|
10
|
+
{
|
|
11
|
+
variants,
|
|
12
|
+
className: "flex flex-row",
|
|
13
|
+
"data-testid": "time-field-input"
|
|
14
|
+
},
|
|
15
|
+
/* @__PURE__ */ React.createElement("span", { className: labelStyle({}) }, label),
|
|
16
|
+
/* @__PURE__ */ React.createElement("div", { className: inputBox("", label) }, /* @__PURE__ */ React.createElement(TimeField, { onChange, value }))
|
|
17
|
+
));
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export { TimeFieldInput };
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { useLocale, useTimeField as useTimeField$1 } from 'react-aria';
|
|
3
|
+
import { useTimeFieldState } from 'react-stately';
|
|
4
|
+
import { Time } from '@internationalized/date';
|
|
5
|
+
|
|
6
|
+
const useTimeField = (props) => {
|
|
7
|
+
const { value, onChange } = props;
|
|
8
|
+
const { locale } = useLocale();
|
|
9
|
+
const state = useTimeFieldState({
|
|
10
|
+
value: new Time(value?.hour, value?.minute),
|
|
11
|
+
onChange: (timeValue) => onChange({ hour: timeValue.hour, minute: timeValue.minute }),
|
|
12
|
+
locale
|
|
13
|
+
});
|
|
14
|
+
const ref = React.useRef(null);
|
|
15
|
+
const { fieldProps } = useTimeField$1(
|
|
16
|
+
{
|
|
17
|
+
"aria-label": "time-field",
|
|
18
|
+
hourCycle: 24
|
|
19
|
+
},
|
|
20
|
+
state,
|
|
21
|
+
ref
|
|
22
|
+
);
|
|
23
|
+
return {
|
|
24
|
+
fieldProps,
|
|
25
|
+
ref,
|
|
26
|
+
state
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
export { useTimeField };
|
package/dist/esm/index.js
CHANGED
|
@@ -19,6 +19,7 @@ export { TCell, TFoot, THead, THeadCell, TRow, TRowHeader, Table, Td } from './c
|
|
|
19
19
|
export { Tag } from './components/Tag.js';
|
|
20
20
|
export { TextArea } from './components/TextArea.js';
|
|
21
21
|
export { Toggle } from './components/Toggle.js';
|
|
22
|
+
export { TimeFieldInput } from './components/TimeFieldInput.js';
|
|
22
23
|
export { SnackbarSonner } from './service/SnackbarSonner.js';
|
|
23
24
|
export { useCalendar } from './hooks/useCalendar.js';
|
|
24
25
|
export { useCalendarCell } from './hooks/useCalendarCell.js';
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { DateFieldState, DateSegment as DateSegmentType } from 'react-stately';
|
|
2
|
+
interface DateSegmentProps {
|
|
3
|
+
segment: DateSegmentType;
|
|
4
|
+
state: DateFieldState;
|
|
5
|
+
}
|
|
6
|
+
export declare const DateSegment: ({ segment, state }: DateSegmentProps) => JSX.Element;
|
|
7
|
+
export {};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { InputPropsBase } from './Input';
|
|
2
|
+
export type TimeValueType = {
|
|
3
|
+
hour: number;
|
|
4
|
+
minute: number;
|
|
5
|
+
};
|
|
6
|
+
export interface TimeFieldInputProps extends InputPropsBase {
|
|
7
|
+
value?: TimeValueType;
|
|
8
|
+
onChange: (number: TimeValueType) => void;
|
|
9
|
+
}
|
|
10
|
+
export declare const TimeFieldInput: (props: TimeFieldInputProps) => JSX.Element;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { TimeFieldProps } from '../components/TimeField';
|
|
3
|
+
export declare const useTimeField: (props: TimeFieldProps) => {
|
|
4
|
+
fieldProps: import("@react-types/shared").GroupDOMAttributes;
|
|
5
|
+
ref: React.MutableRefObject<null>;
|
|
6
|
+
state: import("react-stately").TimeFieldState;
|
|
7
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import '@testing-library/jest-dom';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import '@testing-library/jest-dom';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import '@testing-library/jest-dom';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import '@testing-library/jest-dom';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import '@testing-library/jest-dom';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tecsinapse/cortex-react",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.0-beta.0",
|
|
4
4
|
"description": "React components based in @tecsinapse/cortex-core",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "dist/esm/index.js",
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
"test:watch": "jest --watch"
|
|
19
19
|
},
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@tecsinapse/cortex-core": "0.2.2-beta.
|
|
21
|
+
"@tecsinapse/cortex-core": "0.2.2-beta.2",
|
|
22
22
|
"clsx": "*",
|
|
23
23
|
"react-aria": "^3.33.1",
|
|
24
24
|
"react-icons": "^5.2.1",
|
|
@@ -39,5 +39,5 @@
|
|
|
39
39
|
"react-dom": ">=18.0.0",
|
|
40
40
|
"tailwind": ">=3.3.0"
|
|
41
41
|
},
|
|
42
|
-
"gitHead": "
|
|
42
|
+
"gitHead": "0ecb7949c627cb5d2fe9395f148e48a0bb071599"
|
|
43
43
|
}
|