mongodb-chatbot-ui
Version:
UI React components for the MongoDB Chatbot Framework
363 lines (342 loc) • 10.7 kB
JavaScript
import h from "react";
import { m as f, o as K, M as N, F as i, h as v, b as p, w as E, d as en, C as rn, n as Q } from "./index2.js";
import { l as tn } from "./index8.js";
import { s as on } from "./index10.js";
import { createPortal as an } from "react-dom";
function x() {
return x = Object.assign ? Object.assign.bind() : function(n) {
for (var r = 1; r < arguments.length; r++) {
var e = arguments[r];
for (var t in e)
Object.prototype.hasOwnProperty.call(e, t) && (n[t] = e[t]);
}
return n;
}, x.apply(this, arguments);
}
function ln(n, r) {
if (n == null)
return {};
var e, t, o = function(c, y) {
if (c == null)
return {};
var u, s, d = {}, g = Object.keys(c);
for (s = 0; s < g.length; s++)
u = g[s], y.indexOf(u) >= 0 || (d[u] = c[u]);
return d;
}(n, r);
if (Object.getOwnPropertySymbols) {
var a = Object.getOwnPropertySymbols(n);
for (t = 0; t < a.length; t++)
e = a[t], r.indexOf(e) >= 0 || Object.prototype.propertyIsEnumerable.call(n, e) && (o[e] = n[e]);
}
return o;
}
function cn(n, r) {
return r || (r = n.slice(0)), Object.freeze(Object.defineProperties(n, { raw: { value: Object.freeze(r) } }));
}
function sn(n, r) {
n["aria-label"] || n["aria-labelledby"] || console.error("For screen-reader accessibility, aria-label or aria-labelledby must be provided".concat(r ? " to ".concat(r) : "", "."));
}
var I, un = ["children", "className"], fn = f(I || (I = cn([`
clip: rect(0, 0, 0, 0);
clip-path: inset(50%);
height: 1px;
width: 1px;
margin: -1px;
overflow: hidden;
padding: 0;
position: absolute;
`])));
function bn(n) {
var r = n.children, e = n.className, t = ln(n, un);
return h.createElement("div", x({}, t, { className: K(fn, e) }), r);
}
bn.displayName = "VisuallyHidden";
function L(n, r) {
var e = Object.keys(n);
if (Object.getOwnPropertySymbols) {
var t = Object.getOwnPropertySymbols(n);
r && (t = t.filter(function(o) {
return Object.getOwnPropertyDescriptor(n, o).enumerable;
})), e.push.apply(e, t);
}
return e;
}
function z(n) {
for (var r = 1; r < arguments.length; r++) {
var e = arguments[r] != null ? arguments[r] : {};
r % 2 ? L(Object(e), !0).forEach(function(t) {
l(n, t, e[t]);
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(n, Object.getOwnPropertyDescriptors(e)) : L(Object(e)).forEach(function(t) {
Object.defineProperty(n, t, Object.getOwnPropertyDescriptor(e, t));
});
}
return n;
}
function dn(n) {
var r = function(e, t) {
if (typeof e != "object" || !e)
return e;
var o = e[Symbol.toPrimitive];
if (o !== void 0) {
var a = o.call(e, t);
if (typeof a != "object")
return a;
throw new TypeError("@@toPrimitive must return a primitive value.");
}
return String(e);
}(n, "string");
return typeof r == "symbol" ? r : r + "";
}
function l(n, r, e) {
return (r = dn(r)) in n ? Object.defineProperty(n, r, { value: e, enumerable: !0, configurable: !0, writable: !0 }) : n[r] = e, n;
}
function P() {
return P = Object.assign ? Object.assign.bind() : function(n) {
for (var r = 1; r < arguments.length; r++) {
var e = arguments[r];
for (var t in e)
Object.prototype.hasOwnProperty.call(e, t) && (n[t] = e[t]);
}
return n;
}, P.apply(this, arguments);
}
function gn(n, r) {
if (n == null)
return {};
var e, t, o = function(c, y) {
if (c == null)
return {};
var u, s, d = {}, g = Object.keys(c);
for (s = 0; s < g.length; s++)
u = g[s], y.indexOf(u) >= 0 || (d[u] = c[u]);
return d;
}(n, r);
if (Object.getOwnPropertySymbols) {
var a = Object.getOwnPropertySymbols(n);
for (t = 0; t < a.length; t++)
e = a[t], r.indexOf(e) >= 0 || Object.prototype.propertyIsEnumerable.call(n, e) && (o[e] = n[e]);
}
return o;
}
function b(n, r) {
return r || (r = n.slice(0)), Object.freeze(Object.defineProperties(n, { raw: { value: Object.freeze(r) } }));
}
var C, A, M, F, T, B, R, X, H, _, q, G, J, U, k = { Default: "default", Large: "large", XLarge: "xlarge" }, pn = f(C || (C = b([`
border: none;
-webkit-appearance: unset;
padding: unset;
`]))), yn = f(A || (A = b([`
display: inline-block;
border-radius: 100px;
position: relative;
cursor: pointer;
flex-shrink: 0;
transition: `, `ms ease-in-out;
transition-property: color, box-shadow;
// Set background to fully-transparent white for cross-browser compatability with Safari
//
// Safari treats "transparent" values in CSS as transparent black instead of white
// which can make things render differently across browsers if not defined explicitly.
background-color: rgba(255, 255, 255, 0);
&:before {
content: '';
transition: `, `ms all ease-in-out;
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
border-radius: 100%;
transform: scale(0.8);
}
&:active:before,
&:hover:before,
&:focus:before {
transform: scale(1);
}
&:focus {
outline: none;
}
`])), N.default, N.default), hn = l(l(l({}, k.Default, f(M || (M = b([`
height: 28px;
width: 28px;
`])))), k.Large, f(F || (F = b([`
height: 36px;
width: 36px;
`])))), k.XLarge, f(T || (T = b([`
height: 42px;
width: 42px;
`])))), mn = l(l({}, p.Light, f(B || (B = b([`
color: `, `;
&:active,
&:hover {
color: `, `;
&:before {
background-color: `, `;
}
}
`])), i.gray.dark1, i.black, v(0.9, i.gray.dark2))), p.Dark, f(R || (R = b([`
color: `, `;
&:active,
&:hover {
color: `, `;
&:before {
background-color: `, `;
}
}
`])), i.gray.light1, i.gray.light3, v(0.9, i.gray.light2))), vn = l(l({}, p.Light, f(X || (X = b([`
&:focus-visible {
color: `, `;
box-shadow: `, `;
&:before {
background-color: `, `;
}
}
`])), i.black, E[p.Light].default, v(0.9, i.gray.dark2))), p.Dark, f(H || (H = b([`
&:focus-visible {
color: `, `;
box-shadow: `, `;
&:before {
background-color: `, `;
}
}
`])), i.gray.light3, E[p.Dark].default, v(0.9, i.gray.light2))), On = l(l({}, p.Light, f(_ || (_ = b([`
cursor: not-allowed;
color: `, `;
background-color: rgba(255, 255, 255, 0);
&:active,
&:hover {
color: `, `;
&:before {
background-color: rgba(255, 255, 255, 0);
}
}
&:focus {
color: `, `;
&:before {
background-color: rgba(255, 255, 255, 0);
}
}
`])), i.gray.light1, i.gray.light1, i.gray.light1)), p.Dark, f(q || (q = b([`
cursor: not-allowed;
color: `, `;
background-color: rgba(255, 255, 255, 0);
&:active,
&:hover {
color: `, `;
&:before {
background-color: rgba(255, 255, 255, 0);
}
}
&:focus {
color: `, `;
&:before {
background-color: rgba(255, 255, 255, 0);
}
}
`])), i.gray.dark1, i.gray.dark1, i.gray.dark1)), wn = l(l({}, p.Light, f(G || (G = b([`
color: `, `;
&:before {
background-color: `, `;
transform: scale(1);
}
`])), i.black, v(0.9, i.gray.dark2))), p.Dark, f(J || (J = b([`
color: `, `;
&:before {
background-color: `, `;
transform: scale(1);
}
`])), i.gray.light3, v(0.9, i.gray.light2))), kn = f(U || (U = b([`
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
display: flex;
align-items: center;
justify-content: center;
`]))), jn = ["size", "darkMode", "disabled", "active", "tabIndex", "className", "children"], xn = h.forwardRef(function(n, r) {
var e = n.size, t = e === void 0 ? k.Default : e, o = n.darkMode, a = n.disabled, c = a !== void 0 && a, y = n.active, u = y !== void 0 && y, s = n.tabIndex, d = s === void 0 ? 0 : s, g = n.className, j = n.children, O = gn(n, jn), w = en(o).theme, W = typeof O.href == "string";
sn(O, "IconButton");
var Y = h.Children.map(j, function(m) {
if (!m)
return null;
if (rn(m, "Icon") || on(m)) {
var S = m.props, nn = S.size, $ = S.title, D = { size: nn || t };
return typeof $ == "string" && $.length !== 0 || (D.title = !1), h.cloneElement(m, D);
}
return m;
}), Z = z(z({}, O), {}, l(l(l(l({ ref: r, tabIndex: d }, "aria-disabled", c), "href", c ? void 0 : O.href), "onClick", c ? void 0 : O.onClick), "className", K(pn, yn, hn[t], mn[w], vn[w], l(l({}, wn[w], u && !c), On[w], c), g)));
return h.createElement(tn, P({ as: W ? "a" : "button" }, Z), h.createElement("div", { className: kn }, Y));
});
xn.displayName = "IconButton";
function Pn(n, r) {
return function(e) {
if (Array.isArray(e))
return e;
}(n) || function(e, t) {
var o = e == null ? null : typeof Symbol < "u" && e[Symbol.iterator] || e["@@iterator"];
if (o != null) {
var a, c, y, u, s = [], d = !0, g = !1;
try {
if (y = (o = o.call(e)).next, t !== 0)
for (; !(d = (a = y.call(o)).done) && (s.push(a.value), s.length !== t); d = !0)
;
} catch (j) {
g = !0, c = j;
} finally {
try {
if (!d && o.return != null && (u = o.return(), Object(u) !== u))
return;
} finally {
if (g)
throw c;
}
}
return s;
}
}(n, r) || function(e, t) {
if (e) {
if (typeof e == "string")
return V(e, t);
var o = Object.prototype.toString.call(e).slice(8, -1);
if (o === "Object" && e.constructor && (o = e.constructor.name), o === "Map" || o === "Set")
return Array.from(e);
if (o === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(o))
return V(e, t);
}
}(n, r) || function() {
throw new TypeError(`Invalid attempt to destructure non-iterable instance.
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`);
}();
}
function V(n, r) {
r > n.length && (r = n.length);
for (var e = 0, t = new Array(r); e < r; e++)
t[e] = n[e];
return t;
}
function Sn(n, r) {
var e = Pn(h.useState(), 2), t = e[0], o = e[1];
return Q(function() {
if (n)
return r && (r.current = n), void o(n);
var a = document.createElement("div");
return document.body.appendChild(a), r && (r.current = a), o(a), function() {
a.remove();
};
}, [n, r]), t;
}
function $n(n) {
var r = n.children, e = n.className, t = n.container, o = n.portalRef, a = Sn(t ?? void 0, o);
return Q(function() {
a && !t && (a.className = e ?? "");
}, [t, a, e]), a ? an(r, a) : null;
}
$n.displayName = "Portal";
export {
xn as J,
$n as u,
bn as w
};