@fuf-stack/uniform 0.8.1 → 0.8.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/CheckboxGroup/index.cjs +3 -3
- package/dist/CheckboxGroup/index.js +2 -2
- 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.js +2 -2
- package/dist/Input/index.cjs +3 -3
- package/dist/Input/index.js +2 -2
- package/dist/RadioGroup/index.cjs +3 -3
- package/dist/RadioGroup/index.js +2 -2
- package/dist/Select/index.cjs +3 -3
- package/dist/Select/index.js +2 -2
- package/dist/SubmitButton/index.cjs +3 -3
- package/dist/SubmitButton/index.js +2 -2
- package/dist/Switch/index.cjs +3 -3
- package/dist/Switch/index.js +2 -2
- package/dist/TextArea/index.cjs +3 -3
- package/dist/TextArea/index.js +2 -2
- package/dist/{chunk-PDXVHUGH.js → chunk-2TJSK7WB.js} +2 -2
- package/dist/{chunk-ENVGJAWA.cjs → chunk-3XZLG7IJ.cjs} +3 -3
- package/dist/{chunk-ENVGJAWA.cjs.map → chunk-3XZLG7IJ.cjs.map} +1 -1
- package/dist/{chunk-FYP5BTHS.js → chunk-4AKB6HQU.js} +2 -2
- package/dist/{chunk-OD5BASYZ.js → chunk-53M7KQQO.js} +2 -2
- package/dist/{chunk-WR2PNNMP.cjs → chunk-6LZND72W.cjs} +4 -4
- package/dist/{chunk-WR2PNNMP.cjs.map → chunk-6LZND72W.cjs.map} +1 -1
- package/dist/{chunk-UIVSMVUT.js → chunk-7JRVSTSP.js} +2 -2
- package/dist/{chunk-YTHRKULG.js → chunk-BZBR7SJP.js} +2 -2
- package/dist/{chunk-OL5DXVY4.cjs → chunk-CGRZXDVB.cjs} +15 -7
- package/dist/chunk-CGRZXDVB.cjs.map +1 -0
- package/dist/{chunk-ZLLK6TCU.js → chunk-DBFTIO6Y.js} +2 -2
- package/dist/{chunk-VGJQLCH3.cjs → chunk-DN2EUCH3.cjs} +3 -3
- package/dist/{chunk-VGJQLCH3.cjs.map → chunk-DN2EUCH3.cjs.map} +1 -1
- package/dist/{chunk-B24NXJTR.js → chunk-GBPUYJXE.js} +15 -7
- package/dist/chunk-GBPUYJXE.js.map +1 -0
- package/dist/{chunk-RULU2SJ5.js → chunk-HI7L4HTP.js} +2 -2
- package/dist/{chunk-DZPPA4BG.cjs → chunk-J36VYWMB.cjs} +3 -3
- package/dist/{chunk-DZPPA4BG.cjs.map → chunk-J36VYWMB.cjs.map} +1 -1
- package/dist/{chunk-TN6ZHEXV.js → chunk-JDXFQPKX.js} +2 -2
- package/dist/{chunk-JI7GA5XH.cjs → chunk-KQIHNO3S.cjs} +3 -3
- package/dist/{chunk-JI7GA5XH.cjs.map → chunk-KQIHNO3S.cjs.map} +1 -1
- package/dist/{chunk-VN4U7FEE.cjs → chunk-KS7TCYGK.cjs} +3 -3
- package/dist/{chunk-VN4U7FEE.cjs.map → chunk-KS7TCYGK.cjs.map} +1 -1
- package/dist/{chunk-X4CGRHLI.js → chunk-LVUHS37D.js} +2 -2
- package/dist/{chunk-QP7FUODS.cjs → chunk-NAFOOSGX.cjs} +3 -3
- package/dist/{chunk-QP7FUODS.cjs.map → chunk-NAFOOSGX.cjs.map} +1 -1
- package/dist/{chunk-ZWRZZGMZ.cjs → chunk-SXJADULP.cjs} +4 -4
- package/dist/{chunk-ZWRZZGMZ.cjs.map → chunk-SXJADULP.cjs.map} +1 -1
- package/dist/{chunk-J23BIH72.cjs → chunk-VPL5TJB5.cjs} +3 -3
- package/dist/{chunk-J23BIH72.cjs.map → chunk-VPL5TJB5.cjs.map} +1 -1
- package/dist/hooks/index.cjs +2 -2
- package/dist/hooks/index.d.cts +1 -3
- package/dist/hooks/index.d.ts +1 -3
- package/dist/hooks/index.js +1 -1
- package/dist/index.cjs +12 -12
- package/dist/index.js +12 -12
- package/package.json +4 -4
- package/dist/chunk-B24NXJTR.js.map +0 -1
- package/dist/chunk-OL5DXVY4.cjs.map +0 -1
- /package/dist/{chunk-PDXVHUGH.js.map → chunk-2TJSK7WB.js.map} +0 -0
- /package/dist/{chunk-FYP5BTHS.js.map → chunk-4AKB6HQU.js.map} +0 -0
- /package/dist/{chunk-OD5BASYZ.js.map → chunk-53M7KQQO.js.map} +0 -0
- /package/dist/{chunk-UIVSMVUT.js.map → chunk-7JRVSTSP.js.map} +0 -0
- /package/dist/{chunk-YTHRKULG.js.map → chunk-BZBR7SJP.js.map} +0 -0
- /package/dist/{chunk-ZLLK6TCU.js.map → chunk-DBFTIO6Y.js.map} +0 -0
- /package/dist/{chunk-RULU2SJ5.js.map → chunk-HI7L4HTP.js.map} +0 -0
- /package/dist/{chunk-TN6ZHEXV.js.map → chunk-JDXFQPKX.js.map} +0 -0
- /package/dist/{chunk-X4CGRHLI.js.map → chunk-LVUHS37D.js.map} +0 -0
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
} from "./chunk-DBLODROX.js";
|
|
7
7
|
import {
|
|
8
8
|
useFormContext
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-GBPUYJXE.js";
|
|
10
10
|
|
|
11
11
|
// src/Input/Input.tsx
|
|
12
12
|
import { Controller } from "react-hook-form";
|
|
@@ -78,4 +78,4 @@ export {
|
|
|
78
78
|
Input_default,
|
|
79
79
|
Input_default2
|
|
80
80
|
};
|
|
81
|
-
//# sourceMappingURL=chunk-
|
|
81
|
+
//# sourceMappingURL=chunk-DBFTIO6Y.js.map
|
|
@@ -6,7 +6,7 @@ var _chunkKMMS4G7Acjs = require('./chunk-KMMS4G7A.cjs');
|
|
|
6
6
|
var _chunkQTL5FREEcjs = require('./chunk-QTL5FREE.cjs');
|
|
7
7
|
|
|
8
8
|
|
|
9
|
-
var
|
|
9
|
+
var _chunkCGRZXDVBcjs = require('./chunk-CGRZXDVB.cjs');
|
|
10
10
|
|
|
11
11
|
// src/Select/Select.tsx
|
|
12
12
|
var _reacthookform = require('react-hook-form');
|
|
@@ -87,7 +87,7 @@ var Select = ({
|
|
|
87
87
|
placeholder = void 0,
|
|
88
88
|
testId: _testId = void 0
|
|
89
89
|
}) => {
|
|
90
|
-
const { control, getFieldState } =
|
|
90
|
+
const { control, getFieldState } = _chunkCGRZXDVBcjs.useFormContext.call(void 0, );
|
|
91
91
|
const { error, invalid, required, testId } = getFieldState(name, _testId);
|
|
92
92
|
const {
|
|
93
93
|
label,
|
|
@@ -236,4 +236,4 @@ var Select_default2 = Select_default;
|
|
|
236
236
|
|
|
237
237
|
|
|
238
238
|
exports.Select_default = Select_default; exports.Select_default2 = Select_default2;
|
|
239
|
-
//# sourceMappingURL=chunk-
|
|
239
|
+
//# sourceMappingURL=chunk-DN2EUCH3.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/home/runner/work/uniform/uniform/packages/uniform/dist/chunk-VGJQLCH3.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;AACA;ACRA,gDAA2B;AAC3B,qGAAwC;AAExC,4CAA0B;AAE1B,oDAAuB;AAiDd,+CAAA;AALT,IAAM,eAAA,EAA0C,CAAC,KAAA,EAAA,GAAU;AAGzD,EAAA,MAAM,OAAA,EAAS,CAAA,EAAA;AAER,EAAA;AACT;AAEM;AAGW,EAAA;AAEb,EAAA;AAKJ;AAEM;AAKW,EAAA;AAEb,EAAA;AAKJ;AAEa;AACJ,EAAA;AACL,IAAA;AAGE,IAAA;AACS,IAAA;AACE,IAAA;AACb,IAAA;AAEO,IAAA;AACO,IAAA;AACd,IAAA;AACA,IAAA;AACO,IAAA;AACP,IAAA;AACA,IAAA;AACM,IAAA;AACI,IAAA;AAAA;AAAA;AAGE,IAAA;AAEV,IAAA;AACF,IAAA;AACA,IAAA;AACA,IAAA;AAEA,IAAA;AAEQ,IAAA;AACK,IAAA;AACb,IA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,cAAA;AACA,cAAA;AACA,cAAA;AAEI,gBAAA;AACD,cAAA;AACH,cAAA;AACA,cAAA;AAEI,gBAAA;AACD,cAAA;AACH,cAAA;AACA,cAAA;AACA,cAAA;AACA,cAAA;AACA,cAAA;AACA,cAAA;AACA,cAAA;AACA,cAAA;AAEI,gBAAA;AACA,gBAAA;AACD,cAAA;AACH,cAAA;AACA,cAAA;AACF,YAAA;AACA,YAAA;AACE,cAAA;AACA,cAAA;AACA,cAAA;AACF,YAAA;AACA,YAAA;AACA,YAAA;AACA,YAAA;AACA,YAAA;AACA,YAAA;AACA,YAAA;AACA,YAAA;AACA,YAAA;AACA,YAAA;AACA,YAAA;AACA,YAAA;AACM,cAAA;AACF,gBAAA;AAEA,gCAAA;AACE,kBAAA;AACD,gBAAA;AACD,gBAAA;AACF,cAAA;AAEE,gBAAA;AACF,cAAA;AACF,YAAA;AACA,YAAA;AAEA,YAAA;AAIA,YAAA;AACA,YAAA;AACA,YAAA;AACA,YAAA;AAAA,UAAA;AACF,QAAA;AACC,QAAA;AAEC,wBAAA;AAOJ,MAAA;AAAA,IAAA;AAEJ,EAAA;AAEJ;AAEO;ADtFW;AACA;AEjOXA;AFmOW;AACA;AACA;AACA;AACA","file":"/home/runner/work/uniform/uniform/packages/uniform/dist/chunk-VGJQLCH3.cjs","sourcesContent":[null,"import type { Props } from 'react-select';\n\nimport { Controller } from 'react-hook-form';\nimport ReactSelect, { components } from 'react-select';\n\nimport { useSelect } from '@nextui-org/select';\n\nimport { cn, tv } from '@fuf-stack/pixel-utils';\n\nimport { useFormContext } from '../hooks';\nimport { FieldCopyTestIdButton } from '../partials/FieldCopyTestIdButton';\nimport { FieldValidationError } from '../partials/FieldValidationError';\n\ntype SelectOption = {\n /** option label */\n label?: React.ReactNode;\n /** option value */\n value: string;\n};\n\nexport interface SelectProps {\n /** CSS class name */\n className?: string; // string;\n /** Determine if the */\n clearable?: boolean;\n /** Set the select to disabled state. */\n disabled?: boolean;\n\n filterOption?:\n | undefined\n | ((option?: SelectOption, inputValue?: string) => boolean);\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']}_input`;\n // eslint-disable-next-line react/jsx-props-no-spreading\n return <components.Input data-testid={testId} {...props} />;\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']}_option_${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}_dropdown`}>\n {/* eslint-disable-next-line react/jsx-props-no-spreading */}\n <components.DropdownIndicator {...props} />\n </div>\n );\n};\n\nexport const selectVariants = tv({\n slots: {\n clearIndicator:\n 'rounded-md p-1 text-neutral-500 hover:cursor-pointer hover:bg-gray-200 hover:text-neutral-800 hover:dark:bg-default-200 hover:dark:text-default-500',\n control:\n 'rounded-lg border-2 border-gray-200 shadow-sm !duration-150 transition-background hover:border-gray-400 motion-reduce:transition-none dark:border-default-200 hover:dark:border-default-400 focus:dark:border-default-400',\n crossIcon: '',\n downChevron: '',\n dropdownIndicator:\n 'rounded-md p-1 text-neutral-500 hover:cursor-pointer hover:bg-gray-200 hover:text-black hover:dark:bg-default-200 hover:dark:text-default-500',\n group: '',\n groupHeading: 'mb-1 ml-3 mt-2 text-sm text-neutral-500',\n indicatorsContainer: 'gap-1 p-1',\n indicatorSeparator: 'bg-gray-300 dark:bg-default-300',\n input: 'py-0.5 pl-1',\n loadingIndicator: '',\n loadingMessage: '',\n menu: 'mt-2 rounded-xl border border-gray-200 bg-default-50 p-1 shadow-sm dark:border-gray-900 dark:bg-default-50',\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:\n 'items-center gap-1.5 rounded bg-gray-100 py-0.5 pl-2 pr-1 dark:bg-default-100',\n multiValueContainer: '',\n multiValueLabel: 'py-0.5 leading-6',\n multiValueRemove:\n 'rounded text-neutral-500 hover:cursor-pointer hover:border-gray-300 hover:text-neutral-800 hover:dark:bg-default-200 hover:dark:text-default-500',\n noOptionsMessage:\n 'rounded-sm bg-gray-50 p-2 text-neutral-500 dark:bg-default-100',\n option: 'rounded px-3 py-2 hover:cursor-pointer',\n placeholder: 'py-0.5 pl-1 text-neutral-500',\n selectContainer: '',\n singleValue: '!ml-1 !leading-7',\n valueContainer: 'gap-1 p-1',\n },\n variants: {\n invalid: {\n true: {\n control:\n 'border-danger hover:border-danger dark:border-danger hover:dark:border-danger',\n },\n },\n focused: {\n true: {\n option:\n 'bg-gray-100 active:bg-gray-200 dark:bg-default-100 dark:active:bg-default-200',\n },\n },\n optionSelected: {\n true: { option: 'bg-gray-300 dark:bg-default-300' },\n },\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 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, getFieldState } = useFormContext();\n const { error, invalid, required, testId } = getFieldState(name, _testId);\n\n const {\n label,\n getLabelProps,\n getTriggerProps,\n getValueProps,\n getHelperWrapperProps,\n getErrorMessageProps,\n } = useSelect({\n isLoading: loading,\n isInvalid: invalid,\n isRequired: required,\n isDisabled: disabled,\n errorMessage: JSON.stringify(error),\n label: _label,\n labelPlacement: 'outside',\n children: [],\n });\n\n const {\n clearIndicator: clearIndicatorSlot,\n control: controlSlot,\n dropdownIndicator: dropdownIndicatorSlot,\n groupHeading: groupHeadingSlot,\n indicatorsContainer: indicatorContainerSlot,\n indicatorSeparator: indicatorSeparatorSlot,\n input: inputSlot,\n menu: menuSlot,\n menuPortal: menuPortalSlot,\n multiValue: multiValueSlot,\n multiValueLabel: multiValueLabelSlot,\n multiValueRemove: multiValueRemoveSlot,\n noOptionsMessage: noOptionsMessageSlot,\n option: optionSlot,\n placeholder: placeholderSlot,\n singleValue: singleValueSlot,\n valueContainer: valueContainerSlot,\n } = selectVariants({ invalid });\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 className={cn(className, 'mt-2')} data-testid={`${testId}_select`}>\n {label && (\n <label\n htmlFor={`react-select-${name}-input`} // {getTriggerProps().id}\n className={`${getLabelProps().className} !pointer-events-auto !static -mb-1 ml-1`}\n >\n {label}\n <FieldCopyTestIdButton testId={testId} />\n </label>\n )}\n <ReactSelect\n aria-errormessage=\"\"\n aria-invalid={invalid}\n // Does not affect the testId of the select, but is needed to pass it to sub-components\n data-testid={`${testId}_select`}\n // eslint-disable-next-line react/jsx-props-no-spreading\n {...() => {\n // eslint-disable-next-line @typescript-eslint/no-unused-vars, @typescript-eslint/naming-convention\n const { className: _className, ...rest } = getTriggerProps();\n return rest;\n }}\n aria-labelledby={\n getTriggerProps()['aria-labelledby']?.split(' ')[1]\n }\n classNames={{\n control: ({ isFocused }) =>\n // border focus style\n controlSlot({\n className: !invalid && isFocused && '!border-primary',\n }),\n placeholder: () => placeholderSlot(),\n input: () => inputSlot(),\n valueContainer: () => valueContainerSlot(),\n singleValue: () =>\n singleValueSlot({\n className: `${getValueProps().className}`,\n }),\n multiValue: () => multiValueSlot(),\n multiValueLabel: () =>\n multiValueLabelSlot({\n className: `${getValueProps().className}`,\n }),\n multiValueRemove: () => multiValueRemoveSlot(),\n indicatorsContainer: () => indicatorContainerSlot(),\n clearIndicator: () => clearIndicatorSlot(),\n indicatorSeparator: () => indicatorSeparatorSlot(),\n dropdownIndicator: () => dropdownIndicatorSlot(),\n menu: () => menuSlot(),\n groupHeading: () => groupHeadingSlot(),\n option: ({ isFocused, isSelected }) =>\n optionSlot({\n focused: isFocused,\n optionSelected: isSelected,\n }),\n noOptionsMessage: () => noOptionsMessageSlot(),\n menuPortal: () => menuPortalSlot(),\n }}\n components={{\n Input: InputComponent,\n Option: OptionComponent,\n DropdownIndicator: DropdownIndicatorComponent,\n }}\n filterOption={filterOption}\n instanceId={name}\n inputValue={inputValue}\n isClearable={clearable}\n isDisabled={disabled}\n isLoading={loading}\n isMulti={multiSelect}\n options={options}\n placeholder={placeholder}\n unstyled\n onChange={(option) => {\n if (multiSelect) {\n const transformedOptions: string[] = [];\n // @ts-expect-error in this case option is an array.\n option?.forEach((o: { value: string }) => {\n transformedOptions.push(o.value);\n });\n onChange(transformedOptions);\n } else {\n // @ts-expect-error in this case option is of type SelectOption and has the property value.\n onChange(option && option.value);\n }\n }}\n onInputChange={onInputChange}\n // attach menu modal or body so it works in card and modal\n menuPortalTarget={\n (document.getElementById('modal_body')?.parentNode\n ?.parentNode as HTMLElement) || document.body\n }\n value={options.find((option) => option.value === value)}\n onBlur={onBlur}\n name={name}\n ref={ref}\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
|
+
{"version":3,"sources":["/home/runner/work/uniform/uniform/packages/uniform/dist/chunk-DN2EUCH3.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;AACA;ACRA,gDAA2B;AAC3B,qGAAwC;AAExC,4CAA0B;AAE1B,oDAAuB;AAiDd,+CAAA;AALT,IAAM,eAAA,EAA0C,CAAC,KAAA,EAAA,GAAU;AAGzD,EAAA,MAAM,OAAA,EAAS,CAAA,EAAA;AAER,EAAA;AACT;AAEM;AAGW,EAAA;AAEb,EAAA;AAKJ;AAEM;AAKW,EAAA;AAEb,EAAA;AAKJ;AAEa;AACJ,EAAA;AACL,IAAA;AAGE,IAAA;AACS,IAAA;AACE,IAAA;AACb,IAAA;AAEO,IAAA;AACO,IAAA;AACd,IAAA;AACA,IAAA;AACO,IAAA;AACP,IAAA;AACA,IAAA;AACM,IAAA;AACI,IAAA;AAAA;AAAA;AAGE,IAAA;AAEV,IAAA;AACF,IAAA;AACA,IAAA;AACA,IAAA;AAEA,IAAA;AAEQ,IAAA;AACK,IAAA;AACb,IAAA;AACa,IAAA;AACb,IAAA;AACF,EAAA;AACU,EAAA;AACC,IAAA;AACD,MAAA;AAEF,QAAA;AACJ,MAAA;AACF,IAAA;AACS,IAAA;AACD,MAAA;AAEF,QAAA;AACJ,MAAA;AACF,IAAA;AACA,IAAA;AACU,MAAA;AACV,IAAA;AACF,EAAA;AACD;AAGe;AACF,EAAA;AACA,EAAA;AACD,EAAA;AACI,EAAA;AACF,EAAA;AACG,EAAA;AACN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AA;AACA,cAAA;AACF,YAAA;AACA,YAAA;AACA,YAAA;AACA,YAAA;AACA,YAAA;AACA,YAAA;AACA,YAAA;AACA,YAAA;AACA,YAAA;AACA,YAAA;AACA,YAAA;AACA,YAAA;AACM,cAAA;AACF,gBAAA;AAEA,gCAAA;AACE,kBAAA;AACD,gBAAA;AACD,gBAAA;AACF,cAAA;AAEE,gBAAA;AACF,cAAA;AACF,YAAA;AACA,YAAA;AAEA,YAAA;AAIA,YAAA;AACA,YAAA;AACA,YAAA;AACA,YAAA;AAAA,UAAA;AACF,QAAA;AACC,QAAA;AAEC,wBAAA;AAOJ,MAAA;AAAA,IAAA;AAEJ,EAAA;AAEJ;AAEO;ADtFW;AACA;AEjOXA;AFmOW;AACA;AACA;AACA;AACA","file":"/home/runner/work/uniform/uniform/packages/uniform/dist/chunk-DN2EUCH3.cjs","sourcesContent":[null,"import type { Props } from 'react-select';\n\nimport { Controller } from 'react-hook-form';\nimport ReactSelect, { components } from 'react-select';\n\nimport { useSelect } from '@nextui-org/select';\n\nimport { cn, tv } from '@fuf-stack/pixel-utils';\n\nimport { useFormContext } from '../hooks';\nimport { FieldCopyTestIdButton } from '../partials/FieldCopyTestIdButton';\nimport { FieldValidationError } from '../partials/FieldValidationError';\n\ntype SelectOption = {\n /** option label */\n label?: React.ReactNode;\n /** option value */\n value: string;\n};\n\nexport interface SelectProps {\n /** CSS class name */\n className?: string; // string;\n /** Determine if the */\n clearable?: boolean;\n /** Set the select to disabled state. */\n disabled?: boolean;\n\n filterOption?:\n | undefined\n | ((option?: SelectOption, inputValue?: string) => boolean);\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']}_input`;\n // eslint-disable-next-line react/jsx-props-no-spreading\n return <components.Input data-testid={testId} {...props} />;\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']}_option_${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}_dropdown`}>\n {/* eslint-disable-next-line react/jsx-props-no-spreading */}\n <components.DropdownIndicator {...props} />\n </div>\n );\n};\n\nexport const selectVariants = tv({\n slots: {\n clearIndicator:\n 'rounded-md p-1 text-neutral-500 hover:cursor-pointer hover:bg-gray-200 hover:text-neutral-800 hover:dark:bg-default-200 hover:dark:text-default-500',\n control:\n 'rounded-lg border-2 border-gray-200 shadow-sm !duration-150 transition-background hover:border-gray-400 motion-reduce:transition-none dark:border-default-200 hover:dark:border-default-400 focus:dark:border-default-400',\n crossIcon: '',\n downChevron: '',\n dropdownIndicator:\n 'rounded-md p-1 text-neutral-500 hover:cursor-pointer hover:bg-gray-200 hover:text-black hover:dark:bg-default-200 hover:dark:text-default-500',\n group: '',\n groupHeading: 'mb-1 ml-3 mt-2 text-sm text-neutral-500',\n indicatorsContainer: 'gap-1 p-1',\n indicatorSeparator: 'bg-gray-300 dark:bg-default-300',\n input: 'py-0.5 pl-1',\n loadingIndicator: '',\n loadingMessage: '',\n menu: 'mt-2 rounded-xl border border-gray-200 bg-default-50 p-1 shadow-sm dark:border-gray-900 dark:bg-default-50',\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:\n 'items-center gap-1.5 rounded bg-gray-100 py-0.5 pl-2 pr-1 dark:bg-default-100',\n multiValueContainer: '',\n multiValueLabel: 'py-0.5 leading-6',\n multiValueRemove:\n 'rounded text-neutral-500 hover:cursor-pointer hover:border-gray-300 hover:text-neutral-800 hover:dark:bg-default-200 hover:dark:text-default-500',\n noOptionsMessage:\n 'rounded-sm bg-gray-50 p-2 text-neutral-500 dark:bg-default-100',\n option: 'rounded px-3 py-2 hover:cursor-pointer',\n placeholder: 'py-0.5 pl-1 text-neutral-500',\n selectContainer: '',\n singleValue: '!ml-1 !leading-7',\n valueContainer: 'gap-1 p-1',\n },\n variants: {\n invalid: {\n true: {\n control:\n 'border-danger hover:border-danger dark:border-danger hover:dark:border-danger',\n },\n },\n focused: {\n true: {\n option:\n 'bg-gray-100 active:bg-gray-200 dark:bg-default-100 dark:active:bg-default-200',\n },\n },\n optionSelected: {\n true: { option: 'bg-gray-300 dark:bg-default-300' },\n },\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 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, getFieldState } = useFormContext();\n const { error, invalid, required, testId } = getFieldState(name, _testId);\n\n const {\n label,\n getLabelProps,\n getTriggerProps,\n getValueProps,\n getHelperWrapperProps,\n getErrorMessageProps,\n } = useSelect({\n isLoading: loading,\n isInvalid: invalid,\n isRequired: required,\n isDisabled: disabled,\n errorMessage: JSON.stringify(error),\n label: _label,\n labelPlacement: 'outside',\n children: [],\n });\n\n const {\n clearIndicator: clearIndicatorSlot,\n control: controlSlot,\n dropdownIndicator: dropdownIndicatorSlot,\n groupHeading: groupHeadingSlot,\n indicatorsContainer: indicatorContainerSlot,\n indicatorSeparator: indicatorSeparatorSlot,\n input: inputSlot,\n menu: menuSlot,\n menuPortal: menuPortalSlot,\n multiValue: multiValueSlot,\n multiValueLabel: multiValueLabelSlot,\n multiValueRemove: multiValueRemoveSlot,\n noOptionsMessage: noOptionsMessageSlot,\n option: optionSlot,\n placeholder: placeholderSlot,\n singleValue: singleValueSlot,\n valueContainer: valueContainerSlot,\n } = selectVariants({ invalid });\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 className={cn(className, 'mt-2')} data-testid={`${testId}_select`}>\n {label && (\n <label\n htmlFor={`react-select-${name}-input`} // {getTriggerProps().id}\n className={`${getLabelProps().className} !pointer-events-auto !static -mb-1 ml-1`}\n >\n {label}\n <FieldCopyTestIdButton testId={testId} />\n </label>\n )}\n <ReactSelect\n aria-errormessage=\"\"\n aria-invalid={invalid}\n // Does not affect the testId of the select, but is needed to pass it to sub-components\n data-testid={`${testId}_select`}\n // eslint-disable-next-line react/jsx-props-no-spreading\n {...() => {\n // eslint-disable-next-line @typescript-eslint/no-unused-vars, @typescript-eslint/naming-convention\n const { className: _className, ...rest } = getTriggerProps();\n return rest;\n }}\n aria-labelledby={\n getTriggerProps()['aria-labelledby']?.split(' ')[1]\n }\n classNames={{\n control: ({ isFocused }) =>\n // border focus style\n controlSlot({\n className: !invalid && isFocused && '!border-primary',\n }),\n placeholder: () => placeholderSlot(),\n input: () => inputSlot(),\n valueContainer: () => valueContainerSlot(),\n singleValue: () =>\n singleValueSlot({\n className: `${getValueProps().className}`,\n }),\n multiValue: () => multiValueSlot(),\n multiValueLabel: () =>\n multiValueLabelSlot({\n className: `${getValueProps().className}`,\n }),\n multiValueRemove: () => multiValueRemoveSlot(),\n indicatorsContainer: () => indicatorContainerSlot(),\n clearIndicator: () => clearIndicatorSlot(),\n indicatorSeparator: () => indicatorSeparatorSlot(),\n dropdownIndicator: () => dropdownIndicatorSlot(),\n menu: () => menuSlot(),\n groupHeading: () => groupHeadingSlot(),\n option: ({ isFocused, isSelected }) =>\n optionSlot({\n focused: isFocused,\n optionSelected: isSelected,\n }),\n noOptionsMessage: () => noOptionsMessageSlot(),\n menuPortal: () => menuPortalSlot(),\n }}\n components={{\n Input: InputComponent,\n Option: OptionComponent,\n DropdownIndicator: DropdownIndicatorComponent,\n }}\n filterOption={filterOption}\n instanceId={name}\n inputValue={inputValue}\n isClearable={clearable}\n isDisabled={disabled}\n isLoading={loading}\n isMulti={multiSelect}\n options={options}\n placeholder={placeholder}\n unstyled\n onChange={(option) => {\n if (multiSelect) {\n const transformedOptions: string[] = [];\n // @ts-expect-error in this case option is an array.\n option?.forEach((o: { value: string }) => {\n transformedOptions.push(o.value);\n });\n onChange(transformedOptions);\n } else {\n // @ts-expect-error in this case option is of type SelectOption and has the property value.\n onChange(option && option.value);\n }\n }}\n onInputChange={onInputChange}\n // attach menu modal or body so it works in card and modal\n menuPortalTarget={\n (document.getElementById('modal_body')?.parentNode\n ?.parentNode as HTMLElement) || document.body\n }\n value={options.find((option) => option.value === value)}\n onBlur={onBlur}\n name={name}\n ref={ref}\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"]}
|
|
@@ -17,7 +17,10 @@ var removeNullishFields = (obj) => {
|
|
|
17
17
|
})
|
|
18
18
|
);
|
|
19
19
|
};
|
|
20
|
-
var UniformContext = React.createContext(
|
|
20
|
+
var UniformContext = React.createContext({
|
|
21
|
+
preventSubmit: () => void 0,
|
|
22
|
+
validation: void 0
|
|
23
|
+
});
|
|
21
24
|
var FormProvider = ({
|
|
22
25
|
children,
|
|
23
26
|
initialValues = void 0,
|
|
@@ -25,11 +28,16 @@ var FormProvider = ({
|
|
|
25
28
|
validation = void 0,
|
|
26
29
|
validationTrigger
|
|
27
30
|
}) => {
|
|
28
|
-
const [
|
|
31
|
+
const [preventSubmit, setPreventSubmit] = useState(false);
|
|
29
32
|
const contextValue = useMemo(
|
|
30
|
-
() => ({
|
|
33
|
+
() => ({
|
|
34
|
+
preventSubmit: (prevent) => {
|
|
35
|
+
setPreventSubmit(prevent);
|
|
36
|
+
},
|
|
37
|
+
validation
|
|
38
|
+
}),
|
|
31
39
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
32
|
-
[
|
|
40
|
+
[]
|
|
33
41
|
);
|
|
34
42
|
const methods = useForm({
|
|
35
43
|
defaultValues: initialValues,
|
|
@@ -47,9 +55,9 @@ var FormProvider = ({
|
|
|
47
55
|
} : {}
|
|
48
56
|
});
|
|
49
57
|
const handleSubmit = async (e) => {
|
|
50
|
-
if (
|
|
58
|
+
if (preventSubmit) {
|
|
51
59
|
console.warn(
|
|
52
|
-
"[FormProvider] form submit was
|
|
60
|
+
"[FormProvider] form submit was prevented because preventSubmit is true..."
|
|
53
61
|
);
|
|
54
62
|
e?.preventDefault();
|
|
55
63
|
return Promise.resolve();
|
|
@@ -126,4 +134,4 @@ export {
|
|
|
126
134
|
recursiveFieldKeySearch,
|
|
127
135
|
useFormContext
|
|
128
136
|
};
|
|
129
|
-
//# sourceMappingURL=chunk-
|
|
137
|
+
//# sourceMappingURL=chunk-GBPUYJXE.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/hooks/useFormContext/useFormContext.ts","../src/Form/subcomponents/FormContext.tsx"],"sourcesContent":["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\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\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 /** Function to update if the form can currently be submitted */\n preventSubmit: (prevent: boolean) => void;\n /** Optional Veto validation schema instance for form validation */\n validation?: VetoInstance;\n}>({\n preventSubmit: () => 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 /** 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 * - React Hook Form context\n */\nconst FormProvider: React.FC<FormProviderProps> = ({\n children,\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 // Memoize the context value to prevent re-renders\n const contextValue = useMemo(\n () => ({\n preventSubmit: (prevent: boolean) => {\n setPreventSubmit(prevent);\n },\n validation,\n }),\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [],\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 if (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"],"mappings":";;;;;AAGA,SAAS,kBAAkB;AAC3B,SAAS,kBAAkB,0BAA0B;;;ACArD,OAAO,SAAS,SAAS,gBAAgB;AACzC,SAAS,gBAAgB,kBAAkB,eAAe;AAsHpD;AAhHC,IAAM,sBAAsB,CAAC,QAAiC;AACnE,SAAO,KAAK;AAAA,IACV,KAAK,UAAU,KAAK,CAAC,MAAM,UAAU;AACnC,aAAO,UAAU,OAAO,SAAY;AAAA,IACtC,CAAC;AAAA,EACH;AACF;AAeO,IAAM,iBAAiB,MAAM,cAKjC;AAAA,EACD,eAAe,MAAM;AAAA,EACrB,YAAY;AACd,CAAC;AAwBD,IAAM,eAA4C,CAAC;AAAA,EACjD;AAAA,EACA,gBAAgB;AAAA,EAChB;AAAA,EACA,aAAa;AAAA,EACb;AACF,MAAM;AAEJ,QAAM,CAAC,eAAe,gBAAgB,IAAI,SAAS,KAAK;AAGxD,QAAM,eAAe;AAAA,IACnB,OAAO;AAAA,MACL,eAAe,CAAC,YAAqB;AACnC,yBAAiB,OAAO;AAAA,MAC1B;AAAA,MACA;AAAA,IACF;AAAA;AAAA,IAEA,CAAC;AAAA,EACH;AAGA,QAAM,UAAU,QAAQ;AAAA,IACtB,eAAe;AAAA;AAAA,IAEf,GAAI,aACA;AAAA;AAAA;AAAA,MAGE,MAAM;AAAA,MACN,UAAU,OAAO,WAAW;AAC1B,cAAM,EAAE,MAAM,QAAQ,GAAG,KAAK,IAAI,MAAM,WAAW;AAAA,UACjD,oBAAoB,MAAM;AAAA,QAC5B;AAEA,eAAO,EAAE,QAAQ,QAAQ,CAAC,GA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9D,MAAI,SAAS,MAAM,OAAO,GAAG;AAC3B,QAAI,KAAK,WAAW,GAAG;AAErB,aACE,MAAM,OAAO,GAAG,MAAM,aAAa,iBACnC,yBAAyB,MAAM,OAAO,CAAC;AAAA,IAE3C;AACA,WAAO,wBAAwB,MAAM,OAAO,GAAG,IAAI;AAAA,EACrD;AAEA,SAAO;AACT;AAKO,IAAM,iBAAiB,MAAM;AAClC,QAAM;AAAA,IACJ;AAAA;AAAA;AAAA,IAGA,eAAe;AAAA,IACf,GAAG;AAAA,EACL,IAAI,mBAAmB;AAEvB,QAAM,iBAAiB,WAAW,cAAc;AAOhD,QAAM,gBAAgB,CAAC,MAAc,WAAoB;AACvD,UAAM,YACJ,OAAO,SAAS,WAAW,KAAK,QAAQ,YAAY,EAAE,EAAE,MAAM,GAAG,IAAI;AAGvE,UAAM,WACH,gBAAgB,cACf,wBAAwB,eAAe,WAAW,QAAQ,SAAS,KACrE;AAGF,UAAM,EAAE,OAAO,GAAG,KAAK,IAAI,kBAAkB,MAAM,SAAS;AAE5D,WAAO;AAAA,MACL,GAAG;AAAA,MACH;AAAA;AAAA,MACA;AAAA,MACA,QAAQ,QAAQ,UAAU,IAAI;AAAA,IAChC;AAAA,EACF;AAEA,SAAO;AAAA,IACL,GAAG;AAAA,IACH,GAAG;AAAA,IACH;AAAA,IACA;AAAA,EACF;AACF;","names":[]}
|
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
} from "./chunk-DBLODROX.js";
|
|
7
7
|
import {
|
|
8
8
|
useFormContext
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-GBPUYJXE.js";
|
|
10
10
|
import {
|
|
11
11
|
slugify
|
|
12
12
|
} from "./chunk-V46BHM2U.js";
|
|
@@ -284,4 +284,4 @@ export {
|
|
|
284
284
|
FieldArray_default,
|
|
285
285
|
FieldArray_default2
|
|
286
286
|
};
|
|
287
|
-
//# sourceMappingURL=chunk-
|
|
287
|
+
//# sourceMappingURL=chunk-HI7L4HTP.js.map
|
|
@@ -6,7 +6,7 @@ var _chunkKMMS4G7Acjs = require('./chunk-KMMS4G7A.cjs');
|
|
|
6
6
|
var _chunkQTL5FREEcjs = require('./chunk-QTL5FREE.cjs');
|
|
7
7
|
|
|
8
8
|
|
|
9
|
-
var
|
|
9
|
+
var _chunkCGRZXDVBcjs = require('./chunk-CGRZXDVB.cjs');
|
|
10
10
|
|
|
11
11
|
// src/Switch/Switch.tsx
|
|
12
12
|
var _reacthookform = require('react-hook-form');
|
|
@@ -20,7 +20,7 @@ var Switch = ({
|
|
|
20
20
|
name,
|
|
21
21
|
testId: _testId = void 0
|
|
22
22
|
}) => {
|
|
23
|
-
const { control, getFieldState } =
|
|
23
|
+
const { control, getFieldState } = _chunkCGRZXDVBcjs.useFormContext.call(void 0, );
|
|
24
24
|
const { error, required, testId, invalid } = getFieldState(name, _testId);
|
|
25
25
|
const { label, getInputProps, getHelperWrapperProps, getErrorMessageProps } = _input.useInput.call(void 0, {
|
|
26
26
|
errorMessage: JSON.stringify(error),
|
|
@@ -78,4 +78,4 @@ var Switch_default2 = Switch_default;
|
|
|
78
78
|
|
|
79
79
|
|
|
80
80
|
exports.Switch_default = Switch_default; exports.Switch_default2 = Switch_default2;
|
|
81
|
-
//# sourceMappingURL=chunk-
|
|
81
|
+
//# sourceMappingURL=chunk-J36VYWMB.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/home/runner/work/uniform/uniform/packages/uniform/dist/chunk-
|
|
1
|
+
{"version":3,"sources":["/home/runner/work/uniform/uniform/packages/uniform/dist/chunk-J36VYWMB.cjs","../src/Switch/Switch.tsx","../src/Switch/index.ts"],"names":[],"mappings":"AAAA;AACE;AACF,wDAA6B;AAC7B;AACE;AACF,wDAA6B;AAC7B;AACE;AACF,wDAA6B;AAC7B;AACA;ACVA,gDAA2B;AAE3B,0CAAyB;AACzB,4CAAqC;AAkD7B,+CAAA;AA5BR,IAAM,OAAA,EAAS,CAAC;AAAA,E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A,EAAU,cAAA,EAAgB,EAAE,CAAA;AAAA,YAAA;AACjF,YAAA;AACa,YAAA;AACb,YAAA;AACA,YAAA;AACA,YAAA;AACA,YAAA;AACA,YAAA;AACA,YAAA;AAEC,cAAA;AAAA,cAAA;AAE2C,8BAAA;AAEL,YAAA;AAAA,UAAA;AAAA,QAAA;AACzC,QAAA;AACC,wBAAA;AAOC,MAAA;AAEJ,IAAA;AAAA,EAAA;AAIR;AAEA;ADnBA;AACA;AEnEA;AFqEA;AACA;AACA;AACA;AACA","file":"/home/runner/work/uniform/uniform/packages/uniform/dist/chunk-J36VYWMB.cjs","sourcesContent":[null,"import { Controller } from 'react-hook-form';\n\nimport { useInput } from '@nextui-org/input';\nimport { Switch as NextSwitch } from '@nextui-org/switch';\n\nimport { useFormContext } from '../hooks';\nimport { FieldCopyTestIdButton } from '../partials/FieldCopyTestIdButton';\nimport { FieldValidationError } from '../partials/FieldValidationError';\n\nexport interface SwitchProps {\n /** CSS class name */\n className: string;\n /** whether the select should be disabled */\n disabled?: boolean;\n /** component displayed next to the switch. */\n label: React.ReactNode;\n /** name the field is registered under */\n name: string;\n /** HTML data-testid attribute used in e2e tests */\n testId?: string;\n}\n\n/**\n * Switch component based on [NextUI Switch](https://nextui.org/docs/components/switch)\n */\nconst Switch = ({\n className,\n disabled = false,\n label: _label = undefined,\n name,\n testId: _testId = undefined,\n}: SwitchProps) => {\n const { control, getFieldState } = useFormContext();\n const { error, required, testId, invalid } = getFieldState(name, _testId);\n\n const { label, getInputProps, getHelperWrapperProps, getErrorMessageProps } =\n useInput({\n errorMessage: JSON.stringify(error),\n isInvalid: invalid,\n isRequired: required,\n label: _label,\n labelPlacement: 'outside',\n placeholder: ' ',\n });\n\n return (\n <Controller\n name={name}\n control={control}\n disabled={disabled}\n render={({\n field: { disabled: isDisabled, value, ref, onBlur, onChange },\n }) => (\n <>\n <NextSwitch\n aria-describedby={getInputProps()['aria-describedby']}\n required={required}\n isSelected={!!value}\n className={className}\n classNames={{\n label: `text-bold block text-ellipsis text-small ${invalid ? 'text-danger' : ''}`,\n }}\n data-testid={testId}\n isDisabled={isDisabled}\n value={value}\n onChange={onChange}\n onBlur={onBlur}\n name={name}\n ref={ref}\n >\n {label}\n {!!required && !!_label && (\n <span className=\"!text-danger\">{' \\u002A'}</span>\n )}\n <FieldCopyTestIdButton testId={testId} />\n </NextSwitch>\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 </>\n )}\n />\n );\n};\n\nexport default Switch;\n","import Switch from './Switch';\n\nexport type { SwitchProps } from './Switch';\n\nexport { Switch };\n\nexport default Switch;\n"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
useFormContext
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-GBPUYJXE.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-JDXFQPKX.js.map
|
|
@@ -6,7 +6,7 @@ var _chunkKMMS4G7Acjs = require('./chunk-KMMS4G7A.cjs');
|
|
|
6
6
|
var _chunkQTL5FREEcjs = require('./chunk-QTL5FREE.cjs');
|
|
7
7
|
|
|
8
8
|
|
|
9
|
-
var
|
|
9
|
+
var _chunkCGRZXDVBcjs = require('./chunk-CGRZXDVB.cjs');
|
|
10
10
|
|
|
11
11
|
// src/Input/Input.tsx
|
|
12
12
|
var _reacthookform = require('react-hook-form');
|
|
@@ -24,7 +24,7 @@ var Input = ({
|
|
|
24
24
|
testId: _testId = void 0,
|
|
25
25
|
type = void 0
|
|
26
26
|
}) => {
|
|
27
|
-
const { control, getFieldState } =
|
|
27
|
+
const { control, getFieldState } = _chunkCGRZXDVBcjs.useFormContext.call(void 0, );
|
|
28
28
|
const { error, invalid, required, testId } = getFieldState(name, _testId);
|
|
29
29
|
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
30
30
|
_reacthookform.Controller,
|
|
@@ -78,4 +78,4 @@ var Input_default2 = Input_default;
|
|
|
78
78
|
|
|
79
79
|
|
|
80
80
|
exports.Input_default = Input_default; exports.Input_default2 = Input_default2;
|
|
81
|
-
//# sourceMappingURL=chunk-
|
|
81
|
+
//# sourceMappingURL=chunk-KQIHNO3S.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/home/runner/work/uniform/uniform/packages/uniform/dist/chunk-
|
|
1
|
+
{"version":3,"sources":["/home/runner/work/uniform/uniform/packages/uniform/dist/chunk-KQIHNO3S.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;AACA;ACRA,gDAA2B;AAE3B,0CAAmC;AAEnC,oDAAmB;AA4DgB,+CAAA;AA9BnC,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,QAAA,EAAU,KAAA,CAAA;AAAA,EAClB,KAAA,EAAO,KAAA;AACT,CAAA,EAAA,GAAkB;AAChB,EAAA,MAAM,EAAE,OAAA,EAAS,cAAc,EAAA,EAAI,8CAAA,CAAe;AAClD,EAAA,MAAM,EAAE,KAAA,EAAO,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eAAAA,EAAQ,aAAA;AFqEf;AACA;AACE;AACA;AACF,+EAAC","file":"/home/runner/work/uniform/uniform/packages/uniform/dist/chunk-KQIHNO3S.cjs","sourcesContent":[null,"import type { ReactNode } from 'react';\n\nimport { Controller } from 'react-hook-form';\n\nimport { Input as NextInput } from '@nextui-org/input';\n\nimport { cn } from '@fuf-stack/pixel-utils';\n\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, getFieldState } = useFormContext();\n const { error, invalid, required, testId } = getFieldState(name, _testId);\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-primary',\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 <>\n {label}\n <FieldCopyTestIdButton testId={testId} />\n </>\n }\n labelPlacement=\"outside\"\n name={name}\n onBlur={onBlur}\n onChange={onChange}\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"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _chunkCGRZXDVBcjs = require('./chunk-CGRZXDVB.cjs');
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
var _chunkBBB4FEY6cjs = require('./chunk-BBB4FEY6.cjs');
|
|
@@ -20,7 +20,7 @@ var SubmitButton = ({
|
|
|
20
20
|
}) => {
|
|
21
21
|
const {
|
|
22
22
|
formState: { isSubmitting, isValidating }
|
|
23
|
-
} =
|
|
23
|
+
} = _chunkCGRZXDVBcjs.useFormContext.call(void 0, );
|
|
24
24
|
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
25
25
|
_pixels.Button,
|
|
26
26
|
{
|
|
@@ -45,4 +45,4 @@ var SubmitButton_default2 = SubmitButton_default;
|
|
|
45
45
|
|
|
46
46
|
|
|
47
47
|
exports.SubmitButton_default = SubmitButton_default; exports.SubmitButton_default2 = SubmitButton_default2;
|
|
48
|
-
//# sourceMappingURL=chunk-
|
|
48
|
+
//# sourceMappingURL=chunk-KS7TCYGK.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/home/runner/work/uniform/uniform/packages/uniform/dist/chunk-
|
|
1
|
+
{"version":3,"sources":["/home/runner/work/uniform/uniform/packages/uniform/dist/chunk-KS7TCYGK.cjs","../src/SubmitButton/SubmitButton.tsx","../src/SubmitButton/index.ts"],"names":["SubmitButton_default"],"mappings":"AAAA;AACE;AACF,wDAA6B;AAC7B;AACE;AACF,wDAA6B;AAC7B;AACA;ACJA,oDAAmB;AACnB,2CAAuB;AAsCnB,+CAAA;AAbJ,IAAM,aAAA,EAAe,CAAC;AAAA,EACpB,SAAA,EAAW,QAAA;AAAA,EACX,UAAA,EAAY,KAAA,CAAA;AAAA,EACZ,MAAA,EAAQ,SAAA;AAAA,EACR,QAAA,EAAU,KAAA;AAAA,EACV,QAAA,EAAU,KAAA,CAAA;AAAA,EACV,KAAA,EAAO,IAAA;AAAA,EACP,OAAA,EAAS;AACX,CAAA,EAAA,GAAyB;AACvB,EAAA,MAAM;AAAA,IACJ,SAAA,EAAW,EAAE,YAAA,EAAc,aAAa;AAAA,EAC1C,EAAA,EAAI,8CAAA,CAAe;AACnB,EAAA,uBACE,6BAAA;AAAA,IAAC,cAAA;AAAA,IAAA;AAAA,MACC,SAAA,EAAW,4BAAA,SAAY,CAAA;AAAA,MACvB,KAAA;AAAA,MACA,MAAA,EAAQ,uCAAA,MAAc,CAAA;AAAA,MACtB,QAAA,EAAU,aAAA,GAAgB,YAAA;AAAA,MAC1B,OAAA;AAAA,MACA,OAAA;AAAA,MACA,IAAA;AAAA,MACA,IAAA,EAAK,QAAA;AAAA,MAEJ;AAAA,IAAA;AAAA,EACH,CAAA;AAEJ,CAAA;AAEA,IAAO,qBAAA,EAAQ,YAAA;ADlBf;AACA;AElCA,IAAOA,sBAAAA,EAAQ,oBAAA;AFoCf;AACA;AACE;AACA;AACF,2GAAC","file":"/home/runner/work/uniform/uniform/packages/uniform/dist/chunk-KS7TCYGK.cjs","sourcesContent":[null,"import type { ButtonProps } from '@fuf-stack/pixels';\nimport type { ReactNode } from 'react';\n\nimport { cn } from '@fuf-stack/pixel-utils';\nimport { Button } from '@fuf-stack/pixels';\n\nimport { slugify } from '../helpers';\nimport { useFormContext } from '../hooks';\n\nexport interface SubmitButtonProps {\n /** child components */\n children?: ReactNode;\n /** CSS class name */\n className?: string;\n /** color of the button */\n color?: ButtonProps['color'];\n /** If set loading animation is shown */\n loading?: boolean;\n /** function called when the button is pressed. */\n onClick?: ButtonProps['onClick'];\n /** size of the button */\n size?: ButtonProps['size'];\n /** HTML data-testid attribute used in e2e tests */\n testId?: string;\n}\n\n/**\n * From SubmitButton\n */\nconst SubmitButton = ({\n children = 'Submit',\n className = undefined,\n color = 'success',\n loading = false,\n onClick = undefined,\n size = 'md',\n testId = 'form_submit_button',\n}: SubmitButtonProps) => {\n const {\n formState: { isSubmitting, isValidating },\n } = useFormContext();\n return (\n <Button\n className={cn(className)}\n color={color}\n testId={slugify(testId)}\n disabled={isSubmitting || isValidating}\n loading={loading}\n onClick={onClick}\n size={size}\n type=\"submit\"\n >\n {children}\n </Button>\n );\n};\n\nexport default SubmitButton;\n","import SubmitButton from './SubmitButton';\n\nexport type { SubmitButtonProps } from './SubmitButton';\n\nexport { SubmitButton };\n\nexport default SubmitButton;\n"]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
FormContext_default,
|
|
3
3
|
useFormContext
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-GBPUYJXE.js";
|
|
5
5
|
import {
|
|
6
6
|
slugify
|
|
7
7
|
} from "./chunk-V46BHM2U.js";
|
|
@@ -145,4 +145,4 @@ export {
|
|
|
145
145
|
Form_default,
|
|
146
146
|
Form_default2
|
|
147
147
|
};
|
|
148
|
-
//# sourceMappingURL=chunk-
|
|
148
|
+
//# sourceMappingURL=chunk-LVUHS37D.js.map
|
|
@@ -6,7 +6,7 @@ var _chunkKMMS4G7Acjs = require('./chunk-KMMS4G7A.cjs');
|
|
|
6
6
|
var _chunkQTL5FREEcjs = require('./chunk-QTL5FREE.cjs');
|
|
7
7
|
|
|
8
8
|
|
|
9
|
-
var
|
|
9
|
+
var _chunkCGRZXDVBcjs = require('./chunk-CGRZXDVB.cjs');
|
|
10
10
|
|
|
11
11
|
|
|
12
12
|
var _chunkBBB4FEY6cjs = require('./chunk-BBB4FEY6.cjs');
|
|
@@ -26,7 +26,7 @@ var CheckboxGroup = ({
|
|
|
26
26
|
name,
|
|
27
27
|
testId: _testId = void 0
|
|
28
28
|
}) => {
|
|
29
|
-
const { getFieldState, control } =
|
|
29
|
+
const { getFieldState, control } = _chunkCGRZXDVBcjs.useFormContext.call(void 0, );
|
|
30
30
|
const { error, invalid, required, testId } = getFieldState(name, _testId);
|
|
31
31
|
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
32
32
|
_reacthookform.Controller,
|
|
@@ -93,4 +93,4 @@ var CheckboxGroup_default2 = CheckboxGroup_default;
|
|
|
93
93
|
|
|
94
94
|
|
|
95
95
|
exports.CheckboxGroup_default = CheckboxGroup_default; exports.CheckboxGroup_default2 = CheckboxGroup_default2;
|
|
96
|
-
//# sourceMappingURL=chunk-
|
|
96
|
+
//# sourceMappingURL=chunk-NAFOOSGX.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/home/runner/work/uniform/uniform/packages/uniform/dist/chunk-
|
|
1
|
+
{"version":3,"sources":["/home/runner/work/uniform/uniform/packages/uniform/dist/chunk-NAFOOSGX.cjs","../src/CheckboxGroup/CheckboxGroup.tsx","../src/CheckboxGroup/index.ts"],"names":[],"mappings":"AAAA;AACE;AACF,wDAA6B;AAC7B;AACE;AACF,wDAA6B;AAC7B;AACE;AACF,wDAA6B;AAC7B;AACE;AACF,wDAA6B;AAC7B;AACA;ACbA,gDAA2B;AAE3B;AACE;AACA;AAAiB,gDACZ;AAyD4B,+CAAA;AArBnC,IAAM,cAAA,EAAgB,CAAC;AAAA,EACrB,UAAA,EAAY,KAAA,CAAA;AAAA,EACZ,MAAA,EAAQ,KAAA,CAAA;AAAA,EACR,OAAA;AAAA,EACA,SAAA,EAAW,KAAA;AAAA,EACX,IAAA;AAAA,EACA,MAAA,EAAQ,QAAA,EAAU,KAAA;AACpB,CAAA,EAAA,GAA0B;AACxB,EAAA,MAAM,EAAE,aAAA,EAAe,QAAQ,EAAA,EAAI,8CAAA,CAAe;AAClD,EAAA,MAAM,EAAE,KAAA,EAAO,OAAA,EAAS,QAAA,EAAU,OAAO,EAAA,EAAI,aAAA,CAAc,IAAA,EAAM,OAAO,CAAA;AAExE,E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react-hook-form';\n\nimport {\n Checkbox,\n CheckboxGroup as NextCheckboxGroup,\n} from '@nextui-org/checkbox';\n\nimport { slugify } from '../helpers';\nimport { useFormContext } from '../hooks';\nimport { FieldCopyTestIdButton } from '../partials/FieldCopyTestIdButton';\nimport { FieldValidationError } from '../partials/FieldValidationError';\n\nexport type CheckboxGroupOption = {\n /** option label */\n label?: React.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 CheckboxGroupProps {\n /** CSS class name. ClassName: string | { buttons?: string | { base?: string; active?: string }; base?: string;} */\n className?: string;\n /** label displayed above the Checkboxes */\n label?: React.ReactNode;\n /** Name the Field is registered on the form. */\n name: string;\n /** Checkboxes that should be displayed. */\n options: CheckboxGroupOption[];\n /** sets all buttons disabled */\n disabled?: boolean;\n /** id for internal testing. */\n testId?: string;\n}\n\n/**\n * CheckboxGroup component based on [NextUI CheckboxGroup](https://nextui.org/docs/components/checkbox-group)\n */\nconst CheckboxGroup = ({\n className = undefined,\n label = undefined,\n options,\n disabled = false,\n name,\n testId: _testId = undefined,\n}: CheckboxGroupProps) => {\n const { getFieldState, control } = useFormContext();\n const { error, invalid, required, testId } = getFieldState(name, _testId);\n\n return (\n <Controller\n control={control}\n name={name}\n disabled={disabled}\n render={({ field: { onChange, value, ref, onBlur } }) => {\n return (\n <NextCheckboxGroup\n className={className}\n data-testid={testId}\n errorMessage={error && <FieldValidationError error={error} />}\n isDisabled={disabled}\n isInvalid={invalid}\n isRequired={required}\n label={\n label && (\n // eslint-disable-next-line jsx-a11y/label-has-associated-control\n <label\n className={`text-bold text-ellipsis text-small ${invalid ? 'text-danger' : 'text-foreground-500'}`}\n >\n {label}\n <FieldCopyTestIdButton testId={testId} />\n </label>\n )\n }\n // eslint-disable-next-line react/jsx-props-no-spreading\n {...(options.length === 1\n ? {\n value: [value].filter((v) => v !== undefined),\n onChange: (newValue) => onChange(newValue && newValue[0]),\n }\n : {\n onChange,\n value,\n })}\n onBlur={onBlur}\n ref={ref}\n >\n {options?.map((option) => {\n return (\n <Checkbox\n key={`index_${option.value}`}\n isDisabled={disabled || option.disabled}\n value={option?.value}\n data-testid={slugify(\n `${testId}_option_${option?.testId || option?.value}`,\n )}\n >\n {option?.label}\n </Checkbox>\n );\n })}\n </NextCheckboxGroup>\n );\n }}\n />\n );\n};\n\nexport default CheckboxGroup;\n","import CheckboxGroup from './CheckboxGroup';\n\nexport type { CheckboxGroupProps, CheckboxGroupOption } from './CheckboxGroup';\n\nexport { CheckboxGroup };\n\nexport default CheckboxGroup;\n"]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
|
|
2
2
|
|
|
3
3
|
|
|
4
|
-
var
|
|
4
|
+
var _chunkCGRZXDVBcjs = require('./chunk-CGRZXDVB.cjs');
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
var _chunkBBB4FEY6cjs = require('./chunk-BBB4FEY6.cjs');
|
|
@@ -23,7 +23,7 @@ var FormDebugViewer = ({ className = void 0 }) => {
|
|
|
23
23
|
watch,
|
|
24
24
|
formState: { dirtyFields, isValid, isSubmitting },
|
|
25
25
|
validation
|
|
26
|
-
} =
|
|
26
|
+
} = _chunkCGRZXDVBcjs.useFormContext.call(void 0, );
|
|
27
27
|
const [debug, setDebug] = _pixels.useLocalStorage.call(void 0, LOCALSTORAGE_DEBUG_KEY, false);
|
|
28
28
|
const [copyTestId, setCopyTestId] = _pixels.useLocalStorage.call(void 0,
|
|
29
29
|
LOCALSTORAGE_COPY_TEST_ID_KEY,
|
|
@@ -114,7 +114,7 @@ var Form = ({
|
|
|
114
114
|
validationTrigger = "all"
|
|
115
115
|
}) => {
|
|
116
116
|
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
117
|
-
|
|
117
|
+
_chunkCGRZXDVBcjs.FormContext_default,
|
|
118
118
|
{
|
|
119
119
|
initialValues,
|
|
120
120
|
onSubmit,
|
|
@@ -145,4 +145,4 @@ var Form_default2 = Form_default;
|
|
|
145
145
|
|
|
146
146
|
|
|
147
147
|
exports.Form_default = Form_default; exports.Form_default2 = Form_default2;
|
|
148
|
-
//# sourceMappingURL=chunk-
|
|
148
|
+
//# sourceMappingURL=chunk-SXJADULP.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/home/runner/work/uniform/uniform/packages/uniform/dist/chunk-
|
|
1
|
+
{"version":3,"sources":["/home/runner/work/uniform/uniform/packages/uniform/dist/chunk-SXJADULP.cjs","../src/Form/Form.tsx","../src/Form/subcomponents/FormDebugViewer.tsx","../src/Form/index.ts"],"names":["jsx","jsxs","cn","Form_default"],"mappings":"AAAA;AACE;AACA;AACF,wDAA6B;AAC7B;AACE;AACF,wDAA6B;AAC7B;AACA;ACJA,oDAAmB;ADMnB;AACA;AETA,8BAAoC;AACpC,oCAAwB;AACxB,sCAAkC;AAElC;AACA,2CAAoD;AAqDtC,+CAAA;AA5Cd,IAAM,uBAAA,EAAyB,4BAAA;AAC/B,IAAM,8BAAA,EAAgC,yCAAA;AAGtC,IAAM,gBAAA,EAAkB,CAAC,EAAE,UAAA,EAAY,KAAA,EAAU,CAAA,EAAA,GAA4B;AAC3E,EAAA,MAAM;AAAA,IACJ,KAAA;AAAA,IACA,SAAA,EAAW,EAAE,WAAA,EAAa,OAAA,EAAS,aAAa,CAAA;AAAA,IAChD;AAAA,EACF,EAAA,EAAI,8CAAA,CAAe;AAEnB,EAAA,MAAM,CAAC,KAAA,EAAO,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CAAA;AAAA,EAChB,KAAA,EAAO,KAAA,CAAA;AAAA,EACP,QAAA;AAAA,EACA,OAAA,EAAS,KAAA,CAAA;AAAA,EACT,WAAA,EAAa,KAAA,CAAA;AAAA,EACb,kBAAA,EAAoB;AACtB,CAAA,EAAA,GAAiB;AACf,EAAA,uBACEA,6BAAAA;AAAA,IAAC,qCAAA;AAAA,IAAA;AAAA,MACC,aAAA;AAAA,MACA,QAAA;AAAA,MACA,UAAA;AAAA,MACA,iBAAA;AAAA,MAEC,QAAA,EAAA,CAAC,EAAE,aAAa,CAAA,EAAA,mBACfC,8BAAAA,KAAC,EAAA,EAAI,SAAA,EAAU,4CAAA,EACb,QAAA,EAAA;AAAA,wBAAAD,6BAAAA;AAAA,UAAC,MAAA;AAAA,UAAA;AAAA,YACC,SAAA,EAAWE,4BAAAA,WAAG,EAAa,SAAS,CAAA;AAAA,YACpC,aAAA,EAAa,uCAAA,OAAQ,GAAU,KAAA,GAAQ,EAAE,CAAA;AAAA,YACzC,IAAA;AAAA,YACA,QAAA,EAAU,YAAA;AAAA,YAET;AAAA,UAAA;AAAA,QACH,CAAA;AAAA,wBACAF,6BAAAA,uBAAC,EAAA,EAAgB,SAAA,EAAU,mBAAA,CAAmB;AAAA,MAAA,EAAA,CAChD;AAAA,IAAA;AAAA,EAEJ,CAAA;AAEJ,CAAA;AAEA,IAAO,aAAA,EAAQ,IAAA;ADyEf;AACA;AGtIA,IAAOG,cAAAA,EAAQ,YAAA;AHwIf;AACA;AACE;AACA;AACF,2EAAC","file":"/home/runner/work/uniform/uniform/packages/uniform/dist/chunk-SXJADULP.cjs","sourcesContent":[null,"import type { VetoInstance } from '@fuf-stack/veto';\nimport type { ReactNode } from 'react';\nimport type { FieldValues, SubmitHandler } from 'react-hook-form';\n\nimport { cn } from '@fuf-stack/pixel-utils';\n\nimport { slugify } from '../helpers';\nimport FormProvider from './subcomponents/FormContext';\nimport FormDebugViewer from './subcomponents/FormDebugViewer';\n\nexport interface FormProps {\n /** form children */\n children: ReactNode | ReactNode[];\n /** CSS class name */\n className?: string | string[];\n /** initial form values */\n initialValues?: FieldValues;\n /** name of the form */\n name?: string;\n /** form submit handler */\n onSubmit: SubmitHandler<FieldValues>;\n /** HTML data-testid attribute used in e2e tests */\n testId?: string;\n /** veto validation schema */\n validation?: VetoInstance;\n /** when the validation should be triggered */\n validationTrigger?: 'onChange' | 'onBlur' | 'onSubmit' | 'onTouched' | 'all';\n}\n\n/**\n * Form component that has to wrap every uniform\n */\nconst Form = ({\n children,\n className = undefined,\n initialValues = undefined,\n name = undefined,\n onSubmit,\n testId = undefined,\n validation = undefined,\n validationTrigger = 'all',\n}: FormProps) => {\n return (\n <FormProvider\n initialValues={initialValues}\n onSubmit={onSubmit}\n validation={validation}\n validationTrigger={validationTrigger}\n >\n {({ handleSubmit }) => (\n <div className=\"flex w-full flex-row justify-between gap-6\">\n <form\n className={cn('flex-grow', className)}\n data-testid={slugify(testId || name || '')}\n name={name}\n onSubmit={handleSubmit}\n >\n {children}\n </form>\n <FormDebugViewer className=\"w-96 flex-shrink\" />\n </div>\n )}\n </FormProvider>\n );\n};\n\nexport default Form;\n","import type { VetoError } from '@fuf-stack/veto';\n\nimport { useEffect, useState } from 'react';\nimport { FaTimes } from 'react-icons/fa';\nimport { FaBug, FaBullseye } from 'react-icons/fa6';\n\nimport { cn } from '@fuf-stack/pixel-utils';\nimport { Button, Card, Json, useLocalStorage } from '@fuf-stack/pixels';\n\nimport { useFormContext } from '../../hooks';\n\ninterface FormDebugViewerProps {\n /** CSS class name */\n className?: string;\n}\n\nconst LOCALSTORAGE_DEBUG_KEY = 'uniform:form-debug-enabled';\nconst LOCALSTORAGE_COPY_TEST_ID_KEY = 'uniform:form-debug-copy-test-id-enabled';\n\n/** Renders a form debug panel with information about the current form state */\nconst FormDebugViewer = ({ className = undefined }: FormDebugViewerProps) => {\n const {\n watch,\n formState: { dirtyFields, isValid, isSubmitting },\n validation,\n } = useFormContext();\n\n const [debug, setDebug] = useLocalStorage(LOCALSTORAGE_DEBUG_KEY, false);\n const [copyTestId, setCopyTestId] = useLocalStorage(\n LOCALSTORAGE_COPY_TEST_ID_KEY,\n false,\n );\n\n const [validationErrors, setValidationErrors] = useState<\n VetoError['errors'] | null\n >(null);\n\n const formValues = watch();\n\n useEffect(\n () => {\n const updateValidationErrors = async () => {\n if (validation) {\n const validateResult = await validation?.validateAsync(formValues);\n setValidationErrors(validateResult?.errors);\n }\n };\n updateValidationErrors();\n },\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [JSON.stringify(formValues)],\n );\n\n if (!debug) {\n return (\n <Button\n ariaLabel=\"Enable form debug mode\"\n onClick={() => setDebug(!debug)}\n className=\"absolute bottom-2.5 right-2.5 w-5 text-default-400\"\n variant=\"light\"\n icon={<FaBug />}\n />\n );\n }\n\n return (\n <Card\n className={cn(className)}\n header={\n <div className=\"flex w-full flex-row justify-between\">\n <span className=\"text-lg\">Debug Mode</span>\n <Button\n icon={<FaTimes className=\"text-danger\" />}\n onClick={() => setDebug(false)}\n size=\"sm\"\n variant=\"flat\"\n />\n </div>\n }\n >\n <Button\n variant={copyTestId ? 'solid' : 'light'}\n icon={<FaBullseye />}\n className=\"mb-4 ml-auto mr-auto\"\n onClick={() => setCopyTestId(!copyTestId)}\n >\n {copyTestId ? 'Hide CopyButton' : 'Show CopyButton'}\n </Button>\n <Json\n value={{\n values: formValues,\n errors: validationErrors,\n dirtyFields,\n isValid,\n isSubmitting,\n }}\n />\n </Card>\n );\n};\nexport default FormDebugViewer;\n","import Form from './Form';\n\nexport type { FormProps } from './Form';\n\nexport { Form };\n\nexport default Form;\n"]}
|
|
@@ -6,7 +6,7 @@ var _chunkKMMS4G7Acjs = require('./chunk-KMMS4G7A.cjs');
|
|
|
6
6
|
var _chunkQTL5FREEcjs = require('./chunk-QTL5FREE.cjs');
|
|
7
7
|
|
|
8
8
|
|
|
9
|
-
var
|
|
9
|
+
var _chunkCGRZXDVBcjs = require('./chunk-CGRZXDVB.cjs');
|
|
10
10
|
|
|
11
11
|
|
|
12
12
|
var _chunkBBB4FEY6cjs = require('./chunk-BBB4FEY6.cjs');
|
|
@@ -103,7 +103,7 @@ var RadioGroup = ({
|
|
|
103
103
|
testId: _testId = void 0,
|
|
104
104
|
variant = "default"
|
|
105
105
|
}) => {
|
|
106
|
-
const { control, getFieldState, getValues } =
|
|
106
|
+
const { control, getFieldState, getValues } = _chunkCGRZXDVBcjs.useFormContext.call(void 0, );
|
|
107
107
|
const { error, invalid, required, testId } = getFieldState(name, _testId);
|
|
108
108
|
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
109
109
|
_reacthookform.Controller,
|
|
@@ -202,4 +202,4 @@ var RadioGroup_default2 = RadioGroup_default;
|
|
|
202
202
|
|
|
203
203
|
|
|
204
204
|
exports.RadioGroup_default = RadioGroup_default; exports.RadioGroup_default2 = RadioGroup_default2;
|
|
205
|
-
//# sourceMappingURL=chunk-
|
|
205
|
+
//# sourceMappingURL=chunk-VPL5TJB5.cjs.map
|