@umami/react-zen 0.127.0 → 0.128.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +12 -6
- package/dist/index.d.ts +12 -6
- package/dist/index.js +246 -4
- package/dist/index.mjs +246 -4
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -152,6 +152,12 @@ interface FormFieldProps extends HTMLAttributes<HTMLDivElement>, Partial<UseForm
|
|
|
152
152
|
}
|
|
153
153
|
declare function FormField({ name, description, label, rules, className, children, ...props }: FormFieldProps): react.JSX.Element;
|
|
154
154
|
|
|
155
|
+
interface FormFieldArrayProps {
|
|
156
|
+
name: string;
|
|
157
|
+
children: (props: any) => ReactNode;
|
|
158
|
+
}
|
|
159
|
+
declare function FormFieldArray({ name, children }: FormFieldArrayProps): ReactNode;
|
|
160
|
+
|
|
155
161
|
interface ButtonProps extends ButtonProps$1 {
|
|
156
162
|
variant?: 'primary' | 'secondary' | 'outline' | 'quiet' | 'danger' | 'zero';
|
|
157
163
|
size?: 'xs' | 'sm' | 'md' | 'lg' | 'xl';
|
|
@@ -311,7 +317,7 @@ interface ContainerProps extends BoxProps {
|
|
|
311
317
|
declare function Container({ isCentered, isFluid, className, children, ...props }: ContainerProps): react.JSX.Element;
|
|
312
318
|
|
|
313
319
|
interface ConfirmationDialogProps extends AlertDialogProps {
|
|
314
|
-
value
|
|
320
|
+
value: string;
|
|
315
321
|
confirmMessage?: ReactNode;
|
|
316
322
|
}
|
|
317
323
|
declare function ConfirmationDialog({ value, confirmMessage, className, children, ...props }: ConfirmationDialogProps): react.JSX.Element;
|
|
@@ -502,14 +508,14 @@ declare function PasswordField({ label, className, ...props }: PasswordFieldProp
|
|
|
502
508
|
declare function Popover({ children, className, ...props }: PopoverProps): react.JSX.Element;
|
|
503
509
|
|
|
504
510
|
interface ProgressBarProps extends ProgressBarProps$1 {
|
|
505
|
-
|
|
511
|
+
showPercentage?: boolean;
|
|
506
512
|
}
|
|
507
|
-
declare function ProgressBar({ className,
|
|
513
|
+
declare function ProgressBar({ className, showPercentage, ...props }: ProgressBarProps): react.JSX.Element;
|
|
508
514
|
|
|
509
515
|
interface ProgressCircleProps extends ProgressBarProps$1 {
|
|
510
|
-
|
|
516
|
+
showPercentage?: boolean;
|
|
511
517
|
}
|
|
512
|
-
declare function ProgressCircle({ className,
|
|
518
|
+
declare function ProgressCircle({ className, showPercentage, ...props }: ProgressCircleProps): react.JSX.Element;
|
|
513
519
|
|
|
514
520
|
interface RadioGroupProps extends RadioGroupProps$1 {
|
|
515
521
|
label?: string;
|
|
@@ -680,4 +686,4 @@ interface ZenProviderProps {
|
|
|
680
686
|
}
|
|
681
687
|
declare function ZenProvider({ children, ...props }: ZenProviderProps): react.JSX.Element;
|
|
682
688
|
|
|
683
|
-
export { Accordion, AccordionItem, type AccordionItemProps, type AccordionProps, AlertBanner, type AlertBannerProps, AlertDialog, type AlertDialogProps, Blockquote, type BlockquoteProps, Box, type BoxProps, Breadcrumb, Breadcrumbs, Button, type ButtonProps, Calendar, type CalendarProps, Checkbox, type CheckboxProps, Code, type CodeProps, Column, type ColumnProps, ConfirmationDialog, type ConfirmationDialogProps, Container, type ContainerProps, DataColumn, type DataColumnProps, DataTable, type DataTableProps, Dialog, type DialogProps, Dots, type DotsProps, Flexbox, type FlexboxProps, FloatingTooltip, type FloatingTooltipProps, Form, FormButtons, type FormButtonsProps, FormField, type FormFieldProps, type FormProps, FormResetButton, type FormResetButtonProps, FormSubmitButton, Grid, type GridProps, Heading, type HeadingProps, type HoverButtonProps, HoverTrigger, Icon, type IconProps, Image, type ImageProps, InlineEditField, type InlineEditFieldProps, Label, type LabelProps, List, ListItem, type ListItemProps, type ListProps, ListSection, type ListSectionProps, ListSeparator, Loading, LoadingButton, type LoadingButtonProps, type LoadingProps, Menu, MenuItem, type MenuItemProps, type MenuProps, MenuSection, type MenuSectionProps, MenuSeparator, Modal, type ModalProps, NavMenu, NavMenuItem, type NavMenuItemProps, type NavMenuProps, Navbar, NavbarContext, NavbarItem, type NavbarItemProps, type NavbarProps, type NavigationContext, PasswordField, type PasswordFieldProps, Popover, ProgressBar, type ProgressBarProps, ProgressCircle, type ProgressCircleProps, Radio, RadioGroup, type RadioGroupProps, Row, type RowProps, SearchField, type SearchFieldProps, Select, type SelectProps, Sidebar, SidebarHeader, SidebarItem, type SidebarItemProps, type SidebarProps, SidebarSection, Slider, type SliderProps, Slot, Spinner, type SpinnerProps, StatusLight, type StatusLightProps, Switch, type SwitchProps, Tab, TabList, TabPanel, Table, TableBody, TableCell, type TableCellProps, TableColumn, type TableColumnProps, TableHeader, TableRow, Tabs, Text, TextField, type TextFieldProps, type TextProps, ThemeButton, type ThemeButtonProps, Toast, type ToastProps, ToastProvider, type ToastProviderProps, Toaster, type ToasterProps, Toggle, ToggleGroup, ToggleGroupItem, type ToggleGroupItemProps, type ToggleGroupProps, type ToggleProps, Tooltip, TooltipBubble, type TooltipBubbleProps, type TooltipProps, ZenProvider, type ZenProviderProps, useDebounce, useNavigationContext, useTheme, useToast };
|
|
689
|
+
export { Accordion, AccordionItem, type AccordionItemProps, type AccordionProps, AlertBanner, type AlertBannerProps, AlertDialog, type AlertDialogProps, Blockquote, type BlockquoteProps, Box, type BoxProps, Breadcrumb, Breadcrumbs, Button, type ButtonProps, Calendar, type CalendarProps, Checkbox, type CheckboxProps, Code, type CodeProps, Column, type ColumnProps, ConfirmationDialog, type ConfirmationDialogProps, Container, type ContainerProps, DataColumn, type DataColumnProps, DataTable, type DataTableProps, Dialog, type DialogProps, Dots, type DotsProps, Flexbox, type FlexboxProps, FloatingTooltip, type FloatingTooltipProps, Form, FormButtons, type FormButtonsProps, FormField, FormFieldArray, type FormFieldArrayProps, type FormFieldProps, type FormProps, FormResetButton, type FormResetButtonProps, FormSubmitButton, Grid, type GridProps, Heading, type HeadingProps, type HoverButtonProps, HoverTrigger, Icon, type IconProps, Image, type ImageProps, InlineEditField, type InlineEditFieldProps, Label, type LabelProps, List, ListItem, type ListItemProps, type ListProps, ListSection, type ListSectionProps, ListSeparator, Loading, LoadingButton, type LoadingButtonProps, type LoadingProps, Menu, MenuItem, type MenuItemProps, type MenuProps, MenuSection, type MenuSectionProps, MenuSeparator, Modal, type ModalProps, NavMenu, NavMenuItem, type NavMenuItemProps, type NavMenuProps, Navbar, NavbarContext, NavbarItem, type NavbarItemProps, type NavbarProps, type NavigationContext, PasswordField, type PasswordFieldProps, Popover, ProgressBar, type ProgressBarProps, ProgressCircle, type ProgressCircleProps, Radio, RadioGroup, type RadioGroupProps, Row, type RowProps, SearchField, type SearchFieldProps, Select, type SelectProps, Sidebar, SidebarHeader, SidebarItem, type SidebarItemProps, type SidebarProps, SidebarSection, Slider, type SliderProps, Slot, Spinner, type SpinnerProps, StatusLight, type StatusLightProps, Switch, type SwitchProps, Tab, TabList, TabPanel, Table, TableBody, TableCell, type TableCellProps, TableColumn, type TableColumnProps, TableHeader, TableRow, Tabs, Text, TextField, type TextFieldProps, type TextProps, ThemeButton, type ThemeButtonProps, Toast, type ToastProps, ToastProvider, type ToastProviderProps, Toaster, type ToasterProps, Toggle, ToggleGroup, ToggleGroupItem, type ToggleGroupItemProps, type ToggleGroupProps, type ToggleProps, Tooltip, TooltipBubble, type TooltipBubbleProps, type TooltipProps, ZenProvider, type ZenProviderProps, useDebounce, useNavigationContext, useTheme, useToast };
|
package/dist/index.d.ts
CHANGED
|
@@ -152,6 +152,12 @@ interface FormFieldProps extends HTMLAttributes<HTMLDivElement>, Partial<UseForm
|
|
|
152
152
|
}
|
|
153
153
|
declare function FormField({ name, description, label, rules, className, children, ...props }: FormFieldProps): react.JSX.Element;
|
|
154
154
|
|
|
155
|
+
interface FormFieldArrayProps {
|
|
156
|
+
name: string;
|
|
157
|
+
children: (props: any) => ReactNode;
|
|
158
|
+
}
|
|
159
|
+
declare function FormFieldArray({ name, children }: FormFieldArrayProps): ReactNode;
|
|
160
|
+
|
|
155
161
|
interface ButtonProps extends ButtonProps$1 {
|
|
156
162
|
variant?: 'primary' | 'secondary' | 'outline' | 'quiet' | 'danger' | 'zero';
|
|
157
163
|
size?: 'xs' | 'sm' | 'md' | 'lg' | 'xl';
|
|
@@ -311,7 +317,7 @@ interface ContainerProps extends BoxProps {
|
|
|
311
317
|
declare function Container({ isCentered, isFluid, className, children, ...props }: ContainerProps): react.JSX.Element;
|
|
312
318
|
|
|
313
319
|
interface ConfirmationDialogProps extends AlertDialogProps {
|
|
314
|
-
value
|
|
320
|
+
value: string;
|
|
315
321
|
confirmMessage?: ReactNode;
|
|
316
322
|
}
|
|
317
323
|
declare function ConfirmationDialog({ value, confirmMessage, className, children, ...props }: ConfirmationDialogProps): react.JSX.Element;
|
|
@@ -502,14 +508,14 @@ declare function PasswordField({ label, className, ...props }: PasswordFieldProp
|
|
|
502
508
|
declare function Popover({ children, className, ...props }: PopoverProps): react.JSX.Element;
|
|
503
509
|
|
|
504
510
|
interface ProgressBarProps extends ProgressBarProps$1 {
|
|
505
|
-
|
|
511
|
+
showPercentage?: boolean;
|
|
506
512
|
}
|
|
507
|
-
declare function ProgressBar({ className,
|
|
513
|
+
declare function ProgressBar({ className, showPercentage, ...props }: ProgressBarProps): react.JSX.Element;
|
|
508
514
|
|
|
509
515
|
interface ProgressCircleProps extends ProgressBarProps$1 {
|
|
510
|
-
|
|
516
|
+
showPercentage?: boolean;
|
|
511
517
|
}
|
|
512
|
-
declare function ProgressCircle({ className,
|
|
518
|
+
declare function ProgressCircle({ className, showPercentage, ...props }: ProgressCircleProps): react.JSX.Element;
|
|
513
519
|
|
|
514
520
|
interface RadioGroupProps extends RadioGroupProps$1 {
|
|
515
521
|
label?: string;
|
|
@@ -680,4 +686,4 @@ interface ZenProviderProps {
|
|
|
680
686
|
}
|
|
681
687
|
declare function ZenProvider({ children, ...props }: ZenProviderProps): react.JSX.Element;
|
|
682
688
|
|
|
683
|
-
export { Accordion, AccordionItem, type AccordionItemProps, type AccordionProps, AlertBanner, type AlertBannerProps, AlertDialog, type AlertDialogProps, Blockquote, type BlockquoteProps, Box, type BoxProps, Breadcrumb, Breadcrumbs, Button, type ButtonProps, Calendar, type CalendarProps, Checkbox, type CheckboxProps, Code, type CodeProps, Column, type ColumnProps, ConfirmationDialog, type ConfirmationDialogProps, Container, type ContainerProps, DataColumn, type DataColumnProps, DataTable, type DataTableProps, Dialog, type DialogProps, Dots, type DotsProps, Flexbox, type FlexboxProps, FloatingTooltip, type FloatingTooltipProps, Form, FormButtons, type FormButtonsProps, FormField, type FormFieldProps, type FormProps, FormResetButton, type FormResetButtonProps, FormSubmitButton, Grid, type GridProps, Heading, type HeadingProps, type HoverButtonProps, HoverTrigger, Icon, type IconProps, Image, type ImageProps, InlineEditField, type InlineEditFieldProps, Label, type LabelProps, List, ListItem, type ListItemProps, type ListProps, ListSection, type ListSectionProps, ListSeparator, Loading, LoadingButton, type LoadingButtonProps, type LoadingProps, Menu, MenuItem, type MenuItemProps, type MenuProps, MenuSection, type MenuSectionProps, MenuSeparator, Modal, type ModalProps, NavMenu, NavMenuItem, type NavMenuItemProps, type NavMenuProps, Navbar, NavbarContext, NavbarItem, type NavbarItemProps, type NavbarProps, type NavigationContext, PasswordField, type PasswordFieldProps, Popover, ProgressBar, type ProgressBarProps, ProgressCircle, type ProgressCircleProps, Radio, RadioGroup, type RadioGroupProps, Row, type RowProps, SearchField, type SearchFieldProps, Select, type SelectProps, Sidebar, SidebarHeader, SidebarItem, type SidebarItemProps, type SidebarProps, SidebarSection, Slider, type SliderProps, Slot, Spinner, type SpinnerProps, StatusLight, type StatusLightProps, Switch, type SwitchProps, Tab, TabList, TabPanel, Table, TableBody, TableCell, type TableCellProps, TableColumn, type TableColumnProps, TableHeader, TableRow, Tabs, Text, TextField, type TextFieldProps, type TextProps, ThemeButton, type ThemeButtonProps, Toast, type ToastProps, ToastProvider, type ToastProviderProps, Toaster, type ToasterProps, Toggle, ToggleGroup, ToggleGroupItem, type ToggleGroupItemProps, type ToggleGroupProps, type ToggleProps, Tooltip, TooltipBubble, type TooltipBubbleProps, type TooltipProps, ZenProvider, type ZenProviderProps, useDebounce, useNavigationContext, useTheme, useToast };
|
|
689
|
+
export { Accordion, AccordionItem, type AccordionItemProps, type AccordionProps, AlertBanner, type AlertBannerProps, AlertDialog, type AlertDialogProps, Blockquote, type BlockquoteProps, Box, type BoxProps, Breadcrumb, Breadcrumbs, Button, type ButtonProps, Calendar, type CalendarProps, Checkbox, type CheckboxProps, Code, type CodeProps, Column, type ColumnProps, ConfirmationDialog, type ConfirmationDialogProps, Container, type ContainerProps, DataColumn, type DataColumnProps, DataTable, type DataTableProps, Dialog, type DialogProps, Dots, type DotsProps, Flexbox, type FlexboxProps, FloatingTooltip, type FloatingTooltipProps, Form, FormButtons, type FormButtonsProps, FormField, FormFieldArray, type FormFieldArrayProps, type FormFieldProps, type FormProps, FormResetButton, type FormResetButtonProps, FormSubmitButton, Grid, type GridProps, Heading, type HeadingProps, type HoverButtonProps, HoverTrigger, Icon, type IconProps, Image, type ImageProps, InlineEditField, type InlineEditFieldProps, Label, type LabelProps, List, ListItem, type ListItemProps, type ListProps, ListSection, type ListSectionProps, ListSeparator, Loading, LoadingButton, type LoadingButtonProps, type LoadingProps, Menu, MenuItem, type MenuItemProps, type MenuProps, MenuSection, type MenuSectionProps, MenuSeparator, Modal, type ModalProps, NavMenu, NavMenuItem, type NavMenuItemProps, type NavMenuProps, Navbar, NavbarContext, NavbarItem, type NavbarItemProps, type NavbarProps, type NavigationContext, PasswordField, type PasswordFieldProps, Popover, ProgressBar, type ProgressBarProps, ProgressCircle, type ProgressCircleProps, Radio, RadioGroup, type RadioGroupProps, Row, type RowProps, SearchField, type SearchFieldProps, Select, type SelectProps, Sidebar, SidebarHeader, SidebarItem, type SidebarItemProps, type SidebarProps, SidebarSection, Slider, type SliderProps, Slot, Spinner, type SpinnerProps, StatusLight, type StatusLightProps, Switch, type SwitchProps, Tab, TabList, TabPanel, Table, TableBody, TableCell, type TableCellProps, TableColumn, type TableColumnProps, TableHeader, TableRow, Tabs, Text, TextField, type TextFieldProps, type TextProps, ThemeButton, type ThemeButtonProps, Toast, type ToastProps, ToastProvider, type ToastProviderProps, Toaster, type ToasterProps, Toggle, ToggleGroup, ToggleGroupItem, type ToggleGroupItemProps, type ToggleGroupProps, type ToggleProps, Tooltip, TooltipBubble, type TooltipBubbleProps, type TooltipProps, ZenProvider, type ZenProviderProps, useDebounce, useNavigationContext, useTheme, useToast };
|
package/dist/index.js
CHANGED
|
@@ -251,6 +251,7 @@ __export(index_exports, {
|
|
|
251
251
|
Form: () => Form,
|
|
252
252
|
FormButtons: () => FormButtons,
|
|
253
253
|
FormField: () => FormField,
|
|
254
|
+
FormFieldArray: () => FormFieldArray,
|
|
254
255
|
FormResetButton: () => FormResetButton,
|
|
255
256
|
FormSubmitButton: () => FormSubmitButton,
|
|
256
257
|
Grid: () => Grid,
|
|
@@ -25245,6 +25246,236 @@ function createFormControl(props = {}) {
|
|
|
25245
25246
|
formControl: methods
|
|
25246
25247
|
};
|
|
25247
25248
|
}
|
|
25249
|
+
var generateId = () => {
|
|
25250
|
+
const d = typeof performance === "undefined" ? Date.now() : performance.now() * 1e3;
|
|
25251
|
+
return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (c) => {
|
|
25252
|
+
const r2 = (Math.random() * 16 + d) % 16 | 0;
|
|
25253
|
+
return (c == "x" ? r2 : r2 & 3 | 8).toString(16);
|
|
25254
|
+
});
|
|
25255
|
+
};
|
|
25256
|
+
var getFocusFieldName = (name, index, options = {}) => options.shouldFocus || isUndefined(options.shouldFocus) ? options.focusName || `${name}.${isUndefined(options.focusIndex) ? index : options.focusIndex}.` : "";
|
|
25257
|
+
var appendAt = (data, value) => [
|
|
25258
|
+
...data,
|
|
25259
|
+
...convertToArrayPayload(value)
|
|
25260
|
+
];
|
|
25261
|
+
var fillEmptyArray = (value) => Array.isArray(value) ? value.map(() => void 0) : void 0;
|
|
25262
|
+
function insert(data, index, value) {
|
|
25263
|
+
return [
|
|
25264
|
+
...data.slice(0, index),
|
|
25265
|
+
...convertToArrayPayload(value),
|
|
25266
|
+
...data.slice(index)
|
|
25267
|
+
];
|
|
25268
|
+
}
|
|
25269
|
+
var moveArrayAt = (data, from, to2) => {
|
|
25270
|
+
if (!Array.isArray(data)) {
|
|
25271
|
+
return [];
|
|
25272
|
+
}
|
|
25273
|
+
if (isUndefined(data[to2])) {
|
|
25274
|
+
data[to2] = void 0;
|
|
25275
|
+
}
|
|
25276
|
+
data.splice(to2, 0, data.splice(from, 1)[0]);
|
|
25277
|
+
return data;
|
|
25278
|
+
};
|
|
25279
|
+
var prependAt = (data, value) => [
|
|
25280
|
+
...convertToArrayPayload(value),
|
|
25281
|
+
...convertToArrayPayload(data)
|
|
25282
|
+
];
|
|
25283
|
+
function removeAtIndexes(data, indexes) {
|
|
25284
|
+
let i = 0;
|
|
25285
|
+
const temp = [...data];
|
|
25286
|
+
for (const index of indexes) {
|
|
25287
|
+
temp.splice(index - i, 1);
|
|
25288
|
+
i++;
|
|
25289
|
+
}
|
|
25290
|
+
return compact(temp).length ? temp : [];
|
|
25291
|
+
}
|
|
25292
|
+
var removeArrayAt = (data, index) => isUndefined(index) ? [] : removeAtIndexes(data, convertToArrayPayload(index).sort((a, b) => a - b));
|
|
25293
|
+
var swapArrayAt = (data, indexA, indexB) => {
|
|
25294
|
+
[data[indexA], data[indexB]] = [data[indexB], data[indexA]];
|
|
25295
|
+
};
|
|
25296
|
+
var updateAt = (fieldValues, index, value) => {
|
|
25297
|
+
fieldValues[index] = value;
|
|
25298
|
+
return fieldValues;
|
|
25299
|
+
};
|
|
25300
|
+
function useFieldArray(props) {
|
|
25301
|
+
const methods = useFormContext();
|
|
25302
|
+
const { control = methods.control, name, keyName = "id", shouldUnregister, rules } = props;
|
|
25303
|
+
const [fields, setFields] = import_react147.default.useState(control._getFieldArray(name));
|
|
25304
|
+
const ids = import_react147.default.useRef(control._getFieldArray(name).map(generateId));
|
|
25305
|
+
const _fieldIds = import_react147.default.useRef(fields);
|
|
25306
|
+
const _name = import_react147.default.useRef(name);
|
|
25307
|
+
const _actioned = import_react147.default.useRef(false);
|
|
25308
|
+
_name.current = name;
|
|
25309
|
+
_fieldIds.current = fields;
|
|
25310
|
+
control._names.array.add(name);
|
|
25311
|
+
rules && control.register(name, rules);
|
|
25312
|
+
import_react147.default.useEffect(() => control._subjects.array.subscribe({
|
|
25313
|
+
next: ({ values, name: fieldArrayName }) => {
|
|
25314
|
+
if (fieldArrayName === _name.current || !fieldArrayName) {
|
|
25315
|
+
const fieldValues = get(values, _name.current);
|
|
25316
|
+
if (Array.isArray(fieldValues)) {
|
|
25317
|
+
setFields(fieldValues);
|
|
25318
|
+
ids.current = fieldValues.map(generateId);
|
|
25319
|
+
}
|
|
25320
|
+
}
|
|
25321
|
+
}
|
|
25322
|
+
}).unsubscribe, [control]);
|
|
25323
|
+
const updateValues = import_react147.default.useCallback((updatedFieldArrayValues) => {
|
|
25324
|
+
_actioned.current = true;
|
|
25325
|
+
control._setFieldArray(name, updatedFieldArrayValues);
|
|
25326
|
+
}, [control, name]);
|
|
25327
|
+
const append = (value, options) => {
|
|
25328
|
+
const appendValue = convertToArrayPayload(cloneObject(value));
|
|
25329
|
+
const updatedFieldArrayValues = appendAt(control._getFieldArray(name), appendValue);
|
|
25330
|
+
control._names.focus = getFocusFieldName(name, updatedFieldArrayValues.length - 1, options);
|
|
25331
|
+
ids.current = appendAt(ids.current, appendValue.map(generateId));
|
|
25332
|
+
updateValues(updatedFieldArrayValues);
|
|
25333
|
+
setFields(updatedFieldArrayValues);
|
|
25334
|
+
control._setFieldArray(name, updatedFieldArrayValues, appendAt, {
|
|
25335
|
+
argA: fillEmptyArray(value)
|
|
25336
|
+
});
|
|
25337
|
+
};
|
|
25338
|
+
const prepend = (value, options) => {
|
|
25339
|
+
const prependValue = convertToArrayPayload(cloneObject(value));
|
|
25340
|
+
const updatedFieldArrayValues = prependAt(control._getFieldArray(name), prependValue);
|
|
25341
|
+
control._names.focus = getFocusFieldName(name, 0, options);
|
|
25342
|
+
ids.current = prependAt(ids.current, prependValue.map(generateId));
|
|
25343
|
+
updateValues(updatedFieldArrayValues);
|
|
25344
|
+
setFields(updatedFieldArrayValues);
|
|
25345
|
+
control._setFieldArray(name, updatedFieldArrayValues, prependAt, {
|
|
25346
|
+
argA: fillEmptyArray(value)
|
|
25347
|
+
});
|
|
25348
|
+
};
|
|
25349
|
+
const remove = (index) => {
|
|
25350
|
+
const updatedFieldArrayValues = removeArrayAt(control._getFieldArray(name), index);
|
|
25351
|
+
ids.current = removeArrayAt(ids.current, index);
|
|
25352
|
+
updateValues(updatedFieldArrayValues);
|
|
25353
|
+
setFields(updatedFieldArrayValues);
|
|
25354
|
+
!Array.isArray(get(control._fields, name)) && set(control._fields, name, void 0);
|
|
25355
|
+
control._setFieldArray(name, updatedFieldArrayValues, removeArrayAt, {
|
|
25356
|
+
argA: index
|
|
25357
|
+
});
|
|
25358
|
+
};
|
|
25359
|
+
const insert$1 = (index, value, options) => {
|
|
25360
|
+
const insertValue = convertToArrayPayload(cloneObject(value));
|
|
25361
|
+
const updatedFieldArrayValues = insert(control._getFieldArray(name), index, insertValue);
|
|
25362
|
+
control._names.focus = getFocusFieldName(name, index, options);
|
|
25363
|
+
ids.current = insert(ids.current, index, insertValue.map(generateId));
|
|
25364
|
+
updateValues(updatedFieldArrayValues);
|
|
25365
|
+
setFields(updatedFieldArrayValues);
|
|
25366
|
+
control._setFieldArray(name, updatedFieldArrayValues, insert, {
|
|
25367
|
+
argA: index,
|
|
25368
|
+
argB: fillEmptyArray(value)
|
|
25369
|
+
});
|
|
25370
|
+
};
|
|
25371
|
+
const swap = (indexA, indexB) => {
|
|
25372
|
+
const updatedFieldArrayValues = control._getFieldArray(name);
|
|
25373
|
+
swapArrayAt(updatedFieldArrayValues, indexA, indexB);
|
|
25374
|
+
swapArrayAt(ids.current, indexA, indexB);
|
|
25375
|
+
updateValues(updatedFieldArrayValues);
|
|
25376
|
+
setFields(updatedFieldArrayValues);
|
|
25377
|
+
control._setFieldArray(name, updatedFieldArrayValues, swapArrayAt, {
|
|
25378
|
+
argA: indexA,
|
|
25379
|
+
argB: indexB
|
|
25380
|
+
}, false);
|
|
25381
|
+
};
|
|
25382
|
+
const move = (from, to2) => {
|
|
25383
|
+
const updatedFieldArrayValues = control._getFieldArray(name);
|
|
25384
|
+
moveArrayAt(updatedFieldArrayValues, from, to2);
|
|
25385
|
+
moveArrayAt(ids.current, from, to2);
|
|
25386
|
+
updateValues(updatedFieldArrayValues);
|
|
25387
|
+
setFields(updatedFieldArrayValues);
|
|
25388
|
+
control._setFieldArray(name, updatedFieldArrayValues, moveArrayAt, {
|
|
25389
|
+
argA: from,
|
|
25390
|
+
argB: to2
|
|
25391
|
+
}, false);
|
|
25392
|
+
};
|
|
25393
|
+
const update3 = (index, value) => {
|
|
25394
|
+
const updateValue = cloneObject(value);
|
|
25395
|
+
const updatedFieldArrayValues = updateAt(control._getFieldArray(name), index, updateValue);
|
|
25396
|
+
ids.current = [...updatedFieldArrayValues].map((item, i) => !item || i === index ? generateId() : ids.current[i]);
|
|
25397
|
+
updateValues(updatedFieldArrayValues);
|
|
25398
|
+
setFields([...updatedFieldArrayValues]);
|
|
25399
|
+
control._setFieldArray(name, updatedFieldArrayValues, updateAt, {
|
|
25400
|
+
argA: index,
|
|
25401
|
+
argB: updateValue
|
|
25402
|
+
}, true, false);
|
|
25403
|
+
};
|
|
25404
|
+
const replace = (value) => {
|
|
25405
|
+
const updatedFieldArrayValues = convertToArrayPayload(cloneObject(value));
|
|
25406
|
+
ids.current = updatedFieldArrayValues.map(generateId);
|
|
25407
|
+
updateValues([...updatedFieldArrayValues]);
|
|
25408
|
+
setFields([...updatedFieldArrayValues]);
|
|
25409
|
+
control._setFieldArray(name, [...updatedFieldArrayValues], (data) => data, {}, true, false);
|
|
25410
|
+
};
|
|
25411
|
+
import_react147.default.useEffect(() => {
|
|
25412
|
+
control._state.action = false;
|
|
25413
|
+
isWatched(name, control._names) && control._subjects.state.next({
|
|
25414
|
+
...control._formState
|
|
25415
|
+
});
|
|
25416
|
+
if (_actioned.current && (!getValidationModes(control._options.mode).isOnSubmit || control._formState.isSubmitted) && !getValidationModes(control._options.reValidateMode).isOnSubmit) {
|
|
25417
|
+
if (control._options.resolver) {
|
|
25418
|
+
control._runSchema([name]).then((result) => {
|
|
25419
|
+
const error = get(result.errors, name);
|
|
25420
|
+
const existingError = get(control._formState.errors, name);
|
|
25421
|
+
if (existingError ? !error && existingError.type || error && (existingError.type !== error.type || existingError.message !== error.message) : error && error.type) {
|
|
25422
|
+
error ? set(control._formState.errors, name, error) : unset(control._formState.errors, name);
|
|
25423
|
+
control._subjects.state.next({
|
|
25424
|
+
errors: control._formState.errors
|
|
25425
|
+
});
|
|
25426
|
+
}
|
|
25427
|
+
});
|
|
25428
|
+
} else {
|
|
25429
|
+
const field = get(control._fields, name);
|
|
25430
|
+
if (field && field._f && !(getValidationModes(control._options.reValidateMode).isOnSubmit && getValidationModes(control._options.mode).isOnSubmit)) {
|
|
25431
|
+
validateField(field, control._names.disabled, control._formValues, control._options.criteriaMode === VALIDATION_MODE.all, control._options.shouldUseNativeValidation, true).then((error) => !isEmptyObject(error) && control._subjects.state.next({
|
|
25432
|
+
errors: updateFieldArrayRootError(control._formState.errors, error, name)
|
|
25433
|
+
}));
|
|
25434
|
+
}
|
|
25435
|
+
}
|
|
25436
|
+
}
|
|
25437
|
+
control._subjects.state.next({
|
|
25438
|
+
name,
|
|
25439
|
+
values: cloneObject(control._formValues)
|
|
25440
|
+
});
|
|
25441
|
+
control._names.focus && iterateFieldsByAction(control._fields, (ref, key) => {
|
|
25442
|
+
if (control._names.focus && key.startsWith(control._names.focus) && ref.focus) {
|
|
25443
|
+
ref.focus();
|
|
25444
|
+
return 1;
|
|
25445
|
+
}
|
|
25446
|
+
return;
|
|
25447
|
+
});
|
|
25448
|
+
control._names.focus = "";
|
|
25449
|
+
control._setValid();
|
|
25450
|
+
_actioned.current = false;
|
|
25451
|
+
}, [fields, name, control]);
|
|
25452
|
+
import_react147.default.useEffect(() => {
|
|
25453
|
+
!get(control._formValues, name) && control._setFieldArray(name);
|
|
25454
|
+
return () => {
|
|
25455
|
+
const updateMounted = (name2, value) => {
|
|
25456
|
+
const field = get(control._fields, name2);
|
|
25457
|
+
if (field && field._f) {
|
|
25458
|
+
field._f.mount = value;
|
|
25459
|
+
}
|
|
25460
|
+
};
|
|
25461
|
+
control._options.shouldUnregister || shouldUnregister ? control.unregister(name) : updateMounted(name, false);
|
|
25462
|
+
};
|
|
25463
|
+
}, [name, control, keyName, shouldUnregister]);
|
|
25464
|
+
return {
|
|
25465
|
+
swap: import_react147.default.useCallback(swap, [updateValues, name, control]),
|
|
25466
|
+
move: import_react147.default.useCallback(move, [updateValues, name, control]),
|
|
25467
|
+
prepend: import_react147.default.useCallback(prepend, [updateValues, name, control]),
|
|
25468
|
+
append: import_react147.default.useCallback(append, [updateValues, name, control]),
|
|
25469
|
+
remove: import_react147.default.useCallback(remove, [updateValues, name, control]),
|
|
25470
|
+
insert: import_react147.default.useCallback(insert$1, [updateValues, name, control]),
|
|
25471
|
+
update: import_react147.default.useCallback(update3, [updateValues, name, control]),
|
|
25472
|
+
replace: import_react147.default.useCallback(replace, [updateValues, name, control]),
|
|
25473
|
+
fields: import_react147.default.useMemo(() => fields.map((field, index) => ({
|
|
25474
|
+
...field,
|
|
25475
|
+
[keyName]: ids.current[index] || generateId()
|
|
25476
|
+
})), [fields, keyName])
|
|
25477
|
+
};
|
|
25478
|
+
}
|
|
25248
25479
|
function useForm(props = {}) {
|
|
25249
25480
|
const _formControl = import_react147.default.useRef(void 0);
|
|
25250
25481
|
const _values = import_react147.default.useRef(void 0);
|
|
@@ -26132,6 +26363,17 @@ function FormField({
|
|
|
26132
26363
|
] });
|
|
26133
26364
|
}
|
|
26134
26365
|
|
|
26366
|
+
// src/components/forms/FormFieldArray.tsx
|
|
26367
|
+
function FormFieldArray({ name, children }) {
|
|
26368
|
+
const context = useFormContext();
|
|
26369
|
+
const { control } = context;
|
|
26370
|
+
const { fields, append, prepend, remove, swap, move, insert: insert2 } = useFieldArray({
|
|
26371
|
+
control,
|
|
26372
|
+
name
|
|
26373
|
+
});
|
|
26374
|
+
return children({ context, fields, append, prepend, remove, swap, move, insert: insert2 });
|
|
26375
|
+
}
|
|
26376
|
+
|
|
26135
26377
|
// src/components/Button.tsx
|
|
26136
26378
|
var import_classnames7 = __toESM(require_classnames());
|
|
26137
26379
|
|
|
@@ -31193,11 +31435,11 @@ var ProgressBar_default = { "progressbar": "ProgressBar_progressbar__YzdlO", "tr
|
|
|
31193
31435
|
|
|
31194
31436
|
// src/components/ProgressBar.tsx
|
|
31195
31437
|
var import_jsx_runtime54 = require("react/jsx-runtime");
|
|
31196
|
-
function ProgressBar2({ className,
|
|
31438
|
+
function ProgressBar2({ className, showPercentage, ...props }) {
|
|
31197
31439
|
return /* @__PURE__ */ (0, import_jsx_runtime54.jsx)($0393f8ab869a0f1a$export$c17561cb55d4db30, { ...props, className: (0, import_classnames40.default)(ProgressBar_default.progressbar, className), children: ({ percentage = 0, valueText }) => {
|
|
31198
31440
|
return /* @__PURE__ */ (0, import_jsx_runtime54.jsxs)(import_jsx_runtime54.Fragment, { children: [
|
|
31199
31441
|
/* @__PURE__ */ (0, import_jsx_runtime54.jsx)("div", { className: ProgressBar_default.track, children: /* @__PURE__ */ (0, import_jsx_runtime54.jsx)("div", { className: ProgressBar_default.fill, style: { width: `${percentage}%` } }) }),
|
|
31200
|
-
|
|
31442
|
+
showPercentage && /* @__PURE__ */ (0, import_jsx_runtime54.jsx)("div", { className: ProgressBar_default.value, children: valueText })
|
|
31201
31443
|
] });
|
|
31202
31444
|
} });
|
|
31203
31445
|
}
|
|
@@ -31210,7 +31452,7 @@ var ProgressCircle_default = { "progresscircle": "ProgressCircle_progresscircle_
|
|
|
31210
31452
|
|
|
31211
31453
|
// src/components/ProgressCircle.tsx
|
|
31212
31454
|
var import_jsx_runtime55 = require("react/jsx-runtime");
|
|
31213
|
-
function ProgressCircle({ className,
|
|
31455
|
+
function ProgressCircle({ className, showPercentage, ...props }) {
|
|
31214
31456
|
return /* @__PURE__ */ (0, import_jsx_runtime55.jsx)($0393f8ab869a0f1a$export$c17561cb55d4db30, { ...props, className: (0, import_classnames41.default)(ProgressCircle_default.progresscircle, className), children: ({ percentage = 0, valueText }) => {
|
|
31215
31457
|
const radius = 45;
|
|
31216
31458
|
const circumference = radius * 2 * Math.PI;
|
|
@@ -31230,7 +31472,7 @@ function ProgressCircle({ className, showValue, ...props }) {
|
|
|
31230
31472
|
}
|
|
31231
31473
|
)
|
|
31232
31474
|
] }),
|
|
31233
|
-
|
|
31475
|
+
showPercentage && /* @__PURE__ */ (0, import_jsx_runtime55.jsx)("label", { className: ProgressCircle_default.value, children: valueText })
|
|
31234
31476
|
] });
|
|
31235
31477
|
} });
|
|
31236
31478
|
}
|
package/dist/index.mjs
CHANGED
|
@@ -25132,6 +25132,236 @@ function createFormControl(props = {}) {
|
|
|
25132
25132
|
formControl: methods
|
|
25133
25133
|
};
|
|
25134
25134
|
}
|
|
25135
|
+
var generateId = () => {
|
|
25136
|
+
const d = typeof performance === "undefined" ? Date.now() : performance.now() * 1e3;
|
|
25137
|
+
return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (c) => {
|
|
25138
|
+
const r2 = (Math.random() * 16 + d) % 16 | 0;
|
|
25139
|
+
return (c == "x" ? r2 : r2 & 3 | 8).toString(16);
|
|
25140
|
+
});
|
|
25141
|
+
};
|
|
25142
|
+
var getFocusFieldName = (name, index, options = {}) => options.shouldFocus || isUndefined(options.shouldFocus) ? options.focusName || `${name}.${isUndefined(options.focusIndex) ? index : options.focusIndex}.` : "";
|
|
25143
|
+
var appendAt = (data, value) => [
|
|
25144
|
+
...data,
|
|
25145
|
+
...convertToArrayPayload(value)
|
|
25146
|
+
];
|
|
25147
|
+
var fillEmptyArray = (value) => Array.isArray(value) ? value.map(() => void 0) : void 0;
|
|
25148
|
+
function insert(data, index, value) {
|
|
25149
|
+
return [
|
|
25150
|
+
...data.slice(0, index),
|
|
25151
|
+
...convertToArrayPayload(value),
|
|
25152
|
+
...data.slice(index)
|
|
25153
|
+
];
|
|
25154
|
+
}
|
|
25155
|
+
var moveArrayAt = (data, from, to2) => {
|
|
25156
|
+
if (!Array.isArray(data)) {
|
|
25157
|
+
return [];
|
|
25158
|
+
}
|
|
25159
|
+
if (isUndefined(data[to2])) {
|
|
25160
|
+
data[to2] = void 0;
|
|
25161
|
+
}
|
|
25162
|
+
data.splice(to2, 0, data.splice(from, 1)[0]);
|
|
25163
|
+
return data;
|
|
25164
|
+
};
|
|
25165
|
+
var prependAt = (data, value) => [
|
|
25166
|
+
...convertToArrayPayload(value),
|
|
25167
|
+
...convertToArrayPayload(data)
|
|
25168
|
+
];
|
|
25169
|
+
function removeAtIndexes(data, indexes) {
|
|
25170
|
+
let i = 0;
|
|
25171
|
+
const temp = [...data];
|
|
25172
|
+
for (const index of indexes) {
|
|
25173
|
+
temp.splice(index - i, 1);
|
|
25174
|
+
i++;
|
|
25175
|
+
}
|
|
25176
|
+
return compact(temp).length ? temp : [];
|
|
25177
|
+
}
|
|
25178
|
+
var removeArrayAt = (data, index) => isUndefined(index) ? [] : removeAtIndexes(data, convertToArrayPayload(index).sort((a, b) => a - b));
|
|
25179
|
+
var swapArrayAt = (data, indexA, indexB) => {
|
|
25180
|
+
[data[indexA], data[indexB]] = [data[indexB], data[indexA]];
|
|
25181
|
+
};
|
|
25182
|
+
var updateAt = (fieldValues, index, value) => {
|
|
25183
|
+
fieldValues[index] = value;
|
|
25184
|
+
return fieldValues;
|
|
25185
|
+
};
|
|
25186
|
+
function useFieldArray(props) {
|
|
25187
|
+
const methods = useFormContext();
|
|
25188
|
+
const { control = methods.control, name, keyName = "id", shouldUnregister, rules } = props;
|
|
25189
|
+
const [fields, setFields] = React__default.useState(control._getFieldArray(name));
|
|
25190
|
+
const ids = React__default.useRef(control._getFieldArray(name).map(generateId));
|
|
25191
|
+
const _fieldIds = React__default.useRef(fields);
|
|
25192
|
+
const _name = React__default.useRef(name);
|
|
25193
|
+
const _actioned = React__default.useRef(false);
|
|
25194
|
+
_name.current = name;
|
|
25195
|
+
_fieldIds.current = fields;
|
|
25196
|
+
control._names.array.add(name);
|
|
25197
|
+
rules && control.register(name, rules);
|
|
25198
|
+
React__default.useEffect(() => control._subjects.array.subscribe({
|
|
25199
|
+
next: ({ values, name: fieldArrayName }) => {
|
|
25200
|
+
if (fieldArrayName === _name.current || !fieldArrayName) {
|
|
25201
|
+
const fieldValues = get(values, _name.current);
|
|
25202
|
+
if (Array.isArray(fieldValues)) {
|
|
25203
|
+
setFields(fieldValues);
|
|
25204
|
+
ids.current = fieldValues.map(generateId);
|
|
25205
|
+
}
|
|
25206
|
+
}
|
|
25207
|
+
}
|
|
25208
|
+
}).unsubscribe, [control]);
|
|
25209
|
+
const updateValues = React__default.useCallback((updatedFieldArrayValues) => {
|
|
25210
|
+
_actioned.current = true;
|
|
25211
|
+
control._setFieldArray(name, updatedFieldArrayValues);
|
|
25212
|
+
}, [control, name]);
|
|
25213
|
+
const append = (value, options) => {
|
|
25214
|
+
const appendValue = convertToArrayPayload(cloneObject(value));
|
|
25215
|
+
const updatedFieldArrayValues = appendAt(control._getFieldArray(name), appendValue);
|
|
25216
|
+
control._names.focus = getFocusFieldName(name, updatedFieldArrayValues.length - 1, options);
|
|
25217
|
+
ids.current = appendAt(ids.current, appendValue.map(generateId));
|
|
25218
|
+
updateValues(updatedFieldArrayValues);
|
|
25219
|
+
setFields(updatedFieldArrayValues);
|
|
25220
|
+
control._setFieldArray(name, updatedFieldArrayValues, appendAt, {
|
|
25221
|
+
argA: fillEmptyArray(value)
|
|
25222
|
+
});
|
|
25223
|
+
};
|
|
25224
|
+
const prepend = (value, options) => {
|
|
25225
|
+
const prependValue = convertToArrayPayload(cloneObject(value));
|
|
25226
|
+
const updatedFieldArrayValues = prependAt(control._getFieldArray(name), prependValue);
|
|
25227
|
+
control._names.focus = getFocusFieldName(name, 0, options);
|
|
25228
|
+
ids.current = prependAt(ids.current, prependValue.map(generateId));
|
|
25229
|
+
updateValues(updatedFieldArrayValues);
|
|
25230
|
+
setFields(updatedFieldArrayValues);
|
|
25231
|
+
control._setFieldArray(name, updatedFieldArrayValues, prependAt, {
|
|
25232
|
+
argA: fillEmptyArray(value)
|
|
25233
|
+
});
|
|
25234
|
+
};
|
|
25235
|
+
const remove = (index) => {
|
|
25236
|
+
const updatedFieldArrayValues = removeArrayAt(control._getFieldArray(name), index);
|
|
25237
|
+
ids.current = removeArrayAt(ids.current, index);
|
|
25238
|
+
updateValues(updatedFieldArrayValues);
|
|
25239
|
+
setFields(updatedFieldArrayValues);
|
|
25240
|
+
!Array.isArray(get(control._fields, name)) && set(control._fields, name, void 0);
|
|
25241
|
+
control._setFieldArray(name, updatedFieldArrayValues, removeArrayAt, {
|
|
25242
|
+
argA: index
|
|
25243
|
+
});
|
|
25244
|
+
};
|
|
25245
|
+
const insert$1 = (index, value, options) => {
|
|
25246
|
+
const insertValue = convertToArrayPayload(cloneObject(value));
|
|
25247
|
+
const updatedFieldArrayValues = insert(control._getFieldArray(name), index, insertValue);
|
|
25248
|
+
control._names.focus = getFocusFieldName(name, index, options);
|
|
25249
|
+
ids.current = insert(ids.current, index, insertValue.map(generateId));
|
|
25250
|
+
updateValues(updatedFieldArrayValues);
|
|
25251
|
+
setFields(updatedFieldArrayValues);
|
|
25252
|
+
control._setFieldArray(name, updatedFieldArrayValues, insert, {
|
|
25253
|
+
argA: index,
|
|
25254
|
+
argB: fillEmptyArray(value)
|
|
25255
|
+
});
|
|
25256
|
+
};
|
|
25257
|
+
const swap = (indexA, indexB) => {
|
|
25258
|
+
const updatedFieldArrayValues = control._getFieldArray(name);
|
|
25259
|
+
swapArrayAt(updatedFieldArrayValues, indexA, indexB);
|
|
25260
|
+
swapArrayAt(ids.current, indexA, indexB);
|
|
25261
|
+
updateValues(updatedFieldArrayValues);
|
|
25262
|
+
setFields(updatedFieldArrayValues);
|
|
25263
|
+
control._setFieldArray(name, updatedFieldArrayValues, swapArrayAt, {
|
|
25264
|
+
argA: indexA,
|
|
25265
|
+
argB: indexB
|
|
25266
|
+
}, false);
|
|
25267
|
+
};
|
|
25268
|
+
const move = (from, to2) => {
|
|
25269
|
+
const updatedFieldArrayValues = control._getFieldArray(name);
|
|
25270
|
+
moveArrayAt(updatedFieldArrayValues, from, to2);
|
|
25271
|
+
moveArrayAt(ids.current, from, to2);
|
|
25272
|
+
updateValues(updatedFieldArrayValues);
|
|
25273
|
+
setFields(updatedFieldArrayValues);
|
|
25274
|
+
control._setFieldArray(name, updatedFieldArrayValues, moveArrayAt, {
|
|
25275
|
+
argA: from,
|
|
25276
|
+
argB: to2
|
|
25277
|
+
}, false);
|
|
25278
|
+
};
|
|
25279
|
+
const update3 = (index, value) => {
|
|
25280
|
+
const updateValue = cloneObject(value);
|
|
25281
|
+
const updatedFieldArrayValues = updateAt(control._getFieldArray(name), index, updateValue);
|
|
25282
|
+
ids.current = [...updatedFieldArrayValues].map((item, i) => !item || i === index ? generateId() : ids.current[i]);
|
|
25283
|
+
updateValues(updatedFieldArrayValues);
|
|
25284
|
+
setFields([...updatedFieldArrayValues]);
|
|
25285
|
+
control._setFieldArray(name, updatedFieldArrayValues, updateAt, {
|
|
25286
|
+
argA: index,
|
|
25287
|
+
argB: updateValue
|
|
25288
|
+
}, true, false);
|
|
25289
|
+
};
|
|
25290
|
+
const replace = (value) => {
|
|
25291
|
+
const updatedFieldArrayValues = convertToArrayPayload(cloneObject(value));
|
|
25292
|
+
ids.current = updatedFieldArrayValues.map(generateId);
|
|
25293
|
+
updateValues([...updatedFieldArrayValues]);
|
|
25294
|
+
setFields([...updatedFieldArrayValues]);
|
|
25295
|
+
control._setFieldArray(name, [...updatedFieldArrayValues], (data) => data, {}, true, false);
|
|
25296
|
+
};
|
|
25297
|
+
React__default.useEffect(() => {
|
|
25298
|
+
control._state.action = false;
|
|
25299
|
+
isWatched(name, control._names) && control._subjects.state.next({
|
|
25300
|
+
...control._formState
|
|
25301
|
+
});
|
|
25302
|
+
if (_actioned.current && (!getValidationModes(control._options.mode).isOnSubmit || control._formState.isSubmitted) && !getValidationModes(control._options.reValidateMode).isOnSubmit) {
|
|
25303
|
+
if (control._options.resolver) {
|
|
25304
|
+
control._runSchema([name]).then((result) => {
|
|
25305
|
+
const error = get(result.errors, name);
|
|
25306
|
+
const existingError = get(control._formState.errors, name);
|
|
25307
|
+
if (existingError ? !error && existingError.type || error && (existingError.type !== error.type || existingError.message !== error.message) : error && error.type) {
|
|
25308
|
+
error ? set(control._formState.errors, name, error) : unset(control._formState.errors, name);
|
|
25309
|
+
control._subjects.state.next({
|
|
25310
|
+
errors: control._formState.errors
|
|
25311
|
+
});
|
|
25312
|
+
}
|
|
25313
|
+
});
|
|
25314
|
+
} else {
|
|
25315
|
+
const field = get(control._fields, name);
|
|
25316
|
+
if (field && field._f && !(getValidationModes(control._options.reValidateMode).isOnSubmit && getValidationModes(control._options.mode).isOnSubmit)) {
|
|
25317
|
+
validateField(field, control._names.disabled, control._formValues, control._options.criteriaMode === VALIDATION_MODE.all, control._options.shouldUseNativeValidation, true).then((error) => !isEmptyObject(error) && control._subjects.state.next({
|
|
25318
|
+
errors: updateFieldArrayRootError(control._formState.errors, error, name)
|
|
25319
|
+
}));
|
|
25320
|
+
}
|
|
25321
|
+
}
|
|
25322
|
+
}
|
|
25323
|
+
control._subjects.state.next({
|
|
25324
|
+
name,
|
|
25325
|
+
values: cloneObject(control._formValues)
|
|
25326
|
+
});
|
|
25327
|
+
control._names.focus && iterateFieldsByAction(control._fields, (ref, key) => {
|
|
25328
|
+
if (control._names.focus && key.startsWith(control._names.focus) && ref.focus) {
|
|
25329
|
+
ref.focus();
|
|
25330
|
+
return 1;
|
|
25331
|
+
}
|
|
25332
|
+
return;
|
|
25333
|
+
});
|
|
25334
|
+
control._names.focus = "";
|
|
25335
|
+
control._setValid();
|
|
25336
|
+
_actioned.current = false;
|
|
25337
|
+
}, [fields, name, control]);
|
|
25338
|
+
React__default.useEffect(() => {
|
|
25339
|
+
!get(control._formValues, name) && control._setFieldArray(name);
|
|
25340
|
+
return () => {
|
|
25341
|
+
const updateMounted = (name2, value) => {
|
|
25342
|
+
const field = get(control._fields, name2);
|
|
25343
|
+
if (field && field._f) {
|
|
25344
|
+
field._f.mount = value;
|
|
25345
|
+
}
|
|
25346
|
+
};
|
|
25347
|
+
control._options.shouldUnregister || shouldUnregister ? control.unregister(name) : updateMounted(name, false);
|
|
25348
|
+
};
|
|
25349
|
+
}, [name, control, keyName, shouldUnregister]);
|
|
25350
|
+
return {
|
|
25351
|
+
swap: React__default.useCallback(swap, [updateValues, name, control]),
|
|
25352
|
+
move: React__default.useCallback(move, [updateValues, name, control]),
|
|
25353
|
+
prepend: React__default.useCallback(prepend, [updateValues, name, control]),
|
|
25354
|
+
append: React__default.useCallback(append, [updateValues, name, control]),
|
|
25355
|
+
remove: React__default.useCallback(remove, [updateValues, name, control]),
|
|
25356
|
+
insert: React__default.useCallback(insert$1, [updateValues, name, control]),
|
|
25357
|
+
update: React__default.useCallback(update3, [updateValues, name, control]),
|
|
25358
|
+
replace: React__default.useCallback(replace, [updateValues, name, control]),
|
|
25359
|
+
fields: React__default.useMemo(() => fields.map((field, index) => ({
|
|
25360
|
+
...field,
|
|
25361
|
+
[keyName]: ids.current[index] || generateId()
|
|
25362
|
+
})), [fields, keyName])
|
|
25363
|
+
};
|
|
25364
|
+
}
|
|
25135
25365
|
function useForm(props = {}) {
|
|
25136
25366
|
const _formControl = React__default.useRef(void 0);
|
|
25137
25367
|
const _values = React__default.useRef(void 0);
|
|
@@ -26019,6 +26249,17 @@ function FormField({
|
|
|
26019
26249
|
] });
|
|
26020
26250
|
}
|
|
26021
26251
|
|
|
26252
|
+
// src/components/forms/FormFieldArray.tsx
|
|
26253
|
+
function FormFieldArray({ name, children }) {
|
|
26254
|
+
const context = useFormContext();
|
|
26255
|
+
const { control } = context;
|
|
26256
|
+
const { fields, append, prepend, remove, swap, move, insert: insert2 } = useFieldArray({
|
|
26257
|
+
control,
|
|
26258
|
+
name
|
|
26259
|
+
});
|
|
26260
|
+
return children({ context, fields, append, prepend, remove, swap, move, insert: insert2 });
|
|
26261
|
+
}
|
|
26262
|
+
|
|
26022
26263
|
// src/components/Button.tsx
|
|
26023
26264
|
var import_classnames7 = __toESM(require_classnames());
|
|
26024
26265
|
|
|
@@ -31084,11 +31325,11 @@ var ProgressBar_default = { "progressbar": "ProgressBar_progressbar__YzdlO", "tr
|
|
|
31084
31325
|
|
|
31085
31326
|
// src/components/ProgressBar.tsx
|
|
31086
31327
|
import { Fragment as Fragment9, jsx as jsx54, jsxs as jsxs29 } from "react/jsx-runtime";
|
|
31087
|
-
function ProgressBar2({ className,
|
|
31328
|
+
function ProgressBar2({ className, showPercentage, ...props }) {
|
|
31088
31329
|
return /* @__PURE__ */ jsx54($0393f8ab869a0f1a$export$c17561cb55d4db30, { ...props, className: (0, import_classnames40.default)(ProgressBar_default.progressbar, className), children: ({ percentage = 0, valueText }) => {
|
|
31089
31330
|
return /* @__PURE__ */ jsxs29(Fragment9, { children: [
|
|
31090
31331
|
/* @__PURE__ */ jsx54("div", { className: ProgressBar_default.track, children: /* @__PURE__ */ jsx54("div", { className: ProgressBar_default.fill, style: { width: `${percentage}%` } }) }),
|
|
31091
|
-
|
|
31332
|
+
showPercentage && /* @__PURE__ */ jsx54("div", { className: ProgressBar_default.value, children: valueText })
|
|
31092
31333
|
] });
|
|
31093
31334
|
} });
|
|
31094
31335
|
}
|
|
@@ -31101,7 +31342,7 @@ var ProgressCircle_default = { "progresscircle": "ProgressCircle_progresscircle_
|
|
|
31101
31342
|
|
|
31102
31343
|
// src/components/ProgressCircle.tsx
|
|
31103
31344
|
import { Fragment as Fragment10, jsx as jsx55, jsxs as jsxs30 } from "react/jsx-runtime";
|
|
31104
|
-
function ProgressCircle({ className,
|
|
31345
|
+
function ProgressCircle({ className, showPercentage, ...props }) {
|
|
31105
31346
|
return /* @__PURE__ */ jsx55($0393f8ab869a0f1a$export$c17561cb55d4db30, { ...props, className: (0, import_classnames41.default)(ProgressCircle_default.progresscircle, className), children: ({ percentage = 0, valueText }) => {
|
|
31106
31347
|
const radius = 45;
|
|
31107
31348
|
const circumference = radius * 2 * Math.PI;
|
|
@@ -31121,7 +31362,7 @@ function ProgressCircle({ className, showValue, ...props }) {
|
|
|
31121
31362
|
}
|
|
31122
31363
|
)
|
|
31123
31364
|
] }),
|
|
31124
|
-
|
|
31365
|
+
showPercentage && /* @__PURE__ */ jsx55("label", { className: ProgressCircle_default.value, children: valueText })
|
|
31125
31366
|
] });
|
|
31126
31367
|
} });
|
|
31127
31368
|
}
|
|
@@ -31635,6 +31876,7 @@ export {
|
|
|
31635
31876
|
Form,
|
|
31636
31877
|
FormButtons,
|
|
31637
31878
|
FormField,
|
|
31879
|
+
FormFieldArray,
|
|
31638
31880
|
FormResetButton,
|
|
31639
31881
|
FormSubmitButton,
|
|
31640
31882
|
Grid,
|