@koobiq/react-components 0.2.0 → 0.2.1
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.
|
@@ -1,81 +1,86 @@
|
|
|
1
1
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { forwardRef } from "react";
|
|
3
|
-
import { isNotNil, clsx } from "@koobiq/react-core";
|
|
2
|
+
import { forwardRef, Children, isValidElement, cloneElement } from "react";
|
|
3
|
+
import { isNotNil, useFocusRing, mergeProps, clsx } from "@koobiq/react-core";
|
|
4
4
|
import { useInputContext, Group } from "@koobiq/react-primitives";
|
|
5
5
|
import s from "./FieldContentGroup.module.css.js";
|
|
6
6
|
import { FieldContentGroupContext } from "./FieldContentGroupContext.js";
|
|
7
7
|
import { FieldAddon } from "../FieldAddon/FieldAddon.js";
|
|
8
|
-
const FieldContentGroup = forwardRef(
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
8
|
+
const FieldContentGroup = forwardRef(function FieldContentGroup2({
|
|
9
|
+
variant = "filled",
|
|
10
|
+
isInvalid = false,
|
|
11
|
+
isDisabled = false,
|
|
12
|
+
children,
|
|
13
|
+
className,
|
|
14
|
+
startAddon,
|
|
15
|
+
endAddon,
|
|
16
|
+
slotProps,
|
|
17
|
+
...other
|
|
18
|
+
}, ref) {
|
|
19
|
+
const { value } = useInputContext();
|
|
20
|
+
const hasStartAddon = !!startAddon;
|
|
21
|
+
const hasEndAddon = !!endAddon;
|
|
22
|
+
const hasValue = isNotNil(value);
|
|
23
|
+
const { focusProps, isFocused } = useFocusRing({ within: true });
|
|
24
|
+
const focusManagedChildren = Children.map(children, (child) => {
|
|
25
|
+
if (!isValidElement(child)) return child;
|
|
26
|
+
const merged = mergeProps(focusProps, child.props);
|
|
27
|
+
return cloneElement(child, merged);
|
|
28
|
+
});
|
|
29
|
+
return /* @__PURE__ */ jsx(
|
|
30
|
+
Group,
|
|
31
|
+
{
|
|
32
|
+
className: clsx(
|
|
33
|
+
s.base,
|
|
34
|
+
s[variant],
|
|
35
|
+
isInvalid && s.invalid,
|
|
36
|
+
isDisabled && s.disabled,
|
|
37
|
+
isFocused && s.focused,
|
|
38
|
+
hasStartAddon && s.hasStartAddon,
|
|
39
|
+
hasEndAddon && s.hasEndAddon,
|
|
40
|
+
className
|
|
41
|
+
),
|
|
42
|
+
isInvalid,
|
|
43
|
+
isDisabled,
|
|
44
|
+
...other,
|
|
45
|
+
ref,
|
|
46
|
+
children: ({ isHovered, isFocusWithin }) => /* @__PURE__ */ jsxs(
|
|
47
|
+
FieldContentGroupContext.Provider,
|
|
48
|
+
{
|
|
49
|
+
value: {
|
|
50
|
+
hasValue,
|
|
51
|
+
isHovered,
|
|
52
|
+
isInvalid,
|
|
53
|
+
isDisabled,
|
|
54
|
+
isFocusWithin
|
|
55
|
+
},
|
|
56
|
+
children: [
|
|
57
|
+
/* @__PURE__ */ jsx(
|
|
58
|
+
FieldAddon,
|
|
59
|
+
{
|
|
60
|
+
placement: "start",
|
|
61
|
+
isInvalid,
|
|
62
|
+
isDisabled,
|
|
63
|
+
...slotProps?.startAddon,
|
|
64
|
+
children: startAddon
|
|
65
|
+
}
|
|
66
|
+
),
|
|
67
|
+
focusManagedChildren,
|
|
68
|
+
/* @__PURE__ */ jsx(
|
|
69
|
+
FieldAddon,
|
|
70
|
+
{
|
|
71
|
+
placement: "end",
|
|
72
|
+
isInvalid,
|
|
73
|
+
isDisabled,
|
|
74
|
+
...slotProps?.endAddon,
|
|
75
|
+
children: endAddon
|
|
76
|
+
}
|
|
77
|
+
)
|
|
78
|
+
]
|
|
79
|
+
}
|
|
80
|
+
)
|
|
81
|
+
}
|
|
82
|
+
);
|
|
83
|
+
});
|
|
79
84
|
FieldContentGroup.displayName = "FieldContentGroup";
|
|
80
85
|
export {
|
|
81
86
|
FieldContentGroup
|
|
@@ -3,6 +3,7 @@ const hasStartAddon = "kbq-fieldcontentgroup-hasStartAddon-62fb80";
|
|
|
3
3
|
const hasEndAddon = "kbq-fieldcontentgroup-hasEndAddon-e8c20a";
|
|
4
4
|
const transparent = "kbq-fieldcontentgroup-transparent-ac42b6";
|
|
5
5
|
const filled = "kbq-fieldcontentgroup-filled-37bb93";
|
|
6
|
+
const focused = "kbq-fieldcontentgroup-focused-8fb205";
|
|
6
7
|
const invalid = "kbq-fieldcontentgroup-invalid-e4973b";
|
|
7
8
|
const disabled = "kbq-fieldcontentgroup-disabled-54827b";
|
|
8
9
|
const s = {
|
|
@@ -11,6 +12,7 @@ const s = {
|
|
|
11
12
|
hasEndAddon,
|
|
12
13
|
transparent,
|
|
13
14
|
filled,
|
|
15
|
+
focused,
|
|
14
16
|
invalid,
|
|
15
17
|
disabled
|
|
16
18
|
};
|
|
@@ -19,6 +21,7 @@ export {
|
|
|
19
21
|
s as default,
|
|
20
22
|
disabled,
|
|
21
23
|
filled,
|
|
24
|
+
focused,
|
|
22
25
|
hasEndAddon,
|
|
23
26
|
hasStartAddon,
|
|
24
27
|
invalid,
|
package/dist/style.css
CHANGED
|
@@ -2018,7 +2018,7 @@
|
|
|
2018
2018
|
--field-content-border-color: var(--kbq-line-contrast-fade);
|
|
2019
2019
|
}
|
|
2020
2020
|
|
|
2021
|
-
.kbq-fieldcontentgroup-filled-37bb93:
|
|
2021
|
+
.kbq-fieldcontentgroup-filled-37bb93:where(.kbq-fieldcontentgroup-focused-8fb205) {
|
|
2022
2022
|
--field-content-outline-color: var(--kbq-states-line-focus-theme);
|
|
2023
2023
|
}
|
|
2024
2024
|
|
|
@@ -2026,7 +2026,7 @@
|
|
|
2026
2026
|
--field-content-border-color: var(--kbq-line-error);
|
|
2027
2027
|
}
|
|
2028
2028
|
|
|
2029
|
-
.kbq-fieldcontentgroup-filled-37bb93:where(.kbq-fieldcontentgroup-invalid-e4973b)
|
|
2029
|
+
.kbq-fieldcontentgroup-filled-37bb93:where(.kbq-fieldcontentgroup-invalid-e4973b.kbq-fieldcontentgroup-focused-8fb205) {
|
|
2030
2030
|
--field-content-outline-color: var(--field-content-border-color);
|
|
2031
2031
|
}
|
|
2032
2032
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@koobiq/react-components",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.1",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -28,10 +28,10 @@
|
|
|
28
28
|
"@koobiq/design-tokens": "^3.14.0",
|
|
29
29
|
"@types/react-transition-group": "^4.4.12",
|
|
30
30
|
"react-transition-group": "^4.4.5",
|
|
31
|
-
"@koobiq/
|
|
32
|
-
"@koobiq/react-
|
|
33
|
-
"@koobiq/react-
|
|
34
|
-
"@koobiq/
|
|
31
|
+
"@koobiq/logger": "0.2.1",
|
|
32
|
+
"@koobiq/react-core": "0.2.1",
|
|
33
|
+
"@koobiq/react-icons": "0.2.1",
|
|
34
|
+
"@koobiq/react-primitives": "0.2.1"
|
|
35
35
|
},
|
|
36
36
|
"peerDependencies": {
|
|
37
37
|
"@koobiq/design-tokens": "^3.14.0",
|