@fuf-stack/uniform 1.3.1 → 1.4.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.
- package/dist/RadioTabs/index.cjs +2 -2
- package/dist/RadioTabs/index.d.cts +2 -2
- package/dist/RadioTabs/index.d.ts +2 -2
- package/dist/RadioTabs/index.js +1 -1
- package/dist/{RadioTabs-8Gn71LRW.d.cts → RadioTabs-BCWW3tru.d.cts} +56 -48
- package/dist/{RadioTabs-8Gn71LRW.d.ts → RadioTabs-BCWW3tru.d.ts} +56 -48
- package/dist/{chunk-PF4NU4QW.js → chunk-JSQ77E6L.js} +46 -9
- package/dist/chunk-JSQ77E6L.js.map +1 -0
- package/dist/{chunk-VPTOKYJG.cjs → chunk-ORQO6JXK.cjs} +46 -9
- package/dist/chunk-ORQO6JXK.cjs.map +1 -0
- package/dist/index.cjs +2 -2
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/package.json +5 -5
- package/dist/chunk-PF4NU4QW.js.map +0 -1
- package/dist/chunk-VPTOKYJG.cjs.map +0 -1
package/dist/RadioTabs/index.cjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
2
|
|
|
3
3
|
|
|
4
|
-
var
|
|
4
|
+
var _chunkORQO6JXKcjs = require('../chunk-ORQO6JXK.cjs');
|
|
5
5
|
require('../chunk-OE5BOGGX.cjs');
|
|
6
6
|
require('../chunk-Y3AB4GV6.cjs');
|
|
7
7
|
require('../chunk-2GYFDVXX.cjs');
|
|
@@ -12,5 +12,5 @@ require('../chunk-555JRYCS.cjs');
|
|
|
12
12
|
|
|
13
13
|
|
|
14
14
|
|
|
15
|
-
exports.RadioTabs =
|
|
15
|
+
exports.RadioTabs = _chunkORQO6JXKcjs.RadioTabs_default; exports.default = _chunkORQO6JXKcjs.RadioTabs_default2;
|
|
16
16
|
//# sourceMappingURL=index.cjs.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { R as RadioTabs } from '../RadioTabs-
|
|
2
|
-
export { a as RadioTabsProps } from '../RadioTabs-
|
|
1
|
+
import { R as RadioTabs } from '../RadioTabs-BCWW3tru.cjs';
|
|
2
|
+
export { a as RadioTabsProps } from '../RadioTabs-BCWW3tru.cjs';
|
|
3
3
|
import 'tailwind-variants';
|
|
4
4
|
import '@fuf-stack/pixel-utils';
|
|
5
5
|
import '@fuf-stack/pixels';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { R as RadioTabs } from '../RadioTabs-
|
|
2
|
-
export { a as RadioTabsProps } from '../RadioTabs-
|
|
1
|
+
import { R as RadioTabs } from '../RadioTabs-BCWW3tru.js';
|
|
2
|
+
export { a as RadioTabsProps } from '../RadioTabs-BCWW3tru.js';
|
|
3
3
|
import 'tailwind-variants';
|
|
4
4
|
import '@fuf-stack/pixel-utils';
|
|
5
5
|
import '@fuf-stack/pixels';
|
package/dist/RadioTabs/index.js
CHANGED
|
@@ -4,71 +4,77 @@ import { TabsProps } from '@fuf-stack/pixels';
|
|
|
4
4
|
import { ReactNode, ReactElement } from 'react';
|
|
5
5
|
|
|
6
6
|
declare const radioTabsVariants: tailwind_variants.TVReturnType<{
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
base
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
wrapper?: tailwind_variants.ClassValue;
|
|
13
|
-
cursor?: tailwind_variants.ClassValue;
|
|
14
|
-
panel?: tailwind_variants.ClassValue;
|
|
15
|
-
tabContent?: tailwind_variants.ClassValue;
|
|
16
|
-
tabList?: tailwind_variants.ClassValue;
|
|
7
|
+
hasContent: {
|
|
8
|
+
true: {
|
|
9
|
+
base: string;
|
|
10
|
+
tabBase: string;
|
|
11
|
+
tabWrapper: string[];
|
|
17
12
|
};
|
|
18
13
|
};
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
base?: tailwind_variants.ClassValue;
|
|
23
|
-
label?: tailwind_variants.ClassValue;
|
|
24
|
-
tab?: tailwind_variants.ClassValue;
|
|
25
|
-
wrapper?: tailwind_variants.ClassValue;
|
|
26
|
-
cursor?: tailwind_variants.ClassValue;
|
|
27
|
-
panel?: tailwind_variants.ClassValue;
|
|
28
|
-
tabContent?: tailwind_variants.ClassValue;
|
|
29
|
-
tabList?: tailwind_variants.ClassValue;
|
|
14
|
+
fullWidth: {
|
|
15
|
+
true: {
|
|
16
|
+
tabWrapper: string;
|
|
30
17
|
};
|
|
31
18
|
};
|
|
32
|
-
}
|
|
19
|
+
}, {
|
|
33
20
|
base: string;
|
|
21
|
+
cursor: string;
|
|
34
22
|
label: string;
|
|
35
|
-
wrapper: string;
|
|
36
|
-
tabList: string;
|
|
37
23
|
tab: string;
|
|
24
|
+
tabBase: string;
|
|
38
25
|
tabContent: string;
|
|
39
|
-
|
|
40
|
-
|
|
26
|
+
tabList: string;
|
|
27
|
+
tabPanel: string;
|
|
28
|
+
tabWrapper: string;
|
|
29
|
+
wrapper: string;
|
|
41
30
|
}, undefined, {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
base
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
wrapper?: tailwind_variants.ClassValue;
|
|
48
|
-
cursor?: tailwind_variants.ClassValue;
|
|
49
|
-
panel?: tailwind_variants.ClassValue;
|
|
50
|
-
tabContent?: tailwind_variants.ClassValue;
|
|
51
|
-
tabList?: tailwind_variants.ClassValue;
|
|
31
|
+
hasContent: {
|
|
32
|
+
true: {
|
|
33
|
+
base: string;
|
|
34
|
+
tabBase: string;
|
|
35
|
+
tabWrapper: string[];
|
|
52
36
|
};
|
|
53
37
|
};
|
|
54
|
-
|
|
38
|
+
fullWidth: {
|
|
39
|
+
true: {
|
|
40
|
+
tabWrapper: string;
|
|
41
|
+
};
|
|
42
|
+
};
|
|
43
|
+
}, {
|
|
55
44
|
base: string;
|
|
45
|
+
cursor: string;
|
|
56
46
|
label: string;
|
|
57
|
-
wrapper: string;
|
|
58
|
-
tabList: string;
|
|
59
47
|
tab: string;
|
|
48
|
+
tabBase: string;
|
|
60
49
|
tabContent: string;
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
50
|
+
tabList: string;
|
|
51
|
+
tabPanel: string;
|
|
52
|
+
tabWrapper: string;
|
|
53
|
+
wrapper: string;
|
|
54
|
+
}, tailwind_variants.TVReturnType<{
|
|
55
|
+
hasContent: {
|
|
56
|
+
true: {
|
|
57
|
+
base: string;
|
|
58
|
+
tabBase: string;
|
|
59
|
+
tabWrapper: string[];
|
|
60
|
+
};
|
|
61
|
+
};
|
|
62
|
+
fullWidth: {
|
|
63
|
+
true: {
|
|
64
|
+
tabWrapper: string;
|
|
65
|
+
};
|
|
66
|
+
};
|
|
67
|
+
}, {
|
|
64
68
|
base: string;
|
|
69
|
+
cursor: string;
|
|
65
70
|
label: string;
|
|
66
|
-
wrapper: string;
|
|
67
|
-
tabList: string;
|
|
68
71
|
tab: string;
|
|
72
|
+
tabBase: string;
|
|
69
73
|
tabContent: string;
|
|
70
|
-
|
|
71
|
-
|
|
74
|
+
tabList: string;
|
|
75
|
+
tabPanel: string;
|
|
76
|
+
tabWrapper: string;
|
|
77
|
+
wrapper: string;
|
|
72
78
|
}, undefined, unknown, unknown, undefined>>;
|
|
73
79
|
type VariantProps = TVProps<typeof radioTabsVariants>;
|
|
74
80
|
type ClassName = TVClassName<typeof radioTabsVariants>;
|
|
@@ -86,11 +92,13 @@ interface RadioTabsOption {
|
|
|
86
92
|
/** option value */
|
|
87
93
|
value: string;
|
|
88
94
|
}
|
|
89
|
-
interface RadioTabsProps extends VariantProps {
|
|
95
|
+
interface RadioTabsProps extends Omit<VariantProps, 'hasContent'> {
|
|
90
96
|
/** CSS class name */
|
|
91
97
|
className?: ClassName;
|
|
92
98
|
/** Determines if the Buttons are disabled or not. */
|
|
93
99
|
disabled?: boolean;
|
|
100
|
+
/** Whether tabs should take up full container width */
|
|
101
|
+
fullWidth?: boolean;
|
|
94
102
|
/** determines orientation of the Buttons. */
|
|
95
103
|
inline?: boolean;
|
|
96
104
|
/** Label displayed next to the RadioButton. */
|
|
@@ -108,6 +116,6 @@ interface RadioTabsProps extends VariantProps {
|
|
|
108
116
|
* RadioTabs component based on [HeroUI RadioGroup](https://www.heroui.com//docs/components/radio-group)
|
|
109
117
|
* and [HeroUI Tabs](https://www.heroui.com//docs/components/tabs)
|
|
110
118
|
*/
|
|
111
|
-
declare const RadioTabs: ({ className, disabled, inline, label, name, options, testId: _testId, variant, }: RadioTabsProps) => ReactElement;
|
|
119
|
+
declare const RadioTabs: ({ className, disabled, fullWidth, inline, label, name, options, testId: _testId, variant, }: RadioTabsProps) => ReactElement;
|
|
112
120
|
|
|
113
121
|
export { RadioTabs as R, type RadioTabsProps as a };
|
|
@@ -4,71 +4,77 @@ import { TabsProps } from '@fuf-stack/pixels';
|
|
|
4
4
|
import { ReactNode, ReactElement } from 'react';
|
|
5
5
|
|
|
6
6
|
declare const radioTabsVariants: tailwind_variants.TVReturnType<{
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
base
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
wrapper?: tailwind_variants.ClassValue;
|
|
13
|
-
cursor?: tailwind_variants.ClassValue;
|
|
14
|
-
panel?: tailwind_variants.ClassValue;
|
|
15
|
-
tabContent?: tailwind_variants.ClassValue;
|
|
16
|
-
tabList?: tailwind_variants.ClassValue;
|
|
7
|
+
hasContent: {
|
|
8
|
+
true: {
|
|
9
|
+
base: string;
|
|
10
|
+
tabBase: string;
|
|
11
|
+
tabWrapper: string[];
|
|
17
12
|
};
|
|
18
13
|
};
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
base?: tailwind_variants.ClassValue;
|
|
23
|
-
label?: tailwind_variants.ClassValue;
|
|
24
|
-
tab?: tailwind_variants.ClassValue;
|
|
25
|
-
wrapper?: tailwind_variants.ClassValue;
|
|
26
|
-
cursor?: tailwind_variants.ClassValue;
|
|
27
|
-
panel?: tailwind_variants.ClassValue;
|
|
28
|
-
tabContent?: tailwind_variants.ClassValue;
|
|
29
|
-
tabList?: tailwind_variants.ClassValue;
|
|
14
|
+
fullWidth: {
|
|
15
|
+
true: {
|
|
16
|
+
tabWrapper: string;
|
|
30
17
|
};
|
|
31
18
|
};
|
|
32
|
-
}
|
|
19
|
+
}, {
|
|
33
20
|
base: string;
|
|
21
|
+
cursor: string;
|
|
34
22
|
label: string;
|
|
35
|
-
wrapper: string;
|
|
36
|
-
tabList: string;
|
|
37
23
|
tab: string;
|
|
24
|
+
tabBase: string;
|
|
38
25
|
tabContent: string;
|
|
39
|
-
|
|
40
|
-
|
|
26
|
+
tabList: string;
|
|
27
|
+
tabPanel: string;
|
|
28
|
+
tabWrapper: string;
|
|
29
|
+
wrapper: string;
|
|
41
30
|
}, undefined, {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
base
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
wrapper?: tailwind_variants.ClassValue;
|
|
48
|
-
cursor?: tailwind_variants.ClassValue;
|
|
49
|
-
panel?: tailwind_variants.ClassValue;
|
|
50
|
-
tabContent?: tailwind_variants.ClassValue;
|
|
51
|
-
tabList?: tailwind_variants.ClassValue;
|
|
31
|
+
hasContent: {
|
|
32
|
+
true: {
|
|
33
|
+
base: string;
|
|
34
|
+
tabBase: string;
|
|
35
|
+
tabWrapper: string[];
|
|
52
36
|
};
|
|
53
37
|
};
|
|
54
|
-
|
|
38
|
+
fullWidth: {
|
|
39
|
+
true: {
|
|
40
|
+
tabWrapper: string;
|
|
41
|
+
};
|
|
42
|
+
};
|
|
43
|
+
}, {
|
|
55
44
|
base: string;
|
|
45
|
+
cursor: string;
|
|
56
46
|
label: string;
|
|
57
|
-
wrapper: string;
|
|
58
|
-
tabList: string;
|
|
59
47
|
tab: string;
|
|
48
|
+
tabBase: string;
|
|
60
49
|
tabContent: string;
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
50
|
+
tabList: string;
|
|
51
|
+
tabPanel: string;
|
|
52
|
+
tabWrapper: string;
|
|
53
|
+
wrapper: string;
|
|
54
|
+
}, tailwind_variants.TVReturnType<{
|
|
55
|
+
hasContent: {
|
|
56
|
+
true: {
|
|
57
|
+
base: string;
|
|
58
|
+
tabBase: string;
|
|
59
|
+
tabWrapper: string[];
|
|
60
|
+
};
|
|
61
|
+
};
|
|
62
|
+
fullWidth: {
|
|
63
|
+
true: {
|
|
64
|
+
tabWrapper: string;
|
|
65
|
+
};
|
|
66
|
+
};
|
|
67
|
+
}, {
|
|
64
68
|
base: string;
|
|
69
|
+
cursor: string;
|
|
65
70
|
label: string;
|
|
66
|
-
wrapper: string;
|
|
67
|
-
tabList: string;
|
|
68
71
|
tab: string;
|
|
72
|
+
tabBase: string;
|
|
69
73
|
tabContent: string;
|
|
70
|
-
|
|
71
|
-
|
|
74
|
+
tabList: string;
|
|
75
|
+
tabPanel: string;
|
|
76
|
+
tabWrapper: string;
|
|
77
|
+
wrapper: string;
|
|
72
78
|
}, undefined, unknown, unknown, undefined>>;
|
|
73
79
|
type VariantProps = TVProps<typeof radioTabsVariants>;
|
|
74
80
|
type ClassName = TVClassName<typeof radioTabsVariants>;
|
|
@@ -86,11 +92,13 @@ interface RadioTabsOption {
|
|
|
86
92
|
/** option value */
|
|
87
93
|
value: string;
|
|
88
94
|
}
|
|
89
|
-
interface RadioTabsProps extends VariantProps {
|
|
95
|
+
interface RadioTabsProps extends Omit<VariantProps, 'hasContent'> {
|
|
90
96
|
/** CSS class name */
|
|
91
97
|
className?: ClassName;
|
|
92
98
|
/** Determines if the Buttons are disabled or not. */
|
|
93
99
|
disabled?: boolean;
|
|
100
|
+
/** Whether tabs should take up full container width */
|
|
101
|
+
fullWidth?: boolean;
|
|
94
102
|
/** determines orientation of the Buttons. */
|
|
95
103
|
inline?: boolean;
|
|
96
104
|
/** Label displayed next to the RadioButton. */
|
|
@@ -108,6 +116,6 @@ interface RadioTabsProps extends VariantProps {
|
|
|
108
116
|
* RadioTabs component based on [HeroUI RadioGroup](https://www.heroui.com//docs/components/radio-group)
|
|
109
117
|
* and [HeroUI Tabs](https://www.heroui.com//docs/components/tabs)
|
|
110
118
|
*/
|
|
111
|
-
declare const RadioTabs: ({ className, disabled, inline, label, name, options, testId: _testId, variant, }: RadioTabsProps) => ReactElement;
|
|
119
|
+
declare const RadioTabs: ({ className, disabled, fullWidth, inline, label, name, options, testId: _testId, variant, }: RadioTabsProps) => ReactElement;
|
|
112
120
|
|
|
113
121
|
export { RadioTabs as R, type RadioTabsProps as a };
|
|
@@ -18,18 +18,40 @@ var radioTabsVariants = tv({
|
|
|
18
18
|
slots: {
|
|
19
19
|
base: "group",
|
|
20
20
|
// Needs group for group-data condition
|
|
21
|
+
cursor: "",
|
|
21
22
|
label: "text-foreground group-data-[invalid=true]:text-danger text-sm subpixel-antialiased",
|
|
22
|
-
wrapper: "",
|
|
23
|
-
tabList: "",
|
|
24
23
|
tab: "",
|
|
24
|
+
tabBase: "",
|
|
25
25
|
tabContent: "",
|
|
26
|
-
|
|
27
|
-
|
|
26
|
+
tabList: "",
|
|
27
|
+
tabPanel: "p-3",
|
|
28
|
+
tabWrapper: "",
|
|
29
|
+
wrapper: ""
|
|
30
|
+
},
|
|
31
|
+
variants: {
|
|
32
|
+
hasContent: {
|
|
33
|
+
true: {
|
|
34
|
+
base: "p-1",
|
|
35
|
+
tabBase: "p-1 pb-0",
|
|
36
|
+
tabWrapper: [
|
|
37
|
+
// border style
|
|
38
|
+
"border-divider rounded-medium border",
|
|
39
|
+
// full width
|
|
40
|
+
"w-full"
|
|
41
|
+
]
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
fullWidth: {
|
|
45
|
+
true: {
|
|
46
|
+
tabWrapper: "w-full"
|
|
47
|
+
}
|
|
48
|
+
}
|
|
28
49
|
}
|
|
29
50
|
});
|
|
30
51
|
var RadioTabs = ({
|
|
31
52
|
className = void 0,
|
|
32
53
|
disabled = false,
|
|
54
|
+
fullWidth = false,
|
|
33
55
|
inline = false,
|
|
34
56
|
label = void 0,
|
|
35
57
|
name,
|
|
@@ -43,7 +65,10 @@ var RadioTabs = ({
|
|
|
43
65
|
const { disabled: isDisabled, onBlur, onChange, ref, value } = field;
|
|
44
66
|
const showTestIdCopyButton = debugMode === "debug-testids";
|
|
45
67
|
const showLabel = label != null ? label : showTestIdCopyButton;
|
|
46
|
-
const
|
|
68
|
+
const hasContent = options.some((option) => {
|
|
69
|
+
return option.content;
|
|
70
|
+
});
|
|
71
|
+
const variants = radioTabsVariants({ hasContent, fullWidth });
|
|
47
72
|
const classNames = variantsToClassNames(variants, className, "base");
|
|
48
73
|
const tabOptions = options.map((option) => {
|
|
49
74
|
var _a, _b;
|
|
@@ -64,7 +89,6 @@ var RadioTabs = ({
|
|
|
64
89
|
HeroRadioGroup,
|
|
65
90
|
{
|
|
66
91
|
ref,
|
|
67
|
-
classNames,
|
|
68
92
|
"data-invalid": invalid,
|
|
69
93
|
"data-required": required,
|
|
70
94
|
"data-testid": testId,
|
|
@@ -74,6 +98,11 @@ var RadioTabs = ({
|
|
|
74
98
|
name,
|
|
75
99
|
onBlur,
|
|
76
100
|
orientation: inline ? "horizontal" : "vertical",
|
|
101
|
+
classNames: {
|
|
102
|
+
base: classNames.base,
|
|
103
|
+
label: classNames.label,
|
|
104
|
+
wrapper: classNames.wrapper
|
|
105
|
+
},
|
|
77
106
|
errorMessage: error ? /* @__PURE__ */ jsx(FieldValidationError_default, { error, testId }) : void 0,
|
|
78
107
|
label: showLabel ? (
|
|
79
108
|
// eslint-disable-next-line jsx-a11y/label-has-associated-control
|
|
@@ -86,12 +115,20 @@ var RadioTabs = ({
|
|
|
86
115
|
Tabs,
|
|
87
116
|
{
|
|
88
117
|
disabledKeys: disabled ? disabledAllKeys : void 0,
|
|
89
|
-
fullWidth: false,
|
|
90
118
|
onSelectionChange: onChange,
|
|
91
119
|
selectedKey: value != null ? value : "",
|
|
92
120
|
tabs: tabOptions,
|
|
93
121
|
testId,
|
|
94
|
-
variant
|
|
122
|
+
variant,
|
|
123
|
+
className: {
|
|
124
|
+
base: classNames.tabBase,
|
|
125
|
+
cursor: classNames.cursor,
|
|
126
|
+
panel: classNames.tabPanel,
|
|
127
|
+
tab: classNames.tab,
|
|
128
|
+
tabContent: classNames.tabContent,
|
|
129
|
+
tabList: classNames.tabList,
|
|
130
|
+
tabWrapper: classNames.tabWrapper
|
|
131
|
+
}
|
|
95
132
|
}
|
|
96
133
|
)
|
|
97
134
|
}
|
|
@@ -106,4 +143,4 @@ export {
|
|
|
106
143
|
RadioTabs_default,
|
|
107
144
|
RadioTabs_default2
|
|
108
145
|
};
|
|
109
|
-
//# sourceMappingURL=chunk-
|
|
146
|
+
//# sourceMappingURL=chunk-JSQ77E6L.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/RadioTabs/RadioTabs.tsx","../src/RadioTabs/index.ts"],"sourcesContent":["import type { TVClassName, TVProps } from '@fuf-stack/pixel-utils';\nimport type { TabsProps } from '@fuf-stack/pixels';\nimport type { TabProps } from '@fuf-stack/pixels/Tabs';\nimport type { ReactElement, ReactNode } from 'react';\n\nimport { RadioGroup as HeroRadioGroup } from '@heroui/radio';\n\nimport { slugify, tv, variantsToClassNames } from '@fuf-stack/pixel-utils';\nimport Tabs from '@fuf-stack/pixels/Tabs';\n\nimport { useController, useFormContext } from '../hooks';\nimport { FieldCopyTestIdButton } from '../partials/FieldCopyTestIdButton';\nimport { FieldValidationError } from '../partials/FieldValidationError';\n\nexport const radioTabsVariants = tv({\n slots: {\n base: 'group', // Needs group for group-data condition\n cursor: '',\n label:\n 'text-foreground group-data-[invalid=true]:text-danger text-sm subpixel-antialiased',\n tab: '',\n tabBase: '',\n tabContent: '',\n tabList: '',\n tabPanel: 'p-3',\n tabWrapper: '',\n wrapper: '',\n },\n variants: {\n hasContent: {\n true: {\n base: 'p-1',\n tabBase: 'p-1 pb-0',\n tabWrapper: [\n // border style\n 'border-divider rounded-medium border',\n // full width\n 'w-full',\n ],\n },\n },\n fullWidth: {\n true: {\n tabWrapper: 'w-full',\n },\n },\n },\n});\n\ntype VariantProps = TVProps<typeof radioTabsVariants>;\ntype ClassName = TVClassName<typeof radioTabsVariants>;\n\nexport interface RadioTabsOption {\n /** Optional content inside of the tab */\n content?: ReactNode;\n /** disables the option */\n disabled?: boolean;\n /** option label */\n label?: React.ReactNode;\n /** option icon */\n icon?: ReactNode;\n /** HTML data-testid attribute of the option */\n testId?: string;\n /** option value */\n value: string;\n}\n\nexport interface RadioTabsProps extends Omit<VariantProps, 'hasContent'> {\n /** CSS class name */\n className?: ClassName;\n /** Determines if the Buttons are disabled or not. */\n disabled?: boolean;\n /** Whether tabs should take up full container width */\n fullWidth?: boolean;\n /** determines orientation of the Buttons. */\n inline?: boolean;\n /** Label displayed next to the RadioButton. */\n label?: ReactNode;\n /** Name the RadioButtons are registered at in HTML forms (react-hook-form). */\n name: string;\n /** Radio button configuration. */\n options: RadioTabsOption[];\n /** Id to grab element in internal tests. */\n testId?: string;\n /** How the RadioTabs should look like. */\n variant?: TabsProps['variant'];\n}\n\n/**\n * RadioTabs component based on [HeroUI RadioGroup](https://www.heroui.com//docs/components/radio-group)\n * and [HeroUI Tabs](https://www.heroui.com//docs/components/tabs)\n */\nconst RadioTabs = ({\n className = undefined,\n disabled = false,\n fullWidth = false,\n inline = false,\n label = undefined,\n name,\n options,\n testId: _testId = undefined,\n variant = undefined,\n}: RadioTabsProps): ReactElement => {\n const { control, debugMode, getFieldState } = useFormContext();\n const { error, invalid, required, testId } = getFieldState(name, _testId);\n\n const { field } = useController({ control, disabled, name });\n const { disabled: isDisabled, onBlur, onChange, ref, value } = field;\n\n const showTestIdCopyButton = debugMode === 'debug-testids';\n const showLabel = label ?? showTestIdCopyButton;\n\n // check if any option has content\n // eslint-disable-next-line @typescript-eslint/no-misused-promises, @typescript-eslint/promise-function-async\n const hasContent = options.some((option) => {\n return option.content;\n });\n\n // classNames from slots\n const variants = radioTabsVariants({ hasContent, fullWidth });\n const classNames = variantsToClassNames(variants, className, 'base');\n\n const tabOptions = options.map<TabProps>((option) => {\n return {\n content: option?.content,\n disabled: option?.disabled,\n key: option.value,\n label: option?.label ?? option?.value,\n testId: slugify(`option_${option?.testId ?? option?.value}`, {\n replaceDots: true,\n }),\n };\n });\n\n const disabledAllKeys: string[] | undefined = tabOptions?.map((option) => {\n return option.key as string;\n });\n\n return (\n <HeroRadioGroup\n ref={ref}\n // see HeroUI styles for group-data condition (data-invalid),\n // e.g.: https://github.com/heroui-inc/heroui/blob/main/packages/components/select/src/use-select.ts\n data-invalid={invalid}\n data-required={required}\n data-testid={testId}\n isDisabled={isDisabled}\n isInvalid={invalid}\n isRequired={required}\n name={name}\n onBlur={onBlur}\n orientation={inline ? 'horizontal' : 'vertical'}\n classNames={{\n base: classNames.base,\n label: classNames.label,\n wrapper: classNames.wrapper,\n }}\n errorMessage={\n error ? (\n <FieldValidationError error={error} testId={testId} />\n ) : undefined\n }\n label={\n showLabel ? (\n // eslint-disable-next-line jsx-a11y/label-has-associated-control\n <label>\n {label}\n {showTestIdCopyButton ? (\n <FieldCopyTestIdButton testId={testId} />\n ) : null}\n </label>\n ) : undefined\n }\n >\n <Tabs\n disabledKeys={disabled ? disabledAllKeys : undefined}\n onSelectionChange={onChange}\n // make sure component is controlled\n selectedKey={value ?? ''}\n tabs={tabOptions}\n testId={testId}\n variant={variant}\n className={{\n base: classNames.tabBase,\n cursor: classNames.cursor,\n panel: classNames.tabPanel,\n tab: classNames.tab,\n tabContent: classNames.tabContent,\n tabList: classNames.tabList,\n tabWrapper: classNames.tabWrapper,\n }}\n />\n </HeroRadioGroup>\n );\n};\n\nexport default RadioTabs;\n","import RadioTabs from './RadioTabs';\n\nexport type { RadioTabsProps } from './RadioTabs';\n\nexport { RadioTabs };\n\nexport default RadioTabs;\n"],"mappings":";;;;;;;;;;;;AAKA,SAAS,cAAc,sBAAsB;AAE7C,SAAS,SAAS,IAAI,4BAA4B;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A,IAAO,oBAAQ;;;AC9Lf,IAAOA,qBAAQ;","names":["RadioTabs_default"]}
|
|
@@ -18,18 +18,40 @@ var radioTabsVariants = _pixelutils.tv.call(void 0, {
|
|
|
18
18
|
slots: {
|
|
19
19
|
base: "group",
|
|
20
20
|
// Needs group for group-data condition
|
|
21
|
+
cursor: "",
|
|
21
22
|
label: "text-foreground group-data-[invalid=true]:text-danger text-sm subpixel-antialiased",
|
|
22
|
-
wrapper: "",
|
|
23
|
-
tabList: "",
|
|
24
23
|
tab: "",
|
|
24
|
+
tabBase: "",
|
|
25
25
|
tabContent: "",
|
|
26
|
-
|
|
27
|
-
|
|
26
|
+
tabList: "",
|
|
27
|
+
tabPanel: "p-3",
|
|
28
|
+
tabWrapper: "",
|
|
29
|
+
wrapper: ""
|
|
30
|
+
},
|
|
31
|
+
variants: {
|
|
32
|
+
hasContent: {
|
|
33
|
+
true: {
|
|
34
|
+
base: "p-1",
|
|
35
|
+
tabBase: "p-1 pb-0",
|
|
36
|
+
tabWrapper: [
|
|
37
|
+
// border style
|
|
38
|
+
"border-divider rounded-medium border",
|
|
39
|
+
// full width
|
|
40
|
+
"w-full"
|
|
41
|
+
]
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
fullWidth: {
|
|
45
|
+
true: {
|
|
46
|
+
tabWrapper: "w-full"
|
|
47
|
+
}
|
|
48
|
+
}
|
|
28
49
|
}
|
|
29
50
|
});
|
|
30
51
|
var RadioTabs = ({
|
|
31
52
|
className = void 0,
|
|
32
53
|
disabled = false,
|
|
54
|
+
fullWidth = false,
|
|
33
55
|
inline = false,
|
|
34
56
|
label = void 0,
|
|
35
57
|
name,
|
|
@@ -43,7 +65,10 @@ var RadioTabs = ({
|
|
|
43
65
|
const { disabled: isDisabled, onBlur, onChange, ref, value } = field;
|
|
44
66
|
const showTestIdCopyButton = debugMode === "debug-testids";
|
|
45
67
|
const showLabel = label != null ? label : showTestIdCopyButton;
|
|
46
|
-
const
|
|
68
|
+
const hasContent = options.some((option) => {
|
|
69
|
+
return option.content;
|
|
70
|
+
});
|
|
71
|
+
const variants = radioTabsVariants({ hasContent, fullWidth });
|
|
47
72
|
const classNames = _pixelutils.variantsToClassNames.call(void 0, variants, className, "base");
|
|
48
73
|
const tabOptions = options.map((option) => {
|
|
49
74
|
var _a, _b;
|
|
@@ -64,7 +89,6 @@ var RadioTabs = ({
|
|
|
64
89
|
_radio.RadioGroup,
|
|
65
90
|
{
|
|
66
91
|
ref,
|
|
67
|
-
classNames,
|
|
68
92
|
"data-invalid": invalid,
|
|
69
93
|
"data-required": required,
|
|
70
94
|
"data-testid": testId,
|
|
@@ -74,6 +98,11 @@ var RadioTabs = ({
|
|
|
74
98
|
name,
|
|
75
99
|
onBlur,
|
|
76
100
|
orientation: inline ? "horizontal" : "vertical",
|
|
101
|
+
classNames: {
|
|
102
|
+
base: classNames.base,
|
|
103
|
+
label: classNames.label,
|
|
104
|
+
wrapper: classNames.wrapper
|
|
105
|
+
},
|
|
77
106
|
errorMessage: error ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkY3AB4GV6cjs.FieldValidationError_default, { error, testId }) : void 0,
|
|
78
107
|
label: showLabel ? (
|
|
79
108
|
// eslint-disable-next-line jsx-a11y/label-has-associated-control
|
|
@@ -86,12 +115,20 @@ var RadioTabs = ({
|
|
|
86
115
|
_Tabs2.default,
|
|
87
116
|
{
|
|
88
117
|
disabledKeys: disabled ? disabledAllKeys : void 0,
|
|
89
|
-
fullWidth: false,
|
|
90
118
|
onSelectionChange: onChange,
|
|
91
119
|
selectedKey: value != null ? value : "",
|
|
92
120
|
tabs: tabOptions,
|
|
93
121
|
testId,
|
|
94
|
-
variant
|
|
122
|
+
variant,
|
|
123
|
+
className: {
|
|
124
|
+
base: classNames.tabBase,
|
|
125
|
+
cursor: classNames.cursor,
|
|
126
|
+
panel: classNames.tabPanel,
|
|
127
|
+
tab: classNames.tab,
|
|
128
|
+
tabContent: classNames.tabContent,
|
|
129
|
+
tabList: classNames.tabList,
|
|
130
|
+
tabWrapper: classNames.tabWrapper
|
|
131
|
+
}
|
|
95
132
|
}
|
|
96
133
|
)
|
|
97
134
|
}
|
|
@@ -106,4 +143,4 @@ var RadioTabs_default2 = RadioTabs_default;
|
|
|
106
143
|
|
|
107
144
|
|
|
108
145
|
exports.RadioTabs_default = RadioTabs_default; exports.RadioTabs_default2 = RadioTabs_default2;
|
|
109
|
-
//# sourceMappingURL=chunk-
|
|
146
|
+
//# sourceMappingURL=chunk-ORQO6JXK.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/home/runner/work/pixels/pixels/packages/uniform/dist/chunk-ORQO6JXK.cjs","../src/RadioTabs/RadioTabs.tsx","../src/RadioTabs/index.ts"],"names":[],"mappings":"AAAA;AACE;AACF,wDAA6B;AAC7B;AACE;AACF,wDAA6B;AAC7B;AACE;AACA;AACF,wDAA6B;AAC7B;AACA;ACNA,sCAA6C;AAE7C,oDAAkD;AAClD,0FAAiB;AAuJP,+CAAA;AAjJH,IAAM,kBAAA,EAAoB,4BAAA;AAAG,EAClC,KAAA,EAAO;AAAA,IACL,IAAA,EAAM,OAAA;AAAA;AAAA,IACN,MAAA,EAAQ,EAAA;AAAA,IACR,KAAA,EACE,oFAAA;AAAA,IACF,GAAA,EAAK,EAAA;AAAA,IACL,OAAA,EAAS,EAAA;AAAA,IACT,UAAA,EAAY,EAAA;AAAA,IACZ,OAAA,EAAS,EAAA;AAAA,IACT,QAAA,EAAU,KAAA;AAAA,IACV,UAAA,EAAY,EAAA;AAAA,IACZ,OAAA,EAAS;AAAA,EACX,CAAA;AAAA,EACA,QAAA,EAAU;AAAA,IACR,UAAA,EAAY;AAAA,MACV,IAAA,EAAM;AAAA,QACJ,IAAA,EAAM,KAAA;AAAA,QACN,OAAA,EAAS,UAAA;AAAA,QACT,UAAA,EAAY;AAAA;AAAA,UAEV,sCAAA;AAAA;AAAA,UAEA;AAAA,QACF;AAAA,MACF;AAAA,IACF,CAAA;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AAC,QAAA;AAAA,QAAA;AAC4C,UAAA;AACxB,UAAA;AAEG,UAAA;AAChB,UAAA;AACN,UAAA;AACA,UAAA;AACW,UAAA;AACQ,YAAA;AACE,YAAA;AACD,YAAA;AACF,YAAA;AACO,YAAA;AACH,YAAA;AACG,YAAA;AACzB,UAAA;AAAA,QAAA;AACF,MAAA;AAAA,IAAA;AACF,EAAA;AAEJ;AAEe;AD3DsH;AACA;AEpItH;AFsIsH;AACA;AACA;AACA;AACA","file":"/home/runner/work/pixels/pixels/packages/uniform/dist/chunk-ORQO6JXK.cjs","sourcesContent":[null,"import type { TVClassName, TVProps } from '@fuf-stack/pixel-utils';\nimport type { TabsProps } from '@fuf-stack/pixels';\nimport type { TabProps } from '@fuf-stack/pixels/Tabs';\nimport type { ReactElement, ReactNode } from 'react';\n\nimport { RadioGroup as HeroRadioGroup } from '@heroui/radio';\n\nimport { slugify, tv, variantsToClassNames } from '@fuf-stack/pixel-utils';\nimport Tabs from '@fuf-stack/pixels/Tabs';\n\nimport { useController, useFormContext } from '../hooks';\nimport { FieldCopyTestIdButton } from '../partials/FieldCopyTestIdButton';\nimport { FieldValidationError } from '../partials/FieldValidationError';\n\nexport const radioTabsVariants = tv({\n slots: {\n base: 'group', // Needs group for group-data condition\n cursor: '',\n label:\n 'text-foreground group-data-[invalid=true]:text-danger text-sm subpixel-antialiased',\n tab: '',\n tabBase: '',\n tabContent: '',\n tabList: '',\n tabPanel: 'p-3',\n tabWrapper: '',\n wrapper: '',\n },\n variants: {\n hasContent: {\n true: {\n base: 'p-1',\n tabBase: 'p-1 pb-0',\n tabWrapper: [\n // border style\n 'border-divider rounded-medium border',\n // full width\n 'w-full',\n ],\n },\n },\n fullWidth: {\n true: {\n tabWrapper: 'w-full',\n },\n },\n },\n});\n\ntype VariantProps = TVProps<typeof radioTabsVariants>;\ntype ClassName = TVClassName<typeof radioTabsVariants>;\n\nexport interface RadioTabsOption {\n /** Optional content inside of the tab */\n content?: ReactNode;\n /** disables the option */\n disabled?: boolean;\n /** option label */\n label?: React.ReactNode;\n /** option icon */\n icon?: ReactNode;\n /** HTML data-testid attribute of the option */\n testId?: string;\n /** option value */\n value: string;\n}\n\nexport interface RadioTabsProps extends Omit<VariantProps, 'hasContent'> {\n /** CSS class name */\n className?: ClassName;\n /** Determines if the Buttons are disabled or not. */\n disabled?: boolean;\n /** Whether tabs should take up full container width */\n fullWidth?: boolean;\n /** determines orientation of the Buttons. */\n inline?: boolean;\n /** Label displayed next to the RadioButton. */\n label?: ReactNode;\n /** Name the RadioButtons are registered at in HTML forms (react-hook-form). */\n name: string;\n /** Radio button configuration. */\n options: RadioTabsOption[];\n /** Id to grab element in internal tests. */\n testId?: string;\n /** How the RadioTabs should look like. */\n variant?: TabsProps['variant'];\n}\n\n/**\n * RadioTabs component based on [HeroUI RadioGroup](https://www.heroui.com//docs/components/radio-group)\n * and [HeroUI Tabs](https://www.heroui.com//docs/components/tabs)\n */\nconst RadioTabs = ({\n className = undefined,\n disabled = false,\n fullWidth = false,\n inline = false,\n label = undefined,\n name,\n options,\n testId: _testId = undefined,\n variant = undefined,\n}: RadioTabsProps): ReactElement => {\n const { control, debugMode, getFieldState } = useFormContext();\n const { error, invalid, required, testId } = getFieldState(name, _testId);\n\n const { field } = useController({ control, disabled, name });\n const { disabled: isDisabled, onBlur, onChange, ref, value } = field;\n\n const showTestIdCopyButton = debugMode === 'debug-testids';\n const showLabel = label ?? showTestIdCopyButton;\n\n // check if any option has content\n // eslint-disable-next-line @typescript-eslint/no-misused-promises, @typescript-eslint/promise-function-async\n const hasContent = options.some((option) => {\n return option.content;\n });\n\n // classNames from slots\n const variants = radioTabsVariants({ hasContent, fullWidth });\n const classNames = variantsToClassNames(variants, className, 'base');\n\n const tabOptions = options.map<TabProps>((option) => {\n return {\n content: option?.content,\n disabled: option?.disabled,\n key: option.value,\n label: option?.label ?? option?.value,\n testId: slugify(`option_${option?.testId ?? option?.value}`, {\n replaceDots: true,\n }),\n };\n });\n\n const disabledAllKeys: string[] | undefined = tabOptions?.map((option) => {\n return option.key as string;\n });\n\n return (\n <HeroRadioGroup\n ref={ref}\n // see HeroUI styles for group-data condition (data-invalid),\n // e.g.: https://github.com/heroui-inc/heroui/blob/main/packages/components/select/src/use-select.ts\n data-invalid={invalid}\n data-required={required}\n data-testid={testId}\n isDisabled={isDisabled}\n isInvalid={invalid}\n isRequired={required}\n name={name}\n onBlur={onBlur}\n orientation={inline ? 'horizontal' : 'vertical'}\n classNames={{\n base: classNames.base,\n label: classNames.label,\n wrapper: classNames.wrapper,\n }}\n errorMessage={\n error ? (\n <FieldValidationError error={error} testId={testId} />\n ) : undefined\n }\n label={\n showLabel ? (\n // eslint-disable-next-line jsx-a11y/label-has-associated-control\n <label>\n {label}\n {showTestIdCopyButton ? (\n <FieldCopyTestIdButton testId={testId} />\n ) : null}\n </label>\n ) : undefined\n }\n >\n <Tabs\n disabledKeys={disabled ? disabledAllKeys : undefined}\n onSelectionChange={onChange}\n // make sure component is controlled\n selectedKey={value ?? ''}\n tabs={tabOptions}\n testId={testId}\n variant={variant}\n className={{\n base: classNames.tabBase,\n cursor: classNames.cursor,\n panel: classNames.tabPanel,\n tab: classNames.tab,\n tabContent: classNames.tabContent,\n tabList: classNames.tabList,\n tabWrapper: classNames.tabWrapper,\n }}\n />\n </HeroRadioGroup>\n );\n};\n\nexport default RadioTabs;\n","import RadioTabs from './RadioTabs';\n\nexport type { RadioTabsProps } from './RadioTabs';\n\nexport { RadioTabs };\n\nexport default RadioTabs;\n"]}
|
package/dist/index.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _chunkORQO6JXKcjs = require('./chunk-ORQO6JXK.cjs');
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
var _chunkAYNTZPKLcjs = require('./chunk-AYNTZPKL.cjs');
|
|
@@ -88,5 +88,5 @@ require('./chunk-555JRYCS.cjs');
|
|
|
88
88
|
|
|
89
89
|
|
|
90
90
|
|
|
91
|
-
exports.CheckboxGroup = _chunkN2EEOWEPcjs.CheckboxGroup_default; exports.FieldArray = _chunkJZF4HUYOcjs.FieldArray_default; exports.FieldCopyTestIdButton = _chunkOE5BOGGXcjs.FieldCopyTestIdButton_default; exports.FieldValidationError = _chunkY3AB4GV6cjs.FieldValidationError_default; exports.Form = _chunkFOVP54XPcjs.Form_default; exports.Grid = _chunkTTD3KL6Ecjs.Grid_default; exports.Input = _chunk77C6VN4Lcjs.Input_default; exports.RadioBoxes = _chunkULR4573Wcjs.RadioBoxes_default; exports.RadioGroup = _chunkEEBHFSBYcjs.RadioGroup_default; exports.RadioTabs =
|
|
91
|
+
exports.CheckboxGroup = _chunkN2EEOWEPcjs.CheckboxGroup_default; exports.FieldArray = _chunkJZF4HUYOcjs.FieldArray_default; exports.FieldCopyTestIdButton = _chunkOE5BOGGXcjs.FieldCopyTestIdButton_default; exports.FieldValidationError = _chunkY3AB4GV6cjs.FieldValidationError_default; exports.Form = _chunkFOVP54XPcjs.Form_default; exports.Grid = _chunkTTD3KL6Ecjs.Grid_default; exports.Input = _chunk77C6VN4Lcjs.Input_default; exports.RadioBoxes = _chunkULR4573Wcjs.RadioBoxes_default; exports.RadioGroup = _chunkEEBHFSBYcjs.RadioGroup_default; exports.RadioTabs = _chunkORQO6JXKcjs.RadioTabs_default; exports.Select = _chunkAYNTZPKLcjs.Select_default; exports.SubmitButton = _chunkC64RKQEWcjs.SubmitButton_default; exports.Switch = _chunkUGCZORU3cjs.Switch_default; exports.TextArea = _chunkRDBCJJI7cjs.TextArea_default; exports.checkFieldIsRequired = _chunk2GYFDVXXcjs.checkFieldIsRequired; exports.fromNullishString = _chunkYGNY6CKUcjs.fromNullishString; exports.toFormFormat = _chunkYGNY6CKUcjs.toFormFormat; exports.toNullishString = _chunkYGNY6CKUcjs.toNullishString; exports.toValidationFormat = _chunkYGNY6CKUcjs.toValidationFormat; exports.useClientValidation = _chunk2GYFDVXXcjs.useClientValidation; exports.useController = _chunk2GYFDVXXcjs.useController; exports.useFieldArray = _chunk2GYFDVXXcjs.useFieldArray; exports.useFormContext = _chunk2GYFDVXXcjs.useFormContext; exports.useInput = _chunk2GYFDVXXcjs.useInput; exports.useInputValueDebounce = _chunkFLK6OPFYcjs.useInputValueDebounce; exports.useInputValueTransform = _chunkP6HJOG7Dcjs.useInputValueTransform;
|
|
92
92
|
//# sourceMappingURL=index.cjs.map
|
package/dist/index.d.cts
CHANGED
|
@@ -13,7 +13,7 @@ export { F as FieldCopyTestIdButton, a as FieldCopyTestIdButtonProps } from './F
|
|
|
13
13
|
export { F as FieldValidationError, a as FieldValidationErrorProps } from './FieldValidationError-CU_xw0BL.cjs';
|
|
14
14
|
export { R as RadioBoxes, a as RadioBoxesProps } from './RadioBoxes-CE3mYoFk.cjs';
|
|
15
15
|
export { R as RadioGroup, a as RadioGroupProps } from './RadioGroup-CAOX80Xx.cjs';
|
|
16
|
-
export { R as RadioTabs, a as RadioTabsProps } from './RadioTabs-
|
|
16
|
+
export { R as RadioTabs, a as RadioTabsProps } from './RadioTabs-BCWW3tru.cjs';
|
|
17
17
|
export { S as Select, a as SelectProps } from './Select-CTRWinmO.cjs';
|
|
18
18
|
export { S as SubmitButton, a as SubmitButtonProps } from './SubmitButton-DqaxyVpp.cjs';
|
|
19
19
|
export { S as Switch, a as SwitchProps } from './Switch-Hr6PnK98.cjs';
|
package/dist/index.d.ts
CHANGED
|
@@ -13,7 +13,7 @@ export { F as FieldCopyTestIdButton, a as FieldCopyTestIdButtonProps } from './F
|
|
|
13
13
|
export { F as FieldValidationError, a as FieldValidationErrorProps } from './FieldValidationError-CU_xw0BL.js';
|
|
14
14
|
export { R as RadioBoxes, a as RadioBoxesProps } from './RadioBoxes-CE3mYoFk.js';
|
|
15
15
|
export { R as RadioGroup, a as RadioGroupProps } from './RadioGroup-CAOX80Xx.js';
|
|
16
|
-
export { R as RadioTabs, a as RadioTabsProps } from './RadioTabs-
|
|
16
|
+
export { R as RadioTabs, a as RadioTabsProps } from './RadioTabs-BCWW3tru.js';
|
|
17
17
|
export { S as Select, a as SelectProps } from './Select-CTRWinmO.js';
|
|
18
18
|
export { S as SubmitButton, a as SubmitButtonProps } from './SubmitButton-DqaxyVpp.js';
|
|
19
19
|
export { S as Switch, a as SwitchProps } from './Switch-Hr6PnK98.js';
|
package/dist/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fuf-stack/uniform",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.4.1",
|
|
4
4
|
"description": "fuf react form library",
|
|
5
5
|
"author": "Fröhlich ∧ Frei",
|
|
6
6
|
"homepage": "https://github.com/fuf-stack/pixels#readme",
|
|
@@ -138,18 +138,18 @@
|
|
|
138
138
|
"@heroui/switch": "2.2.22",
|
|
139
139
|
"@heroui/system": "2.4.20",
|
|
140
140
|
"@heroui/theme": "2.4.20",
|
|
141
|
-
"@react-aria/visually-hidden": "3.8.
|
|
141
|
+
"@react-aria/visually-hidden": "3.8.28",
|
|
142
142
|
"framer-motion": "12.23.22",
|
|
143
143
|
"react-icons": "5.5.0",
|
|
144
144
|
"react-hook-form": "7.55.0",
|
|
145
145
|
"react-select": "5.10.2",
|
|
146
146
|
"@fuf-stack/pixels": "1.3.6",
|
|
147
|
-
"@fuf-stack/
|
|
148
|
-
"@fuf-stack/
|
|
147
|
+
"@fuf-stack/pixel-utils": "1.0.5",
|
|
148
|
+
"@fuf-stack/veto": "0.12.6"
|
|
149
149
|
},
|
|
150
150
|
"devDependencies": {
|
|
151
151
|
"@types/debug": "4.1.12",
|
|
152
|
-
"@types/react": "19.1.
|
|
152
|
+
"@types/react": "19.1.16",
|
|
153
153
|
"@types/react-dom": "19.1.9",
|
|
154
154
|
"react": "19.1.1",
|
|
155
155
|
"react-dom": "19.1.1"
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/RadioTabs/RadioTabs.tsx","../src/RadioTabs/index.ts"],"sourcesContent":["import type { TVClassName, TVProps } from '@fuf-stack/pixel-utils';\nimport type { TabsProps } from '@fuf-stack/pixels';\nimport type { TabProps } from '@fuf-stack/pixels/Tabs';\nimport type { ReactElement, ReactNode } from 'react';\n\nimport { RadioGroup as HeroRadioGroup } from '@heroui/radio';\n\nimport { slugify, tv, variantsToClassNames } from '@fuf-stack/pixel-utils';\nimport Tabs from '@fuf-stack/pixels/Tabs';\n\nimport { useController, useFormContext } from '../hooks';\nimport { FieldCopyTestIdButton } from '../partials/FieldCopyTestIdButton';\nimport { FieldValidationError } from '../partials/FieldValidationError';\n\nexport const radioTabsVariants = tv({\n slots: {\n base: 'group', // Needs group for group-data condition\n label:\n 'text-foreground group-data-[invalid=true]:text-danger text-sm subpixel-antialiased',\n wrapper: '',\n tabList: '',\n tab: '',\n tabContent: '',\n cursor: '',\n panel: '',\n },\n});\n\ntype VariantProps = TVProps<typeof radioTabsVariants>;\ntype ClassName = TVClassName<typeof radioTabsVariants>;\n\nexport interface RadioTabsOption {\n /** Optional content inside of the tab */\n content?: ReactNode;\n /** disables the option */\n disabled?: boolean;\n /** option label */\n label?: React.ReactNode;\n /** option icon */\n icon?: ReactNode;\n /** HTML data-testid attribute of the option */\n testId?: string;\n /** option value */\n value: string;\n}\n\nexport interface RadioTabsProps extends VariantProps {\n /** CSS class name */\n className?: ClassName;\n /** Determines if the Buttons are disabled or not. */\n disabled?: boolean;\n /** determines orientation of the Buttons. */\n inline?: boolean;\n /** Label displayed next to the RadioButton. */\n label?: ReactNode;\n /** Name the RadioButtons are registered at in HTML forms (react-hook-form). */\n name: string;\n /** Radio button configuration. */\n options: RadioTabsOption[];\n /** Id to grab element in internal tests. */\n testId?: string;\n /** How the RadioTabs should look like. */\n variant?: TabsProps['variant'];\n}\n\n/**\n * RadioTabs component based on [HeroUI RadioGroup](https://www.heroui.com//docs/components/radio-group)\n * and [HeroUI Tabs](https://www.heroui.com//docs/components/tabs)\n */\nconst RadioTabs = ({\n className = undefined,\n disabled = false,\n inline = false,\n label = undefined,\n name,\n options,\n testId: _testId = undefined,\n variant = undefined,\n}: RadioTabsProps): ReactElement => {\n const { control, debugMode, getFieldState } = useFormContext();\n const { error, invalid, required, testId } = getFieldState(name, _testId);\n\n const { field } = useController({ control, disabled, name });\n const { disabled: isDisabled, onBlur, onChange, ref, value } = field;\n\n const showTestIdCopyButton = debugMode === 'debug-testids';\n const showLabel = label ?? showTestIdCopyButton;\n\n const variants = radioTabsVariants();\n const classNames = variantsToClassNames(variants, className, 'base');\n\n const tabOptions = options.map<TabProps>((option) => {\n return {\n content: option?.content,\n disabled: option?.disabled,\n key: option.value,\n label: option?.label ?? option?.value,\n testId: slugify(`option_${option?.testId ?? option?.value}`, {\n replaceDots: true,\n }),\n };\n });\n\n const disabledAllKeys: string[] | undefined = tabOptions?.map((option) => {\n return option.key as string;\n });\n\n return (\n <HeroRadioGroup\n ref={ref}\n classNames={classNames}\n // see HeroUI styles for group-data condition (data-invalid),\n // e.g.: https://github.com/heroui-inc/heroui/blob/main/packages/components/select/src/use-select.ts\n data-invalid={invalid}\n data-required={required}\n data-testid={testId}\n isDisabled={isDisabled}\n isInvalid={invalid}\n isRequired={required}\n name={name}\n onBlur={onBlur}\n orientation={inline ? 'horizontal' : 'vertical'}\n errorMessage={\n error ? (\n <FieldValidationError error={error} testId={testId} />\n ) : undefined\n }\n label={\n showLabel ? (\n // eslint-disable-next-line jsx-a11y/label-has-associated-control\n <label>\n {label}\n {showTestIdCopyButton ? (\n <FieldCopyTestIdButton testId={testId} />\n ) : null}\n </label>\n ) : undefined\n }\n >\n <Tabs\n disabledKeys={disabled ? disabledAllKeys : undefined}\n fullWidth={false}\n onSelectionChange={onChange}\n // make sure component is controlled\n selectedKey={value ?? ''}\n tabs={tabOptions}\n testId={testId}\n variant={variant}\n />\n </HeroRadioGroup>\n );\n};\n\nexport default RadioTabs;\n","import RadioTabs from './RadioTabs';\n\nexport type { Radio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,IACH;AAAA,EACF,CAAC;AAED,QAAM,kBAAwC,yCAAY,IAAI,CAAC,WAAW;AACxE,WAAO,OAAO;AAAA,EAChB;AAEA,SACE;AAAA,IAAC;AAAA;AAAA,MACC;AAAA,MACA;AAAA,MAGA,gBAAc;AAAA,MACd,iBAAe;AAAA,MACf,eAAa;AAAA,MACb;AAAA,MACA,WAAW;AAAA,MACX,YAAY;AAAA,MACZ;AAAA,MACA;AAAA,MACA,aAAa,SAAS,eAAe;AAAA,MACrC,cACE,QACE,oBAAC,gCAAqB,OAAc,QAAgB,IAClD;AAAA,MAEN,OACE;AAAA;AAAA,QAEE,qBAAC,WACE;AAAA;AAAA,UACA,uBACC,oBAAC,iCAAsB,QAAgB,IACrC;AAAA,WACN;AAAA,UACE;AAAA,MAGN;AAAA,QAAC;AAAA;AAAA,UACC,cAAc,WAAW,kBAAkB;AAAA,UAC3C,WAAW;AAAA,UACX,mBAAmB;AAAA,UAEnB,aAAa,wBAAS;AAAA,UACtB,MAAM;AAAA,UACN;AAAA,UACA;AAAA;AAAA,MACF;AAAA;AAAA,EACF;AAEJ;AAEA,IAAO,oBAAQ;;;ACnJf,IAAOA,qBAAQ;","names":["RadioTabs_default"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["/home/runner/work/pixels/pixels/packages/uniform/dist/chunk-VPTOKYJG.cjs","../src/RadioTabs/RadioTabs.tsx","../src/RadioTabs/index.ts"],"names":[],"mappings":"AAAA;AACE;AACF,wDAA6B;AAC7B;AACE;AACF,wDAA6B;AAC7B;AACE;AACA;AACF,wDAA6B;AAC7B;AACA;ACNA,sCAA6C;AAE7C,oDAAkD;AAClD,0FAAiB;AAoHP,+CAAA;AA9GH,IAAM,kBAAA,EAAoB,4BAAA;AAAG,EAClC,KAAA,EAAO;AAAA,IACL,IAAA,EAAM,OAAA;AAAA;AAAA,IACN,KAAA,EACE,oFAAA;AAAA,IACF,OAAA,EAAS,EAAA;AAAA,IACT,OAAA,EAAS,E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runner/work/pixels/pixels/packages/uniform/dist/chunk-VPTOKYJG.cjs","sourcesContent":[null,"import type { TVClassName, TVProps } from '@fuf-stack/pixel-utils';\nimport type { TabsProps } from '@fuf-stack/pixels';\nimport type { TabProps } from '@fuf-stack/pixels/Tabs';\nimport type { ReactElement, ReactNode } from 'react';\n\nimport { RadioGroup as HeroRadioGroup } from '@heroui/radio';\n\nimport { slugify, tv, variantsToClassNames } from '@fuf-stack/pixel-utils';\nimport Tabs from '@fuf-stack/pixels/Tabs';\n\nimport { useController, useFormContext } from '../hooks';\nimport { FieldCopyTestIdButton } from '../partials/FieldCopyTestIdButton';\nimport { FieldValidationError } from '../partials/FieldValidationError';\n\nexport const radioTabsVariants = tv({\n slots: {\n base: 'group', // Needs group for group-data condition\n label:\n 'text-foreground group-data-[invalid=true]:text-danger text-sm subpixel-antialiased',\n wrapper: '',\n tabList: '',\n tab: '',\n tabContent: '',\n cursor: '',\n panel: '',\n },\n});\n\ntype VariantProps = TVProps<typeof radioTabsVariants>;\ntype ClassName = TVClassName<typeof radioTabsVariants>;\n\nexport interface RadioTabsOption {\n /** Optional content inside of the tab */\n content?: ReactNode;\n /** disables the option */\n disabled?: boolean;\n /** option label */\n label?: React.ReactNode;\n /** option icon */\n icon?: ReactNode;\n /** HTML data-testid attribute of the option */\n testId?: string;\n /** option value */\n value: string;\n}\n\nexport interface RadioTabsProps extends VariantProps {\n /** CSS class name */\n className?: ClassName;\n /** Determines if the Buttons are disabled or not. */\n disabled?: boolean;\n /** determines orientation of the Buttons. */\n inline?: boolean;\n /** Label displayed next to the RadioButton. */\n label?: ReactNode;\n /** Name the RadioButtons are registered at in HTML forms (react-hook-form). */\n name: string;\n /** Radio button configuration. */\n options: RadioTabsOption[];\n /** Id to grab element in internal tests. */\n testId?: string;\n /** How the RadioTabs should look like. */\n variant?: TabsProps['variant'];\n}\n\n/**\n * RadioTabs component based on [HeroUI RadioGroup](https://www.heroui.com//docs/components/radio-group)\n * and [HeroUI Tabs](https://www.heroui.com//docs/components/tabs)\n */\nconst RadioTabs = ({\n className = undefined,\n disabled = false,\n inline = false,\n label = undefined,\n name,\n options,\n testId: _testId = undefined,\n variant = undefined,\n}: RadioTabsProps): ReactElement => {\n const { control, debugMode, getFieldState } = useFormContext();\n const { error, invalid, required, testId } = getFieldState(name, _testId);\n\n const { field } = useController({ control, disabled, name });\n const { disabled: isDisabled, onBlur, onChange, ref, value } = field;\n\n const showTestIdCopyButton = debugMode === 'debug-testids';\n const showLabel = label ?? showTestIdCopyButton;\n\n const variants = radioTabsVariants();\n const classNames = variantsToClassNames(variants, className, 'base');\n\n const tabOptions = options.map<TabProps>((option) => {\n return {\n content: option?.content,\n disabled: option?.disabled,\n key: option.value,\n label: option?.label ?? option?.value,\n testId: slugify(`option_${option?.testId ?? option?.value}`, {\n replaceDots: true,\n }),\n };\n });\n\n const disabledAllKeys: string[] | undefined = tabOptions?.map((option) => {\n return option.key as string;\n });\n\n return (\n <HeroRadioGroup\n ref={ref}\n classNames={classNames}\n // see HeroUI styles for group-data condition (data-invalid),\n // e.g.: https://github.com/heroui-inc/heroui/blob/main/packages/components/select/src/use-select.ts\n data-invalid={invalid}\n data-required={required}\n data-testid={testId}\n isDisabled={isDisabled}\n isInvalid={invalid}\n isRequired={required}\n name={name}\n onBlur={onBlur}\n orientation={inline ? 'horizontal' : 'vertical'}\n errorMessage={\n error ? (\n <FieldValidationError error={error} testId={testId} />\n ) : undefined\n }\n label={\n showLabel ? (\n // eslint-disable-next-line jsx-a11y/label-has-associated-control\n <label>\n {label}\n {showTestIdCopyButton ? (\n <FieldCopyTestIdButton testId={testId} />\n ) : null}\n </label>\n ) : undefined\n }\n >\n <Tabs\n disabledKeys={disabled ? disabledAllKeys : undefined}\n fullWidth={false}\n onSelectionChange={onChange}\n // make sure component is controlled\n selectedKey={value ?? ''}\n tabs={tabOptions}\n testId={testId}\n variant={variant}\n />\n </HeroRadioGroup>\n );\n};\n\nexport default RadioTabs;\n","import RadioTabs from './RadioTabs';\n\nexport type { RadioTabsProps } from './RadioTabs';\n\nexport { RadioTabs };\n\nexport default RadioTabs;\n"]}
|