@fuf-stack/uniform 0.9.5 → 0.9.7
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/CheckboxGroup/index.cjs +3 -3
- package/dist/CheckboxGroup/index.d.cts +5 -2
- package/dist/CheckboxGroup/index.d.ts +5 -2
- package/dist/CheckboxGroup/index.js +2 -2
- package/dist/CheckboxGroup-o-qWkWe1.d.cts +130 -0
- package/dist/CheckboxGroup-o-qWkWe1.d.ts +130 -0
- package/dist/FieldArray/index.cjs +3 -3
- package/dist/FieldArray/index.js +2 -2
- package/dist/{FieldValidationError-BSXedjCA.d.cts → FieldValidationError-DAT12Ess.d.cts} +2 -1
- package/dist/{FieldValidationError-BSXedjCA.d.ts → FieldValidationError-DAT12Ess.d.ts} +2 -1
- package/dist/Input/index.cjs +3 -3
- package/dist/Input/index.js +2 -2
- package/dist/RadioGroup/index.cjs +3 -3
- package/dist/RadioGroup/index.d.cts +5 -2
- package/dist/RadioGroup/index.d.ts +5 -2
- package/dist/RadioGroup/index.js +2 -2
- package/dist/RadioGroup-D_kiBt0M.d.cts +162 -0
- package/dist/RadioGroup-D_kiBt0M.d.ts +162 -0
- package/dist/Select/index.cjs +3 -3
- package/dist/Select/index.d.cts +3 -3
- package/dist/Select/index.d.ts +3 -3
- package/dist/Select/index.js +2 -2
- package/dist/Select-BhS4z0Pj.d.cts +317 -0
- package/dist/Select-BhS4z0Pj.d.ts +317 -0
- package/dist/Switch/index.cjs +3 -3
- package/dist/Switch/index.d.cts +5 -2
- package/dist/Switch/index.d.ts +5 -2
- package/dist/Switch/index.js +2 -2
- package/dist/Switch-Fdldj8LV.d.cts +126 -0
- package/dist/Switch-Fdldj8LV.d.ts +126 -0
- package/dist/TextArea/index.cjs +3 -3
- package/dist/TextArea/index.js +2 -2
- package/dist/{chunk-OCR2UWG2.cjs → chunk-4RTJ5XR2.cjs} +3 -3
- package/dist/{chunk-OCR2UWG2.cjs.map → chunk-4RTJ5XR2.cjs.map} +1 -1
- package/dist/{chunk-FMQNL3RT.js → chunk-F7GG67YU.js} +2 -2
- package/dist/{chunk-W24WP5YE.cjs → chunk-HFMFDBEV.cjs} +46 -14
- package/dist/chunk-HFMFDBEV.cjs.map +1 -0
- package/dist/{chunk-NHPQEYYN.js → chunk-HOCRJOEU.js} +2 -2
- package/dist/{chunk-TNELIBCV.cjs → chunk-JDRMKZ35.cjs} +4 -4
- package/dist/{chunk-TNELIBCV.cjs.map → chunk-JDRMKZ35.cjs.map} +1 -1
- package/dist/{chunk-4AHVJWTB.js → chunk-JG5VQZ4V.js} +46 -14
- package/dist/chunk-JG5VQZ4V.js.map +1 -0
- package/dist/{chunk-5UHHZ7KY.cjs → chunk-JRFKYVXY.cjs} +3 -3
- package/dist/{chunk-5UHHZ7KY.cjs.map → chunk-JRFKYVXY.cjs.map} +1 -1
- package/dist/chunk-LDW7K7LW.js +231 -0
- package/dist/chunk-LDW7K7LW.js.map +1 -0
- package/dist/{chunk-INTLZONV.cjs → chunk-NQ4JZ7AK.cjs} +37 -15
- package/dist/chunk-NQ4JZ7AK.cjs.map +1 -0
- package/dist/{chunk-QVBZ5RLN.cjs → chunk-NXTXKBTP.cjs} +104 -113
- package/dist/chunk-NXTXKBTP.cjs.map +1 -0
- package/dist/{chunk-QTL5FREE.cjs → chunk-OHJYXA6R.cjs} +7 -5
- package/dist/chunk-OHJYXA6R.cjs.map +1 -0
- package/dist/{chunk-YUAJN6HW.cjs → chunk-PAX2HXPK.cjs} +54 -19
- package/dist/chunk-PAX2HXPK.cjs.map +1 -0
- package/dist/{chunk-AVKEYJH7.js → chunk-PFX4YRWI.js} +38 -16
- package/dist/chunk-PFX4YRWI.js.map +1 -0
- package/dist/{chunk-DTSX7YON.js → chunk-SCTH3FAO.js} +2 -2
- package/dist/{chunk-ARUVDZFG.js → chunk-VZFPQ6ZZ.js} +54 -19
- package/dist/chunk-VZFPQ6ZZ.js.map +1 -0
- package/dist/{chunk-DBLODROX.js → chunk-WKM2D7LF.js} +7 -5
- package/dist/chunk-WKM2D7LF.js.map +1 -0
- package/dist/index.cjs +9 -9
- package/dist/index.d.cts +8 -8
- package/dist/index.d.ts +8 -8
- package/dist/index.js +10 -10
- package/dist/partials/FieldValidationError/index.cjs +2 -2
- package/dist/partials/FieldValidationError/index.d.cts +2 -2
- package/dist/partials/FieldValidationError/index.d.ts +2 -2
- package/dist/partials/FieldValidationError/index.js +1 -1
- package/package.json +6 -6
- package/dist/CheckboxGroup-BYsQ0A0q.d.cts +0 -32
- package/dist/CheckboxGroup-BYsQ0A0q.d.ts +0 -32
- package/dist/RadioGroup-BU4K9cnS.d.cts +0 -40
- package/dist/RadioGroup-BU4K9cnS.d.ts +0 -40
- package/dist/Select-C08Oftdr.d.cts +0 -184
- package/dist/Select-C08Oftdr.d.ts +0 -184
- package/dist/Switch-OkO3GdPy.d.cts +0 -20
- package/dist/Switch-OkO3GdPy.d.ts +0 -20
- package/dist/chunk-4AHVJWTB.js.map +0 -1
- package/dist/chunk-ARUVDZFG.js.map +0 -1
- package/dist/chunk-AVKEYJH7.js.map +0 -1
- package/dist/chunk-DBLODROX.js.map +0 -1
- package/dist/chunk-I5M2A3MN.js +0 -240
- package/dist/chunk-I5M2A3MN.js.map +0 -1
- package/dist/chunk-INTLZONV.cjs.map +0 -1
- package/dist/chunk-QTL5FREE.cjs.map +0 -1
- package/dist/chunk-QVBZ5RLN.cjs.map +0 -1
- package/dist/chunk-W24WP5YE.cjs.map +0 -1
- package/dist/chunk-YUAJN6HW.cjs.map +0 -1
- /package/dist/{chunk-FMQNL3RT.js.map → chunk-F7GG67YU.js.map} +0 -0
- /package/dist/{chunk-NHPQEYYN.js.map → chunk-HOCRJOEU.js.map} +0 -0
- /package/dist/{chunk-DTSX7YON.js.map → chunk-SCTH3FAO.js.map} +0 -0
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
} from "./chunk-T3CCNJHK.js";
|
|
4
4
|
import {
|
|
5
5
|
FieldValidationError_default
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-WKM2D7LF.js";
|
|
7
7
|
import {
|
|
8
8
|
useFormContext
|
|
9
9
|
} from "./chunk-HWDQZO7X.js";
|
|
@@ -12,7 +12,22 @@ import {
|
|
|
12
12
|
import { Controller } from "react-hook-form";
|
|
13
13
|
import { useInput } from "@nextui-org/input";
|
|
14
14
|
import { Switch as NextSwitch } from "@nextui-org/switch";
|
|
15
|
-
import {
|
|
15
|
+
import { tv, variantsToClassNames } from "@fuf-stack/pixel-utils";
|
|
16
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
17
|
+
var switchVariants = tv({
|
|
18
|
+
slots: {
|
|
19
|
+
base: "",
|
|
20
|
+
endContent: "",
|
|
21
|
+
errorMessage: "ml-1 mt-1",
|
|
22
|
+
// See NextUI styles for group-data condition, e.g.: https://github.com/nextui-org/nextui/blob/main/packages/core/theme/src/components/select.ts
|
|
23
|
+
label: 'text-sm text-foreground subpixel-antialiased group-data-[invalid=true]:!text-danger group-data-[required=true]:after:ml-0.5 group-data-[required=true]:after:text-danger group-data-[required=true]:after:content-["*"]',
|
|
24
|
+
outerWrapper: "place-content-center",
|
|
25
|
+
startContent: "",
|
|
26
|
+
thumb: "",
|
|
27
|
+
thumbIcon: "",
|
|
28
|
+
wrapper: ""
|
|
29
|
+
}
|
|
30
|
+
});
|
|
16
31
|
var Switch = ({
|
|
17
32
|
className = void 0,
|
|
18
33
|
disabled = false,
|
|
@@ -30,6 +45,10 @@ var Switch = ({
|
|
|
30
45
|
labelPlacement: "outside",
|
|
31
46
|
placeholder: " "
|
|
32
47
|
});
|
|
48
|
+
const variants = switchVariants();
|
|
49
|
+
const classNames = variantsToClassNames(variants, className, "outerWrapper");
|
|
50
|
+
console.log("getHelperWrapperProps()", getHelperWrapperProps());
|
|
51
|
+
console.log("getErrorMessageProps()", getErrorMessageProps());
|
|
33
52
|
return /* @__PURE__ */ jsx(
|
|
34
53
|
Controller,
|
|
35
54
|
{
|
|
@@ -38,33 +57,36 @@ var Switch = ({
|
|
|
38
57
|
disabled,
|
|
39
58
|
render: ({
|
|
40
59
|
field: { disabled: isDisabled, value, ref, onBlur, onChange }
|
|
41
|
-
}) => /* @__PURE__ */ jsxs(
|
|
60
|
+
}) => /* @__PURE__ */ jsxs("div", { className: classNames.outerWrapper, children: [
|
|
42
61
|
/* @__PURE__ */ jsxs(
|
|
43
62
|
NextSwitch,
|
|
44
63
|
{
|
|
45
64
|
"aria-describedby": getInputProps()["aria-describedby"],
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
classNames: {
|
|
50
|
-
label: `text-bold block text-ellipsis text-small ${invalid ? "text-danger" : ""}`
|
|
51
|
-
},
|
|
65
|
+
classNames,
|
|
66
|
+
"data-invalid": invalid,
|
|
67
|
+
"data-required": required,
|
|
52
68
|
"data-testid": testId,
|
|
53
69
|
isDisabled,
|
|
54
|
-
value,
|
|
55
|
-
onChange,
|
|
56
|
-
onBlur,
|
|
70
|
+
isSelected: !!value,
|
|
57
71
|
name,
|
|
72
|
+
onBlur,
|
|
73
|
+
onChange,
|
|
58
74
|
ref,
|
|
75
|
+
required,
|
|
76
|
+
value,
|
|
59
77
|
children: [
|
|
60
78
|
label,
|
|
61
|
-
!!required && !!_label && /* @__PURE__ */ jsx("span", { className: "!text-danger", children: " *" }),
|
|
62
79
|
/* @__PURE__ */ jsx(FieldCopyTestIdButton_default, { testId })
|
|
63
80
|
]
|
|
64
81
|
}
|
|
65
82
|
),
|
|
66
|
-
error &&
|
|
67
|
-
|
|
83
|
+
error && /* @__PURE__ */ jsx("div", { className: classNames.errorMessage, children: /* @__PURE__ */ jsx(
|
|
84
|
+
"div",
|
|
85
|
+
{
|
|
86
|
+
...getErrorMessageProps(),
|
|
87
|
+
children: /* @__PURE__ */ jsx(FieldValidationError_default, { error })
|
|
88
|
+
}
|
|
89
|
+
) })
|
|
68
90
|
] })
|
|
69
91
|
}
|
|
70
92
|
);
|
|
@@ -78,4 +100,4 @@ export {
|
|
|
78
100
|
Switch_default,
|
|
79
101
|
Switch_default2
|
|
80
102
|
};
|
|
81
|
-
//# sourceMappingURL=chunk-
|
|
103
|
+
//# sourceMappingURL=chunk-PFX4YRWI.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/Switch/Switch.tsx","../src/Switch/index.ts"],"sourcesContent":["import type { TVClassName, TVProps } from '@fuf-stack/pixel-utils';\n\nimport { Controller } from 'react-hook-form';\n\nimport { useInput } from '@nextui-org/input';\nimport { Switch as NextSwitch } from '@nextui-org/switch';\n\nimport { tv, variantsToClassNames } from '@fuf-stack/pixel-utils';\n\nimport { useFormContext } from '../hooks';\nimport { FieldCopyTestIdButton } from '../partials/FieldCopyTestIdButton';\nimport { FieldValidationError } from '../partials/FieldValidationError';\n\nexport const switchVariants = tv({\n slots: {\n base: '',\n endContent: '',\n errorMessage: 'ml-1 mt-1',\n // See NextUI styles for group-data condition, e.g.: https://github.com/nextui-org/nextui/blob/main/packages/core/theme/src/components/select.ts\n label:\n 'text-sm text-foreground subpixel-antialiased group-data-[invalid=true]:!text-danger group-data-[required=true]:after:ml-0.5 group-data-[required=true]:after:text-danger group-data-[required=true]:after:content-[\"*\"]',\n outerWrapper: 'place-content-center',\n startContent: '',\n thumb: '',\n thumbIcon: '',\n wrapper: '',\n },\n});\n\ntype VariantProps = TVProps<typeof switchVariants>;\ntype ClassName = TVClassName<typeof switchVariants>;\n\nexport interface SwitchProps extends VariantProps {\n /** CSS class name */\n className?: ClassName;\n /** whether the select should be disabled */\n disabled?: boolean;\n /** component displayed next to the switch. */\n label?: React.ReactNode;\n /** name the field is registered under */\n name: string;\n /** HTML data-testid attribute used in e2e tests */\n testId?: string;\n}\n\n/**\n * Switch component based on [NextUI Switch](https://nextui.org/docs/components/switch)\n */\nconst Switch = ({\n className = undefined,\n disabled = false,\n label: _label = undefined,\n name,\n testId: _testId = undefined,\n}: SwitchProps) => {\n const { control, getFieldState } = useFormContext();\n const { error, required, testId, invalid } = getFieldState(name, _testId);\n\n const { label, getInputProps, getHelperWrapperProps, getErrorMessageProps } =\n useInput({\n errorMessage: JSON.stringify(error),\n isInvalid: invalid,\n isRequired: required,\n label: _label,\n labelPlacement: 'outside',\n placeholder: ' ',\n });\n\n const variants = switchVariants();\n const classNames = variantsToClassNames(variants, className, 'outerWrapper');\n\n console.log('getHelperWrapperProps()', getHelperWrapperProps());\n console.log('getErrorMessageProps()', getErrorMessageProps());\n\n return (\n <Controller\n name={name}\n control={control}\n disabled={disabled}\n render={({\n field: { disabled: isDisabled, value, ref, onBlur, onChange },\n }) => (\n <div className={classNames.outerWrapper}>\n <NextSwitch\n aria-describedby={getInputProps()['aria-describedby']}\n classNames={classNames}\n // See NextUI styles for group-data condition (data-invalid), e.g.: https://github.com/nextui-org/nextui/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 isSelected={!!value}\n name={name}\n onBlur={onBlur}\n onChange={onChange}\n ref={ref}\n required={required}\n value={value}\n >\n {label}\n <FieldCopyTestIdButton testId={testId} />\n </NextSwitch>\n {error && (\n <div className={classNames.errorMessage}>\n <div\n /* eslint-disable-next-line react/jsx-props-no-spreading */\n {...getErrorMessageProps()}\n >\n <FieldValidationError error={error} />\n </div>\n </div>\n )}\n </div>\n )}\n />\n );\n};\n\nexport default Switch;\n","import Switch from './Switch';\n\nexport type { SwitchProps } from './Switch';\n\nexport { Switch };\n\nexport default Switch;\n"],"mappings":";;;;;;;;;;;AAEA,SAAS,kBAAkB;AAE3B,SAAS,gBAAgB;AACzB,SAAS,UAAU,kBAAkB;AAErC,SAAS,IAAI,4BAA4B;AA4E/B,SAiBE,KAjBF;AAtEH,IAAM,iBAAiB,GAAG;AAAA,EAC/B,OAAO;AAAA,IACL,MAAM;AAAA,IACN,YAAY;AAAA,IACZ,cAAc;AAAA;AAAA,IAEd,OACE;AAAA,IACF,cAAc;AAAA,IACd,cAAc;AAAA,I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AA;AAAA,YAEE,GAAG,qBAAqB;AAAA,YAEzB,8BAAC,gCAAqB,OAAc;AAAA;AAAA,QACtC,GACF;AAAA,SAEJ;AAAA;AAAA,EAEJ;AAEJ;AAEA,IAAO,iBAAQ;;;AChHf,IAAOA,kBAAQ;","names":["Switch_default"]}
|
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
} from "./chunk-T3CCNJHK.js";
|
|
4
4
|
import {
|
|
5
5
|
FieldValidationError_default
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-WKM2D7LF.js";
|
|
7
7
|
import {
|
|
8
8
|
useFormContext
|
|
9
9
|
} from "./chunk-HWDQZO7X.js";
|
|
@@ -78,4 +78,4 @@ export {
|
|
|
78
78
|
Input_default,
|
|
79
79
|
Input_default2
|
|
80
80
|
};
|
|
81
|
-
//# sourceMappingURL=chunk-
|
|
81
|
+
//# sourceMappingURL=chunk-SCTH3FAO.js.map
|
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
} from "./chunk-T3CCNJHK.js";
|
|
4
4
|
import {
|
|
5
5
|
FieldValidationError_default
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-WKM2D7LF.js";
|
|
7
7
|
import {
|
|
8
8
|
useFormContext
|
|
9
9
|
} from "./chunk-HWDQZO7X.js";
|
|
@@ -15,7 +15,7 @@ import {
|
|
|
15
15
|
import { Controller } from "react-hook-form";
|
|
16
16
|
import { ButtonGroup as NextButtonGroup } from "@nextui-org/button";
|
|
17
17
|
import { RadioGroup as NextRadioGroup, Radio } from "@nextui-org/radio";
|
|
18
|
-
import { cn as cn3 } from "@fuf-stack/pixel-utils";
|
|
18
|
+
import { cn as cn3, tv, variantsToClassNames } from "@fuf-stack/pixel-utils";
|
|
19
19
|
|
|
20
20
|
// src/RadioGroup/Variants/RadioBox.tsx
|
|
21
21
|
import { useRadio } from "@nextui-org/radio";
|
|
@@ -71,16 +71,18 @@ import { cn as cn2 } from "@fuf-stack/pixel-utils";
|
|
|
71
71
|
import { Button } from "@fuf-stack/pixels";
|
|
72
72
|
import { jsx as jsx2 } from "react/jsx-runtime";
|
|
73
73
|
var RadioButton = ({
|
|
74
|
+
children,
|
|
74
75
|
className = void 0,
|
|
75
|
-
value,
|
|
76
76
|
isDisabled = false,
|
|
77
77
|
onChange,
|
|
78
|
-
|
|
78
|
+
testID = void 0,
|
|
79
|
+
value
|
|
79
80
|
}) => {
|
|
80
81
|
return /* @__PURE__ */ jsx2(
|
|
81
82
|
Button,
|
|
82
83
|
{
|
|
83
84
|
className: cn2(className),
|
|
85
|
+
testId: testID,
|
|
84
86
|
disabled: isDisabled,
|
|
85
87
|
onClick: () => {
|
|
86
88
|
return onChange(value);
|
|
@@ -93,6 +95,25 @@ var RadioButton = ({
|
|
|
93
95
|
|
|
94
96
|
// src/RadioGroup/RadioGroup.tsx
|
|
95
97
|
import { jsx as jsx3, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
98
|
+
var radioGroupVariants = tv({
|
|
99
|
+
slots: {
|
|
100
|
+
base: "group",
|
|
101
|
+
// Needs group for group-data condition
|
|
102
|
+
buttonGroup: "rounded-xl group-data-[invalid=true]:border group-data-[invalid=true]:border-danger",
|
|
103
|
+
// optional if a button group is used
|
|
104
|
+
itemBase: "",
|
|
105
|
+
itemBaseActive: "bg-opacity-50",
|
|
106
|
+
// optional if a button group is used
|
|
107
|
+
itemControl: "",
|
|
108
|
+
itemDescription: "",
|
|
109
|
+
itemLabel: "text-sm",
|
|
110
|
+
itemLabelWrapper: "",
|
|
111
|
+
itemWrapper: "",
|
|
112
|
+
// See NextUI styles for group-data condition, e.g.: https://github.com/nextui-org/nextui/blob/main/packages/core/theme/src/components/select.ts
|
|
113
|
+
label: "text-sm text-foreground subpixel-antialiased group-data-[invalid=true]:!text-danger",
|
|
114
|
+
wrapper: ""
|
|
115
|
+
}
|
|
116
|
+
});
|
|
96
117
|
var RadioGroup = ({
|
|
97
118
|
className = void 0,
|
|
98
119
|
disabled = false,
|
|
@@ -105,6 +126,8 @@ var RadioGroup = ({
|
|
|
105
126
|
}) => {
|
|
106
127
|
const { control, getFieldState, getValues } = useFormContext();
|
|
107
128
|
const { error, invalid, required, testId } = getFieldState(name, _testId);
|
|
129
|
+
const variants = radioGroupVariants();
|
|
130
|
+
const classNames = variantsToClassNames(variants, className, "base");
|
|
108
131
|
return /* @__PURE__ */ jsx3(
|
|
109
132
|
Controller,
|
|
110
133
|
{
|
|
@@ -113,19 +136,28 @@ var RadioGroup = ({
|
|
|
113
136
|
name,
|
|
114
137
|
render: ({ field: { onChange, disabled: isDisabled, onBlur, ref } }) => {
|
|
115
138
|
let RadioComponents;
|
|
139
|
+
const itemClassNames = {
|
|
140
|
+
base: classNames.itemBase,
|
|
141
|
+
control: classNames.itemControl,
|
|
142
|
+
description: classNames.itemDescription,
|
|
143
|
+
label: classNames.itemLabel,
|
|
144
|
+
labelWrapper: classNames.itemLabelWrapper,
|
|
145
|
+
wrapper: classNames.itemWrapper
|
|
146
|
+
};
|
|
116
147
|
switch (variant) {
|
|
117
148
|
case "radioBox":
|
|
118
149
|
RadioComponents = options.map((option) => /* @__PURE__ */ jsx3(
|
|
119
150
|
RadioBox,
|
|
120
151
|
{
|
|
152
|
+
classNames: itemClassNames,
|
|
121
153
|
"data-testid": slugify(
|
|
122
154
|
`${testId}_option_${option.testId || option.value}`
|
|
123
155
|
),
|
|
124
|
-
isDisabled: isDisabled || option.disabled,
|
|
125
|
-
value: option.value,
|
|
126
|
-
onChange,
|
|
127
156
|
description: option.description,
|
|
128
157
|
icon: option.icon,
|
|
158
|
+
isDisabled: isDisabled || option.disabled,
|
|
159
|
+
onChange,
|
|
160
|
+
value: option.value,
|
|
129
161
|
children: option.label ? option.label : option.value
|
|
130
162
|
},
|
|
131
163
|
option.value
|
|
@@ -135,15 +167,15 @@ var RadioGroup = ({
|
|
|
135
167
|
RadioComponents = options.map((option) => /* @__PURE__ */ jsx3(
|
|
136
168
|
RadioButton,
|
|
137
169
|
{
|
|
138
|
-
|
|
170
|
+
className: cn3(classNames.itemBase, {
|
|
171
|
+
[classNames.itemBaseActive]: getValues()[name] !== option.value
|
|
172
|
+
}),
|
|
173
|
+
isDisabled: isDisabled || option.disabled,
|
|
174
|
+
testID: slugify(
|
|
139
175
|
`${testId}_option_${option.testId || option.value}`
|
|
140
176
|
),
|
|
141
|
-
isDisabled: isDisabled || option.disabled,
|
|
142
|
-
value: option.value,
|
|
143
177
|
onChange,
|
|
144
|
-
|
|
145
|
-
`${getValues()[name] !== option.value ? "bg-opacity-50" : ""}`
|
|
146
|
-
),
|
|
178
|
+
value: option.value,
|
|
147
179
|
children: option.label ? option.label : option.value
|
|
148
180
|
},
|
|
149
181
|
option.value
|
|
@@ -153,12 +185,13 @@ var RadioGroup = ({
|
|
|
153
185
|
RadioComponents = options.map((option) => /* @__PURE__ */ jsx3(
|
|
154
186
|
Radio,
|
|
155
187
|
{
|
|
188
|
+
classNames: itemClassNames,
|
|
156
189
|
"data-testid": slugify(
|
|
157
190
|
`${testId}_option_${option.testId || option.value}`
|
|
158
191
|
),
|
|
159
192
|
isDisabled: isDisabled || option.disabled,
|
|
160
|
-
value: option.value,
|
|
161
193
|
onChange,
|
|
194
|
+
value: option.value,
|
|
162
195
|
children: option.label ? option.label : option.value
|
|
163
196
|
},
|
|
164
197
|
option.value
|
|
@@ -167,25 +200,27 @@ var RadioGroup = ({
|
|
|
167
200
|
return /* @__PURE__ */ jsx3(
|
|
168
201
|
NextRadioGroup,
|
|
169
202
|
{
|
|
170
|
-
|
|
203
|
+
classNames,
|
|
204
|
+
"data-invalid": invalid,
|
|
205
|
+
"data-required": required,
|
|
171
206
|
"data-testid": testId,
|
|
172
207
|
errorMessage: error && /* @__PURE__ */ jsx3(FieldValidationError_default, { error }),
|
|
173
208
|
isDisabled,
|
|
174
209
|
isInvalid: invalid,
|
|
175
210
|
isRequired: required,
|
|
176
211
|
label: label && // eslint-disable-next-line jsx-a11y/label-has-associated-control
|
|
177
|
-
/* @__PURE__ */ jsxs2("label", {
|
|
212
|
+
/* @__PURE__ */ jsxs2("label", { children: [
|
|
178
213
|
label,
|
|
179
214
|
/* @__PURE__ */ jsx3(FieldCopyTestIdButton_default, { testId })
|
|
180
215
|
] }),
|
|
216
|
+
name,
|
|
181
217
|
orientation: inline ? "horizontal" : "vertical",
|
|
182
218
|
onBlur,
|
|
183
219
|
onChange,
|
|
184
|
-
name,
|
|
185
220
|
ref,
|
|
186
221
|
children: variant === "radioButton" ? (
|
|
187
222
|
// TODO: NextButtonGroup uses ref to modify Button style, but we wrap it, so it does not work at the moment.
|
|
188
|
-
/* @__PURE__ */ jsx3(NextButtonGroup, { children: RadioComponents })
|
|
223
|
+
/* @__PURE__ */ jsx3(NextButtonGroup, { className: classNames.buttonGroup, children: RadioComponents })
|
|
189
224
|
) : RadioComponents
|
|
190
225
|
}
|
|
191
226
|
);
|
|
@@ -202,4 +237,4 @@ export {
|
|
|
202
237
|
RadioGroup_default,
|
|
203
238
|
RadioGroup_default2
|
|
204
239
|
};
|
|
205
|
-
//# sourceMappingURL=chunk-
|
|
240
|
+
//# sourceMappingURL=chunk-VZFPQ6ZZ.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/RadioGroup/RadioGroup.tsx","../src/RadioGroup/Variants/RadioBox.tsx","../src/RadioGroup/Variants/RadioButton.tsx","../src/RadioGroup/index.ts"],"sourcesContent":["import type { TVClassName, TVProps } from '@fuf-stack/pixel-utils';\nimport type { ReactElement, ReactNode } from 'react';\n\nimport { Controller } from 'react-hook-form';\n\nimport { ButtonGroup as NextButtonGroup } from '@nextui-org/button';\nimport { RadioGroup as NextRadioGroup, Radio } from '@nextui-org/radio';\n\nimport { cn, tv, variantsToClassNames } from '@fuf-stack/pixel-utils';\n\nimport { slugify } from '../helpers';\nimport { useFormContext } from '../hooks';\nimport { FieldCopyTestIdButton } from '../partials/FieldCopyTestIdButton';\nimport { FieldValidationError } from '../partials/FieldValidationError';\nimport { RadioBox } from './Variants/RadioBox';\nimport { RadioButton } from './Variants/RadioButton';\n\nexport const radioGroupVariants = tv({\n slots: {\n base: 'group', // Needs group for group-data condition\n buttonGroup:\n 'rounded-xl group-data-[invalid=true]:border group-data-[invalid=true]:border-danger', // optional if a button group is used\n itemBase: '',\n itemBaseActive: 'bg-opacity-50', // optional if a button group is used\n itemControl: '',\n itemDescription: '',\n itemLabel: 'text-sm',\n itemLabelWrapper: '',\n itemWrapper: '',\n // See NextUI styles for group-data condition, e.g.: https://github.com/nextui-org/nextui/blob/main/packages/core/theme/src/components/select.ts\n label:\n 'text-sm text-foreground subpixel-antialiased group-data-[invalid=true]:!text-danger',\n wrapper: '',\n },\n});\n\ntype VariantProps = TVProps<typeof radioGroupVariants>;\ntype ClassName = TVClassName<typeof radioGroupVariants>;\n\nexport interface RadioGroupOption {\n /** Description of the value. Works with variant radioBox. */\n description?: React.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 RadioGroupProps 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: RadioGroupOption[];\n /** Id to grab element in internal tests. */\n testId?: string;\n /** How the RadioGroup should look like. */\n variant?: 'default' | 'radioBox' | 'radioButton';\n}\n\n/**\n * RadioGroup component based on [NextUI RadioGroup](https://nextui.org/docs/components/radio-group)\n */\nconst RadioGroup = ({\n className = undefined,\n disabled = false,\n inline = false,\n label = undefined,\n name,\n options,\n testId: _testId = undefined,\n variant = 'default',\n}: RadioGroupProps): ReactElement => {\n const { control, getFieldState, getValues } = useFormContext();\n\n const { error, invalid, required, testId } = getFieldState(name, _testId);\n\n const variants = radioGroupVariants();\n const classNames = variantsToClassNames(variants, className, 'base');\n\n return (\n <Controller\n control={control}\n disabled={disabled}\n name={name}\n render={({ field: { onChange, disabled: isDisabled, onBlur, ref } }) => {\n let RadioComponents: ReactNode;\n\n const itemClassNames = {\n base: classNames.itemBase,\n control: classNames.itemControl,\n description: classNames.itemDescription,\n label: classNames.itemLabel,\n labelWrapper: classNames.itemLabelWrapper,\n wrapper: classNames.itemWrapper,\n };\n\n switch (variant) {\n case 'radioBox':\n RadioComponents = options.map((option) => (\n <RadioBox\n classNames={itemClassNames}\n data-testid={slugify(\n `${testId}_option_${option.testId || option.value}`,\n )}\n description={option.description}\n icon={option.icon}\n isDisabled={isDisabled || option.disabled}\n key={option.value}\n onChange={onChange}\n value={option.value}\n >\n {option.label ? option.label : option.value}\n </RadioBox>\n ));\n break;\n case 'radioButton':\n RadioComponents = options.map((option) => (\n <RadioButton\n className={cn(classNames.itemBase, {\n [classNames.itemBaseActive]:\n getValues()[name] !== option.value,\n })}\n isDisabled={isDisabled || option.disabled}\n key={option.value}\n testID={slugify(\n `${testId}_option_${option.testId || option.value}`,\n )}\n onChange={onChange}\n value={option.value}\n // TODO: how to do the classNames properly (make selected option darker with same color)\n >\n {option.label ? option.label : option.value}\n </RadioButton>\n ));\n break;\n default:\n RadioComponents = options.map((option) => (\n <Radio\n classNames={itemClassNames}\n data-testid={slugify(\n `${testId}_option_${option.testId || option.value}`,\n )}\n isDisabled={isDisabled || option.disabled}\n key={option.value}\n onChange={onChange}\n value={option.value}\n >\n {option.label ? option.label : option.value}\n </Radio>\n ));\n }\n\n return (\n <NextRadioGroup\n // className={className}\n classNames={classNames}\n // See NextUI styles for group-data condition (data-invalid), e.g.: https://github.com/nextui-org/nextui/blob/main/packages/components/select/src/use-select.ts\n data-invalid={invalid}\n data-required={required}\n data-testid={testId}\n errorMessage={error && <FieldValidationError error={error} />}\n isDisabled={isDisabled}\n isInvalid={invalid}\n isRequired={required}\n label={\n label && (\n // eslint-disable-next-line jsx-a11y/label-has-associated-control\n <label>\n {label}\n <FieldCopyTestIdButton testId={testId} />\n </label>\n )\n }\n name={name}\n orientation={inline ? 'horizontal' : 'vertical'}\n onBlur={onBlur}\n onChange={onChange}\n ref={ref}\n >\n {variant === 'radioButton' ? (\n // TODO: NextButtonGroup uses ref to modify Button style, but we wrap it, so it does not work at the moment.\n <NextButtonGroup className={classNames.buttonGroup}>\n {RadioComponents}\n </NextButtonGroup>\n ) : (\n RadioComponents\n )}\n </NextRadioGroup>\n );\n }}\n />\n );\n};\n\nexport default RadioGroup;\n","import type { RadioProps as NextRadioProps } from '@nextui-org/radio';\nimport type { ReactNode } from 'react';\n\nimport { useRadio } from '@nextui-org/radio';\nimport { VisuallyHidden } from '@react-aria/visually-hidden';\n\nimport { cn } from '@fuf-stack/pixel-utils';\n\ninterface RadioProps extends NextRadioProps {\n /** icon for the option */\n icon?: ReactNode;\n}\n\nexport const RadioBox = ({ icon = undefined, ...props }: RadioProps) => {\n const {\n children,\n Component,\n description,\n getBaseProps,\n getControlProps,\n getInputProps,\n getLabelProps,\n getLabelWrapperProps,\n getWrapperProps,\n isDisabled,\n } = useRadio(props);\n\n return (\n <Component\n // eslint-disable-next-line react/jsx-props-no-spreading\n {...getBaseProps()}\n className={cn(\n 'group inline-flex flex-auto cursor-pointer items-center justify-between gap-4 rounded-lg border-2 border-default p-4 hover:bg-content2 data-[selected=true]:border-primary',\n {\n // disabled styles\n 'pointer-events-none opacity-disabled': isDisabled,\n },\n )}\n >\n <VisuallyHidden>\n {/* eslint-disable-next-line react/jsx-props-no-spreading */}\n <input {...getInputProps()} />\n </VisuallyHidden>\n {/* eslint-disable-next-line react/jsx-props-no-spreading */}\n <span {...getWrapperProps()}>\n {/* eslint-disable-next-line react/jsx-props-no-spreading */}\n <span {...getControlProps()} />\n </span>\n {icon}\n <div\n // eslint-disable-next-line react/jsx-props-no-spreading\n {...getLabelWrapperProps()}\n className={cn(getLabelWrapperProps().className, 'grow')}\n >\n {/* eslint-disable-next-line react/jsx-props-no-spreading */}\n {children && <span {...getLabelProps()}>{children}</span>}\n {description && (\n <span className=\"text-small text-foreground opacity-70\">\n {description}\n </span>\n )}\n </div>\n </Component>\n );\n};\n\nexport default RadioBox;\n","import { cn } from '@fuf-stack/pixel-utils';\nimport { Button } from '@fuf-stack/pixels';\n\ninterface RadioButtonProps {\n /** label of the value. */\n children: React.ReactNode;\n /** CSS class name */\n className?: string;\n /** disables the option */\n isDisabled?: boolean;\n /** HTML data-testid attribute of the option */\n testID?: string;\n /** Callback function. Executed if the option is clicked. */\n onChange: (...event: unknown[]) => void;\n /** value of the option. */\n value: string;\n}\n\nexport const RadioButton = ({\n children,\n className = undefined,\n isDisabled = false,\n onChange,\n testID = undefined,\n value,\n}: RadioButtonProps) => {\n return (\n <Button\n className={cn(className)}\n testId={testID}\n disabled={isDisabled}\n key={`index_${value}`}\n onClick={() => {\n return onChange(value);\n }}\n >\n {children}\n </Button>\n );\n};\n\nexport default RadioButton;\n","import RadioGroup from './RadioGroup';\n\nexport type { RadioGroupProps } from './RadioGroup';\n\nexport { RadioGroup };\n\nexport default RadioGroup;\n"],"mappings":";;;;;;;;;;;;;;AAGA,SAAS,kBAAkB;AAE3B,SAAS,eAAe,uBAAuB;AAC/C,SAAS,cAAc,gBAAgB,aAAa;AAEpD,SAAS,MAAAA,KAAI,IAAI,4BAA4B;;;ACL7C,SAAS,gBAAgB;AACzB,SAAS,sBAAsB;AAE/B,SAAS,UAAU;AAmCX,cAQF,YARE;AA5BD,IAAM,WAAW,CAAC,EAAE,OAAO,QAAW,GAAG,MAAM,MAAkB;AACtE,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,IAAI,SAAS,KAAK;AAElB,SACE;AAAA,IAAC;AAAA;AAAA,MAEE,GAAG,aAAa;AAAA,MACjB,WAAW;AAAA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AA;AAAA,EACF;AAEJ;AAEA,IAAO,qBAAQ;;;AG1Mf,IAAOG,sBAAQ;","names":["cn","cn","jsx","jsx","jsxs","cn","RadioGroup_default"]}
|
|
@@ -5,20 +5,21 @@ import {
|
|
|
5
5
|
// src/partials/FieldValidationError/FieldValidationError.tsx
|
|
6
6
|
import { jsx } from "react/jsx-runtime";
|
|
7
7
|
var FieldValidationError = ({
|
|
8
|
+
className = void 0,
|
|
8
9
|
error,
|
|
9
10
|
testId = void 0
|
|
10
11
|
}) => {
|
|
11
12
|
if (!error) {
|
|
12
13
|
return null;
|
|
13
14
|
}
|
|
14
|
-
let
|
|
15
|
+
let tmpErrors = [];
|
|
15
16
|
if (typeof error === "object" && !(error instanceof Array)) {
|
|
16
|
-
const
|
|
17
|
+
const errorObject = error;
|
|
17
18
|
Object.keys(error).forEach((key) => {
|
|
18
|
-
|
|
19
|
+
tmpErrors = [...tmpErrors, ...errorObject[key]];
|
|
19
20
|
});
|
|
20
21
|
}
|
|
21
|
-
const errorArray = JSON.stringify(
|
|
22
|
+
const errorArray = JSON.stringify(tmpErrors) !== "[]" ? tmpErrors : error;
|
|
22
23
|
const errorStrings = errorArray.map((e) => e.message);
|
|
23
24
|
const ariaString = `Error: ${errorStrings.join("\n")}`;
|
|
24
25
|
return /* @__PURE__ */ jsx(
|
|
@@ -26,6 +27,7 @@ var FieldValidationError = ({
|
|
|
26
27
|
{
|
|
27
28
|
"data-testid": slugify(testId || errorStrings.join()),
|
|
28
29
|
"aria-label": ariaString,
|
|
30
|
+
className,
|
|
29
31
|
children: errorStrings.map((errorString, i) => (
|
|
30
32
|
// eslint-disable-next-line react/no-array-index-key
|
|
31
33
|
/* @__PURE__ */ jsx("li", { children: /* @__PURE__ */ jsx("div", { children: errorString }) }, `error_${i}`)
|
|
@@ -42,4 +44,4 @@ export {
|
|
|
42
44
|
FieldValidationError_default,
|
|
43
45
|
FieldValidationError_default2
|
|
44
46
|
};
|
|
45
|
-
//# sourceMappingURL=chunk-
|
|
47
|
+
//# sourceMappingURL=chunk-WKM2D7LF.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/partials/FieldValidationError/FieldValidationError.tsx","../src/partials/FieldValidationError/index.ts"],"sourcesContent":["import type { FieldError } from 'react-hook-form';\n\nimport { slugify } from '../../helpers';\n\nexport interface FieldValidationErrorProps {\n className?: string;\n error: FieldError[] | Record<string, FieldError[]>;\n testId?: string;\n}\n\n/**\n * Renders a validation error of a field\n */\nconst FieldValidationError = ({\n className = undefined,\n error,\n testId = undefined,\n}: FieldValidationErrorProps) => {\n if (!error) {\n return null;\n }\n\n let tmpErrors: FieldError[] = [];\n\n if (typeof error === 'object' && !(error instanceof Array)) {\n const errorObject = error as Record<string, FieldError[]>;\n Object.keys(error).forEach((key) => {\n tmpErrors = [...tmpErrors, ...errorObject[key]];\n });\n }\n\n const errorArray: FieldError[] =\n JSON.stringify(tmpErrors) !== '[]' ? tmpErrors : (error as FieldError[]);\n const errorStrings: string[] = errorArray.map((e) => e.message) as string[];\n const ariaString = `Error: ${errorStrings.join('\\n')}`;\n\n return (\n <ul\n data-testid={slugify(testId || errorStrings.join())}\n aria-label={ariaString} // TODO: ist das richtig @Hannes?\n className={className}\n >\n {errorStrings.map((errorString: string, i: number) => (\n // eslint-disable-next-line react/no-array-index-key\n <li key={`error_${i}`}>\n <div>{errorString}</div>\n </li>\n ))}\n </ul>\n );\n};\n\nexport default FieldValidationError;\n","import FieldValidationError from './FieldValidationError';\n\nexport type { FieldValidationErrorProps } from './FieldValidationError';\n\nexport { FieldValidationError };\n\nexport default FieldValidationError;\n"],"mappings":";;;;;AA6CU;AAhCV,IAAM,uBAAuB,CAAC;AAAA,EAC5B,YAAY;AAAA,EACZ;AAAA,EACA,SAAS;AACX,MAAiC;AAC/B,MAAI,CAAC,OAAO;AACV,WAAO;AAAA,EACT;AAEA,MAAI,YAA0B,CAAC;AAE/B,MAAI,OAAO,UAAU,YAAY,EAAE,iBAAiB,QAAQ;AAC1D,UAAM,cAAc;AACpB,WAAO,KAAK,KAAK,EAAE,QAAQ,CAAC,QAAQ;AAClC,kBAAY,CAAC,GAAG,WAAW,GAAG,YAAY,GAAG,CAAC;AAAA,IAChD,CAAC;AAAA,EACH;AAEA,QAAM,aACJ,KAAK,UAAU,SAAS,MAAM,OAAO,YAAa;AACpD,QAAM,eAAyB,WAAW,IAAI,CAAC,MAAM,EAAE,OAAO;AAC9D,QAAM,aAAa,UAAU,aAAa,KAAK,IAAI,CAAC;AAEpD,SACE;AAAA,IAAC;AAAA;AAAA,MACC,eAAa,QAAQ,UAAU,aAAa,KAAK,CAAC;AAAA,MAClD,cAAY;AAAA,MACZ;AAAA,MAEC,uBAAa,IAAI,CAAC,aAAqB;AAAA;AAAA,QAEtC,oBAAC,QACC,8BAAC,SAAK,uBAAY,KADX,SAAS,CAAC,EAEnB;AAAA,OACD;AAAA;AAAA,EACH;AAEJ;AAEA,IAAO,+BAAQ;;;AC9Cf,IAAOA,gCAAQ;","names":["FieldValidationError_default"]}
|
package/dist/index.cjs
CHANGED
|
@@ -3,16 +3,16 @@
|
|
|
3
3
|
var _chunkMKM7ZYRNcjs = require('./chunk-MKM7ZYRN.cjs');
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
var
|
|
6
|
+
var _chunkNQ4JZ7AKcjs = require('./chunk-NQ4JZ7AK.cjs');
|
|
7
7
|
|
|
8
8
|
|
|
9
|
-
var
|
|
9
|
+
var _chunk4RTJ5XR2cjs = require('./chunk-4RTJ5XR2.cjs');
|
|
10
10
|
|
|
11
11
|
|
|
12
|
-
var
|
|
12
|
+
var _chunkHFMFDBEVcjs = require('./chunk-HFMFDBEV.cjs');
|
|
13
13
|
|
|
14
14
|
|
|
15
|
-
var
|
|
15
|
+
var _chunkJDRMKZ35cjs = require('./chunk-JDRMKZ35.cjs');
|
|
16
16
|
|
|
17
17
|
|
|
18
18
|
var _chunkQYZV7ZUYcjs = require('./chunk-QYZV7ZUY.cjs');
|
|
@@ -21,19 +21,19 @@ var _chunkQYZV7ZUYcjs = require('./chunk-QYZV7ZUY.cjs');
|
|
|
21
21
|
var _chunk6GN255GPcjs = require('./chunk-6GN255GP.cjs');
|
|
22
22
|
|
|
23
23
|
|
|
24
|
-
var
|
|
24
|
+
var _chunkPAX2HXPKcjs = require('./chunk-PAX2HXPK.cjs');
|
|
25
25
|
|
|
26
26
|
|
|
27
|
-
var
|
|
27
|
+
var _chunkNXTXKBTPcjs = require('./chunk-NXTXKBTP.cjs');
|
|
28
28
|
|
|
29
29
|
|
|
30
|
-
var
|
|
30
|
+
var _chunkJRFKYVXYcjs = require('./chunk-JRFKYVXY.cjs');
|
|
31
31
|
|
|
32
32
|
|
|
33
33
|
var _chunkKMMS4G7Acjs = require('./chunk-KMMS4G7A.cjs');
|
|
34
34
|
|
|
35
35
|
|
|
36
|
-
var
|
|
36
|
+
var _chunkOHJYXA6Rcjs = require('./chunk-OHJYXA6R.cjs');
|
|
37
37
|
|
|
38
38
|
|
|
39
39
|
|
|
@@ -57,5 +57,5 @@ var _chunkBBB4FEY6cjs = require('./chunk-BBB4FEY6.cjs');
|
|
|
57
57
|
|
|
58
58
|
|
|
59
59
|
|
|
60
|
-
exports.CheckboxGroup =
|
|
60
|
+
exports.CheckboxGroup = _chunkHFMFDBEVcjs.CheckboxGroup_default; exports.FieldArray = _chunkJDRMKZ35cjs.FieldArray_default; exports.FieldCopyTestIdButton = _chunkKMMS4G7Acjs.FieldCopyTestIdButton_default; exports.FieldValidationError = _chunkOHJYXA6Rcjs.FieldValidationError_default; exports.Form = _chunkQYZV7ZUYcjs.Form_default; exports.Grid = _chunk6GN255GPcjs.Grid_default; exports.Input = _chunkJRFKYVXYcjs.Input_default; exports.RadioGroup = _chunkPAX2HXPKcjs.RadioGroup_default; exports.Select = _chunkNXTXKBTPcjs.Select_default; exports.SubmitButton = _chunkMKM7ZYRNcjs.SubmitButton_default; exports.Switch = _chunkNQ4JZ7AKcjs.Switch_default; exports.TextArea = _chunk4RTJ5XR2cjs.TextArea_default; exports.recursiveFieldKeySearch = _chunkLDCRR7FPcjs.recursiveFieldKeySearch; exports.slugify = _chunkBBB4FEY6cjs.slugify; exports.useFormContext = _chunkLDCRR7FPcjs.useFormContext;
|
|
61
61
|
//# sourceMappingURL=index.cjs.map
|
package/dist/index.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { C as CheckboxGroup, b as CheckboxGroupOption, a as CheckboxGroupProps } from './CheckboxGroup-
|
|
1
|
+
export { C as CheckboxGroup, b as CheckboxGroupOption, a as CheckboxGroupProps } from './CheckboxGroup-o-qWkWe1.cjs';
|
|
2
2
|
export { F as FieldArray, c as FieldArrayFieldChildren, b as FieldArrayHideOption, a as FieldArrayProps } from './FieldArray-DUvn98Fe.cjs';
|
|
3
3
|
export { F as Form, a as FormProps } from './Form-nJbG1hNH.cjs';
|
|
4
4
|
export { G as Grid, a as GridProps } from './Grid-DF3L9NF3.cjs';
|
|
@@ -6,19 +6,19 @@ export { slugify } from './helpers/index.cjs';
|
|
|
6
6
|
export { recursiveFieldKeySearch, useFormContext } from './hooks/index.cjs';
|
|
7
7
|
export { I as Input, a as InputProps } from './Input-B6dNQiiD.cjs';
|
|
8
8
|
export { F as FieldCopyTestIdButton, a as FieldCopyTestIdButtonProps } from './FieldCopyTestIdButton-D-z1usqE.cjs';
|
|
9
|
-
export { F as FieldValidationError, a as FieldValidationErrorProps } from './FieldValidationError-
|
|
10
|
-
export { R as RadioGroup, a as RadioGroupProps } from './RadioGroup-
|
|
11
|
-
export { S as Select, a as SelectProps } from './Select-
|
|
9
|
+
export { F as FieldValidationError, a as FieldValidationErrorProps } from './FieldValidationError-DAT12Ess.cjs';
|
|
10
|
+
export { R as RadioGroup, a as RadioGroupProps } from './RadioGroup-D_kiBt0M.cjs';
|
|
11
|
+
export { S as Select, a as SelectProps } from './Select-BhS4z0Pj.cjs';
|
|
12
12
|
export { S as SubmitButton, a as SubmitButtonProps } from './SubmitButton-BEp_zzwf.cjs';
|
|
13
|
-
export { S as Switch, a as SwitchProps } from './Switch-
|
|
13
|
+
export { S as Switch, a as SwitchProps } from './Switch-Fdldj8LV.cjs';
|
|
14
14
|
export { T as TextArea, a as TextAreaProps } from './TextArea-B-sKvTkd.cjs';
|
|
15
15
|
import 'react/jsx-runtime';
|
|
16
|
+
import 'tailwind-variants/dist/config.js';
|
|
17
|
+
import 'tailwind-variants';
|
|
18
|
+
import '@fuf-stack/pixel-utils';
|
|
16
19
|
import 'react-hook-form';
|
|
17
20
|
import '@fuf-stack/veto';
|
|
18
21
|
import 'react';
|
|
19
22
|
import 'slug';
|
|
20
|
-
import 'tailwind-variants';
|
|
21
|
-
import 'tailwind-variants/dist/config.js';
|
|
22
|
-
import '@fuf-stack/pixel-utils';
|
|
23
23
|
import 'react-select';
|
|
24
24
|
import '@fuf-stack/pixels';
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { C as CheckboxGroup, b as CheckboxGroupOption, a as CheckboxGroupProps } from './CheckboxGroup-
|
|
1
|
+
export { C as CheckboxGroup, b as CheckboxGroupOption, a as CheckboxGroupProps } from './CheckboxGroup-o-qWkWe1.js';
|
|
2
2
|
export { F as FieldArray, c as FieldArrayFieldChildren, b as FieldArrayHideOption, a as FieldArrayProps } from './FieldArray-DUvn98Fe.js';
|
|
3
3
|
export { F as Form, a as FormProps } from './Form-nJbG1hNH.js';
|
|
4
4
|
export { G as Grid, a as GridProps } from './Grid-DF3L9NF3.js';
|
|
@@ -6,19 +6,19 @@ export { slugify } from './helpers/index.js';
|
|
|
6
6
|
export { recursiveFieldKeySearch, useFormContext } from './hooks/index.js';
|
|
7
7
|
export { I as Input, a as InputProps } from './Input-B6dNQiiD.js';
|
|
8
8
|
export { F as FieldCopyTestIdButton, a as FieldCopyTestIdButtonProps } from './FieldCopyTestIdButton-D-z1usqE.js';
|
|
9
|
-
export { F as FieldValidationError, a as FieldValidationErrorProps } from './FieldValidationError-
|
|
10
|
-
export { R as RadioGroup, a as RadioGroupProps } from './RadioGroup-
|
|
11
|
-
export { S as Select, a as SelectProps } from './Select-
|
|
9
|
+
export { F as FieldValidationError, a as FieldValidationErrorProps } from './FieldValidationError-DAT12Ess.js';
|
|
10
|
+
export { R as RadioGroup, a as RadioGroupProps } from './RadioGroup-D_kiBt0M.js';
|
|
11
|
+
export { S as Select, a as SelectProps } from './Select-BhS4z0Pj.js';
|
|
12
12
|
export { S as SubmitButton, a as SubmitButtonProps } from './SubmitButton-BEp_zzwf.js';
|
|
13
|
-
export { S as Switch, a as SwitchProps } from './Switch-
|
|
13
|
+
export { S as Switch, a as SwitchProps } from './Switch-Fdldj8LV.js';
|
|
14
14
|
export { T as TextArea, a as TextAreaProps } from './TextArea-B-sKvTkd.js';
|
|
15
15
|
import 'react/jsx-runtime';
|
|
16
|
+
import 'tailwind-variants/dist/config.js';
|
|
17
|
+
import 'tailwind-variants';
|
|
18
|
+
import '@fuf-stack/pixel-utils';
|
|
16
19
|
import 'react-hook-form';
|
|
17
20
|
import '@fuf-stack/veto';
|
|
18
21
|
import 'react';
|
|
19
22
|
import 'slug';
|
|
20
|
-
import 'tailwind-variants';
|
|
21
|
-
import 'tailwind-variants/dist/config.js';
|
|
22
|
-
import '@fuf-stack/pixel-utils';
|
|
23
23
|
import 'react-select';
|
|
24
24
|
import '@fuf-stack/pixels';
|
package/dist/index.js
CHANGED
|
@@ -3,16 +3,16 @@ import {
|
|
|
3
3
|
} from "./chunk-4GVPJYZW.js";
|
|
4
4
|
import {
|
|
5
5
|
Switch_default
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-PFX4YRWI.js";
|
|
7
7
|
import {
|
|
8
8
|
TextArea_default
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-HOCRJOEU.js";
|
|
10
10
|
import {
|
|
11
11
|
CheckboxGroup_default
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-JG5VQZ4V.js";
|
|
13
13
|
import {
|
|
14
14
|
FieldArray_default
|
|
15
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-F7GG67YU.js";
|
|
16
16
|
import {
|
|
17
17
|
Form_default
|
|
18
18
|
} from "./chunk-DF77NLWL.js";
|
|
@@ -21,19 +21,19 @@ import {
|
|
|
21
21
|
} from "./chunk-PDCEKC3G.js";
|
|
22
22
|
import {
|
|
23
23
|
RadioGroup_default
|
|
24
|
-
} from "./chunk-
|
|
25
|
-
import {
|
|
26
|
-
Input_default
|
|
27
|
-
} from "./chunk-DTSX7YON.js";
|
|
24
|
+
} from "./chunk-VZFPQ6ZZ.js";
|
|
28
25
|
import {
|
|
29
26
|
Select_default
|
|
30
|
-
} from "./chunk-
|
|
27
|
+
} from "./chunk-LDW7K7LW.js";
|
|
28
|
+
import {
|
|
29
|
+
Input_default
|
|
30
|
+
} from "./chunk-SCTH3FAO.js";
|
|
31
31
|
import {
|
|
32
32
|
FieldCopyTestIdButton_default
|
|
33
33
|
} from "./chunk-T3CCNJHK.js";
|
|
34
34
|
import {
|
|
35
35
|
FieldValidationError_default
|
|
36
|
-
} from "./chunk-
|
|
36
|
+
} from "./chunk-WKM2D7LF.js";
|
|
37
37
|
import {
|
|
38
38
|
recursiveFieldKeySearch,
|
|
39
39
|
useFormContext
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
2
|
|
|
3
3
|
|
|
4
|
-
var
|
|
4
|
+
var _chunkOHJYXA6Rcjs = require('../../chunk-OHJYXA6R.cjs');
|
|
5
5
|
require('../../chunk-BBB4FEY6.cjs');
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
|
|
9
|
-
exports.FieldValidationError =
|
|
9
|
+
exports.FieldValidationError = _chunkOHJYXA6Rcjs.FieldValidationError_default; exports.default = _chunkOHJYXA6Rcjs.FieldValidationError_default2;
|
|
10
10
|
//# sourceMappingURL=index.cjs.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { F as FieldValidationError } from '../../FieldValidationError-
|
|
2
|
-
export { a as FieldValidationErrorProps } from '../../FieldValidationError-
|
|
1
|
+
import { F as FieldValidationError } from '../../FieldValidationError-DAT12Ess.cjs';
|
|
2
|
+
export { a as FieldValidationErrorProps } from '../../FieldValidationError-DAT12Ess.cjs';
|
|
3
3
|
import 'react/jsx-runtime';
|
|
4
4
|
import 'react-hook-form';
|
|
5
5
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { F as FieldValidationError } from '../../FieldValidationError-
|
|
2
|
-
export { a as FieldValidationErrorProps } from '../../FieldValidationError-
|
|
1
|
+
import { F as FieldValidationError } from '../../FieldValidationError-DAT12Ess.js';
|
|
2
|
+
export { a as FieldValidationErrorProps } from '../../FieldValidationError-DAT12Ess.js';
|
|
3
3
|
import 'react/jsx-runtime';
|
|
4
4
|
import 'react-hook-form';
|
|
5
5
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fuf-stack/uniform",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.7",
|
|
4
4
|
"description": "fuf react form library",
|
|
5
5
|
"author": "Hannes Tiede",
|
|
6
6
|
"homepage": "https://github.com/fuf-stack/uniform#readme",
|
|
@@ -118,20 +118,20 @@
|
|
|
118
118
|
"@nextui-org/switch": "2.0.34",
|
|
119
119
|
"@nextui-org/system": "2.2.6",
|
|
120
120
|
"@nextui-org/theme": "2.2.11",
|
|
121
|
-
"@react-aria/visually-hidden": "3.8.
|
|
122
|
-
"framer-motion": "11.11.
|
|
121
|
+
"@react-aria/visually-hidden": "3.8.17",
|
|
122
|
+
"framer-motion": "11.11.9",
|
|
123
123
|
"react-icons": "5.3.0",
|
|
124
124
|
"react-hook-form": "7.53.0",
|
|
125
125
|
"react-select": "5.8.1",
|
|
126
126
|
"slug": "9.1.0",
|
|
127
|
-
"@fuf-stack/pixels": "0.24.0",
|
|
128
127
|
"@fuf-stack/pixel-utils": "0.3.0",
|
|
129
|
-
"@fuf-stack/veto": "0.5.0"
|
|
128
|
+
"@fuf-stack/veto": "0.5.0",
|
|
129
|
+
"@fuf-stack/pixels": "0.24.0"
|
|
130
130
|
},
|
|
131
131
|
"devDependencies": {
|
|
132
132
|
"@types/debug": "4.1.12",
|
|
133
133
|
"@types/react": "18.3.11",
|
|
134
|
-
"@types/react-dom": "18.3.
|
|
134
|
+
"@types/react-dom": "18.3.1",
|
|
135
135
|
"@types/slug": "5.0.9",
|
|
136
136
|
"react": "18.3.1",
|
|
137
137
|
"react-dom": "18.3.1",
|