@payfit/unity-components 1.1.1-beta.1 → 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 +31 -1
- package/dist/esm/components/code/Code.js +39 -0
- package/dist/esm/components/code/copyToClipboard.js +10 -0
- 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/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/parts/FunnelPageActions.js +24 -24
- 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/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 +15 -0
- package/i18n/es-ES.json +15 -0
- package/i18n/fr-FR.json +15 -0
- package/package.json +25 -22
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { StandardSchemaV1 } from '@standard-schema/spec';
|
|
2
|
+
import { StandardSchema, StandardSchemaField } from '../types/schema.js';
|
|
3
|
+
export declare class StandardSchemaAdapter implements StandardSchema {
|
|
4
|
+
private standardSchema;
|
|
5
|
+
constructor(standardSchema: StandardSchemaV1);
|
|
6
|
+
getField(path: string): StandardSchemaField | null;
|
|
7
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
class r {
|
|
2
|
+
constructor(t) {
|
|
3
|
+
this.standardSchema = t;
|
|
4
|
+
}
|
|
5
|
+
getField(t) {
|
|
6
|
+
try {
|
|
7
|
+
return this.standardSchema ? {
|
|
8
|
+
isOptional: !1,
|
|
9
|
+
// Default to required - can be enhanced with actual validation logic
|
|
10
|
+
type: "unknown",
|
|
11
|
+
shape: void 0
|
|
12
|
+
} : null;
|
|
13
|
+
} catch {
|
|
14
|
+
return null;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
export {
|
|
19
|
+
r as StandardSchemaAdapter
|
|
20
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { StandardSchema, StandardSchemaField } from '../types/schema.js';
|
|
2
|
+
import { z as z3 } from 'zod/v3';
|
|
3
|
+
import { z as z4 } from 'zod/v4';
|
|
4
|
+
export declare class ZodV3SchemaAdapter implements StandardSchema {
|
|
5
|
+
private zodSchema;
|
|
6
|
+
constructor(zodSchema: z3.ZodObject<z3.ZodRawShape>);
|
|
7
|
+
getField(path: string): StandardSchemaField | null;
|
|
8
|
+
}
|
|
9
|
+
export declare class ZodV4SchemaAdapter implements StandardSchema {
|
|
10
|
+
private zodSchema;
|
|
11
|
+
constructor(zodSchema: z4.ZodObject<z4.ZodRawShape>);
|
|
12
|
+
getField(path: string): StandardSchemaField | null;
|
|
13
|
+
}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { z as c } from "zod/v3";
|
|
2
|
+
import { z as p } from "zod/v4";
|
|
3
|
+
class u {
|
|
4
|
+
constructor(n) {
|
|
5
|
+
this.zodSchema = n;
|
|
6
|
+
}
|
|
7
|
+
getField(n) {
|
|
8
|
+
try {
|
|
9
|
+
if (!this.zodSchema) return null;
|
|
10
|
+
const a = n.split(".");
|
|
11
|
+
let r = this.zodSchema.shape, e;
|
|
12
|
+
for (let t = 0; t < a.length; t++) {
|
|
13
|
+
const l = a[t];
|
|
14
|
+
if (e = r[l], !e) return null;
|
|
15
|
+
if (t < a.length - 1) {
|
|
16
|
+
const i = e instanceof c.ZodOptional ? e._def.innerType.shape : e.shape;
|
|
17
|
+
if (!i) return null;
|
|
18
|
+
r = i;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
const s = e instanceof c.ZodOptional, o = s ? e._def.innerType : e;
|
|
22
|
+
return {
|
|
23
|
+
isOptional: s,
|
|
24
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-member-access
|
|
25
|
+
type: o._def?.typeName || "unknown",
|
|
26
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
27
|
+
shape: o instanceof c.ZodObject ? (
|
|
28
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
29
|
+
o.shape
|
|
30
|
+
) : void 0
|
|
31
|
+
};
|
|
32
|
+
} catch {
|
|
33
|
+
return null;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
class m {
|
|
38
|
+
constructor(n) {
|
|
39
|
+
this.zodSchema = n;
|
|
40
|
+
}
|
|
41
|
+
getField(n) {
|
|
42
|
+
try {
|
|
43
|
+
if (!this.zodSchema) return null;
|
|
44
|
+
const a = n.split(".");
|
|
45
|
+
let r = this.zodSchema.shape, e;
|
|
46
|
+
for (let t = 0; t < a.length; t++) {
|
|
47
|
+
const l = a[t];
|
|
48
|
+
if (e = r[l], !e) return null;
|
|
49
|
+
if (t < a.length - 1) {
|
|
50
|
+
const i = e instanceof p.ZodOptional ? e.def.innerType.shape : e.shape;
|
|
51
|
+
if (!i) return null;
|
|
52
|
+
r = i;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
const s = e instanceof p.ZodOptional, o = s ? e.def.innerType : e;
|
|
56
|
+
return {
|
|
57
|
+
isOptional: s,
|
|
58
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-member-access
|
|
59
|
+
type: o.def?.typeName || "unknown",
|
|
60
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
61
|
+
shape: o instanceof p.ZodObject ? (
|
|
62
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
63
|
+
o.shape
|
|
64
|
+
) : void 0
|
|
65
|
+
};
|
|
66
|
+
} catch {
|
|
67
|
+
return null;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
export {
|
|
72
|
+
u as ZodV3SchemaAdapter,
|
|
73
|
+
m as ZodV4SchemaAdapter
|
|
74
|
+
};
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import { jsxs as n, jsx as
|
|
2
|
-
import
|
|
3
|
-
import { uyTv as
|
|
4
|
-
import { Toolbar as
|
|
5
|
-
import { useIntl as
|
|
6
|
-
import { Button as
|
|
7
|
-
import { IconButton as
|
|
8
|
-
import { Icon as
|
|
9
|
-
import { Menu as
|
|
10
|
-
import { MenuContent as
|
|
11
|
-
import { MenuItem as
|
|
12
|
-
import { MenuTrigger as
|
|
13
|
-
import { ActionBarAction as
|
|
14
|
-
const
|
|
1
|
+
import { jsxs as n, jsx as t } from "react/jsx-runtime";
|
|
2
|
+
import P, { forwardRef as T, useCallback as j, isValidElement as z } from "react";
|
|
3
|
+
import { uyTv as D } from "@payfit/unity-themes";
|
|
4
|
+
import { Toolbar as R, Group as y } from "react-aria-components";
|
|
5
|
+
import { useIntl as S, FormattedMessage as l } from "react-intl";
|
|
6
|
+
import { Button as _ } from "../button/Button.js";
|
|
7
|
+
import { IconButton as E } from "../icon-button/IconButton.js";
|
|
8
|
+
import { Icon as F } from "../icon/Icon.js";
|
|
9
|
+
import { Menu as G } from "../menu/Menu.js";
|
|
10
|
+
import { MenuContent as K } from "../menu/parts/MenuContent.js";
|
|
11
|
+
import { MenuItem as L } from "../menu/parts/MenuItem.js";
|
|
12
|
+
import { MenuTrigger as O } from "../menu/parts/MenuTrigger.js";
|
|
13
|
+
import { ActionBarAction as U } from "./parts/ActionBarAction.js";
|
|
14
|
+
const V = D({
|
|
15
15
|
slots: {
|
|
16
16
|
base: [
|
|
17
17
|
"uy:bg-surface-inverted uy:text-content-inverted",
|
|
@@ -30,59 +30,58 @@ const q = R({
|
|
|
30
30
|
"uy:md:not-sr-only"
|
|
31
31
|
]
|
|
32
32
|
}
|
|
33
|
-
}),
|
|
33
|
+
}), q = T(
|
|
34
34
|
({
|
|
35
|
-
id:
|
|
35
|
+
id: d,
|
|
36
36
|
selectionCount: u,
|
|
37
|
-
onClearSelection:
|
|
37
|
+
onClearSelection: f,
|
|
38
38
|
children: r,
|
|
39
39
|
actions: a,
|
|
40
40
|
renderSelectionText: c,
|
|
41
|
-
"aria-label":
|
|
42
|
-
onFocus:
|
|
43
|
-
onBlur:
|
|
41
|
+
"aria-label": p,
|
|
42
|
+
onFocus: b,
|
|
43
|
+
onBlur: h,
|
|
44
44
|
...i
|
|
45
|
-
},
|
|
46
|
-
|
|
47
|
-
const { base: x, selectionArea: A, selectionCountText: M, actionArea: k } = q(), m = _(), s = a !== void 0 && typeof r == "function", B = i["aria-keyshortcuts"] !== void 0, I = b ?? m.formatMessage({
|
|
45
|
+
}, v) => {
|
|
46
|
+
const { base: g, selectionArea: x, selectionCountText: A, actionArea: M } = V(), m = S(), s = a !== void 0 && typeof r == "function", k = i["aria-keyshortcuts"] !== void 0, B = p ?? m.formatMessage({
|
|
48
47
|
id: "unity:component:action-bar:toolbar-label",
|
|
49
48
|
defaultMessage: "Bulk actions toolbar"
|
|
50
|
-
}),
|
|
49
|
+
}), I = j(() => {
|
|
51
50
|
if (s) {
|
|
52
51
|
const e = r;
|
|
53
|
-
return a.map((
|
|
52
|
+
return a.map((o, N) => e(o, N));
|
|
54
53
|
}
|
|
55
54
|
return r;
|
|
56
|
-
}, [r, a, s]),
|
|
57
|
-
if (!
|
|
55
|
+
}, [r, a, s]), C = !!r || "actions" in i && i.actions.length > 0, w = s ? a.filter((e) => e.variant !== "primary") : P.Children.map(r, (e) => {
|
|
56
|
+
if (!z(e) || e.type !== U)
|
|
58
57
|
return null;
|
|
59
|
-
const
|
|
60
|
-
return
|
|
61
|
-
...
|
|
62
|
-
id: e.key ??
|
|
63
|
-
onPress:
|
|
64
|
-
label:
|
|
65
|
-
variant:
|
|
66
|
-
prefixIcon:
|
|
58
|
+
const o = e.props;
|
|
59
|
+
return o.variant === "primary" ? null : {
|
|
60
|
+
...o,
|
|
61
|
+
id: e.key ?? o.id,
|
|
62
|
+
onPress: o.onPress,
|
|
63
|
+
label: o.children,
|
|
64
|
+
variant: o.variant,
|
|
65
|
+
prefixIcon: o.prefixIcon
|
|
67
66
|
};
|
|
68
|
-
})
|
|
67
|
+
})?.filter(Boolean);
|
|
69
68
|
return /* @__PURE__ */ n(
|
|
70
|
-
|
|
69
|
+
R,
|
|
71
70
|
{
|
|
72
71
|
...i,
|
|
73
|
-
id:
|
|
74
|
-
ref:
|
|
75
|
-
className:
|
|
76
|
-
"aria-label":
|
|
72
|
+
id: d,
|
|
73
|
+
ref: v,
|
|
74
|
+
className: g(),
|
|
75
|
+
"aria-label": B,
|
|
77
76
|
orientation: "horizontal",
|
|
78
77
|
tabIndex: -1,
|
|
79
|
-
onFocus:
|
|
80
|
-
onBlur:
|
|
78
|
+
onFocus: b,
|
|
79
|
+
onBlur: h,
|
|
81
80
|
children: [
|
|
82
81
|
/* @__PURE__ */ n(
|
|
83
|
-
|
|
82
|
+
y,
|
|
84
83
|
{
|
|
85
|
-
className:
|
|
84
|
+
className: x(),
|
|
86
85
|
"aria-label": m.formatMessage({
|
|
87
86
|
id: "unity:component:action-bar:group:label",
|
|
88
87
|
defaultMessage: "Selection information"
|
|
@@ -91,12 +90,12 @@ const q = R({
|
|
|
91
90
|
/* @__PURE__ */ n(
|
|
92
91
|
"div",
|
|
93
92
|
{
|
|
94
|
-
className:
|
|
93
|
+
className: A(),
|
|
95
94
|
role: "status",
|
|
96
95
|
"aria-live": "polite",
|
|
97
96
|
"aria-atomic": "true",
|
|
98
97
|
children: [
|
|
99
|
-
c ? c(u) : /* @__PURE__ */
|
|
98
|
+
c ? c(u) : /* @__PURE__ */ t(
|
|
100
99
|
l,
|
|
101
100
|
{
|
|
102
101
|
id: "unity:component:action-bar:selection-count-text",
|
|
@@ -104,7 +103,7 @@ const q = R({
|
|
|
104
103
|
values: { selectionCount: u }
|
|
105
104
|
}
|
|
106
105
|
),
|
|
107
|
-
|
|
106
|
+
k && /* @__PURE__ */ t("span", { className: "uy:sr-only", children: /* @__PURE__ */ t(
|
|
108
107
|
l,
|
|
109
108
|
{
|
|
110
109
|
id: "unity:component:action-bar:key-shortcuts-text",
|
|
@@ -117,7 +116,7 @@ const q = R({
|
|
|
117
116
|
]
|
|
118
117
|
}
|
|
119
118
|
),
|
|
120
|
-
/* @__PURE__ */
|
|
119
|
+
/* @__PURE__ */ t(_, { color: "inverted", variant: "ghost", onPress: f, children: /* @__PURE__ */ t(
|
|
121
120
|
l,
|
|
122
121
|
{
|
|
123
122
|
id: "unity:component:action-bar:clear-selection-button",
|
|
@@ -127,17 +126,17 @@ const q = R({
|
|
|
127
126
|
]
|
|
128
127
|
}
|
|
129
128
|
),
|
|
130
|
-
|
|
131
|
-
|
|
129
|
+
C && /* @__PURE__ */ n(
|
|
130
|
+
y,
|
|
132
131
|
{
|
|
133
|
-
className:
|
|
132
|
+
className: M(),
|
|
134
133
|
role: "group",
|
|
135
134
|
"aria-label": "Available actions",
|
|
136
135
|
children: [
|
|
137
|
-
|
|
138
|
-
/* @__PURE__ */
|
|
139
|
-
/* @__PURE__ */
|
|
140
|
-
|
|
136
|
+
I(),
|
|
137
|
+
/* @__PURE__ */ t("div", { className: "uy:block uy:md:hidden", children: /* @__PURE__ */ n(G, { children: [
|
|
138
|
+
/* @__PURE__ */ t(O, { asChild: !0, children: /* @__PURE__ */ t(
|
|
139
|
+
E,
|
|
141
140
|
{
|
|
142
141
|
icon: "DotsThreeOutlined",
|
|
143
142
|
label: "More actions",
|
|
@@ -145,14 +144,13 @@ const q = R({
|
|
|
145
144
|
color: "inverted"
|
|
146
145
|
}
|
|
147
146
|
) }),
|
|
148
|
-
/* @__PURE__ */
|
|
149
|
-
|
|
147
|
+
/* @__PURE__ */ t(K, { children: w.map((e) => /* @__PURE__ */ t(
|
|
148
|
+
L,
|
|
150
149
|
{
|
|
151
150
|
onAction: () => {
|
|
152
|
-
|
|
153
|
-
(t = e.onPress) == null || t.call(e, {});
|
|
151
|
+
e.onPress?.({});
|
|
154
152
|
},
|
|
155
|
-
prefix: e.prefixIcon ? /* @__PURE__ */
|
|
153
|
+
prefix: e.prefixIcon ? /* @__PURE__ */ t(F, { src: e.prefixIcon, size: 20 }) : void 0,
|
|
156
154
|
children: e.label
|
|
157
155
|
},
|
|
158
156
|
e.id
|
|
@@ -166,8 +164,8 @@ const q = R({
|
|
|
166
164
|
);
|
|
167
165
|
}
|
|
168
166
|
);
|
|
169
|
-
|
|
167
|
+
q.displayName = "ActionBar";
|
|
170
168
|
export {
|
|
171
|
-
|
|
172
|
-
|
|
169
|
+
q as ActionBar,
|
|
170
|
+
V as actionBar
|
|
173
171
|
};
|
|
@@ -5,10 +5,57 @@ export interface ActionableProps extends AriaButtonProps {
|
|
|
5
5
|
/** set to true to remove the Actionable's base styles */
|
|
6
6
|
isUnstyled?: boolean;
|
|
7
7
|
/** The HTML element to render the actionable as. */
|
|
8
|
-
asElement?: 'span' | 'div';
|
|
8
|
+
asElement?: 'span' | 'div' | 'button';
|
|
9
9
|
}
|
|
10
10
|
/**
|
|
11
|
-
*
|
|
11
|
+
* Actionable primitive creates interactive surfaces that behave like buttons while allowing complete control over appearance and content.
|
|
12
|
+
* Use this component when you need to build complex interactive elements that require custom styling or dynamic content based on interaction states, and when standard Unity button components are insufficient for your use case.
|
|
13
|
+
* @param {ActionableProps} props - Button behavior props from React Aria, plus styling and element configuration
|
|
14
|
+
* @example
|
|
15
|
+
* ```tsx
|
|
16
|
+
* // Basic usage with custom styling
|
|
17
|
+
* import { Actionable } from '@payfit/unity-components'
|
|
18
|
+
*
|
|
19
|
+
* function Example() {
|
|
20
|
+
* return (
|
|
21
|
+
* <Actionable
|
|
22
|
+
* className="uy:p-100 uy:rounded-100 uy:border uy:border-border-neutral uy:hover:bg-surface-neutral-hover"
|
|
23
|
+
* onPress={() => console.log('Pressed!')}
|
|
24
|
+
* >
|
|
25
|
+
* Click me
|
|
26
|
+
* </Actionable>
|
|
27
|
+
* )
|
|
28
|
+
* }
|
|
29
|
+
* ```
|
|
30
|
+
* @example
|
|
31
|
+
* ```tsx
|
|
32
|
+
* // Dynamic content based on interaction state
|
|
33
|
+
* import { Actionable, Icon } from '@payfit/unity-components'
|
|
34
|
+
*
|
|
35
|
+
* function Example() {
|
|
36
|
+
* return (
|
|
37
|
+
* <Actionable asElement="button" className="uy:p-100 uy:flex uy:items-center uy:gap-100">
|
|
38
|
+
* {({ isHovered, isPressed }) => (
|
|
39
|
+
* <>
|
|
40
|
+
* <Icon src={isHovered || isPressed ? 'CakeFilled' : 'CakeOutlined'} />
|
|
41
|
+
* <span>Interactive content</span>
|
|
42
|
+
* </>
|
|
43
|
+
* )}
|
|
44
|
+
* </Actionable>
|
|
45
|
+
* )
|
|
46
|
+
* }
|
|
47
|
+
* ```
|
|
48
|
+
* @remarks
|
|
49
|
+
* - Provides button-like interaction behavior using React Aria hooks for accessibility
|
|
50
|
+
* - Supports rendering as `div`, `span`, or `button` elements via the `asElement` prop
|
|
51
|
+
* - Includes built-in state management for hover, focus, and press interactions
|
|
52
|
+
* - Automatically applies appropriate ARIA attributes and keyboard navigation
|
|
53
|
+
* - Supports both static children and render prop pattern for dynamic content
|
|
54
|
+
* - Use data attributes (`data-hovered`, `data-pressed`, `data-focused`, `data-disabled`, `data-focus-visible`) for styling non-button elements
|
|
55
|
+
* - Marked as `uy:group` for styling child elements based on parent state
|
|
56
|
+
* @see {@link ActionableProps} for all available props
|
|
57
|
+
* @see Source code in {@link https://github.com/PayFit/hr-apps/tree/master/libs/shared/unity/components/src/components/actionable GitHub}
|
|
58
|
+
* @see Developer docs in {@link https://unity-components.payfit.io/?path=/docs/primitives-actionable--docs unity-components.payfit.io}
|
|
12
59
|
*/
|
|
13
|
-
declare const Actionable: import('react').ForwardRefExoticComponent<ActionableProps & import('react').RefAttributes<HTMLDivElement>>;
|
|
60
|
+
declare const Actionable: import('react').ForwardRefExoticComponent<ActionableProps & import('react').RefAttributes<HTMLButtonElement | HTMLDivElement | HTMLSpanElement>>;
|
|
14
61
|
export { Actionable };
|
|
@@ -1,64 +1,74 @@
|
|
|
1
|
-
import { jsx as
|
|
1
|
+
import { jsx as C } from "react/jsx-runtime";
|
|
2
2
|
import { forwardRef as H, useState as k } from "react";
|
|
3
3
|
import { uyTv as F } from "@payfit/unity-themes";
|
|
4
4
|
import { useFocusVisible as E, useHover as x, useFocus as N } from "@react-aria/interactions";
|
|
5
|
-
import { useObjectRef as S, mergeProps as
|
|
5
|
+
import { useObjectRef as S, mergeProps as p } from "@react-aria/utils";
|
|
6
6
|
import { useButton as U } from "react-aria";
|
|
7
7
|
const V = F({
|
|
8
|
-
base: "uy:group
|
|
8
|
+
base: "uy:group",
|
|
9
9
|
variants: {
|
|
10
10
|
isUnstyled: {
|
|
11
11
|
true: "",
|
|
12
|
-
false:
|
|
12
|
+
false: [
|
|
13
|
+
"uy:cursor-pointer",
|
|
14
|
+
"uy:aria-disabled:cursor-not-allowed",
|
|
15
|
+
"uy:aria-disabled:text-content-neutral-disabled"
|
|
16
|
+
]
|
|
13
17
|
}
|
|
14
18
|
},
|
|
15
19
|
defaultVariants: {
|
|
16
20
|
isUnstyled: !1
|
|
17
21
|
}
|
|
18
|
-
}), j = H((
|
|
22
|
+
}), j = H((f, e) => {
|
|
19
23
|
const {
|
|
20
|
-
asElement:
|
|
21
|
-
isUnstyled:
|
|
22
|
-
className:
|
|
24
|
+
asElement: l = "div",
|
|
25
|
+
isUnstyled: m = !1,
|
|
26
|
+
className: v,
|
|
23
27
|
children: o,
|
|
24
|
-
...
|
|
25
|
-
} =
|
|
26
|
-
|
|
27
|
-
const { isFocusVisible:
|
|
28
|
-
onHoverStart:
|
|
29
|
-
onHoverEnd:
|
|
30
|
-
onHoverChange:
|
|
31
|
-
isDisabled:
|
|
32
|
-
}), [
|
|
33
|
-
onFocusChange:
|
|
34
|
-
isDisabled:
|
|
35
|
-
}), { buttonProps:
|
|
28
|
+
...s
|
|
29
|
+
} = f;
|
|
30
|
+
e = S(e);
|
|
31
|
+
const { isFocusVisible: i } = E(), { isHovered: a, hoverProps: d } = x({
|
|
32
|
+
onHoverStart: s.onHoverStart,
|
|
33
|
+
onHoverEnd: s.onHoverEnd,
|
|
34
|
+
onHoverChange: s.onHoverChange,
|
|
35
|
+
isDisabled: s.isDisabled
|
|
36
|
+
}), [t, D] = k(!1), { focusProps: c } = N({
|
|
37
|
+
onFocusChange: D,
|
|
38
|
+
isDisabled: s.isDisabled
|
|
39
|
+
}), { buttonProps: u, isPressed: r } = U(
|
|
36
40
|
{
|
|
37
|
-
...
|
|
38
|
-
|
|
41
|
+
...s,
|
|
42
|
+
isDisabled: s.isDisabled,
|
|
43
|
+
elementType: l
|
|
39
44
|
},
|
|
40
|
-
|
|
41
|
-
),
|
|
42
|
-
if (
|
|
43
|
-
|
|
45
|
+
e
|
|
46
|
+
), y = l, g = (n) => {
|
|
47
|
+
if (s.isDisabled) {
|
|
48
|
+
n.preventDefault(), n.stopPropagation();
|
|
44
49
|
return;
|
|
45
50
|
}
|
|
46
|
-
const
|
|
47
|
-
|
|
48
|
-
},
|
|
49
|
-
return /* @__PURE__ */
|
|
50
|
-
|
|
51
|
+
const b = p(u, d, c);
|
|
52
|
+
b.onClick && b.onClick(n);
|
|
53
|
+
}, P = p(u, d, c), { onClick: w, ...h } = P;
|
|
54
|
+
return /* @__PURE__ */ C(
|
|
55
|
+
y,
|
|
51
56
|
{
|
|
52
57
|
...h,
|
|
53
|
-
onClick:
|
|
54
|
-
className: V({ isUnstyled:
|
|
55
|
-
|
|
58
|
+
onClick: g,
|
|
59
|
+
className: V({ isUnstyled: m, className: v }),
|
|
60
|
+
...r && { "data-pressed": r },
|
|
61
|
+
...t && { "data-focused": t },
|
|
62
|
+
...a && { "data-hovered": a },
|
|
63
|
+
...s.isDisabled && { "data-disabled": s.isDisabled },
|
|
64
|
+
...i && { "data-focus-visible": i },
|
|
65
|
+
ref: e,
|
|
56
66
|
children: typeof o == "function" ? o({
|
|
57
|
-
isHovered:
|
|
58
|
-
isPressed:
|
|
59
|
-
isFocused:
|
|
60
|
-
isDisabled: !!
|
|
61
|
-
isFocusVisible:
|
|
67
|
+
isHovered: a,
|
|
68
|
+
isPressed: r,
|
|
69
|
+
isFocused: t,
|
|
70
|
+
isDisabled: !!s.isDisabled,
|
|
71
|
+
isFocusVisible: i,
|
|
62
72
|
isPending: !1,
|
|
63
73
|
defaultChildren: null
|
|
64
74
|
}) : o
|