@fuf-stack/uniform 1.4.1 → 1.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Checkboxes/index.cjs +16 -0
- package/dist/{RadioGroup → Checkboxes}/index.cjs.map +1 -1
- package/dist/Checkboxes/index.d.cts +10 -0
- package/dist/Checkboxes/index.d.ts +10 -0
- package/dist/Checkboxes/index.js +16 -0
- package/dist/{CheckboxGroup-B1g42iP0.d.cts → Checkboxes-CR0Uu2g9.d.cts} +9 -9
- package/dist/{CheckboxGroup-B1g42iP0.d.ts → Checkboxes-CR0Uu2g9.d.ts} +9 -9
- package/dist/FieldArray/index.cjs +5 -5
- package/dist/FieldArray/index.d.cts +2 -2
- package/dist/FieldArray/index.d.ts +2 -2
- package/dist/FieldArray/index.js +4 -4
- package/dist/FieldArray-EP4otr2x.d.cts +160 -0
- package/dist/FieldArray-EP4otr2x.d.ts +160 -0
- package/dist/{FieldValidationError-CU_xw0BL.d.ts → FieldValidationError-DwtLkGMo.d.cts} +2 -2
- package/dist/{FieldValidationError-CU_xw0BL.d.cts → FieldValidationError-DwtLkGMo.d.ts} +2 -2
- package/dist/Form/index.cjs +6 -4
- package/dist/Form/index.cjs.map +1 -1
- package/dist/Form/index.js +5 -3
- package/dist/Input/index.cjs +5 -5
- package/dist/Input/index.d.cts +2 -2
- package/dist/Input/index.d.ts +2 -2
- package/dist/Input/index.js +4 -4
- package/dist/{Input-C6ujfEkn.d.ts → Input-CCIEnvIp.d.ts} +1 -1
- package/dist/{Input-BQkZtJx8.d.cts → Input-D7HT_8jf.d.cts} +1 -1
- package/dist/RadioBoxes/index.cjs +5 -5
- package/dist/RadioBoxes/index.d.cts +3 -2
- package/dist/RadioBoxes/index.d.ts +3 -2
- package/dist/RadioBoxes/index.js +4 -4
- package/dist/{RadioBoxes-CE3mYoFk.d.cts → RadioBoxes-DpkI28l0.d.cts} +3 -2
- package/dist/{RadioBoxes-CE3mYoFk.d.ts → RadioBoxes-DpkI28l0.d.ts} +3 -2
- package/dist/RadioTabs/index.cjs +5 -5
- package/dist/RadioTabs/index.d.cts +2 -2
- package/dist/RadioTabs/index.d.ts +2 -2
- package/dist/RadioTabs/index.js +4 -4
- package/dist/{RadioTabs-BCWW3tru.d.cts → RadioTabs-DTDcAZoH.d.cts} +1 -1
- package/dist/{RadioTabs-BCWW3tru.d.ts → RadioTabs-DTDcAZoH.d.ts} +1 -1
- package/dist/Radios/index.cjs +16 -0
- package/dist/Radios/index.cjs.map +1 -0
- package/dist/Radios/index.d.cts +9 -0
- package/dist/Radios/index.d.ts +9 -0
- package/dist/Radios/index.js +16 -0
- package/dist/{RadioGroup-CAOX80Xx.d.cts → Radios-DprlJhoq.d.cts} +9 -9
- package/dist/{RadioGroup-CAOX80Xx.d.ts → Radios-DprlJhoq.d.ts} +9 -9
- package/dist/Select/index.cjs +5 -5
- package/dist/Select/index.d.cts +2 -2
- package/dist/Select/index.d.ts +2 -2
- package/dist/Select/index.js +4 -4
- package/dist/{Select-CTRWinmO.d.cts → Select-CDkZmZp2.d.cts} +1 -1
- package/dist/{Select-CTRWinmO.d.ts → Select-CDkZmZp2.d.ts} +1 -1
- package/dist/SubmitButton/index.cjs +6 -4
- package/dist/SubmitButton/index.cjs.map +1 -1
- package/dist/SubmitButton/index.js +5 -3
- package/dist/Switch/index.cjs +5 -5
- package/dist/Switch/index.js +4 -4
- package/dist/TextArea/index.cjs +5 -5
- package/dist/TextArea/index.d.cts +4 -2
- package/dist/TextArea/index.d.ts +4 -2
- package/dist/TextArea/index.js +4 -4
- package/dist/TextArea-DhxNWYNg.d.cts +86 -0
- package/dist/TextArea-DhxNWYNg.d.ts +86 -0
- package/dist/chunk-2DHTL4PW.cjs +117 -0
- package/dist/chunk-2DHTL4PW.cjs.map +1 -0
- package/dist/{chunk-FOVP54XP.cjs → chunk-3NH4MEMM.cjs} +18 -27
- package/dist/chunk-3NH4MEMM.cjs.map +1 -0
- package/dist/{chunk-M2DNMSQZ.js → chunk-3Q3IUEGL.js} +52 -49
- package/dist/chunk-3Q3IUEGL.js.map +1 -0
- package/dist/{chunk-JSQ77E6L.js → chunk-4WRUHOGY.js} +49 -47
- package/dist/chunk-4WRUHOGY.js.map +1 -0
- package/dist/{chunk-KG4XCEPW.js → chunk-53XSXUNE.js} +42 -40
- package/dist/chunk-53XSXUNE.js.map +1 -0
- package/dist/{chunk-77C6VN4L.cjs → chunk-5LWD6VRV.cjs} +50 -47
- package/dist/chunk-5LWD6VRV.cjs.map +1 -0
- package/dist/{chunk-C64RKQEW.cjs → chunk-62AYJT2H.cjs} +3 -3
- package/dist/{chunk-C64RKQEW.cjs.map → chunk-62AYJT2H.cjs.map} +1 -1
- package/dist/chunk-76KOVUDN.js +138 -0
- package/dist/chunk-76KOVUDN.js.map +1 -0
- package/dist/{chunk-FHRMVL6B.js → chunk-AYWMAPAX.js} +134 -89
- package/dist/chunk-AYWMAPAX.js.map +1 -0
- package/dist/chunk-BWPTCHL7.cjs +103 -0
- package/dist/chunk-BWPTCHL7.cjs.map +1 -0
- package/dist/{chunk-2GYFDVXX.cjs → chunk-C5GIWGQR.cjs} +173 -33
- package/dist/chunk-C5GIWGQR.cjs.map +1 -0
- package/dist/{chunk-IYDCKENI.js → chunk-CJD3DW4J.js} +166 -26
- package/dist/chunk-CJD3DW4J.js.map +1 -0
- package/dist/{chunk-N2EEOWEP.cjs → chunk-CW4VK77Z.cjs} +59 -64
- package/dist/chunk-CW4VK77Z.cjs.map +1 -0
- package/dist/{chunk-LJQ35BUK.js → chunk-D2HI4KE4.js} +2 -2
- package/dist/chunk-DYTE5N3B.cjs +684 -0
- package/dist/chunk-DYTE5N3B.cjs.map +1 -0
- package/dist/chunk-ELYGQTXB.js +47 -0
- package/dist/chunk-ELYGQTXB.js.map +1 -0
- package/dist/chunk-GST3AQOR.js +684 -0
- package/dist/chunk-GST3AQOR.js.map +1 -0
- package/dist/{chunk-AYNTZPKL.cjs → chunk-HQNZYWJX.cjs} +132 -87
- package/dist/chunk-HQNZYWJX.cjs.map +1 -0
- package/dist/chunk-LLQLEDOO.js +103 -0
- package/dist/chunk-LLQLEDOO.js.map +1 -0
- package/dist/chunk-NHEZXA4H.cjs +47 -0
- package/dist/chunk-NHEZXA4H.cjs.map +1 -0
- package/dist/{chunk-M7VM7XBE.js → chunk-OCYJFIPV.js} +8 -8
- package/dist/chunk-OCYJFIPV.js.map +1 -0
- package/dist/{chunk-ORQO6JXK.cjs → chunk-S36CKKDV.cjs} +45 -43
- package/dist/chunk-S36CKKDV.cjs.map +1 -0
- package/dist/chunk-S7K35LVS.js +117 -0
- package/dist/chunk-S7K35LVS.js.map +1 -0
- package/dist/{chunk-Y3GELCDP.js → chunk-VLEYEBRE.js} +62 -67
- package/dist/chunk-VLEYEBRE.js.map +1 -0
- package/dist/{chunk-UGCZORU3.cjs → chunk-YIBISSMT.cjs} +9 -9
- package/dist/chunk-YIBISSMT.cjs.map +1 -0
- package/dist/chunk-Z353BLWI.cjs +138 -0
- package/dist/chunk-Z353BLWI.cjs.map +1 -0
- package/dist/{chunk-ULR4573W.cjs → chunk-ZLQCMOVU.cjs} +40 -38
- package/dist/chunk-ZLQCMOVU.cjs.map +1 -0
- package/dist/{chunk-2B6CDMOZ.js → chunk-ZN3ESUQR.js} +16 -25
- package/dist/chunk-ZN3ESUQR.js.map +1 -0
- package/dist/helpers/index.cjs +4 -2
- package/dist/helpers/index.cjs.map +1 -1
- package/dist/helpers/index.d.cts +54 -10
- package/dist/helpers/index.d.ts +54 -10
- package/dist/helpers/index.js +3 -1
- package/dist/hooks/index.cjs +7 -3
- package/dist/hooks/index.cjs.map +1 -1
- package/dist/hooks/index.d.cts +86 -4
- package/dist/hooks/index.d.ts +86 -4
- package/dist/hooks/index.js +8 -4
- package/dist/index.cjs +20 -16
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +11 -11
- package/dist/index.d.ts +11 -11
- package/dist/index.js +30 -26
- 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 +13 -12
- package/dist/CheckboxGroup/index.cjs +0 -16
- package/dist/CheckboxGroup/index.cjs.map +0 -1
- package/dist/CheckboxGroup/index.d.cts +0 -10
- package/dist/CheckboxGroup/index.d.ts +0 -10
- package/dist/CheckboxGroup/index.js +0 -16
- package/dist/FieldArray-DVQka7Bh.d.cts +0 -130
- package/dist/FieldArray-DVQka7Bh.d.ts +0 -130
- package/dist/RadioGroup/index.cjs +0 -16
- package/dist/RadioGroup/index.d.cts +0 -9
- package/dist/RadioGroup/index.d.ts +0 -9
- package/dist/RadioGroup/index.js +0 -16
- package/dist/TextArea-DnFGyl4a.d.cts +0 -27
- package/dist/TextArea-DnFGyl4a.d.ts +0 -27
- package/dist/chunk-2B6CDMOZ.js.map +0 -1
- package/dist/chunk-2GYFDVXX.cjs.map +0 -1
- package/dist/chunk-77C6VN4L.cjs.map +0 -1
- package/dist/chunk-AYNTZPKL.cjs.map +0 -1
- package/dist/chunk-CQWA2DFV.js +0 -37
- package/dist/chunk-CQWA2DFV.js.map +0 -1
- package/dist/chunk-EEBHFSBY.cjs +0 -112
- package/dist/chunk-EEBHFSBY.cjs.map +0 -1
- package/dist/chunk-FHRMVL6B.js.map +0 -1
- package/dist/chunk-FOVP54XP.cjs.map +0 -1
- package/dist/chunk-IYDCKENI.js.map +0 -1
- package/dist/chunk-JSQ77E6L.js.map +0 -1
- package/dist/chunk-JZF4HUYO.cjs +0 -409
- package/dist/chunk-JZF4HUYO.cjs.map +0 -1
- package/dist/chunk-KG4XCEPW.js.map +0 -1
- package/dist/chunk-KQN55PEW.js +0 -76
- package/dist/chunk-KQN55PEW.js.map +0 -1
- package/dist/chunk-M2DNMSQZ.js.map +0 -1
- package/dist/chunk-M7VM7XBE.js.map +0 -1
- package/dist/chunk-N2EEOWEP.cjs.map +0 -1
- package/dist/chunk-NAZIH6HV.js +0 -409
- package/dist/chunk-NAZIH6HV.js.map +0 -1
- package/dist/chunk-ORQO6JXK.cjs.map +0 -1
- package/dist/chunk-RDBCJJI7.cjs +0 -88
- package/dist/chunk-RDBCJJI7.cjs.map +0 -1
- package/dist/chunk-RF7KNUCI.js +0 -88
- package/dist/chunk-RF7KNUCI.js.map +0 -1
- package/dist/chunk-UGCZORU3.cjs.map +0 -1
- package/dist/chunk-ULR4573W.cjs.map +0 -1
- package/dist/chunk-XKMLCM5K.js +0 -112
- package/dist/chunk-XKMLCM5K.js.map +0 -1
- package/dist/chunk-Y3AB4GV6.cjs +0 -37
- package/dist/chunk-Y3AB4GV6.cjs.map +0 -1
- package/dist/chunk-Y3GELCDP.js.map +0 -1
- package/dist/chunk-YGNY6CKU.cjs +0 -76
- package/dist/chunk-YGNY6CKU.cjs.map +0 -1
- /package/dist/{CheckboxGroup → Checkboxes}/index.js.map +0 -0
- /package/dist/{RadioGroup → Radios}/index.js.map +0 -0
- /package/dist/{chunk-LJQ35BUK.js.map → chunk-D2HI4KE4.js.map} +0 -0
|
@@ -1,14 +1,14 @@
|
|
|
1
|
+
import {
|
|
2
|
+
useController,
|
|
3
|
+
useFormContext,
|
|
4
|
+
useInput
|
|
5
|
+
} from "./chunk-CJD3DW4J.js";
|
|
1
6
|
import {
|
|
2
7
|
FieldCopyTestIdButton_default
|
|
3
8
|
} from "./chunk-NTDKZW4E.js";
|
|
4
9
|
import {
|
|
5
10
|
FieldValidationError_default
|
|
6
|
-
} from "./chunk-
|
|
7
|
-
import {
|
|
8
|
-
useController,
|
|
9
|
-
useFormContext,
|
|
10
|
-
useInput
|
|
11
|
-
} from "./chunk-IYDCKENI.js";
|
|
11
|
+
} from "./chunk-ELYGQTXB.js";
|
|
12
12
|
import {
|
|
13
13
|
__spreadProps,
|
|
14
14
|
__spreadValues
|
|
@@ -56,9 +56,9 @@ var Switch = ({
|
|
|
56
56
|
labelPlacement: "outside",
|
|
57
57
|
placeholder: " "
|
|
58
58
|
});
|
|
59
|
+
const showTestIdCopyButton = debugMode === "debug-testids";
|
|
59
60
|
const variants = switchVariants();
|
|
60
61
|
const classNames = variantsToClassNames(variants, className, "outerWrapper");
|
|
61
|
-
const showTestIdCopyButton = debugMode === "debug-testids";
|
|
62
62
|
return /* @__PURE__ */ jsxs("div", { className: classNames.outerWrapper, children: [
|
|
63
63
|
/* @__PURE__ */ jsxs(
|
|
64
64
|
HeroSwitch,
|
|
@@ -98,4 +98,4 @@ export {
|
|
|
98
98
|
Switch_default,
|
|
99
99
|
Switch_default2
|
|
100
100
|
};
|
|
101
|
-
//# sourceMappingURL=chunk-
|
|
101
|
+
//# sourceMappingURL=chunk-OCYJFIPV.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';\nimport type { SwitchProps as HeroSwitchProps } from '@heroui/switch';\nimport type { ReactNode } from 'react';\nimport type { FieldValues } from 'react-hook-form';\n\nimport { Switch as HeroSwitch } from '@heroui/switch';\n\nimport { tv, variantsToClassNames } from '@fuf-stack/pixel-utils';\n\nimport { useController, useFormContext, useInput } 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: 'mt-1 ml-1',\n // see HeroUI styles for group-data condition,\n // e.g.: https://github.com/heroui-inc/heroui/blob/main/packages/core/theme/src/components/select.ts\n label:\n 'text-foreground group-data-[invalid=true]:!text-danger group-data-[required=true]:after:text-danger text-sm subpixel-antialiased group-data-[required=true]:after:ml-0.5 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 /** Icon to be displayed at the end of the switch (when enabled) */\n endContent?: ReactNode;\n /** component displayed next to the switch */\n label?: ReactNode;\n /** name the field is registered under */\n name: string;\n /* Size of the switch */\n size?: 'sm' | 'md' | 'lg';\n /** Icon to be displayed at the start of the switch (when disabled) */\n startContent?: ReactNode;\n /** HTML data-testid attribute used in e2e tests */\n testId?: string;\n /** Icon to be displayed inside the thumb */\n thumbIcon?: HeroSwitchProps['thumbIcon'];\n}\n\n/**\n * Switch component based on [HeroUI Switch](https://www.heroui.com//docs/components/switch)\n */\nconst Switch = ({\n className = undefined,\n disabled = false,\n endContent = undefined,\n label: _label = undefined,\n name,\n size = undefined,\n startContent = undefined,\n testId: _testId = undefined,\n thumbIcon = undefined,\n}: SwitchProps) => {\n const { control, debugMode, getFieldState } = useFormContext();\n const { error, required, testId, invalid } = getFieldState(name, _testId);\n\n const { field } = useController<FieldValues>({ name, control, disabled });\n const { disabled: isDisabled, value, ref, onBlur, onChange } = field;\n\n const { label, getInputProps, getErrorMessageProps } = useInput({\n errorMessage: JSON.stringify(error),\n isInvalid: invalid,\n isRequired: required,\n label: _label,\n labelPlacement: 'outside',\n placeholder: ' ',\n });\n\n const showTestIdCopyButton = debugMode === 'debug-testids';\n\n // classNames from slots\n const variants = switchVariants();\n const classNames = variantsToClassNames(variants, className, 'outerWrapper');\n\n return (\n <div className={classNames.outerWrapper}>\n <HeroSwitch\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 aria-describedby={getInputProps()['aria-describedby']}\n classNames={classNames}\n data-invalid={invalid}\n data-required={required}\n data-testid={testId}\n endContent={endContent}\n isDisabled={isDisabled}\n isSelected={!!value}\n name={name}\n onBlur={onBlur}\n onValueChange={onChange}\n required={required}\n size={size}\n startContent={startContent}\n thumbIcon={thumbIcon}\n value={value}\n >\n {label}\n {showTestIdCopyButton ? (\n <FieldCopyTestIdButton testId={testId} />\n ) : null}\n </HeroSwitch>\n {error ? (\n <div className={classNames.errorMessage}>\n <div {...getErrorMessageProps()}>\n <FieldValidationError error={error} testId={testId} />\n </div>\n </div>\n ) : null}\n </div>\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":";;;;;;;;;;;;;;;;;AAKA,SAAS,UAAU,kBAAkB;AAErC,SAAS,IAAI,4BAA4B;AAoFnC,SAuBI,KAvBJ;AA9EC,IAAM,iBAAiB,GAAG;AAAA,EAC/B,OAAO;AAAA,IACL,MAAM;AAAA,IACN,YAAY;AAAA,IACZ,cAAc;AAAA;AAAA;AAAA,IAGd,OACE;AAAA,IACF,cAAc;AAAA,IACd,cAAc;AAAA,IACd,OAAO;AAAA,IACP,WAAW;AAAA,IACX,SAAS;AAAA,EACX;AACF,CAAC;AA6BD,IAAM,SAAS,CAAC;AAAA,EACd,YAAY;AAAA,EACZ,WAAW;AAAA,EACX,aAAa;AAAA,EACb,OAAO,SAAS;AAAA,EAChB;AAAA,EACA,OAAO;AAAA,EACP,eAAe;AAAA,EACf,QAAQ,UAAU;AAAA,EAClB,YAAY;AACd,MAAmB;AACjB,QAAM,EAAE,SAAS,WAAW,cAAc,IAAI,eAAe;AAC7D,QAAM,EAAE,OAAO,UAAU,QAAQ,QAAQ,IAAI,cAAc,MAAM,OAAO;AAExE,QAAM,EAAE,MAAM,IAAI,cAA2B,EAAE,MAAM,SAAS,SAAS,CAAC;AACxE,QAAM,EAAE,UAAU,YAAY,OAAO,KAAK,QAAQ,SAAS,IAAI;AAE/D,QAAM,EAAE,OAAO,eAAe,qBAAqB,IAAI,SAAS;AAAA,IAC9D,cAAc,KAAK,UAAU,KAAK;AAAA,IAClC,WAAW;AAAA,IACX,YAAY;AAAA,IACZ,OAAO;AAAA,IACP,gBAAgB;AAAA,IAChB,aAAa;AAAA,EACf,CAAC;AAED,QAAM,uBAAuB,cAAc;AAG3C,QAAM,WAAW,eAAe;AAChC,QAAM,aAAa,qBAAqB,UAAU,WAAW,cAAc;AAE3E,SACE,qBAAC,SAAI,WAAW,WAAW,cACzB;AAAA;AAAA,MAAC;AAAA;AAAA,QACC;AAAA,QAGA,oBAAkB,cAAc,EAAE,kBAAkB;AAAA,QACpD;AAAA,QACA,gBAAc;AAAA,QACd,iBAAe;AAAA,QACf,eAAa;AAAA,QACb;AAAA,QACA;AAAA,QACA,YAAY,CAAC,CAAC;AAAA,QACd;AAAA,QACA;AAAA,QACA,eAAe;AAAA,QACf;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QAEC;AAAA;AAAA,UACA,uBACC,oBAAC,iCAAsB,QAAgB,IACrC;AAAA;AAAA;AAAA,IACN;AAAA,IACC,QACC,oBAAC,SAAI,WAAW,WAAW,cACzB,8BAAC,wCAAQ,qBAAqB,IAA7B,EACC,8BAAC,gCAAqB,OAAc,QAAgB,IACtD,GACF,IACE;AAAA,KACN;AAEJ;AAEA,IAAO,iBAAQ;;;AC1Hf,IAAOA,kBAAQ;","names":["Switch_default"]}
|
|
@@ -1,13 +1,10 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _chunkC5GIWGQRcjs = require('./chunk-C5GIWGQR.cjs');
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
var _chunkY3AB4GV6cjs = require('./chunk-Y3AB4GV6.cjs');
|
|
7
6
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
var _chunk2GYFDVXXcjs = require('./chunk-2GYFDVXX.cjs');
|
|
7
|
+
var _chunk555JRYCScjs = require('./chunk-555JRYCS.cjs');
|
|
11
8
|
|
|
12
9
|
// src/RadioTabs/RadioTabs.tsx
|
|
13
10
|
var _radio = require('@heroui/radio');
|
|
@@ -16,10 +13,10 @@ var _Tabs = require('@fuf-stack/pixels/Tabs'); var _Tabs2 = _interopRequireDefau
|
|
|
16
13
|
var _jsxruntime = require('react/jsx-runtime');
|
|
17
14
|
var radioTabsVariants = _pixelutils.tv.call(void 0, {
|
|
18
15
|
slots: {
|
|
19
|
-
base: "group",
|
|
16
|
+
base: "group gap-0",
|
|
20
17
|
// Needs group for group-data condition
|
|
21
18
|
cursor: "",
|
|
22
|
-
label: "text-foreground group-data-[invalid=true]:text-danger text-sm subpixel-antialiased",
|
|
19
|
+
label: "text-foreground group-data-[invalid=true]:text-danger mb-2 inline-flex text-sm subpixel-antialiased",
|
|
23
20
|
tab: "",
|
|
24
21
|
tabBase: "",
|
|
25
22
|
tabContent: "",
|
|
@@ -31,7 +28,7 @@ var radioTabsVariants = _pixelutils.tv.call(void 0, {
|
|
|
31
28
|
variants: {
|
|
32
29
|
hasContent: {
|
|
33
30
|
true: {
|
|
34
|
-
base: "
|
|
31
|
+
base: "",
|
|
35
32
|
tabBase: "p-1 pb-0",
|
|
36
33
|
tabWrapper: [
|
|
37
34
|
// border style
|
|
@@ -48,36 +45,42 @@ var radioTabsVariants = _pixelutils.tv.call(void 0, {
|
|
|
48
45
|
}
|
|
49
46
|
}
|
|
50
47
|
});
|
|
51
|
-
var RadioTabs = ({
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
const
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
48
|
+
var RadioTabs = (_a) => {
|
|
49
|
+
var _b = _a, {
|
|
50
|
+
className = void 0,
|
|
51
|
+
fullWidth = false,
|
|
52
|
+
inline = false,
|
|
53
|
+
name,
|
|
54
|
+
options,
|
|
55
|
+
variant = void 0
|
|
56
|
+
} = _b, uniformFieldProps = _chunk555JRYCScjs.__objRest.call(void 0, _b, [
|
|
57
|
+
"className",
|
|
58
|
+
"fullWidth",
|
|
59
|
+
"inline",
|
|
60
|
+
"name",
|
|
61
|
+
"options",
|
|
62
|
+
"variant"
|
|
63
|
+
]);
|
|
64
|
+
const {
|
|
65
|
+
disabled,
|
|
66
|
+
errorMessage,
|
|
67
|
+
field: { onBlur, onChange, ref, value },
|
|
68
|
+
invalid,
|
|
69
|
+
label,
|
|
70
|
+
required,
|
|
71
|
+
testId
|
|
72
|
+
} = _chunkC5GIWGQRcjs.useUniformField.call(void 0, _chunk555JRYCScjs.__spreadValues.call(void 0, {
|
|
73
|
+
name,
|
|
74
|
+
showInvalidWhen: "immediate"
|
|
75
|
+
}, uniformFieldProps));
|
|
73
76
|
const tabOptions = options.map((option) => {
|
|
74
|
-
var
|
|
77
|
+
var _a2, _b2;
|
|
75
78
|
return {
|
|
76
79
|
content: option == null ? void 0 : option.content,
|
|
77
80
|
disabled: option == null ? void 0 : option.disabled,
|
|
78
81
|
key: option.value,
|
|
79
|
-
label: (
|
|
80
|
-
testId: _pixelutils.slugify.call(void 0, `option_${(
|
|
82
|
+
label: (_a2 = option == null ? void 0 : option.label) != null ? _a2 : option == null ? void 0 : option.value,
|
|
83
|
+
testId: _pixelutils.slugify.call(void 0, `option_${(_b2 = option == null ? void 0 : option.testId) != null ? _b2 : option == null ? void 0 : option.value}`, {
|
|
81
84
|
replaceDots: true
|
|
82
85
|
})
|
|
83
86
|
};
|
|
@@ -85,6 +88,11 @@ var RadioTabs = ({
|
|
|
85
88
|
const disabledAllKeys = tabOptions == null ? void 0 : tabOptions.map((option) => {
|
|
86
89
|
return option.key;
|
|
87
90
|
});
|
|
91
|
+
const hasContent = options.some((option) => {
|
|
92
|
+
return option.content;
|
|
93
|
+
});
|
|
94
|
+
const variants = radioTabsVariants({ hasContent, fullWidth });
|
|
95
|
+
const classNames = _pixelutils.variantsToClassNames.call(void 0, variants, className, "base");
|
|
88
96
|
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
89
97
|
_radio.RadioGroup,
|
|
90
98
|
{
|
|
@@ -92,9 +100,11 @@ var RadioTabs = ({
|
|
|
92
100
|
"data-invalid": invalid,
|
|
93
101
|
"data-required": required,
|
|
94
102
|
"data-testid": testId,
|
|
95
|
-
|
|
103
|
+
errorMessage,
|
|
104
|
+
isDisabled: disabled,
|
|
96
105
|
isInvalid: invalid,
|
|
97
106
|
isRequired: required,
|
|
107
|
+
label: label ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "legend", { children: label }) : null,
|
|
98
108
|
name,
|
|
99
109
|
onBlur,
|
|
100
110
|
orientation: inline ? "horizontal" : "vertical",
|
|
@@ -103,14 +113,6 @@ var RadioTabs = ({
|
|
|
103
113
|
label: classNames.label,
|
|
104
114
|
wrapper: classNames.wrapper
|
|
105
115
|
},
|
|
106
|
-
errorMessage: error ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkY3AB4GV6cjs.FieldValidationError_default, { error, testId }) : void 0,
|
|
107
|
-
label: showLabel ? (
|
|
108
|
-
// eslint-disable-next-line jsx-a11y/label-has-associated-control
|
|
109
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "label", { children: [
|
|
110
|
-
label,
|
|
111
|
-
showTestIdCopyButton ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkOE5BOGGXcjs.FieldCopyTestIdButton_default, { testId }) : null
|
|
112
|
-
] })
|
|
113
|
-
) : void 0,
|
|
114
116
|
children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
115
117
|
_Tabs2.default,
|
|
116
118
|
{
|
|
@@ -143,4 +145,4 @@ var RadioTabs_default2 = RadioTabs_default;
|
|
|
143
145
|
|
|
144
146
|
|
|
145
147
|
exports.RadioTabs_default = RadioTabs_default; exports.RadioTabs_default2 = RadioTabs_default2;
|
|
146
|
-
//# sourceMappingURL=chunk-
|
|
148
|
+
//# sourceMappingURL=chunk-S36CKKDV.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/home/runner/work/pixels/pixels/packages/uniform/dist/chunk-S36CKKDV.cjs","../src/RadioTabs/RadioTabs.tsx","../src/RadioTabs/index.ts"],"names":["_a","_b"],"mappings":"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","file":"/home/runner/work/pixels/pixels/packages/uniform/dist/chunk-S36CKKDV.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 { useUniformField } from '../hooks';\n\nexport const radioTabsVariants = tv({\n slots: {\n base: 'group gap-0', // Needs group for group-data condition\n cursor: '',\n label:\n 'text-foreground group-data-[invalid=true]:text-danger mb-2 inline-flex 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: '',\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 fullWidth = false,\n inline = false,\n name,\n options,\n variant = undefined,\n ...uniformFieldProps\n}: RadioTabsProps): ReactElement => {\n const {\n disabled,\n errorMessage,\n field: { onBlur, onChange, ref, value },\n invalid,\n label,\n required,\n testId,\n } = useUniformField({\n name,\n showInvalidWhen: 'immediate',\n ...uniformFieldProps,\n });\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 // 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 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 errorMessage={errorMessage}\n isDisabled={disabled}\n isInvalid={invalid}\n isRequired={required}\n label={label ? <legend>{label}</legend> : null}\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 >\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"]}
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import {
|
|
2
|
+
useUniformField
|
|
3
|
+
} from "./chunk-CJD3DW4J.js";
|
|
4
|
+
import {
|
|
5
|
+
__objRest,
|
|
6
|
+
__spreadValues
|
|
7
|
+
} from "./chunk-K2V4ULA2.js";
|
|
8
|
+
|
|
9
|
+
// src/Radios/Radios.tsx
|
|
10
|
+
import {
|
|
11
|
+
Radio as HeroRadio,
|
|
12
|
+
RadioGroup as HeroRadioGroup
|
|
13
|
+
} from "@heroui/radio";
|
|
14
|
+
import { slugify, tv, variantsToClassNames } from "@fuf-stack/pixel-utils";
|
|
15
|
+
import { jsx } from "react/jsx-runtime";
|
|
16
|
+
var radiosVariants = tv({
|
|
17
|
+
slots: {
|
|
18
|
+
// Needs group for group-data condition
|
|
19
|
+
base: "group gap-0",
|
|
20
|
+
itemBase: "",
|
|
21
|
+
itemControl: "bg-focus group-data-[invalid=true]:bg-danger",
|
|
22
|
+
itemDescription: "",
|
|
23
|
+
itemLabel: "text-sm",
|
|
24
|
+
itemLabelWrapper: "",
|
|
25
|
+
itemWrapper: 'group-data-[invalid=true]:border-danger! [&:not(group-data-[invalid="true"]):not(group-data-[selected="false"])]:border-focus',
|
|
26
|
+
// e.g.: https://github.com/heroui-inc/heroui/blob/main/packages/core/theme/src/components/select.ts
|
|
27
|
+
label: "text-foreground group-data-[invalid=true]:text-danger mb-2 inline-flex text-sm subpixel-antialiased",
|
|
28
|
+
wrapper: ""
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
var Radios = (_a) => {
|
|
32
|
+
var _b = _a, {
|
|
33
|
+
className = void 0,
|
|
34
|
+
inline = false,
|
|
35
|
+
name,
|
|
36
|
+
options
|
|
37
|
+
} = _b, uniformFieldProps = __objRest(_b, [
|
|
38
|
+
"className",
|
|
39
|
+
"inline",
|
|
40
|
+
"name",
|
|
41
|
+
"options"
|
|
42
|
+
]);
|
|
43
|
+
const {
|
|
44
|
+
disabled,
|
|
45
|
+
errorMessage,
|
|
46
|
+
field: { onBlur, onChange, ref },
|
|
47
|
+
invalid,
|
|
48
|
+
label,
|
|
49
|
+
required,
|
|
50
|
+
defaultValue,
|
|
51
|
+
testId
|
|
52
|
+
} = useUniformField(__spreadValues({
|
|
53
|
+
name,
|
|
54
|
+
showInvalidWhen: "immediate"
|
|
55
|
+
}, uniformFieldProps));
|
|
56
|
+
const variants = radiosVariants();
|
|
57
|
+
const classNames = variantsToClassNames(variants, className, "base");
|
|
58
|
+
const itemClassNames = {
|
|
59
|
+
base: classNames.itemBase,
|
|
60
|
+
control: classNames.itemControl,
|
|
61
|
+
description: classNames.itemDescription,
|
|
62
|
+
label: classNames.itemLabel,
|
|
63
|
+
labelWrapper: classNames.itemLabelWrapper,
|
|
64
|
+
wrapper: classNames.itemWrapper
|
|
65
|
+
};
|
|
66
|
+
return /* @__PURE__ */ jsx(
|
|
67
|
+
HeroRadioGroup,
|
|
68
|
+
{
|
|
69
|
+
ref,
|
|
70
|
+
classNames,
|
|
71
|
+
"data-invalid": invalid,
|
|
72
|
+
"data-required": required,
|
|
73
|
+
"data-testid": testId,
|
|
74
|
+
defaultValue,
|
|
75
|
+
errorMessage,
|
|
76
|
+
isDisabled: disabled,
|
|
77
|
+
isInvalid: invalid,
|
|
78
|
+
isRequired: required,
|
|
79
|
+
label: label ? /* @__PURE__ */ jsx("legend", { children: label }) : null,
|
|
80
|
+
name,
|
|
81
|
+
onBlur,
|
|
82
|
+
orientation: inline ? "horizontal" : "vertical",
|
|
83
|
+
children: options.map((option) => {
|
|
84
|
+
var _a2, _b2;
|
|
85
|
+
if ("value" in option) {
|
|
86
|
+
const optionTestId = slugify(
|
|
87
|
+
`${testId}_option_${(_a2 = option.testId) != null ? _a2 : option.value}`,
|
|
88
|
+
{ replaceDots: true }
|
|
89
|
+
);
|
|
90
|
+
return /* @__PURE__ */ jsx(
|
|
91
|
+
HeroRadio,
|
|
92
|
+
{
|
|
93
|
+
classNames: itemClassNames,
|
|
94
|
+
"data-testid": optionTestId,
|
|
95
|
+
isDisabled: !!disabled || option.disabled,
|
|
96
|
+
onChange,
|
|
97
|
+
value: option.value,
|
|
98
|
+
children: (_b2 = option.label) != null ? _b2 : option.value
|
|
99
|
+
},
|
|
100
|
+
option.value
|
|
101
|
+
);
|
|
102
|
+
}
|
|
103
|
+
return null;
|
|
104
|
+
})
|
|
105
|
+
}
|
|
106
|
+
);
|
|
107
|
+
};
|
|
108
|
+
var Radios_default = Radios;
|
|
109
|
+
|
|
110
|
+
// src/Radios/index.ts
|
|
111
|
+
var Radios_default2 = Radios_default;
|
|
112
|
+
|
|
113
|
+
export {
|
|
114
|
+
Radios_default,
|
|
115
|
+
Radios_default2
|
|
116
|
+
};
|
|
117
|
+
//# sourceMappingURL=chunk-S7K35LVS.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/Radios/Radios.tsx","../src/Radios/index.ts"],"sourcesContent":["import type { TVClassName, TVProps } from '@fuf-stack/pixel-utils';\nimport type { ReactElement, ReactNode } from 'react';\n\nimport {\n Radio as HeroRadio,\n RadioGroup as HeroRadioGroup,\n} from '@heroui/radio';\n\nimport { slugify, tv, variantsToClassNames } from '@fuf-stack/pixel-utils';\n\nimport { useUniformField } from '../hooks';\n\nexport const radiosVariants = tv({\n slots: {\n // Needs group for group-data condition\n base: 'group gap-0',\n itemBase: '',\n itemControl: 'bg-focus group-data-[invalid=true]:bg-danger',\n itemDescription: '',\n itemLabel: 'text-sm',\n itemLabelWrapper: '',\n itemWrapper:\n 'group-data-[invalid=true]:border-danger! [&:not(group-data-[invalid=\"true\"]):not(group-data-[selected=\"false\"])]:border-focus',\n // e.g.: https://github.com/heroui-inc/heroui/blob/main/packages/core/theme/src/components/select.ts\n label:\n 'text-foreground group-data-[invalid=true]:text-danger mb-2 inline-flex text-sm subpixel-antialiased',\n wrapper: '',\n },\n});\n\ntype VariantProps = TVProps<typeof radiosVariants>;\ntype ClassName = TVClassName<typeof radiosVariants>;\n\nexport interface RadioOption {\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 RadiosProps 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: RadioOption[];\n /** Id to grab element in internal tests. */\n testId?: string;\n}\n\n/**\n * Radios component based on [HeroUI RadioGroup](https://www.heroui.com//docs/components/radio-group)\n */\nconst Radios = ({\n className = undefined,\n inline = false,\n name,\n options,\n ...uniformFieldProps\n}: RadiosProps): ReactElement => {\n const {\n disabled,\n errorMessage,\n field: { onBlur, onChange, ref },\n invalid,\n label,\n required,\n defaultValue,\n testId,\n } = useUniformField({\n name,\n showInvalidWhen: 'immediate',\n ...uniformFieldProps,\n });\n\n // classNames from slots\n const variants = radiosVariants();\n const classNames = variantsToClassNames(variants, className, 'base');\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 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 defaultValue={defaultValue as string | undefined}\n errorMessage={errorMessage}\n isDisabled={disabled}\n isInvalid={invalid}\n isRequired={required}\n label={label ? <legend>{label}</legend> : null}\n name={name}\n onBlur={onBlur}\n orientation={inline ? 'horizontal' : 'vertical'}\n >\n {options.map((option) => {\n if ('value' in option) {\n const optionTestId = slugify(\n `${testId}_option_${option.testId ?? option.value}`,\n { replaceDots: true },\n );\n return (\n <HeroRadio\n key={option.value}\n classNames={itemClassNames}\n data-testid={optionTestId}\n isDisabled={!!disabled || option.disabled}\n onChange={onChange}\n value={option.value}\n >\n {option.label ?? option.value}\n </HeroRadio>\n );\n }\n return null;\n })}\n </HeroRadioGroup>\n );\n};\n\nexport default Radios;\n","import Radios from './Radios';\n\nexport type { RadiosProps } from './Radios';\n\nexport { Radios };\n\nexport default Radios;\n"],"mappings":";;;;;;;;;AAGA;AAAA,EACE,SAAS;AAAA,EACT,cAAc;AAAA,OACT;AAEP,SAAS,SAAS,IAAI,4BAA4B;AA2G7B;AAvGd,IAAM,iBAAiB,GAAG;AAAA,EAC/B,OAAO;AAAA;AAAA,IAEL,MAAM;AAAA,IACN,UAAU;AAAA,IACV,aAAa;AAAA,IACb,iBAAiB;AAAA,IACjB,WAAW;AAAA,IACX,kBAAkB;AAAA,IAClB,aACE;AAAA;AAAA,IAEF,OACE;AAAA,IACF,SAAS;AAAA,EACX;AACF,CAAC;AAsCD,IAAM,SAAS,CAAC,OAMiB;AANjB,eACd;AAAA,gBAAY;AAAA,IACZ,SAAS;AAAA,IACT;AAAA,IACA;AAAA,EAtEF,IAkEgB,IAKX,8BALW,IAKX;AAAA,IAJH;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA;AAGA,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA,OAAO,EAAE,QAAQ,UAAU,IAAI;AAAA,IAC/B;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,IAAI,gBAAgB;AAAA,IAClB;AAAA,IACA,iBAAiB;AAAA,KACd,kBACJ;AAGD,QAAM,WAAW,eAAe;AAChC,QAAM,aAAa,qBAAqB,UAAU,WAAW,MAAM;AAEnE,QAAM,iBAAiB;AAAA,IACrB,MAAM,WAAW;AAAA,IACjB,SAAS,WAAW;AAAA,IACpB,aAAa,WAAW;AAAA,IACxB,OAAO,WAAW;AAAA,IAClB,cAAc,WAAW;AAAA,IACzB,SAAS,WAAW;AAAA,EACtB;AAEA,SACE;AAAA,IAAC;AAAA;AAAA,MACC;AAAA,MACA;AAAA,MAGA,gBAAc;AAAA,MACd,iBAAe;AAAA,MACf,eAAa;AAAA,MACb;AAAA,MACA;AAAA,MACA,YAAY;AAAA,MACZ,WAAW;AAAA,MACX,YAAY;AAAA,MACZ,OAAO,QAAQ,oBAAC,YAAQ,iBAAM,IAAY;AAAA,MAC1C;AAAA,MACA;AAAA,MACA,aAAa,SAAS,eAAe;AAAA,MAEpC,kBAAQ,IAAI,CAAC,WAAW;AAxH/B,YAAAA,KAAAC;AAyHQ,YAAI,WAAW,QAAQ;AACrB,gBAAM,eAAe;AAAA,YACnB,GAAG,MAAM,YAAWD,MAAA,OAAO,WAAP,OAAAA,MAAiB,OAAO,KAAK;AAAA,YACjD,EAAE,aAAa,KAAK;AAAA,UACtB;AACA,iBACE;AAAA,YAAC;AAAA;AAAA,cAEC,YAAY;AAAA,cACZ,eAAa;AAAA,cACb,YAAY,CAAC,CAAC,YAAY,OAAO;AAAA,cACjC;AAAA,cACA,OAAO,OAAO;AAAA,cAEb,WAAAC,MAAA,OAAO,UAAP,OAAAA,MAAgB,OAAO;AAAA;AAAA,YAPnB,OAAO;AAAA,UAQd;AAAA,QAEJ;AACA,eAAO;AAAA,MACT,CAAC;AAAA;AAAA,EACH;AAEJ;AAEA,IAAO,iBAAQ;;;AC3If,IAAOC,kBAAQ;","names":["_a","_b","Radios_default"]}
|
|
@@ -1,19 +1,16 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
} from "./chunk-
|
|
2
|
+
useUniformField
|
|
3
|
+
} from "./chunk-CJD3DW4J.js";
|
|
4
4
|
import {
|
|
5
5
|
FieldValidationError_default
|
|
6
|
-
} from "./chunk-
|
|
7
|
-
import {
|
|
8
|
-
useController,
|
|
9
|
-
useFormContext
|
|
10
|
-
} from "./chunk-IYDCKENI.js";
|
|
6
|
+
} from "./chunk-ELYGQTXB.js";
|
|
11
7
|
import {
|
|
8
|
+
__objRest,
|
|
12
9
|
__spreadProps,
|
|
13
10
|
__spreadValues
|
|
14
11
|
} from "./chunk-K2V4ULA2.js";
|
|
15
12
|
|
|
16
|
-
// src/
|
|
13
|
+
// src/Checkboxes/Checkboxes.tsx
|
|
17
14
|
import {
|
|
18
15
|
Checkbox as HeroCheckbox,
|
|
19
16
|
CheckboxGroup as HeroCheckboxGroup
|
|
@@ -21,14 +18,14 @@ import {
|
|
|
21
18
|
import { checkbox as heroCheckboxVariants } from "@heroui/theme";
|
|
22
19
|
import { slugify, tv, variantsToClassNames } from "@fuf-stack/pixel-utils";
|
|
23
20
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
24
|
-
var
|
|
21
|
+
var checkboxesVariants = tv({
|
|
25
22
|
slots: {
|
|
26
23
|
base: "group",
|
|
27
24
|
// Needs group for group-data condition
|
|
28
25
|
errorMessage: "text-tiny",
|
|
29
26
|
// see HeroUI styles for group-data condition,
|
|
30
27
|
// e.g.: https://github.com/heroui-inc/heroui/blob/main/packages/core/theme/src/components/select.ts
|
|
31
|
-
label: "text-foreground group-data-[invalid=true]:!text-danger text-sm subpixel-antialiased",
|
|
28
|
+
label: "text-foreground group-data-[invalid=true]:!text-danger inline-flex text-sm subpixel-antialiased",
|
|
32
29
|
optionBase: "",
|
|
33
30
|
optionIcon: "",
|
|
34
31
|
optionLabel: "",
|
|
@@ -55,44 +52,39 @@ var checkboxGroupVariants = tv({
|
|
|
55
52
|
}
|
|
56
53
|
}
|
|
57
54
|
});
|
|
58
|
-
var
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
55
|
+
var Checkboxes = (_a) => {
|
|
56
|
+
var _b = _a, {
|
|
57
|
+
className = void 0,
|
|
58
|
+
color = "primary",
|
|
59
|
+
inline = false,
|
|
60
|
+
lineThrough = false,
|
|
61
|
+
options,
|
|
62
|
+
name
|
|
63
|
+
} = _b, uniformFieldProps = __objRest(_b, [
|
|
64
|
+
"className",
|
|
65
|
+
"color",
|
|
66
|
+
"inline",
|
|
67
|
+
"lineThrough",
|
|
68
|
+
"options",
|
|
69
|
+
"name"
|
|
70
|
+
]);
|
|
71
|
+
var _a2;
|
|
70
72
|
const {
|
|
73
|
+
disabled,
|
|
71
74
|
error: _error,
|
|
75
|
+
field: { onChange, value = [], ref, onBlur },
|
|
72
76
|
invalid,
|
|
77
|
+
label,
|
|
73
78
|
required,
|
|
74
79
|
testId
|
|
75
|
-
} =
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
const
|
|
80
|
-
const variants = checkboxGroupVariants({ lineThrough });
|
|
81
|
-
const classNames = variantsToClassNames(variants, className, "base");
|
|
82
|
-
const heroCheckboxGroupClassNames = {
|
|
83
|
-
base: classNames.base,
|
|
84
|
-
label: classNames.label,
|
|
85
|
-
wrapper: classNames.wrapper
|
|
86
|
-
};
|
|
87
|
-
const heroCheckboxClassNames = {
|
|
88
|
-
base: classNames.optionBase,
|
|
89
|
-
icon: classNames.optionIcon,
|
|
90
|
-
label: classNames.optionLabel,
|
|
91
|
-
wrapper: classNames.optionWrapper
|
|
92
|
-
};
|
|
93
|
-
const errorFlat = _error && Object.values(
|
|
80
|
+
} = useUniformField(__spreadValues({
|
|
81
|
+
name,
|
|
82
|
+
showInvalidWhen: "immediate"
|
|
83
|
+
}, uniformFieldProps));
|
|
84
|
+
const errorFlat = (_a2 = _error && Object.values(
|
|
94
85
|
_error
|
|
95
|
-
).flat()
|
|
86
|
+
).flat()) != null ? _a2 : [];
|
|
87
|
+
const errorMessage = /* @__PURE__ */ jsx(FieldValidationError_default, { error: errorFlat, testId });
|
|
96
88
|
const getCheckboxValue = (inputValue) => {
|
|
97
89
|
if (Array.isArray(inputValue)) {
|
|
98
90
|
return inputValue;
|
|
@@ -112,38 +104,41 @@ var CheckboxGroup = ({
|
|
|
112
104
|
onChange,
|
|
113
105
|
value: getCheckboxValue(value)
|
|
114
106
|
};
|
|
115
|
-
const
|
|
107
|
+
const checkboxesProps = options.length === 1 ? singleCheckboxProps : multipleCheckboxProps;
|
|
108
|
+
const variants = checkboxesVariants({ lineThrough });
|
|
109
|
+
const classNames = variantsToClassNames(variants, className, "base");
|
|
110
|
+
const heroCheckboxGroupClassNames = {
|
|
111
|
+
base: classNames.base,
|
|
112
|
+
label: classNames.label,
|
|
113
|
+
wrapper: classNames.wrapper
|
|
114
|
+
};
|
|
115
|
+
const heroCheckboxClassNames = {
|
|
116
|
+
base: classNames.optionBase,
|
|
117
|
+
icon: classNames.optionIcon,
|
|
118
|
+
label: classNames.optionLabel,
|
|
119
|
+
wrapper: classNames.optionWrapper
|
|
120
|
+
};
|
|
116
121
|
return /* @__PURE__ */ jsx(
|
|
117
122
|
HeroCheckboxGroup,
|
|
118
123
|
__spreadProps(__spreadValues({
|
|
124
|
+
ref,
|
|
119
125
|
classNames: heroCheckboxGroupClassNames,
|
|
120
126
|
color: color === "info" ? "primary" : color,
|
|
121
127
|
"data-invalid": invalid,
|
|
122
128
|
"data-testid": testId,
|
|
129
|
+
errorMessage,
|
|
123
130
|
isDisabled: disabled,
|
|
124
131
|
isInvalid: invalid,
|
|
125
132
|
isRequired: required,
|
|
133
|
+
label: label ? /* @__PURE__ */ jsx("legend", { children: label }) : null,
|
|
126
134
|
name,
|
|
127
135
|
onBlur,
|
|
128
|
-
orientation: inline ? "horizontal" : "vertical"
|
|
129
|
-
|
|
130
|
-
FieldValidationError_default,
|
|
131
|
-
{
|
|
132
|
-
className: classNames.errorMessage,
|
|
133
|
-
error: errorFlat,
|
|
134
|
-
testId
|
|
135
|
-
}
|
|
136
|
-
),
|
|
137
|
-
label: showLabel && // eslint-disable-next-line jsx-a11y/label-has-associated-control
|
|
138
|
-
/* @__PURE__ */ jsxs("label", { children: [
|
|
139
|
-
label,
|
|
140
|
-
showTestIdCopyButton && /* @__PURE__ */ jsx(FieldCopyTestIdButton_default, { testId })
|
|
141
|
-
] }),
|
|
142
|
-
ref
|
|
143
|
-
}, checkboxGroupProps), {
|
|
136
|
+
orientation: inline ? "horizontal" : "vertical"
|
|
137
|
+
}, checkboxesProps), {
|
|
144
138
|
children: options == null ? void 0 : options.map((option) => {
|
|
139
|
+
var _a3;
|
|
145
140
|
const optionTestId = slugify(
|
|
146
|
-
`${testId}_option_${(option == null ? void 0 : option.testId)
|
|
141
|
+
`${testId}_option_${(_a3 = option == null ? void 0 : option.testId) != null ? _a3 : option == null ? void 0 : option.value}`,
|
|
147
142
|
{ replaceDots: true }
|
|
148
143
|
);
|
|
149
144
|
const hasSubline = !!option.labelSubline;
|
|
@@ -164,7 +159,7 @@ var CheckboxGroup = ({
|
|
|
164
159
|
classNames: optionClassNames,
|
|
165
160
|
"data-invalid": invalid,
|
|
166
161
|
"data-testid": optionTestId,
|
|
167
|
-
isDisabled: disabled || option.disabled,
|
|
162
|
+
isDisabled: !!disabled || option.disabled,
|
|
168
163
|
value: option == null ? void 0 : option.value,
|
|
169
164
|
"aria-label": typeof option.label === "string" ? option.label : option.value,
|
|
170
165
|
children: labelContent
|
|
@@ -175,13 +170,13 @@ var CheckboxGroup = ({
|
|
|
175
170
|
})
|
|
176
171
|
);
|
|
177
172
|
};
|
|
178
|
-
var
|
|
173
|
+
var Checkboxes_default = Checkboxes;
|
|
179
174
|
|
|
180
|
-
// src/
|
|
181
|
-
var
|
|
175
|
+
// src/Checkboxes/index.ts
|
|
176
|
+
var Checkboxes_default2 = Checkboxes_default;
|
|
182
177
|
|
|
183
178
|
export {
|
|
184
|
-
|
|
185
|
-
|
|
179
|
+
Checkboxes_default,
|
|
180
|
+
Checkboxes_default2
|
|
186
181
|
};
|
|
187
|
-
//# sourceMappingURL=chunk-
|
|
182
|
+
//# sourceMappingURL=chunk-VLEYEBRE.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/Checkboxes/Checkboxes.tsx","../src/Checkboxes/index.ts"],"sourcesContent":["import type { TVClassName, TVProps } from '@fuf-stack/pixel-utils';\nimport type {\n CheckboxGroupProps as HeroCheckboxGroupProps,\n CheckboxProps as HeroCheckboxProps,\n} from '@heroui/checkbox';\nimport type { ReactNode } from 'react';\nimport type { FieldError } from 'react-hook-form';\n\nimport {\n Checkbox as HeroCheckbox,\n CheckboxGroup as HeroCheckboxGroup,\n} from '@heroui/checkbox';\nimport { checkbox as heroCheckboxVariants } from '@heroui/theme';\n\nimport { slugify, tv, variantsToClassNames } from '@fuf-stack/pixel-utils';\n\nimport { useUniformField } from '../hooks';\nimport { FieldValidationError } from '../partials/FieldValidationError';\n\nexport const checkboxesVariants = tv({\n slots: {\n base: 'group', // Needs group for group-data condition\n errorMessage: 'text-tiny',\n // see HeroUI styles for group-data condition,\n // e.g.: https://github.com/heroui-inc/heroui/blob/main/packages/core/theme/src/components/select.ts\n label:\n 'text-foreground group-data-[invalid=true]:!text-danger inline-flex text-sm subpixel-antialiased',\n optionBase: '',\n optionIcon: '',\n optionLabel: '',\n optionLabelSubline: '!text-small text-foreground-400',\n optionWrapper: '',\n wrapper: '',\n },\n variants: {\n // see: https://github.com/heroui-inc/heroui/blob/canary/packages/core/theme/src/components/checkbox.ts\n color: {\n info: {\n wrapper:\n 'text-info-foreground after:bg-info after:text-info-foreground',\n },\n ...heroCheckboxVariants.variants.color,\n } as const,\n lineThrough: {\n true: {\n optionLabel: [\n ...heroCheckboxVariants.variants.lineThrough.true.label,\n // fix stroke position when used with subline and enable animation\n 'relative before:transition-all before:duration-200',\n ],\n optionLabelSubline: 'group-data-[selected=true]:opacity-60',\n },\n },\n },\n});\n\ntype VariantProps = TVProps<typeof checkboxesVariants>;\ntype ClassName = TVClassName<typeof checkboxesVariants>;\n\nexport interface CheckboxOption {\n /** option label */\n label?: ReactNode;\n /** subline displayed below the label */\n labelSubline?: ReactNode;\n /** option value */\n value: string;\n /** disables the option */\n disabled?: boolean;\n /** HTML data-testid attribute of the option */\n testId?: string;\n}\n\nexport interface CheckboxesProps extends VariantProps {\n /** CSS class name */\n className?: ClassName;\n /** Color scheme of the checkboxes */\n color?: VariantProps['color'];\n /** Sets all checkboxes disabled */\n disabled?: boolean;\n /** Orientation of the checkboxes */\n inline?: boolean;\n /** Label displayed above the checkboxes */\n label?: ReactNode;\n /** Whether the checkboxes label should be crossed out */\n lineThrough?: boolean;\n /** Name the Field is registered on the form */\n name: string;\n /** Checkboxes that should be displayed. */\n options: CheckboxOption[];\n /** HTML data-testid attribute used in e2e tests */\n testId?: string;\n}\n\n/**\n * Checkboxes component based on [HeroUI CheckboxGroup](https://www.heroui.com//docs/components/checkbox-group)\n */\nconst Checkboxes = ({\n className = undefined,\n color = 'primary',\n inline = false,\n lineThrough = false,\n options,\n name,\n ...uniformFieldProps\n}: CheckboxesProps) => {\n const {\n disabled,\n error: _error,\n field: { onChange, value = [], ref, onBlur },\n invalid,\n label,\n required,\n testId,\n } = useUniformField({\n name,\n showInvalidWhen: 'immediate',\n ...uniformFieldProps,\n });\n\n // Convert React Hook Form's nested error object structure to a flat array\n // RHF errors can be nested like: checkboxField.0 (individual checkbox errors)\n // and checkboxField._error (global field errors) - this flattens all\n // error values into a single array for rendering with FieldValidationError\n const errorFlat: FieldError[] =\n (_error &&\n Object.values(\n _error as unknown as Record<string, FieldError[]>,\n ).flat()) ??\n [];\n const errorMessage = (\n <FieldValidationError error={errorFlat} testId={testId} />\n );\n\n /**\n * Handles the checkboxes value changes based on the number of options:\n * 1. For single checkbox (options.length === 1):\n * - Converts undefined/empty array to [] for consistent controlled behavior\n * - Extracts single value from array for onChange\n *\n * Example: undefined → []\n * [value] → value\n *\n * 2. For multiple checkboxes:\n * - Uses raw value array with fallback to empty array\n * - Passes through onChange directly\n *\n * Example: undefined → []\n * ['value1', 'value2'] → ['value1', 'value2']\n */\n const getCheckboxValue = (inputValue: unknown): string[] => {\n if (Array.isArray(inputValue)) {\n return inputValue as string[];\n }\n if (inputValue) {\n return [inputValue as string];\n }\n return [];\n };\n\n const singleCheckboxProps = {\n value: getCheckboxValue(value),\n onChange: (newValue: string[]) => {\n onChange(newValue?.[0]);\n },\n };\n\n const multipleCheckboxProps = {\n onChange,\n value: getCheckboxValue(value),\n };\n\n const checkboxesProps =\n options.length === 1 ? singleCheckboxProps : multipleCheckboxProps;\n\n // classNames from slots\n const variants = checkboxesVariants({ lineThrough });\n const classNames = variantsToClassNames(variants, className, 'base');\n\n // map slots to HeroUI class names\n const heroCheckboxGroupClassNames: HeroCheckboxGroupProps['classNames'] = {\n base: classNames.base,\n label: classNames.label,\n wrapper: classNames.wrapper,\n };\n const heroCheckboxClassNames: HeroCheckboxProps['classNames'] = {\n base: classNames.optionBase,\n icon: classNames.optionIcon,\n label: classNames.optionLabel,\n wrapper: classNames.optionWrapper,\n };\n\n return (\n <HeroCheckboxGroup\n ref={ref}\n classNames={heroCheckboxGroupClassNames}\n color={color === 'info' ? 'primary' : color}\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-testid={testId}\n errorMessage={errorMessage}\n isDisabled={disabled}\n isInvalid={invalid}\n isRequired={required}\n label={label ? <legend>{label}</legend> : null}\n name={name}\n onBlur={onBlur}\n orientation={inline ? 'horizontal' : 'vertical'}\n {...checkboxesProps}\n >\n {options?.map((option) => {\n const optionTestId = slugify(\n `${testId}_option_${option?.testId ?? option?.value}`,\n { replaceDots: true },\n );\n\n // set content and classes depending option has subline\n const hasSubline = !!option.labelSubline;\n let labelContent: ReactNode;\n let optionClassNames = heroCheckboxClassNames;\n if (hasSubline) {\n labelContent = (\n <div className=\"flex grow flex-col items-start\">\n <span className={classNames.optionLabel}>{option.label}</span>\n <span className={classNames.optionLabelSubline}>\n {option.labelSubline}\n </span>\n </div>\n );\n // remove label classes from outer label when subline is used\n optionClassNames = { ...optionClassNames, label: '' };\n } else {\n labelContent = option.label;\n }\n\n return (\n <HeroCheckbox\n key={`index_${option.value}`}\n classNames={optionClassNames}\n data-invalid={invalid}\n data-testid={optionTestId}\n isDisabled={!!disabled || option.disabled}\n value={option?.value}\n aria-label={\n typeof option.label === 'string' ? option.label : option.value\n }\n >\n {labelContent}\n </HeroCheckbox>\n );\n })}\n </HeroCheckboxGroup>\n );\n};\n\nexport default Checkboxes;\n","import Checkboxes from './Checkboxes';\n\nexport type { CheckboxesProps, CheckboxOption } from './Checkboxes';\n\nexport { Checkboxes };\n\nexport default Checkboxes;\n"],"mappings":"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","names":["_a","Checkboxes_default"]}
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
2
|
|
|
3
|
-
var _chunkOE5BOGGXcjs = require('./chunk-OE5BOGGX.cjs');
|
|
4
3
|
|
|
5
4
|
|
|
6
|
-
var
|
|
5
|
+
var _chunkC5GIWGQRcjs = require('./chunk-C5GIWGQR.cjs');
|
|
7
6
|
|
|
8
7
|
|
|
8
|
+
var _chunkOE5BOGGXcjs = require('./chunk-OE5BOGGX.cjs');
|
|
9
9
|
|
|
10
10
|
|
|
11
|
-
var
|
|
11
|
+
var _chunkNHEZXA4Hcjs = require('./chunk-NHEZXA4H.cjs');
|
|
12
12
|
|
|
13
13
|
|
|
14
14
|
|
|
@@ -44,11 +44,11 @@ var Switch = ({
|
|
|
44
44
|
testId: _testId = void 0,
|
|
45
45
|
thumbIcon = void 0
|
|
46
46
|
}) => {
|
|
47
|
-
const { control, debugMode, getFieldState } =
|
|
47
|
+
const { control, debugMode, getFieldState } = _chunkC5GIWGQRcjs.useFormContext.call(void 0, );
|
|
48
48
|
const { error, required, testId, invalid } = getFieldState(name, _testId);
|
|
49
|
-
const { field } =
|
|
49
|
+
const { field } = _chunkC5GIWGQRcjs.useController.call(void 0, { name, control, disabled });
|
|
50
50
|
const { disabled: isDisabled, value, ref, onBlur, onChange } = field;
|
|
51
|
-
const { label, getInputProps, getErrorMessageProps } =
|
|
51
|
+
const { label, getInputProps, getErrorMessageProps } = _chunkC5GIWGQRcjs.useInput.call(void 0, {
|
|
52
52
|
errorMessage: JSON.stringify(error),
|
|
53
53
|
isInvalid: invalid,
|
|
54
54
|
isRequired: required,
|
|
@@ -56,9 +56,9 @@ var Switch = ({
|
|
|
56
56
|
labelPlacement: "outside",
|
|
57
57
|
placeholder: " "
|
|
58
58
|
});
|
|
59
|
+
const showTestIdCopyButton = debugMode === "debug-testids";
|
|
59
60
|
const variants = switchVariants();
|
|
60
61
|
const classNames = _pixelutils.variantsToClassNames.call(void 0, variants, className, "outerWrapper");
|
|
61
|
-
const showTestIdCopyButton = debugMode === "debug-testids";
|
|
62
62
|
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: classNames.outerWrapper, children: [
|
|
63
63
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
64
64
|
_switch.Switch,
|
|
@@ -86,7 +86,7 @@ var Switch = ({
|
|
|
86
86
|
]
|
|
87
87
|
}
|
|
88
88
|
),
|
|
89
|
-
error ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: classNames.errorMessage, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", _chunk555JRYCScjs.__spreadProps.call(void 0, _chunk555JRYCScjs.__spreadValues.call(void 0, {}, getErrorMessageProps()), { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
89
|
+
error ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: classNames.errorMessage, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", _chunk555JRYCScjs.__spreadProps.call(void 0, _chunk555JRYCScjs.__spreadValues.call(void 0, {}, getErrorMessageProps()), { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkNHEZXA4Hcjs.FieldValidationError_default, { error, testId }) })) }) : null
|
|
90
90
|
] });
|
|
91
91
|
};
|
|
92
92
|
var Switch_default = Switch;
|
|
@@ -98,4 +98,4 @@ var Switch_default2 = Switch_default;
|
|
|
98
98
|
|
|
99
99
|
|
|
100
100
|
exports.Switch_default = Switch_default; exports.Switch_default2 = Switch_default2;
|
|
101
|
-
//# sourceMappingURL=chunk-
|
|
101
|
+
//# sourceMappingURL=chunk-YIBISSMT.cjs.map
|