welcome-ui
Version:
Customizable design system with react • styled-components • styled-system and ariakit.
1,088 lines (1,078 loc) • 23.7 kB
JavaScript
"use client";
import { j as p } from "./jsx-runtime-Bqq1Hxg9.mjs";
import { D as he } from "./downshift.esm-DT64V-tc.mjs";
import { g as ze } from "./_commonjsHelpers-CXJ7dpIk.mjs";
import Le, { useMemo as Ze, useState as B, useEffect as pe, Fragment as Qe } from "react";
import { ClearButton as Xe } from "./ClearButton.mjs";
import { StyledIcon as qe } from "./Icon.mjs";
import { D as Ge } from "./index-B80lXHoK.mjs";
import { shouldForwardProp as te, forwardRef as Je } from "./System.mjs";
import { c as et } from "./create-event-rXDe5aCQ.mjs";
import { d as tt, F as nt } from "./field-styles-CfVLcVQp.mjs";
import { StyledTag as rt, Tag as ot } from "./Tag.mjs";
import b, { system as Ce, th as E, css as _ } from "@xstyled/styled-components";
import { Box as st } from "./Box.mjs";
import { IconWrapper as it } from "./Field.mjs";
import { o as G } from "./overflow-ellipsis-DGV5Kgt-.mjs";
var F = { exports: {} }, ge;
function lt() {
if (ge) return F.exports;
ge = 1;
var e = {
À: "A",
Á: "A",
Â: "A",
Ã: "A",
Ä: "A",
Å: "A",
Ấ: "A",
Ắ: "A",
Ẳ: "A",
Ẵ: "A",
Ặ: "A",
Æ: "AE",
Ầ: "A",
Ằ: "A",
Ȃ: "A",
Ả: "A",
Ạ: "A",
Ẩ: "A",
Ẫ: "A",
Ậ: "A",
Ç: "C",
Ḉ: "C",
È: "E",
É: "E",
Ê: "E",
Ë: "E",
Ế: "E",
Ḗ: "E",
Ề: "E",
Ḕ: "E",
Ḝ: "E",
Ȇ: "E",
Ẻ: "E",
Ẽ: "E",
Ẹ: "E",
Ể: "E",
Ễ: "E",
Ệ: "E",
Ì: "I",
Í: "I",
Î: "I",
Ï: "I",
Ḯ: "I",
Ȋ: "I",
Ỉ: "I",
Ị: "I",
Ð: "D",
Ñ: "N",
Ò: "O",
Ó: "O",
Ô: "O",
Õ: "O",
Ö: "O",
Ø: "O",
Ố: "O",
Ṍ: "O",
Ṓ: "O",
Ȏ: "O",
Ỏ: "O",
Ọ: "O",
Ổ: "O",
Ỗ: "O",
Ộ: "O",
Ờ: "O",
Ở: "O",
Ỡ: "O",
Ớ: "O",
Ợ: "O",
Ù: "U",
Ú: "U",
Û: "U",
Ü: "U",
Ủ: "U",
Ụ: "U",
Ử: "U",
Ữ: "U",
Ự: "U",
Ý: "Y",
à: "a",
á: "a",
â: "a",
ã: "a",
ä: "a",
å: "a",
ấ: "a",
ắ: "a",
ẳ: "a",
ẵ: "a",
ặ: "a",
æ: "ae",
ầ: "a",
ằ: "a",
ȃ: "a",
ả: "a",
ạ: "a",
ẩ: "a",
ẫ: "a",
ậ: "a",
ç: "c",
ḉ: "c",
è: "e",
é: "e",
ê: "e",
ë: "e",
ế: "e",
ḗ: "e",
ề: "e",
ḕ: "e",
ḝ: "e",
ȇ: "e",
ẻ: "e",
ẽ: "e",
ẹ: "e",
ể: "e",
ễ: "e",
ệ: "e",
ì: "i",
í: "i",
î: "i",
ï: "i",
ḯ: "i",
ȋ: "i",
ỉ: "i",
ị: "i",
ð: "d",
ñ: "n",
ò: "o",
ó: "o",
ô: "o",
õ: "o",
ö: "o",
ø: "o",
ố: "o",
ṍ: "o",
ṓ: "o",
ȏ: "o",
ỏ: "o",
ọ: "o",
ổ: "o",
ỗ: "o",
ộ: "o",
ờ: "o",
ở: "o",
ỡ: "o",
ớ: "o",
ợ: "o",
ù: "u",
ú: "u",
û: "u",
ü: "u",
ủ: "u",
ụ: "u",
ử: "u",
ữ: "u",
ự: "u",
ý: "y",
ÿ: "y",
Ā: "A",
ā: "a",
Ă: "A",
ă: "a",
Ą: "A",
ą: "a",
Ć: "C",
ć: "c",
Ĉ: "C",
ĉ: "c",
Ċ: "C",
ċ: "c",
Č: "C",
č: "c",
C̆: "C",
c̆: "c",
Ď: "D",
ď: "d",
Đ: "D",
đ: "d",
Ē: "E",
ē: "e",
Ĕ: "E",
ĕ: "e",
Ė: "E",
ė: "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: "s",
V̌: "V",
v̌: "v",
W̌: "W",
w̌: "w",
X̌: "X",
x̌: "x",
Y̌: "Y",
y̌: "y",
A̧: "A",
a̧: "a",
B̧: "B",
b̧: "b",
Ḑ: "D",
ḑ: "d",
Ȩ: "E",
ȩ: "e",
Ɛ̧: "E",
ɛ̧: "e",
Ḩ: "H",
ḩ: "h",
I̧: "I",
i̧: "i",
Ɨ̧: "I",
ɨ̧: "i",
M̧: "M",
m̧: "m",
O̧: "O",
o̧: "o",
Q̧: "Q",
q̧: "q",
U̧: "U",
u̧: "u",
X̧: "X",
x̧: "x",
Z̧: "Z",
z̧: "z",
й: "и",
Й: "И",
ё: "е",
Ё: "Е"
}, t = Object.keys(e).join("|"), n = new RegExp(t, "g"), r = new RegExp(t, "");
function o(a) {
return e[a];
}
var s = function(a) {
return a.replace(n, o);
}, u = function(a) {
return !!a.match(r);
};
return F.exports = s, F.exports.has = u, F.exports.remove = s, F.exports;
}
var at = lt();
const ct = /* @__PURE__ */ ze(at);
/**
* @name match-sorter
* @license MIT license.
* @copyright (c) 2020 Kent C. Dodds
* @author Kent C. Dodds <me@kentcdodds.com> (https://kentcdodds.com)
*/
const I = {
CASE_SENSITIVE_EQUAL: 7,
EQUAL: 6,
STARTS_WITH: 5,
WORD_STARTS_WITH: 4,
CONTAINS: 3,
ACRONYM: 2,
MATCHES: 1,
NO_MATCH: 0
}, ut = (e, t) => String(e.rankedValue).localeCompare(String(t.rankedValue));
function J(e, t, n) {
n === void 0 && (n = {});
const {
keys: r,
threshold: o = I.MATCHES,
baseSort: s = ut,
sorter: u = (f) => f.sort((d, i) => ht(d, i, s))
} = n, a = e.reduce(c, []);
return u(a).map((f) => {
let {
item: d
} = f;
return d;
});
function c(f, d, i) {
const m = dt(d, r, t, n), {
rank: O,
keyThreshold: x = o
} = m;
return O >= x && f.push({
...m,
item: d,
index: i
}), f;
}
}
J.rankings = I;
function dt(e, t, n, r) {
if (!t) {
const s = e;
return {
// ends up being duplicate of 'item' in matches but consistent
rankedValue: s,
rank: Ie(s, n, r),
keyIndex: -1,
keyThreshold: r.threshold
};
}
return It(e, t).reduce((s, u, a) => {
let {
rank: c,
rankedValue: f,
keyIndex: d,
keyThreshold: i
} = s, {
itemValue: m,
attributes: O
} = u, x = Ie(m, n, r), U = f;
const {
minRanking: $,
maxRanking: H,
threshold: K
} = O;
return x < $ && x >= I.MATCHES ? x = $ : x > H && (x = H), x > c && (c = x, d = a, i = K, U = m), {
rankedValue: U,
rank: c,
keyIndex: d,
keyThreshold: i
};
}, {
rankedValue: e,
rank: I.NO_MATCH,
keyIndex: -1,
keyThreshold: r.threshold
});
}
function Ie(e, t, n) {
return e = Ae(e, n), t = Ae(t, n), t.length > e.length ? I.NO_MATCH : e === t ? I.CASE_SENSITIVE_EQUAL : (e = e.toLowerCase(), t = t.toLowerCase(), e === t ? I.EQUAL : e.startsWith(t) ? I.STARTS_WITH : e.includes(` ${t}`) ? I.WORD_STARTS_WITH : e.includes(t) ? I.CONTAINS : t.length === 1 ? I.NO_MATCH : ft(e).includes(t) ? I.ACRONYM : mt(e, t));
}
function ft(e) {
let t = "";
return e.split(" ").forEach((r) => {
r.split("-").forEach((s) => {
t += s.substr(0, 1);
});
}), t;
}
function mt(e, t) {
let n = 0, r = 0;
function o(c, f, d) {
for (let i = d, m = f.length; i < m; i++)
if (f[i] === c)
return n += 1, i + 1;
return -1;
}
function s(c) {
const f = 1 / c, d = n / t.length;
return I.MATCHES + d * f;
}
const u = o(t[0], e, 0);
if (u < 0)
return I.NO_MATCH;
r = u;
for (let c = 1, f = t.length; c < f; c++) {
const d = t[c];
if (r = o(d, e, r), !(r > -1))
return I.NO_MATCH;
}
const a = r - u;
return s(a);
}
function ht(e, t, n) {
const {
rank: s,
keyIndex: u
} = e, {
rank: a,
keyIndex: c
} = t;
return s === a ? u === c ? n(e, t) : u < c ? -1 : 1 : s > a ? -1 : 1;
}
function Ae(e, t) {
let {
keepDiacritics: n
} = t;
return e = `${e}`, n || (e = ct(e)), e;
}
function pt(e, t) {
typeof t == "object" && (t = t.key);
let n;
if (typeof t == "function")
n = t(e);
else if (e == null)
n = null;
else if (Object.hasOwnProperty.call(e, t))
n = e[t];
else {
if (t.includes("."))
return gt(t, e);
n = null;
}
return n == null ? [] : Array.isArray(n) ? n : [String(n)];
}
function gt(e, t) {
const n = e.split(".");
let r = [t];
for (let o = 0, s = n.length; o < s; o++) {
const u = n[o];
let a = [];
for (let c = 0, f = r.length; c < f; c++) {
const d = r[c];
if (d != null)
if (Object.hasOwnProperty.call(d, u)) {
const i = d[u];
i != null && a.push(i);
} else u === "*" && (a = a.concat(d));
}
r = a;
}
return Array.isArray(r[0]) ? [].concat(...r) : r;
}
function It(e, t) {
const n = [];
for (let r = 0, o = t.length; r < o; r++) {
const s = t[r], u = At(s), a = pt(e, s);
for (let c = 0, f = a.length; c < f; c++)
n.push({
itemValue: a[c],
attributes: u
});
}
return n;
}
const xe = {
maxRanking: 1 / 0,
minRanking: -1 / 0
};
function At(e) {
return typeof e == "string" ? xe : {
...xe,
...e
};
}
const Oe = b(it)``, ke = b(st).withConfig({ shouldForwardProp: te })(
({ disabled: e }) => _`
position: relative;
${Ce}
${Oe} {
color: ${e ? E("defaultFields.select.disabled.color") : "initial"};
}
`
), xt = b.div`
position: relative;
`, ye = b.divBox.withConfig({ shouldForwardProp: te })(
({ iconPlacement: e, isClearable: t, size: n, transparent: r, variant: o }) => _`
position: relative;
${tt({
iconPlacement: e,
isClearable: t,
size: n,
transparent: r,
variant: o
})};
${G};
cursor: pointer;
${Ce}
line-height: 1em;
br {
display: none;
}
&::before {
content: attr(data-spacer);
visibility: hidden;
display: block;
height: 0;
}
&:empty {
&::after {
content: attr(placeholder);
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
${G};
padding: inherit;
${E("defaultFields.placeholder")}
}
&::before {
height: auto;
}
}
`
), yt = b.ul`
${E("defaultFields.select.default")};
${E("cards.default")};
position: absolute;
z-index: 2;
right: 0;
left: 0;
margin: 0;
margin-top: md;
padding: 0;
transition: medium;
overflow: auto;
-webkit-overflow-scrolling: touch;
&:hover > * {
cursor: pointer;
}
`, X = b.li(
({ allowUnselectFromList: e, isDisabled: t, isHighlighted: n, isMultiple: r, isSelected: o }) => _`
color: beige-70;
${n && E("defaultFields.select.highlighted")};
${o && !r && E("defaultFields.select.selected")};
${o && r && !e && E("defaultFields.select.existing")};
${t && E("defaultFields.select.disabled")};
${G};
padding: md;
list-style: none;
text-decoration: none;
font-size: sm;
transition: background ${E.transition("medium")};
`
), Et = b.divBox(
({ size: e }) => _`
position: absolute;
padding: 0;
top: 0;
bottom: 0;
right: ${e === "xs" ? "sm" : "md"};
display: flex;
gap: xs;
`
), Ee = b.button.withConfig({ shouldForwardProp: te })(
({ isOpen: e }) => _`
position: relative;
height: 100%;
padding: 0;
outline: none !important; /* important for firefox */
appearance: none;
cursor: pointer;
border: none;
background: transparent;
display: flex;
align-items: center;
justify-content: center;
${qe} {
transform: ${e ? "rotate3d(0, 0, 1, 180deg)" : "rotate3d(0)"};
transition: medium;
}
&:not(:last-child) {
width: auto;
}
&:disabled {
color: ${E("defaultFields.select.disabled.color")};
}
`
), vt = b.divBox`
margin-top: lg;
${/* sc-selector */
rt}:not(:last-child) {
margin-right: sm;
margin-bottom: sm;
}
&:empty {
display: none;
}
`;
function bt(e, t) {
return /* @__PURE__ */ p.jsx(vt, { role: "list", children: e.map((n) => /* @__PURE__ */ p.jsx(ot, { onRemove: () => t(n.value.toString()), role: "listitem", children: n.label }, n.value)) });
}
const ne = "", Se = (e) => {
if (typeof e == "number")
return String(e);
if (typeof e == "string") {
const t = e.match(/[A-Z]{2,}(?=[A-Z][a-z]+[0-9]*|\b)|[A-Z]?[a-z]+[0-9]*|[A-Z]|[0-9]+/g);
return t && t.map((n) => n.toLowerCase()).join("-");
}
}, ve = (e) => e ? e.label : ne, Ct = (e) => e.reduce(
(t, n) => n.label && t.length > n.label.length ? t : n.label,
ne
), Ot = (e, t, n) => {
const r = t.find((o) => e.value === o.value);
return r && n ? t.filter((o) => e.value !== o.value) : r ? t : [...t, e];
}, q = (e, t) => !!t.find((n) => n.value === e), ee = (e, t = []) => t.find(
(r) => r.label === (e.label || e) || r.value === (e.value || e)
) || { label: e, value: Se(e) }, kt = (e, t, n = !1) => {
const r = n ? t.flatMap((o) => o.options) : t;
return !e && e !== 0 ? [] : Array.isArray(e) ? e.map((o) => ee(o, r)) : [ee(e, r)];
}, St = (e, t) => !!t.find((n) => n.value === e.value), wt = (e, t) => St(e, t) ? e.value : e.label, be = (e, t) => {
if (e)
return e.map((n) => wt(n, t));
}, jt = (e, t) => {
if (e)
return e.filter(
(n) => !t.find((r) => r.value === n.value)
);
}, Tt = ({
inputValue: e,
isMultiple: t,
isSearchable: n,
options: r,
renderItem: o
}) => {
const s = ee(e, r);
return t ? e : s.label ? n ? s.label : o(s) : ne;
}, Rt = he.default || he, Lt = Je(
({
allowUnselectFromList: e,
autoComplete: t = "off",
autoFocus: n,
dataTestId: r,
disableCloseOnSelect: o,
disabled: s,
groupsEnabled: u,
icon: a,
id: c,
isClearable: f,
isCreatable: d,
isMultiple: i,
isSearchable: m,
name: O,
onBlur: x,
onChange: U,
onClick: $,
onCreate: H,
onFocus: K,
options: A = [],
placeholder: re = "Choose from…",
renderCreateItem: we = (w) => `Create "${w}"`,
renderGroupHeader: je,
renderItem: Y = ve,
renderMultiple: Te = bt,
size: W = "md",
transparent: Re,
value: oe,
variant: Ve,
...se
}, N) => {
const w = Ze(
() => kt(oe, A, u),
[oe, A, u]
), z = !i && w[0] || null, L = z ? z.label : "", [k, Z] = B(w), [v, D] = B(L), [M, P] = B(A), [S, j] = B(!1);
m = d || m, pe(() => {
var l;
n && ((l = N == null ? void 0 : N.current) == null || l.focus(), m && j(!0));
}, [m, n, N]), pe(() => {
Z(w), D(L), P(A);
}, [L, A, w]);
const Ue = (l) => {
if (m && l !== v) {
let h = [];
u ? h = J(A, l, {
// should match on group.label OR group.options.label
keys: [(g) => g.label, (g) => g.options.map((T) => T.label)]
}) : h = J(A, l, { keys: ["label"] }), D(l), P(h);
}
}, $e = () => {
m && !S && j(!0);
}, ie = (l) => {
let h = [];
u ? h = be(
l,
A.flatMap((R) => R.options)
) : h = be(l, A);
const g = i ? h : h[0], T = et({ name: O, value: i ? l : l[0] });
if (U && U(g, T), d) {
const R = jt(l, A);
R.length && H && H(R[0].label, T);
}
}, He = (l) => {
let h, g;
!l || l != null && l.disabled ? (h = i ? k : [], g = !0) : (h = i ? Ot(l, k, e) : [l], g = i), g && D(""), P(A), Z(h), ie(h), o || j(!1);
}, Ne = (l) => {
const h = k.filter((g) => g.value !== l);
Z(h), ie(h);
}, De = (l) => {
i && l.selectedItem ? D("") : m && l.selectedItem && D(l.selectedItem.label), P(A), j(!1);
}, Fe = Ct(A), le = Tt({
inputValue: v,
isMultiple: i,
isSearchable: m,
options: A,
renderItem: Y
});
return /* @__PURE__ */ p.jsx(
Rt,
{
id: c,
inputValue: m ? le : "",
isOpen: S,
itemToString: ve,
onInputValueChange: Ue,
onOuterClick: De,
onSelect: He,
selectedItem: z,
children: ({
clearSelection: l,
getInputProps: h,
getItemProps: g,
getMenuProps: T,
getRootProps: R,
getToggleButtonProps: _e,
highlightedIndex: Q
}) => {
const ae = !!(d && v && !q(v, k)), We = S && (M.length || ae), Me = f && v, Pe = /* @__PURE__ */ p.jsx(Ee, { as: "div", children: /* @__PURE__ */ p.jsx(
Xe,
{
onClick: l
}
) }), Be = /* @__PURE__ */ p.jsx(
Ee,
{
"data-testid": r ? `${r}-arrow-icon` : null,
disabled: s,
isOpen: S,
size: W,
tabIndex: -1,
..._e({
onClick: () => j(!S)
}),
children: /* @__PURE__ */ p.jsx(Ge, { size: "sm" })
}
), Ke = (V) => {
$ && $(V), j(!S);
}, Ye = R(se), ce = h({
autoComplete: t,
autoFocus: n,
"data-spacer": Fe || re,
"data-testid": r,
disabled: s,
iconPlacement: a ? "both" : "right",
id: c,
isClearable: f,
name: O,
onBlur: x,
onClick: s ? void 0 : Ke,
onFocus: K,
onKeyDown: $e,
placeholder: re,
ref: N,
size: W,
tabIndex: 0,
transparent: Re,
variant: S ? "focused" : Ve,
...se
// eslint-disable-next-line @typescript-eslint/no-explicit-any
}), ue = nt[W];
return /* @__PURE__ */ p.jsxs(ke, { ...Ye, disabled: s, children: [
/* @__PURE__ */ p.jsxs(xt, { children: [
m ? /* @__PURE__ */ p.jsx(ye, { as: "input", type: "text", ...ce }) : /* @__PURE__ */ p.jsx(ye, { ...ce, children: le }),
a ? /* @__PURE__ */ p.jsx(Oe, { iconPlacement: "left", size: ue, children: Le.cloneElement(a, { ...a.props, size: ue }) }) : null,
/* @__PURE__ */ p.jsxs(Et, { size: W, children: [
Me ? Pe : null,
Be
] })
] }),
We ? /* @__PURE__ */ p.jsxs(yt, { ...T(), children: [
M.reduce(
(V, y, de) => {
if (u && "options" in y)
V.itemsToRender.push(
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
/* @__PURE__ */ p.jsxs(Qe, { children: [
je(y),
y.options ? y.options.map((C) => {
const fe = V.itemIndex++, me = q(C.value, k);
return /* @__PURE__ */ p.jsx(
X,
{
allowUnselectFromList: e,
isDisabled: C.disabled,
isHighlighted: Q === fe,
isMultiple: i,
...g({
index: fe,
isSelected: me,
item: C
}),
children: Y(C, me)
},
C.value
);
}) : null
] }, y.label)
);
else if ("value" in y) {
const C = q(y.value, k);
V.itemsToRender.push(
/* @__PURE__ */ p.jsx(
X,
{
allowUnselectFromList: e,
isDisabled: y.disabled,
isHighlighted: Q === de,
isMultiple: i,
...g({
index: de,
isSelected: C,
item: y
}),
children: Y(y, C)
},
y.value
)
);
}
return V;
},
{ itemIndex: 0, itemsToRender: [] }
).itemsToRender,
ae && v.length ? /* @__PURE__ */ p.jsx(
X,
{
isHighlighted: Q === M.length,
...g({
index: M.length,
item: {
label: v,
value: Se(v)
}
}),
children: we(v)
},
"add"
) : null
] }) : null,
i ? Te(k, Ne) : null
] });
}
}
);
}
), Zt = ke;
export {
Lt as Select,
Zt as StyledSelect
};