@payfit/unity-components 2.6.0 → 2.7.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/components/select/Select.d.ts +4 -0
- package/dist/esm/components/select/Select.js +30 -28
- package/dist/esm/components/select/TanstackSelect.js +24 -17
- package/dist/esm/components/select/parts/SelectButton.d.ts +13 -2
- package/dist/esm/components/select/parts/SelectButton.js +50 -48
- package/dist/esm/components/select-field/TanstackSelectField.js +22 -20
- package/package.json +7 -7
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { Node } from '@react-types/shared';
|
|
1
2
|
import { ForwardedRef, JSX, ReactNode } from 'react';
|
|
2
3
|
import { PopoverProps as AriaPopoverProps, SelectProps as AriaSelectProps } from 'react-aria-components';
|
|
3
4
|
export interface SelectProps<T extends object> extends Omit<AriaSelectProps<T>, 'children' | 'label' | 'style' | 'className' | 'value' | 'defaultValue' | 'onChange' | 'selectionMode'> {
|
|
@@ -17,7 +18,10 @@ export interface SelectProps<T extends object> extends Omit<AriaSelectProps<T>,
|
|
|
17
18
|
isSearchable?: boolean;
|
|
18
19
|
/** The placement of the popover */
|
|
19
20
|
placement?: Extract<AriaPopoverProps['placement'], 'top' | 'bottom'>;
|
|
21
|
+
/** The aria-label for the search input when isSearchable is true */
|
|
20
22
|
searchInputAriaLabel?: string;
|
|
23
|
+
/** Custom render function to format the selected value display */
|
|
24
|
+
renderValue?: (value: Node<T>) => ReactNode;
|
|
21
25
|
}
|
|
22
26
|
type SelectComponent = (<TItems extends object>(props: SelectProps<TItems> & {
|
|
23
27
|
ref?: ForwardedRef<HTMLDivElement>;
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import { jsxs as c, jsx as e } from "react/jsx-runtime";
|
|
2
|
-
import { forwardRef as
|
|
3
|
-
import { uyTv as
|
|
4
|
-
import { useFilter as
|
|
5
|
-
import { useIntl as
|
|
6
|
-
import { SearchInput as
|
|
7
|
-
import { SelectButton as
|
|
8
|
-
const
|
|
2
|
+
import { forwardRef as C, useState as F } from "react";
|
|
3
|
+
import { uyTv as I } from "@payfit/unity-themes";
|
|
4
|
+
import { useFilter as M, Select as z, Popover as A, Autocomplete as T, Virtualizer as p, ListLayout as d, ListBox as y } from "react-aria-components";
|
|
5
|
+
import { useIntl as U } from "react-intl";
|
|
6
|
+
import { SearchInput as V } from "./parts/SearchInput.js";
|
|
7
|
+
import { SelectButton as $ } from "./parts/SelectButton.js";
|
|
8
|
+
const k = I({
|
|
9
9
|
slots: {
|
|
10
10
|
base: "uy:flex uy:flex-col uy:gap-100 uy:w-full",
|
|
11
11
|
popover: "uy:rounded-100 uy:sm:rounded-75 uy:border uy:border-solid uy:border-border-neutral uy:w-[var(--trigger-width)] uy:bg-surface-neutral uy:shadow-300",
|
|
12
12
|
listbox: "uy:overflow-y-auto uy:max-h-[296px] uy:pt-100 uy:pb-100"
|
|
13
13
|
}
|
|
14
|
-
}),
|
|
14
|
+
}), q = ({
|
|
15
15
|
children: t,
|
|
16
16
|
items: o,
|
|
17
17
|
placeholder: r,
|
|
@@ -25,46 +25,48 @@ const $ = F({
|
|
|
25
25
|
onBlur: b,
|
|
26
26
|
placement: h,
|
|
27
27
|
searchInputAriaLabel: x,
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
28
|
+
renderValue: S,
|
|
29
|
+
...g
|
|
30
|
+
}, v) => {
|
|
31
|
+
const w = U(), [N, O] = F(!1), { contains: L } = M({ sensitivity: "base" }), { base: P, popover: j, listbox: u } = k(), B = n !== void 0 || i !== void 0 ? {
|
|
31
32
|
value: n,
|
|
32
33
|
onChange: i
|
|
33
34
|
} : { defaultValue: m };
|
|
34
35
|
return /* @__PURE__ */ c(
|
|
35
|
-
|
|
36
|
+
z,
|
|
36
37
|
{
|
|
37
|
-
onOpenChange:
|
|
38
|
-
...
|
|
39
|
-
ref:
|
|
40
|
-
className:
|
|
38
|
+
onOpenChange: O,
|
|
39
|
+
...g,
|
|
40
|
+
ref: v,
|
|
41
|
+
className: P(),
|
|
41
42
|
placeholder: s ? void 0 : r,
|
|
42
43
|
isDisabled: s || a,
|
|
43
44
|
isInvalid: l,
|
|
44
45
|
onBlur: b,
|
|
45
|
-
...
|
|
46
|
+
...B,
|
|
46
47
|
children: [
|
|
47
48
|
/* @__PURE__ */ e(
|
|
48
|
-
|
|
49
|
+
$,
|
|
49
50
|
{
|
|
50
51
|
isDisabled: s,
|
|
51
52
|
isInvalid: l,
|
|
52
53
|
isReadOnly: a,
|
|
53
|
-
isOpen:
|
|
54
|
+
isOpen: N,
|
|
55
|
+
renderValue: S
|
|
54
56
|
}
|
|
55
57
|
),
|
|
56
58
|
/* @__PURE__ */ e(
|
|
57
|
-
|
|
59
|
+
A,
|
|
58
60
|
{
|
|
59
61
|
offset: 1,
|
|
60
62
|
containerPadding: 8,
|
|
61
|
-
className:
|
|
63
|
+
className: j(),
|
|
62
64
|
placement: h,
|
|
63
|
-
children: f ? /* @__PURE__ */ c(
|
|
65
|
+
children: f ? /* @__PURE__ */ c(T, { filter: L, children: [
|
|
64
66
|
/* @__PURE__ */ e(
|
|
65
|
-
|
|
67
|
+
V,
|
|
66
68
|
{
|
|
67
|
-
"aria-label": x ??
|
|
69
|
+
"aria-label": x ?? w.formatMessage({
|
|
68
70
|
id: "unity:component:select:search:label",
|
|
69
71
|
defaultMessage: "Search options"
|
|
70
72
|
})
|
|
@@ -95,10 +97,10 @@ const $ = F({
|
|
|
95
97
|
]
|
|
96
98
|
}
|
|
97
99
|
);
|
|
98
|
-
},
|
|
99
|
-
return
|
|
100
|
+
}, E = C(function(o, r) {
|
|
101
|
+
return q(o, r);
|
|
100
102
|
});
|
|
101
|
-
|
|
103
|
+
E.displayName = "Select";
|
|
102
104
|
export {
|
|
103
|
-
|
|
105
|
+
E as Select
|
|
104
106
|
};
|
|
@@ -1,15 +1,21 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { forwardRef as
|
|
3
|
-
import { useFieldContext as
|
|
4
|
-
import { useFieldA11yContext as
|
|
5
|
-
import { Select as
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
import { jsx as m } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef as f } from "react";
|
|
3
|
+
import { useFieldContext as u } from "../../hooks/tanstack-form-context.js";
|
|
4
|
+
import { useFieldA11yContext as p } from "../form-field/TanstackFormField.context.js";
|
|
5
|
+
import { Select as b } from "./Select.js";
|
|
6
|
+
const h = ({
|
|
7
|
+
onBlur: o,
|
|
8
|
+
isReadOnly: a,
|
|
9
|
+
isDisabled: l,
|
|
10
|
+
renderValue: r,
|
|
11
|
+
...s
|
|
12
|
+
}, c) => {
|
|
13
|
+
const e = u(), t = p(), d = e.state.meta.isTouched && !e.state.meta.isValid, i = [t.helperTextId, t.feedbackTextId].filter(Boolean).join(" ");
|
|
14
|
+
return /* @__PURE__ */ m(
|
|
15
|
+
b,
|
|
10
16
|
{
|
|
11
|
-
...
|
|
12
|
-
ref:
|
|
17
|
+
...s,
|
|
18
|
+
ref: c,
|
|
13
19
|
value: e.state.value ?? "",
|
|
14
20
|
onChange: (n) => {
|
|
15
21
|
e.handleChange(n);
|
|
@@ -19,16 +25,17 @@ const b = ({ onBlur: o, isReadOnly: a, isDisabled: l, ...r }, s) => {
|
|
|
19
25
|
},
|
|
20
26
|
isReadOnly: a,
|
|
21
27
|
isDisabled: l,
|
|
22
|
-
isInvalid:
|
|
28
|
+
isInvalid: d,
|
|
23
29
|
"aria-labelledby": t.labelId,
|
|
24
30
|
"aria-describedby": i.length > 0 ? i : void 0,
|
|
25
|
-
"aria-details": t.contextualLinkId
|
|
31
|
+
"aria-details": t.contextualLinkId,
|
|
32
|
+
renderValue: r
|
|
26
33
|
}
|
|
27
34
|
);
|
|
28
|
-
},
|
|
29
|
-
return
|
|
35
|
+
}, x = f(function(a, l) {
|
|
36
|
+
return h(a, l);
|
|
30
37
|
});
|
|
31
|
-
|
|
38
|
+
x.displayName = "TanstackSelect";
|
|
32
39
|
export {
|
|
33
|
-
|
|
40
|
+
x as TanstackSelect
|
|
34
41
|
};
|
|
@@ -1,8 +1,19 @@
|
|
|
1
|
-
|
|
1
|
+
import { Node } from '@react-types/shared';
|
|
2
|
+
import { ReactNode } from 'react';
|
|
3
|
+
export interface SelectButtonProps<T extends object> {
|
|
4
|
+
/** Whether the button is disabled */
|
|
2
5
|
isDisabled?: boolean;
|
|
6
|
+
/** Whether the button is in an invalid state */
|
|
3
7
|
isInvalid?: boolean;
|
|
8
|
+
/** Whether the button is read-only */
|
|
4
9
|
isReadOnly?: boolean;
|
|
10
|
+
/** Whether the select popover is currently open */
|
|
5
11
|
isOpen: boolean;
|
|
12
|
+
/** Custom render function to format the selected value display */
|
|
13
|
+
renderValue?: (selectedItem: Node<T>) => ReactNode;
|
|
6
14
|
}
|
|
7
|
-
declare const SelectButton:
|
|
15
|
+
declare const SelectButton: {
|
|
16
|
+
<T extends object>({ isDisabled, isInvalid, isReadOnly, isOpen, renderValue, }: SelectButtonProps<T>): import("react/jsx-runtime").JSX.Element;
|
|
17
|
+
displayName: string;
|
|
18
|
+
};
|
|
8
19
|
export { SelectButton };
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { Button as b, SelectValue as p } from "react-aria-components";
|
|
1
|
+
import { jsxs as l, jsx as e } from "react/jsx-runtime";
|
|
2
|
+
import { uyTv as b } from "@payfit/unity-themes";
|
|
3
|
+
import { Button as p, SelectValue as n } from "react-aria-components";
|
|
5
4
|
import { useIntl as v } from "react-intl";
|
|
6
|
-
import { Icon as
|
|
7
|
-
const x =
|
|
5
|
+
import { Icon as u } from "../../icon/Icon.js";
|
|
6
|
+
const x = b({
|
|
8
7
|
slots: {
|
|
9
8
|
base: "uy:flex uy:flex-row uy:gap-100 uy:h-5.5 uy:sm:h-500 uy:py-125 uy:sm:py-100 uy:px-150 uy:rounded-100 uy:sm:rounded-75 uy:border-solid uy:focus-visible:ring-2 uy:focus-visible:ring-utility-focus-ring uy:focus-visible:ring-offset-2 uy:outline-none uy:border",
|
|
10
9
|
selectValue: [
|
|
@@ -52,49 +51,52 @@ const x = m({
|
|
|
52
51
|
isInvalid: !1,
|
|
53
52
|
isReadOnly: !1
|
|
54
53
|
}
|
|
55
|
-
}), h =
|
|
56
|
-
|
|
57
|
-
|
|
54
|
+
}), h = ({
|
|
55
|
+
isDisabled: r,
|
|
56
|
+
isInvalid: t,
|
|
57
|
+
isReadOnly: i,
|
|
58
|
+
isOpen: d,
|
|
59
|
+
renderValue: o
|
|
60
|
+
}) => {
|
|
61
|
+
const c = v(), { base: y, selectValue: a, iconWrapper: f, icon: m } = x({
|
|
62
|
+
isDisabled: r,
|
|
63
|
+
isInvalid: t,
|
|
64
|
+
isReadOnly: i
|
|
65
|
+
});
|
|
66
|
+
return /* @__PURE__ */ l(
|
|
67
|
+
p,
|
|
68
|
+
{
|
|
69
|
+
"data-dd-privacy": "mask",
|
|
70
|
+
className: y(),
|
|
58
71
|
isDisabled: r,
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
className: c(),
|
|
88
|
-
"aria-hidden": "true",
|
|
89
|
-
src: u ? "CaretUpOutlined" : "CaretDownOutlined"
|
|
90
|
-
}
|
|
91
|
-
)
|
|
92
|
-
] })
|
|
93
|
-
]
|
|
94
|
-
}
|
|
95
|
-
);
|
|
96
|
-
}
|
|
97
|
-
);
|
|
72
|
+
"data-unity-slot": "select-button",
|
|
73
|
+
children: [
|
|
74
|
+
o ? /* @__PURE__ */ e(n, { className: a(), translate: "no", children: ({ state: s }) => s.selectedItems[0] ? o(s.selectedItems[0]) : null }) : /* @__PURE__ */ e(n, { className: a(), translate: "no" }),
|
|
75
|
+
/* @__PURE__ */ l("div", { className: f(), children: [
|
|
76
|
+
t && /* @__PURE__ */ e(
|
|
77
|
+
u,
|
|
78
|
+
{
|
|
79
|
+
src: "WarningCircleOutlined",
|
|
80
|
+
color: "content.form.invalid",
|
|
81
|
+
alt: c.formatMessage({
|
|
82
|
+
id: "unity:component:form-field:form-input:error:alt",
|
|
83
|
+
defaultMessage: "Error"
|
|
84
|
+
})
|
|
85
|
+
}
|
|
86
|
+
),
|
|
87
|
+
/* @__PURE__ */ e(
|
|
88
|
+
u,
|
|
89
|
+
{
|
|
90
|
+
className: m(),
|
|
91
|
+
"aria-hidden": "true",
|
|
92
|
+
src: d ? "CaretUpOutlined" : "CaretDownOutlined"
|
|
93
|
+
}
|
|
94
|
+
)
|
|
95
|
+
] })
|
|
96
|
+
]
|
|
97
|
+
}
|
|
98
|
+
);
|
|
99
|
+
};
|
|
98
100
|
h.displayName = "SelectButton";
|
|
99
101
|
export {
|
|
100
102
|
h as SelectButton
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { forwardRef as
|
|
3
|
-
import { TanstackFormFeedbackText as
|
|
4
|
-
import { TanstackFormHelperText as
|
|
5
|
-
import { TanstackFormLabel as
|
|
6
|
-
import { TanstackFormField as
|
|
7
|
-
import { TanstackSelect as
|
|
8
|
-
const
|
|
1
|
+
import { jsxs as d, jsx as r } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef as f } from "react";
|
|
3
|
+
import { TanstackFormFeedbackText as k } from "../form-field/parts/TanstackFormFeedbackText.js";
|
|
4
|
+
import { TanstackFormHelperText as p } from "../form-field/parts/TanstackFormHelperText.js";
|
|
5
|
+
import { TanstackFormLabel as F } from "../form-field/parts/TanstackFormLabel.js";
|
|
6
|
+
import { TanstackFormField as T } from "../form-field/TanstackFormField.js";
|
|
7
|
+
import { TanstackSelect as S } from "../select/TanstackSelect.js";
|
|
8
|
+
const x = ({
|
|
9
9
|
label: a,
|
|
10
10
|
helperText: t,
|
|
11
11
|
contextualLink: e,
|
|
@@ -13,32 +13,34 @@ const S = ({
|
|
|
13
13
|
isDisabled: c,
|
|
14
14
|
isReadOnly: m,
|
|
15
15
|
requiredVariant: n,
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
renderValue: i,
|
|
17
|
+
...l
|
|
18
|
+
}, s) => /* @__PURE__ */ d(T, { children: [
|
|
18
19
|
/* @__PURE__ */ r(
|
|
19
|
-
|
|
20
|
+
F,
|
|
20
21
|
{
|
|
21
22
|
requiredVariant: n,
|
|
22
23
|
isRequired: o,
|
|
23
24
|
children: a
|
|
24
25
|
}
|
|
25
26
|
),
|
|
26
|
-
t && /* @__PURE__ */ r(
|
|
27
|
+
t && /* @__PURE__ */ r(p, { children: t }),
|
|
27
28
|
/* @__PURE__ */ r(
|
|
28
|
-
|
|
29
|
+
S,
|
|
29
30
|
{
|
|
30
|
-
ref:
|
|
31
|
+
ref: s,
|
|
31
32
|
isDisabled: c,
|
|
32
33
|
isReadOnly: m,
|
|
33
|
-
|
|
34
|
+
renderValue: i,
|
|
35
|
+
...l
|
|
34
36
|
}
|
|
35
37
|
),
|
|
36
|
-
/* @__PURE__ */ r(
|
|
38
|
+
/* @__PURE__ */ r(k, {}),
|
|
37
39
|
e
|
|
38
|
-
] }),
|
|
39
|
-
return
|
|
40
|
+
] }), u = f(function(t, e) {
|
|
41
|
+
return x(t, e);
|
|
40
42
|
});
|
|
41
|
-
|
|
43
|
+
u.displayName = "TanstackSelectField";
|
|
42
44
|
export {
|
|
43
|
-
|
|
45
|
+
u as TanstackSelectField
|
|
44
46
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@payfit/unity-components",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.7.0",
|
|
4
4
|
"module": "./dist/esm/index.js",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
"@hookform/devtools": "4.4.0",
|
|
43
43
|
"@hookform/resolvers": "5.2.1",
|
|
44
44
|
"@internationalized/date": "3.11.0",
|
|
45
|
-
"@payfit/unity-illustrations": "2.
|
|
45
|
+
"@payfit/unity-illustrations": "2.7.0",
|
|
46
46
|
"@radix-ui/react-avatar": "1.1.11",
|
|
47
47
|
"@radix-ui/react-slot": "1.2.4",
|
|
48
48
|
"@react-aria/interactions": "3.27.0",
|
|
@@ -71,8 +71,8 @@
|
|
|
71
71
|
},
|
|
72
72
|
"peerDependencies": {
|
|
73
73
|
"@hookform/devtools": "^4",
|
|
74
|
-
"@payfit/unity-icons": "2.
|
|
75
|
-
"@payfit/unity-themes": "2.
|
|
74
|
+
"@payfit/unity-icons": "2.7.0",
|
|
75
|
+
"@payfit/unity-themes": "2.7.0",
|
|
76
76
|
"@storybook/react-vite": "^10.2.2",
|
|
77
77
|
"@tanstack/react-query": "^5",
|
|
78
78
|
"@tanstack/react-router": "^1.131",
|
|
@@ -91,9 +91,9 @@
|
|
|
91
91
|
"@payfit/hr-apps-tsconfigs": "0.0.0-use.local",
|
|
92
92
|
"@payfit/storybook-addon-console-errors": "0.0.0-use.local",
|
|
93
93
|
"@payfit/storybook-config": "0.0.0-use.local",
|
|
94
|
-
"@payfit/unity-icons": "2.
|
|
95
|
-
"@payfit/unity-illustrations": "2.
|
|
96
|
-
"@payfit/unity-themes": "2.
|
|
94
|
+
"@payfit/unity-icons": "2.7.0",
|
|
95
|
+
"@payfit/unity-illustrations": "2.7.0",
|
|
96
|
+
"@payfit/unity-themes": "2.7.0",
|
|
97
97
|
"@payfit/vite-configs": "0.0.0-use.local",
|
|
98
98
|
"@storybook/addon-a11y": "10.2.7",
|
|
99
99
|
"@storybook/addon-docs": "10.2.7",
|