@ultraviolet/form 4.0.0-beta.10 → 4.0.0-beta.11

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.
Files changed (33) hide show
  1. package/dist/components/KeyValueField/index.cjs +1 -1
  2. package/dist/components/KeyValueField/index.d.ts +6 -6
  3. package/dist/components/KeyValueField/index.js +1 -1
  4. package/dist/components/NumberInputField/index.cjs +24 -24
  5. package/dist/components/NumberInputField/index.d.ts +3 -9
  6. package/dist/components/NumberInputField/index.js +24 -24
  7. package/dist/components/SelectInputField/index.cjs +19 -71
  8. package/dist/components/SelectInputField/index.d.ts +3 -81
  9. package/dist/components/SelectInputField/index.js +20 -72
  10. package/dist/components/SelectableCardOptionGroupField/index.d.ts +3 -3
  11. package/dist/components/TextInputField/index.cjs +19 -73
  12. package/dist/components/TextInputField/index.d.ts +5 -11
  13. package/dist/components/TextInputField/index.js +19 -73
  14. package/dist/components/{TimeInputFieldV2 → TimeInputField}/index.cjs +3 -3
  15. package/dist/components/TimeInputField/index.d.ts +11 -0
  16. package/dist/components/{TimeInputFieldV2 → TimeInputField}/index.js +4 -4
  17. package/dist/components/index.d.ts +2 -6
  18. package/dist/index.cjs +36 -44
  19. package/dist/index.js +3 -11
  20. package/package.json +3 -3
  21. package/dist/components/NumberInputFieldV2/index.cjs +0 -59
  22. package/dist/components/NumberInputFieldV2/index.d.ts +0 -7
  23. package/dist/components/NumberInputFieldV2/index.js +0 -59
  24. package/dist/components/SelectInputFieldV2/index.cjs +0 -50
  25. package/dist/components/SelectInputFieldV2/index.d.ts +0 -7
  26. package/dist/components/SelectInputFieldV2/index.js +0 -50
  27. package/dist/components/TextInputFieldV2/index.cjs +0 -62
  28. package/dist/components/TextInputFieldV2/index.d.ts +0 -12
  29. package/dist/components/TextInputFieldV2/index.js +0 -62
  30. package/dist/components/TimeField/index.cjs +0 -68
  31. package/dist/components/TimeField/index.d.ts +0 -7
  32. package/dist/components/TimeField/index.js +0 -68
  33. package/dist/components/TimeInputFieldV2/index.d.ts +0 -11
@@ -1,50 +0,0 @@
1
- "use client";
2
- "use strict";
3
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
4
- const jsxRuntime = require("@emotion/react/jsx-runtime");
5
- const ui = require("@ultraviolet/ui");
6
- const react = require("react");
7
- const reactHookForm = require("react-hook-form");
8
- const index = require("../../providers/ErrorContext/index.cjs");
9
- const SelectInputFieldV2 = ({
10
- label = "",
11
- onBlur,
12
- required,
13
- name,
14
- "aria-label": ariaLabel,
15
- shouldUnregister = false,
16
- control,
17
- validate,
18
- onChange,
19
- multiselect,
20
- ...props
21
- }) => {
22
- const {
23
- field,
24
- fieldState: {
25
- error
26
- }
27
- } = reactHookForm.useController({
28
- name,
29
- control,
30
- shouldUnregister,
31
- rules: {
32
- required,
33
- validate
34
- }
35
- });
36
- const {
37
- getError
38
- } = index.useErrors();
39
- const handleChange = react.useCallback((value) => {
40
- onChange?.(value);
41
- field.onChange(value);
42
- }, [onChange, field]);
43
- return /* @__PURE__ */ jsxRuntime.jsx(ui.SelectInputV2, { name: field.name, multiselect, required, onBlur: (event) => {
44
- field.onBlur();
45
- onBlur?.(event);
46
- }, value: field.value, error: getError({
47
- label: label ?? ariaLabel ?? name
48
- }, error), label, "aria-label": ariaLabel, onChange: handleChange, ...props });
49
- };
50
- exports.SelectInputFieldV2 = SelectInputFieldV2;
@@ -1,7 +0,0 @@
1
- import { SelectInputV2 } from '@ultraviolet/ui';
2
- import { type ComponentProps } from 'react';
3
- import type { FieldPath, FieldValues } from 'react-hook-form';
4
- import type { BaseFieldProps } from '../../types';
5
- type SelectInputFieldV2Props<TFieldValues extends FieldValues, TFieldName extends FieldPath<TFieldValues>> = BaseFieldProps<TFieldValues, TFieldName> & Omit<ComponentProps<typeof SelectInputV2>, 'value' | 'onChange'>;
6
- export declare const SelectInputFieldV2: <TFieldValues extends FieldValues, TFieldName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>>({ label, onBlur, required, name, "aria-label": ariaLabel, shouldUnregister, control, validate, onChange, multiselect, ...props }: SelectInputFieldV2Props<TFieldValues, TFieldName>) => import("@emotion/react/jsx-runtime").JSX.Element;
7
- export {};
@@ -1,50 +0,0 @@
1
- "use client";
2
- import { jsx } from "@emotion/react/jsx-runtime";
3
- import { SelectInputV2 } from "@ultraviolet/ui";
4
- import { useCallback } from "react";
5
- import { useController } from "react-hook-form";
6
- import { useErrors } from "../../providers/ErrorContext/index.js";
7
- const SelectInputFieldV2 = ({
8
- label = "",
9
- onBlur,
10
- required,
11
- name,
12
- "aria-label": ariaLabel,
13
- shouldUnregister = false,
14
- control,
15
- validate,
16
- onChange,
17
- multiselect,
18
- ...props
19
- }) => {
20
- const {
21
- field,
22
- fieldState: {
23
- error
24
- }
25
- } = useController({
26
- name,
27
- control,
28
- shouldUnregister,
29
- rules: {
30
- required,
31
- validate
32
- }
33
- });
34
- const {
35
- getError
36
- } = useErrors();
37
- const handleChange = useCallback((value) => {
38
- onChange?.(value);
39
- field.onChange(value);
40
- }, [onChange, field]);
41
- return /* @__PURE__ */ jsx(SelectInputV2, { name: field.name, multiselect, required, onBlur: (event) => {
42
- field.onBlur();
43
- onBlur?.(event);
44
- }, value: field.value, error: getError({
45
- label: label ?? ariaLabel ?? name
46
- }, error), label, "aria-label": ariaLabel, onChange: handleChange, ...props });
47
- };
48
- export {
49
- SelectInputFieldV2
50
- };
@@ -1,62 +0,0 @@
1
- "use client";
2
- "use strict";
3
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
4
- const jsxRuntime = require("@emotion/react/jsx-runtime");
5
- const ui = require("@ultraviolet/ui");
6
- const reactHookForm = require("react-hook-form");
7
- const validateRegex = require("../../utils/validateRegex.cjs");
8
- const index = require("../../providers/ErrorContext/index.cjs");
9
- const TextInputField = ({
10
- regex: regexes,
11
- onChange,
12
- label,
13
- required = false,
14
- name,
15
- onBlur,
16
- minLength,
17
- maxLength,
18
- "aria-label": ariaLabel,
19
- shouldUnregister,
20
- validate,
21
- control,
22
- ...props
23
- }) => {
24
- const {
25
- getError
26
- } = index.useErrors();
27
- const {
28
- field,
29
- fieldState: {
30
- error
31
- }
32
- } = reactHookForm.useController({
33
- name,
34
- shouldUnregister,
35
- control,
36
- rules: {
37
- required,
38
- validate: {
39
- ...regexes ? {
40
- pattern: (value) => validateRegex.validateRegex(value, regexes)
41
- } : {},
42
- ...validate
43
- },
44
- minLength,
45
- maxLength
46
- }
47
- });
48
- return /* @__PURE__ */ jsxRuntime.jsx(ui.TextInputV2, { ...props, error: getError({
49
- regex: regexes,
50
- minLength,
51
- maxLength,
52
- label: label ?? ariaLabel ?? name,
53
- value: field.value
54
- }, error), label, minLength, maxLength, name, onBlur: (event) => {
55
- onBlur?.(event);
56
- field.onBlur();
57
- }, onChange: (event) => {
58
- field.onChange(event);
59
- onChange?.(event.target.value);
60
- }, required, value: field.value === void 0 ? "" : field.value, "aria-label": ariaLabel });
61
- };
62
- exports.TextInputField = TextInputField;
@@ -1,12 +0,0 @@
1
- import { TextInputV2 } from '@ultraviolet/ui';
2
- import type { ComponentProps } from 'react';
3
- import type { FieldPath, FieldValues } from 'react-hook-form';
4
- import type { BaseFieldProps } from '../../types';
5
- type TextInputFieldProps<TFieldValues extends FieldValues, TFieldName extends FieldPath<TFieldValues>> = BaseFieldProps<TFieldValues, TFieldName> & Omit<ComponentProps<typeof TextInputV2>, 'value' | 'error' | 'name' | 'onChange'> & {
6
- regex?: (RegExp | RegExp[])[];
7
- };
8
- /**
9
- * This component offers a form field based on Ultraviolet UI TextInputV2 component
10
- */
11
- export declare const TextInputField: <TFieldValues extends FieldValues, TFieldName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>>({ regex: regexes, onChange, label, required, name, onBlur, minLength, maxLength, "aria-label": ariaLabel, shouldUnregister, validate, control, ...props }: TextInputFieldProps<TFieldValues, TFieldName>) => import("@emotion/react/jsx-runtime").JSX.Element;
12
- export {};
@@ -1,62 +0,0 @@
1
- "use client";
2
- import { jsx } from "@emotion/react/jsx-runtime";
3
- import { TextInputV2 } from "@ultraviolet/ui";
4
- import { useController } from "react-hook-form";
5
- import { validateRegex } from "../../utils/validateRegex.js";
6
- import { useErrors } from "../../providers/ErrorContext/index.js";
7
- const TextInputField = ({
8
- regex: regexes,
9
- onChange,
10
- label,
11
- required = false,
12
- name,
13
- onBlur,
14
- minLength,
15
- maxLength,
16
- "aria-label": ariaLabel,
17
- shouldUnregister,
18
- validate,
19
- control,
20
- ...props
21
- }) => {
22
- const {
23
- getError
24
- } = useErrors();
25
- const {
26
- field,
27
- fieldState: {
28
- error
29
- }
30
- } = useController({
31
- name,
32
- shouldUnregister,
33
- control,
34
- rules: {
35
- required,
36
- validate: {
37
- ...regexes ? {
38
- pattern: (value) => validateRegex(value, regexes)
39
- } : {},
40
- ...validate
41
- },
42
- minLength,
43
- maxLength
44
- }
45
- });
46
- return /* @__PURE__ */ jsx(TextInputV2, { ...props, error: getError({
47
- regex: regexes,
48
- minLength,
49
- maxLength,
50
- label: label ?? ariaLabel ?? name,
51
- value: field.value
52
- }, error), label, minLength, maxLength, name, onBlur: (event) => {
53
- onBlur?.(event);
54
- field.onBlur();
55
- }, onChange: (event) => {
56
- field.onChange(event);
57
- onChange?.(event.target.value);
58
- }, required, value: field.value === void 0 ? "" : field.value, "aria-label": ariaLabel });
59
- };
60
- export {
61
- TextInputField
62
- };
@@ -1,68 +0,0 @@
1
- "use client";
2
- "use strict";
3
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
4
- const jsxRuntime = require("@emotion/react/jsx-runtime");
5
- const ui = require("@ultraviolet/ui");
6
- const reactHookForm = require("react-hook-form");
7
- const parseTime = (date) => {
8
- const timeStr = date && typeof date !== "string" ? date.toLocaleTimeString().slice(0, -3) : "";
9
- return {
10
- label: timeStr,
11
- value: timeStr
12
- };
13
- };
14
- const TimeField = ({
15
- required,
16
- name,
17
- control,
18
- schedule,
19
- placeholder,
20
- disabled,
21
- readOnly,
22
- onBlur,
23
- onFocus,
24
- onChange,
25
- isLoading,
26
- isClearable,
27
- inputId,
28
- id,
29
- animation,
30
- animationDuration,
31
- animationOnChange,
32
- className,
33
- isSearchable,
34
- options,
35
- "data-testid": dataTestId,
36
- shouldUnregister = false,
37
- noTopLabel,
38
- validate
39
- }) => {
40
- const {
41
- field,
42
- fieldState: {
43
- error
44
- }
45
- } = reactHookForm.useController({
46
- name,
47
- control,
48
- shouldUnregister,
49
- rules: {
50
- required,
51
- validate
52
- }
53
- });
54
- return /* @__PURE__ */ jsxRuntime.jsx(ui.TimeInput, { name: field.name, placeholder, schedule, required, value: parseTime(field.value), onChange: (val) => {
55
- if (!val) return;
56
- onChange?.(val);
57
- const [hours, minutes] = val.value.split(":");
58
- const date = field.value ? new Date(field.value) : /* @__PURE__ */ new Date();
59
- date.setHours(Number(hours), Number(minutes), 0);
60
- field.onChange(date);
61
- }, onBlur: (event) => {
62
- field.onBlur();
63
- onBlur?.(event);
64
- }, onFocus: (event) => {
65
- onFocus?.(event);
66
- }, error: error?.message, disabled, readOnly, animation, animationDuration, animationOnChange, className, isLoading, isClearable, isSearchable, inputId, id, options, "data-testid": dataTestId, noTopLabel });
67
- };
68
- exports.TimeField = TimeField;
@@ -1,7 +0,0 @@
1
- import { TimeInput } from '@ultraviolet/ui';
2
- import type { ComponentProps } from 'react';
3
- import type { FieldPath, FieldValues } from 'react-hook-form';
4
- import type { BaseFieldProps } from '../../types';
5
- type TimeFieldProps<TFieldValues extends FieldValues, TFieldName extends FieldPath<TFieldValues>> = BaseFieldProps<TFieldValues, TFieldName> & Omit<ComponentProps<typeof TimeInput>, 'onChange'>;
6
- export declare const TimeField: <TFieldValues extends FieldValues, TFieldName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>>({ required, name, control, schedule, placeholder, disabled, readOnly, onBlur, onFocus, onChange, isLoading, isClearable, inputId, id, animation, animationDuration, animationOnChange, className, isSearchable, options, "data-testid": dataTestId, shouldUnregister, noTopLabel, validate, }: TimeFieldProps<TFieldValues, TFieldName>) => import("@emotion/react/jsx-runtime").JSX.Element;
7
- export {};
@@ -1,68 +0,0 @@
1
- "use client";
2
- import { jsx } from "@emotion/react/jsx-runtime";
3
- import { TimeInput } from "@ultraviolet/ui";
4
- import { useController } from "react-hook-form";
5
- const parseTime = (date) => {
6
- const timeStr = date && typeof date !== "string" ? date.toLocaleTimeString().slice(0, -3) : "";
7
- return {
8
- label: timeStr,
9
- value: timeStr
10
- };
11
- };
12
- const TimeField = ({
13
- required,
14
- name,
15
- control,
16
- schedule,
17
- placeholder,
18
- disabled,
19
- readOnly,
20
- onBlur,
21
- onFocus,
22
- onChange,
23
- isLoading,
24
- isClearable,
25
- inputId,
26
- id,
27
- animation,
28
- animationDuration,
29
- animationOnChange,
30
- className,
31
- isSearchable,
32
- options,
33
- "data-testid": dataTestId,
34
- shouldUnregister = false,
35
- noTopLabel,
36
- validate
37
- }) => {
38
- const {
39
- field,
40
- fieldState: {
41
- error
42
- }
43
- } = useController({
44
- name,
45
- control,
46
- shouldUnregister,
47
- rules: {
48
- required,
49
- validate
50
- }
51
- });
52
- return /* @__PURE__ */ jsx(TimeInput, { name: field.name, placeholder, schedule, required, value: parseTime(field.value), onChange: (val) => {
53
- if (!val) return;
54
- onChange?.(val);
55
- const [hours, minutes] = val.value.split(":");
56
- const date = field.value ? new Date(field.value) : /* @__PURE__ */ new Date();
57
- date.setHours(Number(hours), Number(minutes), 0);
58
- field.onChange(date);
59
- }, onBlur: (event) => {
60
- field.onBlur();
61
- onBlur?.(event);
62
- }, onFocus: (event) => {
63
- onFocus?.(event);
64
- }, error: error?.message, disabled, readOnly, animation, animationDuration, animationOnChange, className, isLoading, isClearable, isSearchable, inputId, id, options, "data-testid": dataTestId, noTopLabel });
65
- };
66
- export {
67
- TimeField
68
- };
@@ -1,11 +0,0 @@
1
- import { TimeInputV2 } from '@ultraviolet/ui';
2
- import type { ComponentProps } from 'react';
3
- import type { FieldPath, FieldValues } from 'react-hook-form';
4
- import type { BaseFieldProps } from '../../types';
5
- type TimeInputFieldProps<TFieldValues extends FieldValues, TFieldName extends FieldPath<TFieldValues>> = BaseFieldProps<TFieldValues, TFieldName> & Omit<ComponentProps<typeof TimeInputV2>, 'value' | 'error' | 'name' | 'onChange'>;
6
- /**
7
- * This component offers a form field based on Ultraviolet UI TimeInputV2 component
8
- * @experimental This component is experimental and may be subject to breaking changes in the future.
9
- */
10
- export declare const TimeInputFieldV2: <TFieldValues extends FieldValues, TFieldName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>>({ onChange, label, required, name, onBlur, "aria-label": ariaLabel, shouldUnregister, control, ...props }: TimeInputFieldProps<TFieldValues, TFieldName>) => import("@emotion/react/jsx-runtime").JSX.Element;
11
- export {};