@payfit/unity-components 2.46.39 → 2.47.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 (28) hide show
  1. package/dist/esm/components/definition-list/DefinitionList.context.js +17 -0
  2. package/dist/esm/components/definition-list/DefinitionList.js +23 -0
  3. package/dist/esm/components/definition-list/parts/DefinitionItem.js +51 -0
  4. package/dist/esm/components/multi-select/MultiSelect.d.ts +6 -1
  5. package/dist/esm/components/multi-select/MultiSelect.js +286 -238
  6. package/dist/esm/components/multi-select/Multiselect.context.d.ts +1 -1
  7. package/dist/esm/components/multi-select/MultiselectTypes.d.ts +5 -4
  8. package/dist/esm/components/multi-select/parts/MultiSelectOptGroup.d.ts +20 -13
  9. package/dist/esm/components/multi-select/parts/MultiSelectOptGroup.js +33 -22
  10. package/dist/esm/components/multi-select/parts/MultiSelectOption.d.ts +6 -3
  11. package/dist/esm/components/multi-select/parts/MultiSelectOption.js +51 -59
  12. package/dist/esm/components/multi-select/utils/selection-adapter.d.ts +5 -0
  13. package/dist/esm/components/multi-select/utils/selection-adapter.js +18 -0
  14. package/dist/esm/components/phone-number/PhoneNumberInput.js +38 -36
  15. package/dist/esm/components/select/Select.js +47 -44
  16. package/dist/esm/index.d.ts +2 -0
  17. package/dist/esm/index.js +444 -440
  18. package/package.json +7 -7
  19. package/dist/esm/components/multi-select/hooks/use-combobox-filter.d.ts +0 -12
  20. package/dist/esm/components/multi-select/hooks/use-combobox-filter.js +0 -22
  21. package/dist/esm/components/multi-select/hooks/use-multiselection-state.d.ts +0 -14
  22. package/dist/esm/components/multi-select/hooks/use-multiselection-state.js +0 -47
  23. package/dist/esm/components/multi-select/parts/MultiSelectButton.d.ts +0 -18
  24. package/dist/esm/components/multi-select/parts/MultiSelectButton.js +0 -174
  25. package/dist/esm/components/multi-select/parts/MultiSelectPopover.d.ts +0 -7
  26. package/dist/esm/components/multi-select/parts/MultiSelectPopover.js +0 -65
  27. package/dist/esm/components/select/parts/SearchInput.d.ts +0 -5
  28. package/dist/esm/components/select/parts/SearchInput.js +0 -59
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@payfit/unity-components",
3
- "version": "2.46.39",
3
+ "version": "2.47.0",
4
4
  "module": "./dist/esm/index.js",
5
5
  "type": "module",
6
6
  "sideEffects": false,
@@ -92,7 +92,7 @@
92
92
  "tailwind-variants": "3.2.2",
93
93
  "usehooks-ts": "3.1.1",
94
94
  "zod": "4.4.3",
95
- "@payfit/unity-illustrations": "2.46.39"
95
+ "@payfit/unity-illustrations": "2.47.0"
96
96
  },
97
97
  "peerDependencies": {
98
98
  "@hookform/devtools": "^4",
@@ -104,8 +104,8 @@
104
104
  "react-hook-form": "^7",
105
105
  "react-router-dom": "^5",
106
106
  "zod": "^3 || ^4",
107
- "@payfit/unity-icons": "2.46.39",
108
- "@payfit/unity-themes": "2.46.39"
107
+ "@payfit/unity-icons": "2.47.0",
108
+ "@payfit/unity-themes": "2.47.0"
109
109
  },
110
110
  "devDependencies": {
111
111
  "@figma/code-connect": "1.4.8",
@@ -154,9 +154,9 @@
154
154
  "@payfit/hr-apps-tsconfigs": "0.0.0-use.local",
155
155
  "@payfit/storybook-addon-console-errors": "0.0.0-use.local",
156
156
  "@payfit/storybook-config": "0.0.0-use.local",
157
- "@payfit/unity-icons": "2.46.39",
158
- "@payfit/unity-illustrations": "2.46.39",
159
- "@payfit/unity-themes": "2.46.39",
157
+ "@payfit/unity-icons": "2.47.0",
158
+ "@payfit/unity-illustrations": "2.47.0",
159
+ "@payfit/unity-themes": "2.47.0",
160
160
  "@payfit/vite-configs": "0.0.0-use.local"
161
161
  },
162
162
  "peerDependenciesMeta": {
@@ -1,12 +0,0 @@
1
- export interface UseComboboxFilterProps<T> {
2
- items?: T[];
3
- extractSearchableText?: (item: T) => string[];
4
- enabled?: boolean;
5
- searchOptions?: Intl.CollatorOptions;
6
- }
7
- export interface UseComboboxFilterReturn<T> {
8
- searchQuery: string;
9
- setSearchQuery: (value: string) => void;
10
- matchingItems: T[];
11
- }
12
- export declare function useComboboxFilter<T>({ items, extractSearchableText, enabled, searchOptions, }: UseComboboxFilterProps<T>): UseComboboxFilterReturn<T>;
@@ -1,22 +0,0 @@
1
- import { useState as m, useMemo as l, startTransition as y } from "react";
2
- import { useFilter as b } from "react-aria-components/Autocomplete";
3
- function p({
4
- items: e = [],
5
- extractSearchableText: s = (t) => [String(t)],
6
- enabled: n = !1,
7
- searchOptions: c = { sensitivity: "base" }
8
- }) {
9
- const [t, a] = m(""), o = b(c), i = o.contains.bind(o), u = (r) => {
10
- y(() => {
11
- a(r);
12
- });
13
- }, h = l(() => !n || t.length === 0 ? e : e.filter((r) => s(r).some((f) => i(f, t))), [n, e, t, s, i]);
14
- return {
15
- searchQuery: t,
16
- setSearchQuery: u,
17
- matchingItems: h
18
- };
19
- }
20
- export {
21
- p as useComboboxFilter
22
- };
@@ -1,14 +0,0 @@
1
- interface UseMultiSelectionStateProps<V extends string | number = string> {
2
- selectedKeys?: Set<V>;
3
- defaultSelectedKeys?: Set<V>;
4
- onSelectionChange?: (keys: Set<V>) => void;
5
- }
6
- interface UseMultiSelectionStateReturn<V extends string | number = string> {
7
- selectedKeys: Set<V>;
8
- isSelected: (key: V) => boolean;
9
- selectKey: (key: V) => void;
10
- unselectKey: (key: V) => void;
11
- toggleKey: (key: V) => void;
12
- }
13
- export declare function useMultiSelectionState<V extends string | number = string>({ selectedKeys: controlledKeys, defaultSelectedKeys, onSelectionChange, }: UseMultiSelectionStateProps<V>): UseMultiSelectionStateReturn<V>;
14
- export {};
@@ -1,47 +0,0 @@
1
- import { useState as w } from "react";
2
- function a({
3
- selectedKeys: c,
4
- defaultSelectedKeys: K,
5
- onSelectionChange: d
6
- }) {
7
- const [u, r] = w(
8
- () => K ?? /* @__PURE__ */ new Set()
9
- ), n = c !== void 0, l = n ? c : u;
10
- return {
11
- selectedKeys: l,
12
- isSelected: (t) => l.has(t),
13
- selectKey: (t) => {
14
- if (n && d) {
15
- const e = new Set(l);
16
- e.add(t), d(e);
17
- } else
18
- r((e) => {
19
- const s = new Set(e);
20
- return s.add(t), d?.(s), s;
21
- });
22
- },
23
- unselectKey: (t) => {
24
- if (n && d) {
25
- const e = new Set(l);
26
- e.delete(t), d(e);
27
- } else
28
- r((e) => {
29
- const s = new Set(e);
30
- return s.delete(t), d?.(s), s;
31
- });
32
- },
33
- toggleKey: (t) => {
34
- if (n && d) {
35
- const e = new Set(l);
36
- e.has(t) ? e.delete(t) : e.add(t), d(e);
37
- } else
38
- r((e) => {
39
- const s = new Set(e);
40
- return s.has(t) ? s.delete(t) : s.add(t), d?.(s), s;
41
- });
42
- }
43
- };
44
- }
45
- export {
46
- a as useMultiSelectionState
47
- };
@@ -1,18 +0,0 @@
1
- import { ForwardedRef, ReactElement } from 'react';
2
- export interface MultiSelectButtonProps<TItem> {
3
- placeholder?: string;
4
- isDisabled?: boolean;
5
- isReadOnly?: boolean;
6
- isLoading?: boolean;
7
- isInvalid?: boolean;
8
- /** The selected items to show in the button */
9
- selectedItems: Set<TItem>;
10
- /** Function to render the selected items */
11
- renderValue: (values: Set<TItem>) => string;
12
- onClearButtonPress?: () => void;
13
- onBlur?: () => void;
14
- onFocus?: () => void;
15
- }
16
- export declare const MultiSelectButton: <TItem>(props: MultiSelectButtonProps<TItem> & {
17
- ref?: ForwardedRef<HTMLButtonElement>;
18
- }) => ReactElement;
@@ -1,174 +0,0 @@
1
- import { jsxs as l, jsx as e } from "react/jsx-runtime";
2
- import { memo as D, forwardRef as k, useContext as A, useMemo as K } from "react";
3
- import { useSelectContext as R, useStoreState as $, Select as L } from "@ariakit/react";
4
- import { uyTv as P } from "@payfit/unity-themes";
5
- import { useId as T } from "react-aria/useId";
6
- import { useIntl as U } from "react-intl";
7
- import { Badge as W } from "../../badge/Badge.js";
8
- import { CircularIconButton as q } from "../../icon-button/CircularIconButton.js";
9
- import { Icon as b } from "../../icon/Icon.js";
10
- import { Spinner as F } from "../../spinner/Spinner.js";
11
- import { MultiSelectContext as G } from "../Multiselect.context.js";
12
- const H = P({
13
- slots: {
14
- base: "uy:h-5.5 uy:sm:h-500 uy:flex uy:items-center uy:justify-between uy:py-125 uy:sm:py-100 uy:px-150 uy:w-full uy:border uy:border-solid uy:rounded-100 uy:sm: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:not([disabled]):border-border-form-active uy:pointer-events-auto!",
15
- inputValue: "uy:flex-1 uy:typography-body uy:text-left uy:line-clamp-1",
16
- state: "uy:grow-0 uy:outline-none uy:typography-body uy:placeholder:text-content-neutral-lowest uy:inline-flex uy:gap-50 uy:items-center uy:px-100",
17
- suffix: "uy:text-content-neutral-lowest"
18
- },
19
- variants: {
20
- isDisabled: {
21
- true: {
22
- base: "uy:bg-surface-form-disabled uy:cursor-not-allowed uy:border-border-form-disabled uy:text-content-form-disabled",
23
- inputValue: "uy:text-content-form-disabled!",
24
- state: "uy:text-content-form-disabled",
25
- suffix: "uy:text-content-form-disabled"
26
- }
27
- },
28
- isReadOnly: {
29
- true: {
30
- base: "uy:bg-surface-form-disabled uy:cursor-not-allowed uy:border-border-form-disabled",
31
- inputValue: "uy:text-content-form-disabled",
32
- state: "uy:text-content-form-disabled",
33
- suffix: "uy:text-content-form-disabled"
34
- }
35
- },
36
- isInvalid: {
37
- true: {
38
- base: "uy:bg-surface-form-error uy:border-border-form-error",
39
- inputValue: "uy:text-content-form-error",
40
- state: "uy:text-content-form-error"
41
- // suffix: 'uy:text-content-form-error',
42
- }
43
- },
44
- isEmpty: {
45
- true: {
46
- inputValue: "uy:text-content-neutral-lowest"
47
- },
48
- false: {
49
- inputValue: "uy:text-content-form-enabled"
50
- }
51
- }
52
- },
53
- compoundVariants: [
54
- {
55
- isInvalid: !1,
56
- isDisabled: !1,
57
- isReadOnly: !1,
58
- className: {
59
- base: "uy:border-border-form-enabled uy:bg-surface-form-enabled",
60
- inputValue: "uy:text-content-form-enabled uy:bg-surface-form-enabled",
61
- state: "uy:text-content-neutral-disabled"
62
- }
63
- },
64
- {
65
- isEmpty: !0,
66
- isDisabled: !1,
67
- isReadOnly: !1,
68
- isInvalid: !1,
69
- className: {
70
- inputValue: "uy:text-content-neutral-lowest"
71
- }
72
- }
73
- ]
74
- });
75
- function J({
76
- isDisabled: n,
77
- isReadOnly: t,
78
- isLoading: c,
79
- isInvalid: r,
80
- placeholder: s,
81
- selectedItems: x,
82
- renderValue: d,
83
- onClearButtonPress: g,
84
- onBlur: w,
85
- onFocus: h,
86
- ...S
87
- }, v) {
88
- const m = T(), u = U(), C = R(), I = $(C, "open"), y = A(G), a = y.maxVisibleItems ?? 0, i = y.selectedKeys ?? /* @__PURE__ */ new Set(), o = Array.from(x), { base: M, inputValue: V, state: B, suffix: N } = H({
89
- isDisabled: !!n,
90
- isReadOnly: !!t,
91
- isInvalid: !!r,
92
- isEmpty: i.size === 0
93
- }), f = Math.max(
94
- o.length - a,
95
- 0
96
- ), O = i.size > 0 && !n && !t && !c, z = K(() => {
97
- if (o.length === 0) return s;
98
- const E = o.slice(0, a), j = new Set(E);
99
- return d(j);
100
- }, [o, a, d, s]);
101
- return /* @__PURE__ */ l(
102
- L,
103
- {
104
- ...S,
105
- ref: v,
106
- className: M(),
107
- disabled: n || t,
108
- "aria-invalid": r,
109
- "aria-readonly": t,
110
- "aria-labelledby": `${m}-select-button-label`,
111
- "data-dd-privacy": "mask",
112
- onBlur: w,
113
- onFocus: h,
114
- children: [
115
- /* @__PURE__ */ e("span", { id: `${m}-select-button-label`, className: V(), children: i.size > 0 ? z : s }),
116
- /* @__PURE__ */ l("div", { className: B(), children: [
117
- c && /* @__PURE__ */ e(
118
- F,
119
- {
120
- color: "inherit",
121
- size: "small",
122
- label: u.formatMessage({
123
- id: "unity:component:form-field:form-input:spinner:label",
124
- defaultMessage: "Loading"
125
- })
126
- }
127
- ),
128
- r && /* @__PURE__ */ e(
129
- b,
130
- {
131
- src: "WarningCircleOutlined",
132
- color: "content.form.invalid",
133
- alt: u.formatMessage({
134
- id: "unity:component:form-field:form-input:error:alt",
135
- defaultMessage: "Error"
136
- })
137
- }
138
- ),
139
- f > 0 && /* @__PURE__ */ l(W, { variant: "numeric", children: [
140
- "+",
141
- f
142
- ] }),
143
- O && /* @__PURE__ */ e(
144
- q,
145
- {
146
- title: u.formatMessage({
147
- id: "unity:component:common:clear:title",
148
- defaultMessage: "Clear"
149
- }),
150
- icon: "CloseOutlined",
151
- onPress: () => {
152
- g?.();
153
- }
154
- }
155
- )
156
- ] }),
157
- /* @__PURE__ */ e(
158
- b,
159
- {
160
- className: N(),
161
- src: I ? "CaretUpOutlined" : "CaretDownOutlined",
162
- role: "presentation"
163
- }
164
- )
165
- ]
166
- }
167
- );
168
- }
169
- const p = D(k(J));
170
- p.displayName = "MultiselectButton";
171
- const ue = p;
172
- export {
173
- ue as MultiSelectButton
174
- };
@@ -1,7 +0,0 @@
1
- import { SelectPopoverProps } from '@ariakit/react';
2
- type MultiSelectPopoverProps = SelectPopoverProps & {
3
- onBlur?: () => void;
4
- };
5
- declare function MultiSelectPopoverComponent({ children, ...props }: MultiSelectPopoverProps): import("react/jsx-runtime").JSX.Element;
6
- export declare const MultiSelectPopover: import('react').MemoExoticComponent<typeof MultiSelectPopoverComponent>;
7
- export {};
@@ -1,65 +0,0 @@
1
- import { jsx as o, jsxs as e, Fragment as m } from "react/jsx-runtime";
2
- import { memo as b, useContext as f } from "react";
3
- import { SelectPopover as h, Combobox as v, ComboboxList as x } from "@ariakit/react";
4
- import { uyTv as t } from "@payfit/unity-themes";
5
- import { Icon as g } from "../../icon/Icon.js";
6
- import { MultiSelectContext as w } from "../Multiselect.context.js";
7
- const S = t({
8
- slots: {
9
- base: "uy:shadow-300 uy:absolute uy:top-full uy:left-0 uy:z-50 uy:w-full uy:rounded-100 uy:sm:rounded-75 uy:border uy:border-solid uy:border-border-neutral uy:bg-surface-neutral uy:overflow-auto uy:max-h-[min(var(--popover-available-height,300px),300px)] uy:outline-none",
10
- list: "uy:p-100"
11
- }
12
- }), N = t({
13
- slots: {
14
- wrapper: "uy:sticky uy:top-0 uy:bg-surface-neutral uy:pt-100 uy:px-100",
15
- base: "uy:flex uy:w-full uy:gap-100 uy:sm:h-500 uy:transition-colors uy:rounded-100 uy:sm:rounded-75 uy:py-125 uy:sm:py-100 uy:bg-surface-form-high-enabled uy:px-125 uy:sm:px-150 uy:typography-body 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 uy:active:border-solid uy:active:border-border-form-active",
16
- input: "uy:focus-visible:outline-none",
17
- divider: "uy:my-100 uy:border-t uy:border-border-neutral"
18
- }
19
- });
20
- function C({
21
- children: r,
22
- ...s
23
- }) {
24
- const i = f(w), { base: l, list: u } = S(), { base: n, input: a, wrapper: y, divider: c } = N(), { onBlur: d, ...p } = s;
25
- return /* @__PURE__ */ o(
26
- h,
27
- {
28
- portal: !0,
29
- sameWidth: !0,
30
- unmountOnHide: !0,
31
- className: l(),
32
- onClose: () => d?.(),
33
- ...p,
34
- children: i.isSearchable ? /* @__PURE__ */ e(m, { children: [
35
- /* @__PURE__ */ e("div", { className: y(), children: [
36
- /* @__PURE__ */ e("div", { className: n(), children: [
37
- /* @__PURE__ */ o(
38
- g,
39
- {
40
- src: "MagnifyingGlassOutlined",
41
- color: "content.neutral.lowest",
42
- "aria-hidden": !0
43
- }
44
- ),
45
- /* @__PURE__ */ o(
46
- v,
47
- {
48
- autoSelect: !0,
49
- placeholder: "Search...",
50
- className: a()
51
- }
52
- )
53
- ] }),
54
- /* @__PURE__ */ o("hr", { className: c() })
55
- ] }),
56
- /* @__PURE__ */ o(x, { className: u(), children: r })
57
- ] }) : /* @__PURE__ */ o("div", { className: u(), children: r })
58
- }
59
- );
60
- }
61
- const M = b(C);
62
- M.displayName = "MultiSelectPopover";
63
- export {
64
- M as MultiSelectPopover
65
- };
@@ -1,5 +0,0 @@
1
- export interface SearchInputProps {
2
- 'aria-label': string;
3
- }
4
- declare const SearchInput: import('react').ForwardRefExoticComponent<SearchInputProps & import('react').RefAttributes<HTMLDivElement>>;
5
- export { SearchInput };
@@ -1,59 +0,0 @@
1
- import { jsxs as e, Fragment as l, jsx as t } from "react/jsx-runtime";
2
- import { forwardRef as m } from "react";
3
- import { uyTv as c } from "@payfit/unity-themes";
4
- import { Input as y } from "react-aria-components/Input";
5
- import { SearchField as d } from "react-aria-components/SearchField";
6
- import { useIntl as p } from "react-intl";
7
- import { CircularIconButton as f } from "../../icon-button/CircularIconButton.js";
8
- import { Icon as b } from "../../icon/Icon.js";
9
- const h = c({
10
- slots: {
11
- base: "uy:flex uy:gap-100 uy:transition-colors uy:py-125 uy:sm:py-100 uy:px-150 uy:rounded-100 uy:sm:rounded-75 uy:bg-surface-form-high-enabled uy:text-content-form-active uy:mt-100 uy:mb-100 uy:ml-100 uy:mr-100 uy:typography-body uy:focus-within:border uy:focus-within:border-solid uy:focus-within:border-border-form-active",
12
- input: "uy:flex-grow uy:outline-none uy:[&::-webkit-search-cancel-button]:hidden uy:min-h-300",
13
- button: "uy:text-content-neutral-enabled",
14
- separator: "uy:h-[1px] uy:bg-surface-neutral-lowest uy:w-full uy:mt-100"
15
- }
16
- }), g = m(
17
- ({ "aria-label": r }, o) => {
18
- const a = p(), { base: u, input: n, button: i, separator: s } = h();
19
- return /* @__PURE__ */ e(l, { children: [
20
- /* @__PURE__ */ e(
21
- d,
22
- {
23
- className: u(),
24
- ref: o,
25
- "data-dd-privacy": "mask",
26
- "aria-label": r,
27
- children: [
28
- /* @__PURE__ */ t(
29
- b,
30
- {
31
- src: "MagnifyingGlassOutlined",
32
- "aria-hidden": "true",
33
- color: "content.neutral.lowest"
34
- }
35
- ),
36
- /* @__PURE__ */ t(y, { className: n() }),
37
- /* @__PURE__ */ t(
38
- f,
39
- {
40
- title: a.formatMessage({
41
- id: "unity:component:common:clear:title",
42
- defaultMessage: "Clear"
43
- }),
44
- className: i(),
45
- icon: "CloseOutlined",
46
- asElement: "button"
47
- }
48
- )
49
- ]
50
- }
51
- ),
52
- /* @__PURE__ */ t("div", { "aria-hidden": "true", className: s() })
53
- ] });
54
- }
55
- );
56
- g.displayName = "SearchInput";
57
- export {
58
- g as SearchInput
59
- };