@codeleap/portals 7.0.0 → 7.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,44 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.alert = exports.Alert = void 0;
4
+ /**
5
+ * Alert utility for displaying typed alert modals (info, error, warn, ask, custom).
6
+ * Provides convenient methods for common alert scenarios.
7
+ */
8
+ class Alert {
9
+ /**
10
+ * Returns the Modal instance used to display alerts.
11
+ * Must be implemented by the consuming app before calling any alert method.
12
+ * @throws Error if not implemented
13
+ */
14
+ static openAlert() {
15
+ throw new Error('Please implement Alert.openAlert to use the alert system');
16
+ }
17
+ trigger(args) {
18
+ Alert.openAlert().open(args);
19
+ }
20
+ /** Opens an alert with 'ask' type. */
21
+ ask(args) {
22
+ this.trigger(Object.assign(Object.assign({}, args), { type: 'ask' }));
23
+ }
24
+ /** Opens an alert with 'error' type. */
25
+ error(args) {
26
+ this.trigger(Object.assign(Object.assign({}, args), { type: 'error' }));
27
+ }
28
+ /** Opens an alert with 'warn' type. */
29
+ warn(args) {
30
+ this.trigger(Object.assign(Object.assign({}, args), { type: 'warn' }));
31
+ }
32
+ /** Opens an alert with 'info' type. */
33
+ info(args) {
34
+ this.trigger(Object.assign(Object.assign({}, args), { type: 'info' }));
35
+ }
36
+ /** Opens a custom alert with user-defined options and type. */
37
+ custom(options) {
38
+ this.trigger(Object.assign(Object.assign({}, options), { type: 'custom' }));
39
+ }
40
+ }
41
+ exports.Alert = Alert;
42
+ /** Global alert instance for showing alerts throughout the app. */
43
+ exports.alert = new Alert();
44
+ //# sourceMappingURL=alert.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"alert.js","sourceRoot":"","sources":["../../src/factors/alert.ts"],"names":[],"mappings":";;;AAsBA;;;GAGG;AACH,MAAa,KAAK;IAEhB;;;;OAIG;IACH,MAAM,CAAC,SAAS;QACd,MAAM,IAAI,KAAK,CAAC,0DAA0D,CAAC,CAAA;IAC7E,CAAC;IAEO,OAAO,CAAC,IAAkB;QAChC,KAAK,CAAC,SAAS,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;IAC9B,CAAC;IAED,sCAAsC;IACtC,GAAG,CAAC,IAAkB;QACpB,IAAI,CAAC,OAAO,iCAAM,IAAI,KAAE,IAAI,EAAE,KAAK,IAAG,CAAA;IACxC,CAAC;IAED,wCAAwC;IACxC,KAAK,CAAC,IAAkB;QACtB,IAAI,CAAC,OAAO,iCAAM,IAAI,KAAE,IAAI,EAAE,OAAO,IAAG,CAAA;IAC1C,CAAC;IAED,uCAAuC;IACvC,IAAI,CAAC,IAAkB;QACrB,IAAI,CAAC,OAAO,iCAAM,IAAI,KAAE,IAAI,EAAE,MAAM,IAAG,CAAA;IACzC,CAAC;IAED,uCAAuC;IACvC,IAAI,CAAC,IAAkB;QACrB,IAAI,CAAC,OAAO,iCAAM,IAAI,KAAE,IAAI,EAAE,MAAM,IAAG,CAAA;IACzC,CAAC;IAED,+DAA+D;IAC/D,MAAM,CAAI,OAAkC;QAC1C,IAAI,CAAC,OAAO,iCAAO,OAAe,KAAE,IAAI,EAAE,QAAQ,IAAG,CAAA;IACvD,CAAC;CACF;AAvCD,sBAuCC;AAED,mEAAmE;AACtD,QAAA,KAAK,GAAG,IAAI,KAAK,EAAE,CAAA"}
@@ -0,0 +1,112 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.BottomSheet = void 0;
13
+ exports.bottomSheet = bottomSheet;
14
+ const Portal_1 = require("../lib/Portal");
15
+ /**
16
+ * Bottom sheet portal for bottom-sliding panels.
17
+ * Extends Portal with bottom sheet-specific wrapper, configuration and ref methods.
18
+ *
19
+ * @template Params - Custom bottom sheet parameters
20
+ * @template Result - Type of result returned by request
21
+ * @template Metadata - Additional configuration metadata
22
+ */
23
+ class BottomSheet extends Portal_1.Portal {
24
+ constructor() {
25
+ super(...arguments);
26
+ this.displayName = 'BottomSheet';
27
+ }
28
+ /** @inheritdoc */
29
+ get defaultTransitionDuration() {
30
+ return BottomSheet.DEFAULT_TRANSITION_DURATION;
31
+ }
32
+ /** @inheritdoc */
33
+ get wrapperComponent() {
34
+ return BottomSheet.WrapperComponent;
35
+ }
36
+ /** Closes all open BottomSheet instances. */
37
+ static closeAll() {
38
+ return __awaiter(this, void 0, void 0, function* () {
39
+ const registries = BottomSheet.registry.getAll();
40
+ yield Promise.all(registries.map(instance => instance.close()));
41
+ });
42
+ }
43
+ /** Returns default config: `rendersWhenHidden=true` and `resetParamsOnClose=false`. */
44
+ getDefaultConfig() {
45
+ return {
46
+ rendersWhenHidden: true,
47
+ resetParamsOnClose: false,
48
+ };
49
+ }
50
+ /** Calls the native open method on the ref via `openKeyMethod`, if configured. */
51
+ openBottomSheet() {
52
+ var _a, _b, _c, _d;
53
+ if (!!BottomSheet.openKeyMethod && !!((_a = this.ref) === null || _a === void 0 ? void 0 : _a.current)) {
54
+ (_d = (_c = (_b = this.ref) === null || _b === void 0 ? void 0 : _b.current) === null || _c === void 0 ? void 0 : _c[BottomSheet.openKeyMethod]) === null || _d === void 0 ? void 0 : _d.call(_c);
55
+ }
56
+ }
57
+ /** Calls the native close method on the ref via `closeKeyMethod`, if configured. */
58
+ closeBottomSheet() {
59
+ var _a, _b, _c, _d;
60
+ if (!!BottomSheet.closeKeyMethod && !!((_a = this.ref) === null || _a === void 0 ? void 0 : _a.current)) {
61
+ (_d = (_c = (_b = this.ref) === null || _b === void 0 ? void 0 : _b.current) === null || _c === void 0 ? void 0 : _c[BottomSheet.closeKeyMethod]) === null || _d === void 0 ? void 0 : _d.call(_c);
62
+ }
63
+ }
64
+ /** @inheritdoc — also triggers the native open animation via `openBottomSheet()`. */
65
+ handleOpen() {
66
+ this.openBottomSheet();
67
+ }
68
+ /** @inheritdoc — also triggers the native close animation via `closeBottomSheet()`. */
69
+ handleClose() {
70
+ this.closeBottomSheet();
71
+ }
72
+ /**
73
+ * Registers a callback to be called when bottom sheet opens.
74
+ * Overrides parent to ensure native open method is called.
75
+ * @param callback - Function to execute on open
76
+ * @returns The bottom sheet instance for chaining
77
+ */
78
+ onOpen(callback) {
79
+ this.handleOpen = () => {
80
+ this.openBottomSheet();
81
+ callback(this);
82
+ };
83
+ return this;
84
+ }
85
+ /**
86
+ * Registers a callback to be called when bottom sheet closes.
87
+ * Overrides parent to ensure native close method is called.
88
+ * @param callback - Function to execute on close
89
+ * @returns The bottom sheet instance for chaining
90
+ */
91
+ onClose(callback) {
92
+ this.handleClose = () => {
93
+ this.closeBottomSheet();
94
+ callback(this);
95
+ };
96
+ return this;
97
+ }
98
+ }
99
+ exports.BottomSheet = BottomSheet;
100
+ /** Wrapper component used to render bottom sheet UI. Must be assigned by the consuming app. */
101
+ BottomSheet.WrapperComponent = () => null;
102
+ /** Default transition duration in milliseconds for bottom sheet open/close animations. */
103
+ BottomSheet.DEFAULT_TRANSITION_DURATION = 200;
104
+ /**
105
+ * Factory function to create a new BottomSheet instance.
106
+ * @param idOrConfig - BottomSheet ID or configuration object
107
+ * @returns New BottomSheet instance
108
+ */
109
+ function bottomSheet(idOrConfig) {
110
+ return new BottomSheet(idOrConfig);
111
+ }
112
+ //# sourceMappingURL=bottomSheet.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bottomSheet.js","sourceRoot":"","sources":["../../src/factors/bottomSheet.ts"],"names":[],"mappings":";;;;;;;;;;;;A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C;IAED,qFAAqF;IAC3E,UAAU;QAClB,IAAI,CAAC,eAAe,EAAE,CAAA;IACxB,CAAC;IAED,uFAAuF;IAC7E,WAAW;QACnB,IAAI,CAAC,gBAAgB,EAAE,CAAA;IACzB,CAAC;IAED;;;;;OAKG;IACH,MAAM,CAAC,QAAqG;QAC1G,IAAI,CAAC,UAAU,GAAG,GAAG,EAAE;YACrB,IAAI,CAAC,eAAe,EAAE,CAAA;YACtB,QAAQ,CAAC,IAAI,CAAC,CAAA;QAChB,CAAC,CAAA;QAED,OAAO,IAAI,CAAA;IACb,CAAC;IAED;;;;;OAKG;IACH,OAAO,CAAC,QAAqG;QAC3G,IAAI,CAAC,WAAW,GAAG,GAAG,EAAE;YACtB,IAAI,CAAC,gBAAgB,EAAE,CAAA;YACvB,QAAQ,CAAC,IAAI,CAAC,CAAA;QAChB,CAAC,CAAA;QAED,OAAO,IAAI,CAAA;IACb,CAAC;;AA3FH,kCA4FC;AAzFC,+FAA+F;AACxF,4BAAgB,GAAgG,GAAG,EAAE,CAAC,IAAI,AAA1G,CAA0G;AAEjI,0FAA0F;AACnF,uCAA2B,GAAG,GAAG,AAAN,CAAM;AAuF1C;;;;GAIG;AACH,SAAgB,WAAW,CAA0C,UAAqD;IACxH,OAAO,IAAI,WAAW,CAA2B,UAAU,CAAC,CAAA;AAC9D,CAAC"}
@@ -0,0 +1,57 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.Drawer = void 0;
13
+ exports.drawer = drawer;
14
+ const Portal_1 = require("../lib/Portal");
15
+ /**
16
+ * Drawer portal for side-sliding panels.
17
+ * Extends Portal with drawer-specific wrapper and configuration.
18
+ *
19
+ * @template Params - Custom drawer parameters
20
+ * @template Result - Type of result returned by request
21
+ * @template Metadata - Additional configuration metadata
22
+ */
23
+ class Drawer extends Portal_1.Portal {
24
+ constructor() {
25
+ super(...arguments);
26
+ this.displayName = 'Drawer';
27
+ }
28
+ /** @inheritdoc */
29
+ get defaultTransitionDuration() {
30
+ return Drawer.DEFAULT_TRANSITION_DURATION;
31
+ }
32
+ /** @inheritdoc */
33
+ get wrapperComponent() {
34
+ return Drawer.WrapperComponent;
35
+ }
36
+ /** Closes all open Drawer instances. */
37
+ static closeAll() {
38
+ return __awaiter(this, void 0, void 0, function* () {
39
+ const registries = Drawer.registry.getAll();
40
+ yield Promise.all(registries.map(instance => instance.close()));
41
+ });
42
+ }
43
+ }
44
+ exports.Drawer = Drawer;
45
+ /** Wrapper component used to render drawer UI. Must be assigned by the consuming app. */
46
+ Drawer.WrapperComponent = () => null;
47
+ /** Default transition duration in milliseconds for drawer open/close animations. */
48
+ Drawer.DEFAULT_TRANSITION_DURATION = 200;
49
+ /**
50
+ * Factory function to create a new Drawer instance.
51
+ * @param idOrConfig - Drawer ID or configuration object
52
+ * @returns New Drawer instance
53
+ */
54
+ function drawer(idOrConfig) {
55
+ return new Drawer(idOrConfig);
56
+ }
57
+ //# sourceMappingURL=drawer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"drawer.js","sourceRoot":"","sources":["../../src/factors/drawer.ts"],"names":[],"mappings":";;;;;;;;;;;;AA4CA,wBAEC;AA5CD,0CAAsC;AAGtC;;;;;;;GAOG;AACH,MAAa,MAAgD,SAAQ,eAA+D;IAApI;;QACE,gBAAW,GAAG,QAAQ,CAAA;IAuBxB,CAAC;IAfC,kBAAkB;IAClB,IAAc,yBAAyB;QACrC,OAAO,MAAM,CAAC,2BAA2B,CAAA;IAC3C,CAAC;IAED,kBAAkB;IAClB,IAAc,gBAAgB;QAC5B,OAAO,MAAM,CAAC,gBAAgB,CAAA;IAChC,CAAC;IAED,wCAAwC;IACxC,MAAM,CAAO,QAAQ;;YACnB,MAAM,UAAU,GAAG,MAAM,CAAC,QAAQ,CAAC,MAAM,EAAE,CAAA;YAC3C,MAAM,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAE,CAAC,QAAQ,CAAC,KAAK,EAAE,CAAC,CAAC,CAAA;QACjE,CAAC;KAAA;;AAvBH,wBAwBC;AArBC,yFAAyF;AAClF,uBAAgB,GAAsF,GAAG,EAAE,CAAC,IAAI,AAAhG,CAAgG;AAEvH,oFAAoF;AAC7E,kCAA2B,GAAG,GAAG,AAAN,CAAM;AAmB1C;;;;GAIG;AACH,SAAgB,MAAM,CAA0C,UAAqD;IACnH,OAAO,IAAI,MAAM,CAA2B,UAAU,CAAC,CAAA;AACzD,CAAC"}
@@ -0,0 +1,57 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.Modal = void 0;
13
+ exports.modal = modal;
14
+ const Portal_1 = require("../lib/Portal");
15
+ /**
16
+ * Modal portal for centered overlay dialogs.
17
+ * Extends Portal with modal-specific wrapper and configuration.
18
+ *
19
+ * @template Params - Custom modal parameters
20
+ * @template Result - Type of result returned by request
21
+ * @template Metadata - Additional configuration metadata
22
+ */
23
+ class Modal extends Portal_1.Portal {
24
+ constructor() {
25
+ super(...arguments);
26
+ this.displayName = 'Modal';
27
+ }
28
+ /** @inheritdoc */
29
+ get defaultTransitionDuration() {
30
+ return Modal.DEFAULT_TRANSITION_DURATION;
31
+ }
32
+ /** @inheritdoc */
33
+ get wrapperComponent() {
34
+ return Modal.WrapperComponent;
35
+ }
36
+ /** Closes all open Modal instances. */
37
+ static closeAll() {
38
+ return __awaiter(this, void 0, void 0, function* () {
39
+ const registries = Modal.registry.getAll();
40
+ yield Promise.all(registries.map(instance => instance.close()));
41
+ });
42
+ }
43
+ }
44
+ exports.Modal = Modal;
45
+ /** Wrapper component used to render modal UI. Must be assigned by the consuming app. */
46
+ Modal.WrapperComponent = () => null;
47
+ /** Default transition duration in milliseconds for modal open/close animations. */
48
+ Modal.DEFAULT_TRANSITION_DURATION = 200;
49
+ /**
50
+ * Factory function to create a new Modal instance.
51
+ * @param idOrConfig - Modal ID or configuration object
52
+ * @returns New Modal instance
53
+ */
54
+ function modal(idOrConfig) {
55
+ return new Modal(idOrConfig);
56
+ }
57
+ //# sourceMappingURL=modal.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"modal.js","sourceRoot":"","sources":["../../src/factors/modal.ts"],"names":[],"mappings":";;;;;;;;;;;;AA4CA,sBAEC;AA5CD,0CAAsC;AAGtC;;;;;;;GAOG;AACH,MAAa,KAA+C,SAAQ,eAA6D;IAAjI;;QACE,gBAAW,GAAG,OAAO,CAAA;IAuBvB,CAAC;IAfC,kBAAkB;IAClB,IAAc,yBAAyB;QACrC,OAAO,KAAK,CAAC,2BAA2B,CAAA;IAC1C,CAAC;IAED,kBAAkB;IAClB,IAAc,gBAAgB;QAC5B,OAAO,KAAK,CAAC,gBAAgB,CAAA;IAC/B,CAAC;IAED,uCAAuC;IACvC,MAAM,CAAO,QAAQ;;YACnB,MAAM,UAAU,GAAG,KAAK,CAAC,QAAQ,CAAC,MAAM,EAAE,CAAA;YAC1C,MAAM,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAE,CAAC,QAAQ,CAAC,KAAK,EAAE,CAAC,CAAC,CAAA;QACjE,CAAC;KAAA;;AAvBH,sBAwBC;AArBC,wFAAwF;AACjF,sBAAgB,GAAoF,GAAG,EAAE,CAAC,IAAI,AAA9F,CAA8F;AAErH,mFAAmF;AAC5E,iCAA2B,GAAG,GAAG,AAAN,CAAM;AAmB1C;;;;GAIG;AACH,SAAgB,KAAK,CAA0C,UAAqD;IAClH,OAAO,IAAI,KAAK,CAA2B,UAAU,CAAC,CAAA;AACxD,CAAC"}
@@ -0,0 +1,4 @@
1
+ "use strict";
2
+ /* eslint-disable @typescript-eslint/no-empty-interface */
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ //# sourceMappingURL=globals.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"globals.js","sourceRoot":"","sources":["../src/globals.ts"],"names":[],"mappings":";AAAA,0DAA0D"}
package/dist/index.js ADDED
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./lib/Portal"), exports);
18
+ __exportStar(require("./lib/PortalRegistry"), exports);
19
+ __exportStar(require("./lib/PortalState"), exports);
20
+ __exportStar(require("./lib/PortalRequest"), exports);
21
+ __exportStar(require("./types/misc"), exports);
22
+ __exportStar(require("./types/portal"), exports);
23
+ __exportStar(require("./utils"), exports);
24
+ // export * from './lib/modalFlow'
25
+ __exportStar(require("./factors/alert"), exports);
26
+ __exportStar(require("./factors/modal"), exports);
27
+ __exportStar(require("./factors/bottomSheet"), exports);
28
+ __exportStar(require("./factors/drawer"), exports);
29
+ __exportStar(require("./globals"), exports);
30
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,+CAA4B;AAC5B,uDAAoC;AACpC,oDAAiC;AACjC,sDAAmC;AACnC,+CAA4B;AAC5B,iDAA8B;AAC9B,0CAAuB;AACvB,kCAAkC;AAClC,kDAA+B;AAC/B,kDAA+B;AAC/B,wDAAqC;AACrC,mDAAgC;AAChC,4CAAyB"}
@@ -11,7 +11,7 @@ type IAtom<T> = ReturnType<typeof atom<T>>;
11
11
  * Drives `GlobalOutlet` re-renders when portals are added or removed (including ephemeral ones).
12
12
  * Read-only outside of portal lifecycle code — mutate only via `Portal` constructor/`onVisibilityChanged`.
13
13
  */
14
- export declare const registeredIds: import("nanostores").PreinitializedWritableAtom<string[]> & object;
14
+ export declare const registeredIds: import("nanostores", { with: { "resolution-mode": "import" } }).PreinitializedWritableAtom<string[]> & object;
15
15
  /**
16
16
  * Base class for creating portals (modal, drawer, bottom sheet, etc).
17
17
  * Manages state, visibility, params and lifecycle of floating components.
@@ -1 +1 @@
1
- {"version":3,"file":"Portal.d.ts","sourceRoot":"","sources":["../../src/lib/Portal.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,GAAG,EAAmB,MAAM,OAAO,CAAA;AACnD,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAA;AAEjC,OAAO,EAAE,SAAS,EAAc,MAAM,iB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;;;;OAIG;IACH,QAAQ,CAAC,KAAK,EAAE,YAAY,EAAE,IAAI,GAAE,KAAK,CAAC,cAAmB;IAS7D;;;OAGG;IACH,QAAQ;;;;IAUR,8DAA8D;IAC9D,IAAI,iBAAiB,YAEpB;IAED;;;;OAIG;IACH,SAAS,CAAC,KAAK,CAAC,EAAE,MAAM,GAAG;QAAE,WAAW,CAAC,EAAE,YAAY,CAAA;KAAE,GAAG,GAAG,CAAC,OAAO,GAAG,IAAI;IA6D9E;;;;;OAKG;IACH,OAAO,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,KAAK,UAAQ;IAItC;;;OAGG;IACH,MAAM,CAAC,QAAQ;IASf;;;;OAIG;IACH,MAAM,CAAC,YAAY;CAKpB"}
@@ -0,0 +1,295 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ var __rest = (this && this.__rest) || function (s, e) {
36
+ var t = {};
37
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
38
+ t[p] = s[p];
39
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
40
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
41
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
42
+ t[p[i]] = s[p[i]];
43
+ }
44
+ return t;
45
+ };
46
+ Object.defineProperty(exports, "__esModule", { value: true });
47
+ exports.Portal = exports.registeredIds = void 0;
48
+ const react_1 = __importStar(require("react"));
49
+ const nanostores_1 = require("nanostores");
50
+ const react_2 = require("@nanostores/react");
51
+ const types_1 = require("@codeleap/types");
52
+ const logger_1 = require("@codeleap/logger");
53
+ const utils_1 = require("../utils");
54
+ const PortalRegistry_1 = require("./PortalRegistry");
55
+ const PortalState_1 = require("./PortalState");
56
+ const PortalRequest_1 = require("./PortalRequest");
57
+ /**
58
+ * Nanostores atom holding the IDs of all currently registered portals in creation order.
59
+ * Drives `GlobalOutlet` re-renders when portals are added or removed (including ephemeral ones).
60
+ * Read-only outside of portal lifecycle code — mutate only via `Portal` constructor/`onVisibilityChanged`.
61
+ */
62
+ exports.registeredIds = (0, nanostores_1.atom)([]);
63
+ /**
64
+ * Base class for creating portals (modal, drawer, bottom sheet, etc).
65
+ * Manages state, visibility, params and lifecycle of floating components.
66
+ *
67
+ * @template Params - Custom portal parameters
68
+ * @template Result - Type of result returned by request
69
+ * @template Metadata - Additional configuration metadata
70
+ * @template RefType - Type of wrapper component ref
71
+ * @template WrapperProps - Props for wrapper component
72
+ */
73
+ class Portal extends PortalState_1.PortalState {
74
+ getDefaultConfig() {
75
+ return {};
76
+ }
77
+ get registry() {
78
+ return Portal.registry;
79
+ }
80
+ get idGenerator() {
81
+ return Portal.generateId;
82
+ }
83
+ get defaultTransitionDuration() {
84
+ return null;
85
+ }
86
+ get wrapperComponent() {
87
+ return null;
88
+ }
89
+ /**
90
+ * Sets the render function for portal content.
91
+ * @param render - Function that renders the portal content
92
+ * @returns The portal instance for chaining
93
+ */
94
+ content(render) {
95
+ this.RenderContent = render;
96
+ return this;
97
+ }
98
+ /** Gets the resolve handler for the pending request. */
99
+ get resolve() {
100
+ return this.requestHandler.resolve;
101
+ }
102
+ /** Gets the reject handler for the pending request. */
103
+ get reject() {
104
+ return this.requestHandler.reject;
105
+ }
106
+ onVisibilityChanged(visible, wasVisible) {
107
+ var _a, _b;
108
+ if (this._config.independent) {
109
+ return;
110
+ }
111
+ if (visible) {
112
+ this.registry.push(this.id);
113
+ }
114
+ else {
115
+ if (wasVisible && !visible) {
116
+ if (this.hasPendingRequest) {
117
+ (_b = (_a = this.requestHandler).resolve) === null || _b === void 0 ? void 0 : _b.call(_a, undefined);
118
+ this.requestHandler.clearRequest();
119
+ }
120
+ if (this._config.ephemeral) {
121
+ this.registry.unregister(this.id);
122
+ exports.registeredIds.set(exports.registeredIds.get().filter(id => id !== this.id));
123
+ return;
124
+ }
125
+ }
126
+ this.registry.remove(this.id);
127
+ }
128
+ }
129
+ /** Gets the z-index position of the portal in the registry stack. */
130
+ get stackIndex() {
131
+ return this.registry.getStackIndex(this.id);
132
+ }
133
+ /**
134
+ * Creates a new portal instance.
135
+ * @param idOrConfig - Portal ID string or configuration object with optional id field
136
+ */
137
+ constructor(idOrConfig) {
138
+ super();
139
+ this.displayName = 'Portal';
140
+ const id = types_1.TypeGuards.isString(idOrConfig) ? idOrConfig : idOrConfig === null || idOrConfig === void 0 ? void 0 : idOrConfig.id;
141
+ const config = types_1.TypeGuards.isObject(idOrConfig) ? idOrConfig : {};
142
+ this._config = Object.assign(Object.assign({ initialParams: {}, startsOpen: false, independent: false, rendersWhenHidden: false, metadata: {}, resetParamsOnClose: true, transitionDuration: this.constructor.DEFAULT_TRANSITION_DURATION }, this.getDefaultConfig()), config);
143
+ this.initializeState({
144
+ initialParams: this._config.initialParams,
145
+ startsOpen: this._config.startsOpen,
146
+ resetParamsOnClose: this._config.resetParamsOnClose,
147
+ transitionDuration: this._config.transitionDuration,
148
+ });
149
+ this.id = id !== null && id !== void 0 ? id : this.idGenerator();
150
+ this.requestHandler = new PortalRequest_1.PortalRequest(this.open.bind(this), this.close.bind(this));
151
+ this._wrapperProps = (0, nanostores_1.atom)({});
152
+ this.ref = react_1.default.createRef();
153
+ this.registry.register(this.id, this);
154
+ exports.registeredIds.set([...exports.registeredIds.get(), this.id]);
155
+ this.subscribe((visible, wasVisible) => {
156
+ this.onVisibilityChanged(visible, wasVisible);
157
+ });
158
+ this.Component = this.Component.bind(this);
159
+ this.useState = this.useState.bind(this);
160
+ this.useProps = this.useProps.bind(this);
161
+ this.toggle = this.toggle.bind(this);
162
+ this.open = this.open.bind(this);
163
+ this.close = this.close.bind(this);
164
+ this.setParams = this.setParams.bind(this);
165
+ this.resetParams = this.resetParams.bind(this);
166
+ this.getParams = this.getParams.bind(this);
167
+ this.request = this.request.bind(this);
168
+ this.assertInitialized = this.assertInitialized.bind(this);
169
+ }
170
+ /**
171
+ * Registers a callback to be called when portal closes.
172
+ * @param callback - Function to execute on close
173
+ * @returns The portal instance for chaining
174
+ */
175
+ onClose(callback) {
176
+ this.handleClose = () => callback(this);
177
+ return this;
178
+ }
179
+ /**
180
+ * Registers a callback to be called when portal opens.
181
+ * @param callback - Function to execute on open
182
+ * @returns The portal instance for chaining
183
+ */
184
+ onOpen(callback) {
185
+ this.handleOpen = () => callback(this);
186
+ return this;
187
+ }
188
+ /**
189
+ * Sets wrapper component props. Can be static or a function based on params.
190
+ * @param props - Props object or function that returns props
191
+ * @returns The portal instance for chaining
192
+ */
193
+ props(props) {
194
+ if (types_1.TypeGuards.isFunction(props)) {
195
+ this._lazyWrapperProps = props;
196
+ }
197
+ else {
198
+ this._wrapperProps.set(props);
199
+ }
200
+ return this;
201
+ }
202
+ /**
203
+ * React hook to update wrapper props with dependency tracking.
204
+ * @param props - Props to merge with existing wrapper props
205
+ * @param deps - Dependency array for effect
206
+ */
207
+ useProps(props, deps = []) {
208
+ (0, react_1.useLayoutEffect)(() => {
209
+ this._wrapperProps.set(Object.assign(Object.assign({}, this._wrapperProps.get()), props));
210
+ }, deps);
211
+ }
212
+ /**
213
+ * React hook to access portal state (visibility and params).
214
+ * @returns Object with visible and params state
215
+ */
216
+ useState() {
217
+ const { visible: visibleStore, params: paramsStore } = this.assertInitialized();
218
+ const visible = (0, react_2.useStore)(visibleStore);
219
+ const params = (0, react_2.useStore)(paramsStore);
220
+ return { visible, params };
221
+ }
222
+ /** Whether there is a pending request awaiting resolution. */
223
+ get hasPendingRequest() {
224
+ return this.requestHandler.hasPendingRequest;
225
+ }
226
+ /**
227
+ * Renders the portal component. Use this as a React component.
228
+ * @param props - Combined params and wrapper props
229
+ * @returns JSX element with portal content wrapped in wrapper component
230
+ */
231
+ Component(props) {
232
+ var _a;
233
+ const { visible, params } = this.useState();
234
+ const wrapperProps = (0, react_2.useStore)(this._wrapperProps);
235
+ const _b = props || {}, { portalProps = {} } = _b, propParams = __rest(_b, ["portalProps"]);
236
+ const [mounted, setMounted] = react_1.default.useState(visible);
237
+ react_1.default.useEffect(() => {
238
+ var _a, _b;
239
+ if (visible) {
240
+ setMounted(true);
241
+ return;
242
+ }
243
+ const timer = setTimeout(() => setMounted(false), (_b = (_a = this._config) === null || _a === void 0 ? void 0 : _a.transitionDuration) !== null && _b !== void 0 ? _b : 0);
244
+ return () => clearTimeout(timer);
245
+ }, [visible]);
246
+ const Content = this.RenderContent;
247
+ if (!Content) {
248
+ logger_1.logger.warn(`${this.displayName} ${this.id} has no content. Did you forget to call .content()?`);
249
+ return null;
250
+ }
251
+ if (!visible && !mounted && !((_a = this._config) === null || _a === void 0 ? void 0 : _a.rendersWhenHidden))
252
+ return null;
253
+ const request = this.requestHandler.getRequestHandlers();
254
+ const lazyWrapperProps = (this === null || this === void 0 ? void 0 : this._lazyWrapperProps) ? this._lazyWrapperProps(params) : {};
255
+ const WrapperComponent = this.wrapperComponent;
256
+ return react_1.default.createElement(WrapperComponent, Object.assign({}, this._config, this._wrapperProps, portalProps, wrapperProps, lazyWrapperProps, { close: this.close, open: this.open, visible: visible, toggle: this.toggle, zIndex: this.stackIndex, ref: this.ref }),
257
+ react_1.default.createElement(Content, Object.assign({ visible: visible, toggle: this.toggle, close: this.close, open: this.open, setParams: this.setParams }, params, (propParams !== null && propParams !== void 0 ? propParams : {}), { request: this.hasPendingRequest ? request : undefined, nextOrToggle: this.toggle, previousOrToggle: this.toggle, ref: this.ref })));
258
+ }
259
+ /**
260
+ * Creates a request promise that resolves when portal is closed with result.
261
+ * @param params - Parameters to pass to the portal
262
+ * @param force - Force new request even if one is pending
263
+ * @returns Promise that resolves with portal result
264
+ */
265
+ request(params, force = false) {
266
+ return this.requestHandler.request(params, force);
267
+ }
268
+ /**
269
+ * Resets all registered portals to their closed initial state.
270
+ * Useful in test afterEach hooks to prevent state leaking between tests.
271
+ */
272
+ static resetAll() {
273
+ Portal.registry.getAll().forEach(portal => {
274
+ var _a, _b;
275
+ (_a = portal.visible) === null || _a === void 0 ? void 0 : _a.set(false);
276
+ if (portal._initialParams !== undefined) {
277
+ (_b = portal.params) === null || _b === void 0 ? void 0 : _b.set(portal._initialParams);
278
+ }
279
+ });
280
+ }
281
+ /**
282
+ * Global outlet component that renders all non-independent portals.
283
+ * Place this once in your app root.
284
+ * @returns JSX element rendering all registered portals
285
+ */
286
+ static GlobalOutlet() {
287
+ (0, react_2.useStore)(exports.registeredIds);
288
+ const portals = Portal.registry.filter(p => { var _a; return !((_a = p._config) === null || _a === void 0 ? void 0 : _a.independent); });
289
+ return react_1.default.createElement(react_1.default.Fragment, null, portals.map(portal => react_1.default.createElement(portal.Component, { key: portal.id })));
290
+ }
291
+ }
292
+ exports.Portal = Portal;
293
+ Portal.registry = new PortalRegistry_1.PortalRegistry();
294
+ Portal.generateId = utils_1.randomId;
295
+ //# sourceMappingURL=Portal.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Portal.js","sourceRoot":"","sources":["../../src/lib/Portal.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+CAAmD;AACnD,2CAAiC;AACjC,6CAA4C;AAC5C,2CAAuD;AACvD,6CAAyC;AACzC,oCAAmC;AAEnC,qDAAiD;AACjD,+CAA2C;AAC3C,mDAA+C;AAI/C;;;;GAIG;AACU,QAAA,aAAa,GAAG,IAAA,iBAAI,EAAW,EAAE,CAAC,CAAA;AAE/C;;;;;;;;;GASG;AACH,MAAa,MAAyF,SAAQ,yBAAmB;IAqBrH,gBAAgB;QACxB,OAAO,EAAE,CAAA;IACX,CAAC;IAED,IAAc,QAAQ;QACpB,OAAO,MAAM,CAAC,QAAQ,CAAA;IACxB,CAAC;IAED,IAAc,WAAW;QACvB,OAAO,MAAM,CAAC,UAAU,CAAA;IAC1B,CAAC;IAED,IAAc,yBAAyB;QACrC,OAAO,IAAI,CAAA;IACb,CAAC;IAED,IAAc,gBAAgB;QAC5B,OAAO,IAAI,CAAA;IACb,CAAC;IAED;;;;OAIG;IACH,OAAO,CAAC,MAAoD;QAC1D,IAAI,CAAC,aAAa,GAAG,MAAM,CAAA;QAC3B,OAAO,IAAI,CAAA;IACb,CAAC;IAED,wDAAwD;IACxD,IAAI,OAAO;QACT,OAAO,IAAI,CAAC,cAAc,CAAC,OAAO,CAAA;IACpC,CAAC;IAED,uDAAuD;IACvD,IAAI,MAAM;QACR,OAAO,IAAI,CAAC,cAAc,CAAC,MAAM,CAAA;IACnC,CAAC;IAEO,mBAAmB,CAAC,OAAgB,EAAE,UAAoB;;QAChE,IAAI,IAAI,CAAC,OAAO,CAAC,WAAW,EAAE,CAAC;YAC7B,OAAM;QACR,CAAC;QAED,IAAI,OAAO,EAAE,CAAC;YACZ,IAAI,CAAC,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,CAAA;YAClD,CAAC;QACH,CAAC,CAAC,CAAA;IACJ,CAAC;IAED;;;;OAIG;IACH,MAAM,CAAC,YAAY;QACjB,IAAA,gBAAQ,EAAC,qBAAa,CAAC,CAAA;QACvB,MAAM,OAAO,GAAG,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,WAAC,OAAA,CAAC,CAAA,MAAA,CAAC,CAAC,OAAO,0CAAE,WAAW,CAAA,CAAA,EAAA,CAAC,CAAA;QACpE,OAAO,8DAAG,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,8BAAC,MAAM,CAAC,SAAS,IAAC,GAAG,EAAE,MAAM,CAAC,EAAE,GAAI,CAAC,CAAI,CAAA;IAC3E,CAAC;;AA5TH,wBA6TC;AA5SQ,eAAQ,GAAG,IAAI,+BAAc,EAAyB,AAA9C,CAA8C;AAEtD,iBAAU,GAAG,gBAAQ,AAAX,CAAW"}
@@ -0,0 +1,88 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PortalRegistry = void 0;
4
+ /**
5
+ * Registry for managing portal instances and their stacking order.
6
+ * Maintains a registry of portals by ID and tracks their z-index stack.
7
+ *
8
+ * @template T - Type of portal instances to manage
9
+ */
10
+ class PortalRegistry {
11
+ constructor() {
12
+ this.registry = {};
13
+ this.stack = [];
14
+ }
15
+ /**
16
+ * Registers a portal instance with an ID.
17
+ * @param id - Unique identifier for the portal
18
+ * @param instance - Portal instance to register
19
+ */
20
+ register(id, instance) {
21
+ this.registry[id] = instance;
22
+ }
23
+ /**
24
+ * Unregisters a portal and removes it from the stack.
25
+ * @param id - Portal ID to unregister
26
+ */
27
+ unregister(id) {
28
+ delete this.registry[id];
29
+ this.remove(id);
30
+ }
31
+ /**
32
+ * Retrieves a portal instance by ID.
33
+ * @param id - Portal ID to retrieve
34
+ * @returns Portal instance or undefined
35
+ */
36
+ getInstance(id) {
37
+ return this.registry[id];
38
+ }
39
+ /**
40
+ * Adds a portal ID to the top of the stack.
41
+ * @param id - Portal ID to push
42
+ */
43
+ push(id) {
44
+ this.stack.push(id);
45
+ }
46
+ /**
47
+ * Removes a portal ID from the stack and all portals above it.
48
+ * @param id - Portal ID to remove
49
+ */
50
+ remove(id) {
51
+ const index = this.stack.indexOf(id);
52
+ if (index > -1) {
53
+ this.stack = this.stack.slice(0, index);
54
+ }
55
+ }
56
+ /**
57
+ * Gets the stack index (z-index position) of a portal.
58
+ * @param id - Portal ID to find
59
+ * @returns Stack index or -1 if not found
60
+ */
61
+ getStackIndex(id) {
62
+ return this.stack.indexOf(id);
63
+ }
64
+ /**
65
+ * Retrieves all registered portal instances.
66
+ * @returns Array of all portal instances
67
+ */
68
+ getAll() {
69
+ return Object.values(this.registry);
70
+ }
71
+ /**
72
+ * Filters portal instances by predicate function.
73
+ * @param predicate - Function to test each instance
74
+ * @returns Filtered array of portal instances
75
+ */
76
+ filter(predicate) {
77
+ return this.getAll().filter(predicate);
78
+ }
79
+ /**
80
+ * Clears all portals from registry and stack.
81
+ */
82
+ clear() {
83
+ this.registry = {};
84
+ this.stack = [];
85
+ }
86
+ }
87
+ exports.PortalRegistry = PortalRegistry;
88
+ //# sourceMappingURL=PortalRegistry.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PortalRegistry.js","sourceRoot":"","sources":["../../src/lib/PortalRegistry.ts"],"names":[],"mappings":";;;AAAA;;;;;GAKG;AACH,MAAa,cAAc;IAA3B;QACU,aAAQ,GAAsB,EAAE,CAAA;QAEhC,UAAK,GAAa,EAAE,CAAA;IAiF9B,CAAC;IA/EC;;;;OAIG;IACH,QAAQ,CAAC,EAAU,EAAE,QAAW;QAC9B,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC,GAAG,QAAQ,CAAA;IAC9B,CAAC;IAED;;;OAGG;IACH,UAAU,CAAC,EAAU;QACnB,OAAO,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAA;QACxB,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,CAAA;IACjB,CAAC;IAED;;;;OAIG;IACH,WAAW,CAAC,EAAU;QACpB,OAAO,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAA;IAC1B,CAAC;IAED;;;OAGG;IACH,IAAI,CAAC,EAAU;QACb,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;IACrB,CAAC;IAED;;;OAGG;IACH,MAAM,CAAC,EAAU;QACf,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,EAAE,CAAC,CAAA;QACpC,IAAI,KAAK,GAAG,CAAC,CAAC,EAAE,CAAC;YACf,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC,CAAA;QACzC,CAAC;IACH,CAAC;IAED;;;;OAIG;IACH,aAAa,CAAC,EAAU;QACtB,OAAO,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,EAAE,CAAC,CAAA;IAC/B,CAAC;IAED;;;OAGG;IACH,MAAM;QACJ,OAAO,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAA;IACrC,CAAC;IAED;;;;OAIG;IACH,MAAM,CAAC,SAAmC;QACxC,OAAO,IAAI,CAAC,MAAM,EAAE,CAAC,MAAM,CAAC,SAAS,CAAC,CAAA;IACxC,CAAC;IAED;;OAEG;IACH,KAAK;QACH,IAAI,CAAC,QAAQ,GAAG,EAAE,CAAA;QAClB,IAAI,CAAC,KAAK,GAAG,EAAE,CAAA;IACjB,CAAC;CACF;AApFD,wCAoFC"}
@@ -0,0 +1,73 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PortalRequest = void 0;
4
+ /**
5
+ * Handles promise-based portal requests with resolve/reject semantics.
6
+ * Manages the async flow of opening a portal and waiting for a result.
7
+ *
8
+ * @template Params - Parameters for opening the portal
9
+ * @template Result - Type of result returned when request resolves
10
+ */
11
+ class PortalRequest {
12
+ /**
13
+ * Creates a portal request handler.
14
+ * @param onOpen - Function to call when opening portal
15
+ * @param onClose - Function to call when closing portal
16
+ */
17
+ constructor(onOpen, onClose) {
18
+ this.onOpen = onOpen;
19
+ this.onClose = onClose;
20
+ }
21
+ /**
22
+ * Checks if there's a pending request waiting for resolution.
23
+ * @returns True if request is pending
24
+ */
25
+ get hasPendingRequest() {
26
+ return !!this.resolve && !!this.reject;
27
+ }
28
+ /**
29
+ * Creates a new request promise that opens the portal and waits for result.
30
+ * @param params - Parameters to pass when opening portal
31
+ * @param force - Force new request even if one is pending
32
+ * @returns Promise that resolves with portal result
33
+ */
34
+ request(params, force = false) {
35
+ if (this.hasPendingRequest && !force) {
36
+ return Promise.reject(new Error('This portal already has a pending request'));
37
+ }
38
+ return new Promise((resolve, reject) => {
39
+ const onResolve = (result) => {
40
+ resolve(result);
41
+ this.onClose();
42
+ this.clearRequest();
43
+ };
44
+ const onReject = (reason) => {
45
+ reject(reason);
46
+ this.onClose();
47
+ this.clearRequest();
48
+ };
49
+ this.resolve = onResolve;
50
+ this.reject = onReject;
51
+ this.onOpen(params);
52
+ });
53
+ }
54
+ /**
55
+ * Clears the current request resolve/reject handlers.
56
+ */
57
+ clearRequest() {
58
+ this.resolve = undefined;
59
+ this.reject = undefined;
60
+ }
61
+ /**
62
+ * Gets the current request handlers for resolve and reject.
63
+ * @returns Object with resolve and reject functions
64
+ */
65
+ getRequestHandlers() {
66
+ return {
67
+ resolve: this.resolve,
68
+ reject: this.reject,
69
+ };
70
+ }
71
+ }
72
+ exports.PortalRequest = PortalRequest;
73
+ //# sourceMappingURL=PortalRequest.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PortalRequest.js","sourceRoot":"","sources":["../../src/lib/PortalRequest.ts"],"names":[],"mappings":";;;AAAA;;;;;;GAMG;AACH,MAAa,aAAa;IASxB;;;;OAIG;IACH,YACE,MAA0C,EAC1C,OAA4B;QAE5B,IAAI,CAAC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CAAC,MAAM;SACpB,CAAA;IACH,CAAC;CACF;AA/ED,sCA+EC"}
@@ -26,8 +26,8 @@ export declare class PortalState<Params = {}> {
26
26
  * @throws Error if `initializeState()` has not been called yet
27
27
  */
28
28
  assertInitialized(): {
29
- visible: import("nanostores").PreinitializedWritableAtom<boolean> & object;
30
- params: import("nanostores").PreinitializedWritableAtom<Params> & object;
29
+ visible: import("nanostores", { with: { "resolution-mode": "import" } }).PreinitializedWritableAtom<boolean> & object;
30
+ params: import("nanostores", { with: { "resolution-mode": "import" } }).PreinitializedWritableAtom<Params> & object;
31
31
  config: PortalStateConfig<Params>;
32
32
  initialParams: Params & ({} | null);
33
33
  };
@@ -0,0 +1,172 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.PortalState = void 0;
13
+ const nanostores_1 = require("nanostores");
14
+ const types_1 = require("@codeleap/types");
15
+ const utils_1 = require("../utils");
16
+ function initAtomWithPromise(a, promise) {
17
+ (0, nanostores_1.onMount)(a, () => {
18
+ (0, nanostores_1.task)(() => __awaiter(this, void 0, void 0, function* () {
19
+ a.set(yield promise);
20
+ }));
21
+ });
22
+ }
23
+ /**
24
+ * Manages portal visibility and parameter state with nanostores.
25
+ * Handles opening, closing, toggling and parameter updates.
26
+ *
27
+ * @template Params - Type of parameters managed by the state
28
+ */
29
+ class PortalState {
30
+ /**
31
+ * Asserts the portal state has been initialized and returns the initialized stores.
32
+ * @throws Error if `initializeState()` has not been called yet
33
+ */
34
+ assertInitialized() {
35
+ if (!this.visible || !this.params || !this.config || this._initialParams === undefined) {
36
+ throw new Error('PortalState has not been initialized. Call initializeState() first.');
37
+ }
38
+ return {
39
+ visible: this.visible,
40
+ params: this.params,
41
+ config: this.config,
42
+ initialParams: this._initialParams,
43
+ };
44
+ }
45
+ /**
46
+ * Initializes the portal state with configuration.
47
+ * @param config - Configuration for initial state, visibility and params
48
+ */
49
+ initializeState(config) {
50
+ var _a;
51
+ this.config = config;
52
+ const initialVisible = types_1.TypeGuards.isBoolean(config.startsOpen) ? config.startsOpen : false;
53
+ const initialParams = types_1.TypeGuards.isFunction(config.initialParams)
54
+ ? {}
55
+ : ((_a = config.initialParams) !== null && _a !== void 0 ? _a : {});
56
+ this._initialParams = initialParams;
57
+ this.visible = (0, nanostores_1.atom)(initialVisible);
58
+ this.params = (0, nanostores_1.atom)(initialParams);
59
+ if (types_1.TypeGuards.isFunction(config.startsOpen)) {
60
+ initAtomWithPromise(this.visible, config.startsOpen());
61
+ }
62
+ if (types_1.TypeGuards.isFunction(config.initialParams)) {
63
+ initAtomWithPromise(this.params, config.initialParams().then(p => {
64
+ this._initialParams = p;
65
+ return p;
66
+ }));
67
+ }
68
+ }
69
+ /** Gets the current visibility state. */
70
+ get isVisible() {
71
+ const { visible } = this.assertInitialized();
72
+ return visible.get();
73
+ }
74
+ /** Gets the current parameter values. */
75
+ get currentParams() {
76
+ const { params } = this.assertInitialized();
77
+ return params.get();
78
+ }
79
+ awaitTransition(count = 1) {
80
+ const { config } = this.assertInitialized();
81
+ return (0, utils_1.awaitTransition)(count, config.transitionDuration);
82
+ }
83
+ /** Lifecycle hook called after the portal opens. Override in subclasses to run custom logic. */
84
+ handleOpen() { }
85
+ /**
86
+ * Opens the portal with optional parameters.
87
+ * @param params - Parameters to merge with current params
88
+ */
89
+ open(params) {
90
+ return __awaiter(this, void 0, void 0, function* () {
91
+ const { visible, params: paramsAtom } = this.assertInitialized();
92
+ if (visible.get()) {
93
+ return;
94
+ }
95
+ if (params) {
96
+ paramsAtom.set(Object.assign(Object.assign({}, paramsAtom.get()), params));
97
+ }
98
+ visible.set(true);
99
+ yield this.awaitTransition();
100
+ this.handleOpen();
101
+ });
102
+ }
103
+ /** Lifecycle hook called after the portal closes. Override in subclasses to run custom logic. */
104
+ handleClose() { }
105
+ /**
106
+ * Closes the portal and optionally resets parameters.
107
+ */
108
+ close() {
109
+ return __awaiter(this, void 0, void 0, function* () {
110
+ const { visible, config } = this.assertInitialized();
111
+ if (!visible.get()) {
112
+ return this.awaitTransition();
113
+ }
114
+ visible.set(false);
115
+ if (config.resetParamsOnClose) {
116
+ setTimeout(() => {
117
+ this.resetParams();
118
+ }, 1000);
119
+ }
120
+ this.handleClose();
121
+ yield this.awaitTransition();
122
+ });
123
+ }
124
+ /**
125
+ * Toggles portal visibility (opens if closed, closes if open).
126
+ */
127
+ toggle() {
128
+ const { visible } = this.assertInitialized();
129
+ if (visible.get()) {
130
+ return this.close();
131
+ }
132
+ else {
133
+ return this.open();
134
+ }
135
+ }
136
+ /**
137
+ * Updates portal parameters by merging with current params.
138
+ * @param next - Partial params or updater function
139
+ */
140
+ setParams(next) {
141
+ const { params } = this.assertInitialized();
142
+ const prev = params.get();
143
+ const patch = types_1.TypeGuards.isFunction(next) ? next(prev) : next;
144
+ params.set(Object.assign(Object.assign({}, prev), patch));
145
+ }
146
+ /**
147
+ * Resets parameters to initial values.
148
+ */
149
+ resetParams() {
150
+ const { params, initialParams } = this.assertInitialized();
151
+ params.set(initialParams);
152
+ }
153
+ /**
154
+ * Gets current parameter values.
155
+ * @returns Current params object
156
+ */
157
+ getParams() {
158
+ const { params } = this.assertInitialized();
159
+ return params.get();
160
+ }
161
+ /**
162
+ * Subscribes to visibility changes.
163
+ * @param callback - Function called when visibility changes
164
+ * @returns Unsubscribe function
165
+ */
166
+ subscribe(callback) {
167
+ const { visible } = this.assertInitialized();
168
+ return visible.subscribe(callback);
169
+ }
170
+ }
171
+ exports.PortalState = PortalState;
172
+ //# sourceMappingURL=PortalState.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PortalState.js","sourceRoot":"","sources":["../../src/lib/PortalState.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2CAAgD;AAChD,2CAA4C;AAC5C,oCAA0C;AAI1C,SAAS,mBAAmB,CAAI,CAAW,EAAE,OAAmB;IAC9D,IAAA,oBAAO,EAAC,CAAC,EAAE,GAAG,EAAE;QACd,IAAA,iBAAI,EAAC,GAAS,EAAE;YACd,CAAC,CAAC,GAAG,CAAC,MAAM,OAAO,CAAC,CAAA;QACtB,CAAC,CAAA,CAAC,CAAA;IACJ,CAAC,CAAC,CAAA;AACJ,CAAC;AAUD;;;;;GAKG;AACH,MAAa,WAAW;IAYtB;;;OAGG;IACH,iBAAiB;QACf,IAAI,CAAC,IAAI,CAAC,OAAO,IAAI,CAAC,IAAI,CAAC,MAAM,IAAI,CAAC,IAAI,CAAC,MAAM,IAAI,IAAI,CAAC,cAAc,KAAK,SAAS,EAAE,CAAC;YACvF,MAAM,IAAI,KAAK,CAAC,qEAAqE,CAAC,CAAA;QACxF,CAAC;QACD,OAAO;YACL,OAAO,EAAE,IAAI,CAAC,OAAO;YACrB,MAAM,EAAE,IAAI,CAAC,MAAM;YACnB,MAAM,EAAE,IAAI,CAAC,MAAM;YACnB,aAAa,EAAE,IAAI,CAAC,cAAc;SACnC,CAAA;IACH,CAAC;IAED;;;OAGG;IACH,eAAe,CAAC,MAAiC;;QAC/C,IAAI,CAAC,MAAM,GAAG,MAAM,CAAA;QAEpB,MAAM,cAAc,GAAG,kBAAU,CAAC,SAAS,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,CAAC,KAAK,CAAA;QAC1F,MAAM,aAAa,GAAG,kBAAU,CAAC,UAAU,CAAC,MAAM,CAAC,aAAa,CAAC;YAC/D,CAAC,CAAC,EAAY;YACd,CAAC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B,CAAC;aAAM,CAAC;YACN,OAAO,IAAI,CAAC,IAAI,EAAE,CAAA;QACpB,CAAC;IACH,CAAC;IAED;;;OAGG;IACH,SAAS,CAAC,IAA2D;QACnE,MAAM,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC,iBAAiB,EAAE,CAAA;QAC3C,MAAM,IAAI,GAAG,MAAM,CAAC,GAAG,EAAE,CAAA;QAEzB,MAAM,KAAK,GAAG,kBAAU,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAA;QAE7D,MAAM,CAAC,GAAG,iCACL,IAAI,GACJ,KAAK,EACR,CAAA;IACJ,CAAC;IAED;;OAEG;IACH,WAAW;QACT,MAAM,EAAE,MAAM,EAAE,aAAa,EAAE,GAAG,IAAI,CAAC,iBAAiB,EAAE,CAAA;QAC1D,MAAM,CAAC,GAAG,CAAC,aAAa,CAAC,CAAA;IAC3B,CAAC;IAED;;;OAGG;IACH,SAAS;QACP,MAAM,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC,iBAAiB,EAAE,CAAA;QAC3C,OAAO,MAAM,CAAC,GAAG,EAAE,CAAA;IACrB,CAAC;IAED;;;;OAIG;IACH,SAAS,CAAC,QAA0D;QAClE,MAAM,EAAE,OAAO,EAAE,GAAG,IAAI,CAAC,iBAAiB,EAAE,CAAA;QAC5C,OAAO,OAAO,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAA;IACpC,CAAC;CACF;AAvLD,kCAuLC"}
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./portal"), exports);
18
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2CAAwB"}
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=misc.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"misc.js","sourceRoot":"","sources":["../../src/types/misc.ts"],"names":[],"mappings":""}
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=portal.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"portal.js","sourceRoot":"","sources":["../../src/types/portal.ts"],"names":[],"mappings":""}
package/dist/utils.js ADDED
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.randomId = void 0;
13
+ exports.awaitTransition = awaitTransition;
14
+ const utils_1 = require("@codeleap/utils");
15
+ /**
16
+ * Generates a random 7-character alphanumeric ID.
17
+ * @returns Random ID string
18
+ */
19
+ const randomId = () => {
20
+ return Math.random().toString(36).slice(2, 9);
21
+ };
22
+ exports.randomId = randomId;
23
+ /**
24
+ * Waits for one or more animation transitions to complete.
25
+ * @param count - Number of transitions to wait for (defaults to 1)
26
+ * @param duration - Duration per transition in milliseconds (defaults to 1000)
27
+ */
28
+ function awaitTransition(count_1) {
29
+ return __awaiter(this, arguments, void 0, function* (count, duration = 1000) {
30
+ for (let i = 0; i < (count !== null && count !== void 0 ? count : 1); i++) {
31
+ yield (0, utils_1.waitFor)(duration);
32
+ }
33
+ });
34
+ }
35
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":";;;;;;;;;;;;AAeA,0CAIC;AAnBD,2CAAyC;AAEzC;;;GAGG;AACI,MAAM,QAAQ,GAAG,GAAG,EAAE;IAC3B,OAAO,IAAI,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAA;AAC/C,CAAC,CAAA;AAFY,QAAA,QAAQ,YAEpB;AAED;;;;GAIG;AACH,SAAsB,eAAe;yDAAC,KAAc,EAAE,QAAQ,GAAG,IAAI;QACnE,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,KAAK,aAAL,KAAK,cAAL,KAAK,GAAI,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;YACtC,MAAM,IAAA,eAAO,EAAC,QAAQ,CAAC,CAAA;QACzB,CAAC;IACH,CAAC;CAAA"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@codeleap/portals",
3
- "version": "7.0.0",
4
- "main": "src/index.ts",
3
+ "version": "7.0.2",
4
+ "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "exports": {
7
7
  ".": {
@@ -22,10 +22,10 @@
22
22
  "directory": "packages/portals"
23
23
  },
24
24
  "devDependencies": {
25
- "@codeleap/types": "7.0.0",
26
- "@codeleap/config": "7.0.0",
27
- "@codeleap/utils": "7.0.0",
28
- "@codeleap/logger": "7.0.0",
25
+ "@codeleap/types": "7.0.1",
26
+ "@codeleap/config": "7.0.1",
27
+ "@codeleap/utils": "7.0.1",
28
+ "@codeleap/logger": "7.0.1",
29
29
  "ts-node-dev": "1.1.8"
30
30
  },
31
31
  "scripts": {
@@ -35,9 +35,9 @@
35
35
  "run-sc": "tsnd --transpile-only"
36
36
  },
37
37
  "peerDependencies": {
38
- "@codeleap/types": "7.0.0",
39
- "@codeleap/utils": "7.0.0",
40
- "@codeleap/logger": "7.0.0",
38
+ "@codeleap/types": "7.0.1",
39
+ "@codeleap/utils": "7.0.1",
40
+ "@codeleap/logger": "7.0.1",
41
41
  "typescript": "6.0.3",
42
42
  "react": "19.1.0",
43
43
  "nanostores": "*",