@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.
Files changed (104) hide show
  1. package/dist/esm/adapters/standardSchemaAdapter.d.ts +7 -0
  2. package/dist/esm/adapters/standardSchemaAdapter.js +20 -0
  3. package/dist/esm/adapters/zodAdapter.d.ts +13 -0
  4. package/dist/esm/adapters/zodAdapter.js +74 -0
  5. package/dist/esm/components/action-bar/ActionBar.js +62 -64
  6. package/dist/esm/components/actionable/Actionable.d.ts +50 -3
  7. package/dist/esm/components/actionable/Actionable.js +49 -39
  8. package/dist/esm/components/app-menu/parts/AppMenuFooter.js +63 -63
  9. package/dist/esm/components/autocomplete/parts/AutocompleteClearButton.js +5 -5
  10. package/dist/esm/components/bottom-sheet/parts/BottomSheetDragIndicator.js +30 -31
  11. package/dist/esm/components/checkbox-field/CheckboxField.d.ts +2 -2
  12. package/dist/esm/components/checkbox-field/CheckboxField.js +18 -17
  13. package/dist/esm/components/checkbox-group-field/CheckboxGroupField.d.ts +2 -2
  14. package/dist/esm/components/checkbox-group-field/CheckboxGroupField.js +4 -1
  15. package/dist/esm/components/code/Code.d.ts +37 -0
  16. package/dist/esm/components/code/Code.js +39 -0
  17. package/dist/esm/components/code/copyToClipboard.d.ts +1 -0
  18. package/dist/esm/components/code/copyToClipboard.js +10 -0
  19. package/dist/esm/components/collapsible/Collapsible.d.ts +1 -1
  20. package/dist/esm/components/collapsible/Collapsible.js +14 -13
  21. package/dist/esm/components/collapsible/parts/CollapsibleTitle.js +7 -7
  22. package/dist/esm/components/data-table/DataTable.d.ts +76 -10
  23. package/dist/esm/components/data-table/DataTable.js +81 -78
  24. package/dist/esm/components/data-table/parts/ColumnSortHeader.js +13 -13
  25. package/dist/esm/components/data-table/parts/DataTableBulkActions.js +20 -20
  26. package/dist/esm/components/date-calendar/DateCalendar.js +52 -52
  27. package/dist/esm/components/date-calendar/parts/DateSegmentSelect.js +30 -33
  28. package/dist/esm/components/date-picker/DatePicker.js +64 -64
  29. package/dist/esm/components/date-picker/parts/DateInput.js +33 -33
  30. package/dist/esm/components/date-picker-field/DatePickerField.d.ts +2 -2
  31. package/dist/esm/components/dialog/parts/DialogActions/DialogButton.js +12 -12
  32. package/dist/esm/components/error-state/ErrorState.d.ts +196 -0
  33. package/dist/esm/components/error-state/ErrorState.js +153 -0
  34. package/dist/esm/components/error-state/initConfig.d.ts +16 -0
  35. package/dist/esm/components/error-state/initConfig.js +149 -0
  36. package/dist/esm/components/error-state/parts/Collapsible.d.ts +59 -0
  37. package/dist/esm/components/error-state/parts/Collapsible.js +67 -0
  38. package/dist/esm/components/form/Form.d.ts +15 -9
  39. package/dist/esm/components/form/Form.js +53 -50
  40. package/dist/esm/components/form-field/FormField.js +24 -23
  41. package/dist/esm/components/form-field/utils/isFieldRequired.d.ts +4 -4
  42. package/dist/esm/components/form-field/utils/isFieldRequired.js +5 -20
  43. package/dist/esm/components/funnel-layout/FunnelLayout.d.ts +1 -1
  44. package/dist/esm/components/funnel-layout/FunnelLayout.js +61 -110
  45. package/dist/esm/components/funnel-layout/parts/FunnelPage.js +8 -9
  46. package/dist/esm/components/funnel-layout/parts/FunnelPageActions.js +24 -24
  47. package/dist/esm/components/funnel-layout/parts/FunnelPageFooter.js +6 -7
  48. package/dist/esm/components/funnel-layout/parts/FunnelPageHeader.d.ts +2 -2
  49. package/dist/esm/components/funnel-layout/parts/FunnelSidebar.d.ts +2 -2
  50. package/dist/esm/components/funnel-layout/parts/FunnelSidebar.js +9 -10
  51. package/dist/esm/components/funnel-layout/parts/FunnelTopBar.js +0 -1
  52. package/dist/esm/components/input/Input.js +28 -28
  53. package/dist/esm/components/label/Label.js +19 -19
  54. package/dist/esm/components/multi-select/MultiSelect.js +94 -94
  55. package/dist/esm/components/multi-select/hooks/use-multiselection-state.js +32 -32
  56. package/dist/esm/components/multi-select/parts/MultiSelectButton.js +38 -38
  57. package/dist/esm/components/multi-select/parts/MultiSelectPopover.js +16 -16
  58. package/dist/esm/components/multi-select-field/MultiSelectField.d.ts +2 -2
  59. package/dist/esm/components/multi-select-field/MultiSelectField.js +53 -53
  60. package/dist/esm/components/nav/parts/NavGroup.js +21 -21
  61. package/dist/esm/components/number-field/NumberField.d.ts +3 -3
  62. package/dist/esm/components/number-input/NumberInput.js +58 -58
  63. package/dist/esm/components/pagination/Pagination.js +97 -101
  64. package/dist/esm/components/pagination/parts/PaginationJumpDialog.js +39 -40
  65. package/dist/esm/components/popover/parts/PopoverHeader.js +8 -8
  66. package/dist/esm/components/radio-button-group/parts/RadioButton.js +11 -11
  67. package/dist/esm/components/select-field/SelectField.d.ts +2 -2
  68. package/dist/esm/components/select-field/SelectField.js +4 -1
  69. package/dist/esm/components/selectable-button-group/SelectableButtonGroup.js +22 -23
  70. package/dist/esm/components/selectable-button-group-field/SelectableButtonGroupField.d.ts +2 -2
  71. package/dist/esm/components/side-panel/parts/SidePanelDragIndicator.js +30 -31
  72. package/dist/esm/components/skip-links/SkipLinks.js +50 -43
  73. package/dist/esm/components/table/Table.js +79 -76
  74. package/dist/esm/components/table/parts/TableBody.js +6 -6
  75. package/dist/esm/components/table/parts/TableCell.js +25 -25
  76. package/dist/esm/components/table/parts/TableColumnHeader.js +38 -38
  77. package/dist/esm/components/table/parts/TablePagination.js +61 -59
  78. package/dist/esm/components/table/parts/TableRow.js +16 -16
  79. package/dist/esm/components/tabs/parts/TabList.js +50 -54
  80. package/dist/esm/components/task-menu/parts/Content.js +24 -24
  81. package/dist/esm/components/task-menu/parts/Header.js +24 -24
  82. package/dist/esm/components/task-menu/parts/SubTask.js +74 -74
  83. package/dist/esm/components/task-menu/parts/Task.js +69 -69
  84. package/dist/esm/components/task-menu/parts/TaskGroup.js +45 -45
  85. package/dist/esm/components/text-area/TextArea.js +30 -31
  86. package/dist/esm/components/text-field/TextField.d.ts +2 -2
  87. package/dist/esm/components/toggle-switch-field/ToggleSwitchField.d.ts +2 -2
  88. package/dist/esm/components/toggle-switch-field/ToggleSwitchField.js +4 -1
  89. package/dist/esm/components/toggle-switch-group/ToggleSwitchGroup.js +74 -74
  90. package/dist/esm/components/toggle-switch-group-field/ToggleSwitchGroupField.d.ts +2 -2
  91. package/dist/esm/components/toggle-switch-group-field/ToggleSwitchGroupField.js +36 -32
  92. package/dist/esm/hooks/use-form.d.ts +5 -5
  93. package/dist/esm/hooks/use-form.types.d.ts +2 -2
  94. package/dist/esm/hooks/use-resizable.js +13 -14
  95. package/dist/esm/index.d.ts +1 -0
  96. package/dist/esm/index.js +22 -19
  97. package/dist/esm/types/schema.d.ts +8 -0
  98. package/dist/esm/utils/createSchemaAdapter.d.ts +7 -0
  99. package/dist/esm/utils/createSchemaAdapter.js +13 -0
  100. package/dist/esm/utils/platform.js +2 -3
  101. package/i18n/en-GB.json +16 -0
  102. package/i18n/es-ES.json +16 -0
  103. package/i18n/fr-FR.json +16 -0
  104. package/package.json +25 -19
@@ -1,9 +1,9 @@
1
- import { jsx as o } from "react/jsx-runtime";
1
+ import { jsx as n } from "react/jsx-runtime";
2
2
  import { memo as x, forwardRef as g } from "react";
3
- import { uyTv as C } from "@payfit/unity-themes";
4
- import { Actionable as T } from "../../actionable/Actionable.js";
5
- import { useTableContext as w } from "../Table.context.js";
6
- const c = C({
3
+ import { uyTv as w } from "@payfit/unity-themes";
4
+ import { Actionable as C } from "../../actionable/Actionable.js";
5
+ import { useTableContext as T } from "../Table.context.js";
6
+ const d = w({
7
7
  base: [
8
8
  "uy:align-middle uy:leading-[1.00]",
9
9
  "uy:px-200 uy:py-100 uy:typography-action uy:text-content-neutral",
@@ -17,62 +17,62 @@ const c = C({
17
17
  right: "uy:text-right"
18
18
  }
19
19
  }
20
- }), H = x(
20
+ }), D = x(
21
21
  g(
22
22
  ({
23
- children: n,
24
- colIndex: a = 0,
25
- rowIndex: f = 0,
26
- align: u,
27
- onKeyDown: r,
28
- onFocus: t,
29
- className: d,
30
- isFocusable: l = !0,
31
- ...i
32
- }, y) => {
33
- const { keyboardNavigation: b } = w(), { isCellFocused: h, handleCellKeyDown: v, handleCellFocus: m } = b, p = l && h(f, a), s = (e) => {
34
- e.key !== "Tab" && (v(e), r == null || r(
23
+ children: r,
24
+ colIndex: t = 0,
25
+ rowIndex: m = 0,
26
+ align: l,
27
+ onKeyDown: f,
28
+ onFocus: i,
29
+ className: u,
30
+ isFocusable: o = !0,
31
+ ...a
32
+ }, s) => {
33
+ const { keyboardNavigation: b } = T(), { isCellFocused: h, handleCellKeyDown: v, handleCellFocus: c } = b, p = o && h(m, t), y = (e) => {
34
+ e.key !== "Tab" && (v(e), f?.(
35
35
  e
36
36
  ));
37
37
  };
38
- return "onPress" in i ? /* @__PURE__ */ o(
38
+ return "onPress" in a ? /* @__PURE__ */ n(
39
39
  "th",
40
40
  {
41
- ref: y,
41
+ ref: s,
42
42
  role: "columnheader",
43
- "aria-colindex": a + 1,
44
- "data-focusable": l,
45
- className: c({ align: u, className: d }),
43
+ "aria-colindex": t + 1,
44
+ "data-focusable": o,
45
+ className: d({ align: l, className: u }),
46
46
  "data-dd-privacy": "allow",
47
- onKeyDown: s,
47
+ onKeyDown: y,
48
48
  onFocus: (e) => {
49
- m(e), t == null || t(e);
49
+ c(e), i?.(e);
50
50
  },
51
- children: /* @__PURE__ */ o(T, { ...i, children: n })
51
+ children: /* @__PURE__ */ n(C, { ...a, children: r })
52
52
  }
53
- ) : /* @__PURE__ */ o(
53
+ ) : /* @__PURE__ */ n(
54
54
  "th",
55
55
  {
56
- ref: y,
56
+ ref: s,
57
57
  role: "columnheader",
58
- "aria-colindex": a + 1,
58
+ "aria-colindex": t + 1,
59
59
  tabIndex: p ? 0 : -1,
60
- "data-focusable": l,
61
- className: c({ align: u, className: d }),
62
- onKeyDown: s,
60
+ "data-focusable": o,
61
+ className: d({ align: l, className: u }),
62
+ onKeyDown: y,
63
63
  onFocus: (e) => {
64
- m(e), t == null || t(e);
64
+ c(e), i?.(e);
65
65
  },
66
66
  "data-dd-privacy": "allow",
67
- ...i,
68
- children: n
67
+ ...a,
68
+ children: r
69
69
  }
70
70
  );
71
71
  }
72
72
  )
73
73
  );
74
- H.displayName = "TableColumnHeader";
74
+ D.displayName = "TableColumnHeader";
75
75
  export {
76
- H as TableColumnHeader,
77
- c as tableColumnHeader
76
+ D as TableColumnHeader,
77
+ d as tableColumnHeader
78
78
  };
@@ -1,69 +1,71 @@
1
- import { jsxs as b, jsx as e } from "react/jsx-runtime";
2
- import { forwardRef as x, useState as I } from "react";
3
- import { uyTv as j } from "@payfit/unity-themes";
1
+ import { jsxs as d, jsx as e } from "react/jsx-runtime";
2
+ import { forwardRef as I, useState as j } from "react";
3
+ import { uyTv as C } from "@payfit/unity-themes";
4
4
  import { useId as L } from "react-aria";
5
5
  import { useIntl as T } from "react-intl";
6
6
  import { Pagination as O } from "../../pagination/Pagination.js";
7
7
  import { SelectOption as R } from "../../select/parts/SelectOption.js";
8
- import { Select as C } from "../../select/Select.js";
9
- const E = j({
8
+ import { Select as E } from "../../select/Select.js";
9
+ const _ = C({
10
10
  base: [
11
11
  "uy:bg-surface-neutral-lowest",
12
12
  "uy:sticky uy:bottom-0",
13
13
  "uy:grid uy:grid-cols-3 uy:items-center",
14
14
  "uy:ps-200 uy:py-100 uy:pe-100"
15
15
  ]
16
- }), _ = [
16
+ }), k = [
17
17
  { value: "10", label: "10" },
18
18
  { value: "50", label: "50" },
19
19
  { value: "100", label: "100" },
20
20
  { value: "200", label: "200" }
21
- ], k = x(
22
- (y, f) => {
21
+ ], A = I(
22
+ (b, y) => {
23
23
  const {
24
- pageCount: t,
25
- rowCount: s,
26
- currentPage: u,
27
- rowsPerPage: n = 10,
28
- defaultPage: p,
29
- pageSizeOptions: h = _,
30
- defaultPageSize: P = n,
31
- onPageChange: v,
32
- onNextPress: N,
33
- onPreviousPress: w,
34
- onPageSizeChange: o,
35
- itemLabel: c = "unity:component:table:pagination:item",
36
- ...M
37
- } = y, a = L(), l = T(), [$, z] = I(P), S = {
38
- pageCount: t,
39
- defaultPage: p,
40
- currentPage: u,
41
- onPageChange: v,
42
- onNextPress: N,
43
- onPreviousPress: w
44
- }, r = Math.max(((u ?? p ?? 1) - 1) * n + 1, 1), m = Math.min(r + n - 1, s), g = {
45
- singular: l.formatMessage(
24
+ pageCount: i,
25
+ rowCount: n,
26
+ currentPage: r,
27
+ rowsPerPage: s = 10,
28
+ defaultPage: u,
29
+ pageSizeOptions: f = k,
30
+ defaultPageSize: h = s,
31
+ onPageChange: P,
32
+ onNextPress: v,
33
+ onPreviousPress: N,
34
+ onPageSizeChange: z,
35
+ onPageHover: S,
36
+ itemLabel: g = "unity:component:table:pagination:item",
37
+ ...w
38
+ } = b, a = L(), t = T(), [M, $] = j(h), x = {
39
+ pageCount: i,
40
+ defaultPage: u,
41
+ currentPage: r,
42
+ onPageChange: P,
43
+ onNextPress: v,
44
+ onPreviousPress: N,
45
+ onPageHover: S
46
+ }, o = Math.max(((r ?? u ?? 1) - 1) * s + 1, 1), p = Math.min(o + s - 1, n), c = {
47
+ singular: t.formatMessage(
46
48
  {
47
- id: c,
49
+ id: g,
48
50
  defaultMessage: "items"
49
51
  },
50
52
  { count: 1 }
51
53
  ),
52
- plural: l.formatMessage(
54
+ plural: t.formatMessage(
53
55
  {
54
- id: c,
56
+ id: g,
55
57
  defaultMessage: "items"
56
58
  },
57
59
  { count: 2 }
58
60
  )
59
61
  };
60
- return /* @__PURE__ */ b(
62
+ return /* @__PURE__ */ d(
61
63
  "div",
62
64
  {
63
65
  "data-dd-privacy": "allow",
64
- ...M,
65
- ref: f,
66
- className: E(),
66
+ ...w,
67
+ ref: y,
68
+ className: _(),
67
69
  "data-unity-slot": "table-pagination",
68
70
  children: [
69
71
  /* @__PURE__ */ e("div", { className: "uy:justify-self-start", children: /* @__PURE__ */ e(
@@ -71,59 +73,59 @@ const E = j({
71
73
  {
72
74
  id: `table-pagination-${a}-label`,
73
75
  className: "uy:typography-body uy:text-content-neutral",
74
- children: l.formatMessage(
76
+ children: t.formatMessage(
75
77
  {
76
78
  id: "unity:component:table:pagination:label",
77
- defaultMessage: `${r}-${m} out of ${s * t} items`
79
+ defaultMessage: `${o}-${p} out of ${n} items`
78
80
  },
79
81
  {
80
- pageCount: t,
81
- startRow: r,
82
- endRow: m,
83
- totalRows: s * t,
84
- itemLabel: g.plural
82
+ pageCount: i,
83
+ startRow: o,
84
+ endRow: p,
85
+ totalRows: n,
86
+ itemLabel: c.plural
85
87
  }
86
88
  )
87
89
  }
88
90
  ) }),
89
- /* @__PURE__ */ e("div", { className: "uy:justify-self-center", children: t > 1 && /* @__PURE__ */ e(
91
+ /* @__PURE__ */ e("div", { className: "uy:justify-self-center", children: i > 1 && /* @__PURE__ */ e(
90
92
  O,
91
93
  {
92
- ...S,
94
+ ...x,
93
95
  "aria-labelledby": `table-pagination-${a}-label`
94
96
  }
95
97
  ) }),
96
- /* @__PURE__ */ e("div", { className: "uy:justify-self-end", children: /* @__PURE__ */ b("form", { className: "uy:flex uy:gap-100 uy:items-center", children: [
98
+ /* @__PURE__ */ e("div", { className: "uy:justify-self-end", children: /* @__PURE__ */ d("form", { className: "uy:flex uy:gap-100 uy:items-center", children: [
97
99
  /* @__PURE__ */ e(
98
100
  "label",
99
101
  {
100
102
  className: "uy:shrink-0",
101
103
  id: `table-pagination-${a}-pagesize-label`,
102
104
  htmlFor: `table-pagination-${a}-pagesize-select`,
103
- children: l.formatMessage(
105
+ children: t.formatMessage(
104
106
  {
105
107
  id: "unity:component:table:pagination:page-size-control-label",
106
108
  defaultMessage: "Items per page"
107
109
  },
108
110
  {
109
- itemLabel: g.plural
111
+ itemLabel: c.plural
110
112
  }
111
113
  )
112
114
  }
113
115
  ),
114
116
  /* @__PURE__ */ e("div", { className: "uy:grow-0 uy:w-1000", children: /* @__PURE__ */ e(
115
- C,
117
+ E,
116
118
  {
117
119
  id: `table-pagination-${a}-pagesize-select`,
118
- items: h,
120
+ items: f,
119
121
  placeholder: "",
120
- value: `${$}`,
121
- onChange: (i) => {
122
- const d = parseInt(i, 10);
123
- o == null || o(d), z(d);
122
+ value: `${M}`,
123
+ onChange: (l) => {
124
+ const m = parseInt(l, 10);
125
+ z?.(m), $(m);
124
126
  },
125
127
  "aria-labelledby": `table-pagination-${a}-pagesize-label`,
126
- children: (i) => /* @__PURE__ */ e(R, { id: i.value, children: i.label })
128
+ children: (l) => /* @__PURE__ */ e(R, { id: l.value, children: l.label })
127
129
  }
128
130
  ) })
129
131
  ] }) })
@@ -132,8 +134,8 @@ const E = j({
132
134
  );
133
135
  }
134
136
  );
135
- k.displayName = "TablePagination";
137
+ A.displayName = "TablePagination";
136
138
  export {
137
- k as TablePagination,
138
- E as tablePagination
139
+ A as TablePagination,
140
+ _ as tablePagination
139
141
  };
@@ -1,7 +1,7 @@
1
- import { jsx as d } from "react/jsx-runtime";
2
- import n, { memo as c, forwardRef as y, useMemo as f, Children as m, cloneElement as p } from "react";
1
+ import { jsx as b } from "react/jsx-runtime";
2
+ import d, { memo as y, forwardRef as c, useMemo as f, Children as m, cloneElement as p } from "react";
3
3
  import { uyTv as v } from "@payfit/unity-themes";
4
- const g = v({
4
+ const w = v({
5
5
  base: [
6
6
  "uy:group uy:h-500",
7
7
  "uy:bg-surface-neutral uy:border-b uy:border-solid uy:border-b-border-neutral-enabled",
@@ -10,30 +10,30 @@ const g = v({
10
10
  "uy:aria-[selected=true]:bg-surface-neutral-selected uy:aria-[selected=true]:border-b-border-neutral-selected",
11
11
  "uy:focus-visible:outline-2 uy:focus-visible:outline-solid uy:focus-visible:outline-offset-[-2px] uy:focus-visible:outline-utility-focus-ring"
12
12
  ]
13
- }), R = c(
14
- y(
15
- ({ children: o, className: a, rowIndex: r = 0, onKeyDown: u, isSelected: t, ...s }, l) => {
16
- const i = f(() => m.map(o, (e, b) => n.isValidElement(e) ? p(
13
+ }), g = y(
14
+ c(
15
+ ({ children: o, className: t, rowIndex: r = 0, onKeyDown: a, isSelected: u, ...s }, l) => {
16
+ const i = f(() => m.map(o, (e, n) => d.isValidElement(e) ? p(
17
17
  e,
18
18
  {
19
19
  rowIndex: r,
20
- colIndex: b,
20
+ colIndex: n,
21
21
  ...e.props
22
22
  }
23
23
  ) : e), [o, r]);
24
- return /* @__PURE__ */ d(
24
+ return /* @__PURE__ */ b(
25
25
  "tr",
26
26
  {
27
27
  ref: l,
28
28
  role: "row",
29
- className: g({ className: a }),
29
+ className: w({ className: t }),
30
30
  "aria-rowindex": r + 1,
31
- "aria-selected": t,
31
+ "aria-selected": u,
32
32
  onKeyDown: (e) => {
33
- u == null || u(e);
33
+ a?.(e);
34
34
  },
35
35
  "data-dd-privacy": "mask",
36
- "data-selectable": t !== void 0,
36
+ "data-selectable": u !== void 0,
37
37
  ...s,
38
38
  children: i
39
39
  }
@@ -41,8 +41,8 @@ const g = v({
41
41
  }
42
42
  )
43
43
  );
44
- R.displayName = "TableRow";
44
+ g.displayName = "TableRow";
45
45
  export {
46
- R as TableRow,
47
- g as tableRow
46
+ g as TableRow,
47
+ w as tableRow
48
48
  };
@@ -1,87 +1,83 @@
1
- import { jsxs as C, jsx as n } from "react/jsx-runtime";
2
- import { forwardRef as B, useRef as j, useState as L, useCallback as q } from "react";
3
- import { TabList as g } from "react-aria-components";
4
- import { useResizeObserver as w } from "usehooks-ts";
5
- import { useTabsContext as z } from "../Tabs.context.js";
6
- import { tabsVariant as P } from "../Tabs.variant.js";
7
- import { NavigationButton as p } from "./NavigationButton.js";
8
- const k = B(
9
- ({ children: f }, u) => {
10
- const r = j(null), [S, R] = L(!1), [v, y] = L(!1), { variant: W, scrollable: b } = z(), { tabList: m, scroller: N } = P({ variant: W, scrollable: b }), h = q(() => {
11
- if (!r.current) return;
12
- const { scrollLeft: t, scrollWidth: s, clientWidth: e } = r.current;
13
- R(t > 0), y(t + e < s);
1
+ import { jsxs as A, jsx as c } from "react/jsx-runtime";
2
+ import { forwardRef as C, useRef as B, useState as d, useCallback as j } from "react";
3
+ import { TabList as L } from "react-aria-components";
4
+ import { useResizeObserver as q } from "usehooks-ts";
5
+ import { useTabsContext as w } from "../Tabs.context.js";
6
+ import { tabsVariant as z } from "../Tabs.variant.js";
7
+ import { NavigationButton as g } from "./NavigationButton.js";
8
+ const P = C(
9
+ ({ children: i }, f) => {
10
+ const t = B(null), [p, S] = d(!1), [R, v] = d(!1), { variant: y, scrollable: u } = w(), { tabList: b, scroller: W } = z({ variant: y, scrollable: u }), m = j(() => {
11
+ if (!t.current) return;
12
+ const { scrollLeft: r, scrollWidth: s, clientWidth: e } = t.current;
13
+ S(r > 0), v(r + e < s);
14
14
  }, []);
15
- w({
16
- ref: r,
17
- onResize: h
15
+ q({
16
+ ref: t,
17
+ onResize: m
18
18
  });
19
- const T = (t) => {
20
- h();
21
- }, x = () => {
22
- var l;
23
- const t = (l = r.current) == null ? void 0 : l.querySelectorAll("[role=tab]");
24
- if (!r.current || !t) return 0;
25
- const { scrollLeft: s } = r.current, e = Array.from(t);
19
+ const N = (r) => {
20
+ m();
21
+ }, T = () => {
22
+ const r = t.current?.querySelectorAll("[role=tab]");
23
+ if (!t.current || !r) return 0;
24
+ const { scrollLeft: s } = t.current, e = Array.from(r);
26
25
  for (let o = e.length - 1; o >= 0; o--) {
27
- const c = e[o];
28
- if (c.offsetLeft < s)
29
- return -c.offsetWidth;
26
+ const l = e[o];
27
+ if (l.offsetLeft < s)
28
+ return -l.offsetWidth;
30
29
  }
31
30
  return 0;
32
- }, A = () => {
33
- var c;
34
- const t = (c = r.current) == null ? void 0 : c.querySelectorAll("[role=tab]");
35
- if (!r.current || !t) return 0;
36
- const { scrollLeft: s, clientWidth: e } = r.current, l = Array.from(t), o = s + e;
37
- for (let a = 0; a < l.length - 1; a++) {
38
- const i = l[a], d = i.offsetLeft + i.offsetWidth;
39
- if (d > o || d < o)
40
- return i.offsetWidth;
31
+ }, x = () => {
32
+ const r = t.current?.querySelectorAll("[role=tab]");
33
+ if (!t.current || !r) return 0;
34
+ const { scrollLeft: s, clientWidth: e } = t.current, o = Array.from(r), l = s + e;
35
+ for (let n = 0; n < o.length - 1; n++) {
36
+ const a = o[n], h = a.offsetLeft + a.offsetWidth;
37
+ if (h > l || h < l)
38
+ return a.offsetWidth;
41
39
  }
42
40
  return 0;
43
41
  };
44
- return b ? /* @__PURE__ */ C("div", { className: "uy:relative", children: [
45
- S && /* @__PURE__ */ n(
46
- p,
42
+ return u ? /* @__PURE__ */ A("div", { className: "uy:relative", children: [
43
+ p && /* @__PURE__ */ c(
44
+ g,
47
45
  {
48
46
  direction: "left",
49
47
  onPress: () => {
50
- var t;
51
- (t = r.current) == null || t.scrollBy({
48
+ t.current?.scrollBy({
52
49
  behavior: "smooth",
53
- left: x()
50
+ left: T()
54
51
  });
55
52
  }
56
53
  }
57
54
  ),
58
- /* @__PURE__ */ n(
55
+ /* @__PURE__ */ c(
59
56
  "div",
60
57
  {
61
- ref: r,
58
+ ref: t,
62
59
  "data-testid": "scrollable-tab-list",
63
- className: N(),
64
- onScroll: T,
65
- children: /* @__PURE__ */ n(g, { ref: u, className: m(), children: f })
60
+ className: W(),
61
+ onScroll: N,
62
+ children: /* @__PURE__ */ c(L, { ref: f, className: b(), children: i })
66
63
  }
67
64
  ),
68
- v && /* @__PURE__ */ n(
69
- p,
65
+ R && /* @__PURE__ */ c(
66
+ g,
70
67
  {
71
68
  direction: "right",
72
69
  onPress: () => {
73
- var t;
74
- (t = r.current) == null || t.scrollBy({
70
+ t.current?.scrollBy({
75
71
  behavior: "smooth",
76
- left: A()
72
+ left: x()
77
73
  });
78
74
  }
79
75
  }
80
76
  )
81
- ] }) : /* @__PURE__ */ n(g, { ref: u, className: m(), children: f });
77
+ ] }) : /* @__PURE__ */ c(L, { ref: f, className: b(), children: i });
82
78
  }
83
79
  );
84
- k.displayName = "TabList";
80
+ P.displayName = "TabList";
85
81
  export {
86
- k as TabList
82
+ P as TabList
87
83
  };
@@ -1,45 +1,45 @@
1
- import { jsx as n } from "react/jsx-runtime";
2
- import { uyTv as a } from "@payfit/unity-themes";
1
+ import { jsx as s } from "react/jsx-runtime";
2
+ import { uyTv as m } from "@payfit/unity-themes";
3
3
  import { FocusScope as p, useOverlay as f, mergeProps as b } from "react-aria";
4
4
  import { useBreakpointListener as i } from "../../../hooks/use-breakpoint-listener.js";
5
5
  import { useTaskMenuContext as r } from "../TaskMenu.context.js";
6
- const v = a({
6
+ const v = m({
7
7
  base: [
8
8
  "uy:flex uy:flex-col uy:mt-100",
9
9
  "uy:flex uy:md:flex-col uy:md:gap-200 uy:md:list-none uy:md:mt-0",
10
10
  "uy:focus-visible:outline-2 uy:focus-visible:outline uy:focus-visible:outline-offset-2 uy:focus-visible:outline-utility-focus-ring"
11
11
  ]
12
- }), l = ({ children: s }) => {
12
+ }), l = ({ children: e }) => {
13
13
  const {
14
- taskMenuContentId: e,
15
- state: o,
16
- overlayProps: c,
17
- overlayRef: t
18
- } = r(), u = i(), y = u === "xs" || u === "sm", { overlayProps: m } = f(
14
+ taskMenuContentId: o,
15
+ state: t,
16
+ overlayProps: a,
17
+ overlayRef: n
18
+ } = r(), u = i(), c = u === "xs" || u === "sm", { overlayProps: y } = f(
19
19
  {
20
- onClose: () => o == null ? void 0 : o.close(),
21
- isOpen: o == null ? void 0 : o.isOpen,
20
+ onClose: () => t?.close(),
21
+ isOpen: t?.isOpen,
22
22
  isDismissable: !1
23
23
  },
24
- t
24
+ n
25
25
  );
26
- return /* @__PURE__ */ n(
26
+ return /* @__PURE__ */ s(
27
27
  "ol",
28
28
  {
29
- ...b(m, c),
30
- ref: t,
29
+ ...b(y, a),
30
+ ref: n,
31
31
  className: v(),
32
- id: e,
33
- ...y && { "data-mobile-open": o == null ? void 0 : o.isOpen },
34
- children: s
32
+ id: o,
33
+ ...c && { "data-mobile-open": t?.isOpen },
34
+ children: e
35
35
  }
36
36
  );
37
- }, d = ({ children: s }) => {
38
- const { state: e } = r();
39
- return !!(e != null && e.isOpen) && /* @__PURE__ */ n("div", { className: "uy:absolute uy:z-9 uy:top-full uy:inset-x-0 uy:h-[100dvh] uy:bg-surface-neutral", children: /* @__PURE__ */ n(p, { contain: !0, restoreFocus: !0, autoFocus: !0, children: /* @__PURE__ */ n(l, { children: s }) }) });
40
- }, x = ({ children: s }) => {
41
- const e = i();
42
- return e === "xs" || e === "sm" ? /* @__PURE__ */ n(d, { children: s }) : /* @__PURE__ */ n(l, { children: s });
37
+ }, d = ({ children: e }) => {
38
+ const { state: o } = r();
39
+ return !!o?.isOpen && /* @__PURE__ */ s("div", { className: "uy:absolute uy:z-9 uy:top-full uy:inset-x-0 uy:h-[100dvh] uy:bg-surface-neutral", children: /* @__PURE__ */ s(p, { contain: !0, restoreFocus: !0, autoFocus: !0, children: /* @__PURE__ */ s(l, { children: e }) }) });
40
+ }, x = ({ children: e }) => {
41
+ const o = i();
42
+ return o === "xs" || o === "sm" ? /* @__PURE__ */ s(d, { children: e }) : /* @__PURE__ */ s(l, { children: e });
43
43
  };
44
44
  x.displayName = "TaskMenuContent";
45
45
  export {
@@ -1,7 +1,7 @@
1
- import { jsxs as d, jsx as o } from "react/jsx-runtime";
1
+ import { jsxs as d, jsx as s } from "react/jsx-runtime";
2
2
  import { uyTv as m } from "@payfit/unity-themes";
3
- import { useIntl as p } from "react-intl";
4
- import { IconButton as c } from "../../icon-button/IconButton.js";
3
+ import { useIntl as c } from "react-intl";
4
+ import { IconButton as p } from "../../icon-button/IconButton.js";
5
5
  import { Text as f } from "../../text/Text.js";
6
6
  import { useTaskMenuContext as y } from "../TaskMenu.context.js";
7
7
  const h = m({
@@ -11,40 +11,40 @@ const h = m({
11
11
  }
12
12
  }), g = () => {
13
13
  const {
14
- currentTask: n,
15
- taskMenuId: r,
16
- taskMenuContentId: s,
14
+ currentTask: t,
15
+ taskMenuId: a,
16
+ taskMenuContentId: n,
17
17
  state: e,
18
- triggerProps: a,
19
- triggerRef: i
20
- } = y(), l = p(), { header: t, headerSelectedTask: u } = h();
21
- return /* @__PURE__ */ d("div", { className: t(), children: [
22
- /* @__PURE__ */ o(
18
+ triggerProps: r,
19
+ triggerRef: o
20
+ } = y(), i = c(), { header: l, headerSelectedTask: u } = h();
21
+ return /* @__PURE__ */ d("div", { className: l(), children: [
22
+ /* @__PURE__ */ s(
23
23
  f,
24
24
  {
25
25
  asElement: "span",
26
26
  className: u(),
27
- "aria-describedby": r,
28
- children: n == null ? void 0 : n.label
27
+ "aria-describedby": a,
28
+ children: t?.label
29
29
  }
30
30
  ),
31
- /* @__PURE__ */ o(
32
- c,
31
+ /* @__PURE__ */ s(
32
+ p,
33
33
  {
34
- ...a,
35
- ref: i,
34
+ ...r,
35
+ ref: o,
36
36
  variant: "ghost",
37
37
  color: "neutral",
38
- icon: e != null && e.isOpen ? "CloseOutlined" : "ListOutlined",
39
- label: l.formatMessage({
40
- id: e != null && e.isOpen ? "unity:component:task-menu:header:menu-close" : "unity:component:task-menu:header:menu-open",
41
- defaultMessage: e != null && e.isOpen ? "Close task menu" : "Open task menu"
38
+ icon: e?.isOpen ? "CloseOutlined" : "ListOutlined",
39
+ label: i.formatMessage({
40
+ id: e?.isOpen ? "unity:component:task-menu:header:menu-close" : "unity:component:task-menu:header:menu-open",
41
+ defaultMessage: e?.isOpen ? "Close task menu" : "Open task menu"
42
42
  }),
43
43
  onClick: () => {
44
- e == null || e.toggle();
44
+ e?.toggle();
45
45
  },
46
- "aria-expanded": !!(e != null && e.isOpen),
47
- "aria-controls": s
46
+ "aria-expanded": !!e?.isOpen,
47
+ "aria-controls": n
48
48
  }
49
49
  )
50
50
  ] });