@fuf-stack/uniform 1.5.1 → 1.5.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/Checkboxes/index.cjs +5 -5
- package/dist/Checkboxes/index.js +4 -4
- package/dist/FieldArray/index.cjs +5 -5
- package/dist/FieldArray/index.js +4 -4
- package/dist/Form/index.cjs +5 -5
- package/dist/Form/index.js +4 -4
- package/dist/Input/index.cjs +5 -5
- package/dist/Input/index.js +4 -4
- package/dist/RadioBoxes/index.cjs +5 -5
- package/dist/RadioBoxes/index.js +4 -4
- package/dist/RadioTabs/index.cjs +5 -5
- package/dist/RadioTabs/index.js +4 -4
- package/dist/Radios/index.cjs +5 -5
- package/dist/Radios/index.js +4 -4
- package/dist/Select/index.cjs +5 -5
- package/dist/Select/index.js +4 -4
- package/dist/SubmitButton/index.cjs +5 -5
- package/dist/SubmitButton/index.js +4 -4
- package/dist/Switch/index.cjs +5 -5
- package/dist/Switch/index.js +4 -4
- package/dist/TextArea/index.cjs +5 -5
- package/dist/TextArea/index.js +4 -4
- package/dist/{chunk-RW35BB4P.js → chunk-2A74CSGX.js} +2 -2
- package/dist/{chunk-7NWHDCME.cjs → chunk-3FSNNDYZ.cjs} +14 -14
- package/dist/{chunk-7NWHDCME.cjs.map → chunk-3FSNNDYZ.cjs.map} +1 -1
- package/dist/{chunk-HSKFVCTS.js → chunk-3MXAIQKI.js} +3 -3
- package/dist/{chunk-COLAXULB.js → chunk-4DGOOLSO.js} +6 -6
- package/dist/{chunk-COLAXULB.js.map → chunk-4DGOOLSO.js.map} +1 -1
- package/dist/{chunk-TVMCTUQ4.js → chunk-4EZWAVRZ.js} +3 -3
- package/dist/{chunk-TVMCTUQ4.js.map → chunk-4EZWAVRZ.js.map} +1 -1
- package/dist/{chunk-P6HJOG7D.cjs → chunk-4WYC2RBE.cjs} +7 -3
- package/dist/chunk-4WYC2RBE.cjs.map +1 -0
- package/dist/{chunk-Q2BOMFJ5.js → chunk-7KLFK2IT.js} +7 -3
- package/dist/{chunk-Q2BOMFJ5.js.map → chunk-7KLFK2IT.js.map} +1 -1
- package/dist/{chunk-3YDAYNNB.cjs → chunk-BOESKBZN.cjs} +81 -59
- package/dist/chunk-BOESKBZN.cjs.map +1 -0
- package/dist/{chunk-FLK6OPFY.cjs → chunk-BZ5OMN4Y.cjs} +3 -3
- package/dist/{chunk-FLK6OPFY.cjs.map → chunk-BZ5OMN4Y.cjs.map} +1 -1
- package/dist/{chunk-74NPRJVH.js → chunk-BZBA2YGQ.js} +4 -4
- package/dist/{chunk-74NPRJVH.js.map → chunk-BZBA2YGQ.js.map} +1 -1
- package/dist/{chunk-SLTUNYTD.js → chunk-CHG25NCC.js} +4 -4
- package/dist/{chunk-SLTUNYTD.js.map → chunk-CHG25NCC.js.map} +1 -1
- package/dist/{chunk-4GBNXNCZ.js → chunk-CROGVLLB.js} +76 -54
- package/dist/chunk-CROGVLLB.js.map +1 -0
- package/dist/{chunk-RTFM4VRY.cjs → chunk-CUXVVIWS.cjs} +5 -5
- package/dist/{chunk-RTFM4VRY.cjs.map → chunk-CUXVVIWS.cjs.map} +1 -1
- package/dist/{chunk-EAJFV3AD.cjs → chunk-I6CQH42B.cjs} +5 -5
- package/dist/{chunk-EAJFV3AD.cjs.map → chunk-I6CQH42B.cjs.map} +1 -1
- package/dist/{chunk-KBUECB4B.cjs → chunk-JJDPGGYL.cjs} +3 -3
- package/dist/{chunk-KBUECB4B.cjs.map → chunk-JJDPGGYL.cjs.map} +1 -1
- package/dist/{chunk-DHO4HSO7.cjs → chunk-KE3ZO2IJ.cjs} +5 -5
- package/dist/{chunk-DHO4HSO7.cjs.map → chunk-KE3ZO2IJ.cjs.map} +1 -1
- package/dist/{chunk-ZQ64MG7T.js → chunk-L53NZ7S5.js} +4 -4
- package/dist/{chunk-ZQ64MG7T.js.map → chunk-L53NZ7S5.js.map} +1 -1
- package/dist/{chunk-65BN4MRG.cjs → chunk-LZPH7LW5.cjs} +7 -7
- package/dist/{chunk-65BN4MRG.cjs.map → chunk-LZPH7LW5.cjs.map} +1 -1
- package/dist/{chunk-6IU7IYYB.js → chunk-MODD3TFE.js} +2 -2
- package/dist/{chunk-J5FFM7WG.cjs → chunk-O3DDOJTB.cjs} +1 -1
- package/dist/{chunk-J5FFM7WG.cjs.map → chunk-O3DDOJTB.cjs.map} +1 -1
- package/dist/{chunk-4MMOSRT3.cjs → chunk-RNBJT4Y7.cjs} +7 -7
- package/dist/{chunk-4MMOSRT3.cjs.map → chunk-RNBJT4Y7.cjs.map} +1 -1
- package/dist/{chunk-EO4A7QGM.cjs → chunk-SU5WXAC7.cjs} +6 -6
- package/dist/{chunk-EO4A7QGM.cjs.map → chunk-SU5WXAC7.cjs.map} +1 -1
- package/dist/{chunk-JLJB4A4K.js → chunk-SUO4QK32.js} +3 -3
- package/dist/{chunk-TFMVYQGN.cjs → chunk-TED4I5EF.cjs} +5 -5
- package/dist/{chunk-TFMVYQGN.cjs.map → chunk-TED4I5EF.cjs.map} +1 -1
- package/dist/{chunk-62BVHALF.js → chunk-TTKSVOSS.js} +13 -13
- package/dist/{chunk-62BVHALF.js.map → chunk-TTKSVOSS.js.map} +1 -1
- package/dist/{chunk-2QLCCB3L.js → chunk-VRFZFKDM.js} +4 -4
- package/dist/{chunk-2QLCCB3L.js.map → chunk-VRFZFKDM.js.map} +1 -1
- package/dist/{chunk-GVMEDVT5.cjs → chunk-XZLIDJKA.cjs} +4 -4
- package/dist/{chunk-GVMEDVT5.cjs.map → chunk-XZLIDJKA.cjs.map} +1 -1
- package/dist/{chunk-CFH4VPJ4.js → chunk-Y6NHIZ2M.js} +1 -1
- package/dist/{chunk-CFH4VPJ4.js.map → chunk-Y6NHIZ2M.js.map} +1 -1
- package/dist/hooks/index.cjs +4 -4
- package/dist/hooks/index.js +3 -3
- package/dist/hooks/useInputValueDebounce/index.cjs +3 -3
- package/dist/hooks/useInputValueDebounce/index.js +2 -2
- package/dist/hooks/useInputValueTransform/index.cjs +2 -2
- package/dist/hooks/useInputValueTransform/index.js +1 -1
- package/dist/index.cjs +15 -15
- package/dist/index.js +14 -14
- package/package.json +4 -4
- package/dist/chunk-3YDAYNNB.cjs.map +0 -1
- package/dist/chunk-4GBNXNCZ.js.map +0 -1
- package/dist/chunk-P6HJOG7D.cjs.map +0 -1
- /package/dist/{chunk-RW35BB4P.js.map → chunk-2A74CSGX.js.map} +0 -0
- /package/dist/{chunk-HSKFVCTS.js.map → chunk-3MXAIQKI.js.map} +0 -0
- /package/dist/{chunk-6IU7IYYB.js.map → chunk-MODD3TFE.js.map} +0 -0
- /package/dist/{chunk-JLJB4A4K.js.map → chunk-SUO4QK32.js.map} +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/home/runner/work/pixels/pixels/packages/uniform/dist/chunk-7NWHDCME.cjs","../src/Select/Select.tsx","../src/Select/index.ts"],"names":["_a","Select_default"],"mappings":"AAAA;AACE;AACF,wDAA6B;AAC7B;AACE;AACA;AACA;AACF,wDAA6B;AAC7B;AACA;ACNA,8BAAyB;AACzB,qGAAwC;AAExC,wCAA0B;AAE1B,oDAAsD;AAgG7C,+CAAA;AA5FF,IAAM,eAAA,EAAiB,4BAAA;AAAG,EAC/B,KAAA,EAAO;AAAA,IACL,IAAA,EAAM,sBAAA;AAAA,IACN,cAAA,EACE,wGAAA;AAAA,IACF,OAAA,EACE,qOAAA;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,gBAAA;AAAA,IACpB,KAAA,EAAO,aAAA;AAAA;AAAA;AAAA,IAGP,KAAA,EACE,yPAAA;AAAA,IACF,gBAAA,EAAkB,EAAA;AAAA,IAClB,cAAA,EAA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E,kBAAA;AACA,kBAAA;AACD,gBAAA;AACH,cAAA;AACA,cAAA;AACE,gBAAA;AACF,cAAA;AACA,cAAA;AACE,gBAAA;AACF,cAAA;AACA,cAAA;AACE,gBAAA;AACF,cAAA;AACF,YAAA;AACA,YAAA;AACE,cAAA;AACA,cAAA;AACA,cAAA;AACA,cAAA;AACF,YAAA;AACA,YAAA;AACE,cAAA;AACA,cAAA;AACF,YAAA;AACA,YAAA;AACM,cAAA;AACF,gBAAA;AACG,kBAAA;AACC,oBAAA;AACF,kBAAA;AACF,gBAAA;AACF,cAAA;AACE,gBAAA;AACF,cAAA;AACF,YAAA;AACA,YAAA;AACE,cAAA;AACF,YAAA;AAEA,YAAA;AACE,cAAA;AACD,YAAA;AAAA,UAAA;AACH,QAAA;AAEE,QAAA;AAIE,MAAA;AAAA,IAAA;AACN,EAAA;AAEJ;AAEO;AD5EW;AACA;AE1QXC;AF4QW;AACA;AACA;AACA;AACA","file":"/home/runner/work/pixels/pixels/packages/uniform/dist/chunk-7NWHDCME.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 '@heroui/select';\n\nimport { cn, slugify, tv, variantsToClassNames } from '@fuf-stack/pixel-utils';\n\nimport { useUniformField } from '../hooks';\n\nexport const selectVariants = tv({\n slots: {\n base: 'group leading-normal',\n clearIndicator:\n 'text-foreground-500 hover:bg-default-200 hover:text-foreground-800 rounded-md p-1 hover:cursor-pointer',\n control:\n 'border-default-200 bg-content1 transition-background hover:border-default-400 group-data-[invalid=true]:border-danger group-data-[invalid=true]:hover:border-danger rounded-lg border-2 duration-150! motion-reduce:transition-none',\n control_focused: 'border-focus',\n crossIcon: '',\n downChevron: '',\n dropdownIndicator:\n 'text-foreground-500 hover:bg-default-200 rounded-md p-1 hover:cursor-pointer hover:text-black',\n group: '',\n groupHeading: 'text-foreground-500 mt-2 mb-1 ml-3 text-sm',\n indicatorsContainer: 'gap-1 p-1',\n indicatorSeparator: 'bg-default-300',\n input: 'py-0.5 pl-1',\n // see HeroUI styles for group-data condition,\n // e.g.: https://github.com/heroui-inc/heroui/blob/main/packages/core/theme/src/components/select.ts\n label:\n 'text-small group-data-[invalid=true]:!text-danger group-data-[required=true]:after:text-danger pointer-events-auto relative bottom-1.5 ml-1 subpixel-antialiased group-data-[required=true]:after:ml-0.5 group-data-[required=true]:after:content-[\"*\"]',\n loadingIndicator: '',\n loadingMessage: 'text-foreground-500 rounded-sm p-2',\n menu: 'border-default-200 bg-content1 mt-2 rounded-xl border 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/heroui-inc/heroui/blob/main/packages/core/theme/src/components/modal.ts (see z-50)\n menuPortal: 'z-50!',\n multiValue: 'bg-default-100 items-center gap-1.5 rounded py-0.5 pr-1 pl-2',\n multiValueContainer: '',\n multiValueLabel: 'py-0.5 leading-6',\n multiValueRemove:\n 'text-default-500 hover:border-default-300 hover:text-default-800 rounded hover:cursor-pointer',\n noOptionsMessage: 'text-foreground-500 rounded-sm p-2',\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: 'text-foreground-500 ml-1 py-0.5 pl-1 text-sm',\n selectContainer: '',\n singleValue: 'ml-1! leading-7!',\n valueContainer: 'gap-1 p-1',\n },\n});\n\ninterface 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/destructuring-assignment\n const testId = `${props.selectProps['data-testid']}`;\n\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/destructuring-assignment\n const testId = `${props.selectProps['data-testid']}_select`;\n return (\n <div data-testid={testId}>\n {}\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/destructuring-assignment\n const testId = `${props.selectProps['data-testid']}_select_option_${slugify(props?.data?.testId ?? props?.data?.value, { replaceDots: true })}`;\n return (\n <div data-testid={testId}>\n {}\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\n const testId = props?.selectProps['data-testid'] as string;\n return (\n <div data-testid={`${testId}_select_dropdown`}>\n {}\n <components.DropdownIndicator {...props} />\n </div>\n );\n};\n\n/** Select component based on [HeroUI Select](https://www.heroui.com//docs/components/select) and [React-Select](https://react-select.com/home) */\nconst Select = ({\n className = undefined,\n clearable = true,\n filterOption = undefined,\n renderOptionLabel = undefined,\n inputValue = undefined,\n loading = false,\n multiSelect = false,\n name,\n onInputChange = undefined,\n options,\n placeholder = undefined,\n ...uniformFieldProps\n}: SelectProps) => {\n const {\n disabled,\n errorMessage,\n field: { onBlur, onChange, ref, value },\n getErrorMessageProps,\n getHelperWrapperProps,\n getLabelProps,\n invalid,\n label,\n required,\n testId,\n } = useUniformField({ name, ...uniformFieldProps });\n\n const [isFocused, setIsFocused] = useState(false);\n\n // classNames from slots\n const variants = selectVariants();\n const classNames = variantsToClassNames(variants, className, 'base');\n\n const { getBaseProps, getTriggerProps, getValueProps } = useSelect({\n children: [],\n classNames,\n errorMessage,\n isDisabled: disabled,\n isInvalid: invalid,\n isLoading: loading,\n isRequired: required,\n label,\n labelPlacement: 'outside',\n });\n\n return (\n <div\n {...getBaseProps()}\n className={cn(classNames.base)}\n // see HeroUI styles for group-data condition (data-invalid),\n // e.g.: https://github.com/heroui-inc/heroui/blob/main/packages/components/select/src/use-select.ts\n data-required={required}\n data-testid={`${testId}_wrapper`}\n >\n {label ? (\n <label\n className={classNames.label}\n data-slot=\"label\"\n htmlFor={`react-select-${name}-input`}\n id={getLabelProps().id}\n >\n {label}\n </label>\n ) : null}\n <ReactSelect\n ref={ref}\n menuShouldBlockScroll\n unstyled\n aria-errormessage=\"\"\n aria-invalid={invalid}\n aria-labelledby={getTriggerProps()['aria-labelledby']?.split(' ')[1]}\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 // 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 name={name}\n onInputChange={onInputChange}\n options={options}\n placeholder={placeholder}\n classNames={{\n control: () => {\n return cn(classNames.control, {\n [classNames.control_focused]: isFocused && !invalid,\n });\n },\n clearIndicator: () => {\n return classNames.clearIndicator;\n },\n dropdownIndicator: () => {\n return classNames.dropdownIndicator;\n },\n groupHeading: () => {\n return classNames.groupHeading;\n },\n indicatorsContainer: () => {\n return classNames.indicatorsContainer;\n },\n indicatorSeparator: () => {\n return classNames.indicatorSeparator;\n },\n loadingIndicator: () => {\n return classNames.loadingIndicator;\n },\n loadingMessage: () => {\n return classNames.loadingMessage;\n },\n input: () => {\n return classNames.input;\n },\n menu: () => {\n return classNames.menu;\n },\n menuList: () => {\n return classNames.menuList;\n },\n menuPortal: () => {\n return classNames.menuPortal;\n },\n multiValue: () => {\n return classNames.multiValue;\n },\n multiValueLabel: () => {\n return cn(\n classNames.multiValueLabel,\n `${getValueProps().className}`,\n );\n },\n multiValueRemove: () => {\n return classNames.multiValueRemove;\n },\n noOptionsMessage: () => {\n return classNames.noOptionsMessage;\n },\n option: ({\n isFocused: optionIsFocused,\n isSelected: optionIsSelected,\n }) => {\n return cn(classNames.option, {\n [classNames.option_focused]: optionIsFocused,\n [classNames.option_selected]: optionIsSelected,\n });\n },\n placeholder: () => {\n return classNames.placeholder;\n },\n singleValue: () => {\n return cn(classNames.singleValue, `${getValueProps().className}`);\n },\n valueContainer: () => {\n return classNames.valueContainer;\n },\n }}\n components={{\n Input: InputComponent,\n Option: OptionComponent,\n DropdownIndicator: DropdownIndicatorComponent,\n Control: ControlComponent,\n }}\n onBlur={(_e) => {\n setIsFocused(false);\n onBlur();\n }}\n onChange={(option) => {\n if (multiSelect) {\n onChange(\n (option as SelectOption[])?.map((_option) => {\n return _option.value;\n }),\n );\n } else {\n onChange((option as SelectOption)?.value);\n }\n }}\n onFocus={(_e) => {\n setIsFocused(true);\n }}\n // set complete option as value by current field value\n value={options.find((option) => {\n return option.value === value;\n })}\n />\n {invalid ? (\n <div {...getHelperWrapperProps()}>\n {}\n <div {...getErrorMessageProps()}>{errorMessage}</div>\n </div>\n ) : null}\n </div>\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/pixels/pixels/packages/uniform/dist/chunk-3FSNNDYZ.cjs","../src/Select/Select.tsx","../src/Select/index.ts"],"names":["_a","Select_default"],"mappings":"AAAA;AACE;AACF,wDAA6B;AAC7B;AACE;AACA;AACA;AACF,wDAA6B;AAC7B;AACA;ACNA,8BAAyB;AACzB,qGAAwC;AAExC,wCAA0B;AAE1B,oDAAsD;AAgG7C,+CAAA;AA5FF,IAAM,eAAA,EAAiB,4BAAA;AAAG,EAC/B,KAAA,EAAO;AAAA,IACL,IAAA,EAAM,sBAAA;AAAA,IACN,cAAA,EACE,wGAAA;AAAA,IACF,OAAA,EACE,qOAAA;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,gBAAA;AAAA,IACpB,KAAA,EAAO,aAAA;AAAA;AAAA;AAAA,IAGP,KAAA,EACE,yPAAA;AAAA,IACF,gBAAA,EAAkB,EAAA;AAAA,IAClB,cAAA,EAAgB,oCAAA;AAAA,IAChB,IAAA,EAAM,qEAAA;AAAA,IACN,QAAA,EAAU,EAAA;AAAA;AAAA;AAAA,IAGV,UAAA,EAAY,OAAA;AAAA,IACZ,UAAA,EAAY,8DAAA;AAAA,IACZ,mBAAA,EAAqB,EAAA;AAAA,IACrB,eAAA,EAAiB,kBAAA;AAAA,IACjB,gBAAA,EACE,+FAAA;AAAA,IACF,gBAAA,EAAkB,oCAAA;AAAA,IAClB,cAAA,EAAgB,sCAAA;AAAA,IAChB,eAAA,EAAiB,gBAAA;AAAA,IACjB,MAAA,EAAQ,wCAAA;AAAA,IACR,WAAA,EAAa,8CAAA;AAAA,IACb,eAAA,EAAiB,EAAA;AAAA,IACjB,WAAA,EAAa,kBAAA;AAAA,IACb,cA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ACA,YAAA;AACA,YAAA;AACA,YAAA;AAIA,YAAA;AACA,YAAA;AACA,YAAA;AACA,YAAA;AACA,YAAA;AACA,YAAA;AACE,cAAA;AACE,gBAAA;AACE,kBAAA;AACD,gBAAA;AACH,cAAA;AACA,cAAA;AACE,gBAAA;AACF,cAAA;AACA,cAAA;AACE,gBAAA;AACF,cAAA;AACA,cAAA;AACE,gBAAA;AACF,cAAA;AACA,cAAA;AACE,gBAAA;AACF,cAAA;AACA,cAAA;AACE,gBAAA;AACF,cAAA;AACA,cAAA;AACE,gBAAA;AACF,cAAA;AACA,cAAA;AACE,gBAAA;AACF,cAAA;AACA,cAAA;AACE,gBAAA;AACF,cAAA;AACA,cAAA;AACE,gBAAA;AACF,cAAA;AACA,cAAA;AACE,gBAAA;AACF,cAAA;AACA,cAAA;AACE,gBAAA;AACF,cAAA;AACA,cAAA;AACE,gBAAA;AACF,cAAA;AACA,cAAA;AACE,gBAAA;AACE,kBAAA;AACA,kBAAA;AACF,gBAAA;AACF,cAAA;AACA,cAAA;AACE,gBAAA;AACF,cAAA;AACA,cAAA;AACE,gBAAA;AACF,cAAA;AACA,cAAA;AACE,gBAAA;AACA,gBAAA;AACF,cAAA;AACE,gBAAA;AACE,kBAAA;AACA,kBAAA;AACD,gBAAA;AACH,cAAA;AACA,cAAA;AACE,gBAAA;AACF,cAAA;AACA,cAAA;AACE,gBAAA;AACF,cAAA;AACA,cAAA;AACE,gBAAA;AACF,cAAA;AACF,YAAA;AACA,YAAA;AACE,cAAA;AACA,cAAA;AACA,cAAA;AACA,cAAA;AACF,YAAA;AACA,YAAA;AACE,cAAA;AACA,cAAA;AACF,YAAA;AACA,YAAA;AACM,cAAA;AACF,gBAAA;AACG,kBAAA;AACC,oBAAA;AACF,kBAAA;AACF,gBAAA;AACF,cAAA;AACE,gBAAA;AACF,cAAA;AACF,YAAA;AACA,YAAA;AACE,cAAA;AACF,YAAA;AAEA,YAAA;AACE,cAAA;AACD,YAAA;AAAA,UAAA;AACH,QAAA;AAEE,QAAA;AAIE,MAAA;AAAA,IAAA;AACN,EAAA;AAEJ;AAEO;AD5EW;AACA;AE1QXC;AF4QW;AACA;AACA;AACA;AACA","file":"/home/runner/work/pixels/pixels/packages/uniform/dist/chunk-3FSNNDYZ.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 '@heroui/select';\n\nimport { cn, slugify, tv, variantsToClassNames } from '@fuf-stack/pixel-utils';\n\nimport { useUniformField } from '../hooks';\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 'duration-150! rounded-lg border-2 border-default-200 bg-content1 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 HeroUI styles for group-data condition,\n // e.g.: https://github.com/heroui-inc/heroui/blob/main/packages/core/theme/src/components/select.ts\n label:\n 'pointer-events-auto relative bottom-1.5 ml-1 subpixel-antialiased text-small 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: 'rounded-sm p-2 text-foreground-500',\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/heroui-inc/heroui/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: 'ml-1 py-0.5 pl-1 text-sm text-foreground-500',\n selectContainer: '',\n singleValue: 'ml-1! leading-7!',\n valueContainer: 'gap-1 p-1',\n },\n});\n\ninterface 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/destructuring-assignment\n const testId = `${props.selectProps['data-testid']}`;\n\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/destructuring-assignment\n const testId = `${props.selectProps['data-testid']}_select`;\n return (\n <div data-testid={testId}>\n {}\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/destructuring-assignment\n const testId = `${props.selectProps['data-testid']}_select_option_${slugify(props?.data?.testId ?? props?.data?.value, { replaceDots: true })}`;\n return (\n <div data-testid={testId}>\n {}\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\n const testId = props?.selectProps['data-testid'] as string;\n return (\n <div data-testid={`${testId}_select_dropdown`}>\n {}\n <components.DropdownIndicator {...props} />\n </div>\n );\n};\n\n/** Select component based on [HeroUI Select](https://www.heroui.com//docs/components/select) and [React-Select](https://react-select.com/home) */\nconst Select = ({\n className = undefined,\n clearable = true,\n filterOption = undefined,\n renderOptionLabel = undefined,\n inputValue = undefined,\n loading = false,\n multiSelect = false,\n name,\n onInputChange = undefined,\n options,\n placeholder = undefined,\n ...uniformFieldProps\n}: SelectProps) => {\n const {\n disabled,\n errorMessage,\n field: { onBlur, onChange, ref, value },\n getErrorMessageProps,\n getHelperWrapperProps,\n getLabelProps,\n invalid,\n label,\n required,\n testId,\n } = useUniformField({ name, ...uniformFieldProps });\n\n const [isFocused, setIsFocused] = useState(false);\n\n // classNames from slots\n const variants = selectVariants();\n const classNames = variantsToClassNames(variants, className, 'base');\n\n const { getBaseProps, getTriggerProps, getValueProps } = useSelect({\n children: [],\n classNames,\n errorMessage,\n isDisabled: disabled,\n isInvalid: invalid,\n isLoading: loading,\n isRequired: required,\n label,\n labelPlacement: 'outside',\n });\n\n return (\n <div\n {...getBaseProps()}\n className={cn(classNames.base)}\n // see HeroUI styles for group-data condition (data-invalid),\n // e.g.: https://github.com/heroui-inc/heroui/blob/main/packages/components/select/src/use-select.ts\n data-required={required}\n data-testid={`${testId}_wrapper`}\n >\n {label ? (\n <label\n className={classNames.label}\n data-slot=\"label\"\n htmlFor={`react-select-${name}-input`}\n id={getLabelProps().id}\n >\n {label}\n </label>\n ) : null}\n <ReactSelect\n ref={ref}\n menuShouldBlockScroll\n unstyled\n aria-errormessage=\"\"\n aria-invalid={invalid}\n aria-labelledby={getTriggerProps()['aria-labelledby']?.split(' ')[1]}\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 // 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 name={name}\n onInputChange={onInputChange}\n options={options}\n placeholder={placeholder}\n classNames={{\n control: () => {\n return cn(classNames.control, {\n [classNames.control_focused]: isFocused && !invalid,\n });\n },\n clearIndicator: () => {\n return classNames.clearIndicator;\n },\n dropdownIndicator: () => {\n return classNames.dropdownIndicator;\n },\n groupHeading: () => {\n return classNames.groupHeading;\n },\n indicatorsContainer: () => {\n return classNames.indicatorsContainer;\n },\n indicatorSeparator: () => {\n return classNames.indicatorSeparator;\n },\n loadingIndicator: () => {\n return classNames.loadingIndicator;\n },\n loadingMessage: () => {\n return classNames.loadingMessage;\n },\n input: () => {\n return classNames.input;\n },\n menu: () => {\n return classNames.menu;\n },\n menuList: () => {\n return classNames.menuList;\n },\n menuPortal: () => {\n return classNames.menuPortal;\n },\n multiValue: () => {\n return classNames.multiValue;\n },\n multiValueLabel: () => {\n return cn(\n classNames.multiValueLabel,\n `${getValueProps().className}`,\n );\n },\n multiValueRemove: () => {\n return classNames.multiValueRemove;\n },\n noOptionsMessage: () => {\n return classNames.noOptionsMessage;\n },\n option: ({\n isFocused: optionIsFocused,\n isSelected: optionIsSelected,\n }) => {\n return cn(classNames.option, {\n [classNames.option_focused]: optionIsFocused,\n [classNames.option_selected]: optionIsSelected,\n });\n },\n placeholder: () => {\n return classNames.placeholder;\n },\n singleValue: () => {\n return cn(classNames.singleValue, `${getValueProps().className}`);\n },\n valueContainer: () => {\n return classNames.valueContainer;\n },\n }}\n components={{\n Input: InputComponent,\n Option: OptionComponent,\n DropdownIndicator: DropdownIndicatorComponent,\n Control: ControlComponent,\n }}\n onBlur={(_e) => {\n setIsFocused(false);\n onBlur();\n }}\n onChange={(option) => {\n if (multiSelect) {\n onChange(\n (option as SelectOption[])?.map((_option) => {\n return _option.value;\n }),\n );\n } else {\n onChange((option as SelectOption)?.value);\n }\n }}\n onFocus={(_e) => {\n setIsFocused(true);\n }}\n // set complete option as value by current field value\n value={options.find((option) => {\n return option.value === value;\n })}\n />\n {invalid ? (\n <div {...getHelperWrapperProps()}>\n {}\n <div {...getErrorMessageProps()}>{errorMessage}</div>\n </div>\n ) : null}\n </div>\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,9 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
useUniformField
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-Y6NHIZ2M.js";
|
|
4
4
|
import {
|
|
5
5
|
useInputValueDebounce
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-MODD3TFE.js";
|
|
7
7
|
import {
|
|
8
8
|
__objRest,
|
|
9
9
|
__spreadValues
|
|
@@ -100,4 +100,4 @@ export {
|
|
|
100
100
|
TextArea_default,
|
|
101
101
|
TextArea_default2
|
|
102
102
|
};
|
|
103
|
-
//# sourceMappingURL=chunk-
|
|
103
|
+
//# sourceMappingURL=chunk-3MXAIQKI.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
useUniformField
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-Y6NHIZ2M.js";
|
|
4
4
|
import {
|
|
5
5
|
__objRest,
|
|
6
6
|
__spreadProps,
|
|
@@ -34,10 +34,10 @@ var RadioBox = (_a) => {
|
|
|
34
34
|
Component,
|
|
35
35
|
__spreadProps(__spreadValues({}, getBaseProps()), {
|
|
36
36
|
className: cn(
|
|
37
|
-
"group
|
|
37
|
+
"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",
|
|
38
38
|
{
|
|
39
39
|
// disabled styles
|
|
40
|
-
"
|
|
40
|
+
"pointer-events-none opacity-disabled": isDisabled
|
|
41
41
|
}
|
|
42
42
|
),
|
|
43
43
|
children: [
|
|
@@ -50,7 +50,7 @@ var RadioBox = (_a) => {
|
|
|
50
50
|
className: cn(getLabelWrapperProps().className, "grow"),
|
|
51
51
|
children: [
|
|
52
52
|
children ? /* @__PURE__ */ jsx("span", __spreadProps(__spreadValues({}, getLabelProps()), { children })) : null,
|
|
53
|
-
description ? /* @__PURE__ */ jsx("span", { className: "text-
|
|
53
|
+
description ? /* @__PURE__ */ jsx("span", { className: "text-foreground opacity-70 text-small", children: description }) : null
|
|
54
54
|
]
|
|
55
55
|
})
|
|
56
56
|
)
|
|
@@ -74,7 +74,7 @@ var radioBoxesVariants = tv({
|
|
|
74
74
|
// TODO: get rid of !.
|
|
75
75
|
// see HeroUI styles for group-data condition,
|
|
76
76
|
// e.g.: https://github.com/heroui-inc/heroui/blob/main/packages/core/theme/src/components/select.ts
|
|
77
|
-
label: "text-foreground group-data-[invalid=true]:text-danger
|
|
77
|
+
label: "mb-2 inline-flex text-sm text-foreground subpixel-antialiased group-data-[invalid=true]:text-danger",
|
|
78
78
|
wrapper: ""
|
|
79
79
|
}
|
|
80
80
|
});
|
|
@@ -168,4 +168,4 @@ export {
|
|
|
168
168
|
RadioBoxes_default,
|
|
169
169
|
RadioBoxes_default2
|
|
170
170
|
};
|
|
171
|
-
//# sourceMappingURL=chunk-
|
|
171
|
+
//# sourceMappingURL=chunk-4DGOOLSO.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/RadioBoxes/RadioBoxes.tsx","../src/RadioBoxes/RadioBox.tsx","../src/RadioBoxes/index.ts"],"sourcesContent":["import type { TVClassName, TVProps } from '@fuf-stack/pixel-utils';\nimport type { ReactNode } from 'react';\n\nimport { RadioGroup as HeroRadioGroup } from '@heroui/radio';\n\nimport { slugify, tv, variantsToClassNames } from '@fuf-stack/pixel-utils';\n\nimport { useUniformField } from '../hooks';\n//\nimport { RadioBox } from './RadioBox';\n\nexport const radioBoxesVariants = tv({\n slots: {\n base: 'group gap-0', // Needs group for group-data condition\n itemBase: '',\n itemControl: 'bg-focus group-data-[invalid=true]:bg-danger',\n itemDescription: '',\n itemLabel: 'text-sm',\n itemLabelWrapper: '',\n itemWrapper:\n 'group-data-[invalid=true]:!border-danger [&:not(group-data-[invalid=\"true\"]):not(group-data-[selected=\"false\"])]:border-focus', // TODO: get rid of !.\n // see HeroUI styles for group-data condition,\n // e.g.: https://github.com/heroui-inc/heroui/blob/main/packages/core/theme/src/components/select.ts\n label:\n 'text-foreground group-data-[invalid=true]:text-danger
|
|
1
|
+
{"version":3,"sources":["../src/RadioBoxes/RadioBoxes.tsx","../src/RadioBoxes/RadioBox.tsx","../src/RadioBoxes/index.ts"],"sourcesContent":["import type { TVClassName, TVProps } from '@fuf-stack/pixel-utils';\nimport type { ReactNode } from 'react';\n\nimport { RadioGroup as HeroRadioGroup } from '@heroui/radio';\n\nimport { slugify, tv, variantsToClassNames } from '@fuf-stack/pixel-utils';\n\nimport { useUniformField } from '../hooks';\n//\nimport { RadioBox } from './RadioBox';\n\nexport const radioBoxesVariants = tv({\n slots: {\n base: 'group gap-0', // Needs group for group-data condition\n itemBase: '',\n itemControl: 'bg-focus group-data-[invalid=true]:bg-danger',\n itemDescription: '',\n itemLabel: 'text-sm',\n itemLabelWrapper: '',\n itemWrapper:\n 'group-data-[invalid=true]:!border-danger [&:not(group-data-[invalid=\"true\"]):not(group-data-[selected=\"false\"])]:border-focus', // TODO: get rid of !.\n // see HeroUI styles for group-data condition,\n // e.g.: https://github.com/heroui-inc/heroui/blob/main/packages/core/theme/src/components/select.ts\n label:\n 'mb-2 inline-flex text-sm text-foreground subpixel-antialiased group-data-[invalid=true]:text-danger',\n wrapper: '',\n },\n});\n\ntype VariantProps = TVProps<typeof radioBoxesVariants>;\ntype ClassName = TVClassName<typeof radioBoxesVariants>;\n\nexport interface RadioBoxesOption {\n /** Description of the value. Works with variant radioBox. */\n description?: ReactNode;\n /** disables the option */\n disabled?: boolean;\n /** option label */\n label?: 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 RadioBoxesProps 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: RadioBoxesOption[];\n /** Id to grab element in internal tests. */\n testId?: string;\n}\n\n/**\n * RadioBoxes component based on [HeroUI RadioGroup](https://www.heroui.com//docs/components/radio-group)\n */\nconst RadioBoxes = ({\n className = undefined,\n inline = false,\n name,\n options,\n ...uniformFieldProps\n}: RadioBoxesProps) => {\n const {\n defaultValue,\n errorMessage,\n invalid,\n disabled,\n label,\n onBlur,\n onChange,\n ref,\n required,\n testId,\n } = useUniformField({\n name,\n showInvalidWhen: 'immediate',\n ...uniformFieldProps,\n });\n\n // classNames from slots\n const variants = radioBoxesVariants();\n const classNames = variantsToClassNames(variants, className, 'base');\n const itemClassNames = {\n base: classNames.itemBase,\n control: classNames.itemControl,\n description: classNames.itemDescription,\n label: classNames.itemLabel,\n labelWrapper: classNames.itemLabelWrapper,\n wrapper: classNames.itemWrapper,\n };\n\n return (\n <HeroRadioGroup\n ref={ref}\n classNames={classNames}\n // see HeroUI styles for group-data condition (data-invalid),\n // e.g.: https://github.com/heroui-inc/heroui/blob/main/packages/components/select/src/use-select.ts\n data-invalid={invalid}\n data-required={required}\n data-testid={testId}\n defaultValue={defaultValue as string}\n errorMessage={errorMessage}\n isDisabled={disabled}\n isInvalid={invalid}\n isRequired={required}\n label={label ? <legend>{label}</legend> : null}\n name={name}\n onBlur={onBlur}\n orientation={inline ? 'horizontal' : 'vertical'}\n >\n {options.map((option) => {\n if ('value' in option) {\n const optionTestId = slugify(\n `${testId}_option_${option.testId ?? option.value}`,\n { replaceDots: true },\n );\n return (\n <RadioBox\n key={option.value}\n classNames={itemClassNames}\n data-testid={optionTestId}\n description={option.description}\n icon={option.icon}\n isDisabled={!!disabled || option.disabled}\n onChange={onChange}\n value={option.value}\n >\n {option.label ?? option.value}\n </RadioBox>\n );\n }\n return null;\n })}\n </HeroRadioGroup>\n );\n};\n\nexport default RadioBoxes;\n","import type { RadioProps as HeroRadioProps } from '@heroui/radio';\nimport type { ReactNode } from 'react';\n\nimport { useRadio } from '@heroui/radio';\nimport { VisuallyHidden } from '@react-aria/visually-hidden';\n\nimport { cn } from '@fuf-stack/pixel-utils';\n\ninterface RadioProps extends HeroRadioProps {\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 {...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 <input {...getInputProps()} />\n </VisuallyHidden>\n <span {...getWrapperProps()}>\n <span {...getControlProps()} />\n </span>\n {icon}\n <div\n {...getLabelWrapperProps()}\n className={cn(getLabelWrapperProps().className, 'grow')}\n >\n {children ? <span {...getLabelProps()}>{children}</span> : null}\n {description ? (\n <span className=\"text-foreground opacity-70 text-small\">\n {description}\n </span>\n ) : null}\n </div>\n </Component>\n );\n};\n\nexport default RadioBox;\n","import RadioBoxes from './RadioBoxes';\n\nexport type { RadioBoxesProps } from './RadioBoxes';\n\nexport { RadioBoxes };\n\nexport default RadioBoxes;\n"],"mappings":";;;;;;;;;;AAGA,SAAS,cAAc,sBAAsB;AAE7C,SAAS,SAAS,IAAI,4BAA4B;;;ACFlD,SAAS,gBAAgB;AACzB,SAAS,sBAAsB;AAE/B,SAAS,UAAU;AAiCX,cAMF,YANE;AA1BD,IAAM,WAAW,CAAC,OAA+C;AAA/C,eAAE,SAAO,OAblC,IAayB,IAAuB,kBAAvB,IAAuB,CAArB;AACzB,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,IAAI,SAAS,KAAK;AAElB,SACE;AAAA,IAAC;AAAA,qCACK,aAAa,IADlB;AAAA,MAEC,WAAW;AAAA,QACT;AAAA,QACA;AAAA;AAAA,UAEE,wCAAwC;AAAA,QAC1C;AAAA,MACF;AAAA,MAEA;AAAA,4BAAC,kBACC,8BAAC,4BAAU,cAAc,EAAG,GAC9B;AAAA,QACA,oBAAC,yCAAS,gBAAgB,IAAzB,EACC,8BAAC,2BAAS,gBAAgB,EAAG,IAC/B;AAAA,QACC;AAAA,QACD;AAAA,UAAC;AAAA,2CACK,qBAAqB,IAD1B;AAAA,YAEC,WAAW,GAAG,qBAAqB,EAAE,WAAW,MAAM;AAAA,YAErD;AAAA,yBAAW,oBAAC,yCAAS,cAAc,IAAvB,EAA2B,WAAS,IAAU;AAAA,cAC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Q,iBAAM,IAAY;AAAA,MAC1C;AAAA,MACA;AAAA,MACA,aAAa,SAAS,eAAe;AAAA,MAEpC,kBAAQ,IAAI,CAAC,WAAW;AA1H/B,YAAAC,KAAAC;AA2HQ,YAAI,WAAW,QAAQ;AACrB,gBAAM,eAAe;AAAA,YACnB,GAAG,MAAM,YAAWD,MAAA,OAAO,WAAP,OAAAA,MAAiB,OAAO,KAAK;AAAA,YACjD,EAAE,aAAa,KAAK;AAAA,UACtB;AACA,iBACE,gBAAAD;AAAA,YAAC;AAAA;AAAA,cAEC,YAAY;AAAA,cACZ,eAAa;AAAA,cACb,aAAa,OAAO;AAAA,cACpB,MAAM,OAAO;AAAA,cACb,YAAY,CAAC,CAAC,YAAY,OAAO;AAAA,cACjC;AAAA,cACA,OAAO,OAAO;AAAA,cAEb,WAAAE,MAAA,OAAO,UAAP,OAAAA,MAAgB,OAAO;AAAA;AAAA,YATnB,OAAO;AAAA,UAUd;AAAA,QAEJ;AACA,eAAO;AAAA,MACT,CAAC;AAAA;AAAA,EACH;AAEJ;AAEA,IAAO,qBAAQ;;;AE/If,IAAOC,sBAAQ;","names":["jsx","_a","_b","RadioBoxes_default"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
useUniformField
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-Y6NHIZ2M.js";
|
|
4
4
|
import {
|
|
5
5
|
__objRest,
|
|
6
6
|
__spreadValues
|
|
@@ -24,7 +24,7 @@ var radiosVariants = tv({
|
|
|
24
24
|
itemLabelWrapper: "",
|
|
25
25
|
itemWrapper: 'group-data-[invalid=true]:border-danger! [&:not(group-data-[invalid="true"]):not(group-data-[selected="false"])]:border-focus',
|
|
26
26
|
// e.g.: https://github.com/heroui-inc/heroui/blob/main/packages/core/theme/src/components/select.ts
|
|
27
|
-
label: "text-foreground group-data-[invalid=true]:text-danger
|
|
27
|
+
label: "mb-2 inline-flex text-sm text-foreground subpixel-antialiased group-data-[invalid=true]:text-danger",
|
|
28
28
|
wrapper: ""
|
|
29
29
|
}
|
|
30
30
|
});
|
|
@@ -114,4 +114,4 @@ export {
|
|
|
114
114
|
Radios_default,
|
|
115
115
|
Radios_default2
|
|
116
116
|
};
|
|
117
|
-
//# sourceMappingURL=chunk-
|
|
117
|
+
//# sourceMappingURL=chunk-4EZWAVRZ.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/Radios/Radios.tsx","../src/Radios/index.ts"],"sourcesContent":["import type { TVClassName, TVProps } from '@fuf-stack/pixel-utils';\nimport type { ReactElement, ReactNode } from 'react';\n\nimport {\n Radio as HeroRadio,\n RadioGroup as HeroRadioGroup,\n} from '@heroui/radio';\n\nimport { slugify, tv, variantsToClassNames } from '@fuf-stack/pixel-utils';\n\nimport { useUniformField } from '../hooks';\n\nexport const radiosVariants = tv({\n slots: {\n // Needs group for group-data condition\n base: 'group gap-0',\n itemBase: '',\n itemControl: 'bg-focus group-data-[invalid=true]:bg-danger',\n itemDescription: '',\n itemLabel: 'text-sm',\n itemLabelWrapper: '',\n itemWrapper:\n 'group-data-[invalid=true]:border-danger! [&:not(group-data-[invalid=\"true\"]):not(group-data-[selected=\"false\"])]:border-focus',\n // e.g.: https://github.com/heroui-inc/heroui/blob/main/packages/core/theme/src/components/select.ts\n label:\n 'text-foreground group-data-[invalid=true]:text-danger
|
|
1
|
+
{"version":3,"sources":["../src/Radios/Radios.tsx","../src/Radios/index.ts"],"sourcesContent":["import type { TVClassName, TVProps } from '@fuf-stack/pixel-utils';\nimport type { ReactElement, ReactNode } from 'react';\n\nimport {\n Radio as HeroRadio,\n RadioGroup as HeroRadioGroup,\n} from '@heroui/radio';\n\nimport { slugify, tv, variantsToClassNames } from '@fuf-stack/pixel-utils';\n\nimport { useUniformField } from '../hooks';\n\nexport const radiosVariants = tv({\n slots: {\n // Needs group for group-data condition\n base: 'group gap-0',\n itemBase: '',\n itemControl: 'bg-focus group-data-[invalid=true]:bg-danger',\n itemDescription: '',\n itemLabel: 'text-sm',\n itemLabelWrapper: '',\n itemWrapper:\n 'group-data-[invalid=true]:border-danger! [&:not(group-data-[invalid=\"true\"]):not(group-data-[selected=\"false\"])]:border-focus',\n // e.g.: https://github.com/heroui-inc/heroui/blob/main/packages/core/theme/src/components/select.ts\n label:\n 'mb-2 inline-flex text-sm text-foreground subpixel-antialiased group-data-[invalid=true]:text-danger',\n wrapper: '',\n },\n});\n\ntype VariantProps = TVProps<typeof radiosVariants>;\ntype ClassName = TVClassName<typeof radiosVariants>;\n\nexport interface RadioOption {\n /** disables the option */\n disabled?: boolean;\n /** option label */\n label?: React.ReactNode;\n /** option icon */\n icon?: ReactNode;\n /** HTML data-testid attribute of the option */\n testId?: string;\n /** option value */\n value: string;\n}\n\nexport interface RadiosProps extends VariantProps {\n /** CSS class name */\n className?: ClassName;\n /** Determines if the Buttons are disabled or not. */\n disabled?: boolean;\n /** determines orientation of the Buttons. */\n inline?: boolean;\n /** Label displayed next to the RadioButton. */\n label?: ReactNode;\n /** Name the RadioButtons are registered at in HTML forms (react-hook-form). */\n name: string;\n /** Radio button configuration. */\n options: RadioOption[];\n /** Id to grab element in internal tests. */\n testId?: string;\n}\n\n/**\n * Radios component based on [HeroUI RadioGroup](https://www.heroui.com//docs/components/radio-group)\n */\nconst Radios = ({\n className = undefined,\n inline = false,\n name,\n options,\n ...uniformFieldProps\n}: RadiosProps): ReactElement => {\n const {\n disabled,\n errorMessage,\n field: { onBlur, onChange, ref },\n invalid,\n label,\n required,\n defaultValue,\n testId,\n } = useUniformField({\n name,\n showInvalidWhen: 'immediate',\n ...uniformFieldProps,\n });\n\n // classNames from slots\n const variants = radiosVariants();\n const classNames = variantsToClassNames(variants, className, 'base');\n\n const itemClassNames = {\n base: classNames.itemBase,\n control: classNames.itemControl,\n description: classNames.itemDescription,\n label: classNames.itemLabel,\n labelWrapper: classNames.itemLabelWrapper,\n wrapper: classNames.itemWrapper,\n };\n\n return (\n <HeroRadioGroup\n ref={ref}\n classNames={classNames}\n // see HeroUI styles for group-data condition (data-invalid),\n // e.g.: https://github.com/heroui-inc/heroui/blob/main/packages/components/select/src/use-select.ts\n data-invalid={invalid}\n data-required={required}\n data-testid={testId}\n defaultValue={defaultValue as string | undefined}\n errorMessage={errorMessage}\n isDisabled={disabled}\n isInvalid={invalid}\n isRequired={required}\n label={label ? <legend>{label}</legend> : null}\n name={name}\n onBlur={onBlur}\n orientation={inline ? 'horizontal' : 'vertical'}\n >\n {options.map((option) => {\n if ('value' in option) {\n const optionTestId = slugify(\n `${testId}_option_${option.testId ?? option.value}`,\n { replaceDots: true },\n );\n return (\n <HeroRadio\n key={option.value}\n classNames={itemClassNames}\n data-testid={optionTestId}\n isDisabled={!!disabled || option.disabled}\n onChange={onChange}\n value={option.value}\n >\n {option.label ?? option.value}\n </HeroRadio>\n );\n }\n return null;\n })}\n </HeroRadioGroup>\n );\n};\n\nexport default Radios;\n","import Radios from './Radios';\n\nexport type { RadiosProps } from './Radios';\n\nexport { Radios };\n\nexport default Radios;\n"],"mappings":";;;;;;;;;AAGA;AAAA,EACE,SAAS;AAAA,EACT,cAAc;AAAA,OACT;AAEP,SAAS,SAAS,IAAI,4BAA4B;AA2G7B;AAvGd,IAAM,iBAAiB,GAAG;AAAA,EAC/B,OAAO;AAAA;AAAA,IAEL,MAAM;AAAA,IACN,UAAU;AAAA,IACV,aAAa;AAAA,IACb,iBAAiB;AAAA,IACjB,WAAW;AAAA,IACX,kBAAkB;AAAA,IAClB,aACE;AAAA;AAAA,IAEF,OACE;AAAA,IACF,SAAS;AAAA,EACX;AACF,CAAC;AAsCD,IAAM,SAAS,CAAC,OAMiB;AANjB,eACd;AAAA,gBAAY;AAAA,IACZ,SAAS;AAAA,IACT;AAAA,IACA;AAAA,EAtEF,IAkEgB,IAKX,8BALW,IAKX;AAAA,IAJH;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA;AAGA,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA,OAAO,EAAE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;AC3If,IAAOC,kBAAQ;","names":["_a","_b","Radios_default"]}
|
|
@@ -10,7 +10,9 @@ var useInputValueTransform = ({
|
|
|
10
10
|
return transform.toDisplayValue(formValue != null ? formValue : "");
|
|
11
11
|
}
|
|
12
12
|
if (type === "number") {
|
|
13
|
-
if (formValue === "")
|
|
13
|
+
if (formValue === "") {
|
|
14
|
+
return "";
|
|
15
|
+
}
|
|
14
16
|
const numValue = Number(formValue);
|
|
15
17
|
return Number.isNaN(numValue) ? formValue : numValue;
|
|
16
18
|
}
|
|
@@ -21,7 +23,9 @@ var useInputValueTransform = ({
|
|
|
21
23
|
const toFormValue = _react.useCallback.call(void 0,
|
|
22
24
|
(displayValue) => {
|
|
23
25
|
if (type === "number") {
|
|
24
|
-
if (displayValue === "")
|
|
26
|
+
if (displayValue === "") {
|
|
27
|
+
return "";
|
|
28
|
+
}
|
|
25
29
|
const numValue = Number(displayValue);
|
|
26
30
|
return Number.isNaN(numValue) ? displayValue : numValue;
|
|
27
31
|
}
|
|
@@ -38,4 +42,4 @@ var useInputValueTransform = ({
|
|
|
38
42
|
|
|
39
43
|
|
|
40
44
|
exports.useInputValueTransform = useInputValueTransform;
|
|
41
|
-
//# sourceMappingURL=chunk-
|
|
45
|
+
//# sourceMappingURL=chunk-4WYC2RBE.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/home/runner/work/pixels/pixels/packages/uniform/dist/chunk-4WYC2RBE.cjs","../src/hooks/useInputValueTransform/useInputValueTransform.ts"],"names":[],"mappings":"AAAA;ACAA,8BAA4B;AAsFrB,IAAM,uBAAA,EAAyB,CAAC;AAAA,EACrC,IAAA;AAAA,EACA;AACF,CAAA,EAAA,GAAmE;AAIjE,EAAA,MAAM,eAAA,EAAiB,gCAAA;AAAA,IACrB,CAAC,SAAA,EAAA,GAAgD;AAC/C,MAAA,GAAA,CAAI,UAAA,GAAA,KAAA,EAAA,KAAA,EAAA,EAAA,SAAA,CAAW,cAAA,EAAgB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cjs","sourcesContent":[null,"import { useCallback } from 'react';\n\nexport interface InputValueTransform {\n /** Transforms the form value to display value (e.g., 1000 → \"$1,000\") */\n toDisplayValue: (value: string | number) => string | number;\n /** Transforms the display value to form value (e.g., \"$1,000\" → 1000) */\n toFormValue: (value: string) => string | number;\n}\n\nexport interface UseInputValueTransformOptions {\n /** Input type for special number handling */\n type?: 'text' | 'number' | 'password';\n /** Value transformation functions */\n transform?: InputValueTransform;\n}\n\nexport interface UseInputValueTransformReturn {\n /** Converts any form value to display value */\n toDisplayValue: (formValue: string | number) => string | number;\n /** Converts any display value to form value */\n toFormValue: (displayValue: string | number) => string | number;\n}\n\n/**\n * Custom hook providing utility functions for value transformations between display and form values.\n *\n * This hook provides pure conversion functions without any state management. It's useful for:\n * - Currency formatting ($1,000 display vs 1000 stored)\n * - Number inputs with special handling\n * - Date formatting (MM/DD/YYYY display vs ISO date stored)\n * - Phone number formatting ((555) 123-4567 display vs 5551234567 stored)\n *\n * **Key Features:**\n * - Pure conversion functions (no state)\n * - Special number input handling (empty string preservation)\n * - Bidirectional value transformations\n * - Memoized functions for performance\n *\n * @param options Configuration for value transformation\n * @returns Pure conversion utility functions\n *\n * @example\n * ```tsx\n * // Currency formatting\n * const currencyTransform = {\n * displayValue: (val) => val ? `$${Number(val).toLocaleString()}` : '',\n * formValue: (val) => parseFloat(val.replace(/[$,]/g, '')) || 0\n * };\n *\n * const { toDisplayValue, toFormValue } = useInputValueTransform({\n * transform: currencyTransform\n * });\n *\n * const displayVal = toDisplayValue(1000); // \"$1,000\"\n * const formVal = toFormValue(\"$1,500\"); // 1500\n * ```\n *\n * @example\n * ```tsx\n * // Number input (no transforms needed)\n * const { toDisplayValue, toFormValue } = useInputValueTransform({\n * type: 'number'\n * });\n *\n * // Handles empty string → empty string (not NaN)\n * // Handles \"123\" → 123 (string to number conversion)\n * ```\n *\n * @example\n * ```tsx\n * // Integration with debouncing\n * const MyInput = ({ field, transform }) => {\n * const transform = useInputValueTransform({ transform });\n *\n * const { onChange, onBlur, value } = useInputValueDebounce({\n * ...transform,\n * initialValue: field.value,\n * debounceDelay: 300,\n * onBlur: field.onBlur,\n * onChange: field.onChange,\n * });\n *\n * return <input value={value} onChange={onChange} onBlur={onBlur} />;\n * };\n * ```\n */\nexport const useInputValueTransform = ({\n type,\n transform,\n}: UseInputValueTransformOptions): UseInputValueTransformReturn => {\n /**\n * Converts any form value to display value\n */\n const toDisplayValue = useCallback(\n (formValue: string | number): string | number => {\n if (transform?.toDisplayValue) {\n return transform.toDisplayValue(formValue ?? '');\n }\n\n // For number type, convert valid strings to numbers for display\n if (type === 'number') {\n if (formValue === '') {\n return '';\n }\n const numValue = Number(formValue);\n return Number.isNaN(numValue) ? formValue : numValue;\n }\n\n return formValue ?? '';\n },\n [type, transform],\n );\n\n /**\n * Converts any display value to form value\n */\n const toFormValue = useCallback(\n (displayValue: string | number): string | number => {\n if (type === 'number') {\n if (displayValue === '') {\n return '';\n }\n const numValue = Number(displayValue);\n return Number.isNaN(numValue) ? displayValue : numValue;\n }\n\n return transform?.toFormValue\n ? transform.toFormValue(displayValue as string)\n : displayValue;\n },\n [type, transform],\n );\n\n return {\n toDisplayValue,\n toFormValue,\n };\n};\n"]}
|
|
@@ -10,7 +10,9 @@ var useInputValueTransform = ({
|
|
|
10
10
|
return transform.toDisplayValue(formValue != null ? formValue : "");
|
|
11
11
|
}
|
|
12
12
|
if (type === "number") {
|
|
13
|
-
if (formValue === "")
|
|
13
|
+
if (formValue === "") {
|
|
14
|
+
return "";
|
|
15
|
+
}
|
|
14
16
|
const numValue = Number(formValue);
|
|
15
17
|
return Number.isNaN(numValue) ? formValue : numValue;
|
|
16
18
|
}
|
|
@@ -21,7 +23,9 @@ var useInputValueTransform = ({
|
|
|
21
23
|
const toFormValue = useCallback(
|
|
22
24
|
(displayValue) => {
|
|
23
25
|
if (type === "number") {
|
|
24
|
-
if (displayValue === "")
|
|
26
|
+
if (displayValue === "") {
|
|
27
|
+
return "";
|
|
28
|
+
}
|
|
25
29
|
const numValue = Number(displayValue);
|
|
26
30
|
return Number.isNaN(numValue) ? displayValue : numValue;
|
|
27
31
|
}
|
|
@@ -38,4 +42,4 @@ var useInputValueTransform = ({
|
|
|
38
42
|
export {
|
|
39
43
|
useInputValueTransform
|
|
40
44
|
};
|
|
41
|
-
//# sourceMappingURL=chunk-
|
|
45
|
+
//# sourceMappingURL=chunk-7KLFK2IT.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/hooks/useInputValueTransform/useInputValueTransform.ts"],"sourcesContent":["import { useCallback } from 'react';\n\nexport interface InputValueTransform {\n /** Transforms the form value to display value (e.g., 1000 → \"$1,000\") */\n toDisplayValue: (value: string | number) => string | number;\n /** Transforms the display value to form value (e.g., \"$1,000\" → 1000) */\n toFormValue: (value: string) => string | number;\n}\n\nexport interface UseInputValueTransformOptions {\n /** Input type for special number handling */\n type?: 'text' | 'number' | 'password';\n /** Value transformation functions */\n transform?: InputValueTransform;\n}\n\nexport interface UseInputValueTransformReturn {\n /** Converts any form value to display value */\n toDisplayValue: (formValue: string | number) => string | number;\n /** Converts any display value to form value */\n toFormValue: (displayValue: string | number) => string | number;\n}\n\n/**\n * Custom hook providing utility functions for value transformations between display and form values.\n *\n * This hook provides pure conversion functions without any state management. It's useful for:\n * - Currency formatting ($1,000 display vs 1000 stored)\n * - Number inputs with special handling\n * - Date formatting (MM/DD/YYYY display vs ISO date stored)\n * - Phone number formatting ((555) 123-4567 display vs 5551234567 stored)\n *\n * **Key Features:**\n * - Pure conversion functions (no state)\n * - Special number input handling (empty string preservation)\n * - Bidirectional value transformations\n * - Memoized functions for performance\n *\n * @param options Configuration for value transformation\n * @returns Pure conversion utility functions\n *\n * @example\n * ```tsx\n * // Currency formatting\n * const currencyTransform = {\n * displayValue: (val) => val ? `$${Number(val).toLocaleString()}` : '',\n * formValue: (val) => parseFloat(val.replace(/[$,]/g, '')) || 0\n * };\n *\n * const { toDisplayValue, toFormValue } = useInputValueTransform({\n * transform: currencyTransform\n * });\n *\n * const displayVal = toDisplayValue(1000); // \"$1,000\"\n * const formVal = toFormValue(\"$1,500\"); // 1500\n * ```\n *\n * @example\n * ```tsx\n * // Number input (no transforms needed)\n * const { toDisplayValue, toFormValue } = useInputValueTransform({\n * type: 'number'\n * });\n *\n * // Handles empty string → empty string (not NaN)\n * // Handles \"123\" → 123 (string to number conversion)\n * ```\n *\n * @example\n * ```tsx\n * // Integration with debouncing\n * const MyInput = ({ field, transform }) => {\n * const transform = useInputValueTransform({ transform });\n *\n * const { onChange, onBlur, value } = useInputValueDebounce({\n * ...transform,\n * initialValue: field.value,\n * debounceDelay: 300,\n * onBlur: field.onBlur,\n * onChange: field.onChange,\n * });\n *\n * return <input value={value} onChange={onChange} onBlur={onBlur} />;\n * };\n * ```\n */\nexport const useInputValueTransform = ({\n type,\n transform,\n}: UseInputValueTransformOptions): UseInputValueTransformReturn => {\n /**\n * Converts any form value to display value\n */\n const toDisplayValue = useCallback(\n (formValue: string | number): string | number => {\n if (transform?.toDisplayValue) {\n return transform.toDisplayValue(formValue ?? '');\n }\n\n // For number type, convert valid strings to numbers for display\n if (type === 'number') {\n if (formValue === '') return '';\n const numValue = Number(formValue);\n return Number.isNaN(numValue) ? formValue : numValue;\n }\n\n return formValue ?? '';\n },\n [type, transform],\n );\n\n /**\n * Converts any display value to form value\n */\n const toFormValue = useCallback(\n (displayValue: string | number): string | number => {\n if (type === 'number') {\n if (displayValue === '') return '';\n const numValue = Number(displayValue);\n return Number.isNaN(numValue) ? displayValue : numValue;\n }\n\n return transform?.toFormValue\n ? transform.toFormValue(displayValue as string)\n : displayValue;\n },\n [type, transform],\n );\n\n return {\n toDisplayValue,\n toFormValue,\n };\n};\n"],"mappings":";AAAA,SAAS,mBAAmB;AAsFrB,IAAM,yBAAyB,CAAC;AAAA,EACrC;AAAA,EACA;AACF,MAAmE;AAIjE,QAAM,iBAAiB;AAAA,IACrB,CAAC,cAAgD;AAC/C,UAAI,uCAAW,gBAAgB;AAC7B,eAAO,UAAU,eAAe,gCAAa,EAAE;AAAA,MACjD;AAGA,UAAI,SAAS,UAAU;AACrB,YAAI,cAAc,
|
|
1
|
+
{"version":3,"sources":["../src/hooks/useInputValueTransform/useInputValueTransform.ts"],"sourcesContent":["import { useCallback } from 'react';\n\nexport interface InputValueTransform {\n /** Transforms the form value to display value (e.g., 1000 → \"$1,000\") */\n toDisplayValue: (value: string | number) => string | number;\n /** Transforms the display value to form value (e.g., \"$1,000\" → 1000) */\n toFormValue: (value: string) => string | number;\n}\n\nexport interface UseInputValueTransformOptions {\n /** Input type for special number handling */\n type?: 'text' | 'number' | 'password';\n /** Value transformation functions */\n transform?: InputValueTransform;\n}\n\nexport interface UseInputValueTransformReturn {\n /** Converts any form value to display value */\n toDisplayValue: (formValue: string | number) => string | number;\n /** Converts any display value to form value */\n toFormValue: (displayValue: string | number) => string | number;\n}\n\n/**\n * Custom hook providing utility functions for value transformations between display and form values.\n *\n * This hook provides pure conversion functions without any state management. It's useful for:\n * - Currency formatting ($1,000 display vs 1000 stored)\n * - Number inputs with special handling\n * - Date formatting (MM/DD/YYYY display vs ISO date stored)\n * - Phone number formatting ((555) 123-4567 display vs 5551234567 stored)\n *\n * **Key Features:**\n * - Pure conversion functions (no state)\n * - Special number input handling (empty string preservation)\n * - Bidirectional value transformations\n * - Memoized functions for performance\n *\n * @param options Configuration for value transformation\n * @returns Pure conversion utility functions\n *\n * @example\n * ```tsx\n * // Currency formatting\n * const currencyTransform = {\n * displayValue: (val) => val ? `$${Number(val).toLocaleString()}` : '',\n * formValue: (val) => parseFloat(val.replace(/[$,]/g, '')) || 0\n * };\n *\n * const { toDisplayValue, toFormValue } = useInputValueTransform({\n * transform: currencyTransform\n * });\n *\n * const displayVal = toDisplayValue(1000); // \"$1,000\"\n * const formVal = toFormValue(\"$1,500\"); // 1500\n * ```\n *\n * @example\n * ```tsx\n * // Number input (no transforms needed)\n * const { toDisplayValue, toFormValue } = useInputValueTransform({\n * type: 'number'\n * });\n *\n * // Handles empty string → empty string (not NaN)\n * // Handles \"123\" → 123 (string to number conversion)\n * ```\n *\n * @example\n * ```tsx\n * // Integration with debouncing\n * const MyInput = ({ field, transform }) => {\n * const transform = useInputValueTransform({ transform });\n *\n * const { onChange, onBlur, value } = useInputValueDebounce({\n * ...transform,\n * initialValue: field.value,\n * debounceDelay: 300,\n * onBlur: field.onBlur,\n * onChange: field.onChange,\n * });\n *\n * return <input value={value} onChange={onChange} onBlur={onBlur} />;\n * };\n * ```\n */\nexport const useInputValueTransform = ({\n type,\n transform,\n}: UseInputValueTransformOptions): UseInputValueTransformReturn => {\n /**\n * Converts any form value to display value\n */\n const toDisplayValue = useCallback(\n (formValue: string | number): string | number => {\n if (transform?.toDisplayValue) {\n return transform.toDisplayValue(formValue ?? '');\n }\n\n // For number type, convert valid strings to numbers for display\n if (type === 'number') {\n if (formValue === '') {\n return '';\n }\n const numValue = Number(formValue);\n return Number.isNaN(numValue) ? formValue : numValue;\n }\n\n return formValue ?? '';\n },\n [type, transform],\n );\n\n /**\n * Converts any display value to form value\n */\n const toFormValue = useCallback(\n (displayValue: string | number): string | number => {\n if (type === 'number') {\n if (displayValue === '') {\n return '';\n }\n const numValue = Number(displayValue);\n return Number.isNaN(numValue) ? displayValue : numValue;\n }\n\n return transform?.toFormValue\n ? transform.toFormValue(displayValue as string)\n : displayValue;\n },\n [type, transform],\n );\n\n return {\n toDisplayValue,\n toFormValue,\n };\n};\n"],"mappings":";AAAA,SAAS,mBAAmB;AAsFrB,IAAM,yBAAyB,CAAC;AAAA,EACrC;AAAA,EACA;AACF,MAAmE;AAIjE,QAAM,iBAAiB;AAAA,IACrB,CAAC,cAAgD;AAC/C,UAAI,uCAAW,gBAAgB;AAC7B,eAAO,UAAU,eAAe,gCAAa,EAAE;AAAA,MACjD;AAGA,UAAI,SAAS,UAAU;AACrB,YAAI,cAAc,IAAI;AACpB,iBAAO;AAAA,QACT;AACA,cAAM,WAAW,OAAO,SAAS;AACjC,eAAO,OAAO,MAAM,QAAQ,IAAI,YAAY;AAAA,MAC9C;AAEA,aAAO,gCAAa;AAAA,IACtB;AAAA,IACA,CAAC,MAAM,SAAS;AAAA,EAClB;AAKA,QAAM,cAAc;AAAA,IAClB,CAAC,iBAAmD;AAClD,UAAI,SAAS,UAAU;AACrB,YAAI,iBAAiB,IAAI;AACvB,iBAAO;AAAA,QACT;AACA,cAAM,WAAW,OAAO,YAAY;AACpC,eAAO,OAAO,MAAM,QAAQ,IAAI,eAAe;AAAA,MACjD;AAEA,cAAO,uCAAW,eACd,UAAU,YAAY,YAAsB,IAC5C;AAAA,IACN;AAAA,IACA,CAAC,MAAM,SAAS;AAAA,EAClB;AAEA,SAAO;AAAA,IACL;AAAA,IACA;AAAA,EACF;AACF;","names":[]}
|
|
@@ -5,7 +5,7 @@ var _chunkTTD3KL6Ecjs = require('./chunk-TTD3KL6E.cjs');
|
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
|
|
8
|
-
var
|
|
8
|
+
var _chunkO3DDOJTBcjs = require('./chunk-O3DDOJTB.cjs');
|
|
9
9
|
|
|
10
10
|
|
|
11
11
|
var _chunkNHEZXA4Hcjs = require('./chunk-NHEZXA4H.cjs');
|
|
@@ -309,7 +309,7 @@ var FieldArrayLabel = ({
|
|
|
309
309
|
name
|
|
310
310
|
}) => {
|
|
311
311
|
var _a;
|
|
312
|
-
const { error, getLabelProps, invalid, label } =
|
|
312
|
+
const { error, getLabelProps, invalid, label } = _chunkO3DDOJTBcjs.useUniformField.call(void 0, {
|
|
313
313
|
name,
|
|
314
314
|
showInvalidWhen: "immediate",
|
|
315
315
|
label: _label
|
|
@@ -351,7 +351,7 @@ var FieldArrayValidationError = ({
|
|
|
351
351
|
getHelperWrapperProps,
|
|
352
352
|
invalid,
|
|
353
353
|
testId
|
|
354
|
-
} =
|
|
354
|
+
} = _chunkO3DDOJTBcjs.useUniformField.call(void 0, {
|
|
355
355
|
name,
|
|
356
356
|
showInvalidWhen: "immediate"
|
|
357
357
|
});
|
|
@@ -389,6 +389,7 @@ var FieldArrayValidationError = ({
|
|
|
389
389
|
var FieldArrayValidationError_default = FieldArrayValidationError;
|
|
390
390
|
|
|
391
391
|
// src/FieldArray/subcomponents/SortContext.tsx
|
|
392
|
+
var _reacthookform = require('react-hook-form');
|
|
392
393
|
|
|
393
394
|
|
|
394
395
|
|
|
@@ -408,10 +409,12 @@ var _modifiers = require('@dnd-kit/modifiers');
|
|
|
408
409
|
|
|
409
410
|
var SortContext = ({
|
|
410
411
|
children,
|
|
411
|
-
sortable,
|
|
412
412
|
fields,
|
|
413
|
-
move
|
|
413
|
+
move,
|
|
414
|
+
name,
|
|
415
|
+
sortable
|
|
414
416
|
}) => {
|
|
417
|
+
const { trigger } = _reacthookform.useFormContext.call(void 0, );
|
|
415
418
|
const sensors = _core.useSensors.call(void 0,
|
|
416
419
|
_core.useSensor.call(void 0, _core.PointerSensor),
|
|
417
420
|
_core.useSensor.call(void 0, _core.KeyboardSensor)
|
|
@@ -429,6 +432,7 @@ var SortContext = ({
|
|
|
429
432
|
return field.id === (over == null ? void 0 : over.id);
|
|
430
433
|
});
|
|
431
434
|
move(oldIndex, newIndex);
|
|
435
|
+
trigger(name);
|
|
432
436
|
}
|
|
433
437
|
};
|
|
434
438
|
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
@@ -469,7 +473,9 @@ var fieldArrayVariants = _pixelutils.tv.call(void 0, {
|
|
|
469
473
|
// base styles
|
|
470
474
|
"flex items-center justify-center text-default-600",
|
|
471
475
|
// fixed height/no round corners/center align
|
|
472
|
-
"h-full rounded-none"
|
|
476
|
+
"h-full rounded-none",
|
|
477
|
+
// focus styles - inset ring
|
|
478
|
+
"outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-focus"
|
|
473
479
|
],
|
|
474
480
|
/** class for the append button */
|
|
475
481
|
appendButton: [
|
|
@@ -567,24 +573,31 @@ var FieldArray = (_a) => {
|
|
|
567
573
|
"name",
|
|
568
574
|
"sortable"
|
|
569
575
|
]);
|
|
570
|
-
const { control, error, getValues, invalid, testId } =
|
|
576
|
+
const { control, error, getValues, invalid, testId } = _chunkO3DDOJTBcjs.useUniformField.call(void 0, _chunk555JRYCScjs.__spreadValues.call(void 0, {
|
|
571
577
|
name,
|
|
572
578
|
showInvalidWhen: "immediate"
|
|
573
579
|
}, uniformFieldProps));
|
|
574
|
-
const { fields, append, remove, insert, move } =
|
|
580
|
+
const { fields, append, remove, insert, move } = _chunkO3DDOJTBcjs.useFieldArray.call(void 0, {
|
|
575
581
|
control,
|
|
576
582
|
name
|
|
577
583
|
});
|
|
578
|
-
const { trigger, setValue } =
|
|
584
|
+
const { trigger, setValue } = _chunkO3DDOJTBcjs.useFormContext.call(void 0, );
|
|
579
585
|
_react.useEffect.call(void 0, () => {
|
|
580
586
|
setTimeout(() => {
|
|
581
587
|
trigger(name);
|
|
582
588
|
}, 200);
|
|
583
589
|
}, [fields.length]);
|
|
584
590
|
const elementInitialValue = flat ? { [_chunkZ353BLWIcjs.flatArrayKey]: _elementInitialValue != null ? _elementInitialValue : null } : _elementInitialValue != null ? _elementInitialValue : {};
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
591
|
+
_react.useEffect.call(void 0,
|
|
592
|
+
() => {
|
|
593
|
+
if (lastElementNotRemovable && fields.length === 0) {
|
|
594
|
+
setValue(name, [elementInitialValue]);
|
|
595
|
+
}
|
|
596
|
+
},
|
|
597
|
+
// only run once when the component mounts
|
|
598
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
599
|
+
[]
|
|
600
|
+
);
|
|
588
601
|
const prefersReducedMotion = _pixelmotion.useReducedMotion.call(void 0, );
|
|
589
602
|
const disableAnimationRef = _react.useRef.call(void 0, true);
|
|
590
603
|
_react.useEffect.call(void 0, () => {
|
|
@@ -605,52 +618,61 @@ var FieldArray = (_a) => {
|
|
|
605
618
|
),
|
|
606
619
|
fields.length ? (
|
|
607
620
|
/* list wrapper */
|
|
608
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: _pixelutils.cn.call(void 0, className.listWrapper), children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
const
|
|
617
|
-
const
|
|
618
|
-
const
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
621
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: _pixelutils.cn.call(void 0, className.listWrapper), children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
622
|
+
SortContext_default,
|
|
623
|
+
{
|
|
624
|
+
fields,
|
|
625
|
+
move,
|
|
626
|
+
name,
|
|
627
|
+
sortable,
|
|
628
|
+
children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "ul", { className: className.list, "data-testid": testId, children: fields.map((field, index) => {
|
|
629
|
+
const elementName = flat ? `${name}.${index}.${_chunkZ353BLWIcjs.flatArrayKey}` : `${name}.${index}`;
|
|
630
|
+
const elementTestId = `${testId}_${index}`;
|
|
631
|
+
const elementMethods = {
|
|
632
|
+
append: () => {
|
|
633
|
+
append(elementInitialValue);
|
|
634
|
+
},
|
|
635
|
+
duplicate: () => {
|
|
636
|
+
const values = getValues(name);
|
|
637
|
+
const currentValue = values[index];
|
|
638
|
+
const nextValue = flat ? { [_chunkZ353BLWIcjs.flatArrayKey]: currentValue } : currentValue;
|
|
639
|
+
insert(index + 1, nextValue);
|
|
640
|
+
},
|
|
641
|
+
insert: () => {
|
|
642
|
+
insert(index + 1, elementInitialValue);
|
|
643
|
+
},
|
|
644
|
+
remove: () => {
|
|
645
|
+
remove(index);
|
|
646
|
+
}
|
|
647
|
+
};
|
|
648
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
649
|
+
FieldArrayElement_default,
|
|
650
|
+
{
|
|
651
|
+
className,
|
|
652
|
+
disableAnimation: disableAnimationRef.current,
|
|
653
|
+
duplicate,
|
|
654
|
+
elementMarginBottom,
|
|
655
|
+
fields,
|
|
656
|
+
id: field.id,
|
|
657
|
+
index,
|
|
658
|
+
insertAfter,
|
|
659
|
+
lastNotDeletable: lastElementNotRemovable,
|
|
660
|
+
methods: elementMethods,
|
|
661
|
+
sortable,
|
|
662
|
+
testId: elementTestId,
|
|
663
|
+
children: children({
|
|
664
|
+
index,
|
|
665
|
+
length: fields.length,
|
|
666
|
+
methods: elementMethods,
|
|
667
|
+
name: elementName,
|
|
668
|
+
testId: elementTestId
|
|
669
|
+
})
|
|
670
|
+
},
|
|
671
|
+
field.id
|
|
672
|
+
);
|
|
673
|
+
}) })
|
|
674
|
+
}
|
|
675
|
+
) })
|
|
654
676
|
) : null,
|
|
655
677
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
656
678
|
ElementAppendButton_default,
|
|
@@ -680,4 +702,4 @@ var FieldArray_default2 = FieldArray_default;
|
|
|
680
702
|
|
|
681
703
|
|
|
682
704
|
exports.FieldArray_default = FieldArray_default; exports.FieldArray_default2 = FieldArray_default2;
|
|
683
|
-
//# sourceMappingURL=chunk-
|
|
705
|
+
//# sourceMappingURL=chunk-BOESKBZN.cjs.map
|