@payfit/unity-components 2.5.7 → 2.6.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.
Files changed (36) hide show
  1. package/dist/esm/components/empty-state/EmptyState.d.ts +48 -0
  2. package/dist/esm/components/empty-state/EmptyState.js +25 -0
  3. package/dist/esm/components/empty-state/EmptyState.variants.d.ts +59 -0
  4. package/dist/esm/components/empty-state/EmptyState.variants.js +24 -0
  5. package/dist/esm/components/empty-state/parts/EmptyStateActions.d.ts +39 -0
  6. package/dist/esm/components/empty-state/parts/EmptyStateActions.js +17 -0
  7. package/dist/esm/components/empty-state/parts/EmptyStateContent.d.ts +40 -0
  8. package/dist/esm/components/empty-state/parts/EmptyStateContent.js +21 -0
  9. package/dist/esm/components/empty-state/parts/EmptyStateIcon.d.ts +41 -0
  10. package/dist/esm/components/empty-state/parts/EmptyStateIcon.js +14 -0
  11. package/dist/esm/components/empty-state/presets/EmptyStateGetStarted.d.ts +41 -0
  12. package/dist/esm/components/empty-state/presets/EmptyStateGetStarted.js +28 -0
  13. package/dist/esm/components/empty-state/presets/EmptyStateGoodJob.d.ts +29 -0
  14. package/dist/esm/components/empty-state/presets/EmptyStateGoodJob.js +55 -0
  15. package/dist/esm/components/empty-state/presets/EmptyStateNoSearchResults.d.ts +38 -0
  16. package/dist/esm/components/empty-state/presets/EmptyStateNoSearchResults.js +28 -0
  17. package/dist/esm/components/empty-state/presets/EmptyStateUpgradeRequired.d.ts +37 -0
  18. package/dist/esm/components/empty-state/presets/EmptyStateUpgradeRequired.js +28 -0
  19. package/dist/esm/components/empty-state/presets/EmptyStateUseDesktop.d.ts +28 -0
  20. package/dist/esm/components/empty-state/presets/EmptyStateUseDesktop.js +26 -0
  21. package/dist/esm/components/empty-state/presets/EmptyStateWaitingForData.d.ts +38 -0
  22. package/dist/esm/components/empty-state/presets/EmptyStateWaitingForData.js +28 -0
  23. package/dist/esm/components/inline-field/InlineField.js +15 -6
  24. package/dist/esm/components/inline-field-group/InlineFieldGroup.context.d.ts +12 -0
  25. package/dist/esm/components/inline-field-group/InlineFieldGroup.d.ts +39 -0
  26. package/dist/esm/components/inline-field-group/InlineFieldGroup.js +119 -93
  27. package/dist/esm/components/inline-field-group/parts/InlineFieldGroupActions.d.ts +24 -0
  28. package/dist/esm/components/inline-field-group/parts/InlineFieldGroupActions.js +158 -0
  29. package/dist/esm/components/inline-field-group/parts/InlineFieldGroupHeader.d.ts +11 -35
  30. package/dist/esm/components/inline-field-group/parts/InlineFieldGroupHeader.js +27 -94
  31. package/dist/esm/index.d.ts +10 -0
  32. package/dist/esm/index.js +431 -411
  33. package/i18n/en-GB.json +9 -0
  34. package/i18n/es-ES.json +9 -0
  35. package/i18n/fr-FR.json +9 -0
  36. package/package.json +7 -7
@@ -0,0 +1,158 @@
1
+ import { jsxs as c, Fragment as y, jsx as i } from "react/jsx-runtime";
2
+ import { useContext as E, useMemo as G } from "react";
3
+ import { uyTv as S } from "@payfit/unity-themes";
4
+ import { useStore as A } from "@tanstack/react-form";
5
+ import { useIntl as B } from "react-intl";
6
+ import { useFormContext as j } from "../../../hooks/tanstack-form-context.js";
7
+ import { useBreakpointListener as k } from "../../../hooks/use-breakpoint-listener.js";
8
+ import { Button as n } from "../../button/Button.js";
9
+ import { InlineFieldGroupContext as V } from "../InlineFieldGroup.context.js";
10
+ const O = S({
11
+ slots: {
12
+ container: "",
13
+ button: ""
14
+ },
15
+ variants: {
16
+ orientation: {
17
+ horizontal: {
18
+ container: "uy:flex uy:gap-100 uy:items-center"
19
+ },
20
+ vertical: {
21
+ container: "uy:flex uy:flex-col uy:gap-100 uy:w-full",
22
+ button: "uy:w-full"
23
+ }
24
+ }
25
+ },
26
+ defaultVariants: {
27
+ orientation: "horizontal"
28
+ }
29
+ });
30
+ function R({
31
+ orientation: b = "horizontal",
32
+ customActions: g
33
+ }) {
34
+ const o = B(), m = E(V), f = k(), p = f === "xs" || f === "sm";
35
+ if (!m)
36
+ throw new Error(
37
+ "InlineFieldGroupActions must be used within InlineFieldGroup"
38
+ );
39
+ const {
40
+ mode: v,
41
+ enterEditMode: x,
42
+ exitEditMode: s,
43
+ editViewId: h,
44
+ isLoading: e,
45
+ editButtonRef: M,
46
+ editLabel: P,
47
+ saveLabel: z,
48
+ cancelLabel: D,
49
+ onEditPress: I,
50
+ onSavePress: r,
51
+ onCancelPress: a
52
+ } = m, L = j(), { isDirty: l } = A(L.store, (C) => ({
53
+ isDirty: C.isDirty
54
+ })), { container: F, button: t } = O({ orientation: b }), N = P || o.formatMessage({
55
+ id: "unity:component:inline-field-group:edit",
56
+ defaultMessage: "Edit"
57
+ }), d = z || o.formatMessage({
58
+ id: "unity:component:inline-field-group:save",
59
+ defaultMessage: "Save"
60
+ }), u = D || o.formatMessage({
61
+ id: "unity:component:inline-field-group:cancel",
62
+ defaultMessage: "Cancel"
63
+ }), w = G(() => p ? /* @__PURE__ */ c(y, { children: [
64
+ /* @__PURE__ */ i(
65
+ n,
66
+ {
67
+ variant: "primary",
68
+ size: "default",
69
+ isDisabled: !l || e,
70
+ isLoading: e,
71
+ type: "submit",
72
+ onPress: () => {
73
+ r?.();
74
+ },
75
+ className: t(),
76
+ children: d
77
+ }
78
+ ),
79
+ /* @__PURE__ */ i(
80
+ n,
81
+ {
82
+ variant: "secondary",
83
+ size: "default",
84
+ onPress: () => {
85
+ a?.(), s();
86
+ },
87
+ isDisabled: e,
88
+ type: "button",
89
+ className: t(),
90
+ children: u
91
+ }
92
+ )
93
+ ] }) : /* @__PURE__ */ c(y, { children: [
94
+ /* @__PURE__ */ i(
95
+ n,
96
+ {
97
+ variant: "secondary",
98
+ size: "default",
99
+ onPress: () => {
100
+ a?.(), s();
101
+ },
102
+ isDisabled: e,
103
+ type: "button",
104
+ className: t(),
105
+ children: u
106
+ }
107
+ ),
108
+ /* @__PURE__ */ i(
109
+ n,
110
+ {
111
+ variant: "primary",
112
+ size: "default",
113
+ isDisabled: !l || e,
114
+ isLoading: e,
115
+ type: "submit",
116
+ onPress: () => {
117
+ r?.();
118
+ },
119
+ className: t(),
120
+ children: d
121
+ }
122
+ )
123
+ ] }), [
124
+ t,
125
+ u,
126
+ d,
127
+ s,
128
+ l,
129
+ e,
130
+ p,
131
+ a,
132
+ r
133
+ ]);
134
+ return /* @__PURE__ */ c("div", { className: F(), role: "group", children: [
135
+ g,
136
+ v === "read" ? /* @__PURE__ */ i(
137
+ n,
138
+ {
139
+ ref: M,
140
+ variant: "secondary",
141
+ size: "default",
142
+ onPress: () => {
143
+ I?.(), x();
144
+ },
145
+ isDisabled: e,
146
+ prefixIcon: "PencilSimpleOutlined",
147
+ "aria-expanded": !1,
148
+ "aria-controls": h,
149
+ className: t(),
150
+ children: N
151
+ }
152
+ ) : w
153
+ ] });
154
+ }
155
+ R.displayName = "InlineFieldGroupActions";
156
+ export {
157
+ R as InlineFieldGroupActions
158
+ };
@@ -6,42 +6,14 @@ export interface InlineFieldGroupHeaderProps {
6
6
  */
7
7
  title: ReactNode;
8
8
  /**
9
- * Custom label for the edit button.
10
- * @default "Edit" (translated)
9
+ * Optional subtitle to display below the title.
11
10
  */
12
- editLabel?: string;
13
- /**
14
- * Custom label for the save button.
15
- * @default "Save" (translated)
16
- */
17
- saveLabel?: string;
18
- /**
19
- * Custom label for the cancel button.
20
- * @default "Cancel" (translated)
21
- */
22
- cancelLabel?: string;
11
+ subtitle?: ReactNode;
23
12
  /**
24
13
  * Additional custom actions to render alongside the default buttons.
25
14
  * These will be displayed between the title and the edit/save/cancel buttons.
26
15
  */
27
16
  customActions?: ReactNode;
28
- /**
29
- * Optional callback fired when the edit button is clicked.
30
- * This is called before entering edit mode and is useful for analytics or side effects.
31
- */
32
- onEditPress?: () => void;
33
- /**
34
- * Optional callback fired when the save button is clicked.
35
- * This is called before form submission and is useful for analytics or side effects.
36
- * Note: Form submission is handled via the form's onSubmit configuration.
37
- */
38
- onSavePress?: () => void;
39
- /**
40
- * Optional callback fired when the cancel button is clicked.
41
- * This is called before canceling and is useful for analytics or side effects.
42
- * The form will be reset and edit mode exited automatically.
43
- */
44
- onCancelPress?: () => void;
45
17
  }
46
18
  /**
47
19
  * InlineFieldGroupHeader renders the title and contextual action buttons for an InlineFieldGroup.
@@ -69,14 +41,18 @@ export interface InlineFieldGroupHeaderProps {
69
41
  * ```
70
42
  * @example Custom button labels and actions
71
43
  * ```tsx
72
- * <form.InlineFieldGroupHeader
73
- * title="Contact Information"
44
+ * <form.InlineFieldGroup
74
45
  * editLabel="Modify"
75
46
  * saveLabel="Confirm"
76
47
  * cancelLabel="Discard"
77
- * customActions={<Button onPress={handleDelete}>Delete</Button>}
78
48
  * onSavePress={() => trackAnalytics('save_clicked')}
79
- * />
49
+ * >
50
+ * <form.InlineFieldGroupHeader
51
+ * title="Contact Information"
52
+ * customActions={<Button onPress={handleDelete}>Delete</Button>}
53
+ * />
54
+ * ...
55
+ * </form.InlineFieldGroup>
80
56
  * ```
81
57
  * @remarks
82
58
  * - Must be used as a child of InlineFieldGroup
@@ -89,7 +65,7 @@ export interface InlineFieldGroupHeaderProps {
89
65
  * @see Source code in {@link https://github.com/PayFit/hr-apps/tree/master/libs/shared/unity/components/src/components/inline-field-group GitHub}
90
66
  * @see Developer docs in {@link https://unity-components.payfit.io/?path=/docs/forms-reference-inlinefieldgroup--docs unity-components.payfit.io}
91
67
  */
92
- export declare function InlineFieldGroupHeader({ title, editLabel, saveLabel, cancelLabel, customActions, onEditPress, onSavePress, onCancelPress, }: InlineFieldGroupHeaderProps): import("react/jsx-runtime").JSX.Element;
68
+ export declare function InlineFieldGroupHeader({ title, subtitle, customActions, }: InlineFieldGroupHeaderProps): import("react/jsx-runtime").JSX.Element;
93
69
  export declare namespace InlineFieldGroupHeader {
94
70
  var displayName: string;
95
71
  }
@@ -1,106 +1,39 @@
1
- import { jsxs as n, jsx as e, Fragment as N } from "react/jsx-runtime";
2
- import { useContext as L } from "react";
3
- import { uyTv as P } from "@payfit/unity-themes";
4
- import { useStore as S } from "@tanstack/react-form";
5
- import { useIntl as j } from "react-intl";
6
- import { useFormContext as z } from "../../../hooks/tanstack-form-context.js";
7
- import { Button as o } from "../../button/Button.js";
8
- import { Text as H } from "../../text/Text.js";
9
- import { InlineFieldGroupContext as B } from "../InlineFieldGroup.context.js";
10
- const T = P({
1
+ import { jsxs as e, jsx as r } from "react/jsx-runtime";
2
+ import { useContext as d } from "react";
3
+ import { uyTv as m } from "@payfit/unity-themes";
4
+ import { useBreakpointListener as f } from "../../../hooks/use-breakpoint-listener.js";
5
+ import { Text as i } from "../../text/Text.js";
6
+ import { InlineFieldGroupContext as y } from "../InlineFieldGroup.context.js";
7
+ import { InlineFieldGroupActions as h } from "./InlineFieldGroupActions.js";
8
+ const x = m({
11
9
  slots: {
12
- base: "uy:flex uy:items-center uy:justify-between uy:w-full",
13
- titleContainer: "uy:flex uy:flex-col uy:gap-0 uy:flex-1",
14
- actions: "uy:flex uy:gap-100 uy:items-center"
10
+ base: "uy:flex uy:items-center uy:justify-between uy:w-full uy:gap-300",
11
+ titleContainer: "uy:flex uy:flex-col uy:gap-100 uy:flex-1"
15
12
  }
16
13
  });
17
- function A({
18
- title: a,
19
- editLabel: s,
20
- saveLabel: l,
21
- cancelLabel: d,
22
- customActions: u,
23
- onEditPress: c,
24
- onSavePress: m,
25
- onCancelPress: f
14
+ function I({
15
+ title: l,
16
+ subtitle: t,
17
+ customActions: s
26
18
  }) {
27
- const i = j(), r = L(B);
28
- if (!r)
19
+ const o = d(y), n = f(), a = n !== "xs" && n !== "sm";
20
+ if (!o)
29
21
  throw new Error(
30
22
  "InlineFieldGroupHeader must be used within InlineFieldGroup"
31
23
  );
32
- const {
33
- mode: p,
34
- enterEditMode: y,
35
- exitEditMode: x,
36
- headerId: g,
37
- editViewId: h,
38
- isLoading: t,
39
- editButtonRef: b
40
- } = r, v = z(), { isDirty: I } = S(v.store, (G) => ({
41
- isDirty: G.isDirty
42
- })), { base: C, titleContainer: M, actions: F } = T(), w = s || i.formatMessage({
43
- id: "unity:component:inline-field-group:edit",
44
- defaultMessage: "Edit"
45
- }), D = l || i.formatMessage({
46
- id: "unity:component:inline-field-group:save",
47
- defaultMessage: "Save"
48
- }), E = d || i.formatMessage({
49
- id: "unity:component:inline-field-group:cancel",
50
- defaultMessage: "Cancel"
51
- });
52
- return /* @__PURE__ */ n("header", { className: C(), children: [
53
- /* @__PURE__ */ e("div", { className: M(), children: /* @__PURE__ */ e(H, { id: g, variant: "h3", color: "content.neutral", children: a }) }),
54
- /* @__PURE__ */ n("div", { className: F(), role: "group", children: [
55
- u,
56
- p === "read" ? /* @__PURE__ */ e(
57
- o,
58
- {
59
- ref: b,
60
- variant: "secondary",
61
- size: "default",
62
- onPress: () => {
63
- c?.(), y();
64
- },
65
- isDisabled: t,
66
- prefixIcon: "PencilSimpleOutlined",
67
- "aria-expanded": !1,
68
- "aria-controls": h,
69
- children: w
70
- }
71
- ) : /* @__PURE__ */ n(N, { children: [
72
- /* @__PURE__ */ e(
73
- o,
74
- {
75
- variant: "secondary",
76
- size: "default",
77
- onPress: () => {
78
- f?.(), x();
79
- },
80
- isDisabled: t,
81
- type: "button",
82
- children: E
83
- }
84
- ),
85
- /* @__PURE__ */ e(
86
- o,
87
- {
88
- variant: "primary",
89
- size: "default",
90
- isDisabled: !I || t,
91
- isLoading: t,
92
- type: "submit",
93
- onPress: () => {
94
- m?.();
95
- },
96
- children: D
97
- }
98
- )
99
- ] })
24
+ const { headerId: u } = o, { base: c, titleContainer: p } = x();
25
+ return /* @__PURE__ */ e("header", { className: c(), children: [
26
+ /* @__PURE__ */ e("hgroup", { className: p(), children: [
27
+ /* @__PURE__ */ r(i, { id: u, variant: "h3", color: "content.neutral", children: l }),
28
+ t && /* @__PURE__ */ r(i, { variant: "subtitle", color: "content.neutral", children: t })
29
+ ] }),
30
+ /* @__PURE__ */ e("div", { className: "uy:flex uy:gap-100 uy:items-center", role: "group", children: [
31
+ s,
32
+ a && /* @__PURE__ */ r(h, { orientation: "horizontal" })
100
33
  ] })
101
34
  ] });
102
35
  }
103
- A.displayName = "InlineFieldGroupHeader";
36
+ I.displayName = "InlineFieldGroupHeader";
104
37
  export {
105
- A as InlineFieldGroupHeader
38
+ I as InlineFieldGroupHeader
106
39
  };
@@ -57,6 +57,16 @@ export * from './components/promo-dialog/parts/PromoDialogSubtitle.js';
57
57
  export * from './components/promo-dialog/parts/PromoDialogContent.js';
58
58
  export * from './components/promo-dialog/parts/PromoDialogActions.js';
59
59
  export * from './components/promo-dialog/parts/PromoDialogTitle.js';
60
+ export * from './components/empty-state/EmptyState.js';
61
+ export * from './components/empty-state/parts/EmptyStateIcon.js';
62
+ export * from './components/empty-state/parts/EmptyStateContent.js';
63
+ export * from './components/empty-state/parts/EmptyStateActions.js';
64
+ export * from './components/empty-state/presets/EmptyStateGetStarted.js';
65
+ export * from './components/empty-state/presets/EmptyStateWaitingForData.js';
66
+ export * from './components/empty-state/presets/EmptyStateGoodJob.js';
67
+ export * from './components/empty-state/presets/EmptyStateUpgradeRequired.js';
68
+ export * from './components/empty-state/presets/EmptyStateNoSearchResults.js';
69
+ export * from './components/empty-state/presets/EmptyStateUseDesktop.js';
60
70
  export * from './components/error-state/ErrorState.js';
61
71
  export * from './components/fieldset/Fieldset.js';
62
72
  export * from './components/fieldset/parts/FieldGroup.js';