show.js 1.4 KB

123456789101112131415161718192021222324252627282930313233
  1. var __rest = (this && this.__rest) || function (s, e) {
  2. var t = {};
  3. for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
  4. t[p] = s[p];
  5. if (s != null && typeof Object.getOwnPropertySymbols === "function")
  6. for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
  7. if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
  8. t[p[i]] = s[p[i]];
  9. }
  10. return t;
  11. };
  12. import { getInstance } from '../common/utils';
  13. export var ActionSheetTheme;
  14. (function (ActionSheetTheme) {
  15. ActionSheetTheme["List"] = "list";
  16. ActionSheetTheme["Grid"] = "grid";
  17. })(ActionSheetTheme || (ActionSheetTheme = {}));
  18. export const show = function (options) {
  19. const _a = Object.assign({}, options), { context, selector = '#t-action-sheet' } = _a, otherOptions = __rest(_a, ["context", "selector"]);
  20. const instance = getInstance(context, selector);
  21. if (instance) {
  22. instance.show(Object.assign({}, otherOptions));
  23. return instance;
  24. }
  25. console.error('未找到组件,请确认 selector && context 是否正确');
  26. };
  27. export const close = function (options) {
  28. const { context, selector = '#t-action-sheet' } = Object.assign({}, options);
  29. const instance = getInstance(context, selector);
  30. if (instance) {
  31. instance.close();
  32. }
  33. };