@tcn/ui 0.0.4 → 0.1.1
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/actions/button/base_button/base_button.d.ts.map +1 -1
- package/dist/actions/button/base_button/base_button.js +17 -12
- package/dist/actions/button/base_button/base_button.js.map +1 -1
- package/dist/actions/button/button/button.d.ts.map +1 -1
- package/dist/actions/button/button/button.js +7 -7
- package/dist/actions/button/button/button.js.map +1 -1
- package/dist/actions/button/slim_button/slim_button.js +2 -2
- package/dist/actions/button/slim_button/slim_button.js.map +1 -1
- package/dist/button.css +1 -1
- package/dist/footer.css +1 -1
- package/dist/form/field/common/field_error.js +3 -2
- package/dist/form/field/common/field_error.js.map +1 -1
- package/dist/inputs/input/input.d.ts +2 -2
- package/dist/inputs/input/input.d.ts.map +1 -1
- package/dist/inputs/input/input.js.map +1 -1
- package/dist/inputs/options/option.d.ts +1 -0
- package/dist/inputs/options/option.d.ts.map +1 -1
- package/dist/inputs/options/option.js.map +1 -1
- package/dist/inputs/phone_number_input/phone_number_input.d.ts +6 -1
- package/dist/inputs/phone_number_input/phone_number_input.d.ts.map +1 -1
- package/dist/inputs/phone_number_input/phone_number_input.js +169 -125
- package/dist/inputs/phone_number_input/phone_number_input.js.map +1 -1
- package/dist/inputs/suggestions/suggestion_item.d.ts +1 -1
- package/dist/inputs/suggestions/suggestion_item.d.ts.map +1 -1
- package/dist/inputs/suggestions/suggestion_item.js +23 -18
- package/dist/inputs/suggestions/suggestion_item.js.map +1 -1
- package/dist/inputs/suggestions/suggestion_list.d.ts +1 -1
- package/dist/inputs/suggestions/suggestion_list.d.ts.map +1 -1
- package/dist/inputs/suggestions/suggestion_list.js +105 -95
- package/dist/inputs/suggestions/suggestion_list.js.map +1 -1
- package/dist/layouts/footer/footer.js +5 -5
- package/dist/layouts/footer/footer.js.map +1 -1
- package/dist/layouts/index.d.ts +3 -2
- package/dist/layouts/index.d.ts.map +1 -1
- package/dist/layouts/index.js +26 -24
- package/dist/layouts/index.js.map +1 -1
- package/dist/layouts/list/item.d.ts +1 -0
- package/dist/layouts/list/item.d.ts.map +1 -1
- package/dist/layouts/list/item.js +17 -6
- package/dist/layouts/list/item.js.map +1 -1
- package/dist/layouts/list/list.js +10 -10
- package/dist/layouts/list/list.js.map +1 -1
- package/dist/overlay/context_menu/context_menu.js +4 -4
- package/dist/overlay/index.js +3 -3
- package/dist/overlay/popper/popper.js +12 -12
- package/dist/{portal-qqIp4SIl.js → overlay/portal/portal.js} +3 -3
- package/dist/overlay/portal/portal.js.map +1 -0
- package/dist/overlay/portal/portal_platform.js +3 -4
- package/dist/overlay/portal/portal_platform.js.map +1 -1
- package/dist/phone_number_input.css +1 -1
- package/dist/slim_button.css +1 -1
- package/dist/surfaces/card/card.d.ts.map +1 -1
- package/dist/surfaces/card/card.js +7 -16
- package/dist/surfaces/card/card.js.map +1 -1
- package/dist/surfaces/confirm/confirm.js +4 -4
- package/dist/themes/index.js +6 -141
- package/dist/themes/index.js.map +1 -1
- package/dist/themes/stylesheets/reset.js +140 -0
- package/dist/themes/stylesheets/reset.js.map +1 -0
- package/dist/themes/themes/ergo/ergo_theme.js +595 -0
- package/dist/themes/themes/ergo/ergo_theme.js.map +1 -0
- package/dist/tokens/bubble/bubble.js +17 -16
- package/dist/tokens/bubble/bubble.js.map +1 -1
- package/dist/tokens/chip/chip.js +9 -8
- package/dist/tokens/chip/chip.js.map +1 -1
- package/dist/typography/title/title.js +8 -8
- package/dist/typography/title/title.js.map +1 -1
- package/package.json +3 -3
- package/src/actions/button/base_button/base_button.tsx +7 -2
- package/src/actions/button/button/button.module.css +0 -78
- package/src/actions/button/button/button.tsx +2 -4
- package/src/actions/button/slim_button/slim_button.module.css +0 -26
- package/src/actions/button/slim_button/slim_button.tsx +1 -1
- package/src/inputs/input/input.tsx +3 -2
- package/src/inputs/options/option.tsx +1 -0
- package/src/inputs/phone_number_input/phone_number_input.module.css +12 -0
- package/src/inputs/phone_number_input/phone_number_input.stories.tsx +8 -0
- package/src/inputs/phone_number_input/phone_number_input.tsx +99 -21
- package/src/inputs/suggestions/suggestion_item.tsx +12 -2
- package/src/inputs/suggestions/suggestion_list.tsx +22 -3
- package/src/layouts/footer/footer.module.css +0 -1
- package/src/layouts/footer/footer.tsx +1 -1
- package/src/layouts/index.ts +3 -2
- package/src/layouts/list/item.tsx +10 -2
- package/src/layouts/list/list.tsx +2 -2
- package/src/surfaces/card/card.tsx +2 -8
- package/src/surfaces/modal/__stories__/modal.stories.tsx +1 -1
- package/src/surfaces/panel/__stories__/panel.stories.tsx +13 -12
- package/src/themes/themes/ergo/__stories__/components/material_picker/sb_inverted_materials.module.css +34 -0
- package/src/themes/themes/ergo/__stories__/components/material_picker/sb_material_picker.tsx +52 -0
- package/src/themes/themes/ergo/__stories__/components/tone_picker/sb_card.module.css +5 -0
- package/src/themes/themes/ergo/__stories__/components/tone_picker/sb_tone_card.tsx +40 -0
- package/src/themes/themes/ergo/__stories__/components/tone_picker/sb_tone_picker.tsx +83 -0
- package/src/themes/themes/ergo/__stories__/components/tone_picker/types.ts +7 -0
- package/src/themes/themes/ergo/__stories__/material.stories.tsx +154 -0
- package/src/themes/themes/ergo/__stories__/sb_materials.module.css +110 -0
- package/src/themes/themes/ergo/__stories__/utils.ts +92 -0
- package/src/themes/themes/ergo/ergo_theme.css +298 -35
- package/src/typography/title/title.tsx +1 -1
- package/tsconfig.json +0 -3
- package/dist/card.css +0 -1
- package/dist/portal-qqIp4SIl.js.map +0 -1
- package/dist/themes/stylesheets/reset.css +0 -1
- package/dist/themes/themes/ergo/ergo_theme.css +0 -1
- package/dist/themes/themes/windows_98/windows_98.css +0 -1
- package/src/surfaces/card/card.module.css +0 -5
- /package/dist/{overlay/portal/portal.css → portal_platform.css} +0 -0
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
import { jsx as
|
|
1
|
+
import { jsx as r, jsxs as K, Fragment as ce } from "react/jsx-runtime";
|
|
2
2
|
import { BodyText as ae } from "../../typography/body_text/body_text.js";
|
|
3
|
-
import { clsx as
|
|
3
|
+
import { clsx as N } from "clsx";
|
|
4
4
|
import "../../callout.module-D8ECmxpO.js";
|
|
5
5
|
import "../../caption.module-DDq0H4xZ.js";
|
|
6
6
|
import "../../footnote.module-DEyFuqOr.js";
|
|
7
7
|
import "../../headline.module-BiwHBtGf.js";
|
|
8
8
|
import "../../subheadline.module-C-v7zMkQ.js";
|
|
9
9
|
import "../../title.module-B16de2jd.js";
|
|
10
|
-
import { VStack as
|
|
10
|
+
import { VStack as O } from "../../stacks/v_stack.js";
|
|
11
11
|
import { ZStack as ue } from "../../stacks/z_stack.js";
|
|
12
|
-
import { Children as pe, isValidElement as de, useState as
|
|
12
|
+
import { Children as pe, isValidElement as de, useState as a, useRef as T, useLayoutEffect as S } from "react";
|
|
13
13
|
import { FocusRedirect as fe } from "../../utils/focus_redirect.js";
|
|
14
14
|
import "../../utils/click_away_listener.js";
|
|
15
15
|
import "../../utils/scroll_away_listener.js";
|
|
16
16
|
import "../../utils/hooks/use_resize_observer.js";
|
|
17
17
|
import { SuggestionItem as ge } from "./suggestion_item.js";
|
|
18
|
-
import { Option as
|
|
18
|
+
import { Option as U } from "../options/option.js";
|
|
19
19
|
import "../../actions/button/base_button/base_button.js";
|
|
20
20
|
import "../../actions/button/button_group/button_group.js";
|
|
21
21
|
import "../../actions/button/slim_button/slim_button.js";
|
|
@@ -26,68 +26,78 @@ import { Popper as me } from "../../overlay/popper/popper.js";
|
|
|
26
26
|
import '../../suggestion_list.css';const we = "_suggestion-list_711fb17", be = "_input_a0df060", R = { "suggestion-list": we, input: be }, I = 50, xe = 50;
|
|
27
27
|
function je({
|
|
28
28
|
value: A = "",
|
|
29
|
-
scrollToValue:
|
|
30
|
-
anchorElement:
|
|
31
|
-
children:
|
|
32
|
-
onOptionSelect:
|
|
33
|
-
noSuggestionMessage:
|
|
34
|
-
onClose:
|
|
29
|
+
scrollToValue: g,
|
|
30
|
+
anchorElement: l,
|
|
31
|
+
children: V,
|
|
32
|
+
onOptionSelect: h,
|
|
33
|
+
noSuggestionMessage: P = "-- No Matches --",
|
|
34
|
+
onClose: b,
|
|
35
35
|
onChange: D,
|
|
36
36
|
onKeyUp: F,
|
|
37
37
|
onKeyDown: H,
|
|
38
|
-
trimCustomInput:
|
|
39
|
-
haveValueAsOption:
|
|
40
|
-
|
|
38
|
+
trimCustomInput: W = !1,
|
|
39
|
+
haveValueAsOption: $ = !1,
|
|
40
|
+
...j
|
|
41
41
|
}) {
|
|
42
|
-
const
|
|
43
|
-
(e) => de(e) && e.type ===
|
|
44
|
-
), [
|
|
45
|
-
if (
|
|
46
|
-
const e =
|
|
42
|
+
const x = pe.toArray(V).filter(
|
|
43
|
+
(e) => de(e) && e.type === U
|
|
44
|
+
), [L, q] = a(() => {
|
|
45
|
+
if (g != null) {
|
|
46
|
+
const e = x.findIndex((o) => o.props.value === g);
|
|
47
47
|
if (e !== -1)
|
|
48
48
|
return e;
|
|
49
49
|
}
|
|
50
50
|
return -1;
|
|
51
|
-
}), M =
|
|
51
|
+
}), M = T(""), [Z, _] = a(I), [f, k] = a(L), [m, X] = a(A), c = T(null), [z, G] = a(x.length), [n, B] = a(
|
|
52
52
|
() => C(A, I)
|
|
53
|
-
), [
|
|
54
|
-
function
|
|
55
|
-
const
|
|
53
|
+
), [J, Q] = a(), [Y, ee] = a();
|
|
54
|
+
function te(e) {
|
|
55
|
+
const o = e.key, t = e.currentTarget, s = M.current = o;
|
|
56
56
|
if (M.current = "", s)
|
|
57
|
-
switch (
|
|
57
|
+
switch (o) {
|
|
58
58
|
case "Enter": {
|
|
59
|
-
if (n[
|
|
60
|
-
const p =
|
|
59
|
+
if (n[f] == null) {
|
|
60
|
+
const p = W ? t.value.trim() : t.value;
|
|
61
61
|
if (p === "")
|
|
62
62
|
return;
|
|
63
|
-
const y = p.toLocaleLowerCase(),
|
|
63
|
+
const y = p.toLocaleLowerCase(), i = x.find(
|
|
64
64
|
(v) => v.props.value.toLocaleLowerCase() === y || v.props.label != null && v.props.label.toLocaleLowerCase() === y
|
|
65
|
-
),
|
|
65
|
+
), E = i != null, d = i?.props.label || p, le = i?.props.value || p;
|
|
66
66
|
requestAnimationFrame(() => {
|
|
67
|
-
|
|
67
|
+
h && h(
|
|
68
|
+
le,
|
|
69
|
+
d,
|
|
70
|
+
E,
|
|
71
|
+
i?.props.obfuscate ?? !1
|
|
72
|
+
);
|
|
68
73
|
});
|
|
69
74
|
break;
|
|
70
75
|
}
|
|
71
|
-
const
|
|
72
|
-
if (
|
|
76
|
+
const u = n[f].props;
|
|
77
|
+
if (u.disabled)
|
|
73
78
|
break;
|
|
74
79
|
requestAnimationFrame(() => {
|
|
75
|
-
|
|
80
|
+
h && h(
|
|
81
|
+
u.value,
|
|
82
|
+
u.label,
|
|
83
|
+
!0,
|
|
84
|
+
u.obfuscate ?? !1
|
|
85
|
+
);
|
|
76
86
|
});
|
|
77
87
|
break;
|
|
78
88
|
}
|
|
79
89
|
case "Escape": {
|
|
80
|
-
|
|
90
|
+
b && b(t.value, t.selectionStart, t.selectionEnd);
|
|
81
91
|
break;
|
|
82
92
|
}
|
|
83
93
|
}
|
|
84
94
|
F && F(e);
|
|
85
95
|
}
|
|
86
|
-
function
|
|
87
|
-
const
|
|
88
|
-
switch (M.current =
|
|
96
|
+
function se(e) {
|
|
97
|
+
const o = e.key;
|
|
98
|
+
switch (M.current = o, o) {
|
|
89
99
|
case "ArrowDown": {
|
|
90
|
-
let t =
|
|
100
|
+
let t = f + 1;
|
|
91
101
|
for (; t < n.length && n[t]?.props.disabled; )
|
|
92
102
|
t++;
|
|
93
103
|
if (t === n.length) {
|
|
@@ -95,13 +105,13 @@ function je({
|
|
|
95
105
|
t++;
|
|
96
106
|
t === n.length && (t = -1);
|
|
97
107
|
}
|
|
98
|
-
|
|
108
|
+
k(t), e.preventDefault();
|
|
99
109
|
break;
|
|
100
110
|
}
|
|
101
111
|
case "Tab": {
|
|
102
112
|
let t = 1;
|
|
103
113
|
e.shiftKey && (t = -1);
|
|
104
|
-
let s =
|
|
114
|
+
let s = f + t;
|
|
105
115
|
if (t > 0)
|
|
106
116
|
for (; s < n.length && n[s]?.props.disabled; )
|
|
107
117
|
s++;
|
|
@@ -117,11 +127,11 @@ function je({
|
|
|
117
127
|
s--;
|
|
118
128
|
s === -1 && (s = -1);
|
|
119
129
|
}
|
|
120
|
-
|
|
130
|
+
k(s), e.preventDefault();
|
|
121
131
|
break;
|
|
122
132
|
}
|
|
123
133
|
case "ArrowUp": {
|
|
124
|
-
let t =
|
|
134
|
+
let t = f - 1;
|
|
125
135
|
for (; t >= 0 && n[t]?.props.disabled; )
|
|
126
136
|
t--;
|
|
127
137
|
if (t === -1) {
|
|
@@ -129,105 +139,105 @@ function je({
|
|
|
129
139
|
t--;
|
|
130
140
|
t === -1 && (t = -1);
|
|
131
141
|
}
|
|
132
|
-
|
|
142
|
+
k(t), e.preventDefault();
|
|
133
143
|
break;
|
|
134
144
|
}
|
|
135
145
|
}
|
|
136
146
|
H && H(e);
|
|
137
147
|
}
|
|
138
|
-
function C(e,
|
|
139
|
-
const t =
|
|
140
|
-
const
|
|
141
|
-
return
|
|
148
|
+
function C(e, o) {
|
|
149
|
+
const t = x.filter((s) => {
|
|
150
|
+
const w = s.props, u = String(w.label).toLocaleLowerCase(), p = w.keywords?.map((d) => d.toLocaleLowerCase()) || [], y = String(w.value).toLocaleLowerCase(), i = e.toLocaleLowerCase();
|
|
151
|
+
return w.obfuscate ?? !1 ? u.includes(i) || p.some((d) => d.includes(i)) : u.includes(i) || p.some((d) => d.includes(i)) || y.includes(i);
|
|
142
152
|
});
|
|
143
|
-
return
|
|
144
|
-
/* @__PURE__ */
|
|
145
|
-
),
|
|
153
|
+
return $ && e.trim().length > 0 && !t.some((s) => s.props.value === e) && t.unshift(
|
|
154
|
+
/* @__PURE__ */ r(U, { value: e, label: e, keywords: [e], children: e }, "value")
|
|
155
|
+
), G(t.length), t.slice(0, o);
|
|
146
156
|
}
|
|
147
|
-
function
|
|
148
|
-
const e =
|
|
157
|
+
function ne() {
|
|
158
|
+
const e = c.current;
|
|
149
159
|
e?.focus();
|
|
150
160
|
}
|
|
151
|
-
function
|
|
152
|
-
const e =
|
|
153
|
-
e != null &&
|
|
161
|
+
function oe() {
|
|
162
|
+
const e = c.current;
|
|
163
|
+
e != null && b && b(e.value, e.selectionStart, e.selectionEnd);
|
|
154
164
|
}
|
|
155
165
|
function ie(e) {
|
|
156
|
-
const
|
|
157
|
-
_(I),
|
|
158
|
-
const t = C(
|
|
166
|
+
const o = e.currentTarget;
|
|
167
|
+
_(I), X(e.target.value);
|
|
168
|
+
const t = C(o.value, I);
|
|
159
169
|
B(t), D && D(e.target.value);
|
|
160
170
|
}
|
|
161
|
-
function
|
|
162
|
-
const e =
|
|
171
|
+
function re() {
|
|
172
|
+
const e = Z + xe;
|
|
163
173
|
_(e);
|
|
164
|
-
const
|
|
165
|
-
B(
|
|
174
|
+
const o = C(m, e);
|
|
175
|
+
B(o);
|
|
166
176
|
}
|
|
167
177
|
return S(() => {
|
|
168
|
-
const e =
|
|
178
|
+
const e = c.current;
|
|
169
179
|
e != null && e.value.length > 0 ? e.select() : e?.focus();
|
|
170
180
|
}, []), S(() => {
|
|
171
|
-
if (
|
|
172
|
-
const e =
|
|
173
|
-
|
|
181
|
+
if (l != null) {
|
|
182
|
+
const e = l.getBoundingClientRect();
|
|
183
|
+
Q(`${e.width}px`), ee(`${e.height}px`), c.current != null && l instanceof HTMLInputElement && (c.current.value = l.value, c.current.selectionStart = l.selectionStart, c.current.selectionEnd = l.selectionEnd);
|
|
174
184
|
}
|
|
175
|
-
}, [
|
|
176
|
-
if (
|
|
185
|
+
}, [l]), S(() => {
|
|
186
|
+
if (g != null) {
|
|
177
187
|
const e = n.findIndex(
|
|
178
|
-
(
|
|
188
|
+
(o) => o.props.value === g
|
|
179
189
|
);
|
|
180
|
-
|
|
190
|
+
q(e);
|
|
181
191
|
}
|
|
182
|
-
}, [n,
|
|
183
|
-
|
|
184
|
-
}, [
|
|
192
|
+
}, [n, g]), S(() => {
|
|
193
|
+
k(m === "" ? L : -1);
|
|
194
|
+
}, [m, L]), /* @__PURE__ */ r(
|
|
185
195
|
me,
|
|
186
196
|
{
|
|
187
197
|
open: !0,
|
|
188
|
-
anchorElement:
|
|
189
|
-
onClose:
|
|
198
|
+
anchorElement: l,
|
|
199
|
+
onClose: oe,
|
|
190
200
|
verticalAnchor: "top",
|
|
191
201
|
verticalOrigin: "top",
|
|
192
202
|
verticalOffset: -4,
|
|
193
|
-
children: /* @__PURE__ */
|
|
194
|
-
|
|
203
|
+
children: /* @__PURE__ */ K(
|
|
204
|
+
O,
|
|
195
205
|
{
|
|
196
|
-
minHeight: `calc(${
|
|
206
|
+
minHeight: `calc(${Y}, 8px)`,
|
|
197
207
|
maxHeight: "300px",
|
|
198
|
-
minWidth:
|
|
208
|
+
minWidth: J,
|
|
199
209
|
width: "auto",
|
|
200
210
|
hAlign: "start",
|
|
201
|
-
className:
|
|
211
|
+
className: N(R["suggestion-list"], "suggestion-list"),
|
|
202
212
|
children: [
|
|
203
|
-
/* @__PURE__ */
|
|
213
|
+
/* @__PURE__ */ r(
|
|
204
214
|
"input",
|
|
205
215
|
{
|
|
206
|
-
ref:
|
|
207
|
-
value:
|
|
208
|
-
onKeyUp:
|
|
209
|
-
onKeyDown:
|
|
216
|
+
ref: c,
|
|
217
|
+
value: m,
|
|
218
|
+
onKeyUp: te,
|
|
219
|
+
onKeyDown: se,
|
|
210
220
|
onChange: ie,
|
|
211
|
-
className:
|
|
212
|
-
|
|
221
|
+
className: N(R.input, "suggestion-list-search-input"),
|
|
222
|
+
...j
|
|
213
223
|
},
|
|
214
224
|
-1
|
|
215
225
|
),
|
|
216
|
-
/* @__PURE__ */
|
|
217
|
-
n.map((e,
|
|
226
|
+
/* @__PURE__ */ K(O, { children: [
|
|
227
|
+
n.map((e, o) => /* @__PURE__ */ r(
|
|
218
228
|
ge,
|
|
219
229
|
{
|
|
220
230
|
option: e,
|
|
221
|
-
isSelected:
|
|
222
|
-
isFocused:
|
|
223
|
-
onClick:
|
|
231
|
+
isSelected: o === L && m !== "",
|
|
232
|
+
isFocused: o === f,
|
|
233
|
+
onClick: h
|
|
224
234
|
},
|
|
225
|
-
|
|
235
|
+
o
|
|
226
236
|
)),
|
|
227
|
-
|
|
237
|
+
z > n.length && /* @__PURE__ */ r(ce, { children: /* @__PURE__ */ r(he, { marginBlock: "8px", hierarchy: "tertiary", onClick: re, children: "Show More" }) })
|
|
228
238
|
] }),
|
|
229
|
-
n.length === 0 && /* @__PURE__ */
|
|
230
|
-
/* @__PURE__ */
|
|
239
|
+
n.length === 0 && /* @__PURE__ */ r(ue, { padding: "8px", className: R["no-results"], children: /* @__PURE__ */ r(ae, { children: P }) }),
|
|
240
|
+
/* @__PURE__ */ r(fe, { onRedirect: ne }, n.length + 1)
|
|
231
241
|
]
|
|
232
242
|
}
|
|
233
243
|
)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"suggestion_list.js","sources":["../../../src/inputs/suggestions/suggestion_list.tsx"],"sourcesContent":["import { BodyText } from '../../typography/index.js';\nimport { VStack } from '../../stacks/v_stack.js';\nimport { ZStack } from '../../stacks/z_stack.js';\nimport { clsx } from 'clsx';\nimport React, { useLayoutEffect, Children, isValidElement } from 'react';\nimport { useRef, useState } from 'react';\nimport { FocusRedirect } from '../../utils/index.js';\nimport { SuggestionItem } from './suggestion_item.js';\nimport { OptionProps, Option } from '../options/option.js';\nimport styles from './suggestion_list.module.css';\n\nimport { Button } from '../../actions/index.js';\nimport { Popper } from '../../overlay/popper/popper.js';\n\nconst MAX_RESULTS = 50;\nconst BATCH_SIZE = 50;\n\nexport interface SuggestionListProps\n extends Omit<React.HTMLAttributes<HTMLInputElement>, 'onChange'> {\n value?: string;\n scrollToValue?: string;\n anchorElement: HTMLElement | null;\n children?: React.ReactNode;\n onChange?: (value: string) => void;\n onOptionSelect?: (\n value: string,\n label: string | undefined,\n isSuggestion: boolean\n ) => void;\n noSuggestionMessage?: React.ReactNode;\n trimCustomInput?: boolean;\n haveValueAsOption?: boolean;\n onClose?: (\n inputValue: string,\n cursorStartPosition: number | null,\n cursorEndPosition: number | null\n ) => void;\n}\n\nexport function SuggestionList({\n value = '',\n scrollToValue,\n anchorElement,\n children,\n onOptionSelect,\n noSuggestionMessage = '-- No Matches --',\n onClose,\n onChange,\n onKeyUp,\n onKeyDown,\n trimCustomInput = false,\n haveValueAsOption = false,\n ...props\n}: SuggestionListProps) {\n // Extract valid Option components from children\n const suggestions = Children.toArray(children).filter(\n (child): child is React.ReactElement<OptionProps> =>\n isValidElement(child) && child.type === Option\n );\n\n const [selectedIndex, setSelectedIndex] = useState(() => {\n if (scrollToValue != null) {\n const index = suggestions.findIndex(option => option.props.value === scrollToValue);\n if (index !== -1) {\n return index;\n }\n }\n return -1;\n });\n\n const keyPressedDownRef = useRef('');\n const [maxResults, setMaxResults] = useState(MAX_RESULTS);\n const [focusedIndex, setFocusedIndex] = useState(selectedIndex);\n const [internalValue, setInternalValue] = useState(value);\n const internalInputRef = useRef<HTMLInputElement | null>(null);\n const [totalMatchedLength, setTotalMatchedLength] = useState(suggestions.length);\n const [matchedOptions, setMatchedOptions] = useState<React.ReactElement<OptionProps>[]>(\n () => getMatchedOptions(value, MAX_RESULTS)\n );\n const [suggestionsWidth, setSuggestionsWidth] = useState<string | undefined>();\n const [suggestionsHeight, setSuggestionsHeight] = useState<string | undefined>();\n\n function handleKeyUp(event: React.KeyboardEvent<HTMLInputElement>) {\n const key = event.key;\n const input = event.currentTarget;\n\n const isSameKey = (keyPressedDownRef.current = key);\n keyPressedDownRef.current = '';\n\n // Enter and Escape remove the popover, so we want to handle this on keyup.\n // This prevents from another element from getting the key events.\n if (isSameKey) {\n switch (key) {\n case 'Enter': {\n if (matchedOptions[focusedIndex] == null) {\n const value = trimCustomInput ? input.value.trim() : input.value;\n\n if (value === '') {\n return;\n }\n\n const lowercaseValue = value.toLocaleLowerCase();\n const option = suggestions.find(\n option =>\n option.props.value.toLocaleLowerCase() === lowercaseValue ||\n (option.props.label != null &&\n option.props.label.toLocaleLowerCase() === lowercaseValue)\n );\n\n const isSuggestion = option != null;\n const label = option?.props.label || value;\n const optionValue = option?.props.value || value;\n\n requestAnimationFrame(() => {\n onOptionSelect && onOptionSelect(optionValue, label, isSuggestion);\n });\n\n break;\n }\n const selectedOption = matchedOptions[focusedIndex];\n const optionProps = selectedOption.props;\n\n // Don't select disabled options\n if (optionProps.disabled) {\n break;\n }\n\n requestAnimationFrame(() => {\n onOptionSelect && onOptionSelect(optionProps.value, optionProps.label, true);\n });\n break;\n }\n case 'Escape': {\n onClose && onClose(input.value, input.selectionStart, input.selectionEnd);\n break;\n }\n }\n }\n\n onKeyUp && onKeyUp(event);\n }\n\n function handleKeyDown(event: React.KeyboardEvent<HTMLInputElement>) {\n const key = event.key;\n keyPressedDownRef.current = key;\n\n // We handle these key events on keydown to be responsive navigation.\n switch (key) {\n case 'ArrowDown': {\n let newIndex = focusedIndex + 1;\n\n // Skip disabled options\n while (\n newIndex < matchedOptions.length &&\n matchedOptions[newIndex]?.props.disabled\n ) {\n newIndex++;\n }\n\n if (newIndex === matchedOptions.length) {\n // Wrap around to first non-disabled option\n newIndex = 0;\n while (\n newIndex < matchedOptions.length &&\n matchedOptions[newIndex]?.props.disabled\n ) {\n newIndex++;\n }\n // If all options are disabled, stay at -1\n if (newIndex === matchedOptions.length) {\n newIndex = -1;\n }\n }\n\n setFocusedIndex(newIndex);\n event.preventDefault();\n break;\n }\n case 'Tab': {\n let step = 1;\n if (event.shiftKey) {\n step = -1;\n }\n let newIndex = focusedIndex + step;\n // Skip disabled options\n if (step > 0) {\n while (\n newIndex < matchedOptions.length &&\n matchedOptions[newIndex]?.props.disabled\n ) {\n newIndex++;\n }\n } else {\n while (newIndex >= 0 && matchedOptions[newIndex]?.props.disabled) {\n newIndex--;\n }\n }\n\n if (newIndex === matchedOptions.length) {\n // Wrap around to first non-disabled option\n newIndex = 0;\n while (\n newIndex < matchedOptions.length &&\n matchedOptions[newIndex]?.props.disabled\n ) {\n newIndex++;\n }\n // If all options are disabled, stay at -1\n if (newIndex === matchedOptions.length) {\n newIndex = -1;\n }\n } else if (newIndex <= -1) {\n // Wrap around to last non-disabled option\n newIndex = matchedOptions.length - 1;\n while (newIndex >= 0 && matchedOptions[newIndex]?.props.disabled) {\n newIndex--;\n }\n // If all options are disabled, stay at -1\n if (newIndex === -1) {\n newIndex = -1;\n }\n }\n\n setFocusedIndex(newIndex);\n event.preventDefault();\n break;\n }\n case 'ArrowUp': {\n let newIndex = focusedIndex - 1;\n\n // Skip disabled options\n while (newIndex >= 0 && matchedOptions[newIndex]?.props.disabled) {\n newIndex--;\n }\n\n if (newIndex === -1) {\n // Wrap around to last non-disabled option\n newIndex = matchedOptions.length - 1;\n while (newIndex >= 0 && matchedOptions[newIndex]?.props.disabled) {\n newIndex--;\n }\n // If all options are disabled, stay at -1\n if (newIndex === -1) {\n newIndex = -1;\n }\n }\n\n setFocusedIndex(newIndex);\n event.preventDefault();\n break;\n }\n }\n onKeyDown && onKeyDown(event);\n }\n\n function getMatchedOptions(value: string, maxResults: number) {\n const results = suggestions.filter(option => {\n const props = option.props;\n const label = String(props.label).toLocaleLowerCase();\n const keywords = props.keywords?.map(k => k.toLocaleLowerCase()) || [];\n const optionValue = String(props.value).toLocaleLowerCase();\n const searchValue = value.toLocaleLowerCase();\n\n return (\n label.includes(searchValue) ||\n keywords.some(k => k.includes(searchValue)) ||\n optionValue.includes(searchValue)\n );\n });\n\n if (\n haveValueAsOption &&\n value.trim().length > 0 &&\n !results.some(r => r.props.value === value)\n ) {\n results.unshift(\n <Option key=\"value\" value={value} label={value} keywords={[value]}>\n {value}\n </Option>\n );\n }\n\n setTotalMatchedLength(results.length);\n return results.slice(0, maxResults);\n }\n\n function focusInput() {\n const input = internalInputRef.current;\n if (input != null) {\n input.focus();\n }\n }\n\n function handleUseClose() {\n const input = internalInputRef.current;\n if (input != null) {\n onClose && onClose(input.value, input.selectionStart, input.selectionEnd);\n }\n }\n\n function handleChange(event: React.ChangeEvent<HTMLInputElement>) {\n const input = event.currentTarget;\n\n setMaxResults(MAX_RESULTS);\n setInternalValue(event.target.value);\n\n const newMatches = getMatchedOptions(input.value, MAX_RESULTS);\n setMatchedOptions(newMatches);\n\n onChange && onChange(event.target.value);\n }\n\n function handleShowMore() {\n const newMaxResults = maxResults + BATCH_SIZE;\n setMaxResults(newMaxResults);\n const newMatches = getMatchedOptions(internalValue, newMaxResults);\n setMatchedOptions(newMatches);\n }\n\n useLayoutEffect(() => {\n const input = internalInputRef.current;\n\n if (input != null && input.value.length > 0) {\n input.select();\n } else if (input != null) {\n input.focus();\n }\n }, []);\n\n useLayoutEffect(() => {\n if (anchorElement != null) {\n const rect = anchorElement.getBoundingClientRect();\n setSuggestionsWidth(`${rect.width}px`);\n setSuggestionsHeight(`${rect.height}px`);\n\n if (internalInputRef.current != null && anchorElement instanceof HTMLInputElement) {\n internalInputRef.current.value = anchorElement.value;\n internalInputRef.current.selectionStart = anchorElement.selectionStart;\n internalInputRef.current.selectionEnd = anchorElement.selectionEnd;\n }\n }\n }, [anchorElement]);\n\n useLayoutEffect(() => {\n if (scrollToValue != null) {\n const index = matchedOptions.findIndex(\n option => option.props.value === scrollToValue\n );\n setSelectedIndex(index);\n }\n }, [matchedOptions, scrollToValue]);\n\n useLayoutEffect(() => {\n setFocusedIndex(internalValue === '' ? selectedIndex : -1);\n }, [internalValue, selectedIndex]);\n\n return (\n <Popper\n open\n anchorElement={anchorElement}\n onClose={handleUseClose}\n verticalAnchor=\"top\"\n verticalOrigin=\"top\"\n verticalOffset={-4}\n >\n <VStack\n minHeight={`calc(${suggestionsHeight}, 8px)`}\n maxHeight=\"300px\"\n minWidth={suggestionsWidth}\n width=\"auto\"\n hAlign=\"start\"\n className={clsx(styles['suggestion-list'], 'suggestion-list')}\n >\n <input\n ref={internalInputRef}\n key={-1}\n value={internalValue}\n onKeyUp={handleKeyUp}\n onKeyDown={handleKeyDown}\n onChange={handleChange}\n className={clsx(styles.input, 'suggestion-list-search-input')}\n {...props}\n />\n <VStack>\n {matchedOptions.map((option, index) => (\n <SuggestionItem\n key={index}\n option={option}\n isSelected={index === selectedIndex && internalValue !== ''}\n isFocused={index === focusedIndex}\n onClick={onOptionSelect}\n />\n ))}\n {totalMatchedLength > matchedOptions.length && (\n <>\n <Button marginBlock=\"8px\" hierarchy=\"tertiary\" onClick={handleShowMore}>\n Show More\n </Button>\n </>\n )}\n </VStack>\n {matchedOptions.length === 0 && (\n <ZStack padding=\"8px\" className={styles['no-results']}>\n <BodyText>{noSuggestionMessage}</BodyText>\n </ZStack>\n )}\n <FocusRedirect key={matchedOptions.length + 1} onRedirect={focusInput} />\n </VStack>\n </Popper>\n );\n}\n"],"names":["MAX_RESULTS","BATCH_SIZE","SuggestionList","value","scrollToValue","anchorElement","children","onOptionSelect","noSuggestionMessage","onClose","onChange","onKeyUp","onKeyDown","trimCustomInput","haveValueAsOption","props","suggestions","Children","child","isValidElement","Option","selectedIndex","setSelectedIndex","useState","index","option","keyPressedDownRef","useRef","maxResults","setMaxResults","focusedIndex","setFocusedIndex","internalValue","setInternalValue","internalInputRef","totalMatchedLength","setTotalMatchedLength","matchedOptions","setMatchedOptions","getMatchedOptions","suggestionsWidth","setSuggestionsWidth","suggestionsHeight","setSuggestionsHeight","handleKeyUp","event","key","input","isSameKey","lowercaseValue","isSuggestion","label","optionValue","optionProps","handleKeyDown","newIndex","step","results","keywords","k","searchValue","r","jsx","focusInput","handleUseClose","handleChange","newMatches","handleShowMore","newMaxResults","useLayoutEffect","rect","Popper","jsxs","VStack","clsx","styles","SuggestionItem","Fragment","Button","ZStack","BodyText","FocusRedirect"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;wGAcMA,IAAc,IACdC,KAAa;AAwBZ,SAASC,GAAe;AAAA,EAC7B,OAAAC,IAAQ;AAAA,EACR,eAAAC;AAAA,EACA,eAAAC;AAAA,EACA,UAAAC;AAAA,EACA,gB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AiB;AAAA,UACpC,WAAU;AAAA,UACV,UAAUF;AAAA,UACV,OAAM;AAAA,UACN,QAAO;AAAA,UACP,WAAWkC,EAAKC,EAAO,iBAAiB,GAAG,iBAAiB;AAAA,UAE5D,UAAA;AAAA,YAAA,gBAAAb;AAAA,cAAC;AAAA,cAAA;AAAA,gBACC,KAAK5B;AAAA,gBAEL,OAAOF;AAAA,gBACP,SAASY;AAAA,gBACT,WAAWU;AAAA,gBACX,UAAUW;AAAA,gBACV,WAAWS,EAAKC,EAAO,OAAO,8BAA8B;AAAA,gBAC3D,GAAG5D;AAAA,cAAA;AAAA,cANC;AAAA,YAAA;AAAA,8BAQN0D,GAAA,EACE,UAAA;AAAA,cAAApC,EAAe,IAAI,CAACZ,GAAQD,MAC3B,gBAAAsC;AAAA,gBAACc;AAAA,gBAAA;AAAA,kBAEC,QAAAnD;AAAA,kBACA,YAAYD,MAAUH,KAAiBW,MAAkB;AAAA,kBACzD,WAAWR,MAAUM;AAAA,kBACrB,SAASvB;AAAA,gBAAA;AAAA,gBAJJiB;AAAA,cAAA,CAMR;AAAA,cACAW,IAAqBE,EAAe,UACnC,gBAAAyB,EAAAe,IAAA,EACE,UAAA,gBAAAf,EAACgB,IAAA,EAAO,aAAY,OAAM,WAAU,YAAW,SAASX,IAAgB,uBAExE,EAAA,CACF;AAAA,YAAA,GAEJ;AAAA,YACC9B,EAAe,WAAW,KACzB,gBAAAyB,EAACiB,MAAO,SAAQ,OAAM,WAAWJ,EAAO,YAAY,GAClD,UAAA,gBAAAb,EAACkB,IAAA,EAAU,aAAoB,GACjC;AAAA,8BAEDC,IAAA,EAA8C,YAAYlB,GAAA,GAAvC1B,EAAe,SAAS,CAA2B;AAAA,UAAA;AAAA,QAAA;AAAA,MAAA;AAAA,IACzE;AAAA,EAAA;AAGN;"}
|
|
1
|
+
{"version":3,"file":"suggestion_list.js","sources":["../../../src/inputs/suggestions/suggestion_list.tsx"],"sourcesContent":["import { BodyText } from '../../typography/index.js';\nimport { VStack } from '../../stacks/v_stack.js';\nimport { ZStack } from '../../stacks/z_stack.js';\nimport { clsx } from 'clsx';\nimport React, { useLayoutEffect, Children, isValidElement } from 'react';\nimport { useRef, useState } from 'react';\nimport { FocusRedirect } from '../../utils/index.js';\nimport { SuggestionItem } from './suggestion_item.js';\nimport { OptionProps, Option } from '../options/option.js';\nimport styles from './suggestion_list.module.css';\n\nimport { Button } from '../../actions/index.js';\nimport { Popper } from '../../overlay/popper/popper.js';\n\nconst MAX_RESULTS = 50;\nconst BATCH_SIZE = 50;\n\nexport interface SuggestionListProps\n extends Omit<React.HTMLAttributes<HTMLInputElement>, 'onChange'> {\n value?: string;\n scrollToValue?: string;\n anchorElement: HTMLElement | null;\n children?: React.ReactNode;\n onChange?: (value: string) => void;\n onOptionSelect?: (\n value: string,\n label: string | undefined,\n isSuggestion: boolean,\n obfuscate: boolean\n ) => void;\n noSuggestionMessage?: React.ReactNode;\n trimCustomInput?: boolean;\n haveValueAsOption?: boolean;\n onClose?: (\n inputValue: string,\n cursorStartPosition: number | null,\n cursorEndPosition: number | null\n ) => void;\n}\n\nexport function SuggestionList({\n value = '',\n scrollToValue,\n anchorElement,\n children,\n onOptionSelect,\n noSuggestionMessage = '-- No Matches --',\n onClose,\n onChange,\n onKeyUp,\n onKeyDown,\n trimCustomInput = false,\n haveValueAsOption = false,\n ...props\n}: SuggestionListProps) {\n // Extract valid Option components from children\n const suggestions = Children.toArray(children).filter(\n (child): child is React.ReactElement<OptionProps> =>\n isValidElement(child) && child.type === Option\n );\n\n const [selectedIndex, setSelectedIndex] = useState(() => {\n if (scrollToValue != null) {\n const index = suggestions.findIndex(option => option.props.value === scrollToValue);\n if (index !== -1) {\n return index;\n }\n }\n return -1;\n });\n\n const keyPressedDownRef = useRef('');\n const [maxResults, setMaxResults] = useState(MAX_RESULTS);\n const [focusedIndex, setFocusedIndex] = useState(selectedIndex);\n const [internalValue, setInternalValue] = useState(value);\n const internalInputRef = useRef<HTMLInputElement | null>(null);\n const [totalMatchedLength, setTotalMatchedLength] = useState(suggestions.length);\n const [matchedOptions, setMatchedOptions] = useState<React.ReactElement<OptionProps>[]>(\n () => getMatchedOptions(value, MAX_RESULTS)\n );\n const [suggestionsWidth, setSuggestionsWidth] = useState<string | undefined>();\n const [suggestionsHeight, setSuggestionsHeight] = useState<string | undefined>();\n\n function handleKeyUp(event: React.KeyboardEvent<HTMLInputElement>) {\n const key = event.key;\n const input = event.currentTarget;\n\n const isSameKey = (keyPressedDownRef.current = key);\n keyPressedDownRef.current = '';\n\n // Enter and Escape remove the popover, so we want to handle this on keyup.\n // This prevents from another element from getting the key events.\n if (isSameKey) {\n switch (key) {\n case 'Enter': {\n if (matchedOptions[focusedIndex] == null) {\n const value = trimCustomInput ? input.value.trim() : input.value;\n\n if (value === '') {\n return;\n }\n\n const lowercaseValue = value.toLocaleLowerCase();\n const option = suggestions.find(\n option =>\n option.props.value.toLocaleLowerCase() === lowercaseValue ||\n (option.props.label != null &&\n option.props.label.toLocaleLowerCase() === lowercaseValue)\n );\n\n const isSuggestion = option != null;\n const label = option?.props.label || value;\n const optionValue = option?.props.value || value;\n\n requestAnimationFrame(() => {\n onOptionSelect &&\n onOptionSelect(\n optionValue,\n label,\n isSuggestion,\n option?.props.obfuscate ?? false\n );\n });\n\n break;\n }\n const selectedOption = matchedOptions[focusedIndex];\n const optionProps = selectedOption.props;\n\n // Don't select disabled options\n if (optionProps.disabled) {\n break;\n }\n\n requestAnimationFrame(() => {\n onOptionSelect &&\n onOptionSelect(\n optionProps.value,\n optionProps.label,\n true,\n optionProps.obfuscate ?? false\n );\n });\n break;\n }\n case 'Escape': {\n onClose && onClose(input.value, input.selectionStart, input.selectionEnd);\n break;\n }\n }\n }\n\n onKeyUp && onKeyUp(event);\n }\n\n function handleKeyDown(event: React.KeyboardEvent<HTMLInputElement>) {\n const key = event.key;\n keyPressedDownRef.current = key;\n\n // We handle these key events on keydown to be responsive navigation.\n switch (key) {\n case 'ArrowDown': {\n let newIndex = focusedIndex + 1;\n\n // Skip disabled options\n while (\n newIndex < matchedOptions.length &&\n matchedOptions[newIndex]?.props.disabled\n ) {\n newIndex++;\n }\n\n if (newIndex === matchedOptions.length) {\n // Wrap around to first non-disabled option\n newIndex = 0;\n while (\n newIndex < matchedOptions.length &&\n matchedOptions[newIndex]?.props.disabled\n ) {\n newIndex++;\n }\n // If all options are disabled, stay at -1\n if (newIndex === matchedOptions.length) {\n newIndex = -1;\n }\n }\n\n setFocusedIndex(newIndex);\n event.preventDefault();\n break;\n }\n case 'Tab': {\n let step = 1;\n if (event.shiftKey) {\n step = -1;\n }\n let newIndex = focusedIndex + step;\n // Skip disabled options\n if (step > 0) {\n while (\n newIndex < matchedOptions.length &&\n matchedOptions[newIndex]?.props.disabled\n ) {\n newIndex++;\n }\n } else {\n while (newIndex >= 0 && matchedOptions[newIndex]?.props.disabled) {\n newIndex--;\n }\n }\n\n if (newIndex === matchedOptions.length) {\n // Wrap around to first non-disabled option\n newIndex = 0;\n while (\n newIndex < matchedOptions.length &&\n matchedOptions[newIndex]?.props.disabled\n ) {\n newIndex++;\n }\n // If all options are disabled, stay at -1\n if (newIndex === matchedOptions.length) {\n newIndex = -1;\n }\n } else if (newIndex <= -1) {\n // Wrap around to last non-disabled option\n newIndex = matchedOptions.length - 1;\n while (newIndex >= 0 && matchedOptions[newIndex]?.props.disabled) {\n newIndex--;\n }\n // If all options are disabled, stay at -1\n if (newIndex === -1) {\n newIndex = -1;\n }\n }\n\n setFocusedIndex(newIndex);\n event.preventDefault();\n break;\n }\n case 'ArrowUp': {\n let newIndex = focusedIndex - 1;\n\n // Skip disabled options\n while (newIndex >= 0 && matchedOptions[newIndex]?.props.disabled) {\n newIndex--;\n }\n\n if (newIndex === -1) {\n // Wrap around to last non-disabled option\n newIndex = matchedOptions.length - 1;\n while (newIndex >= 0 && matchedOptions[newIndex]?.props.disabled) {\n newIndex--;\n }\n // If all options are disabled, stay at -1\n if (newIndex === -1) {\n newIndex = -1;\n }\n }\n\n setFocusedIndex(newIndex);\n event.preventDefault();\n break;\n }\n }\n onKeyDown && onKeyDown(event);\n }\n\n function getMatchedOptions(value: string, maxResults: number) {\n const results = suggestions.filter(option => {\n const props = option.props;\n const label = String(props.label).toLocaleLowerCase();\n const keywords = props.keywords?.map(k => k.toLocaleLowerCase()) || [];\n const optionValue = String(props.value).toLocaleLowerCase();\n const searchValue = value.toLocaleLowerCase();\n const obfuscate = props.obfuscate ?? false;\n\n // Obfuscated options can only be searched by label or keywords, not by value\n if (obfuscate) {\n return label.includes(searchValue) || keywords.some(k => k.includes(searchValue));\n }\n\n return (\n label.includes(searchValue) ||\n keywords.some(k => k.includes(searchValue)) ||\n optionValue.includes(searchValue)\n );\n });\n\n if (\n haveValueAsOption &&\n value.trim().length > 0 &&\n !results.some(r => r.props.value === value)\n ) {\n results.unshift(\n <Option key=\"value\" value={value} label={value} keywords={[value]}>\n {value}\n </Option>\n );\n }\n\n setTotalMatchedLength(results.length);\n return results.slice(0, maxResults);\n }\n\n function focusInput() {\n const input = internalInputRef.current;\n if (input != null) {\n input.focus();\n }\n }\n\n function handleUseClose() {\n const input = internalInputRef.current;\n if (input != null) {\n onClose && onClose(input.value, input.selectionStart, input.selectionEnd);\n }\n }\n\n function handleChange(event: React.ChangeEvent<HTMLInputElement>) {\n const input = event.currentTarget;\n\n setMaxResults(MAX_RESULTS);\n setInternalValue(event.target.value);\n\n const newMatches = getMatchedOptions(input.value, MAX_RESULTS);\n setMatchedOptions(newMatches);\n\n onChange && onChange(event.target.value);\n }\n\n function handleShowMore() {\n const newMaxResults = maxResults + BATCH_SIZE;\n setMaxResults(newMaxResults);\n const newMatches = getMatchedOptions(internalValue, newMaxResults);\n setMatchedOptions(newMatches);\n }\n\n useLayoutEffect(() => {\n const input = internalInputRef.current;\n\n if (input != null && input.value.length > 0) {\n input.select();\n } else if (input != null) {\n input.focus();\n }\n }, []);\n\n useLayoutEffect(() => {\n if (anchorElement != null) {\n const rect = anchorElement.getBoundingClientRect();\n setSuggestionsWidth(`${rect.width}px`);\n setSuggestionsHeight(`${rect.height}px`);\n\n if (internalInputRef.current != null && anchorElement instanceof HTMLInputElement) {\n internalInputRef.current.value = anchorElement.value;\n internalInputRef.current.selectionStart = anchorElement.selectionStart;\n internalInputRef.current.selectionEnd = anchorElement.selectionEnd;\n }\n }\n }, [anchorElement]);\n\n useLayoutEffect(() => {\n if (scrollToValue != null) {\n const index = matchedOptions.findIndex(\n option => option.props.value === scrollToValue\n );\n setSelectedIndex(index);\n }\n }, [matchedOptions, scrollToValue]);\n\n useLayoutEffect(() => {\n setFocusedIndex(internalValue === '' ? selectedIndex : -1);\n }, [internalValue, selectedIndex]);\n\n return (\n <Popper\n open\n anchorElement={anchorElement}\n onClose={handleUseClose}\n verticalAnchor=\"top\"\n verticalOrigin=\"top\"\n verticalOffset={-4}\n >\n <VStack\n minHeight={`calc(${suggestionsHeight}, 8px)`}\n maxHeight=\"300px\"\n minWidth={suggestionsWidth}\n width=\"auto\"\n hAlign=\"start\"\n className={clsx(styles['suggestion-list'], 'suggestion-list')}\n >\n <input\n ref={internalInputRef}\n key={-1}\n value={internalValue}\n onKeyUp={handleKeyUp}\n onKeyDown={handleKeyDown}\n onChange={handleChange}\n className={clsx(styles.input, 'suggestion-list-search-input')}\n {...props}\n />\n <VStack>\n {matchedOptions.map((option, index) => (\n <SuggestionItem\n key={index}\n option={option}\n isSelected={index === selectedIndex && internalValue !== ''}\n isFocused={index === focusedIndex}\n onClick={onOptionSelect}\n />\n ))}\n {totalMatchedLength > matchedOptions.length && (\n <>\n <Button marginBlock=\"8px\" hierarchy=\"tertiary\" onClick={handleShowMore}>\n Show More\n </Button>\n </>\n )}\n </VStack>\n {matchedOptions.length === 0 && (\n <ZStack padding=\"8px\" className={styles['no-results']}>\n <BodyText>{noSuggestionMessage}</BodyText>\n </ZStack>\n )}\n <FocusRedirect key={matchedOptions.length + 1} onRedirect={focusInput} />\n </VStack>\n </Popper>\n );\n}\n"],"names":["MAX_RESULTS","BATCH_SIZE","SuggestionList","value","scrollToValue","anchorElement","children","onOptionSelect","noSuggestionMessage","onClose","onChange","onKeyUp","onKeyDown","trimCustomInput","haveValueAsOption","props","suggestions","Children","child","isValidElement","Option","selectedIndex","setSelectedIndex","useState","index","option","keyPressedDownRef","useRef","maxResults","setMaxResults","focusedIndex","setFocusedIndex","internalValue","setInternalValue","internalInputRef","totalMatchedLength","setTotalMatchedLength","matchedOptions","setMatchedOptions","getMatchedOptions","suggestionsWidth","setSuggestionsWidth","suggestionsHeight","setSuggestionsHeight","handleKeyUp","event","key","input","isSameKey","lowercaseValue","isSuggestion","label","optionValue","optionProps","handleKeyDown","newIndex","step","results","keywords","k","searchValue","r","jsx","focusInput","handleUseClose","handleChange","newMatches","handleShowMore","newMaxResults","useLayoutEffect","rect","Popper","jsxs","VStack","clsx","styles","SuggestionItem","Fragment","Button","ZStack","BodyText","FocusRedirect"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;wGAcMA,IAAc,IACdC,KAAa;AAyBZ,SAASC,GAAe;AAAA,EAC7B,OAAAC,IAAQ;AAAA,EACR,eAAAC;AAAA,EACA,eAAAC;AAAA,EACA,UAAAC;AAAA,EACA,gBAAAC;AAAA,EACA,qBAAAC,IAAsB;AAAA,EACtB,SAAAC;AAAA,EACA,UAAAC;AAAA,EACA,SAAAC;AAAA,EACA,WAAAC;AAAA,EACA,iBAAAC,IAAkB;AAAA,EAClB,mBAAAC,IAAoB;AAAA,EACpB,GAAGC;AACL,GAAwB;AAEtB,QAAMC,IAAcC,GAAS,QAAQX,CAAQ,EAAE;AAAA,IAC7C,CAACY,MACCC,GAAeD,CAAK,KAAKA,EAAM,SAASE;AAAA,EAAA,GAGtC,CAACC,GAAeC,CAAgB,IAAIC,EAAS,MAAM;AACvD,QAAInB,KAAiB,MAAM;AACzB,YAAMoB,IAAQR,EAAY,UAAU,OAAUS,EAAO,MAAM,UAAUrB,CAAa;AAClF,UAAIoB,MAAU;AACZ,eAAOA;AAAA,IAEX;AACA,WAAO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gBACV,WAAWS,EAAKC,EAAO,OAAO,8BAA8B;AAAA,gBAC3D,GAAG5D;AAAA,cAAA;AAAA,cANC;AAAA,YAAA;AAAA,8BAQN0D,GAAA,EACE,UAAA;AAAA,cAAApC,EAAe,IAAI,CAACZ,GAAQD,MAC3B,gBAAAsC;AAAA,gBAACc;AAAA,gBAAA;AAAA,kBAEC,QAAAnD;AAAA,kBACA,YAAYD,MAAUH,KAAiBW,MAAkB;AAAA,kBACzD,WAAWR,MAAUM;AAAA,kBACrB,SAASvB;AAAA,gBAAA;AAAA,gBAJJiB;AAAA,cAAA,CAMR;AAAA,cACAW,IAAqBE,EAAe,UACnC,gBAAAyB,EAAAe,IAAA,EACE,UAAA,gBAAAf,EAACgB,IAAA,EAAO,aAAY,OAAM,WAAU,YAAW,SAASX,IAAgB,uBAExE,EAAA,CACF;AAAA,YAAA,GAEJ;AAAA,YACC9B,EAAe,WAAW,KACzB,gBAAAyB,EAACiB,MAAO,SAAQ,OAAM,WAAWJ,EAAO,YAAY,GAClD,UAAA,gBAAAb,EAACkB,IAAA,EAAU,aAAoB,GACjC;AAAA,8BAEDC,IAAA,EAA8C,YAAYlB,GAAA,GAAvC1B,EAAe,SAAS,CAA2B;AAAA,UAAA;AAAA,QAAA;AAAA,MAAA;AAAA,IACzE;AAAA,EAAA;AAGN;"}
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { jsx as
|
|
1
|
+
import { jsx as f } from "react/jsx-runtime";
|
|
2
2
|
import s from "react";
|
|
3
3
|
import { clsx as m } from "clsx";
|
|
4
4
|
import { HStack as n } from "../../stacks/h_stack.js";
|
|
5
|
-
import '../../footer.css';const i = "_footer_4a43c3e", d = { footer: i }, u = s.forwardRef(function({ hierarchy: o = "secondary", size: r = "md", children: t, className: e, ...a },
|
|
6
|
-
return /* @__PURE__ */
|
|
5
|
+
import '../../footer.css';const i = "_footer_4a43c3e", d = { footer: i }, u = s.forwardRef(function({ hierarchy: o = "secondary", size: r = "md", children: t, className: e, ...a }, c) {
|
|
6
|
+
return /* @__PURE__ */ f(
|
|
7
7
|
n,
|
|
8
8
|
{
|
|
9
|
-
ref:
|
|
9
|
+
ref: c,
|
|
10
10
|
as: "footer",
|
|
11
|
-
className: m(d.footer, e, "
|
|
11
|
+
className: m(d.footer, e, "tcn-footer"),
|
|
12
12
|
"data-hierarchy": o,
|
|
13
13
|
"data-size": r,
|
|
14
14
|
...a,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"footer.js","sources":["../../../src/layouts/footer/footer.tsx"],"sourcesContent":["import React from 'react';\nimport { clsx } from 'clsx';\nimport { HStack, type HStackProps } from '../../stacks/h_stack.js';\nimport type { Hierarchy, Size } from '../../utils/index.js';\nimport styles from './footer.module.css';\n\nexport interface FooterProps extends Omit<HStackProps, 'as' | 'children'> {\n hierarchy?: Hierarchy;\n size?: Size;\n children?: React.ReactNode;\n}\n\nexport const Footer = React.forwardRef<HTMLElement, FooterProps>(function Footer(\n { hierarchy = 'secondary', size = 'md', children, className, ...props }: FooterProps,\n ref\n) {\n return (\n <HStack\n ref={ref}\n as=\"footer\"\n className={clsx(styles.footer, className, '
|
|
1
|
+
{"version":3,"file":"footer.js","sources":["../../../src/layouts/footer/footer.tsx"],"sourcesContent":["import React from 'react';\nimport { clsx } from 'clsx';\nimport { HStack, type HStackProps } from '../../stacks/h_stack.js';\nimport type { Hierarchy, Size } from '../../utils/index.js';\nimport styles from './footer.module.css';\n\nexport interface FooterProps extends Omit<HStackProps, 'as' | 'children'> {\n hierarchy?: Hierarchy;\n size?: Size;\n children?: React.ReactNode;\n}\n\nexport const Footer = React.forwardRef<HTMLElement, FooterProps>(function Footer(\n { hierarchy = 'secondary', size = 'md', children, className, ...props }: FooterProps,\n ref\n) {\n return (\n <HStack\n ref={ref}\n as=\"footer\"\n className={clsx(styles.footer, className, 'tcn-footer')}\n data-hierarchy={hierarchy}\n data-size={size}\n {...props}\n >\n {children}\n </HStack>\n );\n});\n"],"names":["Footer","React","hierarchy","size","children","className","props","ref","jsx","HStack","clsx","styles"],"mappings":";;;;gDAYaA,IAASC,EAAM,WAAqC,SAC/D,EAAE,WAAAC,IAAY,aAAa,MAAAC,IAAO,MAAM,UAAAC,GAAU,WAAAC,GAAW,GAAGC,EAAA,GAChEC,GACA;AACA,SACE,gBAAAC;AAAA,IAACC;AAAA,IAAA;AAAA,MACC,KAAAF;AAAA,MACA,IAAG;AAAA,MACH,WAAWG,EAAKC,EAAO,QAAQN,GAAW,YAAY;AAAA,MACtD,kBAAgBH;AAAA,MAChB,aAAWC;AAAA,MACV,GAAGG;AAAA,MAEH,UAAAF;AAAA,IAAA;AAAA,EAAA;AAGP,CAAC;"}
|
package/dist/layouts/index.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
export * from './body/h_body.js';
|
|
2
|
+
export * from './body/v_body.js';
|
|
1
3
|
export * from './column/column.js';
|
|
2
4
|
export * from './divider/divider.js';
|
|
3
5
|
export * from './footer/footer.js';
|
|
@@ -8,6 +10,5 @@ export * from './list/list.js';
|
|
|
8
10
|
export * from './list/section_header.js';
|
|
9
11
|
export * from './sidebar_end/sidebar_end.js';
|
|
10
12
|
export * from './sidebar_start/sidebar_start.js';
|
|
11
|
-
export * from './
|
|
12
|
-
export * from './body/v_body.js';
|
|
13
|
+
export * from './utility_bar/utility_bar.js';
|
|
13
14
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/layouts/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC;AACnC,cAAc,sBAAsB,CAAC;AACrC,cAAc,oBAAoB,CAAC;AACnC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,oBAAoB,CAAC;AACnC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,0BAA0B,CAAC;AACzC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,kCAAkC,CAAC;AACjD,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/layouts/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC;AACjC,cAAc,kBAAkB,CAAC;AACjC,cAAc,oBAAoB,CAAC;AACnC,cAAc,sBAAsB,CAAC;AACrC,cAAc,oBAAoB,CAAC;AACnC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,oBAAoB,CAAC;AACnC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,0BAA0B,CAAC;AACzC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,kCAAkC,CAAC;AACjD,cAAc,8BAA8B,CAAC"}
|
package/dist/layouts/index.js
CHANGED
|
@@ -1,27 +1,29 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
1
|
+
import { HBody as e } from "./body/h_body.js";
|
|
2
|
+
import { VBody as m } from "./body/v_body.js";
|
|
3
|
+
import { Column as p } from "./column/column.js";
|
|
4
|
+
import { Divider as d } from "./divider/divider.js";
|
|
5
|
+
import { Footer as a } from "./footer/footer.js";
|
|
6
|
+
import { Grid as n } from "./grid/grid.js";
|
|
7
|
+
import { Header as B } from "./header/header.js";
|
|
8
|
+
import { Item as b } from "./list/item.js";
|
|
9
|
+
import { List as c } from "./list/list.js";
|
|
10
|
+
import { SectionHeader as u } from "./list/section_header.js";
|
|
11
|
+
import { SidebarEnd as C } from "./sidebar_end/sidebar_end.js";
|
|
12
|
+
import { SidebarStart as E } from "./sidebar_start/sidebar_start.js";
|
|
13
|
+
import { UtilityBar as G } from "./utility_bar/utility_bar.js";
|
|
13
14
|
export {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
15
|
+
p as Column,
|
|
16
|
+
d as Divider,
|
|
17
|
+
a as Footer,
|
|
18
|
+
n as Grid,
|
|
19
|
+
e as HBody,
|
|
20
|
+
B as Header,
|
|
21
|
+
b as Item,
|
|
22
|
+
c as List,
|
|
23
|
+
u as SectionHeader,
|
|
24
|
+
C as SidebarEnd,
|
|
25
|
+
E as SidebarStart,
|
|
26
|
+
G as UtilityBar,
|
|
27
|
+
m as VBody
|
|
26
28
|
};
|
|
27
29
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;"}
|
|
@@ -2,6 +2,7 @@ import { default as React } from 'react';
|
|
|
2
2
|
import { HStackProps } from '../../stacks/h_stack.js';
|
|
3
3
|
export interface ItemProps extends Omit<HStackProps, 'as' | 'children'> {
|
|
4
4
|
children?: React.ReactNode;
|
|
5
|
+
selected?: boolean;
|
|
5
6
|
}
|
|
6
7
|
export declare const Item: React.ForwardRefExoticComponent<ItemProps & React.RefAttributes<HTMLDivElement>>;
|
|
7
8
|
//# sourceMappingURL=item.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"item.d.ts","sourceRoot":"","sources":["../../../src/layouts/list/item.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAU,KAAK,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAGnE,MAAM,WAAW,SAAU,SAAQ,IAAI,CAAC,WAAW,EAAE,IAAI,GAAG,UAAU,CAAC;IACrE,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"item.d.ts","sourceRoot":"","sources":["../../../src/layouts/list/item.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAU,KAAK,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAGnE,MAAM,WAAW,SAAU,SAAQ,IAAI,CAAC,WAAW,EAAE,IAAI,GAAG,UAAU,CAAC;IACrE,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC3B,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED,eAAO,MAAM,IAAI,kFAgBf,CAAC"}
|
|
@@ -1,9 +1,20 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import
|
|
3
|
-
import { HStack as
|
|
4
|
-
import { clsx as
|
|
5
|
-
const x =
|
|
6
|
-
return /* @__PURE__ */
|
|
1
|
+
import { jsx as m } from "react/jsx-runtime";
|
|
2
|
+
import o from "react";
|
|
3
|
+
import { HStack as c } from "../../stacks/h_stack.js";
|
|
4
|
+
import { clsx as f } from "clsx";
|
|
5
|
+
const x = o.forwardRef(function({ children: r, className: a, selected: t = !1, ...e }, i) {
|
|
6
|
+
return /* @__PURE__ */ m(
|
|
7
|
+
c,
|
|
8
|
+
{
|
|
9
|
+
ref: i,
|
|
10
|
+
as: "li",
|
|
11
|
+
"data-hierarchy": t ? "primary" : "tertiary",
|
|
12
|
+
"data-is-selected": t,
|
|
13
|
+
className: f("tcn-item", "tcn-interactive", a),
|
|
14
|
+
...e,
|
|
15
|
+
children: r
|
|
16
|
+
}
|
|
17
|
+
);
|
|
7
18
|
});
|
|
8
19
|
export {
|
|
9
20
|
x as Item
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"item.js","sources":["../../../src/layouts/list/item.tsx"],"sourcesContent":["import React from 'react';\nimport { HStack, type HStackProps } from '../../stacks/h_stack.js';\nimport { clsx } from 'clsx';\n\nexport interface ItemProps extends Omit<HStackProps, 'as' | 'children'> {\n children?: React.ReactNode;\n}\n\nexport const Item = React.forwardRef<HTMLDivElement, ItemProps>(function Item(\n { children, className, ...props }: ItemProps,\n ref\n) {\n return (\n <HStack
|
|
1
|
+
{"version":3,"file":"item.js","sources":["../../../src/layouts/list/item.tsx"],"sourcesContent":["import React from 'react';\nimport { HStack, type HStackProps } from '../../stacks/h_stack.js';\nimport { clsx } from 'clsx';\n\nexport interface ItemProps extends Omit<HStackProps, 'as' | 'children'> {\n children?: React.ReactNode;\n selected?: boolean;\n}\n\nexport const Item = React.forwardRef<HTMLDivElement, ItemProps>(function Item(\n { children, className, selected = false, ...props }: ItemProps,\n ref\n) {\n return (\n <HStack\n ref={ref}\n as=\"li\"\n data-hierarchy={selected ? 'primary' : 'tertiary'}\n data-is-selected={selected}\n className={clsx('tcn-item', 'tcn-interactive', className)}\n {...props}\n >\n {children}\n </HStack>\n );\n});\n"],"names":["Item","React","children","className","selected","props","ref","jsx","HStack","clsx"],"mappings":";;;;AASO,MAAMA,IAAOC,EAAM,WAAsC,SAC9D,EAAE,UAAAC,GAAU,WAAAC,GAAW,UAAAC,IAAW,IAAO,GAAGC,EAAA,GAC5CC,GACA;AACA,SACE,gBAAAC;AAAA,IAACC;AAAA,IAAA;AAAA,MACC,KAAAF;AAAA,MACA,IAAG;AAAA,MACH,kBAAgBF,IAAW,YAAY;AAAA,MACvC,oBAAkBA;AAAA,MAClB,WAAWK,EAAK,YAAY,mBAAmBN,CAAS;AAAA,MACvD,GAAGE;AAAA,MAEH,UAAAH;AAAA,IAAA;AAAA,EAAA;AAGP,CAAC;"}
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import { jsx as f } from "react/jsx-runtime";
|
|
2
|
-
import
|
|
3
|
-
import { clsx as
|
|
4
|
-
import { VStack as
|
|
5
|
-
const x =
|
|
2
|
+
import i from "react";
|
|
3
|
+
import { clsx as a } from "clsx";
|
|
4
|
+
import { VStack as c } from "../../stacks/v_stack.js";
|
|
5
|
+
const x = i.forwardRef(function({ children: t, className: o, isOrdered: r = !1, ...s }, m) {
|
|
6
6
|
return /* @__PURE__ */ f(
|
|
7
|
-
|
|
7
|
+
c,
|
|
8
8
|
{
|
|
9
|
-
ref:
|
|
10
|
-
as:
|
|
11
|
-
className:
|
|
12
|
-
...
|
|
13
|
-
children:
|
|
9
|
+
ref: m,
|
|
10
|
+
as: r ? "ol" : "ul",
|
|
11
|
+
className: a("tcn-list", o),
|
|
12
|
+
...s,
|
|
13
|
+
children: t
|
|
14
14
|
}
|
|
15
15
|
);
|
|
16
16
|
});
|