@studiolxd/brand 41.0.0 → 42.0.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.
- package/CHANGELOG.md +119 -0
- package/dist/_shared/tokens.js +3 -0
- package/dist/_types/atoms/AsyncMultiSelect/AsyncMultiSelect.d.ts +28 -5
- package/dist/_types/atoms/AsyncSelect/AsyncSelect.d.ts +26 -6
- package/dist/_types/atoms/Button/Button.d.ts +17 -4
- package/dist/_types/atoms/InputPhone/InputPhone.d.ts +15 -4
- package/dist/_types/atoms/MultiSelect/MultiSelect.d.ts +20 -1
- package/dist/_types/atoms/NumberInput/NumberInput.d.ts +14 -4
- package/dist/_types/atoms/OtpInput/OtpInput.d.ts +15 -4
- package/dist/_types/atoms/Select/Select.d.ts +18 -1
- package/dist/_types/messages/BrandMessages.d.ts +25 -1
- package/dist/_types/messages/index.d.ts +1 -1
- package/dist/_types/molecules/Card/Card.d.ts +13 -4
- package/dist/_types/molecules/DocsSearch/DocsSearch.d.ts +31 -12
- package/dist/_types/molecules/FilterBar/FilterBar.d.ts +10 -1
- package/dist/_types/molecules/InputField/InputField.d.ts +16 -2
- package/dist/_types/molecules/MultiSelectField/MultiSelectField.d.ts +9 -1
- package/dist/_types/molecules/PasswordField/PasswordField.d.ts +22 -2
- package/dist/_types/molecules/SearchForm/SearchForm.d.ts +18 -6
- package/dist/_types/molecules/SelectField/SelectField.d.ts +5 -0
- package/dist/_types/organisms/AnnotationThread/AnnotationThread.d.ts +10 -1
- package/dist/annotation-thread.css +1 -1
- package/dist/async-multi-select.js +50 -49
- package/dist/async-select.js +89 -88
- package/dist/brand.css +4 -1
- package/dist/card.css +1 -1
- package/dist/docs-search.js +38 -37
- package/dist/filter-bar.css +1 -1
- package/dist/filter-bar.js +19 -17
- package/dist/input-field.js +66 -65
- package/dist/input-phone.js +39 -38
- package/dist/multi-select.js +109 -108
- package/dist/number-input.js +61 -60
- package/dist/otp-input.js +86 -85
- package/dist/password-field.js +46 -45
- package/dist/search-form.js +35 -34
- package/dist/select.js +75 -71
- package/dist/tokens.css +4 -1
- package/package.json +1 -1
- package/src/tokens/molecules/annotation-thread.css +1 -0
- package/src/tokens/molecules/filter-bar.css +2 -0
- package/src/tokens/scss/molecules/_annotation-thread.scss +1 -0
- package/src/tokens/scss/molecules/_filter-bar.scss +2 -0
- package/src/tokens/tokens.json +3 -0
package/dist/async-select.js
CHANGED
|
@@ -1,154 +1,155 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import './async-select.css';
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
3
|
+
import { n as e } from "./_shared/brandmessagescontext.js";
|
|
4
|
+
import { Icon as t } from "./icon.js";
|
|
5
|
+
import { Spinner as n } from "./spinner.js";
|
|
6
|
+
import { forwardRef as r, useCallback as i, useEffect as a, useId as o, useRef as s, useState as c } from "react";
|
|
7
|
+
import { jsx as l, jsxs as u } from "react/jsx-runtime";
|
|
8
|
+
import { Popover as d } from "@base-ui/react/popover";
|
|
8
9
|
//#region src/stories/atoms/AsyncSelect/AsyncSelect.tsx
|
|
9
10
|
function ee(e, t) {
|
|
10
11
|
typeof e == "function" ? e(t) : e && (e.current = t);
|
|
11
12
|
}
|
|
12
|
-
var
|
|
13
|
-
let
|
|
14
|
-
let t = ++
|
|
15
|
-
|
|
13
|
+
var f = r(function({ onSearch: r, value: f, onValueChange: p, selectedOption: m, placeholder: h, disabled: g, readOnly: _, size: v = "md", debounceMs: y = 300, id: b, name: x, error: S = !1, required: te, onBlur: ne, className: C, "aria-label": w, "aria-describedby": T, emptyMessage: re, loadingLabel: ie, clearLabel: ae, container: E }, D) {
|
|
14
|
+
let O = e("asyncSelect"), [k, A] = c(!1), [j, M] = c(""), [N, P] = c(!1), [F, I] = c([]), [oe, L] = c(!1), [R, z] = c(-1), [B, V] = c(null), [H, U] = c(null), W = s(null), G = s(0), K = s(null), q = s(null), J = o(), se = o(), Y = f === void 0 ? B : f, ce = m === void 0 ? H : m, X = (e) => `${se}-opt-${e}`, Z = i(async (e) => {
|
|
15
|
+
let t = ++G.current;
|
|
16
|
+
P(!0), L(!1);
|
|
16
17
|
try {
|
|
17
|
-
let
|
|
18
|
-
if (t !==
|
|
19
|
-
|
|
18
|
+
let n = await r(e);
|
|
19
|
+
if (t !== G.current) return;
|
|
20
|
+
I(n), z(-1);
|
|
20
21
|
} catch {
|
|
21
|
-
if (t !==
|
|
22
|
-
|
|
22
|
+
if (t !== G.current) return;
|
|
23
|
+
I([]), z(-1);
|
|
23
24
|
} finally {
|
|
24
|
-
t ===
|
|
25
|
+
t === G.current && (P(!1), L(!0));
|
|
25
26
|
}
|
|
26
|
-
}, [
|
|
27
|
-
|
|
28
|
-
|
|
27
|
+
}, [r]);
|
|
28
|
+
a(() => () => {
|
|
29
|
+
G.current += 1, W.current && clearTimeout(W.current);
|
|
29
30
|
}, []);
|
|
30
|
-
function
|
|
31
|
+
function le(e) {
|
|
31
32
|
let t = e.target.value;
|
|
32
|
-
|
|
33
|
+
M(t), W.current && clearTimeout(W.current), W.current = setTimeout(() => void Z(t), y);
|
|
33
34
|
}
|
|
34
|
-
function
|
|
35
|
-
|
|
35
|
+
function ue(e) {
|
|
36
|
+
g || _ || k || (e.preventDefault(), K.current?.focus(), z(-1), M(""), I([]), L(!1), A(!0), Z(""));
|
|
36
37
|
}
|
|
37
38
|
function Q(e) {
|
|
38
|
-
|
|
39
|
+
f === void 0 && (V(e.value), U(e)), p?.(e.value, e), A(!1), z(-1), M("");
|
|
39
40
|
}
|
|
40
41
|
function $() {
|
|
41
|
-
|
|
42
|
+
f === void 0 && (V(null), U(null)), p?.(null, null), M(""), I([]), L(!1), K.current?.focus();
|
|
42
43
|
}
|
|
43
|
-
function
|
|
44
|
+
function de(e) {
|
|
44
45
|
e.stopPropagation(), $();
|
|
45
46
|
}
|
|
46
|
-
function
|
|
47
|
-
e.key === "ArrowDown" ? (e.preventDefault(),
|
|
47
|
+
function fe(e) {
|
|
48
|
+
e.key === "ArrowDown" ? (e.preventDefault(), k ? z((e) => Math.min(e + 1, F.length - 1)) : (A(!0), Z(j))) : e.key === "ArrowUp" ? (e.preventDefault(), z((e) => Math.max(e - 1, -1))) : e.key === "Enter" && R >= 0 && F[R] ? (e.preventDefault(), Q(F[R])) : e.key === "Escape" ? (A(!1), M(""), z(-1)) : e.key === "Tab" ? (A(!1), z(-1)) : (e.key === "Backspace" || e.key === "Delete") && j === "" && Y && !g && !_ ? (e.preventDefault(), $()) : !k && e.key.length === 1 && !e.ctrlKey && !e.metaKey && !e.altKey && (e.preventDefault(), M(e.key), A(!0), I([]), L(!1), W.current && clearTimeout(W.current), W.current = setTimeout(() => void Z(e.key), y));
|
|
48
49
|
}
|
|
49
|
-
function
|
|
50
|
+
function pe(e, t) {
|
|
50
51
|
if (!e) {
|
|
51
52
|
if (t.reason === "outside-press") {
|
|
52
53
|
let e = t.event?.target;
|
|
53
|
-
if (e instanceof Node &&
|
|
54
|
+
if (e instanceof Node && q.current?.contains(e)) return;
|
|
54
55
|
}
|
|
55
|
-
|
|
56
|
+
A(!1), M(""), z(-1);
|
|
56
57
|
}
|
|
57
58
|
}
|
|
58
|
-
let
|
|
59
|
+
let me = k ? j : ce?.label ?? "", he = [
|
|
59
60
|
"async-select",
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
].filter(Boolean).join(" "),
|
|
65
|
-
return /* @__PURE__ */
|
|
66
|
-
open:
|
|
67
|
-
onOpenChange:
|
|
68
|
-
children: [/* @__PURE__ */
|
|
69
|
-
ref:
|
|
70
|
-
className:
|
|
71
|
-
"data-popup-open":
|
|
61
|
+
v === "md" ? "" : `async-select--${v}`,
|
|
62
|
+
g ? "async-select--disabled" : "",
|
|
63
|
+
S ? "async-select--error" : "",
|
|
64
|
+
C ?? ""
|
|
65
|
+
].filter(Boolean).join(" "), ge = ["async-select__content", v === "md" ? "" : `async-select__content--${v}`].filter(Boolean).join(" ");
|
|
66
|
+
return /* @__PURE__ */ u(d.Root, {
|
|
67
|
+
open: k,
|
|
68
|
+
onOpenChange: pe,
|
|
69
|
+
children: [/* @__PURE__ */ u("div", {
|
|
70
|
+
ref: q,
|
|
71
|
+
className: he,
|
|
72
|
+
"data-popup-open": k || void 0,
|
|
72
73
|
children: [
|
|
73
|
-
/* @__PURE__ */
|
|
74
|
+
/* @__PURE__ */ l("input", {
|
|
74
75
|
ref: (e) => {
|
|
75
|
-
|
|
76
|
+
K.current = e, ee(D, e);
|
|
76
77
|
},
|
|
77
|
-
id:
|
|
78
|
+
id: b,
|
|
78
79
|
type: "text",
|
|
79
80
|
className: "async-select__input",
|
|
80
|
-
value:
|
|
81
|
-
onChange:
|
|
82
|
-
onPointerDown:
|
|
83
|
-
onKeyDown:
|
|
84
|
-
placeholder:
|
|
85
|
-
disabled:
|
|
86
|
-
readOnly:
|
|
87
|
-
"aria-label":
|
|
88
|
-
"aria-describedby":
|
|
89
|
-
"aria-invalid":
|
|
90
|
-
"aria-required":
|
|
91
|
-
"aria-expanded":
|
|
81
|
+
value: me,
|
|
82
|
+
onChange: le,
|
|
83
|
+
onPointerDown: ue,
|
|
84
|
+
onKeyDown: fe,
|
|
85
|
+
placeholder: O("placeholder", h),
|
|
86
|
+
disabled: g,
|
|
87
|
+
readOnly: _,
|
|
88
|
+
"aria-label": w,
|
|
89
|
+
"aria-describedby": T,
|
|
90
|
+
"aria-invalid": S || void 0,
|
|
91
|
+
"aria-required": te || void 0,
|
|
92
|
+
"aria-expanded": k,
|
|
92
93
|
"aria-haspopup": "listbox",
|
|
93
|
-
"aria-controls":
|
|
94
|
-
"aria-activedescendant":
|
|
94
|
+
"aria-controls": k ? J : void 0,
|
|
95
|
+
"aria-activedescendant": R >= 0 ? X(R) : void 0,
|
|
95
96
|
autoComplete: "off",
|
|
96
97
|
role: "combobox",
|
|
97
98
|
"aria-autocomplete": "list",
|
|
98
|
-
onBlur:
|
|
99
|
+
onBlur: ne
|
|
99
100
|
}),
|
|
100
|
-
|
|
101
|
+
x && /* @__PURE__ */ l("input", {
|
|
101
102
|
type: "hidden",
|
|
102
|
-
name:
|
|
103
|
-
value:
|
|
103
|
+
name: x,
|
|
104
|
+
value: Y ?? ""
|
|
104
105
|
}),
|
|
105
|
-
|
|
106
|
+
N && /* @__PURE__ */ l(n, {
|
|
106
107
|
size: "sm",
|
|
107
108
|
"aria-hidden": !0
|
|
108
109
|
}),
|
|
109
|
-
!
|
|
110
|
+
!N && Y && !g && !_ && /* @__PURE__ */ l("button", {
|
|
110
111
|
type: "button",
|
|
111
112
|
className: "async-select__clear",
|
|
112
|
-
"aria-label":
|
|
113
|
+
"aria-label": O("clear", ae),
|
|
113
114
|
tabIndex: -1,
|
|
114
|
-
onMouseDown:
|
|
115
|
-
children: /* @__PURE__ */
|
|
115
|
+
onMouseDown: de,
|
|
116
|
+
children: /* @__PURE__ */ l(t, {
|
|
116
117
|
name: "close",
|
|
117
118
|
size: "xs"
|
|
118
119
|
})
|
|
119
120
|
})
|
|
120
121
|
]
|
|
121
|
-
}), /* @__PURE__ */
|
|
122
|
-
container:
|
|
123
|
-
children: /* @__PURE__ */
|
|
122
|
+
}), /* @__PURE__ */ l(d.Portal, {
|
|
123
|
+
container: E,
|
|
124
|
+
children: /* @__PURE__ */ l(d.Positioner, {
|
|
124
125
|
className: "async-select__positioner",
|
|
125
|
-
anchor:
|
|
126
|
+
anchor: q,
|
|
126
127
|
align: "start",
|
|
127
128
|
sideOffset: -1,
|
|
128
|
-
children: /* @__PURE__ */
|
|
129
|
-
className:
|
|
129
|
+
children: /* @__PURE__ */ l(d.Popup, {
|
|
130
|
+
className: ge,
|
|
130
131
|
initialFocus: !1,
|
|
131
132
|
finalFocus: !1,
|
|
132
|
-
children: /* @__PURE__ */
|
|
133
|
+
children: /* @__PURE__ */ u("div", {
|
|
133
134
|
role: "listbox",
|
|
134
|
-
"aria-label":
|
|
135
|
-
id:
|
|
135
|
+
"aria-label": w ?? O("placeholder", h),
|
|
136
|
+
id: J,
|
|
136
137
|
children: [
|
|
137
|
-
|
|
138
|
+
N && /* @__PURE__ */ l("div", {
|
|
138
139
|
className: "async-select__loading",
|
|
139
|
-
children: /* @__PURE__ */
|
|
140
|
+
children: /* @__PURE__ */ l(n, {
|
|
140
141
|
size: "sm",
|
|
141
|
-
label:
|
|
142
|
+
label: O("loading", ie)
|
|
142
143
|
})
|
|
143
144
|
}),
|
|
144
|
-
!
|
|
145
|
+
!N && oe && F.length === 0 && /* @__PURE__ */ l("div", {
|
|
145
146
|
className: "async-select__empty",
|
|
146
|
-
children:
|
|
147
|
+
children: O("empty", re)
|
|
147
148
|
}),
|
|
148
|
-
!
|
|
149
|
-
let n = e.value ===
|
|
150
|
-
return /* @__PURE__ */
|
|
151
|
-
id:
|
|
149
|
+
!N && F.map((e, t) => {
|
|
150
|
+
let n = e.value === Y, r = R === t;
|
|
151
|
+
return /* @__PURE__ */ l("div", {
|
|
152
|
+
id: X(t),
|
|
152
153
|
role: "option",
|
|
153
154
|
"aria-selected": n,
|
|
154
155
|
className: [
|
|
@@ -169,4 +170,4 @@ var d = n(function({ onSearch: n, value: d, onValueChange: f, selectedOption: p,
|
|
|
169
170
|
});
|
|
170
171
|
});
|
|
171
172
|
//#endregion
|
|
172
|
-
export {
|
|
173
|
+
export { f as AsyncSelect };
|