@fuf-stack/uniform 0.10.2 → 0.11.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/CheckboxGroup/index.cjs +4 -3
- package/dist/CheckboxGroup/index.cjs.map +1 -1
- package/dist/CheckboxGroup/index.js +3 -2
- package/dist/Controller/index.cjs +9 -0
- package/dist/Controller/index.cjs.map +1 -0
- package/dist/Controller/index.d.cts +4 -0
- package/dist/Controller/index.d.ts +4 -0
- package/dist/Controller/index.js +9 -0
- package/dist/Controller/index.js.map +1 -0
- package/dist/FieldArray/index.cjs +3 -3
- package/dist/FieldArray/index.js +2 -2
- package/dist/Form/index.cjs +3 -3
- package/dist/Form/index.d.cts +3 -2
- package/dist/Form/index.d.ts +3 -2
- package/dist/Form/index.js +2 -2
- package/dist/{Form-Dav2xhog.d.ts → Form-D0grgL6G.d.cts} +4 -3
- package/dist/{Form-Dav2xhog.d.cts → Form-DX5NTR-H.d.ts} +4 -3
- package/dist/FormContext-ldCpxKnY.d.cts +8 -0
- package/dist/FormContext-ldCpxKnY.d.ts +8 -0
- package/dist/Input/index.cjs +4 -3
- package/dist/Input/index.cjs.map +1 -1
- package/dist/Input/index.js +3 -2
- package/dist/RadioGroup/index.cjs +4 -3
- package/dist/RadioGroup/index.cjs.map +1 -1
- package/dist/RadioGroup/index.d.cts +3 -2
- package/dist/RadioGroup/index.d.ts +3 -2
- package/dist/RadioGroup/index.js +3 -2
- package/dist/{RadioGroup-D_kiBt0M.d.cts → RadioGroup-DcmL1H1w.d.cts} +45 -4
- package/dist/{RadioGroup-D_kiBt0M.d.ts → RadioGroup-DcmL1H1w.d.ts} +45 -4
- package/dist/Select/index.cjs +4 -3
- package/dist/Select/index.cjs.map +1 -1
- package/dist/Select/index.js +3 -2
- package/dist/SubmitButton/index.cjs +3 -3
- package/dist/SubmitButton/index.js +2 -2
- package/dist/Switch/index.cjs +4 -3
- package/dist/Switch/index.cjs.map +1 -1
- package/dist/Switch/index.js +3 -2
- package/dist/TextArea/index.cjs +4 -3
- package/dist/TextArea/index.cjs.map +1 -1
- package/dist/TextArea/index.js +3 -2
- package/dist/{chunk-6LIAYPMV.js → chunk-2X4PRJ7K.js} +93 -53
- package/dist/chunk-2X4PRJ7K.js.map +1 -0
- package/dist/{chunk-PTJDXWBN.cjs → chunk-4DP5IMTU.cjs} +3 -3
- package/dist/{chunk-PTJDXWBN.cjs.map → chunk-4DP5IMTU.cjs.map} +1 -1
- package/dist/{chunk-4YV5S72F.js → chunk-4F2PNEJZ.js} +5 -3
- package/dist/chunk-4F2PNEJZ.js.map +1 -0
- package/dist/{chunk-VBDGQ5T3.js → chunk-4FDD5XNY.js} +5 -3
- package/dist/chunk-4FDD5XNY.js.map +1 -0
- package/dist/{chunk-LCLUJFBW.cjs → chunk-7RYAD5OS.cjs} +7 -6
- package/dist/chunk-7RYAD5OS.cjs.map +1 -0
- package/dist/{chunk-R3IBN7K6.cjs → chunk-BKX5WAKS.cjs} +7 -5
- package/dist/chunk-BKX5WAKS.cjs.map +1 -0
- package/dist/{chunk-3KT6EELT.cjs → chunk-D6NOYVFK.cjs} +7 -5
- package/dist/chunk-D6NOYVFK.cjs.map +1 -0
- package/dist/{chunk-7XOJIVJG.js → chunk-J4IZIB6S.js} +5 -3
- package/dist/chunk-J4IZIB6S.js.map +1 -0
- package/dist/{chunk-ZFF2GFNX.js → chunk-JFJSEJ4F.js} +3 -3
- package/dist/chunk-JFJSEJ4F.js.map +1 -0
- package/dist/chunk-KOKIM2ND.js +9 -0
- package/dist/chunk-KOKIM2ND.js.map +1 -0
- package/dist/{chunk-KVJNGHAP.cjs → chunk-MFFQUEAY.cjs} +7 -5
- package/dist/chunk-MFFQUEAY.cjs.map +1 -0
- package/dist/{chunk-EG3EFTJN.js → chunk-OYSI3IRJ.js} +5 -4
- package/dist/chunk-OYSI3IRJ.js.map +1 -0
- package/dist/{chunk-NAGQKQ7C.js → chunk-PGQLFSIL.js} +12 -5
- package/dist/chunk-PGQLFSIL.js.map +1 -0
- package/dist/{chunk-MK2PLALW.cjs → chunk-QGEY2AVG.cjs} +6 -6
- package/dist/chunk-QGEY2AVG.cjs.map +1 -0
- package/dist/{chunk-ORFZIRSW.js → chunk-R6U3M5P5.js} +5 -3
- package/dist/chunk-R6U3M5P5.js.map +1 -0
- package/dist/{chunk-R4SIKN2S.cjs → chunk-SRAFHMB2.cjs} +7 -5
- package/dist/chunk-SRAFHMB2.cjs.map +1 -0
- package/dist/{chunk-ZNVGXKHS.js → chunk-U4IDHTW5.js} +2 -2
- package/dist/chunk-VQWKXSHW.cjs +9 -0
- package/dist/chunk-VQWKXSHW.cjs.map +1 -0
- package/dist/{chunk-TPQE3IFL.js → chunk-WLYFBQVU.js} +5 -3
- package/dist/chunk-WLYFBQVU.js.map +1 -0
- package/dist/{chunk-S4GIEBID.cjs → chunk-WPWPZNSG.cjs} +24 -17
- package/dist/chunk-WPWPZNSG.cjs.map +1 -0
- package/dist/{chunk-K6PIOPQN.cjs → chunk-ZBCEV3W6.cjs} +96 -56
- package/dist/chunk-ZBCEV3W6.cjs.map +1 -0
- package/dist/{chunk-DW5HZXZO.cjs → chunk-ZQ75EBWB.cjs} +7 -5
- package/dist/chunk-ZQ75EBWB.cjs.map +1 -0
- package/dist/hooks/index.cjs +4 -2
- package/dist/hooks/index.cjs.map +1 -1
- package/dist/hooks/index.d.cts +7 -4
- package/dist/hooks/index.d.ts +7 -4
- package/dist/hooks/index.js +3 -1
- package/dist/index.cjs +17 -11
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +5 -3
- package/dist/index.d.ts +5 -3
- package/dist/index.js +19 -13
- package/package.json +14 -8
- package/dist/chunk-3KT6EELT.cjs.map +0 -1
- package/dist/chunk-4YV5S72F.js.map +0 -1
- package/dist/chunk-6LIAYPMV.js.map +0 -1
- package/dist/chunk-7XOJIVJG.js.map +0 -1
- package/dist/chunk-DW5HZXZO.cjs.map +0 -1
- package/dist/chunk-EG3EFTJN.js.map +0 -1
- package/dist/chunk-K6PIOPQN.cjs.map +0 -1
- package/dist/chunk-KVJNGHAP.cjs.map +0 -1
- package/dist/chunk-LCLUJFBW.cjs.map +0 -1
- package/dist/chunk-MK2PLALW.cjs.map +0 -1
- package/dist/chunk-NAGQKQ7C.js.map +0 -1
- package/dist/chunk-ORFZIRSW.js.map +0 -1
- package/dist/chunk-R3IBN7K6.cjs.map +0 -1
- package/dist/chunk-R4SIKN2S.cjs.map +0 -1
- package/dist/chunk-S4GIEBID.cjs.map +0 -1
- package/dist/chunk-TPQE3IFL.js.map +0 -1
- package/dist/chunk-VBDGQ5T3.js.map +0 -1
- package/dist/chunk-ZFF2GFNX.js.map +0 -1
- /package/dist/{chunk-ZNVGXKHS.js.map → chunk-U4IDHTW5.js.map} +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/home/runner/work/uniform/uniform/packages/uniform/dist/chunk-SRAFHMB2.cjs","../src/Select/Select.tsx","../src/Select/index.ts"],"names":["Select_default"],"mappings":"AAAA;AACE;AACF,wDAA6B;AAC7B;AACE;AACF,wDAA6B;AAC7B;AACE;AACF,wDAA6B;AAC7B;AACE;AACF,wDAA6B;AAC7B;AACE;AACF,wDAA6B;AAC7B;AACA;ACbA,8BAAyB;AACzB,qGAAwC;AAExC,4CAA0B;AAE1B,oDAA6C;AAmGpC,+CAAA;AA3FF,IAAM,eAAA,EAAiB,4BAAA;AAAG,EAC/B,KAAA,EAAO;AAAA,IACL,IAAA,EAAM,sBAAA;AAAA,IACN,cAAA,EACE,wGAAA;AAAA,IACF,OAAA,EACE,yNAAA;AAAA,IACF,eAAA,EAAiB,cAAA;AAAA,IACjB,SAAA,EAAW,EAAA;AAAA,IACX,WAAA,EAAa,EAAA;AAAA,IACb,iBAAA,EACE,+FAAA;AAAA,IACF,KAAA,EAAO,EAAA;AAAA,IACP,YAAA,EAAc,4CAAA;AAAA,IACd,mBAAA,EAAqB,WAAA;AAAA,IACrB,kBAAA,EAAoB,gBA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A;AACF,kBAAA;AACF,gBAAA;AACA,gBAAA;AACE,kBAAA;AACF,gBAAA;AACA,gBAAA;AACA,gBAAA;AAEA,gBAAA;AACA,gBAAA;AAAQ,cAAA;AACV,YAAA;AACC,YAAA;AAEC,4BAAA;AAKA,UAAA;AAAA,QAAA;AAEJ,MAAA;AAAA,IAAA;AAEJ,EAAA;AAEJ;AAEO;AD7FW;AACA;AEnOXA;AFqOW;AACA;AACA;AACA;AACA","file":"/home/runner/work/uniform/uniform/packages/uniform/dist/chunk-SRAFHMB2.cjs","sourcesContent":[null,"import type { TVClassName, TVProps } from '@fuf-stack/pixel-utils';\nimport type { Props } from 'react-select';\n\nimport { useState } from 'react';\nimport ReactSelect, { components } from 'react-select';\n\nimport { useSelect } from '@nextui-org/select';\n\nimport { cn, tv, variantsToClassNames } from '@fuf-stack/pixel-utils';\n\nimport { Controller } from '../Controller';\nimport { slugify } from '../helpers';\nimport { useFormContext } from '../hooks';\nimport { FieldCopyTestIdButton } from '../partials/FieldCopyTestIdButton';\nimport { FieldValidationError } from '../partials/FieldValidationError';\n\nexport const selectVariants = tv({\n slots: {\n base: 'group leading-normal',\n clearIndicator:\n 'rounded-md p-1 text-foreground-500 hover:cursor-pointer hover:bg-default-200 hover:text-foreground-800',\n control:\n 'rounded-lg border-2 border-default-200 !duration-150 transition-background hover:border-default-400 group-data-[invalid=true]:border-danger group-data-[invalid=true]:hover:border-danger motion-reduce:transition-none',\n control_focused: 'border-focus',\n crossIcon: '',\n downChevron: '',\n dropdownIndicator:\n 'rounded-md p-1 text-foreground-500 hover:cursor-pointer hover:bg-default-200 hover:text-black',\n group: '',\n groupHeading: 'mb-1 ml-3 mt-2 text-sm text-foreground-500',\n indicatorsContainer: 'gap-1 p-1',\n indicatorSeparator: 'bg-default-300',\n input: 'py-0.5 pl-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 'pointer-events-auto relative bottom-1.5 ml-1 text-small 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 loadingIndicator: '',\n loadingMessage: '',\n menu: 'mt-2 rounded-xl border border-default-200 bg-content1 p-1 shadow-lg',\n menuList: '',\n // ensure menu has same z-index as modal so it is visible when rendered in modal\n // see: https://github.com/nextui-org/nextui/blob/main/packages/core/theme/src/components/modal.ts (see z-50)\n menuPortal: '!z-50',\n multiValue: 'items-center gap-1.5 rounded bg-default-100 py-0.5 pl-2 pr-1',\n multiValueContainer: '',\n multiValueLabel: 'py-0.5 leading-6',\n multiValueRemove:\n 'rounded text-default-500 hover:cursor-pointer hover:border-default-300 hover:text-default-800',\n noOptionsMessage: 'rounded-sm p-2 text-foreground-500',\n option_focused: 'bg-default-100 active:bg-default-200',\n option_selected: 'bg-default-300',\n option: 'rounded px-3 py-2 hover:cursor-pointer',\n placeholder: 'py-0.5 pl-1 text-foreground-500',\n selectContainer: '',\n singleValue: '!ml-1 !leading-7',\n valueContainer: 'gap-1 p-1',\n },\n});\n\ntype SelectOption = {\n /** option label */\n label?: React.ReactNode;\n /** option value */\n value: string;\n};\n\ntype VariantProps = TVProps<typeof selectVariants>;\ntype ClassName = TVClassName<typeof selectVariants>;\n\nexport interface SelectProps extends VariantProps {\n /** CSS class name */\n className?: ClassName; // string;\n /** Determine if the */\n clearable?: boolean;\n /** Set the select to disabled state. */\n disabled?: boolean;\n /** Filter Select Options */\n filterOption?:\n | undefined\n | ((option?: SelectOption, inputValue?: string) => boolean);\n /** Format the label of the option */\n renderOptionLabel?: undefined | Props['formatOptionLabel'];\n /** The value of the search input */\n inputValue?: string;\n /** Label that should be associated with the select. */\n label?: React.ReactNode;\n /** Set the select to a loading state. */\n loading?: boolean;\n /** switch between single and multi select mode. */\n multiSelect?: boolean;\n /** The name for the Select component, used by react-hook-form */\n name: string;\n /** Placeholder that is displayed when nothing is selected */\n placeholder?: string;\n /** The options for the Select component */\n options: SelectOption[];\n /** Handle change events on the input */\n onInputChange?: Props['onInputChange'];\n /** HTML data-testid attribute used in e2e tests */\n testId?: string;\n}\n\nconst InputComponent: typeof components.Input = (props) => {\n // @ts-expect-error data-testid is not a default prop\n // eslint-disable-next-line react/prop-types, react/destructuring-assignment\n const testId = `${props.selectProps['data-testid']}`;\n // eslint-disable-next-line react/jsx-props-no-spreading\n return <components.Input data-testid={testId} {...props} />;\n};\n\nconst ControlComponent: typeof components.Control = (props) => {\n // @ts-expect-error data-testid is not a default prop\n // eslint-disable-next-line react/prop-types, react/destructuring-assignment\n const testId = `${props.selectProps['data-testid']}_select`;\n return (\n <div data-testid={testId}>\n {/* eslint-disable-next-line react/jsx-props-no-spreading */}\n <components.Control {...props} />\n </div>\n );\n};\n\nconst OptionComponent: typeof components.Option = (props) => {\n // @ts-expect-error data-testid is not a default prop\n // eslint-disable-next-line react/prop-types, react/destructuring-assignment\n const testId = `${props.selectProps['data-testid']}_select_option_${slugify(props?.data?.testId ?? props?.data?.value)}`;\n return (\n <div data-testid={testId}>\n {/* eslint-disable-next-line react/jsx-props-no-spreading */}\n <components.Option {...props} />\n </div>\n );\n};\n\nconst DropdownIndicatorComponent: typeof components.DropdownIndicator = (\n props,\n) => {\n // @ts-expect-error data-testid is not a default prop\n // eslint-disable-next-line react/prop-types\n const testId = props?.selectProps['data-testid'] as string;\n return (\n <div data-testid={`${testId}_select_dropdown`}>\n {/* eslint-disable-next-line react/jsx-props-no-spreading */}\n <components.DropdownIndicator {...props} />\n </div>\n );\n};\n\n/** Select component based on [NextUI Select](https://nextui.org/docs/components/select) and [React-Select](https://react-select.com/home) */\nconst Select = ({\n className = undefined,\n clearable = true,\n disabled = false,\n filterOption = undefined,\n renderOptionLabel = undefined,\n inputValue = undefined,\n label: _label = undefined,\n loading = false,\n multiSelect = false,\n name,\n onInputChange = undefined,\n options,\n placeholder = undefined,\n testId: _testId = undefined,\n}: SelectProps) => {\n const { control, debugMode, getFieldState } = useFormContext();\n const { error, invalid, required, testId } = getFieldState(name, _testId);\n\n const [isFocused, setIsFocused] = useState(false);\n\n const variants = selectVariants();\n const classNames = variantsToClassNames(variants, className, 'base');\n\n const {\n getBaseProps,\n getErrorMessageProps,\n getHelperWrapperProps,\n getLabelProps,\n getTriggerProps,\n getValueProps,\n label,\n } = useSelect({\n children: [],\n classNames,\n errorMessage: JSON.stringify(error),\n isDisabled: disabled,\n isInvalid: invalid,\n isLoading: loading,\n isRequired: required,\n label: _label,\n labelPlacement: 'outside',\n placeholder: ' ',\n });\n\n const showTestIdCopyButton = debugMode === 'debug-testids';\n const showLabel = label || showTestIdCopyButton;\n\n return (\n <Controller\n control={control}\n name={name}\n render={({\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n field: { onChange, value, ref, onBlur },\n }) => (\n <div\n // eslint-disable-next-line react/jsx-props-no-spreading\n {...getBaseProps()}\n className={cn(classNames.base)}\n data-testid={`${testId}_wrapper`}\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-required={required}\n >\n {showLabel && (\n <label\n className={classNames.label}\n data-slot=\"label\"\n htmlFor={`react-select-${name}-input`}\n id={getLabelProps().id}\n >\n {label}\n {showTestIdCopyButton && (\n <FieldCopyTestIdButton testId={testId} />\n )}\n </label>\n )}\n <ReactSelect\n aria-errormessage=\"\"\n aria-labelledby={\n getTriggerProps()['aria-labelledby']?.split(' ')[1]\n }\n aria-invalid={invalid}\n classNames={{\n control: () =>\n cn(classNames.control, {\n [classNames.control_focused]: isFocused && !invalid,\n }),\n clearIndicator: () => classNames.clearIndicator,\n dropdownIndicator: () => classNames.dropdownIndicator,\n groupHeading: () => classNames.groupHeading,\n indicatorsContainer: () => classNames.indicatorsContainer,\n indicatorSeparator: () => classNames.indicatorSeparator,\n input: () => classNames.input,\n menu: () => classNames.menu,\n menuList: () => classNames.menuList,\n menuPortal: () => classNames.menuPortal,\n multiValue: () => classNames.multiValue,\n multiValueLabel: () =>\n cn(classNames.multiValueLabel, `${getValueProps().className}`),\n multiValueRemove: () => classNames.multiValueRemove,\n noOptionsMessage: () => classNames.noOptionsMessage,\n option: ({\n isFocused: optionIsFocused,\n isSelected: optionIsSelected,\n }) =>\n cn(classNames.option, {\n [classNames.option_focused]: optionIsFocused,\n [classNames.option_selected]: optionIsSelected,\n }),\n placeholder: () => classNames.placeholder,\n singleValue: () =>\n cn(classNames.singleValue, `${getValueProps().className}`),\n valueContainer: () => classNames.valueContainer,\n }}\n components={{\n Input: InputComponent,\n Option: OptionComponent,\n DropdownIndicator: DropdownIndicatorComponent,\n Control: ControlComponent,\n }}\n // Does not affect the testId of the select, but is needed to pass it to sub-components\n data-testid={testId}\n filterOption={filterOption}\n formatOptionLabel={renderOptionLabel}\n inputValue={inputValue}\n instanceId={name}\n isClearable={clearable}\n isDisabled={disabled}\n isLoading={loading}\n isMulti={multiSelect}\n name={name}\n // set menuPosition to fixed so that menu can be rendered\n // inside Card / Modal components, menuShouldBlockScroll\n // prevents container scroll when menu is open\n menuPosition=\"fixed\"\n menuShouldBlockScroll\n options={options}\n placeholder={placeholder}\n onBlur={(_e) => {\n setIsFocused(false);\n return onBlur();\n }}\n onChange={(option) => {\n if (multiSelect) {\n onChange(\n (option as SelectOption[])?.map((_option) => _option.value),\n );\n } else {\n onChange((option as SelectOption)?.value);\n }\n }}\n onFocus={(_e) => {\n setIsFocused(true);\n }}\n onInputChange={onInputChange}\n ref={ref}\n // set complete option as value by current field value\n value={options.find((option) => option.value === value)}\n unstyled\n />\n {error && (\n // eslint-disable-next-line react/jsx-props-no-spreading\n <div {...getHelperWrapperProps()}>\n {/* eslint-disable-next-line react/jsx-props-no-spreading */}\n <div {...getErrorMessageProps()}>\n <FieldValidationError error={error} />\n </div>\n </div>\n )}\n </div>\n )}\n />\n );\n};\n\nexport default Select;\n","import Select from './Select';\n\nexport type { SelectProps } from './Select';\n\nexport { Select };\n\nexport default Select;\n"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
useFormContext
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-PGQLFSIL.js";
|
|
4
4
|
import {
|
|
5
5
|
slugify
|
|
6
6
|
} from "./chunk-V46BHM2U.js";
|
|
@@ -45,4 +45,4 @@ export {
|
|
|
45
45
|
SubmitButton_default,
|
|
46
46
|
SubmitButton_default2
|
|
47
47
|
};
|
|
48
|
-
//# sourceMappingURL=chunk-
|
|
48
|
+
//# sourceMappingURL=chunk-U4IDHTW5.js.map
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});// src/Controller/index.ts
|
|
2
|
+
var _reacthookform = require('react-hook-form');
|
|
3
|
+
var Controller_default = _reacthookform.Controller;
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
exports.Controller = _reacthookform.Controller; exports.Controller_default = Controller_default;
|
|
9
|
+
//# sourceMappingURL=chunk-VQWKXSHW.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/home/runner/work/uniform/uniform/packages/uniform/dist/chunk-VQWKXSHW.cjs","../src/Controller/index.ts"],"names":[],"mappings":"AAAA;ACEA,gDAA2B;AAM3B,IAAO,mBAAA,EAAQ,yBAAA;ADLf;AACA;AACE;AACA;AACF,gGAAC","file":"/home/runner/work/uniform/uniform/packages/uniform/dist/chunk-VQWKXSHW.cjs","sourcesContent":[null,"/** @see https://react-hook-form.com/docs/usecontroller/controller */\n\nimport { Controller } from 'react-hook-form';\n\nexport type { ControllerProps } from 'react-hook-form';\n\nexport { Controller };\n\nexport default Controller;\n"]}
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Controller
|
|
3
|
+
} from "./chunk-KOKIM2ND.js";
|
|
1
4
|
import {
|
|
2
5
|
FieldCopyTestIdButton_default
|
|
3
6
|
} from "./chunk-2CRY7VDQ.js";
|
|
@@ -6,10 +9,9 @@ import {
|
|
|
6
9
|
} from "./chunk-WKM2D7LF.js";
|
|
7
10
|
import {
|
|
8
11
|
useFormContext
|
|
9
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-PGQLFSIL.js";
|
|
10
13
|
|
|
11
14
|
// src/TextArea/TextArea.tsx
|
|
12
|
-
import { Controller } from "react-hook-form";
|
|
13
15
|
import { Textarea as NextTextArea } from "@nextui-org/input";
|
|
14
16
|
import { cn } from "@fuf-stack/pixel-utils";
|
|
15
17
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
@@ -75,4 +77,4 @@ export {
|
|
|
75
77
|
TextArea_default,
|
|
76
78
|
TextArea_default2
|
|
77
79
|
};
|
|
78
|
-
//# sourceMappingURL=chunk-
|
|
80
|
+
//# sourceMappingURL=chunk-WLYFBQVU.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/TextArea/TextArea.tsx","../src/TextArea/index.ts"],"sourcesContent":["import type { ReactNode } from 'react';\n\nimport { Textarea as NextTextArea } from '@nextui-org/input';\n\nimport { cn } from '@fuf-stack/pixel-utils';\n\nimport { Controller } from '../Controller';\nimport { useFormContext } from '../hooks';\nimport { FieldCopyTestIdButton } from '../partials/FieldCopyTestIdButton';\nimport { FieldValidationError } from '../partials/FieldValidationError';\n\nexport interface TextAreaProps {\n /** Child components. The content of the textarea. */\n children?: ReactNode;\n /** CSS class name */\n className?: string;\n /** Determines if the TextArea is disabled or not. */\n disabled?: boolean;\n /** Label displayed above the TextArea. */\n label?: ReactNode;\n /** Name the TextArea is registered at in HTML forms (react-hook-form). */\n name: string;\n /** placeholder for the textArea content. */\n placeholder?: string;\n /** Id to grab element in internal tests. */\n testId?: string;\n}\n\n/**\n * TextArea component based on [NextUI TextArea](https://nextui.org/docs/components/textarea)\n */\nconst TextArea = ({\n children = null,\n className = undefined,\n disabled = false,\n label = undefined,\n name,\n placeholder = ' ',\n testId: _testId = undefined,\n}: TextAreaProps) => {\n const { control, debugMode, getFieldState } = useFormContext();\n const { error, invalid, required, testId } = getFieldState(name, _testId);\n\n const showTestIdCopyButton = debugMode === 'debug-testids';\n const showLabel = label || showTestIdCopyButton;\n\n return (\n <Controller\n control={control}\n name={name}\n disabled={disabled}\n render={({\n field: { disabled: isDisabled, onChange, onBlur, value, ref },\n }) => {\n return (\n <NextTextArea\n className={cn(className)}\n classNames={{\n inputWrapper: 'group-data-[focus=true]:border-focus',\n }}\n data-testid={testId}\n errorMessage={error && <FieldValidationError error={error} />}\n isDisabled={isDisabled}\n isRequired={required}\n isInvalid={invalid}\n label={\n showLabel && (\n <>\n {label}\n {showTestIdCopyButton && (\n <FieldCopyTestIdButton testId={testId} />\n )}\n </>\n )\n }\n labelPlacement=\"outside\"\n placeholder={placeholder}\n name={name}\n value={value}\n onChange={onChange}\n onBlur={onBlur}\n ref={ref}\n variant=\"bordered\"\n >\n {children}\n </NextTextArea>\n );\n }}\n />\n );\n};\n\nexport default TextArea;\n","import TextArea from './TextArea';\n\nexport type { TextAreaProps } from './TextArea';\n\nexport { TextArea };\n\nexport default TextArea;\n"],"mappings":";;;;;;;;;;;;;;AAEA,SAAS,YAAY,oBAAoB;AAEzC,SAAS,UAAU;AAyDgB,SAMnB,UANmB,KAMnB,YANmB;AA9BnC,IAAM,WAAW,CAAC;AAAA,EAChB,WAAW;AAAA,EACX,YAAY;AAAA,EACZ,WAAW;AAAA,EACX,QAAQ;AAAA,EACR;AAAA,EACA,cAAc;AAAA,EACd,QAAQ,UAAU;AACpB,MAAqB;AACnB,QAAM,EAAE,SAAS,WAAW,cAAc,IAAI,eAAe;AAC7D,QAAM,EAAE,OAAO,SAAS,UAAU,OAAO,IAAI,cAAc,MAAM,OAAO;AAExE,QAAM,uBAAuB,cAAc;AAC3C,QAAM,YAAY,SAAS;AAE3B,SACE;AAAA,IAAC;AAAA;AAAA,MACC;AAAA,MACA;AAAA,MACA;AAAA,MACA,QAAQ,CAAC;AAAA,QACP,OAAO,EAAE,UAAU,YAAY,UAAU,QAAQ,OAAO,IAAI;AAAA,MAC9D,MAAM;AACJ,eACE;AAAA,UAAC;AAAA;AAAA,YACC,WAAW,GAAG,SAAS;AAAA,YACvB,YAAY;AAAA,cACV,cAAc;AAAA,YAChB;AAAA,YACA,eAAa;AAAA,YACb,cAAc,SAAS,oBAAC,gCAAqB,OAAc;AAAA,YAC3D;AAAA,YACA,YAAY;AAAA,YACZ,WAAW;AAAA,YACX,OACE,aACE,iCACG;AAAA;AAAA,cACA,wBACC,oBAAC,iCAAsB,QAAgB;AAAA,eAE3C;AAAA,YAGJ,gBAAe;AAAA,YACf;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YACA,SAAQ;AAAA,YAEP;AAAA;AAAA,QACH;AAAA,MAEJ;AAAA;AAAA,EACF;AAEJ;AAEA,IAAO,mBAAQ;;;ACtFf,IAAOA,oBAAQ;","names":["TextArea_default"]}
|
|
@@ -2,9 +2,12 @@
|
|
|
2
2
|
|
|
3
3
|
var _chunkBBB4FEY6cjs = require('./chunk-BBB4FEY6.cjs');
|
|
4
4
|
|
|
5
|
+
// src/hooks/useFieldArray/useFieldArray.ts
|
|
6
|
+
var _reacthookform = require('react-hook-form');
|
|
7
|
+
|
|
5
8
|
// src/hooks/useFormContext/useFormContext.ts
|
|
6
9
|
var _react = require('react'); var _react2 = _interopRequireDefault(_react);
|
|
7
|
-
|
|
10
|
+
|
|
8
11
|
|
|
9
12
|
// src/Form/subcomponents/FormContext.tsx
|
|
10
13
|
|
|
@@ -18,15 +21,16 @@ var removeNullishFields = (obj) => {
|
|
|
18
21
|
})
|
|
19
22
|
);
|
|
20
23
|
};
|
|
24
|
+
var DEBUG_MODE_LOCAL_STORAGE_KEY_DEFAULT = "uniform:debug-mode";
|
|
21
25
|
var UniformContext = _react2.default.createContext({
|
|
22
26
|
debugMode: "off",
|
|
23
27
|
preventSubmit: () => void 0,
|
|
24
28
|
setDebugMode: () => void 0,
|
|
25
29
|
validation: void 0
|
|
26
30
|
});
|
|
27
|
-
var LOCALSTORAGE_DEBUG_MODE_KEY = "uniform:debug-mode";
|
|
28
31
|
var FormProvider = ({
|
|
29
32
|
children,
|
|
33
|
+
debugModeSettings = void 0,
|
|
30
34
|
initialValues = void 0,
|
|
31
35
|
onSubmit,
|
|
32
36
|
validation = void 0,
|
|
@@ -34,12 +38,14 @@ var FormProvider = ({
|
|
|
34
38
|
}) => {
|
|
35
39
|
const [preventSubmit, setPreventSubmit] = _react.useState.call(void 0, false);
|
|
36
40
|
const [debugMode, setDebugMode] = _pixels.useLocalStorage.call(void 0,
|
|
37
|
-
|
|
41
|
+
_optionalChain([debugModeSettings, 'optionalAccess', _ => _.localStorageKey]) || DEBUG_MODE_LOCAL_STORAGE_KEY_DEFAULT,
|
|
38
42
|
"off"
|
|
39
43
|
);
|
|
40
44
|
const contextValue = _react.useMemo.call(void 0,
|
|
41
45
|
() => ({
|
|
42
|
-
debugMode
|
|
46
|
+
// set debugMode to disabled when debugModeSettings.disable is true
|
|
47
|
+
// otherwise use current debug mode from localStorage
|
|
48
|
+
debugMode: _optionalChain([debugModeSettings, 'optionalAccess', _2 => _2.disable]) ? "disabled" : debugMode,
|
|
43
49
|
preventSubmit: (prevent) => {
|
|
44
50
|
setPreventSubmit(prevent);
|
|
45
51
|
},
|
|
@@ -47,7 +53,7 @@ var FormProvider = ({
|
|
|
47
53
|
validation
|
|
48
54
|
}),
|
|
49
55
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
50
|
-
[debugMode]
|
|
56
|
+
[debugMode, _optionalChain([debugModeSettings, 'optionalAccess', _3 => _3.disable])]
|
|
51
57
|
);
|
|
52
58
|
const methods = _reacthookform.useForm.call(void 0, {
|
|
53
59
|
defaultValues: initialValues,
|
|
@@ -69,7 +75,7 @@ var FormProvider = ({
|
|
|
69
75
|
console.warn(
|
|
70
76
|
"[FormProvider] form submit was prevented because preventSubmit is true..."
|
|
71
77
|
);
|
|
72
|
-
_optionalChain([e, 'optionalAccess',
|
|
78
|
+
_optionalChain([e, 'optionalAccess', _4 => _4.preventDefault, 'call', _5 => _5()]);
|
|
73
79
|
return Promise.resolve();
|
|
74
80
|
}
|
|
75
81
|
await methods.handleSubmit(onSubmit)(e);
|
|
@@ -81,9 +87,9 @@ var FormContext_default = FormProvider;
|
|
|
81
87
|
// src/hooks/useFormContext/useFormContext.ts
|
|
82
88
|
var recursiveSearchInnerType = (schema) => {
|
|
83
89
|
let currentSchema = schema;
|
|
84
|
-
while (_optionalChain([currentSchema, 'optionalAccess',
|
|
90
|
+
while (_optionalChain([currentSchema, 'optionalAccess', _6 => _6._def, 'optionalAccess', _7 => _7.innerType])) {
|
|
85
91
|
currentSchema = currentSchema._def.innerType;
|
|
86
|
-
if (_optionalChain([currentSchema, 'optionalAccess',
|
|
92
|
+
if (_optionalChain([currentSchema, 'optionalAccess', _8 => _8._def, 'optionalAccess', _9 => _9.typeName]) === "ZodOptional") {
|
|
87
93
|
return false;
|
|
88
94
|
}
|
|
89
95
|
}
|
|
@@ -92,19 +98,19 @@ var recursiveSearchInnerType = (schema) => {
|
|
|
92
98
|
var recursiveFieldKeySearch = (schema, path) => {
|
|
93
99
|
const [current, ...rest] = path;
|
|
94
100
|
let currentSchema = schema;
|
|
95
|
-
if (_optionalChain([schema, 'optionalAccess',
|
|
101
|
+
if (_optionalChain([schema, 'optionalAccess', _10 => _10._def, 'optionalAccess', _11 => _11.typeName]) === "ZodOptional") {
|
|
96
102
|
currentSchema = schema.unwrap();
|
|
97
103
|
}
|
|
98
|
-
if (_optionalChain([schema, 'optionalAccess',
|
|
104
|
+
if (_optionalChain([schema, 'optionalAccess', _12 => _12._def, 'optionalAccess', _13 => _13.typeName]) === "ZodEffects") {
|
|
99
105
|
return recursiveFieldKeySearch(schema._def.schema, path);
|
|
100
106
|
}
|
|
101
|
-
if (_optionalChain([currentSchema, 'optionalAccess',
|
|
102
|
-
return (_optionalChain([currentSchema, 'access',
|
|
107
|
+
if (_optionalChain([currentSchema, 'optionalAccess', _14 => _14._def, 'optionalAccess', _15 => _15.typeName]) === "ZodIntersection") {
|
|
108
|
+
return (_optionalChain([currentSchema, 'access', _16 => _16._def, 'access', _17 => _17.left, 'optionalAccess', _18 => _18.schema]) ? recursiveFieldKeySearch(currentSchema._def.left.schema, path) : recursiveFieldKeySearch(currentSchema._def.left, path)) || (_optionalChain([currentSchema, 'access', _19 => _19._def, 'access', _20 => _20.right, 'optionalAccess', _21 => _21.schema]) ? recursiveFieldKeySearch(currentSchema._def.right.schema, path) : recursiveFieldKeySearch(currentSchema._def.right, path));
|
|
103
109
|
}
|
|
104
|
-
const shape = _nullishCoalesce(_optionalChain([currentSchema, 'optionalAccess',
|
|
110
|
+
const shape = _nullishCoalesce(_optionalChain([currentSchema, 'optionalAccess', _22 => _22.shape]), () => ( _optionalChain([currentSchema, 'optionalAccess', _23 => _23.element, 'optionalAccess', _24 => _24.shape])));
|
|
105
111
|
if (shape && shape[current]) {
|
|
106
112
|
if (rest.length === 0) {
|
|
107
|
-
return _optionalChain([shape, 'access',
|
|
113
|
+
return _optionalChain([shape, 'access', _25 => _25[current], 'optionalAccess', _26 => _26._def, 'optionalAccess', _27 => _27.typeName]) !== "ZodOptional" && recursiveSearchInnerType(shape[current]);
|
|
108
114
|
}
|
|
109
115
|
return recursiveFieldKeySearch(shape[current], rest);
|
|
110
116
|
}
|
|
@@ -121,7 +127,7 @@ var useFormContext = () => {
|
|
|
121
127
|
const uniformContext = _react.useContext.call(void 0, UniformContext);
|
|
122
128
|
const getFieldState = (name, testId) => {
|
|
123
129
|
const fieldPath = typeof name === "string" ? name.replace(/\[\d+\]/g, "").split(".") : name;
|
|
124
|
-
const required = _optionalChain([uniformContext, 'optionalAccess',
|
|
130
|
+
const required = _optionalChain([uniformContext, 'optionalAccess', _28 => _28.validation]) && recursiveFieldKeySearch(uniformContext.validation.schema, fieldPath) || false;
|
|
125
131
|
const { error, ...rest } = getFieldStateOrig(name, formState);
|
|
126
132
|
return {
|
|
127
133
|
...rest,
|
|
@@ -143,5 +149,6 @@ var useFormContext = () => {
|
|
|
143
149
|
|
|
144
150
|
|
|
145
151
|
|
|
146
|
-
|
|
147
|
-
|
|
152
|
+
|
|
153
|
+
exports.useFieldArray = _reacthookform.useFieldArray; exports.FormContext_default = FormContext_default; exports.recursiveFieldKeySearch = recursiveFieldKeySearch; exports.useFormContext = useFormContext;
|
|
154
|
+
//# sourceMappingURL=chunk-WPWPZNSG.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/home/runner/work/uniform/uniform/packages/uniform/dist/chunk-WPWPZNSG.cjs","../src/hooks/useFieldArray/useFieldArray.ts","../src/hooks/useFormContext/useFormContext.ts","../src/Form/subcomponents/FormContext.tsx"],"names":[],"mappings":"AAAA;AACE;AACF,wDAA6B;AAC7B;AACA;ACDA,gDAA8B;ADG9B;AACA;AEJA,4EAA2B;AAC3B;AFMA;AACA;AGPA;AACA;AAEA,2CAAgC;AAyJ1B,+CAAA;AAnJC,IAAM,oBAAA,EAAsB,CAAC,GAAA,EAAA,GAAiC;AACnE,EAAA,OAAO,IAAA,CAAK,KAAA;AAAA,IACV,IAAA,CAAK,SAAA,CAAU,GAAA,EAAK,CAAC,IAAA,EAAM,KAAA,EAAA,GAAU;AACnC,MAAA,OAAO,MAAA,IAAU,KAAA,EAAO,KAAA,EAAA,EAAY,KAAA;AAAA,IACtC,CAAC;AAAA,EACH,CAAA;AACF,CAAA;AAWA,IAAM,qCAAA,EAAuC,oBAAA;AAetC,IAAM,eAAA,EAAiB,eAAA,CAAM,aAAA,CAWjC;AAAA,EACD,SAAA,EAAW,KAAA;AAAA,EACX,aAAA,EAAe,CAAA,EAAA,GAAM,KAAA,CAAA;AAAA,EACrB,YAAA,EAAc,CAAA,EAAA,GAAM,KAAA,CAAA;AAAA,EACpB,UAAA,EAAY,KAAA;AACd,CAAC,CAAA;AA2BD,IAAM,aAAA,EAA4C,CAAC;AAAA,EACjD,QAAA;AAA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,"/* eslint-disable import/prefer-default-export */\n\n/** @see https://react-hook-form.com/docs/usefieldarray */\nexport { useFieldArray } from 'react-hook-form';\n","import type { VetoSchema } from '@fuf-stack/veto';\nimport type { FieldError } from 'react-hook-form';\n\nimport { useContext } from 'react';\nimport { useFormContext as useHookFormContext } from 'react-hook-form';\n\nimport { UniformContext } from '../../Form/subcomponents/FormContext';\nimport { slugify } from '../../helpers';\n\n/** Checks whether the field is an optional type by recursively checking inner types */\nconst recursiveSearchInnerType = (schema: VetoSchema): boolean => {\n let currentSchema = schema;\n\n // Loop through inner types to find the root type\n while (currentSchema?._def?.innerType) {\n currentSchema = currentSchema._def.innerType;\n if (currentSchema?._def?.typeName === 'ZodOptional') {\n // Stop recursion if optional is found\n return false;\n }\n }\n // If no optional was found, assume it's required\n return true;\n};\n\n/** Recursive search to check whether a field is required or optional */\nexport const recursiveFieldKeySearch = (\n schema: VetoSchema,\n path: string[],\n): boolean | null => {\n const [current, ...rest] = path;\n\n let currentSchema = schema;\n\n // Handle ZodOptional schema: unwrap and continue searching\n if (schema?._def?.typeName === 'ZodOptional') {\n // @ts-expect-error not sure here\n currentSchema = schema.unwrap();\n }\n\n // Handle ZodEffects (transformations or validation effects)\n if (schema?._def?.typeName === 'ZodEffects') {\n // Unwrap and continue\n return recursiveFieldKeySearch(schema._def.schema, path);\n }\n\n // Handle ZodIntersection (intersection types)\n if (currentSchema?._def?.typeName === 'ZodIntersection') {\n return (\n (currentSchema._def.left?.schema\n ? recursiveFieldKeySearch(currentSchema._def.left.schema, path)\n : recursiveFieldKeySearch(currentSchema._def.left, path)) ||\n (currentSchema._def.right?.schema\n ? recursiveFieldKeySearch(currentSchema._def.right.schema, path)\n : recursiveFieldKeySearch(currentSchema._def.right, path))\n );\n }\n\n // Get the shape of an object or elements of an array schema\n // @ts-expect-error not sure here\n const shape = currentSchema?.shape ?? currentSchema?.element?.shape;\n\n if (shape && shape[current]) {\n if (rest.length === 0) {\n // At the end of the path, check if the field is optional\n return (\n shape[current]?._def?.typeName !== 'ZodOptional' &&\n recursiveSearchInnerType(shape[current])\n );\n }\n return recursiveFieldKeySearch(shape[current], rest);\n }\n // Return null if field not found\n return null;\n};\n\n/**\n * Custom hook that extends react-hook-form's useFormContext to add validation and state management.\n */\nexport const useFormContext = () => {\n const {\n formState,\n // https://react-hook-form.com/docs/useform/getfieldstate\n // for getFieldState a subscription to formState properties is needed!\n getFieldState: getFieldStateOrig,\n ...otherMethods\n } = useHookFormContext();\n\n const uniformContext = useContext(UniformContext);\n\n /**\n * Updated getFieldState method which returns:\n * - Whether the field is required by checking the validation schema\n * - Existing field state information (errors, etc.)\n */\n const getFieldState = (name: string, testId?: string) => {\n const fieldPath =\n typeof name === 'string' ? name.replace(/\\[\\d+\\]/g, '').split('.') : name;\n\n // Check if the field is required using the validation schema\n const required =\n (uniformContext?.validation &&\n recursiveFieldKeySearch(uniformContext.validation.schema, fieldPath)) ||\n false;\n\n // Get the original field state (errors, etc.) from react-hook-form\n const { error, ...rest } = getFieldStateOrig(name, formState);\n\n return {\n ...rest,\n error: error as FieldError[] | undefined, // Ensure correct type for error\n required,\n testId: slugify(testId || name),\n };\n };\n\n return {\n ...otherMethods,\n ...uniformContext,\n getFieldState,\n formState,\n };\n};\n","import type { VetoInstance } from '@fuf-stack/veto';\nimport type { ReactNode } from 'react';\nimport type { FieldValues, SubmitHandler } from 'react-hook-form';\n\nimport React, { useMemo, useState } from 'react';\nimport { FormProvider as HookFormProvider, useForm } from 'react-hook-form';\n\nimport { useLocalStorage } from '@fuf-stack/pixels';\n\n/**\n * recursively removes all fields that are null or undefined before\n * the form data is passed to the veto validation function\n */\nexport const removeNullishFields = (obj: Record<string, unknown>) => {\n return JSON.parse(\n JSON.stringify(obj, (_key, value) => {\n return value === null ? undefined : value;\n }),\n );\n};\n\ntype DebugMode = 'debug' | 'debug-testids' | 'off' | 'disabled';\n\nexport type DebugModeSettings = {\n /** disable form debug completely */\n disable?: boolean;\n /** custom localStorage key to save debug mode state */\n localStorageKey?: string;\n};\n\nconst DEBUG_MODE_LOCAL_STORAGE_KEY_DEFAULT = 'uniform:debug-mode';\n\n/**\n * The `UniformContext` provides control over the form's submission behavior and may optionally include\n * a Veto validation schema for form validation.\n *\n * Specifically, this context offers:\n * 1. **Form Submission Control**: The `preventSubmit` function allows components to enable or disable\n * form submissions.\n * 2. **Optional Validation Schema**: The `validation` property may hold a Veto validation schema instance\n * that can be used to validate form fields and handle validation logic.\n *\n * This context is useful for components that need to interact with or control the form submission state,\n * or access the validation schema for managing form validation logic.\n */\nexport const UniformContext = React.createContext<{\n /** Form debug mode enabled or not */\n debugMode: DebugMode;\n /** settings for from debug mode */\n debugModeSettings?: DebugModeSettings;\n /** Function to update if the form can currently be submitted */\n preventSubmit: (prevent: boolean) => void;\n /** Setter to enable or disable form debug mode */\n setDebugMode: (debugMode: DebugMode) => void;\n /** Optional Veto validation schema instance for form validation */\n validation?: VetoInstance;\n}>({\n debugMode: 'off',\n preventSubmit: () => undefined,\n setDebugMode: () => undefined,\n validation: undefined,\n});\n\n// Define props for the FormProvider component, extending HookForm's props\ninterface FormProviderProps {\n /** children form render function */\n children: (childProps: {\n handleSubmit: (e?: React.BaseSyntheticEvent) => Promise<void>;\n }) => ReactNode;\n /** settings for from debug mode */\n debugModeSettings?: DebugModeSettings;\n /** initial form values */\n initialValues?: FieldValues;\n /** form submit handler */\n onSubmit: SubmitHandler<FieldValues>;\n /** Veto validation schema instance */\n validation?: VetoInstance;\n /** when the validation should be triggered */\n validationTrigger: 'onChange' | 'onBlur' | 'onSubmit' | 'onTouched' | 'all';\n}\n\n/**\n * FormProvider component provides:\n * - The veto validation schema context\n * - Submit handler creation and submission control with preventSubmit\n * - Form Debug Mode state\n * - React Hook Form context\n */\nconst FormProvider: React.FC<FormProviderProps> = ({\n children,\n debugModeSettings = undefined,\n initialValues = undefined,\n onSubmit,\n validation = undefined,\n validationTrigger,\n}) => {\n // Control if the form can currently be submitted\n const [preventSubmit, setPreventSubmit] = useState(false);\n\n // Form Debug mode state is handled in the form context\n const [debugMode, setDebugMode] = useLocalStorage<DebugMode>(\n debugModeSettings?.localStorageKey || DEBUG_MODE_LOCAL_STORAGE_KEY_DEFAULT,\n 'off',\n );\n\n // Memoize the context value to prevent re-renders\n const contextValue = useMemo(\n () => ({\n // set debugMode to disabled when debugModeSettings.disable is true\n // otherwise use current debug mode from localStorage\n debugMode: debugModeSettings?.disable ? 'disabled' : debugMode,\n preventSubmit: (prevent: boolean) => {\n setPreventSubmit(prevent);\n },\n setDebugMode,\n validation,\n }),\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [debugMode, debugModeSettings?.disable],\n );\n\n // Initialize react hook form\n const methods = useForm({\n defaultValues: initialValues,\n // add validation config when validation schema provided\n ...(validation\n ? {\n // set rhf mode\n // see: https://react-hook-form.com/docs/useform#mode\n mode: validationTrigger,\n resolver: async (values) => {\n const { data, errors, ...rest } = await validation.validateAsync(\n removeNullishFields(values),\n );\n // https://github.com/react-hook-form/resolvers/blob/master/zod/src/zod.ts\n return { values: data || {}, errors: errors || {}, ...rest };\n },\n }\n : {}),\n });\n\n // Create submit handler\n // eslint-disable-next-line consistent-return\n const handleSubmit = async (e?: React.BaseSyntheticEvent) => {\n // only prevent submit when form state is valid, because otherwise\n // submit will only trigger validation and add errors / focus invalid fields\n if (methods.formState.isValid && preventSubmit) {\n console.warn(\n '[FormProvider] form submit was prevented because preventSubmit is true...',\n );\n e?.preventDefault();\n return Promise.resolve();\n }\n await methods.handleSubmit(onSubmit)(e);\n };\n\n return (\n <UniformContext.Provider value={contextValue}>\n {/* Spread all hook form props into HookFormProvider */}\n {/* eslint-disable-next-line react/jsx-props-no-spreading */}\n <HookFormProvider {...methods}>\n {children({ handleSubmit })}\n </HookFormProvider>\n </UniformContext.Provider>\n );\n};\n\nexport default FormProvider;\n"]}
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
2
|
+
|
|
3
|
+
var _chunkVQWKXSHWcjs = require('./chunk-VQWKXSHW.cjs');
|
|
4
|
+
|
|
2
5
|
|
|
3
6
|
var _chunkJU5RT22Ycjs = require('./chunk-JU5RT22Y.cjs');
|
|
4
7
|
|
|
@@ -6,16 +9,16 @@ var _chunkJU5RT22Ycjs = require('./chunk-JU5RT22Y.cjs');
|
|
|
6
9
|
var _chunkOHJYXA6Rcjs = require('./chunk-OHJYXA6R.cjs');
|
|
7
10
|
|
|
8
11
|
|
|
9
|
-
var
|
|
12
|
+
var _chunkWPWPZNSGcjs = require('./chunk-WPWPZNSG.cjs');
|
|
10
13
|
|
|
11
14
|
|
|
12
15
|
var _chunkBBB4FEY6cjs = require('./chunk-BBB4FEY6.cjs');
|
|
13
16
|
|
|
14
17
|
// src/RadioGroup/RadioGroup.tsx
|
|
15
|
-
var _reacthookform = require('react-hook-form');
|
|
16
18
|
var _radio = require('@nextui-org/radio');
|
|
17
19
|
var _pixelutils = require('@fuf-stack/pixel-utils');
|
|
18
20
|
var _pixels = require('@fuf-stack/pixels');
|
|
21
|
+
var _Tabs = require('@fuf-stack/pixels/Tabs'); var _Tabs2 = _interopRequireDefault(_Tabs);
|
|
19
22
|
|
|
20
23
|
// src/RadioGroup/Variants/RadioBox.tsx
|
|
21
24
|
|
|
@@ -104,14 +107,21 @@ var radioGroupVariants = _pixelutils.tv.call(void 0, {
|
|
|
104
107
|
itemBase: "",
|
|
105
108
|
itemBaseActive: "bg-opacity-50",
|
|
106
109
|
// optional if a button group is used
|
|
107
|
-
itemControl: "",
|
|
110
|
+
itemControl: "bg-focus group-data-[invalid=true]:bg-danger",
|
|
108
111
|
itemDescription: "",
|
|
109
112
|
itemLabel: "text-sm",
|
|
110
113
|
itemLabelWrapper: "",
|
|
111
|
-
itemWrapper: "",
|
|
114
|
+
itemWrapper: 'group-data-[invalid=true]:!border-danger [&:not(group-data-[invalid="true"]):not(group-data-[selected="false"])]:border-focus',
|
|
115
|
+
// TODO: get rid of !.
|
|
112
116
|
// 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]
|
|
114
|
-
wrapper: ""
|
|
117
|
+
label: "text-sm text-foreground subpixel-antialiased group-data-[invalid=true]:text-danger",
|
|
118
|
+
wrapper: "",
|
|
119
|
+
// Tabs
|
|
120
|
+
tabList: "",
|
|
121
|
+
tab: "",
|
|
122
|
+
tabContent: "",
|
|
123
|
+
cursor: "",
|
|
124
|
+
panel: ""
|
|
115
125
|
}
|
|
116
126
|
});
|
|
117
127
|
var RadioGroup = ({
|
|
@@ -124,14 +134,14 @@ var RadioGroup = ({
|
|
|
124
134
|
testId: _testId = void 0,
|
|
125
135
|
variant = "default"
|
|
126
136
|
}) => {
|
|
127
|
-
const { control, debugMode, getFieldState, getValues } =
|
|
137
|
+
const { control, debugMode, getFieldState, getValues } = _chunkWPWPZNSGcjs.useFormContext.call(void 0, );
|
|
128
138
|
const { error, invalid, required, testId } = getFieldState(name, _testId);
|
|
129
139
|
const showTestIdCopyButton = debugMode === "debug-testids";
|
|
130
140
|
const showLabel = label || showTestIdCopyButton;
|
|
131
141
|
const variants = radioGroupVariants();
|
|
132
142
|
const classNames = _pixelutils.variantsToClassNames.call(void 0, variants, className, "base");
|
|
133
143
|
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
134
|
-
|
|
144
|
+
_chunkVQWKXSHWcjs.Controller,
|
|
135
145
|
{
|
|
136
146
|
control,
|
|
137
147
|
disabled,
|
|
@@ -144,60 +154,90 @@ var RadioGroup = ({
|
|
|
144
154
|
description: classNames.itemDescription,
|
|
145
155
|
label: classNames.itemLabel,
|
|
146
156
|
labelWrapper: classNames.itemLabelWrapper,
|
|
147
|
-
wrapper: classNames.itemWrapper
|
|
157
|
+
wrapper: classNames.itemWrapper,
|
|
158
|
+
tabList: classNames.tabList,
|
|
159
|
+
tab: classNames.tab,
|
|
160
|
+
tabContent: classNames.tabContent,
|
|
161
|
+
cursor: classNames.cursor,
|
|
162
|
+
panel: classNames.panel
|
|
148
163
|
};
|
|
149
164
|
switch (variant) {
|
|
150
165
|
case "radioBox":
|
|
151
|
-
RadioComponents = options.map((option) =>
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
166
|
+
RadioComponents = options.map((option) => {
|
|
167
|
+
if ("value" in option) {
|
|
168
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
169
|
+
RadioBox,
|
|
170
|
+
{
|
|
171
|
+
classNames: itemClassNames,
|
|
172
|
+
"data-testid": _chunkBBB4FEY6cjs.slugify.call(void 0,
|
|
173
|
+
`${testId}_option_${option.testId || option.value}`
|
|
174
|
+
),
|
|
175
|
+
description: option.description,
|
|
176
|
+
icon: option.icon,
|
|
177
|
+
isDisabled: isDisabled || option.disabled,
|
|
178
|
+
onChange,
|
|
179
|
+
value: option.value,
|
|
180
|
+
children: option.label ? option.label : option.value
|
|
181
|
+
},
|
|
182
|
+
option.value
|
|
183
|
+
);
|
|
184
|
+
}
|
|
185
|
+
return null;
|
|
186
|
+
});
|
|
167
187
|
break;
|
|
168
188
|
case "radioButton":
|
|
169
|
-
RadioComponents = options.map((option) =>
|
|
170
|
-
|
|
189
|
+
RadioComponents = options.map((option) => {
|
|
190
|
+
if ("value" in option) {
|
|
191
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
192
|
+
RadioButton,
|
|
193
|
+
{
|
|
194
|
+
className: _pixelutils.cn.call(void 0, classNames.itemBase, {
|
|
195
|
+
[classNames.itemBaseActive]: getValues()[name] !== option.value
|
|
196
|
+
}),
|
|
197
|
+
isDisabled: isDisabled || option.disabled,
|
|
198
|
+
testID: _chunkBBB4FEY6cjs.slugify.call(void 0,
|
|
199
|
+
`${testId}_option_${option.testId || option.value}`
|
|
200
|
+
),
|
|
201
|
+
onChange,
|
|
202
|
+
value: option.value,
|
|
203
|
+
children: option.label ? option.label : option.value
|
|
204
|
+
},
|
|
205
|
+
option.value
|
|
206
|
+
);
|
|
207
|
+
}
|
|
208
|
+
return null;
|
|
209
|
+
});
|
|
210
|
+
break;
|
|
211
|
+
case "tabs":
|
|
212
|
+
RadioComponents = /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
213
|
+
_Tabs2.default,
|
|
171
214
|
{
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
`${testId}_option_${option.testId || option.value}`
|
|
178
|
-
),
|
|
179
|
-
onChange,
|
|
180
|
-
value: option.value,
|
|
181
|
-
children: option.label ? option.label : option.value
|
|
182
|
-
},
|
|
183
|
-
option.value
|
|
184
|
-
));
|
|
215
|
+
fullWidth: false,
|
|
216
|
+
tabs: options,
|
|
217
|
+
onSelectionChange: onChange
|
|
218
|
+
}
|
|
219
|
+
);
|
|
185
220
|
break;
|
|
186
221
|
default:
|
|
187
|
-
RadioComponents = options.map((option) =>
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
222
|
+
RadioComponents = options.map((option) => {
|
|
223
|
+
if ("value" in option) {
|
|
224
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
225
|
+
_radio.Radio,
|
|
226
|
+
{
|
|
227
|
+
classNames: itemClassNames,
|
|
228
|
+
"data-testid": _chunkBBB4FEY6cjs.slugify.call(void 0,
|
|
229
|
+
`${testId}_option_${option.testId || option.value}`
|
|
230
|
+
),
|
|
231
|
+
isDisabled: isDisabled || option.disabled,
|
|
232
|
+
onChange,
|
|
233
|
+
value: option.value,
|
|
234
|
+
children: option.label ? option.label : option.value
|
|
235
|
+
},
|
|
236
|
+
option.value
|
|
237
|
+
);
|
|
238
|
+
}
|
|
239
|
+
return null;
|
|
240
|
+
});
|
|
201
241
|
}
|
|
202
242
|
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
203
243
|
_radio.RadioGroup,
|
|
@@ -236,4 +276,4 @@ var RadioGroup_default2 = RadioGroup_default;
|
|
|
236
276
|
|
|
237
277
|
|
|
238
278
|
exports.RadioGroup_default = RadioGroup_default; exports.RadioGroup_default2 = RadioGroup_default2;
|
|
239
|
-
//# sourceMappingURL=chunk-
|
|
279
|
+
//# sourceMappingURL=chunk-ZBCEV3W6.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/home/runner/work/uniform/uniform/packages/uniform/dist/chunk-ZBCEV3W6.cjs","../src/RadioGroup/RadioGroup.tsx","../src/RadioGroup/Variants/RadioBox.tsx","../src/RadioGroup/Variants/RadioButton.tsx","../src/RadioGroup/index.ts"],"names":["jsx","cn"],"mappings":"AAAA;AACE;AACF,wDAA6B;AAC7B;AACE;AACF,wDAA6B;AAC7B;AACE;AACF,wDAA6B;AAC7B;AACE;AACF,wDAA6B;AAC7B;AACE;AACF,wDAA6B;AAC7B;AACA;ACZA,0CAAoD;AAEpD,oDAA6C;AAC7C,2CAA4B;AAC5B,0FAAiB;ADajB;AACA;AEnBA;AACA,6DAA+B;AAE/B;AAmCQ,+CAAA;AA5BD,IAAM,SAAA,EAAW,CAAC,EAAE,KAAA,EAAO,KAAA,CAAA,EAAW,GAAG,MAAM,CAAA,EAAA,GAAkB;AACtE,EAAA,MAAM;AAAA,IACJ,QAAA;AAAA,IACA,SAAA;AAAA,IACA,WAAA;AAAA,IACA,YAAA;AAAA,IACA,eAAA;AAAA,IACA,aA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AAEJ,IAAA;AAAA,EAAA;AAGN;AAEA;ADeA;AACA;AIzQA;AJ2QA;AACA;AACA;AACA;AACA","file":"/home/runner/work/uniform/uniform/packages/uniform/dist/chunk-ZBCEV3W6.cjs","sourcesContent":[null,"import type { TVClassName, TVProps } from '@fuf-stack/pixel-utils';\nimport type { TabOptions } from '@fuf-stack/pixels/Tabs';\nimport type { ReactElement, ReactNode } from 'react';\n\nimport { RadioGroup as NextRadioGroup, Radio } from '@nextui-org/radio';\n\nimport { cn, tv, variantsToClassNames } from '@fuf-stack/pixel-utils';\nimport { ButtonGroup } from '@fuf-stack/pixels';\nimport Tabs from '@fuf-stack/pixels/Tabs';\n\nimport { Controller } from '../Controller';\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: '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', // TODO: get rid of !.\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 // Tabs\n tabList: '',\n tab: '',\n tabContent: '',\n cursor: '',\n panel: '',\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<\n V extends 'default' | 'radioBox' | 'radioButton' | 'tabs',\n> 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: V extends 'default' | 'radioBox' | 'radioButton'\n ? RadioGroupOption[]\n : TabOptions[];\n /** Id to grab element in internal tests. */\n testId?: string;\n /** How the RadioGroup should look like. */\n variant?: V;\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<\n 'default' | 'radioBox' | 'radioButton' | 'tabs'\n>): ReactElement => {\n const { control, debugMode, getFieldState, getValues } = useFormContext();\n\n const { error, invalid, required, testId } = getFieldState(name, _testId);\n\n const showTestIdCopyButton = debugMode === 'debug-testids';\n const showLabel = label || showTestIdCopyButton;\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 tabList: classNames.tabList,\n tab: classNames.tab,\n tabContent: classNames.tabContent,\n cursor: classNames.cursor,\n panel: classNames.panel,\n };\n\n switch (variant) {\n case 'radioBox':\n RadioComponents = options.map((option) => {\n if ('value' in option) {\n return (\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 }\n return null;\n });\n break;\n case 'radioButton':\n RadioComponents = options.map((option) => {\n if ('value' in option) {\n return (\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 }\n return null;\n });\n break;\n\n case 'tabs':\n RadioComponents = (\n <Tabs\n fullWidth={false}\n tabs={options as TabOptions[]}\n onSelectionChange={onChange}\n />\n );\n break;\n default:\n RadioComponents = options.map((option) => {\n if ('value' in option) {\n return (\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 return null;\n });\n }\n\n return (\n <NextRadioGroup\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 showLabel && (\n // eslint-disable-next-line jsx-a11y/label-has-associated-control\n <label>\n {label}\n {showTestIdCopyButton && (\n <FieldCopyTestIdButton testId={testId} />\n )}\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 <ButtonGroup className={classNames.buttonGroup}>\n {RadioComponents}\n </ButtonGroup>\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-focus',\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"]}
|
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
2
|
|
|
3
|
+
var _chunkVQWKXSHWcjs = require('./chunk-VQWKXSHW.cjs');
|
|
4
|
+
|
|
5
|
+
|
|
3
6
|
var _chunkJU5RT22Ycjs = require('./chunk-JU5RT22Y.cjs');
|
|
4
7
|
|
|
5
8
|
|
|
6
9
|
var _chunkOHJYXA6Rcjs = require('./chunk-OHJYXA6R.cjs');
|
|
7
10
|
|
|
8
11
|
|
|
9
|
-
var
|
|
12
|
+
var _chunkWPWPZNSGcjs = require('./chunk-WPWPZNSG.cjs');
|
|
10
13
|
|
|
11
14
|
// src/Input/Input.tsx
|
|
12
|
-
var _reacthookform = require('react-hook-form');
|
|
13
15
|
var _input = require('@nextui-org/input');
|
|
14
16
|
var _pixelutils = require('@fuf-stack/pixel-utils');
|
|
15
17
|
var _jsxruntime = require('react/jsx-runtime');
|
|
@@ -24,12 +26,12 @@ var Input = ({
|
|
|
24
26
|
testId: _testId = void 0,
|
|
25
27
|
type = void 0
|
|
26
28
|
}) => {
|
|
27
|
-
const { control, debugMode, getFieldState } =
|
|
29
|
+
const { control, debugMode, getFieldState } = _chunkWPWPZNSGcjs.useFormContext.call(void 0, );
|
|
28
30
|
const { error, invalid, required, testId } = getFieldState(name, _testId);
|
|
29
31
|
const showTestIdCopyButton = debugMode === "debug-testids";
|
|
30
32
|
const showLabel = label || showTestIdCopyButton;
|
|
31
33
|
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
32
|
-
|
|
34
|
+
_chunkVQWKXSHWcjs.Controller,
|
|
33
35
|
{
|
|
34
36
|
control,
|
|
35
37
|
disabled,
|
|
@@ -82,4 +84,4 @@ var Input_default2 = Input_default;
|
|
|
82
84
|
|
|
83
85
|
|
|
84
86
|
exports.Input_default = Input_default; exports.Input_default2 = Input_default2;
|
|
85
|
-
//# sourceMappingURL=chunk-
|
|
87
|
+
//# sourceMappingURL=chunk-ZQ75EBWB.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/home/runner/work/uniform/uniform/packages/uniform/dist/chunk-ZQ75EBWB.cjs","../src/Input/Input.tsx","../src/Input/index.ts"],"names":["Input_default"],"mappings":"AAAA;AACE;AACF,wDAA6B;AAC7B;AACE;AACF,wDAA6B;AAC7B;AACE;AACF,wDAA6B;AAC7B;AACE;AACF,wDAA6B;AAC7B;AACA;ACXA,0CAAmC;AAEnC,oDAAmB;AAgEgB,+CAAA;AAjCnC,IAAM,MAAA,EAAQ,CAAC;AAAA,EACb,UAAA,EAAY,KAAA,CAAA;AAAA,EACZ,SAAA,EAAW,KAAA;AAAA,EACX,WAAA,EAAa,KAAA,CAAA;AAAA,EACb,MAAA,EAAQ,KAAA,CAAA;AAAA,EACR,IAAA;AAAA,EACA,YAAA,EAAc,GAAA;AAAA,EACd,aAAA,EAAe,KAAA,CAAA;AAAA,EACf,MAAA,EAAQ,Q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f,IAAA;AAAA,YACA,MAAA;AAAA,YACA,QAAA,EACE,KAAA,IAAS,SAAA,EACL,CAAC,CAAA,EAAA,GAAM;AACL,cAAA,QAAA,CAAS,MAAA,CAAO,CAAA,CAAE,MAAA,CAAO,KAAK,CAAC,CAAA;AAAA,YACjC,EAAA,EACA,QAAA;AAAA,YAEN,WAAA;AAAA,YACA,MAAA,EAAO,IAAA;AAAA,YACP,GAAA;AAAA,YACA,YAAA;AAAA,YACA,IAAA;AAAA,YACA,KAAA;AAAA,YACA,OAAA,EAAQ;AAAA,UAAA;AAAA,QACV,CAAA;AAAA,MAEJ;AAAA,IAAA;AAAA,EACF,CAAA;AAEJ,CAAA;AAEA,IAAO,cAAA,EAAQ,KAAA;AD5Bf;AACA;AEzEA,IAAOA,eAAAA,EAAQ,aAAA;AF2Ef;AACA;AACE;AACA;AACF,+EAAC","file":"/home/runner/work/uniform/uniform/packages/uniform/dist/chunk-ZQ75EBWB.cjs","sourcesContent":[null,"import type { ReactNode } from 'react';\n\nimport { Input as NextInput } from '@nextui-org/input';\n\nimport { cn } from '@fuf-stack/pixel-utils';\n\nimport { Controller } from '../Controller';\nimport { useFormContext } from '../hooks';\nimport { FieldCopyTestIdButton } from '../partials/FieldCopyTestIdButton';\nimport { FieldValidationError } from '../partials/FieldValidationError';\n\nexport interface InputProps {\n /** CSS class name */\n className?: string;\n /** input field is disabled */\n disabled?: boolean;\n /** added content to the end of the input Field. */\n endContent?: ReactNode;\n /** form field label (set to false to disable label) */\n label?: string | false;\n /** form field name */\n name: string;\n /** form field placeholder */\n placeholder?: string;\n /** content added to the start of the input field */\n startContent?: ReactNode;\n /** HTML data-testid attribute used in e2e tests */\n testId?: string;\n /** input type */\n type?: 'number' | 'password';\n}\n\n/**\n * Input component based on [NextUI Input](https://nextui.org/docs/components/input)\n */\nconst Input = ({\n className = undefined,\n disabled = false,\n endContent = undefined,\n label = undefined,\n name,\n placeholder = ' ',\n startContent = undefined,\n testId: _testId = undefined,\n type = undefined,\n}: InputProps) => {\n const { control, debugMode, getFieldState } = useFormContext();\n const { error, invalid, required, testId } = getFieldState(name, _testId);\n\n const showTestIdCopyButton = debugMode === 'debug-testids';\n const showLabel = label || showTestIdCopyButton;\n\n return (\n <Controller\n control={control}\n disabled={disabled}\n name={name}\n render={({\n field: { disabled: isDisabled, onChange, onBlur, value, ref },\n }) => {\n return (\n <NextInput\n className={cn(className)}\n classNames={{\n inputWrapper: 'group-data-[focus=true]:border-focus',\n }}\n data-testid={testId}\n endContent={endContent}\n errorMessage={error && <FieldValidationError error={error} />}\n isDisabled={isDisabled}\n isInvalid={invalid}\n isRequired={required}\n label={\n showLabel && (\n <>\n {label}\n {showTestIdCopyButton && (\n <FieldCopyTestIdButton testId={testId} />\n )}\n </>\n )\n }\n labelPlacement=\"outside\"\n name={name}\n onBlur={onBlur}\n onChange={\n type === 'number'\n ? (e) => {\n onChange(Number(e.target.value));\n }\n : onChange\n }\n placeholder={placeholder}\n radius=\"sm\"\n ref={ref}\n startContent={startContent}\n type={type}\n value={value}\n variant=\"bordered\"\n />\n );\n }}\n />\n );\n};\n\nexport default Input;\n","import Input from './Input';\n\nexport type { InputProps } from './Input';\n\nexport { Input };\n\nexport default Input;\n"]}
|
package/dist/hooks/index.cjs
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
2
|
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
|
|
5
|
+
var _chunkWPWPZNSGcjs = require('../chunk-WPWPZNSG.cjs');
|
|
5
6
|
require('../chunk-BBB4FEY6.cjs');
|
|
6
7
|
|
|
7
8
|
|
|
8
9
|
|
|
9
|
-
|
|
10
|
+
|
|
11
|
+
exports.recursiveFieldKeySearch = _chunkWPWPZNSGcjs.recursiveFieldKeySearch; exports.useFieldArray = _chunkWPWPZNSGcjs.useFieldArray; exports.useFormContext = _chunkWPWPZNSGcjs.useFormContext;
|
|
10
12
|
//# sourceMappingURL=index.cjs.map
|
package/dist/hooks/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/home/runner/work/uniform/uniform/packages/uniform/dist/hooks/index.cjs"],"names":[],"mappings":"AAAA;AACE;AACA;AACF,yDAA8B;AAC9B,iCAA8B;AAC9B;AACE;AACA;AACF,
|
|
1
|
+
{"version":3,"sources":["/home/runner/work/uniform/uniform/packages/uniform/dist/hooks/index.cjs"],"names":[],"mappings":"AAAA;AACE;AACA;AACA;AACF,yDAA8B;AAC9B,iCAA8B;AAC9B;AACE;AACA;AACA;AACF,gMAAC","file":"/home/runner/work/uniform/uniform/packages/uniform/dist/hooks/index.cjs"}
|