@common-stack/components-pro 0.1.21 → 0.1.24

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.
Files changed (59) hide show
  1. package/lib/index.d.ts +1 -0
  2. package/lib/index.js +10 -0
  3. package/lib/index.js.map +1 -0
  4. package/lib/index.native.d.ts +1 -0
  5. package/lib/index.native.js +9 -0
  6. package/lib/index.native.js.map +1 -0
  7. package/lib/slot-fill/__tests__/filler-slot.test.d.ts +1 -0
  8. package/lib/slot-fill/__tests__/filler-slot.test.js +63 -0
  9. package/lib/slot-fill/__tests__/filler-slot.test.js.map +1 -0
  10. package/lib/slot-fill/__tests__/slot-features.test.d.ts +1 -0
  11. package/lib/slot-fill/__tests__/slot-features.test.js +230 -0
  12. package/lib/slot-fill/__tests__/slot-features.test.js.map +1 -0
  13. package/lib/slot-fill/base/context.d.ts +6 -0
  14. package/lib/slot-fill/base/context.js +38 -0
  15. package/lib/slot-fill/base/context.js.map +1 -0
  16. package/lib/slot-fill/base/fill.d.ts +10 -0
  17. package/lib/slot-fill/base/fill.js +65 -0
  18. package/lib/slot-fill/base/fill.js.map +1 -0
  19. package/lib/slot-fill/base/provider.d.ts +21 -0
  20. package/lib/slot-fill/base/provider.js +117 -0
  21. package/lib/slot-fill/base/provider.js.map +1 -0
  22. package/lib/slot-fill/base/slot.d.ts +8 -0
  23. package/lib/slot-fill/base/slot.js +83 -0
  24. package/lib/slot-fill/base/slot.js.map +1 -0
  25. package/lib/slot-fill/base/use-slot.d.ts +7 -0
  26. package/lib/slot-fill/base/use-slot.js +28 -0
  27. package/lib/slot-fill/base/use-slot.js.map +1 -0
  28. package/lib/slot-fill/bubbles-virtually/fill.d.ts +5 -0
  29. package/lib/slot-fill/bubbles-virtually/fill.js +54 -0
  30. package/lib/slot-fill/bubbles-virtually/fill.js.map +1 -0
  31. package/lib/slot-fill/bubbles-virtually/slot-fill-context.d.ts +4 -0
  32. package/lib/slot-fill/bubbles-virtually/slot-fill-context.js +21 -0
  33. package/lib/slot-fill/bubbles-virtually/slot-fill-context.js.map +1 -0
  34. package/lib/slot-fill/bubbles-virtually/slot-fill-provider.d.ts +4 -0
  35. package/lib/slot-fill/bubbles-virtually/slot-fill-provider.js +112 -0
  36. package/lib/slot-fill/bubbles-virtually/slot-fill-provider.js.map +1 -0
  37. package/lib/slot-fill/bubbles-virtually/slot.d.ts +6 -0
  38. package/lib/slot-fill/bubbles-virtually/slot.js +61 -0
  39. package/lib/slot-fill/bubbles-virtually/slot.js.map +1 -0
  40. package/lib/slot-fill/bubbles-virtually/use-slot.d.ts +2 -0
  41. package/lib/slot-fill/bubbles-virtually/use-slot.js +32 -0
  42. package/lib/slot-fill/bubbles-virtually/use-slot.js.map +1 -0
  43. package/lib/slot-fill/index.d.ts +30 -0
  44. package/lib/slot-fill/index.js +81 -0
  45. package/lib/slot-fill/index.js.map +1 -0
  46. package/lib/slot-fill/index.native.d.ts +16 -0
  47. package/lib/slot-fill/index.native.js +48 -0
  48. package/lib/slot-fill/index.native.js.map +1 -0
  49. package/lib/slot-fill/interfaces/index.d.ts +79 -0
  50. package/lib/slot-fill/interfaces/index.js +3 -0
  51. package/lib/slot-fill/interfaces/index.js.map +1 -0
  52. package/lib/slot-fill/utils/index.d.ts +1 -0
  53. package/lib/slot-fill/utils/index.js +14 -0
  54. package/lib/slot-fill/utils/index.js.map +1 -0
  55. package/lib/slot-fill/utils/isEmptyElement.d.ts +8 -0
  56. package/lib/slot-fill/utils/isEmptyElement.js +21 -0
  57. package/lib/slot-fill/utils/isEmptyElement.js.map +1 -0
  58. package/package.json +5 -4
  59. package/esm/index.js +0 -2
package/lib/index.d.ts ADDED
@@ -0,0 +1 @@
1
+ export { createSlotFill, Slot, Fill, Provider as SlotFillProvider, useSlot as __experimentalUseSlot, } from './slot-fill';
package/lib/index.js ADDED
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.__experimentalUseSlot = exports.SlotFillProvider = exports.Fill = exports.Slot = exports.createSlotFill = void 0;
4
+ var slot_fill_1 = require("./slot-fill");
5
+ Object.defineProperty(exports, "createSlotFill", { enumerable: true, get: function () { return slot_fill_1.createSlotFill; } });
6
+ Object.defineProperty(exports, "Slot", { enumerable: true, get: function () { return slot_fill_1.Slot; } });
7
+ Object.defineProperty(exports, "Fill", { enumerable: true, get: function () { return slot_fill_1.Fill; } });
8
+ Object.defineProperty(exports, "SlotFillProvider", { enumerable: true, get: function () { return slot_fill_1.Provider; } });
9
+ Object.defineProperty(exports, "__experimentalUseSlot", { enumerable: true, get: function () { return slot_fill_1.useSlot; } });
10
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,yCAMqB;AALpB,2GAAA,cAAc,OAAA;AACd,iGAAA,IAAI,OAAA;AACJ,iGAAA,IAAI,OAAA;AACJ,6GAAA,QAAQ,OAAoB;AAC5B,kHAAA,OAAO,OAAyB"}
@@ -0,0 +1 @@
1
+ export { createSlotFill, Slot, Fill, Provider as SlotFillProvider, } from './slot-fill';
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SlotFillProvider = exports.Fill = exports.Slot = exports.createSlotFill = void 0;
4
+ var slot_fill_1 = require("./slot-fill");
5
+ Object.defineProperty(exports, "createSlotFill", { enumerable: true, get: function () { return slot_fill_1.createSlotFill; } });
6
+ Object.defineProperty(exports, "Slot", { enumerable: true, get: function () { return slot_fill_1.Slot; } });
7
+ Object.defineProperty(exports, "Fill", { enumerable: true, get: function () { return slot_fill_1.Fill; } });
8
+ Object.defineProperty(exports, "SlotFillProvider", { enumerable: true, get: function () { return slot_fill_1.Provider; } });
9
+ //# sourceMappingURL=index.native.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.native.js","sourceRoot":"","sources":["../src/index.native.ts"],"names":[],"mappings":";;;AAAA,yCAKqB;AAJpB,2GAAA,cAAc,OAAA;AACd,iGAAA,IAAI,OAAA;AACJ,iGAAA,IAAI,OAAA;AACJ,6GAAA,QAAQ,OAAoB"}
@@ -0,0 +1 @@
1
+ import 'jest';
@@ -0,0 +1,63 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
+ }) : (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ o[k2] = m[k];
8
+ }));
9
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
10
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
11
+ }) : function(o, v) {
12
+ o["default"] = v;
13
+ });
14
+ var __importStar = (this && this.__importStar) || function (mod) {
15
+ if (mod && mod.__esModule) return mod;
16
+ var result = {};
17
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
18
+ __setModuleDefault(result, mod);
19
+ return result;
20
+ };
21
+ Object.defineProperty(exports, "__esModule", { value: true });
22
+ /* tslint:disable */
23
+ const React = __importStar(require("react"));
24
+ const ReactTestRenderer = __importStar(require("react-test-renderer"));
25
+ const __1 = require("../");
26
+ // import Provider from '../context';
27
+ const index_1 = require("../index");
28
+ require("jest");
29
+ describe('Slot with filter', () => {
30
+ it("calls the functions passed as the Slot's fillProps in the Fill", () => {
31
+ const onClose = jest.fn();
32
+ const List = ({ items }) => {
33
+ return (React.createElement("ul", null, items.map((item, i) => React.createElement(ListItem, { key: i, item: item }))));
34
+ };
35
+ class ListItem extends React.Component {
36
+ constructor() {
37
+ super(...arguments);
38
+ this.state = { showing: true };
39
+ this.handleClick = () => {
40
+ this.setState({ showing: true });
41
+ };
42
+ this.handlHideModal = () => {
43
+ this.setState({ showing: false });
44
+ };
45
+ }
46
+ render() {
47
+ return (React.createElement("li", null,
48
+ this.state.showing &&
49
+ React.createElement(__1.Fill, { name: "modal" },
50
+ "Showing ",
51
+ this.props.item,
52
+ React.createElement("button", { onClick: this.handlHideModal }, "Hide")),
53
+ this.props.item));
54
+ }
55
+ }
56
+ const tree = ReactTestRenderer.create(React.createElement(index_1.SlotFillProvider, null,
57
+ React.createElement(List, { items: ["one", "two", "three"] }),
58
+ React.createElement("div", { className: "modal" },
59
+ React.createElement(__1.Slot, { name: "modal" })))).toJSON();
60
+ expect(tree).toMatchSnapshot();
61
+ });
62
+ });
63
+ //# sourceMappingURL=filler-slot.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"filler-slot.test.js","sourceRoot":"","sources":["../../../src/slot-fill/__tests__/filler-slot.test.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA,oBAAoB;AACpB,6CAA+B;AAE/B,uEAAyD;AACzD,2BAA8B;AAC9B,qCAAqC;AACrC,oCAAwD;AACxD,gBAAc;AAEd,QAAQ,CAAC,kBAAkB,EAAE,GAAG,EAAE;IAChC,EAAE,CAAC,gEAAgE,EAAE,GAAG,EAAE;QACxE,MAAM,OAAO,GAAG,IAAI,CAAC,EAAE,EAAE,CAAC;QAE1B,MAAM,IAAI,GAAG,CAAE,EAAE,KAAK,EAAE,EAAE,EAAE;YACxB,OAAO,CACH,gCACK,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC,EAAE,EAAE,CAAC,oBAAC,QAAQ,IAAC,GAAG,EAAE,CAAC,EAAE,IAAI,EAAE,IAAI,GAAI,CAAC,CACxD,CACR,CAAA;QACL,CAAC,CAAA;QAED,MAAM,QAAS,SAAQ,KAAK,CAAC,SAAuB;YAApD;;gBACI,UAAK,GAAG,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;gBAC1B,gBAAW,GAAG,GAAG,EAAE;oBACf,IAAI,CAAC,QAAQ,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC;gBACrC,CAAC,CAAA;gBACD,mBAAc,GAAG,GAAG,EAAE;oBAClB,IAAI,CAAC,QAAQ,CAAC,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC,CAAC;gBACtC,CAAC,CAAA;YAaL,CAAC;YAZG,MAAM;gBACF,OAAO,CACH;oBACK,IAAI,CAAC,KAAK,CAAC,OAAO;wBACnB,oBAAC,QAAI,IAAC,IAAI,EAAC,OAAO;;4BAAU,IAAI,CAAC,KAAK,CAAC,IAAI;4BACvC,gCAAQ,OAAO,EAAE,IAAI,CAAC,cAAc,WAAe,CAChD;oBAEN,IAAI,CAAC,KAAK,CAAC,IAAI,CACf,CACR,CAAA;YACL,CAAC;SACJ;QAED,MAAM,IAAI,GAAG,iBAAiB,CAAC,MAAM,CACjC,oBAAC,wBAAQ;YACL,oBAAC,IAAI,IAAC,KAAK,EAAE,CAAC,KAAK,EAAE,KAAK,EAAE,OAAO,CAAC,GAAI;YACxC,6BAAK,SAAS,EAAC,OAAO;gBAClB,oBAAC,QAAI,IAAC,IAAI,EAAC,OAAO,GAAG,CACnB,CACC,CACd,CAAC,MAAM,EAAE,CAAC;QAEX,MAAM,CAAC,IAAI,CAAC,CAAC,eAAe,EAAE,CAAC;IACjC,CAAC,CAAC,CAAC;AAEL,CAAC,CAAC,CAAC"}
@@ -0,0 +1 @@
1
+ import 'jest';
@@ -0,0 +1,230 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
+ }) : (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ o[k2] = m[k];
8
+ }));
9
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
10
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
11
+ }) : function(o, v) {
12
+ o["default"] = v;
13
+ });
14
+ var __importStar = (this && this.__importStar) || function (mod) {
15
+ if (mod && mod.__esModule) return mod;
16
+ var result = {};
17
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
18
+ __setModuleDefault(result, mod);
19
+ return result;
20
+ };
21
+ Object.defineProperty(exports, "__esModule", { value: true });
22
+ /* tslint:disable */
23
+ const React = __importStar(require("react"));
24
+ const lodash_1 = require("lodash");
25
+ const react_1 = require("@testing-library/react");
26
+ const __1 = require("../");
27
+ const react_2 = require("react");
28
+ require("jest");
29
+ class Filler extends react_2.Component {
30
+ constructor(props) {
31
+ super(props);
32
+ this.state = {
33
+ num: 1
34
+ };
35
+ }
36
+ render() {
37
+ return [
38
+ React.createElement("button", { key: "1", type: "button", onClick: () => this.setState({ num: this.state.num + 1 }) }),
39
+ React.createElement(__1.Fill, { name: this.props.name, key: "2" }, this.props.text || this.state.num.toString())
40
+ ];
41
+ }
42
+ }
43
+ describe("Slot", () => {
44
+ it("should render empty Fills", () => {
45
+ const { container } = react_1.render(React.createElement(__1.Provider, null,
46
+ React.createElement("div", null,
47
+ React.createElement(__1.Slot, { name: "chicken" })),
48
+ React.createElement(__1.Fill, { name: "chicken" })));
49
+ expect(container).toMatchSnapshot();
50
+ });
51
+ it("should render a string Fill", () => {
52
+ const { container } = react_1.render(React.createElement(__1.Provider, null,
53
+ React.createElement("div", null,
54
+ React.createElement(__1.Slot, { name: "chicken" })),
55
+ React.createElement(__1.Fill, { name: "chicken" }, "content")));
56
+ expect(container).toMatchSnapshot();
57
+ });
58
+ it("should render a Fill containing an element", () => {
59
+ const { container } = react_1.render(React.createElement(__1.Provider, null,
60
+ React.createElement("div", null,
61
+ React.createElement(__1.Slot, { name: "chicken" })),
62
+ React.createElement(__1.Fill, { name: "chicken" },
63
+ React.createElement("span", null))));
64
+ expect(container).toMatchSnapshot();
65
+ });
66
+ it("should render a Fill containing an array", () => {
67
+ const { container } = react_1.render(React.createElement(__1.Provider, null,
68
+ React.createElement("div", null,
69
+ React.createElement(__1.Slot, { name: "chicken" })),
70
+ React.createElement(__1.Fill, { name: "chicken" }, [React.createElement("span", { key: "1" }), React.createElement("div", { key: "2" }), "text"])));
71
+ expect(container).toMatchSnapshot();
72
+ });
73
+ it("calls the functions passed as the Slot's fillProps in the Fill", () => {
74
+ const onClose = jest.fn();
75
+ const { getByText } = react_1.render(React.createElement(__1.Provider, null,
76
+ React.createElement(__1.Slot, { name: "chicken", fillProps: { onClose } }),
77
+ React.createElement(__1.Fill, { name: "chicken" }, props => {
78
+ return React.createElement("button", { onClick: props.onClose }, " Click me");
79
+ })));
80
+ react_1.fireEvent.click(getByText('Click me'));
81
+ expect(onClose).toHaveBeenCalledTimes(1);
82
+ });
83
+ it("should render empty Fills without HTML wrapper when render props used", () => {
84
+ const { container } = react_1.render(React.createElement(__1.Provider, null,
85
+ React.createElement("div", null,
86
+ React.createElement(__1.Slot, { name: "chicken" }, fills => !lodash_1.isEmpty(fills) && React.createElement("blockquote", null, fills))),
87
+ React.createElement(__1.Fill, { name: "chicken" })));
88
+ expect(container).toMatchSnapshot();
89
+ });
90
+ it("should render a string Fill with HTML wrapper when render props used", () => {
91
+ const { container } = react_1.render(React.createElement(__1.Provider, null,
92
+ React.createElement("div", null,
93
+ React.createElement(__1.Slot, { name: "chicken" }, fills => fills && React.createElement("blockquote", null, fills))),
94
+ React.createElement(__1.Fill, { name: "chicken" }, "content")));
95
+ expect(container).toMatchSnapshot();
96
+ });
97
+ it("should re-render Slot when not bubbling virtually", () => {
98
+ const { container, getByRole } = react_1.render(React.createElement(__1.Provider, null,
99
+ React.createElement("div", null,
100
+ React.createElement(__1.Slot, { name: "egg" })),
101
+ React.createElement(Filler, { name: "egg" })));
102
+ expect(container).toMatchSnapshot();
103
+ react_1.fireEvent.click(getByRole('button'));
104
+ expect(container).toMatchSnapshot();
105
+ });
106
+ it("should render in expected order when fills always mounted", () => {
107
+ const { container, rerender } = react_1.render(React.createElement(__1.Provider, null,
108
+ React.createElement("div", { key: "slot" },
109
+ React.createElement(__1.Slot, { name: "egg" }))));
110
+ rerender(React.createElement(__1.Provider, null,
111
+ React.createElement("div", { key: "slot" },
112
+ React.createElement(__1.Slot, { name: "egg" })),
113
+ React.createElement(Filler, { name: "egg", key: "first", text: "first" }),
114
+ React.createElement(Filler, { name: "egg", key: "second", text: "second" })));
115
+ rerender(React.createElement(__1.Provider, null,
116
+ React.createElement("div", { key: "slot" },
117
+ React.createElement(__1.Slot, { name: "egg" })),
118
+ React.createElement(__1.Fill, { name: "egg", key: "first" }),
119
+ React.createElement(__1.Fill, { name: "egg", key: "second" }, "second"),
120
+ React.createElement(__1.Fill, { name: "egg", key: "third" }, "third")));
121
+ rerender(React.createElement(__1.Provider, null,
122
+ React.createElement("div", { key: "slot" },
123
+ React.createElement(__1.Slot, { name: "egg" })),
124
+ React.createElement(__1.Fill, { name: "egg", key: "first" }, "first (rerendered)"),
125
+ React.createElement(__1.Fill, { name: "egg", key: "second" }, "second"),
126
+ React.createElement(__1.Fill, { name: "egg", key: "third" }, "third"),
127
+ React.createElement(__1.Fill, { name: "egg", key: "fourth" }, "fourth (new)")));
128
+ expect(container).toMatchSnapshot();
129
+ });
130
+ it('should render in expected order when fills unmounted', () => {
131
+ const { container, rerender } = react_1.render(React.createElement(__1.Provider, null,
132
+ React.createElement("div", { key: "slot" },
133
+ React.createElement(__1.Slot, { name: "egg" }))));
134
+ rerender(React.createElement(__1.Provider, null,
135
+ React.createElement("div", { key: "slot" },
136
+ React.createElement(__1.Slot, { name: "egg" })),
137
+ React.createElement(Filler, { name: "egg", key: "first", text: "first" }),
138
+ React.createElement(Filler, { name: "egg", key: "second", text: "second" })));
139
+ rerender(React.createElement(__1.Provider, null,
140
+ React.createElement("div", { key: "slot" },
141
+ React.createElement(__1.Slot, { name: "egg" })),
142
+ React.createElement(Filler, { name: "egg", key: "second", text: "second" }),
143
+ React.createElement(Filler, { name: "egg", key: "third", text: "third" })));
144
+ rerender(React.createElement(__1.Provider, null,
145
+ React.createElement("div", { key: "slot" },
146
+ React.createElement(__1.Slot, { name: "egg" })),
147
+ React.createElement(Filler, { name: "egg", key: "first", text: "first (rerendered)" }),
148
+ React.createElement(Filler, { name: "egg", key: "second", text: "second" }),
149
+ React.createElement(Filler, { name: "egg", key: "third", text: "third" }),
150
+ React.createElement(Filler, { name: "egg", key: "fourth", text: "fourth (new)" })));
151
+ expect(container).toMatchSnapshot();
152
+ });
153
+ it('should warn without a Provider', () => {
154
+ const { container } = react_1.render(React.createElement(React.Fragment, null,
155
+ React.createElement("div", null,
156
+ React.createElement(__1.Slot, { name: "chicken", bubblesVirtually: true })),
157
+ React.createElement(__1.Fill, { name: "chicken" })));
158
+ expect(container).toMatchSnapshot();
159
+ // expect(console).toHaveWarned();
160
+ });
161
+ describe.each([false, true])("bubblesVirtually %p", bubblesVirtually => {
162
+ it("should subsume another slot by the same name", () => {
163
+ const { container, rerender } = react_1.render(React.createElement(__1.Provider, null,
164
+ React.createElement("div", { "data-position": "first" },
165
+ React.createElement(__1.Slot, { name: "egg", bubblesVirtually: bubblesVirtually })),
166
+ React.createElement("div", { "data-position": "second" }),
167
+ React.createElement(__1.Fill, { name: "egg" }, "Content")));
168
+ rerender(React.createElement(__1.Provider, null,
169
+ React.createElement("div", { "data-position": "first" },
170
+ React.createElement(__1.Slot, { name: "egg", bubblesVirtually: bubblesVirtually })),
171
+ React.createElement("div", { "data-position": "second" },
172
+ React.createElement(__1.Slot, { name: "egg", bubblesVirtually: bubblesVirtually })),
173
+ React.createElement(__1.Fill, { name: "egg" }, "Content")));
174
+ expect(container).toMatchSnapshot();
175
+ rerender(React.createElement(__1.Provider, null,
176
+ React.createElement("div", { "data-position": "first" }),
177
+ React.createElement("div", { "data-position": "second" },
178
+ React.createElement(__1.Slot, { name: "egg", bubblesVirtually: bubblesVirtually })),
179
+ React.createElement(__1.Fill, { name: "egg" }, "Content")));
180
+ expect(container).toMatchSnapshot();
181
+ });
182
+ it('should unmount two slots with the same name', () => {
183
+ const { rerender, container } = react_1.render(React.createElement(__1.Provider, null,
184
+ React.createElement("div", { "data-position": "first" },
185
+ React.createElement(__1.Slot, { name: "egg", bubblesVirtually: bubblesVirtually })),
186
+ React.createElement("div", { "data-position": "second" },
187
+ React.createElement(__1.Slot, { name: "egg", bubblesVirtually: bubblesVirtually })),
188
+ React.createElement(__1.Fill, { name: "egg" }, "Content")));
189
+ rerender(React.createElement(__1.Provider, null,
190
+ React.createElement("div", { "data-position": "first" },
191
+ React.createElement(__1.Slot, { name: "egg", bubblesVirtually: bubblesVirtually })),
192
+ React.createElement("div", { "data-position": "second" }),
193
+ React.createElement(__1.Fill, { name: "egg" }, "Content")));
194
+ rerender(React.createElement(__1.Provider, null,
195
+ React.createElement("div", { "data-position": "first" }),
196
+ React.createElement("div", { "data-position": "second" }),
197
+ React.createElement(__1.Fill, { name: "egg" }, "Content")));
198
+ expect(container).toMatchSnapshot();
199
+ });
200
+ });
201
+ });
202
+ //@sri custom logic
203
+ describe("Slot with logic", () => {
204
+ it("should render a string Fill with HTML wrapper when render props used", () => {
205
+ const Fill1 = props => {
206
+ return React.createElement(__1.Fill, { name: "chicken", fillId: 'id1' }, props => {
207
+ return "content";
208
+ });
209
+ };
210
+ const Fill2 = props => {
211
+ return (React.createElement(__1.Fill, { name: "chicken", fillId: 'id2' }, props => {
212
+ console.log("--filler--props", props);
213
+ return "content1";
214
+ }));
215
+ };
216
+ const Slot1 = props => {
217
+ return (React.createElement(__1.Slot, { name: "chicken", fillProps: { selected: "one" } }, fills => {
218
+ console.log("---files", fills);
219
+ return fills && React.createElement("blockquote", null, "Test");
220
+ }));
221
+ };
222
+ const { container } = react_1.render(React.createElement(__1.Provider, null,
223
+ React.createElement("div", null,
224
+ React.createElement(Slot1, null)),
225
+ React.createElement(Fill1, null),
226
+ React.createElement(Fill2, null)));
227
+ expect(container).toMatchSnapshot();
228
+ });
229
+ });
230
+ //# sourceMappingURL=slot-features.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"slot-features.test.js","sour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K,CAAC,EAAE;YAEpB,OAAO,CACL,oBAAC,QAAI,IAAC,IAAI,EAAC,SAAS,EAAC,SAAS,EAAE,EAAE,QAAQ,EAAE,KAAK,EAAE,IAChD,KAAK,CAAC,EAAE;gBACP,OAAO,CAAC,GAAG,CAAC,UAAU,EAAE,KAAK,CAAC,CAAC;gBAC/B,OAAO,KAAK,IAAI,+CAA6B,CAAC;YAChD,CAAC,CACI,CACR,CAAA;QACH,CAAC,CAAA;QACD,MAAM,EAAE,SAAS,EAAE,GAAG,cAAM,CAC1B,oBAAC,YAAQ;YACP;gBACE,oBAAC,KAAK,OAAG,CACL;YACN,oBAAC,KAAK,OAAG;YACT,oBAAC,KAAK,OAAG,CACA,CACZ,CAAC;QACF,MAAM,CAAC,SAAS,CAAC,CAAC,eAAe,EAAE,CAAC;IACtC,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -0,0 +1,6 @@
1
+ import * as React from 'react';
2
+ import { IContext } from '../interfaces';
3
+ declare const SlotFillContext: React.Context<IContext>;
4
+ declare const Provider: React.Provider<IContext>, Consumer: React.Consumer<IContext>;
5
+ export { Consumer, Provider };
6
+ export default SlotFillContext;
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
+ }) : (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ o[k2] = m[k];
8
+ }));
9
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
10
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
11
+ }) : function(o, v) {
12
+ o["default"] = v;
13
+ });
14
+ var __importStar = (this && this.__importStar) || function (mod) {
15
+ if (mod && mod.__esModule) return mod;
16
+ var result = {};
17
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
18
+ __setModuleDefault(result, mod);
19
+ return result;
20
+ };
21
+ Object.defineProperty(exports, "__esModule", { value: true });
22
+ exports.Provider = exports.Consumer = void 0;
23
+ const React = __importStar(require("react"));
24
+ const SlotFillContext = React.createContext({
25
+ registerSlot: () => { },
26
+ unregisterSlot: () => { },
27
+ registerFill: () => { },
28
+ unregisterFill: () => { },
29
+ getSlot: () => ({}),
30
+ getFills: () => ([]),
31
+ hasFills: () => false,
32
+ subscribe: () => { },
33
+ });
34
+ const { Provider, Consumer } = SlotFillContext;
35
+ exports.Provider = Provider;
36
+ exports.Consumer = Consumer;
37
+ exports.default = SlotFillContext;
38
+ //# sourceMappingURL=context.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"context.js","sourceRoot":"","sources":["../../../src/slot-fill/base/context.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA,6CAA+B;AAG/B,MAAM,eAAe,GAAG,KAAK,CAAC,aAAa,CAAkB;IAC3D,YAAY,EAAE,GAAG,EAAE,GAAE,CAAC;IACtB,cAAc,EAAE,GAAG,EAAE,GAAE,CAAC;IACxB,YAAY,EAAE,GAAG,EAAE,GAAE,CAAC;IACtB,cAAc,EAAE,GAAG,EAAE,GAAE,CAAC;IACxB,OAAO,EAAE,GAAG,EAAE,CAAC,CAAC,EAAE,CAAQ;IAC1B,QAAQ,EAAE,GAAG,EAAE,CAAC,CAAC,EAAE,CAAC;IACpB,QAAQ,EAAE,GAAG,EAAE,CAAC,KAAK;IACrB,SAAS,EAAE,GAAG,EAAE,GAAE,CAAC;CACpB,CAAC,CAAC;AACH,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,GAAG,eAAe,CAAC;AAC5B,4BAAQ;AAAlB,4BAAQ;AACjB,kBAAe,eAAe,CAAC"}
@@ -0,0 +1,10 @@
1
+ import { FC } from 'react';
2
+ import { IFillProps, IContext } from '../interfaces';
3
+ export declare namespace IFillComponent {
4
+ interface Props extends IFillProps, Partial<IContext> {
5
+ }
6
+ }
7
+ declare type IFillComponentProps<T = IFillProps> = T;
8
+ declare type IFillComponent<T = IFillProps> = FC<IFillComponentProps<T>>;
9
+ declare const Fill: IFillComponent;
10
+ export default Fill;
@@ -0,0 +1,65 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
+ }) : (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ o[k2] = m[k];
8
+ }));
9
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
10
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
11
+ }) : function(o, v) {
12
+ o["default"] = v;
13
+ });
14
+ var __importStar = (this && this.__importStar) || function (mod) {
15
+ if (mod && mod.__esModule) return mod;
16
+ var result = {};
17
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
18
+ __setModuleDefault(result, mod);
19
+ return result;
20
+ };
21
+ Object.defineProperty(exports, "__esModule", { value: true });
22
+ const react_1 = __importStar(require("react"));
23
+ const react_dom_1 = require("react-dom");
24
+ const lodash_1 = require("lodash");
25
+ const context_1 = require("./context");
26
+ const use_slot_1 = require("./use-slot");
27
+ const FillComponent = ({ name, children, registerFill, unregisterFill, }) => {
28
+ const slot = use_slot_1.useSlot(name);
29
+ const ref = react_1.useRef({
30
+ name,
31
+ children,
32
+ });
33
+ react_1.useLayoutEffect(() => {
34
+ registerFill(name, ref.current);
35
+ return () => unregisterFill(name, ref.current);
36
+ }, []);
37
+ react_1.useLayoutEffect(() => {
38
+ ref.current.children = children;
39
+ if (slot) {
40
+ slot.forceUpdate();
41
+ }
42
+ }, [children]);
43
+ react_1.useLayoutEffect(() => {
44
+ if (name === ref.current.name) {
45
+ // ignore initial effect
46
+ return;
47
+ }
48
+ unregisterFill(ref.current.name, ref.current);
49
+ ref.current.name = name;
50
+ registerFill(name, ref.current);
51
+ }, [name]);
52
+ if (!slot || !slot.node) {
53
+ return null;
54
+ }
55
+ // If a function is passed as a child, provide it with the fillProps.
56
+ if (lodash_1.isFunction(children)) {
57
+ children = children(slot.props.fillProps);
58
+ }
59
+ return react_dom_1.createPortal(children, slot.node);
60
+ };
61
+ const Fill = props => {
62
+ return (react_1.default.createElement(context_1.Consumer, null, ({ registerFill, unregisterFill }) => (react_1.default.createElement(FillComponent, Object.assign({}, props, { registerFill: registerFill, unregisterFill: unregisterFill })))));
63
+ };
64
+ exports.default = Fill;
65
+ //# sourceMappingURL=fill.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fill.js","sourceRoot":"","sources":["../../../src/slot-fill/base/fill.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA,+CAAgE;AAChE,yCAAyC;AACzC,mCAAoC;AACpC,uCAAqC;AAErC,yCAAqC;AAKrC,MAAM,aAAa,GAA8B,CAAC,EAChD,IAAI,EACJ,QAAQ,EACR,YAAY,EACZ,cAAc,GACf,EAAE,EAAE;IACH,MAAM,IAAI,GAAG,kBAAO,CAAC,IAAI,CAAC,CAAC;IAE3B,MAAM,GAAG,GAAG,cAAM,CAAC;QACjB,IAAI;QACJ,QAAQ;KACT,CAAC,CAAC;IAEH,uBAAe,CAAC,GAAG,EAAE;QACnB,YAAY,CAAC,IAAI,EAAE,GAAG,CAAC,OAAO,CAAC,CAAC;QAChC,OAAO,GAAG,EAAE,CAAC,cAAc,CAAC,IAAI,EAAE,GAAG,CAAC,OAAO,CAAC,CAAC;IACjD,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,uBAAe,CAAC,GAAG,EAAE;QACnB,GAAG,CAAC,OAAO,CAAC,QAAQ,GAAG,QAAQ,CAAC;QAChC,IAAI,IAAI,EAAE;YACR,IAAI,CAAC,WAAW,EAAE,CAAC;SACpB;IACH,CAAC,EAAE,CAAC,QAAQ,CAAC,CAAC,CAAC;IAEf,uBAAe,CAAC,GAAG,EAAE;QACnB,IAAI,IAAI,KAAK,GAAG,CAAC,OAAO,CAAC,IAAI,EAAE;YAC7B,wBAAwB;YACxB,OAAO;SACR;QACD,cAAc,CAAC,GAAG,CAAC,OAAO,CAAC,IAAI,EAAE,GAAG,CAAC,OAAO,CAAC,CAAC;QAC9C,GAAG,CAAC,OAAO,CAAC,IAAI,GAAG,IAAI,CAAC;QACxB,YAAY,CAAC,IAAI,EAAE,GAAG,CAAC,OAAO,CAAC,CAAC;IAClC,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC;IAEX,IAAI,CAAC,IAAI,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE;QACvB,OAAO,IAAI,CAAC;KACb;IAED,qEAAqE;IACrE,IAAI,mBAAU,CAAC,QAAQ,CAAC,EAAE;QACxB,QAAQ,GAAG,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;KAC3C;IAED,OAAO,wBAAY,CAAC,QAAQ,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC;AAC3C,CAAC,CAAC;AAQF,MAAM,IAAI,GAAmB,KAAK,CAAC,EAAE;IACnC,OAAO,CACL,8BAAC,kBAAQ,QACN,CAAC,EAAE,YAAY,EAAE,cAAc,EAAE,EAAE,EAAE,CAAC,CACrC,8BAAC,aAAa,oBACR,KAAK,IACT,YAAY,EAAE,YAAY,EAC1B,cAAc,EAAE,cAAc,IAC9B,CACH,CACQ,CACZ,CAAC;AACJ,CAAC,CAAC;AAEF,kBAAe,IAAI,CAAC"}
@@ -0,0 +1,21 @@
1
+ import { Component } from 'react';
2
+ import { IFill, ISlot } from '../interfaces';
3
+ declare class SlotFillProvider extends Component<{}, {}> {
4
+ private slots;
5
+ private fills;
6
+ private listeners;
7
+ private contextValue;
8
+ constructor(props: any);
9
+ registerSlot(name: any, slot: any): void;
10
+ registerFill(name: any, instance: any): void;
11
+ unregisterSlot(name: any, instance: any): void;
12
+ unregisterFill(name: any, instance: IFill): void;
13
+ getSlot(name: any): ISlot;
14
+ getFills(name: any, slotInstance: any): IFill[];
15
+ hasFills(name: any): boolean;
16
+ private forceUpdateSlot;
17
+ private triggerListeners;
18
+ subscribe(listener: any): () => void;
19
+ render(): JSX.Element;
20
+ }
21
+ export default SlotFillProvider;
@@ -0,0 +1,117 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
+ }) : (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ o[k2] = m[k];
8
+ }));
9
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
10
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
11
+ }) : function(o, v) {
12
+ o["default"] = v;
13
+ });
14
+ var __importStar = (this && this.__importStar) || function (mod) {
15
+ if (mod && mod.__esModule) return mod;
16
+ var result = {};
17
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
18
+ __setModuleDefault(result, mod);
19
+ return result;
20
+ };
21
+ Object.defineProperty(exports, "__esModule", { value: true });
22
+ const react_1 = __importStar(require("react"));
23
+ const lodash_1 = require("lodash");
24
+ const context_1 = require("./context");
25
+ class SlotFillProvider extends react_1.Component {
26
+ constructor(props) {
27
+ super(props);
28
+ this.registerSlot = this.registerSlot.bind(this);
29
+ this.registerFill = this.registerFill.bind(this);
30
+ this.unregisterSlot = this.unregisterSlot.bind(this);
31
+ this.unregisterFill = this.unregisterFill.bind(this);
32
+ this.getSlot = this.getSlot.bind(this);
33
+ this.getFills = this.getFills.bind(this);
34
+ this.subscribe = this.subscribe.bind(this);
35
+ this.slots = {};
36
+ this.fills = {};
37
+ this.listeners = [];
38
+ this.contextValue = {
39
+ registerSlot: this.registerSlot,
40
+ unregisterSlot: this.unregisterSlot,
41
+ registerFill: this.registerFill,
42
+ unregisterFill: this.unregisterFill,
43
+ getSlot: this.getSlot,
44
+ getFills: this.getFills,
45
+ hasFills: this.hasFills,
46
+ subscribe: this.subscribe,
47
+ };
48
+ }
49
+ registerSlot(name, slot) {
50
+ const previousSlot = this.slots[name];
51
+ this.slots[name] = slot;
52
+ this.triggerListeners();
53
+ // Sometimes the fills are registered after the initial render of slot
54
+ // But before the registerSlot call, we need to rerender the slot
55
+ this.forceUpdateSlot(name);
56
+ // If a new instance of a slot is being mounted while another with the
57
+ // same name exists, force its update _after_ the new slot has been
58
+ // assigned into the instance, suich that its own rendering of children
59
+ // will be empty (the new Slot will subsume all fills for this name).
60
+ if (previousSlot) {
61
+ previousSlot.forceUpdate();
62
+ }
63
+ }
64
+ registerFill(name, instance) {
65
+ this.fills[name] = [...(this.fills[name] || []), instance];
66
+ this.forceUpdateSlot(name);
67
+ }
68
+ unregisterSlot(name, instance) {
69
+ // If a previous instance of a Slot by this name unmounts, do nothing,
70
+ // as the slot and its fills should only be removed for the current
71
+ // known instance.
72
+ if (this.slots[name] !== instance) {
73
+ return;
74
+ }
75
+ delete this.slots[name];
76
+ this.triggerListeners();
77
+ }
78
+ unregisterFill(name, instance) {
79
+ this.fills[name] = lodash_1.without(this.fills[name], instance);
80
+ this.forceUpdateSlot(name);
81
+ }
82
+ getSlot(name) {
83
+ return this.slots[name];
84
+ }
85
+ getFills(name, slotInstance) {
86
+ // Commented following as we need the Slot to render at multiple places
87
+ // Fills should only be returned for the current instance of the slot
88
+ // in which they occupy.
89
+ // if (this.slots[name] !== slotInstance) {
90
+ // return [];
91
+ // }
92
+ return lodash_1.sortBy(this.fills[name]);
93
+ }
94
+ hasFills(name) {
95
+ return this.fills[name] && !!this.fills[name].length;
96
+ }
97
+ forceUpdateSlot(name) {
98
+ const slot = this.getSlot(name);
99
+ if (slot) {
100
+ slot.forceUpdate();
101
+ }
102
+ }
103
+ triggerListeners() {
104
+ this.listeners.forEach((listener) => listener());
105
+ }
106
+ subscribe(listener) {
107
+ this.listeners.push(listener);
108
+ return () => {
109
+ this.listeners = lodash_1.without(this.listeners, listener);
110
+ };
111
+ }
112
+ render() {
113
+ return react_1.default.createElement(context_1.Provider, { value: this.contextValue }, this.props.children);
114
+ }
115
+ }
116
+ exports.default = SlotFillProvider;
117
+ //# sourceMappingURL=provider.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"provider.js","sourceRoot":"","sources":["../../../src/slot-fill/base/provider.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA,+CAA0C;AAC1C,mCAAyC;AAEzC,uCAAqC;AAErC,MAAM,gBAAiB,SAAQ,iBAAiB;IAK5C,YAAY,KAAK;QACb,KAAK,CAAC,KAAK,CAAC,CAAC;QAEb,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACjD,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACjD,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACrD,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACrD,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACvC,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACzC,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAE3C,IAAI,CAAC,KAAK,GAAG,EAAE,CAAC;QAChB,IAAI,CAAC,KAAK,GAAG,EAAE,CAAC;QAChB,IAAI,CAAC,SAAS,GAAG,EAAE,CAAC;QACpB,IAAI,CAAC,Y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