UNPKG

2.13 kBJavaScriptView Raw
1"use strict";
2var __assign = (this && this.__assign) || function () {
3 __assign = Object.assign || function(t) {
4 for (var s, i = 1, n = arguments.length; i < n; i++) {
5 s = arguments[i];
6 for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7 t[p] = s[p];
8 }
9 return t;
10 };
11 return __assign.apply(this, arguments);
12};
13var __rest = (this && this.__rest) || function (s, e) {
14 var t = {};
15 for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
16 t[p] = s[p];
17 if (s != null && typeof Object.getOwnPropertySymbols === "function")
18 for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
19 if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
20 t[p[i]] = s[p[i]];
21 }
22 return t;
23};
24var __importStar = (this && this.__importStar) || function (mod) {
25 if (mod && mod.__esModule) return mod;
26 var result = {};
27 if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
28 result["default"] = mod;
29 return result;
30};
31Object.defineProperty(exports, "__esModule", { value: true });
32var React = __importStar(require("react"));
33var StaticWrapper_1 = require("./StaticWrapper");
34var ModalWrapper_1 = require("./ModalWrapper");
35var InlineWrapper_1 = require("./InlineWrapper");
36function getWrapperFromVariant(variant) {
37 switch (variant) {
38 case 'inline':
39 return InlineWrapper_1.InlineWrapper;
40 case 'static':
41 return StaticWrapper_1.StaticWrapper;
42 default:
43 return ModalWrapper_1.ModalWrapper;
44 }
45}
46exports.getWrapperFromVariant = getWrapperFromVariant;
47exports.VariantContext = React.createContext(null);
48exports.Wrapper = function (_a) {
49 var variant = _a.variant, props = __rest(_a, ["variant"]);
50 var Component = getWrapperFromVariant(variant);
51 return (React.createElement(exports.VariantContext.Provider, { value: variant || 'dialog' },
52 React.createElement(Component, __assign({}, props))));
53};