@common-stack/components-pro 3.0.1-alpha.0 → 3.0.2-alpha.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.
- package/lib/index.js +2 -12
- package/lib/index.js.map +1 -1
- package/lib/index.native.js +1 -8
- package/lib/index.native.js.map +1 -1
- package/lib/slot-fill/__tests__/filler-slot.test.js +8 -33
- package/lib/slot-fill/__tests__/filler-slot.test.js.map +1 -1
- package/lib/slot-fill/__tests__/slot-features.test.js +81 -106
- package/lib/slot-fill/__tests__/slot-features.test.js.map +1 -1
- package/lib/slot-fill/base/context.js +3 -30
- package/lib/slot-fill/base/context.js.map +1 -1
- package/lib/slot-fill/base/fill.js +10 -35
- package/lib/slot-fill/base/fill.js.map +1 -1
- package/lib/slot-fill/base/provider.js +7 -32
- package/lib/slot-fill/base/provider.js.map +1 -1
- package/lib/slot-fill/base/slot.js +11 -36
- package/lib/slot-fill/base/slot.js.map +1 -1
- package/lib/slot-fill/base/use-slot.js +6 -13
- package/lib/slot-fill/base/use-slot.js.map +1 -1
- package/lib/slot-fill/bubbles-virtually/fill.js +11 -17
- package/lib/slot-fill/bubbles-virtually/fill.js.map +1 -1
- package/lib/slot-fill/bubbles-virtually/slot-fill-context.js +8 -13
- package/lib/slot-fill/bubbles-virtually/slot-fill-context.js.map +1 -1
- package/lib/slot-fill/bubbles-virtually/slot-fill-provider.js +19 -48
- package/lib/slot-fill/bubbles-virtually/slot-fill-provider.js.map +1 -1
- package/lib/slot-fill/bubbles-virtually/slot.js +9 -37
- package/lib/slot-fill/bubbles-virtually/slot.js.map +1 -1
- package/lib/slot-fill/bubbles-virtually/use-slot-fills.js +6 -12
- package/lib/slot-fill/bubbles-virtually/use-slot-fills.js.map +1 -1
- package/lib/slot-fill/bubbles-virtually/use-slot.js +10 -16
- package/lib/slot-fill/bubbles-virtually/use-slot.js.map +1 -1
- package/lib/slot-fill/index.js +24 -57
- package/lib/slot-fill/index.js.map +1 -1
- package/lib/slot-fill/index.native.js +10 -42
- package/lib/slot-fill/index.native.js.map +1 -1
- package/lib/slot-fill/interfaces/index.js +1 -2
- package/lib/slot-fill/utils/index.js +3 -19
- package/lib/slot-fill/utils/index.js.map +1 -1
- package/lib/slot-fill/utils/isEmptyElement.js +1 -5
- package/lib/slot-fill/utils/isEmptyElement.js.map +1 -1
- package/lib/slot-fill/utils/removeUniversalPortals.js +1 -5
- package/lib/slot-fill/utils/removeUniversalPortals.js.map +1 -1
- package/lib/slot-fill/utils/replaceServerFills.js +2 -29
- package/lib/slot-fill/utils/replaceServerFills.js.map +1 -1
- package/package.json +3 -2
package/lib/index.js
CHANGED
|
@@ -1,13 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.replaceServerFills = exports.removeUniversalPortals = 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
|
-
var utils_1 = require("./slot-fill/utils");
|
|
11
|
-
Object.defineProperty(exports, "removeUniversalPortals", { enumerable: true, get: function () { return utils_1.removeUniversalPortals; } });
|
|
12
|
-
Object.defineProperty(exports, "replaceServerFills", { enumerable: true, get: function () { return utils_1.replaceServerFills; } });
|
|
1
|
+
export { createSlotFill, Slot, Fill, Provider as SlotFillProvider, useSlot as __experimentalUseSlot, } from './slot-fill';
|
|
2
|
+
export { removeUniversalPortals, replaceServerFills, } from './slot-fill/utils';
|
|
13
3
|
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,cAAc,EACd,IAAI,EACJ,IAAI,EACJ,QAAQ,IAAI,gBAAgB,EAC5B,OAAO,IAAI,qBAAqB,GAChC,MAAM,aAAa,CAAC;AAErB,OAAO,EACN,sBAAsB,EACtB,kBAAkB,GAClB,MAAM,mBAAmB,CAAC"}
|
package/lib/index.native.js
CHANGED
|
@@ -1,9 +1,2 @@
|
|
|
1
|
-
|
|
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; } });
|
|
1
|
+
export { createSlotFill, Slot, Fill, Provider as SlotFillProvider, } from './slot-fill';
|
|
9
2
|
//# sourceMappingURL=index.native.js.map
|
package/lib/index.native.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.native.js","sourceRoot":"","sources":["../src/index.native.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.native.js","sourceRoot":"","sources":["../src/index.native.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,cAAc,EACd,IAAI,EACJ,IAAI,EACJ,QAAQ,IAAI,gBAAgB,GAC5B,MAAM,aAAa,CAAC"}
|
|
@@ -1,35 +1,10 @@
|
|
|
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 (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
1
|
/* tslint:disable */
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import * as ReactTestRenderer from 'react-test-renderer';
|
|
4
|
+
import { Slot, Fill } from '../';
|
|
30
5
|
// import Provider from '../context';
|
|
31
|
-
|
|
32
|
-
|
|
6
|
+
import { SlotFillProvider as Provider } from '../index';
|
|
7
|
+
import 'jest';
|
|
33
8
|
describe('Slot with filter', () => {
|
|
34
9
|
it("calls the functions passed as the Slot's fillProps in the Fill", () => {
|
|
35
10
|
const onClose = jest.fn();
|
|
@@ -50,17 +25,17 @@ describe('Slot with filter', () => {
|
|
|
50
25
|
render() {
|
|
51
26
|
return (React.createElement("li", null,
|
|
52
27
|
this.state.showing &&
|
|
53
|
-
React.createElement(
|
|
28
|
+
React.createElement(Fill, { name: "modal" },
|
|
54
29
|
"Showing ",
|
|
55
30
|
this.props.item,
|
|
56
31
|
React.createElement("button", { onClick: this.handlHideModal }, "Hide")),
|
|
57
32
|
this.props.item));
|
|
58
33
|
}
|
|
59
34
|
}
|
|
60
|
-
const tree = ReactTestRenderer.create(React.createElement(
|
|
35
|
+
const tree = ReactTestRenderer.create(React.createElement(Provider, null,
|
|
61
36
|
React.createElement(List, { items: ["one", "two", "three"] }),
|
|
62
37
|
React.createElement("div", { className: "modal" },
|
|
63
|
-
React.createElement(
|
|
38
|
+
React.createElement(Slot, { name: "modal" })))).toJSON();
|
|
64
39
|
expect(tree).toMatchSnapshot();
|
|
65
40
|
});
|
|
66
41
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"filler-slot.test.js","sourceRoot":"","sources":["../../../src/slot-fill/__tests__/filler-slot.test.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"filler-slot.test.js","sourceRoot":"","sources":["../../../src/slot-fill/__tests__/filler-slot.test.tsx"],"names":[],"mappings":"AAAA,oBAAoB;AACpB,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,KAAK,iBAAiB,MAAM,qBAAqB,CAAC;AACzD,OAAO,EAAC,IAAI,EAAC,IAAI,EAAC,MAAM,KAAK,CAAC;AAC9B,qCAAqC;AACrC,OAAO,EAAE,gBAAgB,IAAI,QAAQ,EAAE,MAAM,UAAU,CAAC;AACxD,OAAO,MAAM,CAAC;AAEd,QAAQ,CAAC,kBAAkB,EAAE,GAAG,EAA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,CACnB,CACC,CACd,CAAC,MAAM,EAAE,CAAC;QAEX,MAAM,CAAC,IAAI,CAAC,CAAC,eAAe,EAAE,CAAC;IACjC,CAAC,CAAC,CAAC;AAEL,CAAC,CAAC,CAAC"}
|
|
@@ -1,35 +1,10 @@
|
|
|
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 (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
1
|
/* tslint:disable */
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
class Filler extends
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import { render, fireEvent } from '@testing-library/react';
|
|
4
|
+
import { Slot, Fill, Provider } from '../';
|
|
5
|
+
import { Component } from 'react';
|
|
6
|
+
import 'jest';
|
|
7
|
+
class Filler extends Component {
|
|
33
8
|
constructor(props) {
|
|
34
9
|
super(props);
|
|
35
10
|
this.state = {
|
|
@@ -39,114 +14,114 @@ class Filler extends react_2.Component {
|
|
|
39
14
|
render() {
|
|
40
15
|
return [
|
|
41
16
|
React.createElement("button", { key: "1", type: "button", onClick: () => this.setState({ num: this.state.num + 1 }) }),
|
|
42
|
-
React.createElement(
|
|
17
|
+
React.createElement(Fill, { name: this.props.name, key: "2" }, this.props.text || this.state.num.toString()),
|
|
43
18
|
];
|
|
44
19
|
}
|
|
45
20
|
}
|
|
46
21
|
describe('Slot', () => {
|
|
47
22
|
it('should render empty Fills', () => {
|
|
48
|
-
const { container } =
|
|
23
|
+
const { container } = render(React.createElement(Provider, null,
|
|
49
24
|
React.createElement("div", null,
|
|
50
|
-
React.createElement(
|
|
51
|
-
React.createElement(
|
|
25
|
+
React.createElement(Slot, { name: "chicken" })),
|
|
26
|
+
React.createElement(Fill, { name: "chicken" })));
|
|
52
27
|
expect(container).toMatchSnapshot();
|
|
53
28
|
});
|
|
54
29
|
it('should render a string Fill', () => {
|
|
55
|
-
const { container } =
|
|
30
|
+
const { container } = render(React.createElement(Provider, null,
|
|
56
31
|
React.createElement("div", null,
|
|
57
|
-
React.createElement(
|
|
58
|
-
React.createElement(
|
|
32
|
+
React.createElement(Slot, { name: "chicken" })),
|
|
33
|
+
React.createElement(Fill, { name: "chicken" }, "content")));
|
|
59
34
|
expect(container).toMatchSnapshot();
|
|
60
35
|
});
|
|
61
36
|
it('should render a Fill containing an element', () => {
|
|
62
|
-
const { container } =
|
|
37
|
+
const { container } = render(React.createElement(Provider, null,
|
|
63
38
|
React.createElement("div", null,
|
|
64
|
-
React.createElement(
|
|
65
|
-
React.createElement(
|
|
39
|
+
React.createElement(Slot, { name: "chicken" })),
|
|
40
|
+
React.createElement(Fill, { name: "chicken" },
|
|
66
41
|
React.createElement("span", null))));
|
|
67
42
|
expect(container).toMatchSnapshot();
|
|
68
43
|
});
|
|
69
44
|
it('should render a Fill containing an array', () => {
|
|
70
|
-
const { container } =
|
|
45
|
+
const { container } = render(React.createElement(Provider, null,
|
|
71
46
|
React.createElement("div", null,
|
|
72
|
-
React.createElement(
|
|
73
|
-
React.createElement(
|
|
47
|
+
React.createElement(Slot, { name: "chicken" })),
|
|
48
|
+
React.createElement(Fill, { name: "chicken" }, [React.createElement("span", { key: "1" }), React.createElement("div", { key: "2" }), 'text'])));
|
|
74
49
|
expect(container).toMatchSnapshot();
|
|
75
50
|
});
|
|
76
51
|
it("calls the functions passed as the Slot's fillProps in the Fill", () => {
|
|
77
52
|
const onClose = jest.fn();
|
|
78
|
-
const { getByText } =
|
|
79
|
-
React.createElement(
|
|
80
|
-
React.createElement(
|
|
53
|
+
const { getByText } = render(React.createElement(Provider, null,
|
|
54
|
+
React.createElement(Slot, { name: "chicken", fillProps: { onClose } }),
|
|
55
|
+
React.createElement(Fill, { name: "chicken" }, (props) => {
|
|
81
56
|
return React.createElement("button", { onClick: props.onClose }, " Click me");
|
|
82
57
|
})));
|
|
83
|
-
|
|
58
|
+
fireEvent.click(getByText('Click me'));
|
|
84
59
|
expect(onClose).toHaveBeenCalledTimes(1);
|
|
85
60
|
});
|
|
86
61
|
it('should render empty Fills without HTML wrapper when render props used', () => {
|
|
87
|
-
const { container } =
|
|
62
|
+
const { container } = render(React.createElement(Provider, null,
|
|
88
63
|
React.createElement("div", null,
|
|
89
|
-
React.createElement(
|
|
90
|
-
React.createElement(
|
|
64
|
+
React.createElement(Slot, { name: "chicken" }, (fills) => ([...fills].length ? React.createElement("blockquote", null, fills) : null))),
|
|
65
|
+
React.createElement(Fill, { name: "chicken" })));
|
|
91
66
|
expect(container).toMatchSnapshot();
|
|
92
67
|
});
|
|
93
68
|
it('should render a string Fill with HTML wrapper when render props used', () => {
|
|
94
|
-
const { container } =
|
|
69
|
+
const { container } = render(React.createElement(Provider, null,
|
|
95
70
|
React.createElement("div", null,
|
|
96
|
-
React.createElement(
|
|
97
|
-
React.createElement(
|
|
71
|
+
React.createElement(Slot, { name: "chicken" }, (fills) => fills && React.createElement("blockquote", null, fills))),
|
|
72
|
+
React.createElement(Fill, { name: "chicken" }, "content")));
|
|
98
73
|
expect(container).toMatchSnapshot();
|
|
99
74
|
});
|
|
100
75
|
it('should re-render Slot when not bubbling virtually', () => {
|
|
101
|
-
const { container, getByRole } =
|
|
76
|
+
const { container, getByRole } = render(React.createElement(Provider, null,
|
|
102
77
|
React.createElement("div", null,
|
|
103
|
-
React.createElement(
|
|
78
|
+
React.createElement(Slot, { name: "egg" })),
|
|
104
79
|
React.createElement(Filler, { name: "egg" })));
|
|
105
80
|
expect(container).toMatchSnapshot();
|
|
106
|
-
|
|
81
|
+
fireEvent.click(getByRole('button'));
|
|
107
82
|
expect(container).toMatchSnapshot();
|
|
108
83
|
});
|
|
109
84
|
it('should render in expected order when fills always mounted', () => {
|
|
110
|
-
const { container, rerender } =
|
|
85
|
+
const { container, rerender } = render(React.createElement(Provider, null,
|
|
111
86
|
React.createElement("div", { key: "slot" },
|
|
112
|
-
React.createElement(
|
|
113
|
-
rerender(React.createElement(
|
|
87
|
+
React.createElement(Slot, { name: "egg" }))));
|
|
88
|
+
rerender(React.createElement(Provider, null,
|
|
114
89
|
React.createElement("div", { key: "slot" },
|
|
115
|
-
React.createElement(
|
|
90
|
+
React.createElement(Slot, { name: "egg" })),
|
|
116
91
|
React.createElement(Filler, { name: "egg", key: "first", text: "first" }),
|
|
117
92
|
React.createElement(Filler, { name: "egg", key: "second", text: "second" })));
|
|
118
|
-
rerender(React.createElement(
|
|
93
|
+
rerender(React.createElement(Provider, null,
|
|
119
94
|
React.createElement("div", { key: "slot" },
|
|
120
|
-
React.createElement(
|
|
121
|
-
React.createElement(
|
|
122
|
-
React.createElement(
|
|
123
|
-
React.createElement(
|
|
124
|
-
rerender(React.createElement(
|
|
95
|
+
React.createElement(Slot, { name: "egg" })),
|
|
96
|
+
React.createElement(Fill, { name: "egg", key: "first" }),
|
|
97
|
+
React.createElement(Fill, { name: "egg", key: "second" }, "second"),
|
|
98
|
+
React.createElement(Fill, { name: "egg", key: "third" }, "third")));
|
|
99
|
+
rerender(React.createElement(Provider, null,
|
|
125
100
|
React.createElement("div", { key: "slot" },
|
|
126
|
-
React.createElement(
|
|
127
|
-
React.createElement(
|
|
128
|
-
React.createElement(
|
|
129
|
-
React.createElement(
|
|
130
|
-
React.createElement(
|
|
101
|
+
React.createElement(Slot, { name: "egg" })),
|
|
102
|
+
React.createElement(Fill, { name: "egg", key: "first" }, "first (rerendered)"),
|
|
103
|
+
React.createElement(Fill, { name: "egg", key: "second" }, "second"),
|
|
104
|
+
React.createElement(Fill, { name: "egg", key: "third" }, "third"),
|
|
105
|
+
React.createElement(Fill, { name: "egg", key: "fourth" }, "fourth (new)")));
|
|
131
106
|
expect(container).toMatchSnapshot();
|
|
132
107
|
});
|
|
133
108
|
it('should render in expected order when fills unmounted', () => {
|
|
134
|
-
const { container, rerender } =
|
|
109
|
+
const { container, rerender } = render(React.createElement(Provider, null,
|
|
135
110
|
React.createElement("div", { key: "slot" },
|
|
136
|
-
React.createElement(
|
|
137
|
-
rerender(React.createElement(
|
|
111
|
+
React.createElement(Slot, { name: "egg" }))));
|
|
112
|
+
rerender(React.createElement(Provider, null,
|
|
138
113
|
React.createElement("div", { key: "slot" },
|
|
139
|
-
React.createElement(
|
|
114
|
+
React.createElement(Slot, { name: "egg" })),
|
|
140
115
|
React.createElement(Filler, { name: "egg", key: "first", text: "first" }),
|
|
141
116
|
React.createElement(Filler, { name: "egg", key: "second", text: "second" })));
|
|
142
|
-
rerender(React.createElement(
|
|
117
|
+
rerender(React.createElement(Provider, null,
|
|
143
118
|
React.createElement("div", { key: "slot" },
|
|
144
|
-
React.createElement(
|
|
119
|
+
React.createElement(Slot, { name: "egg" })),
|
|
145
120
|
React.createElement(Filler, { name: "egg", key: "second", text: "second" }),
|
|
146
121
|
React.createElement(Filler, { name: "egg", key: "third", text: "third" })));
|
|
147
|
-
rerender(React.createElement(
|
|
122
|
+
rerender(React.createElement(Provider, null,
|
|
148
123
|
React.createElement("div", { key: "slot" },
|
|
149
|
-
React.createElement(
|
|
124
|
+
React.createElement(Slot, { name: "egg" })),
|
|
150
125
|
React.createElement(Filler, { name: "egg", key: "first", text: "first (rerendered)" }),
|
|
151
126
|
React.createElement(Filler, { name: "egg", key: "second", text: "second" }),
|
|
152
127
|
React.createElement(Filler, { name: "egg", key: "third", text: "third" }),
|
|
@@ -154,50 +129,50 @@ describe('Slot', () => {
|
|
|
154
129
|
expect(container).toMatchSnapshot();
|
|
155
130
|
});
|
|
156
131
|
it('should warn without a Provider', () => {
|
|
157
|
-
const { container } =
|
|
132
|
+
const { container } = render(React.createElement(React.Fragment, null,
|
|
158
133
|
React.createElement("div", null,
|
|
159
|
-
React.createElement(
|
|
160
|
-
React.createElement(
|
|
134
|
+
React.createElement(Slot, { name: "chicken", bubblesVirtually: true })),
|
|
135
|
+
React.createElement(Fill, { name: "chicken" })));
|
|
161
136
|
expect(container).toMatchSnapshot();
|
|
162
137
|
// expect(console).toHaveWarned();
|
|
163
138
|
});
|
|
164
139
|
describe.each([false, true])('bubblesVirtually %p', (bubblesVirtually) => {
|
|
165
140
|
it('should subsume another slot by the same name', () => {
|
|
166
|
-
const { container, rerender } =
|
|
141
|
+
const { container, rerender } = render(React.createElement(Provider, null,
|
|
167
142
|
React.createElement("div", { "data-position": "first" },
|
|
168
|
-
React.createElement(
|
|
143
|
+
React.createElement(Slot, { name: "egg", bubblesVirtually: bubblesVirtually })),
|
|
169
144
|
React.createElement("div", { "data-position": "second" }),
|
|
170
|
-
React.createElement(
|
|
171
|
-
rerender(React.createElement(
|
|
145
|
+
React.createElement(Fill, { name: "egg" }, "Content")));
|
|
146
|
+
rerender(React.createElement(Provider, null,
|
|
172
147
|
React.createElement("div", { "data-position": "first" },
|
|
173
|
-
React.createElement(
|
|
148
|
+
React.createElement(Slot, { name: "egg", bubblesVirtually: bubblesVirtually })),
|
|
174
149
|
React.createElement("div", { "data-position": "second" },
|
|
175
|
-
React.createElement(
|
|
176
|
-
React.createElement(
|
|
150
|
+
React.createElement(Slot, { name: "egg", bubblesVirtually: bubblesVirtually })),
|
|
151
|
+
React.createElement(Fill, { name: "egg" }, "Content")));
|
|
177
152
|
expect(container).toMatchSnapshot();
|
|
178
|
-
rerender(React.createElement(
|
|
153
|
+
rerender(React.createElement(Provider, null,
|
|
179
154
|
React.createElement("div", { "data-position": "first" }),
|
|
180
155
|
React.createElement("div", { "data-position": "second" },
|
|
181
|
-
React.createElement(
|
|
182
|
-
React.createElement(
|
|
156
|
+
React.createElement(Slot, { name: "egg", bubblesVirtually: bubblesVirtually })),
|
|
157
|
+
React.createElement(Fill, { name: "egg" }, "Content")));
|
|
183
158
|
expect(container).toMatchSnapshot();
|
|
184
159
|
});
|
|
185
160
|
it('should unmount two slots with the same name', () => {
|
|
186
|
-
const { rerender, container } =
|
|
161
|
+
const { rerender, container } = render(React.createElement(Provider, null,
|
|
187
162
|
React.createElement("div", { "data-position": "first" },
|
|
188
|
-
React.createElement(
|
|
163
|
+
React.createElement(Slot, { name: "egg", bubblesVirtually: bubblesVirtually })),
|
|
189
164
|
React.createElement("div", { "data-position": "second" },
|
|
190
|
-
React.createElement(
|
|
191
|
-
React.createElement(
|
|
192
|
-
rerender(React.createElement(
|
|
165
|
+
React.createElement(Slot, { name: "egg", bubblesVirtually: bubblesVirtually })),
|
|
166
|
+
React.createElement(Fill, { name: "egg" }, "Content")));
|
|
167
|
+
rerender(React.createElement(Provider, null,
|
|
193
168
|
React.createElement("div", { "data-position": "first" },
|
|
194
|
-
React.createElement(
|
|
169
|
+
React.createElement(Slot, { name: "egg", bubblesVirtually: bubblesVirtually })),
|
|
195
170
|
React.createElement("div", { "data-position": "second" }),
|
|
196
|
-
React.createElement(
|
|
197
|
-
rerender(React.createElement(
|
|
171
|
+
React.createElement(Fill, { name: "egg" }, "Content")));
|
|
172
|
+
rerender(React.createElement(Provider, null,
|
|
198
173
|
React.createElement("div", { "data-position": "first" }),
|
|
199
174
|
React.createElement("div", { "data-position": "second" }),
|
|
200
|
-
React.createElement(
|
|
175
|
+
React.createElement(Fill, { name: "egg" }, "Content")));
|
|
201
176
|
expect(container).toMatchSnapshot();
|
|
202
177
|
});
|
|
203
178
|
});
|
|
@@ -206,23 +181,23 @@ describe('Slot', () => {
|
|
|
206
181
|
describe('Slot with logic', () => {
|
|
207
182
|
it('should render a string Fill with HTML wrapper when render props used', () => {
|
|
208
183
|
const Fill1 = (props) => {
|
|
209
|
-
return (React.createElement(
|
|
184
|
+
return (React.createElement(Fill, { name: "chicken", fillId: "id1" }, (props) => {
|
|
210
185
|
return 'content';
|
|
211
186
|
}));
|
|
212
187
|
};
|
|
213
188
|
const Fill2 = (props) => {
|
|
214
|
-
return (React.createElement(
|
|
189
|
+
return (React.createElement(Fill, { name: "chicken", fillId: "id2" }, (props) => {
|
|
215
190
|
console.log('--filler--props', props);
|
|
216
191
|
return 'content1';
|
|
217
192
|
}));
|
|
218
193
|
};
|
|
219
194
|
const Slot1 = (props) => {
|
|
220
|
-
return (React.createElement(
|
|
195
|
+
return (React.createElement(Slot, { name: "chicken", fillProps: { selected: 'one' } }, (fills) => {
|
|
221
196
|
console.log('---files', fills);
|
|
222
197
|
return fills && React.createElement("blockquote", null, "Test");
|
|
223
198
|
}));
|
|
224
199
|
};
|
|
225
|
-
const { container } =
|
|
200
|
+
const { container } = render(React.createElement(Provider, null,
|
|
226
201
|
React.createElement("div", null,
|
|
227
202
|
React.createElement(Slot1, null)),
|
|
228
203
|
React.createElement(Fill1, null),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"slot-features.test.js","sourceRoot":"","sources":["../../../src/slot-fill/__tests__/slot-features.test.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"slot-features.test.js","sourceRoot":"","sources":["../../../src/slot-fill/__tests__/slot-features.test.tsx"],"names":[],"mappings":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C5B,CAAC,KAAK,EAAE,EAAE;gBACP,OAAO,CAAC,GAAG,CAAC,iBAAiB,EAAE,KAAK,CAAC,CAAC;gBACtC,OAAO,UAAU,CAAC;YACtB,CAAC,CACE,CACV,CAAC;QACN,CAAC,CAAC;QAEF,MAAM,KAAK,GAAG,CAAC,KAAK,EAAE,EAAE;YACpB,OAAO,CACH,oBAAC,IAAI,IAAC,IAAI,EAAC,SAAS,EAAC,SAAS,EAAE,EAAE,QAAQ,EAAE,KAAK,EAAE,IAC9C,CAAC,KAAK,EAAE,EAAE;gBACP,OAAO,CAAC,GAAG,CAAC,UAAU,EAAE,KAAK,CAAC,CAAC;gBAC/B,OAAO,KAAK,IAAI,+CAA6B,CAAC;YAClD,CAAC,CACE,CACV,CAAC;QACN,CAAC,CAAC;QACF,MAAM,EAAE,SAAS,EAAE,GAAG,MAAM,CACxB,oBAAC,QAAQ;YACL;gBACI,oBAAC,KAAK,OAAG,CACP;YACN,oBAAC,KAAK,OAAG;YACT,oBAAC,KAAK,OAAG,CACF,CACd,CAAC;QACF,MAAM,CAAC,SAAS,CAAC,CAAC,eAAe,EAAE,CAAC;IACxC,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC"}
|
|
@@ -1,30 +1,4 @@
|
|
|
1
|
-
|
|
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 (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.Provider = exports.Consumer = void 0;
|
|
27
|
-
const React = __importStar(require("react"));
|
|
1
|
+
import * as React from 'react';
|
|
28
2
|
const SlotFillContext = React.createContext({
|
|
29
3
|
registerSlot: () => { },
|
|
30
4
|
unregisterSlot: () => { },
|
|
@@ -36,7 +10,6 @@ const SlotFillContext = React.createContext({
|
|
|
36
10
|
subscribe: () => { },
|
|
37
11
|
});
|
|
38
12
|
const { Provider, Consumer } = SlotFillContext;
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
exports.default = SlotFillContext;
|
|
13
|
+
export { Consumer, Provider };
|
|
14
|
+
export default SlotFillContext;
|
|
42
15
|
//# sourceMappingURL=context.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context.js","sourceRoot":"","sources":["../../../src/slot-fill/base/context.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"context.js","sourceRoot":"","sources":["../../../src/slot-fill/base/context.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;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;AAC/C,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,CAAC;AAC9B,eAAe,eAAe,CAAC"}
|
|
@@ -1,34 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
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 (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
const react_1 = __importStar(require("react"));
|
|
27
|
-
const react_dom_1 = require("react-dom");
|
|
28
|
-
const context_1 = require("./context");
|
|
29
|
-
const use_slot_1 = require("./use-slot");
|
|
1
|
+
import React, { useRef } from 'react';
|
|
2
|
+
import { createPortal } from 'react-dom';
|
|
3
|
+
import { Consumer } from './context';
|
|
4
|
+
import { useSlot } from './use-slot';
|
|
30
5
|
const FillComponent = ({ name, children, registerFill, unregisterFill, serverMode }) => {
|
|
31
|
-
const slot =
|
|
6
|
+
const slot = useSlot(name);
|
|
32
7
|
let useLayoutEffect;
|
|
33
8
|
if (serverMode) {
|
|
34
9
|
useLayoutEffect = (args) => { };
|
|
@@ -38,9 +13,9 @@ const FillComponent = ({ name, children, registerFill, unregisterFill, serverMod
|
|
|
38
13
|
return null;
|
|
39
14
|
}
|
|
40
15
|
else {
|
|
41
|
-
useLayoutEffect =
|
|
16
|
+
useLayoutEffect = React.useLayoutEffect;
|
|
42
17
|
}
|
|
43
|
-
const ref =
|
|
18
|
+
const ref = useRef({
|
|
44
19
|
name,
|
|
45
20
|
children,
|
|
46
21
|
});
|
|
@@ -80,11 +55,11 @@ const FillComponent = ({ name, children, registerFill, unregisterFill, serverMod
|
|
|
80
55
|
if (typeof children === 'function') {
|
|
81
56
|
children = children(slot.props.fillProps);
|
|
82
57
|
}
|
|
83
|
-
return
|
|
58
|
+
return createPortal(children, slot.node);
|
|
84
59
|
};
|
|
85
60
|
const Fill = (props) => {
|
|
86
61
|
const serverMode = (typeof window === 'undefined');
|
|
87
|
-
return (
|
|
62
|
+
return (React.createElement(Consumer, null, ({ registerFill, unregisterFill }) => (React.createElement(FillComponent, Object.assign({}, props, { registerFill: registerFill, unregisterFill: unregisterFill, serverMode: serverMode })))));
|
|
88
63
|
};
|
|
89
|
-
|
|
64
|
+
export default Fill;
|
|
90
65
|
//# sourceMappingURL=fill.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fill.js","sourceRoot":"","sources":["../../../src/slot-fill/base/fill.tsx"],"names":[],"mappings":"
|
|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