@payfit/unity-components 1.1.0 → 1.2.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/esm/adapters/standardSchemaAdapter.d.ts +7 -0
- package/dist/esm/adapters/standardSchemaAdapter.js +20 -0
- package/dist/esm/adapters/zodAdapter.d.ts +13 -0
- package/dist/esm/adapters/zodAdapter.js +74 -0
- package/dist/esm/components/action-bar/ActionBar.js +62 -64
- package/dist/esm/components/actionable/Actionable.d.ts +50 -3
- package/dist/esm/components/actionable/Actionable.js +49 -39
- package/dist/esm/components/app-menu/parts/AppMenuFooter.js +63 -63
- package/dist/esm/components/autocomplete/parts/AutocompleteClearButton.js +5 -5
- package/dist/esm/components/bottom-sheet/parts/BottomSheetDragIndicator.js +30 -31
- package/dist/esm/components/checkbox-field/CheckboxField.d.ts +2 -2
- package/dist/esm/components/checkbox-field/CheckboxField.js +18 -17
- package/dist/esm/components/checkbox-group-field/CheckboxGroupField.d.ts +2 -2
- package/dist/esm/components/checkbox-group-field/CheckboxGroupField.js +4 -1
- package/dist/esm/components/code/Code.d.ts +37 -0
- package/dist/esm/components/code/Code.js +39 -0
- package/dist/esm/components/code/copyToClipboard.d.ts +1 -0
- package/dist/esm/components/code/copyToClipboard.js +10 -0
- package/dist/esm/components/collapsible/Collapsible.d.ts +1 -1
- package/dist/esm/components/collapsible/Collapsible.js +14 -13
- package/dist/esm/components/collapsible/parts/CollapsibleTitle.js +7 -7
- package/dist/esm/components/data-table/DataTable.d.ts +76 -10
- package/dist/esm/components/data-table/DataTable.js +81 -78
- package/dist/esm/components/data-table/parts/ColumnSortHeader.js +13 -13
- package/dist/esm/components/data-table/parts/DataTableBulkActions.js +20 -20
- package/dist/esm/components/date-calendar/DateCalendar.js +52 -52
- package/dist/esm/components/date-calendar/parts/DateSegmentSelect.js +30 -33
- package/dist/esm/components/date-picker/DatePicker.js +64 -64
- package/dist/esm/components/date-picker/parts/DateInput.js +33 -33
- package/dist/esm/components/date-picker-field/DatePickerField.d.ts +2 -2
- package/dist/esm/components/dialog/parts/DialogActions/DialogButton.js +12 -12
- package/dist/esm/components/error-state/ErrorState.d.ts +196 -0
- package/dist/esm/components/error-state/ErrorState.js +153 -0
- package/dist/esm/components/error-state/initConfig.d.ts +16 -0
- package/dist/esm/components/error-state/initConfig.js +149 -0
- package/dist/esm/components/error-state/parts/Collapsible.d.ts +59 -0
- package/dist/esm/components/error-state/parts/Collapsible.js +67 -0
- package/dist/esm/components/form/Form.d.ts +15 -9
- package/dist/esm/components/form/Form.js +53 -50
- package/dist/esm/components/form-field/FormField.js +24 -23
- package/dist/esm/components/form-field/utils/isFieldRequired.d.ts +4 -4
- package/dist/esm/components/form-field/utils/isFieldRequired.js +5 -20
- package/dist/esm/components/funnel-layout/FunnelLayout.d.ts +1 -1
- package/dist/esm/components/funnel-layout/FunnelLayout.js +61 -110
- package/dist/esm/components/funnel-layout/parts/FunnelPage.js +8 -9
- package/dist/esm/components/funnel-layout/parts/FunnelPageActions.js +24 -24
- package/dist/esm/components/funnel-layout/parts/FunnelPageFooter.js +6 -7
- package/dist/esm/components/funnel-layout/parts/FunnelPageHeader.d.ts +2 -2
- package/dist/esm/components/funnel-layout/parts/FunnelSidebar.d.ts +2 -2
- package/dist/esm/components/funnel-layout/parts/FunnelSidebar.js +9 -10
- package/dist/esm/components/funnel-layout/parts/FunnelTopBar.js +0 -1
- package/dist/esm/components/input/Input.js +28 -28
- package/dist/esm/components/label/Label.js +19 -19
- package/dist/esm/components/multi-select/MultiSelect.js +94 -94
- package/dist/esm/components/multi-select/hooks/use-multiselection-state.js +32 -32
- package/dist/esm/components/multi-select/parts/MultiSelectButton.js +38 -38
- package/dist/esm/components/multi-select/parts/MultiSelectPopover.js +16 -16
- package/dist/esm/components/multi-select-field/MultiSelectField.d.ts +2 -2
- package/dist/esm/components/multi-select-field/MultiSelectField.js +53 -53
- package/dist/esm/components/nav/parts/NavGroup.js +21 -21
- package/dist/esm/components/number-field/NumberField.d.ts +3 -3
- package/dist/esm/components/number-input/NumberInput.js +58 -58
- package/dist/esm/components/pagination/Pagination.js +97 -101
- package/dist/esm/components/pagination/parts/PaginationJumpDialog.js +39 -40
- package/dist/esm/components/popover/parts/PopoverHeader.js +8 -8
- package/dist/esm/components/radio-button-group/parts/RadioButton.js +11 -11
- package/dist/esm/components/select-field/SelectField.d.ts +2 -2
- package/dist/esm/components/select-field/SelectField.js +4 -1
- package/dist/esm/components/selectable-button-group/SelectableButtonGroup.js +22 -23
- package/dist/esm/components/selectable-button-group-field/SelectableButtonGroupField.d.ts +2 -2
- package/dist/esm/components/side-panel/parts/SidePanelDragIndicator.js +30 -31
- package/dist/esm/components/skip-links/SkipLinks.js +50 -43
- package/dist/esm/components/table/Table.js +79 -76
- package/dist/esm/components/table/parts/TableBody.js +6 -6
- package/dist/esm/components/table/parts/TableCell.js +25 -25
- package/dist/esm/components/table/parts/TableColumnHeader.js +38 -38
- package/dist/esm/components/table/parts/TablePagination.js +61 -59
- package/dist/esm/components/table/parts/TableRow.js +16 -16
- package/dist/esm/components/tabs/parts/TabList.js +50 -54
- package/dist/esm/components/task-menu/parts/Content.js +24 -24
- package/dist/esm/components/task-menu/parts/Header.js +24 -24
- package/dist/esm/components/task-menu/parts/SubTask.js +74 -74
- package/dist/esm/components/task-menu/parts/Task.js +69 -69
- package/dist/esm/components/task-menu/parts/TaskGroup.js +45 -45
- package/dist/esm/components/text-area/TextArea.js +30 -31
- package/dist/esm/components/text-field/TextField.d.ts +2 -2
- package/dist/esm/components/toggle-switch-field/ToggleSwitchField.d.ts +2 -2
- package/dist/esm/components/toggle-switch-field/ToggleSwitchField.js +4 -1
- package/dist/esm/components/toggle-switch-group/ToggleSwitchGroup.js +74 -74
- package/dist/esm/components/toggle-switch-group-field/ToggleSwitchGroupField.d.ts +2 -2
- package/dist/esm/components/toggle-switch-group-field/ToggleSwitchGroupField.js +36 -32
- package/dist/esm/hooks/use-form.d.ts +5 -5
- package/dist/esm/hooks/use-form.types.d.ts +2 -2
- package/dist/esm/hooks/use-resizable.js +13 -14
- package/dist/esm/index.d.ts +1 -0
- package/dist/esm/index.js +22 -19
- package/dist/esm/types/schema.d.ts +8 -0
- package/dist/esm/utils/createSchemaAdapter.d.ts +7 -0
- package/dist/esm/utils/createSchemaAdapter.js +13 -0
- package/dist/esm/utils/platform.js +2 -3
- package/i18n/en-GB.json +16 -0
- package/i18n/es-ES.json +16 -0
- package/i18n/fr-FR.json +16 -0
- package/package.json +25 -19
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { jsxs as t, jsx as e } from "react/jsx-runtime";
|
|
2
|
-
import { forwardRef as
|
|
3
|
-
import { uyTv as
|
|
4
|
-
import { TextArea as
|
|
5
|
-
import { useIntl as
|
|
6
|
-
import { useResizable as
|
|
7
|
-
import { Icon as
|
|
8
|
-
import { Spinner as
|
|
9
|
-
const
|
|
2
|
+
import { forwardRef as x } from "react";
|
|
3
|
+
import { uyTv as h } from "@payfit/unity-themes";
|
|
4
|
+
import { TextArea as v } from "react-aria-components";
|
|
5
|
+
import { useIntl as w } from "react-intl";
|
|
6
|
+
import { useResizable as M } from "../../hooks/use-resizable.js";
|
|
7
|
+
import { Icon as z } from "../icon/Icon.js";
|
|
8
|
+
import { Spinner as L } from "../spinner/Spinner.js";
|
|
9
|
+
const D = h({
|
|
10
10
|
slots: {
|
|
11
|
-
base: "uy:flex uy:border uy:border-solid uy:rounded-
|
|
12
|
-
inputWrapper: "uy:flex uy:gap-50 uy:flex-grow uy:pt-100 uy:pb-100 uy:pl-150 uy:pr-150 uy:rounded-
|
|
11
|
+
base: "uy:flex uy:border uy:border-solid uy:rounded-75 uy:focus-within:outline-none uy:focus-within:ring-2 uy:focus-within:ring-utility-focus-ring uy:focus-within:ring-offset-2 uy:active:border-border-form-active uy:overflow-hidden uy:relative",
|
|
12
|
+
inputWrapper: "uy:flex uy:gap-50 uy:flex-grow uy:pt-100 uy:pb-100 uy:pl-150 uy:pr-150 uy:rounded-75",
|
|
13
13
|
input: "uy:flex-grow uy:flex-shrink uy:outline-none uy:typography-body uy:placeholder:text-content-neutral-lowest uy:resize-none",
|
|
14
14
|
state: "uy:flex uy:gap-50 uy:flex-shrink-0 uy:basis-250",
|
|
15
15
|
resizeHandle: "uy:absolute uy:bottom-25 uy:right-25 uy:w-100 uy:h-100 uy:cursor-se-resize uy:flex uy:items-center uy:justify-center"
|
|
@@ -56,38 +56,38 @@ const W = w({
|
|
|
56
56
|
isDisabled: !1,
|
|
57
57
|
isReadOnly: !1
|
|
58
58
|
}
|
|
59
|
-
}),
|
|
59
|
+
}), N = x(
|
|
60
60
|
({
|
|
61
61
|
isInvalid: n,
|
|
62
62
|
isLoading: s,
|
|
63
63
|
isDisabled: a,
|
|
64
64
|
isReadOnly: r,
|
|
65
65
|
isResizable: i = !1,
|
|
66
|
-
...
|
|
67
|
-
},
|
|
68
|
-
const o =
|
|
66
|
+
...d
|
|
67
|
+
}, f) => {
|
|
68
|
+
const o = w(), { containerRef: l, handleResizeStart: y } = M({
|
|
69
69
|
isDisabled: !i || a || r
|
|
70
|
-
}), { base:
|
|
70
|
+
}), { base: b, inputWrapper: m, input: c, state: p, resizeHandle: g } = D({
|
|
71
71
|
isInvalid: n,
|
|
72
72
|
isDisabled: a,
|
|
73
73
|
isReadOnly: r
|
|
74
74
|
});
|
|
75
|
-
return /* @__PURE__ */ t("div", { ref: l, className:
|
|
76
|
-
/* @__PURE__ */ t("div", { className:
|
|
75
|
+
return /* @__PURE__ */ t("div", { ref: l, className: b(), children: [
|
|
76
|
+
/* @__PURE__ */ t("div", { className: m(), children: [
|
|
77
77
|
/* @__PURE__ */ e(
|
|
78
|
-
|
|
78
|
+
v,
|
|
79
79
|
{
|
|
80
80
|
"data-dd-privacy": "mask",
|
|
81
|
-
...
|
|
82
|
-
ref:
|
|
83
|
-
className:
|
|
81
|
+
...d,
|
|
82
|
+
ref: f,
|
|
83
|
+
className: c(),
|
|
84
84
|
"aria-busy": s,
|
|
85
85
|
readOnly: r
|
|
86
86
|
}
|
|
87
87
|
),
|
|
88
|
-
/* @__PURE__ */ t("div", { className:
|
|
88
|
+
/* @__PURE__ */ t("div", { className: p(), children: [
|
|
89
89
|
s && /* @__PURE__ */ e(
|
|
90
|
-
|
|
90
|
+
L,
|
|
91
91
|
{
|
|
92
92
|
color: "inherit",
|
|
93
93
|
size: "small",
|
|
@@ -98,7 +98,7 @@ const W = w({
|
|
|
98
98
|
}
|
|
99
99
|
),
|
|
100
100
|
n && /* @__PURE__ */ e(
|
|
101
|
-
|
|
101
|
+
z,
|
|
102
102
|
{
|
|
103
103
|
src: "WarningCircleOutlined",
|
|
104
104
|
color: "content.form.invalid",
|
|
@@ -113,8 +113,8 @@ const W = w({
|
|
|
113
113
|
i && !a && !r && /* @__PURE__ */ e(
|
|
114
114
|
"div",
|
|
115
115
|
{
|
|
116
|
-
className:
|
|
117
|
-
onMouseDown:
|
|
116
|
+
className: g(),
|
|
117
|
+
onMouseDown: y,
|
|
118
118
|
role: "button",
|
|
119
119
|
tabIndex: 0,
|
|
120
120
|
"aria-label": o.formatMessage({
|
|
@@ -122,8 +122,7 @@ const W = w({
|
|
|
122
122
|
defaultMessage: "Resize textarea"
|
|
123
123
|
}),
|
|
124
124
|
onKeyDown: (u) => {
|
|
125
|
-
|
|
126
|
-
(u.key === "Enter" || u.key === " ") && (u.preventDefault(), (f = (d = l.current) == null ? void 0 : d.querySelector("textarea")) == null || f.focus());
|
|
125
|
+
(u.key === "Enter" || u.key === " ") && (u.preventDefault(), l.current?.querySelector("textarea")?.focus());
|
|
127
126
|
},
|
|
128
127
|
children: /* @__PURE__ */ t(
|
|
129
128
|
"svg",
|
|
@@ -156,8 +155,8 @@ const W = w({
|
|
|
156
155
|
] });
|
|
157
156
|
}
|
|
158
157
|
);
|
|
159
|
-
|
|
158
|
+
N.displayName = "TextArea";
|
|
160
159
|
export {
|
|
161
|
-
|
|
162
|
-
|
|
160
|
+
N as TextArea,
|
|
161
|
+
D as textArea
|
|
163
162
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import { StandardSchemaV1 } from '@standard-schema/spec';
|
|
1
2
|
import { ForwardedRef, HTMLAttributes, JSX, ReactNode } from 'react';
|
|
2
3
|
import { FieldPath, FieldValues } from 'react-hook-form';
|
|
3
|
-
import { infer as ZodInfer } from 'zod';
|
|
4
4
|
import { Schema } from '../../hooks/use-form.types.js';
|
|
5
5
|
import { InputProps } from '../input/Input.js';
|
|
6
6
|
import { LabelProps } from '../label/Label.js';
|
|
@@ -30,7 +30,7 @@ interface TextFieldWithTextAreaProps<TFieldValues extends FieldValues = FieldVal
|
|
|
30
30
|
type?: never;
|
|
31
31
|
}
|
|
32
32
|
export type TextFieldProps<TFieldValues extends FieldValues = FieldValues, TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>> = TextFieldWithInputProps<TFieldValues, TName> | TextFieldWithTextAreaProps<TFieldValues, TName>;
|
|
33
|
-
type TextFieldComponent = (<TSchema extends Schema>(props: TextFieldProps<
|
|
33
|
+
type TextFieldComponent = (<TSchema extends Schema>(props: TextFieldProps<StandardSchemaV1.InferOutput<TSchema>> & {
|
|
34
34
|
ref?: ForwardedRef<HTMLInputElement | HTMLTextAreaElement>;
|
|
35
35
|
}) => JSX.Element) & {
|
|
36
36
|
displayName?: string;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import { StandardSchemaV1 } from '@standard-schema/spec';
|
|
1
2
|
import { ForwardedRef, JSX } from 'react';
|
|
2
3
|
import { FieldPath, FieldValues } from 'react-hook-form';
|
|
3
|
-
import { infer as ZodInfer } from 'zod';
|
|
4
4
|
import { Schema } from '../../hooks/use-form.types.js';
|
|
5
5
|
interface FieldProps<TFieldValues extends FieldValues = FieldValues, TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>> {
|
|
6
6
|
/** The name of the field, which should match the form schema. */
|
|
@@ -23,7 +23,7 @@ interface FieldProps<TFieldValues extends FieldValues = FieldValues, TName exten
|
|
|
23
23
|
isLabelSrOnly?: boolean;
|
|
24
24
|
}
|
|
25
25
|
export type ToggleSwitchFieldProps<TFieldValues extends FieldValues = FieldValues, TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>> = FieldProps<TFieldValues, TName>;
|
|
26
|
-
type ToggleSwitchFieldComponent = (<TSchema extends Schema>(props: ToggleSwitchFieldProps<
|
|
26
|
+
type ToggleSwitchFieldComponent = (<TSchema extends Schema>(props: ToggleSwitchFieldProps<StandardSchemaV1.InferOutput<TSchema>> & {
|
|
27
27
|
ref?: ForwardedRef<HTMLLabelElement>;
|
|
28
28
|
}) => JSX.Element) & {
|
|
29
29
|
displayName?: string;
|
|
@@ -1,99 +1,99 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { forwardRef as
|
|
3
|
-
import { uyTv as
|
|
4
|
-
import { Label as
|
|
5
|
-
import { Text as
|
|
6
|
-
const
|
|
1
|
+
import { jsxs as k, jsx as t } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef as q, useState as z, useId as A, useRef as H, useCallback as J, isValidElement as B, cloneElement as w, Children as K } from "react";
|
|
3
|
+
import { uyTv as Q } from "@payfit/unity-themes";
|
|
4
|
+
import { Label as U } from "../label/Label.js";
|
|
5
|
+
import { Text as j } from "../text/Text.js";
|
|
6
|
+
const W = Q({
|
|
7
7
|
base: "uy:flex uy:flex-col uy:gap-50"
|
|
8
8
|
});
|
|
9
|
-
function
|
|
10
|
-
if (!
|
|
11
|
-
const
|
|
12
|
-
return typeof
|
|
9
|
+
function X(i) {
|
|
10
|
+
if (!B(i)) return !1;
|
|
11
|
+
const o = i.props;
|
|
12
|
+
return typeof o == "object" && o !== null && "value" in o && typeof o.value == "string";
|
|
13
13
|
}
|
|
14
|
-
const
|
|
14
|
+
const Y = q(
|
|
15
15
|
({
|
|
16
|
-
label:
|
|
17
|
-
helperText:
|
|
18
|
-
feedbackText:
|
|
19
|
-
isDisabled:
|
|
20
|
-
isReadOnly:
|
|
21
|
-
isInvalid:
|
|
22
|
-
isRequired:
|
|
23
|
-
children:
|
|
24
|
-
requiredVariant:
|
|
25
|
-
value:
|
|
26
|
-
defaultValue:
|
|
27
|
-
onChange:
|
|
28
|
-
onFocus:
|
|
29
|
-
onBlur:
|
|
30
|
-
onFocusChange:
|
|
31
|
-
...
|
|
32
|
-
},
|
|
33
|
-
const
|
|
34
|
-
|
|
35
|
-
),
|
|
36
|
-
|
|
37
|
-
},
|
|
38
|
-
|
|
39
|
-
},
|
|
16
|
+
label: i,
|
|
17
|
+
helperText: o,
|
|
18
|
+
feedbackText: r,
|
|
19
|
+
isDisabled: f,
|
|
20
|
+
isReadOnly: E,
|
|
21
|
+
isInvalid: a,
|
|
22
|
+
isRequired: y,
|
|
23
|
+
children: N,
|
|
24
|
+
requiredVariant: R,
|
|
25
|
+
value: m,
|
|
26
|
+
defaultValue: V,
|
|
27
|
+
onChange: g,
|
|
28
|
+
onFocus: C,
|
|
29
|
+
onBlur: G,
|
|
30
|
+
onFocusChange: h,
|
|
31
|
+
...I
|
|
32
|
+
}, F) => {
|
|
33
|
+
const c = m !== void 0, [M, O] = z(
|
|
34
|
+
V ?? []
|
|
35
|
+
), n = c ? m : M, v = A(), b = o ? `${v}-helper` : void 0, d = a && r ? `${v}-feedback` : void 0, $ = [b, d].filter(Boolean).join(" ") || void 0, S = H(!1), x = (e) => {
|
|
36
|
+
S.current = !0, C?.(e), h?.(!0);
|
|
37
|
+
}, D = (e) => {
|
|
38
|
+
S.current = !1, G?.(e), h?.(!1);
|
|
39
|
+
}, L = J(
|
|
40
40
|
(e) => {
|
|
41
|
-
let
|
|
42
|
-
|
|
41
|
+
let l;
|
|
42
|
+
n.includes(e) ? l = n.filter((s) => s !== e) : l = [...n, e], c || O(l), g?.(l);
|
|
43
43
|
},
|
|
44
|
-
[
|
|
45
|
-
),
|
|
46
|
-
if (!
|
|
47
|
-
const
|
|
48
|
-
return
|
|
49
|
-
key:
|
|
50
|
-
isSelected:
|
|
51
|
-
isDisabled:
|
|
52
|
-
isReadOnly:
|
|
53
|
-
value:
|
|
44
|
+
[n, c, g]
|
|
45
|
+
), P = () => K.map(N, (e, l) => {
|
|
46
|
+
if (!X(e)) return e;
|
|
47
|
+
const s = e, u = s.props, p = u.value;
|
|
48
|
+
return w(s, {
|
|
49
|
+
key: s.key ?? l,
|
|
50
|
+
isSelected: n.includes(p),
|
|
51
|
+
isDisabled: f ?? u.isDisabled,
|
|
52
|
+
isReadOnly: E ?? u.isReadOnly,
|
|
53
|
+
value: p,
|
|
54
54
|
onChange: () => {
|
|
55
|
-
|
|
55
|
+
L(p);
|
|
56
56
|
}
|
|
57
57
|
});
|
|
58
58
|
});
|
|
59
|
-
return /* @__PURE__ */
|
|
59
|
+
return /* @__PURE__ */ k(
|
|
60
60
|
"fieldset",
|
|
61
61
|
{
|
|
62
|
-
...
|
|
63
|
-
ref:
|
|
64
|
-
className:
|
|
65
|
-
"aria-describedby":
|
|
66
|
-
"aria-invalid":
|
|
67
|
-
"aria-required":
|
|
68
|
-
disabled:
|
|
69
|
-
onFocus:
|
|
70
|
-
onBlur:
|
|
62
|
+
...I,
|
|
63
|
+
ref: F,
|
|
64
|
+
className: W(),
|
|
65
|
+
"aria-describedby": $,
|
|
66
|
+
"aria-invalid": a || void 0,
|
|
67
|
+
"aria-required": y || void 0,
|
|
68
|
+
disabled: f,
|
|
69
|
+
onFocus: x,
|
|
70
|
+
onBlur: D,
|
|
71
71
|
children: [
|
|
72
|
-
/* @__PURE__ */
|
|
73
|
-
|
|
74
|
-
|
|
72
|
+
/* @__PURE__ */ t("legend", { className: "uy:mb-50", children: /* @__PURE__ */ t(U, { isRequired: y, requiredVariant: R, children: i }) }),
|
|
73
|
+
o && /* @__PURE__ */ t(
|
|
74
|
+
j,
|
|
75
75
|
{
|
|
76
|
-
id:
|
|
76
|
+
id: b,
|
|
77
77
|
variant: "bodySmall",
|
|
78
78
|
color: "content.neutral.low",
|
|
79
79
|
slot: "description",
|
|
80
|
-
children:
|
|
80
|
+
children: o
|
|
81
81
|
}
|
|
82
82
|
),
|
|
83
|
-
/* @__PURE__ */
|
|
84
|
-
|
|
85
|
-
|
|
83
|
+
/* @__PURE__ */ t("div", { className: "uy:mt-100 uy:flex uy:flex-col uy:gap-150 uy:py-25", children: P() }),
|
|
84
|
+
a && r && (typeof r == "string" ? /* @__PURE__ */ t(
|
|
85
|
+
j,
|
|
86
86
|
{
|
|
87
|
-
id:
|
|
87
|
+
id: d,
|
|
88
88
|
variant: "bodySmallStrong",
|
|
89
89
|
color: "content.form.invalid",
|
|
90
90
|
slot: "errorMessage",
|
|
91
|
-
children:
|
|
91
|
+
children: r
|
|
92
92
|
}
|
|
93
|
-
) :
|
|
94
|
-
|
|
93
|
+
) : B(r) && w(
|
|
94
|
+
r,
|
|
95
95
|
{
|
|
96
|
-
id:
|
|
96
|
+
id: d,
|
|
97
97
|
slot: "errorMessage"
|
|
98
98
|
}
|
|
99
99
|
))
|
|
@@ -102,8 +102,8 @@ const _ = B(
|
|
|
102
102
|
);
|
|
103
103
|
}
|
|
104
104
|
);
|
|
105
|
-
|
|
105
|
+
Y.displayName = "ToggleSwitchGroup";
|
|
106
106
|
export {
|
|
107
|
-
|
|
108
|
-
|
|
107
|
+
Y as ToggleSwitchGroup,
|
|
108
|
+
W as toggleSwitchGroup
|
|
109
109
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import { StandardSchemaV1 } from '@standard-schema/spec';
|
|
1
2
|
import { ForwardedRef, JSX, PropsWithChildren, ReactNode } from 'react';
|
|
2
3
|
import { FieldPath, FieldValues } from 'react-hook-form';
|
|
3
|
-
import { infer as ZodInfer } from 'zod';
|
|
4
4
|
import { Schema } from '../../hooks/use-form.types.js';
|
|
5
5
|
import { LabelProps } from '../label/Label.js';
|
|
6
6
|
import { ToggleSwitchGroupProps } from '../toggle-switch-group/ToggleSwitchGroup.js';
|
|
@@ -33,7 +33,7 @@ interface FieldProps<TFieldValues extends FieldValues = FieldValues, TName exten
|
|
|
33
33
|
onFocusChange?: (isFocused: boolean) => void;
|
|
34
34
|
}
|
|
35
35
|
export type ToggleSwitchGroupFieldProps<TFieldValues extends FieldValues = FieldValues, TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>> = FieldProps<TFieldValues, TName>;
|
|
36
|
-
type ToggleSwitchGroupFieldComponent = (<TSchema extends Schema>(props: ToggleSwitchGroupFieldProps<
|
|
36
|
+
type ToggleSwitchGroupFieldComponent = (<TSchema extends Schema>(props: ToggleSwitchGroupFieldProps<StandardSchemaV1.InferOutput<TSchema>> & {
|
|
37
37
|
ref?: ForwardedRef<HTMLFieldSetElement>;
|
|
38
38
|
}) => JSX.Element) & {
|
|
39
39
|
displayName?: string;
|
|
@@ -1,59 +1,63 @@
|
|
|
1
|
-
import { jsxs as
|
|
1
|
+
import { jsxs as T, jsx as i } from "react/jsx-runtime";
|
|
2
2
|
import { forwardRef as x, useMemo as G } from "react";
|
|
3
3
|
import { useFormContext as R } from "react-hook-form";
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
|
|
4
|
+
import { createSchemaAdapter as q } from "../../utils/createSchemaAdapter.js";
|
|
5
|
+
import { FormField as y } from "../form-field/FormField.js";
|
|
6
|
+
import { FormControl as P } from "../form-field/parts/FormControl.js";
|
|
7
|
+
import { FormFeedbackText as j } from "../form-field/parts/FormFeedbackText.js";
|
|
8
|
+
import { isFieldRequired as v } from "../form-field/utils/isFieldRequired.js";
|
|
9
|
+
import { useUnityFormProvider as C } from "../form/Form.context.js";
|
|
10
|
+
import { ToggleSwitchGroup as U } from "../toggle-switch-group/ToggleSwitchGroup.js";
|
|
11
|
+
function b({
|
|
11
12
|
name: o,
|
|
12
13
|
label: r,
|
|
13
|
-
defaultValue:
|
|
14
|
+
defaultValue: e,
|
|
14
15
|
helperText: m,
|
|
15
16
|
contextualLink: c,
|
|
16
|
-
isRequired:
|
|
17
|
-
isInvalid:
|
|
17
|
+
isRequired: p,
|
|
18
|
+
isInvalid: s,
|
|
18
19
|
isLoading: l,
|
|
19
20
|
isDisabled: n,
|
|
20
|
-
isReadOnly:
|
|
21
|
-
requiredVariant:
|
|
21
|
+
isReadOnly: d,
|
|
22
|
+
requiredVariant: u,
|
|
22
23
|
children: f,
|
|
23
24
|
...F
|
|
24
|
-
},
|
|
25
|
-
const { control:
|
|
26
|
-
() =>
|
|
25
|
+
}, h) {
|
|
26
|
+
const { control: g, watch: a } = R(), { schema: t } = C(), w = G(
|
|
27
|
+
() => v(q(t), o),
|
|
27
28
|
[t, o]
|
|
28
|
-
),
|
|
29
|
-
return /* @__PURE__ */
|
|
30
|
-
isInvalid:
|
|
29
|
+
), S = a(o);
|
|
30
|
+
return /* @__PURE__ */ T(y, { control: g, name: o, ...{
|
|
31
|
+
isInvalid: s,
|
|
31
32
|
isLoading: l,
|
|
32
33
|
isDisabled: n,
|
|
33
|
-
isReadOnly:
|
|
34
|
+
isReadOnly: d
|
|
34
35
|
}, children: [
|
|
35
|
-
/* @__PURE__ */
|
|
36
|
-
|
|
36
|
+
/* @__PURE__ */ i(P, { children: /* @__PURE__ */ i(
|
|
37
|
+
U,
|
|
37
38
|
{
|
|
38
|
-
ref:
|
|
39
|
+
ref: h,
|
|
39
40
|
label: r,
|
|
40
|
-
defaultValue:
|
|
41
|
-
value:
|
|
41
|
+
defaultValue: e,
|
|
42
|
+
value: S,
|
|
42
43
|
helperText: m,
|
|
43
|
-
requiredVariant:
|
|
44
|
+
requiredVariant: u,
|
|
44
45
|
...F,
|
|
45
|
-
isRequired:
|
|
46
|
+
isRequired: w ?? p,
|
|
46
47
|
children: f
|
|
47
48
|
}
|
|
48
49
|
) }),
|
|
49
|
-
/* @__PURE__ */
|
|
50
|
+
/* @__PURE__ */ i(j, {}),
|
|
50
51
|
c
|
|
51
52
|
] });
|
|
52
53
|
}
|
|
53
|
-
const
|
|
54
|
-
return
|
|
54
|
+
const k = x(function(r, e) {
|
|
55
|
+
return b(
|
|
56
|
+
r,
|
|
57
|
+
e
|
|
58
|
+
);
|
|
55
59
|
});
|
|
56
|
-
|
|
60
|
+
k.displayName = "ToggleSwitchGroupField";
|
|
57
61
|
export {
|
|
58
|
-
|
|
62
|
+
k as ToggleSwitchGroupField
|
|
59
63
|
};
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
+
import { StandardSchemaV1 } from '@standard-schema/spec';
|
|
1
2
|
import { JSX, PropsWithChildren } from 'react';
|
|
2
3
|
import { UseFormProps as UseHookFormProps, UseFormReturn as UseHookFormReturn } from 'react-hook-form';
|
|
3
|
-
import { infer as ZodInfer } from 'zod';
|
|
4
4
|
import { FormFieldProps } from '../components/form-field/FormField.js';
|
|
5
5
|
import { FormProps } from '../components/form/Form.js';
|
|
6
6
|
import { Schema } from './use-form.types.js';
|
|
7
7
|
export type UseUnityFormReturn<TSchema extends Schema> = {
|
|
8
|
-
methods: UseHookFormReturn<
|
|
9
|
-
Form: (props: Omit<FormProps<TSchema>, 'form' | 'schema'>) => JSX.Element;
|
|
10
|
-
FormField: (props: PropsWithChildren<Omit<FormFieldProps<
|
|
8
|
+
methods: UseHookFormReturn<StandardSchemaV1.InferInput<TSchema>, any, StandardSchemaV1.InferOutput<TSchema>>;
|
|
9
|
+
Form: (props: Omit<FormProps<TSchema, StandardSchemaV1.InferInput<TSchema>, StandardSchemaV1.InferOutput<TSchema>>, 'form' | 'schema'>) => JSX.Element;
|
|
10
|
+
FormField: (props: PropsWithChildren<Omit<FormFieldProps<StandardSchemaV1.InferOutput<TSchema>>, 'control'>>) => JSX.Element;
|
|
11
11
|
};
|
|
12
12
|
/**
|
|
13
13
|
* A hook to create `Form` and `FormField` components that are bound to a specific schema definition and form controller. The resulting components will have full type-safety based on the provided schema type.
|
|
@@ -45,4 +45,4 @@ export type UseUnityFormReturn<TSchema extends Schema> = {
|
|
|
45
45
|
* @remarks
|
|
46
46
|
* [API]() • [Demo]()
|
|
47
47
|
*/
|
|
48
|
-
export declare function useUnityForm<TSchema extends Schema>(schema: TSchema, options?: Omit<UseHookFormProps<
|
|
48
|
+
export declare function useUnityForm<TSchema extends Schema>(schema: TSchema, options?: Omit<UseHookFormProps<StandardSchemaV1.InferInput<TSchema>, any, StandardSchemaV1.InferOutput<TSchema>>, 'resolver'>): UseUnityFormReturn<TSchema>;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { StandardSchemaV1 } from '@standard-schema/spec';
|
|
2
2
|
export type TFormValues = Record<string, unknown>;
|
|
3
|
-
export type Schema =
|
|
3
|
+
export type Schema = StandardSchemaV1<TFormValues>;
|
|
@@ -10,35 +10,34 @@ function x({
|
|
|
10
10
|
startY: 0,
|
|
11
11
|
startWidth: 0,
|
|
12
12
|
startHeight: 0
|
|
13
|
-
}), l = (
|
|
14
|
-
var s;
|
|
13
|
+
}), l = (s) => {
|
|
15
14
|
if (c) return;
|
|
16
|
-
|
|
17
|
-
const
|
|
18
|
-
!e.current || !
|
|
15
|
+
s.preventDefault();
|
|
16
|
+
const r = e.current?.querySelector("textarea");
|
|
17
|
+
!e.current || !r || o({
|
|
19
18
|
isResizing: !0,
|
|
20
|
-
startX:
|
|
21
|
-
startY:
|
|
19
|
+
startX: s.clientX,
|
|
20
|
+
startY: s.clientY,
|
|
22
21
|
startWidth: e.current.offsetWidth,
|
|
23
|
-
startHeight:
|
|
22
|
+
startHeight: r.offsetHeight
|
|
24
23
|
});
|
|
25
24
|
};
|
|
26
25
|
return g(() => {
|
|
27
26
|
if (!t.isResizing) return;
|
|
28
|
-
const
|
|
27
|
+
const s = (n) => {
|
|
29
28
|
if (!e.current) return;
|
|
30
29
|
const u = e.current.querySelector("textarea");
|
|
31
30
|
if (!u) return;
|
|
32
|
-
const d =
|
|
31
|
+
const d = n.clientX - t.startX, f = n.clientY - t.startY, h = Math.max(t.startWidth + d, i ?? 0), m = Math.max(
|
|
33
32
|
t.startHeight + f,
|
|
34
33
|
a ?? 0
|
|
35
34
|
);
|
|
36
35
|
e.current.style.width = `${h}px`, u.style.height = `${m}px`;
|
|
37
|
-
},
|
|
38
|
-
o((
|
|
36
|
+
}, r = () => {
|
|
37
|
+
o((n) => ({ ...n, isResizing: !1 }));
|
|
39
38
|
};
|
|
40
|
-
return document.addEventListener("mousemove",
|
|
41
|
-
document.removeEventListener("mousemove",
|
|
39
|
+
return document.addEventListener("mousemove", s), document.addEventListener("mouseup", r), () => {
|
|
40
|
+
document.removeEventListener("mousemove", s), document.removeEventListener("mouseup", r);
|
|
42
41
|
};
|
|
43
42
|
}, [t, i, a]), {
|
|
44
43
|
containerRef: e,
|
package/dist/esm/index.d.ts
CHANGED
|
@@ -164,3 +164,4 @@ export * from './providers/router/RouterProvider.js';
|
|
|
164
164
|
export * from './components/action-bar/ActionBar.js';
|
|
165
165
|
export * from './components/action-bar/parts/ActionBarAction.js';
|
|
166
166
|
export * from './components/action-bar/parts/ActionBarRoot.js';
|
|
167
|
+
export * from './components/error-state/ErrorState.js';
|