@studiolxd/brand 49.18.0 → 49.20.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (44) hide show
  1. package/CHANGELOG.md +206 -0
  2. package/dist/_shared/tokens.js +59 -0
  3. package/dist/_types/atoms/Autocomplete/Autocomplete.d.ts +83 -0
  4. package/dist/_types/atoms/List/List.d.ts +20 -0
  5. package/dist/_types/atoms/NumberInput/NumberInput.d.ts +33 -2
  6. package/dist/_types/atoms/Text/Text.d.ts +12 -2
  7. package/dist/_types/molecules/AutocompleteField/AutocompleteField.d.ts +57 -0
  8. package/dist/_types/molecules/NumberInputField/NumberInputField.d.ts +14 -2
  9. package/dist/autocomplete-field.css +1 -0
  10. package/dist/autocomplete-field.js +58 -0
  11. package/dist/autocomplete.css +1 -0
  12. package/dist/autocomplete.js +145 -0
  13. package/dist/brand.css +122 -1
  14. package/dist/list.css +1 -1
  15. package/dist/list.js +39 -13
  16. package/dist/number-input-field.js +22 -19
  17. package/dist/number-input.css +1 -1
  18. package/dist/number-input.js +54 -44
  19. package/dist/text.css +1 -1
  20. package/dist/text.js +6 -5
  21. package/dist/toaster.js +23 -20
  22. package/dist/tokens.css +126 -1
  23. package/package.json +16 -2
  24. package/src/tokens/components/autocomplete.css +40 -0
  25. package/src/tokens/components/autocomplete.ts +7 -0
  26. package/src/tokens/components/number-input.css +5 -0
  27. package/src/tokens/components/number-input.ts +2 -2
  28. package/src/tokens/components/text-inline.css +3 -0
  29. package/src/tokens/components/text.css +9 -0
  30. package/src/tokens/index.css +2 -0
  31. package/src/tokens/molecules/autocomplete-field.css +17 -0
  32. package/src/tokens/molecules/autocomplete-field.ts +8 -0
  33. package/src/tokens/scss/_index.legacy.scss +2 -0
  34. package/src/tokens/scss/_index.scss +2 -0
  35. package/src/tokens/scss/components/_autocomplete.scss +37 -0
  36. package/src/tokens/scss/components/_number-input.scss +5 -0
  37. package/src/tokens/scss/components/_text-inline.scss +2 -0
  38. package/src/tokens/scss/components/_text.scss +7 -0
  39. package/src/tokens/scss/molecules/_autocomplete-field.scss +14 -0
  40. package/src/tokens/surface-dark-derived.css +12 -0
  41. package/src/tokens/surface-invert.css +15 -0
  42. package/src/tokens/surface-light.css +15 -0
  43. package/src/tokens/surface-public.css +7 -0
  44. package/src/tokens/tokens.json +59 -0
@@ -0,0 +1,58 @@
1
+ 'use client';
2
+ import './autocomplete-field.css';
3
+ import { Autocomplete as e } from "./autocomplete.js";
4
+ import { n as t } from "./_shared/form-size.js";
5
+ import { ErrorText as n } from "./error-text.js";
6
+ import { Label as r } from "./label.js";
7
+ import { n as i } from "./_shared/field-labels.js";
8
+ import { forwardRef as a, useId as o } from "react";
9
+ import { jsx as s, jsxs as c } from "react/jsx-runtime";
10
+ //#region src/stories/molecules/AutocompleteField/AutocompleteField.tsx
11
+ var l = a(function({ id: a, label: l, labelHidden: u, value: d, defaultValue: f, onValueChange: p, onSelect: m, options: h, onSearch: g, debounceMs: _, minChars: v, placeholder: y, name: b, disabled: x, readOnly: S, size: C, required: w, maxLength: T, error: E = !1, errorMessage: D, helperText: O, className: k, container: A, onBlur: j }, M) {
12
+ let N = i(u), P = t(C), F = o(), I = a ?? F, L = D ? `${I}-error` : void 0, R = O ? `${I}-helper` : void 0, z = [L, R].filter(Boolean).join(" ") || void 0, B = E || !!D;
13
+ return /* @__PURE__ */ c("div", {
14
+ className: ["autocomplete-field", k].filter(Boolean).join(" "),
15
+ children: [
16
+ /* @__PURE__ */ s(r, {
17
+ htmlFor: I,
18
+ hidden: N,
19
+ size: P,
20
+ children: l
21
+ }),
22
+ /* @__PURE__ */ s(e, {
23
+ ref: M,
24
+ id: I,
25
+ name: b,
26
+ value: d,
27
+ defaultValue: f,
28
+ onValueChange: p,
29
+ onSelect: m,
30
+ options: h,
31
+ onSearch: g,
32
+ debounceMs: _,
33
+ minChars: v,
34
+ placeholder: y,
35
+ disabled: x,
36
+ readOnly: S,
37
+ size: P,
38
+ required: w,
39
+ maxLength: T,
40
+ error: B,
41
+ container: A,
42
+ "aria-describedby": z,
43
+ onBlur: j
44
+ }),
45
+ D && /* @__PURE__ */ s(n, {
46
+ id: L,
47
+ children: D
48
+ }),
49
+ O && /* @__PURE__ */ s("span", {
50
+ id: R,
51
+ className: "autocomplete-field__helper",
52
+ children: O
53
+ })
54
+ ]
55
+ });
56
+ });
57
+ //#endregion
58
+ export { l as AutocompleteField };
@@ -0,0 +1 @@
1
+ .autocomplete{align-items:center;gap:var(--autocomplete-content-gap);block-size:var(--autocomplete-height);padding-block:0;padding-inline:var(--autocomplete-padding-inline);font-family:var(--autocomplete-font-family);font-size:var(--autocomplete-font-size);line-height:var(--autocomplete-line-height);font-weight:var(--autocomplete-font-weight);color:var(--autocomplete-color);background-color:var(--autocomplete-bg);border-width:var(--autocomplete-border-width);border-style:var(--autocomplete-border-style);border-color:var(--autocomplete-border-color);border-radius:var(--autocomplete-border-radius);box-sizing:border-box;width:100%;display:inline-flex}.autocomplete:focus-within{outline:var(--autocomplete-focus-ring-width) solid var(--autocomplete-focus-ring-color);outline-offset:calc(-1 * (var(--autocomplete-focus-ring-width) + var(--autocomplete-border-width)))}.autocomplete.autocomplete--disabled{opacity:.5;cursor:var(--autocomplete-disabled-cursor);pointer-events:none}.autocomplete__input{all:unset;cursor:text;min-width:0;font-family:inherit;font-size:inherit;line-height:inherit;font-weight:inherit;color:inherit;flex:1}.autocomplete__input::placeholder{color:var(--autocomplete-placeholder-color)}.autocomplete__input:disabled{cursor:var(--autocomplete-disabled-cursor)}.autocomplete__content{background-color:var(--autocomplete-content-bg);border-width:var(--autocomplete-border-width);border-style:var(--autocomplete-border-style);border-color:var(--autocomplete-content-border-color);min-width:var(--anchor-width);max-height:var(--autocomplete-content-max-height,var(--available-height));overscroll-behavior:contain;overflow-y:auto}.autocomplete__content[data-side=bottom]{border-top:none}.autocomplete__content[data-side=top]{border-bottom:none}.autocomplete__item{all:unset;box-sizing:border-box;width:100%;padding-block:var(--autocomplete-item-padding-block);padding-inline:var(--autocomplete-padding-inline);font-size:var(--autocomplete-font-size);font-family:var(--autocomplete-font-family);color:var(--autocomplete-color);cursor:pointer;align-items:center;display:flex}.autocomplete__item:focus-visible,.autocomplete__item:hover{background-color:var(--autocomplete-item-highlighted-bg);color:var(--autocomplete-item-highlighted-color)}.autocomplete__item.autocomplete__item--selected{font-weight:var(--autocomplete-item-selected-font-weight)}.autocomplete__item.autocomplete__item--active{background-color:var(--autocomplete-item-highlighted-bg);color:var(--autocomplete-item-highlighted-color)}.autocomplete__content .autocomplete__item+.autocomplete__item,.autocomplete__content[data-side=bottom] .autocomplete__item:first-child{border-top:var(--autocomplete-border-width) var(--autocomplete-border-style) var(--autocomplete-content-border-color)}.autocomplete__content[data-side=top] .autocomplete__item:last-child{border-bottom:var(--autocomplete-border-width) var(--autocomplete-border-style) var(--autocomplete-content-border-color)}.autocomplete.autocomplete--sm{font-size:var(--autocomplete-sm-font-size);--autocomplete-height:var(--autocomplete-sm-height);padding-inline:var(--autocomplete-sm-padding-inline)}.autocomplete__content--sm .autocomplete__item{font-size:var(--autocomplete-sm-font-size);padding-block:var(--autocomplete-sm-item-padding-block)}.autocomplete.autocomplete--lg{font-size:var(--autocomplete-lg-font-size);--autocomplete-height:var(--autocomplete-lg-height);padding-inline:var(--autocomplete-lg-padding-inline)}.autocomplete__content--lg .autocomplete__item{font-size:var(--autocomplete-lg-font-size);padding-block:var(--autocomplete-lg-item-padding-block)}.autocomplete__positioner{z-index:var(--autocomplete-content-z-index)}.autocomplete.autocomplete--error{border-color:var(--autocomplete-error-border-color)}
@@ -0,0 +1,145 @@
1
+ 'use client';
2
+ import './autocomplete.css';
3
+ import { Spinner as e } from "./spinner.js";
4
+ import { n as t } from "./_shared/portal-container.js";
5
+ import { forwardRef as n, useCallback as r, useEffect as i, useId as a, useRef as o, useState as s } from "react";
6
+ import { jsx as c, jsxs as l } from "react/jsx-runtime";
7
+ import { Popover as u } from "@base-ui/react/popover";
8
+ //#region src/stories/atoms/Autocomplete/Autocomplete.tsx
9
+ function ee(e, t) {
10
+ typeof e == "function" ? e(t) : e && (e.current = t);
11
+ }
12
+ function d(e) {
13
+ return e.normalize("NFD").replace(/[\u0300-\u036f]/g, "").toLowerCase();
14
+ }
15
+ var f = n(function({ value: n, defaultValue: f = "", onValueChange: p, onSelect: m, options: h, onSearch: g, debounceMs: _ = 200, minChars: v = 1, placeholder: y, disabled: b, readOnly: x, size: S = "md", id: C, name: w, error: T = !1, required: E, maxLength: D, onBlur: O, className: k, "aria-label": A, "aria-describedby": j, container: M }, N) {
16
+ let te = t(M), [ne, re] = s(f), [ie, P] = s(!1), [ae, F] = s(!1), [I, L] = s([]), [R, z] = s(-1), B = o(null), V = o(0), H = o(null), U = o(null), W = a(), G = a(), K = n === void 0 ? ne : n, q = ie && I.length > 0, J = (e) => `${G}-opt-${e}`, Y = r((e) => {
17
+ let t = ++V.current;
18
+ if (g) {
19
+ F(!0), Promise.resolve().then(() => g(e)).then((e) => e, () => []).then((e) => {
20
+ t === V.current && (L(e), z(-1), F(!1));
21
+ });
22
+ return;
23
+ }
24
+ let n = d(e);
25
+ L((h ?? []).filter((e) => d(e.label).includes(n))), z(-1);
26
+ }, [g, h]);
27
+ i(() => () => {
28
+ V.current += 1, B.current && clearTimeout(B.current);
29
+ }, []);
30
+ function X(e) {
31
+ B.current && clearTimeout(B.current), g && _ > 0 ? B.current = setTimeout(() => Y(e), _) : Y(e);
32
+ }
33
+ function Z() {
34
+ B.current && clearTimeout(B.current), V.current += 1, F(!1), P(!1), z(-1);
35
+ }
36
+ function Q(e) {
37
+ n === void 0 && re(e), p?.(e);
38
+ }
39
+ function oe(e) {
40
+ let t = e.target.value;
41
+ if (Q(t), t.length < v) {
42
+ Z();
43
+ return;
44
+ }
45
+ P(!0), X(t);
46
+ }
47
+ function $(e) {
48
+ Q(e.label), m?.(e), Z(), L([]);
49
+ }
50
+ function se(e) {
51
+ b || x || (e.key === "ArrowDown" ? (e.preventDefault(), q ? z((e) => Math.min(e + 1, I.length - 1)) : (P(!0), X(K))) : e.key === "ArrowUp" ? (e.preventDefault(), q && z((e) => Math.max(e - 1, -1))) : e.key === "Enter" ? q && R >= 0 && I[R] ? (e.preventDefault(), $(I[R])) : q && Z() : e.key === "Escape" ? q && (e.preventDefault(), e.stopPropagation(), Z()) : e.key === "Tab" && Z());
52
+ }
53
+ function ce(e, t) {
54
+ if (!e) {
55
+ if (t.reason === "outside-press") {
56
+ let e = t.event?.target;
57
+ if (e instanceof Node && U.current?.contains(e)) return;
58
+ }
59
+ Z();
60
+ }
61
+ }
62
+ let le = [
63
+ "autocomplete",
64
+ S === "md" ? "" : `autocomplete--${S}`,
65
+ b ? "autocomplete--disabled" : "",
66
+ T ? "autocomplete--error" : "",
67
+ k ?? ""
68
+ ].filter(Boolean).join(" "), ue = ["autocomplete__content", S === "md" ? "" : `autocomplete__content--${S}`].filter(Boolean).join(" ");
69
+ return /* @__PURE__ */ l(u.Root, {
70
+ open: q,
71
+ onOpenChange: ce,
72
+ children: [/* @__PURE__ */ l("div", {
73
+ ref: U,
74
+ className: le,
75
+ "data-popup-open": q || void 0,
76
+ children: [/* @__PURE__ */ c("input", {
77
+ ref: (e) => {
78
+ H.current = e, ee(N, e);
79
+ },
80
+ id: C,
81
+ name: w,
82
+ type: "text",
83
+ className: "autocomplete__input",
84
+ value: K,
85
+ onChange: oe,
86
+ onKeyDown: se,
87
+ placeholder: y,
88
+ disabled: b,
89
+ readOnly: x,
90
+ required: E,
91
+ maxLength: D,
92
+ "aria-label": A,
93
+ "aria-describedby": j,
94
+ "aria-invalid": T || void 0,
95
+ "aria-expanded": q,
96
+ "aria-haspopup": "listbox",
97
+ "aria-controls": q ? W : void 0,
98
+ "aria-activedescendant": q && R >= 0 ? J(R) : void 0,
99
+ autoComplete: "off",
100
+ role: "combobox",
101
+ "aria-autocomplete": "list",
102
+ onBlur: O
103
+ }), ae && /* @__PURE__ */ c(e, {
104
+ size: "sm",
105
+ "aria-hidden": !0
106
+ })]
107
+ }), /* @__PURE__ */ c(u.Portal, {
108
+ container: te,
109
+ children: /* @__PURE__ */ c(u.Positioner, {
110
+ className: "autocomplete__positioner",
111
+ anchor: U,
112
+ align: "start",
113
+ sideOffset: -1,
114
+ children: /* @__PURE__ */ c(u.Popup, {
115
+ className: ue,
116
+ initialFocus: !1,
117
+ finalFocus: !1,
118
+ children: /* @__PURE__ */ c("div", {
119
+ role: "listbox",
120
+ "aria-label": A ?? y,
121
+ id: W,
122
+ children: I.map((e, t) => {
123
+ let n = e.label === K, r = R === t;
124
+ return /* @__PURE__ */ c("div", {
125
+ id: J(t),
126
+ role: "option",
127
+ "aria-selected": r,
128
+ className: [
129
+ "autocomplete__item",
130
+ n ? "autocomplete__item--selected" : "",
131
+ r ? "autocomplete__item--active" : ""
132
+ ].filter(Boolean).join(" "),
133
+ onPointerDown: (e) => e.preventDefault(),
134
+ onClick: () => $(e),
135
+ children: e.label
136
+ }, e.value);
137
+ })
138
+ })
139
+ })
140
+ })
141
+ })]
142
+ });
143
+ });
144
+ //#endregion
145
+ export { f as Autocomplete };