UNPKG

mongodb-chatbot-ui

Version:

UI React components for the MongoDB Assistant

329 lines (308 loc) 18.1 kB
import X from "react"; import { m, n as mr, w as s, F as t, P as Sr, Y as Pr, d as $r, r as jr } from "./index2.js"; import { K as Lr } from "./index7.js"; import { c as T } from "./polished.esm.js"; function J() { return J = Object.assign ? Object.assign.bind() : function(o) { for (var n = 1; n < arguments.length; n++) { var g = arguments[n]; for (var d in g) ({}).hasOwnProperty.call(g, d) && (o[d] = g[d]); } return o; }, J.apply(null, arguments); } function Er(o, n) { return n || (n = o.slice(0)), Object.freeze(Object.defineProperties(o, { raw: { value: Object.freeze(n) } })); } function Ir(o, n) { o["aria-label"] || o["aria-labelledby"] || console.error("For screen-reader accessibility, aria-label or aria-labelledby must be provided".concat(n ? " to ".concat(n) : "", ".")); } var rr, zr = ["children", "className"], Nr = m(rr || (rr = Er([` clip: rect(0, 0, 0, 0); clip-path: inset(50%); height: 1px; width: 1px; margin: -1px; overflow: hidden; padding: 0; position: absolute; `]))); function Tr(o) { var n = o.children, g = o.className, d = function(h, v) { if (h == null) return {}; var H, y, w = function(O, Z) { if (O == null) return {}; var K = {}; for (var j in O) if ({}.hasOwnProperty.call(O, j)) { if (Z.indexOf(j) !== -1) continue; K[j] = O[j]; } return K; }(h, v); if (Object.getOwnPropertySymbols) { var B = Object.getOwnPropertySymbols(h); for (y = 0; y < B.length; y++) H = B[y], v.indexOf(H) === -1 && {}.propertyIsEnumerable.call(h, H) && (w[H] = h[H]); } return w; }(o, zr); return X.createElement("div", J({}, d, { className: mr(Nr, g) }), n); } Tr.displayName = "VisuallyHidden"; function r(o, n, g) { return (n = function(d) { var h = function(v, H) { if (typeof v != "object" || !v) return v; var y = v[Symbol.toPrimitive]; if (y !== void 0) { var w = y.call(v, H); if (typeof w != "object") return w; throw new TypeError("@@toPrimitive must return a primitive value."); } return String(v); }(d, "string"); return typeof h == "symbol" ? h : h + ""; }(n)) in o ? Object.defineProperty(o, n, { value: g, enumerable: !0, configurable: !0, writable: !0 }) : o[n] = g, o; } var er, ar, a = { Disabled: "disabled", Placeholder: "placeholder", Primary: "primary", Secondary: "secondary", Tertiary: "tertiary", InversePrimary: "inversePrimary", InverseSecondary: "inverseSecondary", Info: "info", Warning: "warning", Error: "error", Success: "success", Link: "link", OnError: "onError", OnSuccess: "onSuccess", OnSuccessLink: "onSuccessLink" }, e = { Default: "default", Hover: "hover", Focus: "focus" }, M = t.black, c = t.blue, l = t.gray, b = t.green, D = t.red, Cr = t.white, L = t.yellow, Wr = { background: r(r(r(r(r(r(r(r({}, a.Primary, r(r(r({}, e.Default, M), e.Hover, l.dark2), e.Focus, c.dark3)), a.Secondary, r(r(r({}, e.Default, l.dark4), e.Hover, l.dark2), e.Focus, c.dark3)), a.InversePrimary, r(r(r({}, e.Default, l.light2), e.Hover, l.light3), e.Focus, c.light2)), a.Info, r(r(r({}, e.Default, c.dark3), e.Hover, c.dark3), e.Focus, c.dark3)), a.Warning, r(r(r({}, e.Default, L.dark3), e.Hover, L.dark3), e.Focus, L.dark3)), a.Success, r(r(r({}, e.Default, b.dark3), e.Hover, b.dark3), e.Focus, b.dark3)), a.Error, r(r(r({}, e.Default, D.dark3), e.Hover, D.dark3), e.Focus, D.dark3)), a.Disabled, r(r(r({}, e.Default, l.dark3), e.Hover, l.dark3), e.Focus, l.dark3)), border: r(r(r(r(r(r(r(r({}, a.Primary, r(r(r({}, e.Default, l.base), e.Hover, l.base), e.Focus, c.light1)), a.Secondary, r(r(r({}, e.Default, l.dark2), e.Hover, l.dark2), e.Focus, c.light1)), a.Tertiary, r(r(r({}, e.Default, l.dark1), e.Hover, l.dark1), e.Focus, c.light1)), a.Success, r(r(r({}, e.Default, b.dark1), e.Hover, b.dark1), e.Focus, c.light1)), a.Error, r(r(r({}, e.Default, D.light1), e.Hover, D.light1), e.Focus, c.light1)), a.OnSuccess, r(r(r({}, e.Default, b.dark2), e.Hover, b.dark2), e.Focus, c.light1)), a.OnError, r(r(r({}, e.Default, D.dark2), e.Hover, D.dark2), e.Focus, c.light1)), a.Disabled, r(r(r({}, e.Default, l.dark2), e.Hover, l.dark2), e.Focus, l.dark2)), icon: r(r(r(r(r(r(r(r({}, a.Primary, r(r(r({}, e.Default, l.light1), e.Hover, l.light3), e.Focus, c.light3)), a.Secondary, r(r(r({}, e.Default, l.base), e.Hover, l.light3), e.Focus, c.light3)), a.InversePrimary, r(r(r({}, e.Default, Cr), e.Hover, M), e.Focus, c.dark2)), a.Info, r(r(r({}, e.Default, c.light1), e.Hover, c.light1), e.Focus, c.light1)), a.Warning, r(r(r({}, e.Default, L.base), e.Hover, L.base), e.Focus, L.base)), a.Success, r(r(r({}, e.Default, b.base), e.Hover, b.base), e.Focus, b.base)), a.Error, r(r(r({}, e.Default, D.light1), e.Hover, D.light1), e.Focus, D.light1)), a.Disabled, r(r(r({}, e.Default, l.dark1), e.Hover, l.dark1), e.Focus, l.dark1)), text: (r(r(r(r(r(r(r(r(r(r(er = {}, a.Primary, r(r(r({}, e.Default, l.light2), e.Hover, l.light2), e.Focus, c.light3)), a.Placeholder, r(r(r({}, e.Default, l.dark1), e.Hover, l.dark1), e.Focus, l.dark1)), a.Secondary, r(r(r({}, e.Default, l.light1), e.Hover, l.light2), e.Focus, c.light3)), a.InversePrimary, r(r(r({}, e.Default, M), e.Hover, M), e.Focus, c.dark2)), a.InverseSecondary, r(r(r({}, e.Default, l.dark2), e.Hover, M), e.Focus, c.dark2)), a.Disabled, r(r(r({}, e.Default, l.dark1), e.Hover, l.dark1), e.Focus, l.dark1)), a.Success, r(r(r({}, e.Default, b.light2), e.Hover, b.light2), e.Focus, b.light2)), a.Error, r(r(r({}, e.Default, D.light1), e.Hover, D.light1), e.Focus, D.light1)), a.OnSuccess, r(r(r({}, e.Default, b.light1), e.Hover, b.light1), e.Focus, b.light1)), a.OnSuccessLink, r(r(r({}, e.Default, b.light3), e.Hover, b.light3), e.Focus, b.light3)), r(r(er, a.OnError, r(r(r({}, e.Default, D.light2), e.Hover, D.light2), e.Focus, D.light2)), a.Link, r(r(r({}, e.Default, c.light1), e.Hover, c.light1), e.Focus, c.light1))) }, E = t.black, u = t.blue, i = t.gray, f = t.green, p = t.red, I = t.white, z = t.yellow, Mr = { background: r(r(r(r(r(r(r(r({}, a.Primary, r(r(r({}, e.Default, I), e.Hover, i.light2), e.Focus, u.light3)), a.Secondary, r(r(r({}, e.Default, i.light3), e.Hover, i.light2), e.Focus, u.light3)), a.InversePrimary, r(r(r({}, e.Default, E), e.Hover, i.dark3), e.Focus, u.dark2)), a.Info, r(r(r({}, e.Default, u.light3), e.Hover, u.light3), e.Focus, u.light3)), a.Warning, r(r(r({}, e.Default, z.light3), e.Hover, z.light3), e.Focus, z.light3)), a.Success, r(r(r({}, e.Default, f.light3), e.Hover, f.light3), e.Focus, f.light3)), a.Error, r(r(r({}, e.Default, p.light3), e.Hover, p.light3), e.Focus, p.light3)), a.Disabled, r(r(r({}, e.Default, i.light2), e.Hover, i.light2), e.Focus, i.light2)), border: r(r(r(r(r(r(r(r({}, a.Primary, r(r(r({}, e.Default, i.base), e.Hover, i.base), e.Focus, u.light1)), a.Secondary, r(r(r({}, e.Default, i.light2), e.Hover, i.light2), e.Focus, u.light1)), a.Tertiary, r(r(r({}, e.Default, i.light1), e.Hover, i.light1), e.Focus, u.light1)), a.Success, r(r(r({}, e.Default, f.dark1), e.Hover, f.dark1), e.Focus, u.light1)), a.Error, r(r(r({}, e.Default, p.base), e.Hover, p.base), e.Focus, u.light1)), a.Disabled, r(r(r({}, e.Default, i.light1), e.Hover, i.light1), e.Focus, i.light1)), a.OnSuccess, r(r(r({}, e.Default, f.light2), e.Hover, f.light2), e.Focus, f.light2)), a.OnError, r(r(r({}, e.Default, p.light2), e.Hover, p.light2), e.Focus, p.light2)), icon: r(r(r(r(r(r(r(r({}, a.Primary, r(r(r({}, e.Default, i.dark1), e.Hover, E), e.Focus, u.dark1)), a.Secondary, r(r(r({}, e.Default, i.base), e.Hover, E), e.Focus, u.dark1)), a.InversePrimary, r(r(r({}, e.Default, I), e.Hover, I), e.Focus, u.light2)), a.Info, r(r(r({}, e.Default, u.base), e.Hover, u.base), e.Focus, u.base)), a.Warning, r(r(r({}, e.Default, z.dark2), e.Hover, z.dark2), e.Focus, z.dark2)), a.Success, r(r(r({}, e.Default, f.dark1), e.Hover, f.dark1), e.Focus, f.dark1)), a.Error, r(r(r({}, e.Default, p.base), e.Hover, p.base), e.Focus, p.base)), a.Disabled, r(r(r({}, e.Default, i.base), e.Hover, i.base), e.Focus, i.base)), text: (r(r(r(r(r(r(r(r(r(r(ar = {}, a.Primary, r(r(r({}, e.Default, E), e.Hover, E), e.Focus, u.dark1)), a.Secondary, r(r(r({}, e.Default, i.dark1), e.Hover, E), e.Focus, u.dark1)), a.InversePrimary, r(r(r({}, e.Default, I), e.Hover, I), e.Focus, u.light2)), a.InverseSecondary, r(r(r({}, e.Default, i.light1), e.Hover, I), e.Focus, u.light2)), a.Disabled, r(r(r({}, e.Default, i.base), e.Hover, i.base), e.Focus, i.base)), a.Success, r(r(r({}, e.Default, f.dark2), e.Hover, f.dark2), e.Focus, f.dark2)), a.Error, r(r(r({}, e.Default, p.base), e.Hover, p.base), e.Focus, p.base)), a.Placeholder, r(r(r({}, e.Default, i.base), e.Hover, i.base), e.Focus, i.base)), a.OnSuccess, r(r(r({}, e.Default, f.dark2), e.Hover, f.dark2), e.Focus, f.dark2)), a.OnSuccessLink, r(r(r({}, e.Default, f.dark3), e.Hover, f.dark3), e.Focus, f.dark3)), r(r(ar, a.OnError, r(r(r({}, e.Default, p.dark2), e.Hover, p.dark2), e.Focus, p.dark2)), a.Link, r(r(r({}, e.Default, u.base), e.Hover, u.base), e.Focus, u.base))) }; r(r({}, s.Dark, Wr), s.Light, Mr); var Y = { Dark: "dark", Light: "light" }, tr = r(r({}, Y.Light, { default: "0 0 0 2px ".concat(t.white, ", 0 0 0 4px ").concat(t.blue.light1), input: "0 0 0 3px ".concat(t.blue.light1) }), Y.Dark, { default: "0 0 0 2px ".concat(t.black, ", 0 0 0 4px ").concat(t.blue.light1), input: "0 0 0 3px ".concat(t.blue.light1) }); r(r({}, Y.Light, { gray: "0 0 0 3px ".concat(t.gray.light2), green: "0 0 0 3px ".concat(t.green.light2), red: "0 0 0 3px ".concat(t.red.light2) }), Y.Dark, { gray: "0 0 0 3px ".concat(t.gray.dark2), green: "0 0 0 3px ".concat(t.green.dark3), red: "0 0 0 3px ".concat(t.yellow.dark3) }); var Xr = t.black, N = t.gray, Br = t.white; r(r({}, a.Primary, r({}, e.Default, N.base)), a.Secondary, r({}, e.Default, N.dark1)), r(r({}, a.Primary, r({}, e.Default, Xr)), a.Secondary, r({}, e.Default, N.dark4)), r(r({}, a.Primary, r({}, e.Default, N.base)), a.Secondary, r({}, e.Default, N.light1)), r(r({}, a.Primary, r({}, e.Default, Br)), a.Secondary, r({}, e.Default, N.light3)); var $ = r(r({}, s.Light, { 1: "color-mix(in srgb, ".concat(t.black, " 15%, transparent)"), 2: "color-mix(in srgb, ".concat(t.black, " 20%, transparent)"), 3: "color-mix(in srgb, ".concat(t.black, " 60%, transparent)"), overflow: "color-mix(in srgb, ".concat(t.gray.dark1, " 30%, transparent)") }), s.Dark, { 1: "transparent", 2: "color-mix(in srgb, #000000 45%, transparent)", 3: "color-mix(in srgb, #000000 60%, transparent)", overflow: "color-mix(in srgb, #000000 30%, transparent)" }); r(r({}, s.Light, { 1: "0px 2px 4px 1px ".concat($[s.Light][1]), 2: "0px 18px 18px -15px ".concat($[s.Light][2]), 3: "0px 8px 20px -8px ".concat($[s.Light][3]), overflow: "0px 2px 4px 1px ".concat($[s.Light].overflow) }), s.Dark, { 1: "unset", 2: "0 18px 18px -15px ".concat($[s.Dark][2]), 3: "0 8px 20px -8px ".concat($[s.Dark][3]), overflow: "0px 2px 4px 1px ".concat($[s.Dark].overflow) }); r(r({}, s.Light, 2), s.Dark, 16); var or = { faster: 100, default: 150, slower: 300, slowest: 500 }; function k(o, n, g) { return (n = function(d) { var h = function(v, H) { if (typeof v != "object" || !v) return v; var y = v[Symbol.toPrimitive]; if (y !== void 0) { var w = y.call(v, H); if (typeof w != "object") return w; throw new TypeError("@@toPrimitive must return a primitive value."); } return String(v); }(d, "string"); return typeof h == "symbol" ? h : h + ""; }(n)) in o ? Object.defineProperty(o, n, { value: g, enumerable: !0, configurable: !0, writable: !0 }) : o[n] = g, o; } function nr(o, n) { var g = Object.keys(o); if (Object.getOwnPropertySymbols) { var d = Object.getOwnPropertySymbols(o); n && (d = d.filter(function(h) { return Object.getOwnPropertyDescriptor(o, h).enumerable; })), g.push.apply(g, d); } return g; } function lr(o) { for (var n = 1; n < arguments.length; n++) { var g = arguments[n] != null ? arguments[n] : {}; n % 2 ? nr(Object(g), !0).forEach(function(d) { k(o, d, g[d]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(o, Object.getOwnPropertyDescriptors(g)) : nr(Object(g)).forEach(function(d) { Object.defineProperty(o, d, Object.getOwnPropertyDescriptor(g, d)); }); } return o; } function F(o, n) { return n || (n = o.slice(0)), Object.freeze(Object.defineProperties(o, { raw: { value: Object.freeze(n) } })); } var ir, cr, sr, ur, gr, dr, fr, br, hr, vr, kr, pr, yr, Dr, V = { Default: "default", Large: "large", XLarge: "xlarge" }, Kr = m(ir || (ir = F([` border: none; -webkit-appearance: unset; padding: unset; `]))), _r = m(cr || (cr = F([` 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, &[data-hover='true']:before, &[data-focus='true']:before { transform: scale(1); } &:focus { outline: none; } `])), or.default, or.default), qr = k(k(k({}, V.Default, m(sr || (sr = F([` height: 28px; width: 28px; `])))), V.Large, m(ur || (ur = F([` height: 36px; width: 36px; `])))), V.XLarge, m(gr || (gr = F([` height: 42px; width: 42px; `])))), Ar = k(k({}, s.Light, m(dr || (dr = F([` color: `, `; &:active, &:hover, &[data-hover='true'] { color: `, `; &::before { background-color: `, `; } } `])), t.gray.dark1, t.black, T(0.9, t.gray.dark2))), s.Dark, m(fr || (fr = F([` color: `, `; &:active, &:hover, &[data-hover='true'] { color: `, `; &::before { background-color: `, `; } } `])), t.gray.light1, t.gray.light3, T(0.9, t.gray.light2))), Gr = k(k({}, s.Light, m(br || (br = F([` &:focus-visible, &[data-focus='true'] { color: `, `; box-shadow: `, `; &::before { background-color: `, `; } } `])), t.black, tr[s.Light].default, T(0.9, t.gray.dark2))), s.Dark, m(hr || (hr = F([` &:focus-visible, &[data-focus='true'] { color: `, `; box-shadow: `, `; &::before { background-color: `, `; } } `])), t.gray.light3, tr[s.Dark].default, T(0.9, t.gray.light2))), Vr = k(k({}, s.Light, m(vr || (vr = F([` cursor: not-allowed; color: `, `; background-color: rgba(255, 255, 255, 0); &:active, &:hover, &[data-hover='true'] { color: `, `; &::before { background-color: rgba(255, 255, 255, 0); } } &:focus, &[data-focus='true'] { color: `, `; &::before { background-color: rgba(255, 255, 255, 0); } } `])), t.gray.light1, t.gray.light1, t.gray.light1)), s.Dark, m(kr || (kr = F([` cursor: not-allowed; color: `, `; background-color: rgba(255, 255, 255, 0); &:active, &:hover, &[data-hover='true'] { color: `, `; &::before { background-color: rgba(255, 255, 255, 0); } } &:focus, &[data-focus='true'] { color: `, `; &::before { background-color: rgba(255, 255, 255, 0); } } `])), t.gray.dark1, t.gray.dark1, t.gray.dark1)), Yr = k(k({}, s.Light, m(pr || (pr = F([` color: `, `; &::before { background-color: `, `; transform: scale(1); } `])), t.black, T(0.9, t.gray.dark2))), s.Dark, m(yr || (yr = F([` color: `, `; &::before { background-color: `, `; transform: scale(1); } `])), t.gray.light3, T(0.9, t.gray.light2))), Zr = m(Dr || (Dr = F([` position: absolute; top: 0; bottom: 0; left: 0; right: 0; display: flex; align-items: center; justify-content: center; `]))), Jr = ["as", "size", "darkMode", "disabled", "active", "tabIndex", "className", "children"], Qr = Sr(function(o, n) { var g = o.as, d = o.size, h = d === void 0 ? V.Default : d, v = o.darkMode, H = o.disabled, y = H !== void 0 && H, w = o.active, B = w !== void 0 && w, O = o.tabIndex, Z = O === void 0 ? 0 : O, K = o.className, j = o.children, Fr = function(x, C) { if (x == null) return {}; var S, P, W = function(A, Or) { if (A == null) return {}; var U = {}; for (var G in A) if ({}.hasOwnProperty.call(A, G)) { if (Or.indexOf(G) !== -1) continue; U[G] = A[G]; } return U; }(x, C); if (Object.getOwnPropertySymbols) { var R = Object.getOwnPropertySymbols(x); for (P = 0; P < R.length; P++) S = R[P], C.indexOf(S) === -1 && {}.propertyIsEnumerable.call(x, S) && (W[S] = x[S]); } return W; }(o, Jr), Q = Pr(g, Fr, "button"), Hr = Q.Component, _ = Q.rest, q = $r(v).theme; Ir(_, "IconButton"); var xr = X.Children.map(j, function(x) { if (!x) return null; if (jr(x, "Icon") || Lr(x)) { var C = x.props, S = C.size, P = C.title, W = { size: S || h }; return typeof P == "string" && P.length !== 0 || (W.title = !1), X.cloneElement(x, W); } return x; }), wr = lr(lr({}, _), {}, k(k(k(k({ ref: n, tabIndex: Z }, "aria-disabled", y), "href", y ? void 0 : _.href), "onClick", y ? void 0 : _.onClick), "className", mr(Kr, _r, qr[h], Ar[q], Gr[q], k(k({}, Yr[q], B && !y), Vr[q], y), K))); return X.createElement(Hr, wr, X.createElement("div", { className: Zr }, xr)); }); Qr.displayName = "IconButton"; export { Qr as H, Tr as g };