alif-ui 1.15.3 → 1.15.4

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.
@@ -1,3 +1,4 @@
1
- import { ListItemProps } from './ListItem.types';
2
- export declare const ListItem: <T>({ isLoading, className, itemClassName, onSearch, onChangeList, customNoOptionsText, style, proportions, options, values, hasSearch, searchValue, searchPlaceholder, fullWidth, isCenteredContent, ...props }: ListItemProps<T>) => import("react/jsx-runtime").JSX.Element;
1
+ import { ListItemBaseProps, ListItemProps } from './ListItem.types';
2
+ export declare const ListItemBase: <T>({ isLoading, className, itemClassName, onSearch, onChangeList, customNoOptionsText, style, proportions, options, values, hasSearch, searchValue, searchPlaceholder, fullWidth, isCenteredContent, activeIndex, ...props }: ListItemBaseProps<T>) => import("react/jsx-runtime").JSX.Element;
3
+ export declare const ListItem: <T>(props: ListItemProps<T>) => import("react/jsx-runtime").JSX.Element;
3
4
  //# sourceMappingURL=ListItem.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ListItem.d.ts","sourceRoot":"","sources":["../../../src/lib/components/ListItem/ListItem.tsx"],"names":[],"mappings":"AAKA,OAAO,EAAsB,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAoBrE,eAAO,MAAM,QAAQ,gRA2HpB,CAAC"}
1
+ {"version":3,"file":"ListItem.d.ts","sourceRoot":"","sources":["../../../src/lib/components/ListItem/ListItem.tsx"],"names":[],"mappings":"AAKA,OAAO,EACN,iBAAiB,EAEjB,aAAa,EACb,MAAM,kBAAkB,CAAC;AAoB1B,eAAO,MAAM,YAAY,iSAoIxB,CAAC;AAEF,eAAO,MAAM,QAAQ,yEAEpB,CAAC"}
@@ -1,27 +1,28 @@
1
- import { jsxs as o, jsx as l } from "react/jsx-runtime";
2
- import { useRef as P } from "react";
3
- import { classNames as t } from "../../utils/class-names.js";
4
- import { getListStyles as W } from "./ListItem.utils.js";
5
- import { useLocale as j } from "../../providers/hooks/useLocale/useLocale.js";
6
- import { Field as D } from "../Field/Field.js";
7
- import { OutlineSystemSearch as R } from "../../icons/components/OutlineSystemSearch.js";
8
- import { Skeleton as E } from "../Skeleton/Skeleton.js";
9
- import { OutlineSystemCheck as M } from "../../icons/components/OutlineSystemCheck.js";
10
- const w = "_root_i6753_1", B = "_fullWidth_i6753_80", F = "_list_i6753_84", q = "_noOptions_i6753_94", z = "_listItem_i6753_102", G = "_disabled_i6753_115", H = "_checkIcon_i6753_120", J = "_icon_i6753_126", K = "_centered_i6753_132", Q = "_selected_i6753_152", U = "_labelContainer_i6753_182", V = "_primaryText_i6753_193", X = "_secondaryText_i6753_194", s = {
11
- root: w,
12
- fullWidth: B,
13
- list: F,
14
- noOptions: q,
15
- listItem: z,
16
- disabled: G,
17
- checkIcon: H,
18
- icon: J,
19
- centered: K,
20
- selected: Q,
21
- labelContainer: U,
22
- primaryText: V,
23
- secondaryText: X
24
- }, h = {
1
+ import { jsxs as m, jsx as t } from "react/jsx-runtime";
2
+ import { useRef as D } from "react";
3
+ import { classNames as c } from "../../utils/class-names.js";
4
+ import { getListStyles as R, getListItemOptionId as B } from "./ListItem.utils.js";
5
+ import { useLocale as E } from "../../providers/hooks/useLocale/useLocale.js";
6
+ import { Field as M } from "../Field/Field.js";
7
+ import { OutlineSystemSearch as w } from "../../icons/components/OutlineSystemSearch.js";
8
+ import { Skeleton as F } from "../Skeleton/Skeleton.js";
9
+ import { OutlineSystemCheck as q } from "../../icons/components/OutlineSystemCheck.js";
10
+ const z = "_root_7se89_1", G = "_fullWidth_7se89_80", H = "_list_7se89_84", J = "_noOptions_7se89_94", K = "_listItem_7se89_102", Q = "_active_7se89_115", U = "_disabled_7se89_119", V = "_checkIcon_7se89_124", X = "_icon_7se89_130", Y = "_centered_7se89_136", Z = "_selected_7se89_156", $ = "_labelContainer_7se89_186", ee = "_primaryText_7se89_197", se = "_secondaryText_7se89_198", s = {
11
+ root: z,
12
+ fullWidth: G,
13
+ list: H,
14
+ noOptions: J,
15
+ listItem: K,
16
+ active: Q,
17
+ disabled: U,
18
+ checkIcon: V,
19
+ icon: X,
20
+ centered: Y,
21
+ selected: Z,
22
+ labelContainer: $,
23
+ primaryText: ee,
24
+ secondaryText: se
25
+ }, I = {
25
26
  ru: {
26
27
  noOptions: "Нет данных",
27
28
  searchPlaceholder: "Поиск..."
@@ -34,99 +35,105 @@ const w = "_root_i6753_1", B = "_fullWidth_i6753_80", F = "_list_i6753_84", q =
34
35
  noOptions: "Маълумот нест",
35
36
  searchPlaceholder: "Чусту чуй..."
36
37
  }
37
- }, ae = ({
38
- isLoading: f,
39
- className: u,
40
- itemClassName: y,
41
- onSearch: r,
42
- onChangeList: I,
43
- customNoOptionsText: b,
44
- style: x,
45
- proportions: d = "m",
46
- options: c = [],
47
- values: a = [],
38
+ }, te = ({
39
+ isLoading: r,
40
+ className: y,
41
+ itemClassName: b,
42
+ onSearch: n,
43
+ onChangeList: x,
44
+ customNoOptionsText: v,
45
+ style: O,
46
+ proportions: _ = "m",
47
+ options: a = [],
48
+ values: i = [],
48
49
  hasSearch: N = !1,
49
50
  searchValue: T = "",
50
- searchPlaceholder: p = "",
51
- fullWidth: C = !1,
52
- isCenteredContent: n = !1,
53
- ...O
51
+ searchPlaceholder: C = "",
52
+ fullWidth: L = !1,
53
+ isCenteredContent: o = !1,
54
+ activeIndex: g = -1,
55
+ ...d
54
56
  }) => {
55
- const { locale: m } = j(), v = P(null), g = t(
57
+ const { locale: h } = E(), p = d.role === "listbox", k = D(null), S = c(
56
58
  s.root,
57
- u,
58
- C && s.fullWidth
59
- ), _ = t(
59
+ y,
60
+ L && s.fullWidth
61
+ ), f = c(
60
62
  s.icon,
61
- n && s.centered
62
- ), k = t(
63
+ o && s.centered
64
+ ), A = c(
63
65
  s.checkIcon,
64
- n && s.centered
65
- ), L = t(
66
+ o && s.centered
67
+ ), P = c(
66
68
  s.labelContainer,
67
- n && s.centered
68
- ), S = (e) => {
69
- const i = Array.isArray(a) ? a.includes(e.value) : a === e.value;
70
- return t(
71
- s.listItem,
72
- y,
73
- i && s.selected,
74
- e.isDisabled && s.disabled
75
- );
76
- }, A = () => f ? [...Array(4)].map((e, i) => /* @__PURE__ */ l(
77
- E,
69
+ o && s.centered
70
+ ), u = (e) => Array.isArray(i) ? i.includes(e.value) : i === e.value, W = (e, l) => c(
71
+ s.listItem,
72
+ b,
73
+ u(e) && s.selected,
74
+ l === g && s.active,
75
+ e.isDisabled && s.disabled
76
+ ), j = () => r ? [...Array(4)].map((e, l) => /* @__PURE__ */ t(
77
+ F,
78
78
  {
79
- height: d === "l" ? "48px" : "44px",
79
+ height: _ === "l" ? "48px" : "44px",
80
80
  style: { borderRadius: "var(--list-item-skeleton-border-radius)" }
81
81
  },
82
- i
83
- )) : c != null && c.length ? c.map((e) => /* @__PURE__ */ o(
82
+ l
83
+ )) : a != null && a.length ? a.map((e, l) => /* @__PURE__ */ m(
84
84
  "li",
85
85
  {
86
- className: S(e),
87
- onClick: () => I(e.value, e),
86
+ ...p && {
87
+ id: B(d.id, l),
88
+ role: "option",
89
+ "aria-selected": u(e),
90
+ "data-option-index": l
91
+ },
92
+ className: W(e, l),
93
+ onClick: () => x(e.value, e),
88
94
  children: [
89
- e.leftIcon && /* @__PURE__ */ l("div", { className: _, children: e.leftIcon }),
90
- /* @__PURE__ */ o("div", { className: L, children: [
91
- /* @__PURE__ */ l("span", { className: s.primaryText, children: e.label }),
92
- e.secondaryText && /* @__PURE__ */ l("span", { className: s.secondaryText, children: e.secondaryText })
95
+ e.leftIcon && /* @__PURE__ */ t("div", { className: f, children: e.leftIcon }),
96
+ /* @__PURE__ */ m("div", { className: P, children: [
97
+ /* @__PURE__ */ t("span", { className: s.primaryText, children: e.label }),
98
+ e.secondaryText && /* @__PURE__ */ t("span", { className: s.secondaryText, children: e.secondaryText })
93
99
  ] }),
94
- e.rightIcon && /* @__PURE__ */ l("div", { className: _, children: e.rightIcon }),
95
- /* @__PURE__ */ l("div", { className: k, children: /* @__PURE__ */ l(M, {}) })
100
+ e.rightIcon && /* @__PURE__ */ t("div", { className: f, children: e.rightIcon }),
101
+ /* @__PURE__ */ t("div", { className: A, children: /* @__PURE__ */ t(q, {}) })
96
102
  ]
97
103
  },
98
104
  String(e.value + e.label)
99
- )) : /* @__PURE__ */ l("li", { className: s.noOptions, children: b || h[m].noOptions });
100
- return /* @__PURE__ */ o(
105
+ )) : /* @__PURE__ */ t("li", { className: s.noOptions, children: v || I[h].noOptions });
106
+ return /* @__PURE__ */ m(
101
107
  "div",
102
108
  {
103
- className: g,
104
- style: W(d, x),
105
- ...O,
109
+ className: S,
110
+ style: R(_, O),
111
+ ...d,
106
112
  children: [
107
- N && /* @__PURE__ */ l(
108
- D,
113
+ N && /* @__PURE__ */ t(
114
+ M,
109
115
  {
110
116
  proportions: "s",
111
117
  value: T,
112
- label: p || h[m].searchPlaceholder,
113
- onChange: (e) => r == null ? void 0 : r(e.target.value, e),
114
- leftIcon: /* @__PURE__ */ l(R, {})
118
+ label: C || I[h].searchPlaceholder,
119
+ onChange: (e) => n == null ? void 0 : n(e.target.value, e),
120
+ leftIcon: /* @__PURE__ */ t(w, {})
115
121
  }
116
122
  ),
117
- /* @__PURE__ */ l(
123
+ /* @__PURE__ */ t(
118
124
  "ul",
119
125
  {
120
126
  className: s.list,
121
- ref: v,
127
+ ref: k,
122
128
  onMouseDown: (e) => e.preventDefault(),
123
- children: A()
129
+ children: j()
124
130
  }
125
131
  )
126
132
  ]
127
133
  }
128
134
  );
129
- };
135
+ }, _e = (r) => /* @__PURE__ */ t(te, { ...r });
130
136
  export {
131
- ae as ListItem
137
+ _e as ListItem,
138
+ te as ListItemBase
132
139
  };
@@ -89,4 +89,13 @@ export interface ListItemProps<T> extends HTMLAttributes<HTMLDivElement> {
89
89
  */
90
90
  fullWidth?: boolean;
91
91
  }
92
+ /**
93
+ * Internal props for `Select` and `SelectMultiple`; not exported from the package.
94
+ */
95
+ export interface ListItemBaseProps<T> extends ListItemProps<T> {
96
+ /**
97
+ * Index of the option highlighted by keyboard navigation.
98
+ */
99
+ activeIndex?: number;
100
+ }
92
101
  //# sourceMappingURL=ListItem.types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ListItem.types.d.ts","sourceRoot":"","sources":["../../../src/lib/components/ListItem/ListItem.types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAE/D,MAAM,WAAW,kBAAkB,CAAC,CAAC;IACpC;;OAEG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IACd;;OAEG;IACH,KAAK,EAAE,CAAC,CAAC;IACT;;OAEG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;IACd;;OAEG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB;;OAEG;IACH,QAAQ,CAAC,EAAE,SAAS,CAAC;IACrB;;OAEG;IACH,SAAS,CAAC,EAAE,SAAS,CAAC;CACtB;AAED,MAAM,MAAM,WAAW,GAAG,GAAG,GAAG,GAAG,CAAC;AAEpC,MAAM,WAAW,aAAa,CAAC,CAAC,CAAE,SAAQ,cAAc,CAAC,cAAc,CAAC;IACvE;;OAEG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;OAEG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB;;OAEG;IACH,WAAW,CAAC,EAAE,WAAW,CAAC;IAC1B;;OAEG;IACH,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B;;OAEG;IACH,OAAO,EAAE,kBAAkB,CAAC,CAAC,CAAC,EAAE,CAAC;IACjC;;;QAGI;IACJ,YAAY,EAAE,CAAC,KAAK,EAAE,CAAC,EAAE,MAAM,EAAE,kBAAkB,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC;IAChE;;OAEG;IACH,MAAM,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC;IACjB;;OAEG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;QAEI;IACJ,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B;;OAEG;IACH,QAAQ,CAAC,EAAE,CACV,UAAU,EAAE,MAAM,EAClB,KAAK,CAAC,EAAE,WAAW,CAAC,gBAAgB,CAAC,KACjC,IAAI,CAAC;IACV;;OAEG;IACH,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B;;OAEG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;CACpB"}
1
+ {"version":3,"file":"ListItem.types.d.ts","sourceRoot":"","sources":["../../../src/lib/components/ListItem/ListItem.types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAE/D,MAAM,WAAW,kBAAkB,CAAC,CAAC;IACpC;;OAEG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IACd;;OAEG;IACH,KAAK,EAAE,CAAC,CAAC;IACT;;OAEG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;IACd;;OAEG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB;;OAEG;IACH,QAAQ,CAAC,EAAE,SAAS,CAAC;IACrB;;OAEG;IACH,SAAS,CAAC,EAAE,SAAS,CAAC;CACtB;AAED,MAAM,MAAM,WAAW,GAAG,GAAG,GAAG,GAAG,CAAC;AAEpC,MAAM,WAAW,aAAa,CAAC,CAAC,CAAE,SAAQ,cAAc,CAAC,cAAc,CAAC;IACvE;;OAEG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;OAEG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB;;OAEG;IACH,WAAW,CAAC,EAAE,WAAW,CAAC;IAC1B;;OAEG;IACH,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B;;OAEG;IACH,OAAO,EAAE,kBAAkB,CAAC,CAAC,CAAC,EAAE,CAAC;IACjC;;;QAGI;IACJ,YAAY,EAAE,CAAC,KAAK,EAAE,CAAC,EAAE,MAAM,EAAE,kBAAkB,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC;IAChE;;OAEG;IACH,MAAM,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC;IACjB;;OAEG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;QAEI;IACJ,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B;;OAEG;IACH,QAAQ,CAAC,EAAE,CACV,UAAU,EAAE,MAAM,EAClB,KAAK,CAAC,EAAE,WAAW,CAAC,gBAAgB,CAAC,KACjC,IAAI,CAAC;IACV;;OAEG;IACH,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B;;OAEG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;CACpB;AAED;;GAEG;AACH,MAAM,WAAW,iBAAiB,CAAC,CAAC,CAAE,SAAQ,aAAa,CAAC,CAAC,CAAC;IAC7D;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;CACrB"}
@@ -1,4 +1,5 @@
1
1
  import { CSSProperties } from 'react';
2
2
  import { Proportions } from './ListItem.types';
3
+ export declare const getListItemOptionId: (listId: string | undefined, index: number) => string;
3
4
  export declare const getListStyles: (proportions: Proportions, style: CSSProperties | undefined) => CSSProperties;
4
5
  //# sourceMappingURL=ListItem.utils.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ListItem.utils.d.ts","sourceRoot":"","sources":["../../../src/lib/components/ListItem/ListItem.utils.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AACtC,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAoB/C,eAAO,MAAM,aAAa,gBACZ,WAAW,SACjB,aAAa,GAAG,SAAS,kBAgChC,CAAC"}
1
+ {"version":3,"file":"ListItem.utils.d.ts","sourceRoot":"","sources":["../../../src/lib/components/ListItem/ListItem.utils.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AACtC,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAoB/C,eAAO,MAAM,mBAAmB,WACvB,MAAM,GAAG,SAAS,SACnB,MAAM,WACkB,CAAC;AAEjC,eAAO,MAAM,aAAa,gBACZ,WAAW,SACjB,aAAa,GAAG,SAAS,kBAgChC,CAAC"}
@@ -1,32 +1,32 @@
1
- import { getSize as t } from "../../utils/get-size.js";
1
+ import { getSize as i } from "../../utils/get-size.js";
2
2
  import { resolveTypography as l } from "../../utils/typography.js";
3
- const a = (i) => {
4
- switch (i) {
3
+ const a = (t) => {
4
+ switch (t) {
5
5
  case "l":
6
6
  return l("body", "m");
7
7
  case "m":
8
8
  return l("body", "s");
9
9
  }
10
- }, c = (i) => {
11
- switch (i) {
10
+ }, c = (t) => {
11
+ switch (t) {
12
12
  case "l":
13
13
  return l("body", "s");
14
14
  case "m":
15
15
  return l("description", "l");
16
16
  }
17
- }, h = (i, n) => {
18
- const e = a(i), s = c(i);
17
+ }, h = (t, n) => `${t}-option-${n}`, r = (t, n) => {
18
+ const e = a(t), s = c(t);
19
19
  return {
20
20
  ...n,
21
- "--list-border-radius": t(i, "list-border-radius"),
22
- "--list-spacing-between": t(i, "list-spacing-between"),
23
- "--list-spacing-horizontal": t(
24
- i,
21
+ "--list-border-radius": i(t, "list-border-radius"),
22
+ "--list-spacing-between": i(t, "list-spacing-between"),
23
+ "--list-spacing-horizontal": i(
24
+ t,
25
25
  "list-spacing-horizontal"
26
26
  ),
27
- "--list-spacing-vertical": t(i, "list-spacing-vertical"),
28
- "--list-item-border-radius": t(
29
- i,
27
+ "--list-spacing-vertical": i(t, "list-spacing-vertical"),
28
+ "--list-item-border-radius": i(
29
+ t,
30
30
  "list-item-border-radius"
31
31
  ),
32
32
  "--list-item-font-family": e.fontFamily,
@@ -39,12 +39,13 @@ const a = (i) => {
39
39
  "--list-item-secondary-font-size": s.fontSize,
40
40
  "--list-item-secondary-line-height": s.lineHeight,
41
41
  "--list-item-secondary-letter-spacing": s.letterSpacing,
42
- "--list-item-icon-width": t(i, "list-item-icon-width"),
43
- "--list-item-icon-height": t(i, "list-item-icon-height"),
44
- "--list-item-image-width": t(i, "list-item-image-width"),
45
- "--list-item-image-height": t(i, "list-item-image-height")
42
+ "--list-item-icon-width": i(t, "list-item-icon-width"),
43
+ "--list-item-icon-height": i(t, "list-item-icon-height"),
44
+ "--list-item-image-width": i(t, "list-item-image-width"),
45
+ "--list-item-image-height": i(t, "list-item-image-height")
46
46
  };
47
47
  };
48
48
  export {
49
- h as getListStyles
49
+ h as getListItemOptionId,
50
+ r as getListStyles
50
51
  };
@@ -1 +1 @@
1
- {"version":3,"file":"Select.d.ts","sourceRoot":"","sources":["../../../src/lib/components/Select/Select.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAIb,aAAa,EAIb,MAAM,OAAO,CAAC;AASf,OAAO,EAAE,WAAW,EAAe,MAAM,gBAAgB,CAAC;AAyL1D,eAAO,MAAM,MAAM,wEAEd,WAAW,CAAC"}
1
+ {"version":3,"file":"Select.d.ts","sourceRoot":"","sources":["../../../src/lib/components/Select/Select.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAIb,aAAa,EAKb,MAAM,OAAO,CAAC;AASf,OAAO,EAAE,WAAW,EAAe,MAAM,gBAAgB,CAAC;AA8M1D,eAAO,MAAM,MAAM,wEAEd,WAAW,CAAC"}
@@ -1,146 +1,161 @@
1
- import { jsxs as X, jsx as c } from "react/jsx-runtime";
2
- import { forwardRef as Y, useState as p, useMemo as y, useEffect as Z } from "react";
3
- import { classNames as I } from "../../utils/class-names.js";
4
- import { isObjectValue as $, getFieldValue as A, restoreSearchValue as D } from "./Select.utils.js";
5
- import { Popover as g } from "../Popover/Popover.js";
6
- import { Input as ee } from "../Input/Input.js";
7
- import { ListItem as re } from "../ListItem/ListItem.js";
8
- import { OutlineNavigationChevronDownSmall as te } from "../../icons/components/OutlineNavigationChevronDownSmall.js";
9
- const oe = "_root_1wy4o_1", se = "_chevron_1wy4o_8", le = "_chevronActive_1wy4o_12", ne = "_fullWidth_1wy4o_16", ce = "_disabled_1wy4o_20", a = {
10
- root: oe,
11
- chevron: se,
12
- chevronActive: le,
13
- fullWidth: ne,
14
- disabled: ce
15
- }, ae = ({
16
- onChange: v,
1
+ import { jsxs as oe, jsx as d } from "react/jsx-runtime";
2
+ import { forwardRef as te, useId as se, useState as x, useMemo as D, useEffect as re } from "react";
3
+ import { classNames as N } from "../../utils/class-names.js";
4
+ import { isObjectValue as ne, getFieldValue as O, restoreSearchValue as A } from "./Select.utils.js";
5
+ import { useSelectNavigation as le } from "./useSelectNavigation.js";
6
+ import { ListItemBase as ce } from "../ListItem/ListItem.js";
7
+ import { Popover as v } from "../Popover/Popover.js";
8
+ import { Input as ae } from "../Input/Input.js";
9
+ import { OutlineNavigationChevronDownSmall as ie } from "../../icons/components/OutlineNavigationChevronDownSmall.js";
10
+ const de = "_root_1wy4o_1", ue = "_chevron_1wy4o_8", me = "_chevronActive_1wy4o_12", he = "_fullWidth_1wy4o_16", fe = "_disabled_1wy4o_20", u = {
11
+ root: de,
12
+ chevron: ue,
13
+ chevronActive: me,
14
+ fullWidth: he,
15
+ disabled: fe
16
+ }, ge = ({
17
+ onChange: p,
17
18
  value: t,
18
- onSearch: h,
19
- onSearchList: f,
20
- className: N,
19
+ onSearch: m,
20
+ onSearchList: h,
21
+ className: L,
21
22
  fullWidth: _ = !0,
22
- style: O,
23
- id: x,
24
- name: L,
25
- searchValue: W,
26
- searchPlaceholder: j,
27
- customNoOptionsText: T,
28
- isCenteredContent: b,
29
- itemClassName: F,
30
- hasSearch: M,
31
- options: r = [],
23
+ style: W,
24
+ id: b,
25
+ name: j,
26
+ searchValue: P,
27
+ searchPlaceholder: T,
28
+ customNoOptionsText: F,
29
+ isCenteredContent: K,
30
+ itemClassName: M,
31
+ hasSearch: R,
32
+ options: o = [],
32
33
  proportions: w = "m",
33
34
  keepLabel: C,
34
- filterable: i = !0,
35
- showClearIcon: R = !0,
35
+ filterable: l = !0,
36
+ showClearIcon: S = !0,
36
37
  isLoading: k,
37
- onBlur: E,
38
- disabled: m,
39
- disableClientFilter: V = !1,
40
- ...P
38
+ onBlur: B,
39
+ disabled: f,
40
+ disableClientFilter: I = !1,
41
+ ...E
41
42
  }, q) => {
42
- const [s, u] = p(!1), l = y(
43
- () => $(t) ? t.value : t,
43
+ const z = se(), V = b || z, [s, c] = x(!1), r = D(
44
+ () => ne(t) ? t.value : t,
44
45
  [t]
45
- ), [d, n] = p(""), z = I(
46
- _ && a.fullWidth,
47
- m && a.disabled,
48
- N
49
- ), B = I(
50
- s && a.chevronActive,
51
- a.chevron
52
- ), G = y(() => !i || V || A(r, l) === d ? r : r.filter(
53
- (e) => e.label.toLowerCase().includes(d.toLowerCase())
46
+ ), [a, i] = x(""), G = N(
47
+ _ && u.fullWidth,
48
+ f && u.disabled,
49
+ L
50
+ ), H = N(
51
+ s && u.chevronActive,
52
+ u.chevron
53
+ ), g = D(() => !l || I || O(o, r) === a ? o : o.filter(
54
+ (e) => e.label.toLowerCase().includes(a.toLowerCase())
54
55
  ), [
55
- i,
56
- V,
57
- r,
58
56
  l,
59
- d
60
- ]), H = () => {
61
- v(null, null), n("");
62
- }, J = () => {
63
- m || u((e) => !e);
64
- }, K = (e) => {
65
- const { value: o } = e.target;
66
- n(o), h == null || h(o, e), !s && i && u(!0);
57
+ I,
58
+ o,
59
+ r,
60
+ a
61
+ ]), J = () => {
62
+ p(null, null), i("");
67
63
  }, Q = () => {
68
- const e = D(
64
+ f || c((e) => !e);
65
+ }, U = (e) => {
66
+ const { value: n } = e.target;
67
+ i(n), m == null || m(n, e), !s && l && c(!0);
68
+ }, X = () => {
69
+ const e = A(
69
70
  t,
70
- r,
71
- l
71
+ o,
72
+ r
72
73
  );
73
- n(e), u(!1);
74
- }, S = (e, o) => {
75
- o.isDisabled || (v(e, o), n(A(r, e)), u(!1));
76
- }, U = (e, o) => {
77
- f == null || f(e, o);
74
+ i(e), c(!1);
75
+ }, y = (e, n) => {
76
+ n.isDisabled || (p(e, n), i(O(o, e)), c(!1));
77
+ }, { handleKeyDown: Y, comboboxProps: Z, listProps: $ } = le({
78
+ id: V,
79
+ options: g,
80
+ isOpen: s,
81
+ searchValue: a,
82
+ selectedIndex: g.findIndex(
83
+ (e) => e.value === r
84
+ ),
85
+ onOpen: () => c(!0),
86
+ onSelect: y
87
+ }), ee = (e, n) => {
88
+ h == null || h(e, n);
78
89
  };
79
- return Z(() => {
90
+ return re(() => {
80
91
  if (!s) {
81
- const e = D(
92
+ const e = A(
82
93
  t,
83
- r,
84
- l
94
+ o,
95
+ r
85
96
  );
86
- n(e);
97
+ i(e);
87
98
  }
88
- }, [r, s, l, t]), /* @__PURE__ */ X(
89
- g,
99
+ }, [o, s, r, t]), /* @__PURE__ */ oe(
100
+ v,
90
101
  {
91
102
  width: "trigger",
92
103
  isOpen: s,
93
- onClose: Q,
104
+ onClose: X,
94
105
  children: [
95
- /* @__PURE__ */ c(g.Trigger, { className: z, style: O, onBlur: E, children: /* @__PURE__ */ c(
96
- ee,
106
+ /* @__PURE__ */ d(v.Trigger, { className: G, style: W, onBlur: B, children: /* @__PURE__ */ d(
107
+ ae,
97
108
  {
98
109
  ref: q,
99
110
  fullWidth: !0,
100
- onClear: R ? H : void 0,
101
- value: d,
111
+ onClear: S ? J : void 0,
112
+ value: a,
102
113
  proportions: w,
103
114
  keepLabelFixed: s && !C,
104
- rightIcon: /* @__PURE__ */ c(
105
- te,
115
+ rightIcon: /* @__PURE__ */ d(
116
+ ie,
106
117
  {
107
118
  onMouseDown: (e) => e.preventDefault(),
108
119
  "aria-label": "Toggle dropdown",
109
- className: B
120
+ className: H
110
121
  }
111
122
  ),
112
- onFieldClick: J,
113
- onChange: K,
114
- readOnly: !i,
115
- id: x,
116
- name: L,
123
+ onFieldClick: Q,
124
+ onChange: U,
125
+ onKeyDown: Y,
126
+ ...Z,
127
+ "aria-autocomplete": l ? "list" : "none",
128
+ readOnly: !l,
129
+ id: V,
130
+ name: j,
117
131
  keepLabel: C,
118
- disabled: m,
119
- ...P
132
+ disabled: f,
133
+ ...E
120
134
  }
121
135
  ) }),
122
- /* @__PURE__ */ c(g.Dropdown, { className: a.root, children: /* @__PURE__ */ c(
123
- re,
136
+ /* @__PURE__ */ d(v.Dropdown, { className: u.root, children: /* @__PURE__ */ d(
137
+ ce,
124
138
  {
139
+ ...$,
125
140
  isLoading: k,
126
- values: l,
127
- onChangeList: S,
128
- options: G,
141
+ values: r,
142
+ onChangeList: y,
143
+ options: g,
129
144
  fullWidth: _,
130
145
  proportions: w === "l" ? "l" : "m",
131
- searchPlaceholder: j,
132
- searchValue: W,
133
- itemClassName: F,
134
- isCenteredContent: b,
135
- customNoOptionsText: T,
136
- onSearch: U,
137
- hasSearch: M
146
+ searchPlaceholder: T,
147
+ searchValue: P,
148
+ itemClassName: M,
149
+ isCenteredContent: K,
150
+ customNoOptionsText: F,
151
+ onSearch: ee,
152
+ hasSearch: R
138
153
  }
139
154
  ) })
140
155
  ]
141
156
  }
142
157
  );
143
- }, _e = Y(ae);
158
+ }, De = te(ge);
144
159
  export {
145
- _e as Select
160
+ De as Select
146
161
  };
@@ -0,0 +1,28 @@
1
+ import { KeyboardEvent, MouseEvent } from 'react';
2
+ import { ListItemOptionType } from '../ListItem';
3
+ interface UseSelectNavigationOptions<T> {
4
+ id: string;
5
+ options: ListItemOptionType<T>[];
6
+ isOpen: boolean;
7
+ searchValue: string;
8
+ selectedIndex?: number;
9
+ onOpen: () => void;
10
+ onSelect: (value: T, option: ListItemOptionType<T>) => void;
11
+ }
12
+ export declare const useSelectNavigation: <T>({ id, options, isOpen, searchValue, selectedIndex, onOpen, onSelect, }: UseSelectNavigationOptions<T>) => {
13
+ handleKeyDown: (e: KeyboardEvent<HTMLElement>) => void;
14
+ comboboxProps: {
15
+ role: string;
16
+ 'aria-expanded': boolean;
17
+ 'aria-controls': string;
18
+ 'aria-activedescendant': string | undefined;
19
+ };
20
+ listProps: {
21
+ id: string;
22
+ role: string;
23
+ activeIndex: number;
24
+ onMouseMove: (e: MouseEvent<HTMLElement>) => void;
25
+ };
26
+ };
27
+ export {};
28
+ //# sourceMappingURL=useSelectNavigation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useSelectNavigation.d.ts","sourceRoot":"","sources":["../../../src/lib/components/Select/useSelectNavigation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,UAAU,EAAY,MAAM,OAAO,CAAC;AAC5D,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAGjD,UAAU,0BAA0B,CAAC,CAAC;IACrC,EAAE,EAAE,MAAM,CAAC;IACX,OAAO,EAAE,kBAAkB,CAAC,CAAC,CAAC,EAAE,CAAC;IACjC,MAAM,EAAE,OAAO,CAAC;IAChB,WAAW,EAAE,MAAM,CAAC;IACpB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,MAAM,EAAE,MAAM,IAAI,CAAC;IACnB,QAAQ,EAAE,CAAC,KAAK,EAAE,CAAC,EAAE,MAAM,EAAE,kBAAkB,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC;CAC5D;AAED,eAAO,MAAM,mBAAmB;uBAkDL,cAAc,WAAW,CAAC;;;;;;;;;;;yBAexB,WAAW,WAAW,CAAC;;CA0BnD,CAAC"}