@common-stack/components-pro 0.2.29 → 0.3.1-alpha.1
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/slot-fill/__tests__/slot-features.test.js +30 -31
- package/lib/slot-fill/__tests__/slot-features.test.js.map +1 -1
- package/lib/slot-fill/__tests__/slot-fill-provider.test.d.ts +0 -0
- package/lib/slot-fill/__tests__/slot-fill-provider.test.js +58 -0
- package/lib/slot-fill/__tests__/slot-fill-provider.test.js.map +1 -0
- package/lib/slot-fill/base/fill.js +15 -6
- package/lib/slot-fill/base/fill.js.map +1 -1
- package/lib/slot-fill/base/provider.d.ts +4 -2
- package/lib/slot-fill/base/provider.js +3 -2
- package/lib/slot-fill/base/provider.js.map +1 -1
- package/lib/slot-fill/base/slot.d.ts +1 -2
- package/lib/slot-fill/base/slot.js +20 -11
- package/lib/slot-fill/base/slot.js.map +1 -1
- package/lib/slot-fill/base/use-slot.js +3 -0
- package/lib/slot-fill/base/use-slot.js.map +1 -1
- package/lib/slot-fill/bubbles-virtually/fill.js +16 -5
- package/lib/slot-fill/bubbles-virtually/fill.js.map +1 -1
- package/lib/slot-fill/bubbles-virtually/slot-fill-context.js +3 -2
- package/lib/slot-fill/bubbles-virtually/slot-fill-context.js.map +1 -1
- package/lib/slot-fill/bubbles-virtually/slot-fill-provider.js +23 -48
- package/lib/slot-fill/bubbles-virtually/slot-fill-provider.js.map +1 -1
- package/lib/slot-fill/bubbles-virtually/slot.js +8 -9
- package/lib/slot-fill/bubbles-virtually/slot.js.map +1 -1
- package/lib/slot-fill/bubbles-virtually/use-slot-fills.d.ts +1 -0
- package/lib/slot-fill/bubbles-virtually/use-slot-fills.js +18 -0
- package/lib/slot-fill/bubbles-virtually/use-slot-fills.js.map +1 -0
- package/lib/slot-fill/bubbles-virtually/use-slot.js +26 -13
- package/lib/slot-fill/bubbles-virtually/use-slot.js.map +1 -1
- package/lib/slot-fill/index.d.ts +1 -0
- package/lib/slot-fill/index.js +3 -1
- package/lib/slot-fill/index.js.map +1 -1
- package/lib/slot-fill/interfaces/index.d.ts +1 -1
- package/lib/slot-fill/utils/isEmptyElement.d.ts +1 -2
- package/lib/slot-fill/utils/isEmptyElement.js +2 -3
- package/lib/slot-fill/utils/isEmptyElement.js.map +1 -1
- package/package.json +59 -58
|
@@ -25,7 +25,6 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
26
|
/* tslint:disable */
|
|
27
27
|
const React = __importStar(require("react"));
|
|
28
|
-
const lodash_1 = require("lodash");
|
|
29
28
|
const react_1 = require("@testing-library/react");
|
|
30
29
|
const __1 = require("../");
|
|
31
30
|
const react_2 = require("react");
|
|
@@ -34,32 +33,32 @@ class Filler extends react_2.Component {
|
|
|
34
33
|
constructor(props) {
|
|
35
34
|
super(props);
|
|
36
35
|
this.state = {
|
|
37
|
-
num: 1
|
|
36
|
+
num: 1,
|
|
38
37
|
};
|
|
39
38
|
}
|
|
40
39
|
render() {
|
|
41
40
|
return [
|
|
42
41
|
React.createElement("button", { key: "1", type: "button", onClick: () => this.setState({ num: this.state.num + 1 }) }),
|
|
43
|
-
React.createElement(__1.Fill, { name: this.props.name, key: "2" }, this.props.text || this.state.num.toString())
|
|
42
|
+
React.createElement(__1.Fill, { name: this.props.name, key: "2" }, this.props.text || this.state.num.toString()),
|
|
44
43
|
];
|
|
45
44
|
}
|
|
46
45
|
}
|
|
47
|
-
describe(
|
|
48
|
-
it(
|
|
46
|
+
describe('Slot', () => {
|
|
47
|
+
it('should render empty Fills', () => {
|
|
49
48
|
const { container } = (0, react_1.render)(React.createElement(__1.Provider, null,
|
|
50
49
|
React.createElement("div", null,
|
|
51
50
|
React.createElement(__1.Slot, { name: "chicken" })),
|
|
52
51
|
React.createElement(__1.Fill, { name: "chicken" })));
|
|
53
52
|
expect(container).toMatchSnapshot();
|
|
54
53
|
});
|
|
55
|
-
it(
|
|
54
|
+
it('should render a string Fill', () => {
|
|
56
55
|
const { container } = (0, react_1.render)(React.createElement(__1.Provider, null,
|
|
57
56
|
React.createElement("div", null,
|
|
58
57
|
React.createElement(__1.Slot, { name: "chicken" })),
|
|
59
58
|
React.createElement(__1.Fill, { name: "chicken" }, "content")));
|
|
60
59
|
expect(container).toMatchSnapshot();
|
|
61
60
|
});
|
|
62
|
-
it(
|
|
61
|
+
it('should render a Fill containing an element', () => {
|
|
63
62
|
const { container } = (0, react_1.render)(React.createElement(__1.Provider, null,
|
|
64
63
|
React.createElement("div", null,
|
|
65
64
|
React.createElement(__1.Slot, { name: "chicken" })),
|
|
@@ -67,38 +66,38 @@ describe("Slot", () => {
|
|
|
67
66
|
React.createElement("span", null))));
|
|
68
67
|
expect(container).toMatchSnapshot();
|
|
69
68
|
});
|
|
70
|
-
it(
|
|
69
|
+
it('should render a Fill containing an array', () => {
|
|
71
70
|
const { container } = (0, react_1.render)(React.createElement(__1.Provider, null,
|
|
72
71
|
React.createElement("div", null,
|
|
73
72
|
React.createElement(__1.Slot, { name: "chicken" })),
|
|
74
|
-
React.createElement(__1.Fill, { name: "chicken" }, [React.createElement("span", { key: "1" }), React.createElement("div", { key: "2" }),
|
|
73
|
+
React.createElement(__1.Fill, { name: "chicken" }, [React.createElement("span", { key: "1" }), React.createElement("div", { key: "2" }), 'text'])));
|
|
75
74
|
expect(container).toMatchSnapshot();
|
|
76
75
|
});
|
|
77
76
|
it("calls the functions passed as the Slot's fillProps in the Fill", () => {
|
|
78
77
|
const onClose = jest.fn();
|
|
79
78
|
const { getByText } = (0, react_1.render)(React.createElement(__1.Provider, null,
|
|
80
79
|
React.createElement(__1.Slot, { name: "chicken", fillProps: { onClose } }),
|
|
81
|
-
React.createElement(__1.Fill, { name: "chicken" }, props => {
|
|
80
|
+
React.createElement(__1.Fill, { name: "chicken" }, (props) => {
|
|
82
81
|
return React.createElement("button", { onClick: props.onClose }, " Click me");
|
|
83
82
|
})));
|
|
84
83
|
react_1.fireEvent.click(getByText('Click me'));
|
|
85
84
|
expect(onClose).toHaveBeenCalledTimes(1);
|
|
86
85
|
});
|
|
87
|
-
it(
|
|
86
|
+
it('should render empty Fills without HTML wrapper when render props used', () => {
|
|
88
87
|
const { container } = (0, react_1.render)(React.createElement(__1.Provider, null,
|
|
89
88
|
React.createElement("div", null,
|
|
90
|
-
React.createElement(__1.Slot, { name: "chicken" }, fills =>
|
|
89
|
+
React.createElement(__1.Slot, { name: "chicken" }, (fills) => ([...fills].length ? React.createElement("blockquote", null, fills) : null))),
|
|
91
90
|
React.createElement(__1.Fill, { name: "chicken" })));
|
|
92
91
|
expect(container).toMatchSnapshot();
|
|
93
92
|
});
|
|
94
|
-
it(
|
|
93
|
+
it('should render a string Fill with HTML wrapper when render props used', () => {
|
|
95
94
|
const { container } = (0, react_1.render)(React.createElement(__1.Provider, null,
|
|
96
95
|
React.createElement("div", null,
|
|
97
|
-
React.createElement(__1.Slot, { name: "chicken" }, fills => fills && React.createElement("blockquote", null, fills))),
|
|
96
|
+
React.createElement(__1.Slot, { name: "chicken" }, (fills) => fills && React.createElement("blockquote", null, fills))),
|
|
98
97
|
React.createElement(__1.Fill, { name: "chicken" }, "content")));
|
|
99
98
|
expect(container).toMatchSnapshot();
|
|
100
99
|
});
|
|
101
|
-
it(
|
|
100
|
+
it('should re-render Slot when not bubbling virtually', () => {
|
|
102
101
|
const { container, getByRole } = (0, react_1.render)(React.createElement(__1.Provider, null,
|
|
103
102
|
React.createElement("div", null,
|
|
104
103
|
React.createElement(__1.Slot, { name: "egg" })),
|
|
@@ -107,7 +106,7 @@ describe("Slot", () => {
|
|
|
107
106
|
react_1.fireEvent.click(getByRole('button'));
|
|
108
107
|
expect(container).toMatchSnapshot();
|
|
109
108
|
});
|
|
110
|
-
it(
|
|
109
|
+
it('should render in expected order when fills always mounted', () => {
|
|
111
110
|
const { container, rerender } = (0, react_1.render)(React.createElement(__1.Provider, null,
|
|
112
111
|
React.createElement("div", { key: "slot" },
|
|
113
112
|
React.createElement(__1.Slot, { name: "egg" }))));
|
|
@@ -162,8 +161,8 @@ describe("Slot", () => {
|
|
|
162
161
|
expect(container).toMatchSnapshot();
|
|
163
162
|
// expect(console).toHaveWarned();
|
|
164
163
|
});
|
|
165
|
-
describe.each([false, true])(
|
|
166
|
-
it(
|
|
164
|
+
describe.each([false, true])('bubblesVirtually %p', (bubblesVirtually) => {
|
|
165
|
+
it('should subsume another slot by the same name', () => {
|
|
167
166
|
const { container, rerender } = (0, react_1.render)(React.createElement(__1.Provider, null,
|
|
168
167
|
React.createElement("div", { "data-position": "first" },
|
|
169
168
|
React.createElement(__1.Slot, { name: "egg", bubblesVirtually: bubblesVirtually })),
|
|
@@ -204,22 +203,22 @@ describe("Slot", () => {
|
|
|
204
203
|
});
|
|
205
204
|
});
|
|
206
205
|
//@sri custom logic
|
|
207
|
-
describe(
|
|
208
|
-
it(
|
|
209
|
-
const Fill1 = props => {
|
|
210
|
-
return React.createElement(__1.Fill, { name: "chicken", fillId:
|
|
211
|
-
return
|
|
212
|
-
});
|
|
206
|
+
describe('Slot with logic', () => {
|
|
207
|
+
it('should render a string Fill with HTML wrapper when render props used', () => {
|
|
208
|
+
const Fill1 = (props) => {
|
|
209
|
+
return (React.createElement(__1.Fill, { name: "chicken", fillId: "id1" }, (props) => {
|
|
210
|
+
return 'content';
|
|
211
|
+
}));
|
|
213
212
|
};
|
|
214
|
-
const Fill2 = props => {
|
|
215
|
-
return (React.createElement(__1.Fill, { name: "chicken", fillId:
|
|
216
|
-
console.log(
|
|
217
|
-
return
|
|
213
|
+
const Fill2 = (props) => {
|
|
214
|
+
return (React.createElement(__1.Fill, { name: "chicken", fillId: "id2" }, (props) => {
|
|
215
|
+
console.log('--filler--props', props);
|
|
216
|
+
return 'content1';
|
|
218
217
|
}));
|
|
219
218
|
};
|
|
220
|
-
const Slot1 = props => {
|
|
221
|
-
return (React.createElement(__1.Slot, { name: "chicken", fillProps: { selected:
|
|
222
|
-
console.log(
|
|
219
|
+
const Slot1 = (props) => {
|
|
220
|
+
return (React.createElement(__1.Slot, { name: "chicken", fillProps: { selected: 'one' } }, (fills) => {
|
|
221
|
+
console.log('---files', fills);
|
|
223
222
|
return fills && React.createElement("blockquote", null, "Test");
|
|
224
223
|
}));
|
|
225
224
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"slot-features.test.js","sourceRoot":"","sources":["../../../src/slot-fill/__tests__/slot-features.test.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,oBAAoB;AACpB,6CAA+B;AAC/B,
|
|
1
|
+
{"version":3,"file":"slot-features.test.js","sourceRoot":"","sources":["../../../src/slot-fill/__tests__/slot-features.test.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,oBAAoB;AACpB,6CAA+B;AAC/B,kDAA2D;AAC3D,2BAA2C;AAC3C,iCAAkC;AAClC,gBAAc;AAEd,MAAM,MAAO,SAAQ,iBAAmB;IACpC,YAAY,KAAK;QACb,KAAK,CAAC,KAAK,CAAC,CAAC;QAEb,IAAI,CAAC,KAAK,GAAG;YACT,GAAG,EAAE,CAAC;SACT,CAAC;IACN,CAAC;IACM,MAAM;QACT,OAAO;YACH,gCAAQ,GAAG,EAAC,GAAG,EAAC,IAAI,EAAC,QAAQ,EAAC,OAAO,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,GAAG,EAAE,IAAI,CAAC,KAAK,CAAC,GAAG,GAAG,CAAC,EAAE,CAAC,GAAI;YAC3F,oBAAC,QAAI,IAAC,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,GAAG,EAAC,GAAG,IAC/B,IAAI,CAAC,KAAK,CAAC,IAAI,IAAI,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,QAAQ,EAAE,CAC1C;SACV,CAAC;IACN,CAAC;CACJ;AAED,QAAQ,CAAC,MAAM,EAAE,GAAG,EAAE;IAClB,EAAE,CAAC,2BAA2B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AsE,EAAE,GAAG,EAAE;QAC5E,MAAM,KAAK,GAAG,CAAC,KAAK,EAAE,EAAE;YACpB,OAAO,CACH,oBAAC,QAAI,IAAC,IAAI,EAAC,SAAS,EAAC,MAAM,EAAC,KAAK,IAC5B,CAAC,KAAK,EAAE,EAAE;gBACP,OAAO,SAAS,CAAC;YACrB,CAAC,CACE,CACV,CAAC;QACN,CAAC,CAAC;QACF,MAAM,KAAK,GAAG,CAAC,KAAK,EAAE,EAAE;YACpB,OAAO,CACH,oBAAC,QAAI,IAAC,IAAI,EAAC,SAAS,EAAC,MAAM,EAAC,KAAK,IAC5B,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,QAAI,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,IAAA,cAAM,EACxB,oBAAC,YAAQ;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"}
|
|
File without changes
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
// import * as React from 'react';
|
|
2
|
+
// import { render, screen, within } from '@testing-library/react';
|
|
3
|
+
// import { createSlotFill, Provider as SlotFillProvider } from '../';
|
|
4
|
+
// describe('createSlotFill', () => {
|
|
5
|
+
// test('should render all slot fills in order of rendering', () => {
|
|
6
|
+
// const PostSidebar: any = createSlotFill('PostSidebar');
|
|
7
|
+
// render(
|
|
8
|
+
// <SlotFillProvider>
|
|
9
|
+
// <PostSidebar.Fill>
|
|
10
|
+
// <p>Post Section 1</p>
|
|
11
|
+
// </PostSidebar.Fill>
|
|
12
|
+
// <PostSidebar.Fill>
|
|
13
|
+
// <p>Post Section 2</p>
|
|
14
|
+
// </PostSidebar.Fill>
|
|
15
|
+
// <div title="Post Sidebar">
|
|
16
|
+
// <PostSidebar.Slot />
|
|
17
|
+
// </div>
|
|
18
|
+
// </SlotFillProvider>,
|
|
19
|
+
// );
|
|
20
|
+
// const postSidebar = screen.getByTitle('Post Sidebar');
|
|
21
|
+
// const postSections = within(postSidebar).getAllByText(/Post Section \d/);
|
|
22
|
+
// expect(postSidebar).toBeVisible();
|
|
23
|
+
// expect(postSections).toHaveLength(2);
|
|
24
|
+
// postSections.forEach((postSection, index) => {
|
|
25
|
+
// expect(postSection).toBeVisible();
|
|
26
|
+
// expect(postSection).toHaveTextContent(`Post Section ${index + 1}`);
|
|
27
|
+
// });
|
|
28
|
+
// });
|
|
29
|
+
// test('should support separate multiple slots and fills', () => {
|
|
30
|
+
// const PostSidebar = createSlotFill('PostSidebar');
|
|
31
|
+
// const PageSidebar = createSlotFill('PageSidebar');
|
|
32
|
+
// render(
|
|
33
|
+
// <SlotFillProvider>
|
|
34
|
+
// <PostSidebar.Fill>
|
|
35
|
+
// <p>Post Section</p>
|
|
36
|
+
// </PostSidebar.Fill>
|
|
37
|
+
// <PageSidebar.Fill>
|
|
38
|
+
// <p>Page Section</p>
|
|
39
|
+
// </PageSidebar.Fill>
|
|
40
|
+
// <div title="Post Sidebar">
|
|
41
|
+
// <PostSidebar.Slot />
|
|
42
|
+
// </div>
|
|
43
|
+
// <div title="Page Sidebar">
|
|
44
|
+
// <PageSidebar.Slot />
|
|
45
|
+
// </div>
|
|
46
|
+
// </SlotFillProvider>,
|
|
47
|
+
// );
|
|
48
|
+
// const postSidebar = screen.getByTitle('Post Sidebar');
|
|
49
|
+
// expect(postSidebar).toBeVisible();
|
|
50
|
+
// expect(within(postSidebar).getByText('Post Section')).toBeVisible();
|
|
51
|
+
// const pageSidebar = screen.getByTitle('Page Sidebar');
|
|
52
|
+
// expect(pageSidebar).toBeVisible();
|
|
53
|
+
// expect(within(pageSidebar).getByText('Page Section')).toBeVisible();
|
|
54
|
+
// expect(within(postSidebar).queryByText('Page Section')).not.toBeInTheDocument();
|
|
55
|
+
// expect(within(pageSidebar).queryByText('Post Section')).not.toBeInTheDocument();
|
|
56
|
+
// });
|
|
57
|
+
// });
|
|
58
|
+
//# sourceMappingURL=slot-fill-provider.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"slot-fill-provider.test.js","sourceRoot":"","sources":["../../../src/slot-fill/__tests__/slot-fill-provider.test.tsx"],"names":[],"mappings":"AAAA,kCAAkC;AAClC,mEAAmE;AACnE,sEAAsE;AAEtE,qCAAqC;AACrC,yEAAyE;AACzE,kEAAkE;AAElE,kBAAkB;AAClB,iCAAiC;AACjC,qCAAqC;AACrC,4CAA4C;AAC5C,sCAAsC;AACtC,qCAAqC;AACrC,4CAA4C;AAC5C,sCAAsC;AACtC,6CAA6C;AAC7C,2CAA2C;AAC3C,yBAAyB;AACzB,mCAAmC;AACnC,aAAa;AAEb,iEAAiE;AACjE,oFAAoF;AAEpF,6CAA6C;AAC7C,gDAAgD;AAChD,yDAAyD;AACzD,iDAAiD;AACjD,kFAAkF;AAClF,cAAc;AACd,UAAU;AAEV,uEAAuE;AACvE,6DAA6D;AAC7D,6DAA6D;AAE7D,kBAAkB;AAClB,iCAAiC;AACjC,qCAAqC;AACrC,0CAA0C;AAC1C,sCAAsC;AACtC,qCAAqC;AACrC,0CAA0C;AAC1C,sCAAsC;AACtC,6CAA6C;AAC7C,2CAA2C;AAC3C,yBAAyB;AACzB,6CAA6C;AAC7C,2CAA2C;AAC3C,yBAAyB;AACzB,mCAAmC;AACnC,aAAa;AAEb,iEAAiE;AAEjE,6CAA6C;AAC7C,+EAA+E;AAE/E,iEAAiE;AAEjE,6CAA6C;AAC7C,+EAA+E;AAE/E,2FAA2F;AAC3F,2FAA2F;AAC3F,UAAU;AACV,MAAM"}
|
|
@@ -25,24 +25,30 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
26
|
const react_1 = __importStar(require("react"));
|
|
27
27
|
const react_dom_1 = require("react-dom");
|
|
28
|
-
const lodash_1 = require("lodash");
|
|
29
28
|
const context_1 = require("./context");
|
|
30
29
|
const use_slot_1 = require("./use-slot");
|
|
31
|
-
const FillComponent = ({ name, children, registerFill, unregisterFill
|
|
30
|
+
const FillComponent = ({ name, children, registerFill, unregisterFill }) => {
|
|
32
31
|
const slot = (0, use_slot_1.useSlot)(name);
|
|
33
32
|
const ref = (0, react_1.useRef)({
|
|
34
33
|
name,
|
|
35
34
|
children,
|
|
36
35
|
});
|
|
37
36
|
(0, react_1.useLayoutEffect)(() => {
|
|
38
|
-
|
|
39
|
-
|
|
37
|
+
const refValue = ref.current;
|
|
38
|
+
registerFill(name, refValue);
|
|
39
|
+
return () => unregisterFill(name, refValue);
|
|
40
|
+
// Ignore reason: the useLayoutEffects here are written to fire at specific times, and introducing new dependencies could cause unexpected changes in behavior.
|
|
41
|
+
// We'll leave them as-is until a more detailed investigation/refactor can be performed.
|
|
42
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
40
43
|
}, []);
|
|
41
44
|
(0, react_1.useLayoutEffect)(() => {
|
|
42
45
|
ref.current.children = children;
|
|
43
46
|
if (slot) {
|
|
44
47
|
slot.forceUpdate();
|
|
45
48
|
}
|
|
49
|
+
// Ignore reason: the useLayoutEffects here are written to fire at specific times, and introducing new dependencies could cause unexpected changes in behavior.
|
|
50
|
+
// We'll leave them as-is until a more detailed investigation/refactor can be performed.
|
|
51
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
46
52
|
}, [children]);
|
|
47
53
|
(0, react_1.useLayoutEffect)(() => {
|
|
48
54
|
if (name === ref.current.name) {
|
|
@@ -52,17 +58,20 @@ const FillComponent = ({ name, children, registerFill, unregisterFill, }) => {
|
|
|
52
58
|
unregisterFill(ref.current.name, ref.current);
|
|
53
59
|
ref.current.name = name;
|
|
54
60
|
registerFill(name, ref.current);
|
|
61
|
+
// Ignore reason: the useLayoutEffects here are written to fire at specific times, and introducing new dependencies could cause unexpected changes in behavior.
|
|
62
|
+
// We'll leave them as-is until a more detailed investigation/refactor can be performed.
|
|
63
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
55
64
|
}, [name]);
|
|
56
65
|
if (!slot || !slot.node) {
|
|
57
66
|
return null;
|
|
58
67
|
}
|
|
59
68
|
// If a function is passed as a child, provide it with the fillProps.
|
|
60
|
-
if (
|
|
69
|
+
if (typeof children === 'function') {
|
|
61
70
|
children = children(slot.props.fillProps);
|
|
62
71
|
}
|
|
63
72
|
return (0, react_dom_1.createPortal)(children, slot.node);
|
|
64
73
|
};
|
|
65
|
-
const Fill = props => {
|
|
74
|
+
const Fill = (props) => {
|
|
66
75
|
return (react_1.default.createElement(context_1.Consumer, null, ({ registerFill, unregisterFill }) => (react_1.default.createElement(FillComponent, Object.assign({}, props, { registerFill: registerFill, unregisterFill: unregisterFill })))));
|
|
67
76
|
};
|
|
68
77
|
exports.default = Fill;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fill.js","sourceRoot":"","sources":["../../../src/slot-fill/base/fill.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+
|
|
1
|
+
{"version":3,"file":"fill.js","sourceRoot":"","sources":["../../../src/slot-fill/base/fill.tsx"],"names":[],"mappings":";;;;;;;;;;;;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,uDAAuD;IACrD,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC;IAEX,IAAI,CAAC,IAAI,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE;QACrB,OAAO,IAAI,CAAC;KACf;IAED,qEAAqE;IACrE,IAAI,OAAO,QAAQ,KAAK,UAAU,EAAE;QAChC,QAAQ,GAAG,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;KAC7C;IAED,OAAO,IAAA,wBAAY,EAAC,QAAQ,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC;AAC7C,CAAC,CAAC;AAOF,MAAM,IAAI,GAAmB,CAAC,KAAK,EAAE,EAAE;IACnC,OAAO,CACH,8BAAC,kBAAQ,QACJ,CAAC,EAAE,YAAY,EAAE,cAAc,EAAE,EAAE,EAAE,CAAC,CACnC,8BAAC,aAAa,oBAAK,KAAK,IAAE,YAAY,EAAE,YAAY,EAAE,cAAc,EAAE,cAAc,IAAI,CAC3F,CACM,CACd,CAAC;AACN,CAAC,CAAC;AAEF,kBAAe,IAAI,CAAC"}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
import { Component } from 'react';
|
|
1
|
+
import { Component, ReactNode } from 'react';
|
|
2
2
|
import { IFill, ISlot } from '../interfaces';
|
|
3
|
-
declare class SlotFillProvider extends Component<{
|
|
3
|
+
declare class SlotFillProvider extends Component<{
|
|
4
|
+
children: ReactNode;
|
|
5
|
+
}, {}> {
|
|
4
6
|
private slots;
|
|
5
7
|
private fills;
|
|
6
8
|
private listeners;
|
|
@@ -80,7 +80,8 @@ class SlotFillProvider extends react_1.Component {
|
|
|
80
80
|
this.triggerListeners();
|
|
81
81
|
}
|
|
82
82
|
unregisterFill(name, instance) {
|
|
83
|
-
|
|
83
|
+
var _a, _b;
|
|
84
|
+
this.fills[name] = (_b = (_a = this.fills[name]) === null || _a === void 0 ? void 0 : _a.filter((fill) => fill !== instance)) !== null && _b !== void 0 ? _b : [];
|
|
84
85
|
this.forceUpdateSlot(name);
|
|
85
86
|
}
|
|
86
87
|
getSlot(name) {
|
|
@@ -110,7 +111,7 @@ class SlotFillProvider extends react_1.Component {
|
|
|
110
111
|
subscribe(listener) {
|
|
111
112
|
this.listeners.push(listener);
|
|
112
113
|
return () => {
|
|
113
|
-
this.listeners =
|
|
114
|
+
this.listeners = this.listeners.filter((l) => l !== listener);
|
|
114
115
|
};
|
|
115
116
|
}
|
|
116
117
|
render() {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"provider.js","sourceRoot":"","sources":["../../../src/slot-fill/base/provider.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+
|
|
1
|
+
{"version":3,"file":"provider.js","sourceRoot":"","sources":["../../../src/slot-fill/base/provider.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+CAAoD;AACpD,mCAAyC;AAEzC,uCAAqC;AAErC,MAAM,gBAAiB,SAAQ,iBAAsC;IAKjE,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,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AAC;IACrD,CAAC;IAEM,SAAS,CAAC,QAAQ;QACrB,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QAE9B,OAAO,GAAG,EAAE;YACR,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,SAAS,CAAC,MAAM,CAAE,CAAE,CAAC,EAAG,EAAE,CAAC,CAAC,KAAK,QAAQ,CAAE,CAAC;QACtE,CAAC,CAAC;IACN,CAAC;IAEM,MAAM;QACT,OAAO,8BAAC,kBAAQ,IAAC,KAAK,EAAE,IAAI,CAAC,YAAY,IAAG,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAY,CAAC;IAChF,CAAC;CACJ;AAED,kBAAe,gBAAgB,CAAC"}
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import { SFC } from 'react';
|
|
2
1
|
import { ISlotProps, IContext } from '../interfaces';
|
|
3
2
|
export declare namespace ISlotComponent {
|
|
4
3
|
interface Props extends Partial<IContext>, ISlotProps {
|
|
5
4
|
}
|
|
6
5
|
}
|
|
7
|
-
declare const Slot:
|
|
6
|
+
declare const Slot: (props: ISlotProps) => JSX.Element;
|
|
8
7
|
export default Slot;
|
|
@@ -23,10 +23,18 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
const lodash_1 = require("lodash");
|
|
27
26
|
const react_1 = __importStar(require("react"));
|
|
28
27
|
const context_1 = require("./context");
|
|
29
28
|
const isEmptyElement_1 = require("../utils/isEmptyElement");
|
|
29
|
+
/**
|
|
30
|
+
* Whether the argument is a function.
|
|
31
|
+
*
|
|
32
|
+
* @param {*} maybeFunc The argument to check.
|
|
33
|
+
* @returns {boolean} True if the argument is a function, false otherwise.
|
|
34
|
+
*/
|
|
35
|
+
function isFunction(maybeFunc) {
|
|
36
|
+
return typeof maybeFunc === 'function';
|
|
37
|
+
}
|
|
30
38
|
class SlotComponent extends react_1.Component {
|
|
31
39
|
constructor(props) {
|
|
32
40
|
super(props);
|
|
@@ -60,27 +68,28 @@ class SlotComponent extends react_1.Component {
|
|
|
60
68
|
super.forceUpdate();
|
|
61
69
|
}
|
|
62
70
|
render() {
|
|
63
|
-
|
|
64
|
-
const
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
71
|
+
var _a;
|
|
72
|
+
const { children, name, fillProps = {}, getFills, className } = this.props;
|
|
73
|
+
const fills = ((_a = getFills(name, this)) !== null && _a !== void 0 ? _a : [])
|
|
74
|
+
.map((fill) => {
|
|
75
|
+
const fillChildren = isFunction(fill.children) ? fill.children(fillProps) : fill.children;
|
|
68
76
|
return react_1.Children.map(fillChildren, (child, childIndex) => {
|
|
69
|
-
if (!child ||
|
|
77
|
+
if (!child || typeof child === 'string') {
|
|
70
78
|
return child;
|
|
71
79
|
}
|
|
72
80
|
const childKey = child.key || childIndex;
|
|
73
81
|
return (0, react_1.cloneElement)(child, { key: childKey });
|
|
74
82
|
});
|
|
75
|
-
})
|
|
83
|
+
})
|
|
84
|
+
.filter(
|
|
76
85
|
// In some cases fills are rendered only when some conditions apply.
|
|
77
86
|
// This ensures that we only use non-empty fills when rendering, i.e.,
|
|
78
87
|
// it allows us to render wrappers only when the fills are actually present.
|
|
79
|
-
(0,
|
|
80
|
-
return react_1.default.createElement(react_1.default.Fragment, null,
|
|
88
|
+
(element) => !(0, isEmptyElement_1.isEmptyElement)(element));
|
|
89
|
+
return react_1.default.createElement(react_1.default.Fragment, null, isFunction(children) ? children(fills) : fills);
|
|
81
90
|
}
|
|
82
91
|
}
|
|
83
|
-
const Slot = props => {
|
|
92
|
+
const Slot = (props) => {
|
|
84
93
|
return (react_1.default.createElement(context_1.Consumer, null, ({ registerSlot, unregisterSlot, getFills }) => (react_1.default.createElement(SlotComponent, Object.assign({}, props, { getFills: getFills, registerSlot: registerSlot, unregisterSlot: unregisterSlot })))));
|
|
85
94
|
};
|
|
86
95
|
exports.default = Slot;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"slot.js","sourceRoot":"","sources":["../../../src/slot-fill/base/slot.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA
|
|
1
|
+
{"version":3,"file":"slot.js","sourceRoot":"","sources":["../../../src/slot-fill/base/slot.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+CAAmF;AACnF,uCAAqC;AAErC,4DAAyD;AAMzD;;;;;GAKG;AACH,SAAS,UAAU,CAAC,SAAS;IACzB,OAAO,OAAO,SAAS,KAAK,UAAU,CAAC;AAC3C,CAAC;AAED,MAAM,aAAc,SAAQ,iBAAmC;IAG3D,YAAY,KAA2B;QACnC,KAAK,CAAC,KAAK,CAAC,CAAC;QACb,IAAI,CAAC,WAAW,GAAG,KAAK,CAAC;QACzB,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC7C,CAAC;IAEM,iBAAiB;QACpB,MAAM,EAAE,YAAY,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC;QACpC,YAAY,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IACxC,CAAC;IAEM,oBAAoB;QACvB,MAAM,EAAE,cAAc,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC;QACtC,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC;QACxB,cAAc,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IAC1C,CAAC;IAEM,kBAAkB,CAAC,SAAS;QAC/B,MAAM,EAAE,IAAI,EAAE,cAAc,EAAE,YAAY,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC;QAE1D,uEAAuE;QACvE,iCAAiC;QACjC,oCAAoC;QACpC,8BAA8B;QAC9B,IAAI;IACR,CAAC;IAEM,QAAQ,CAAC,IAAa;QACzB,IAAI,CAAC,I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,MAAM,IAAI,GAAG,CAAC,KAAiB,EAAE,EAAE;IAC/B,OAAO,CACH,8BAAC,kBAAQ,QACJ,CAAC,EAAE,YAAY,EAAE,cAAc,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAC,CAC7C,8BAAC,aAAa,oBACN,KAAK,IACT,QAAQ,EAAE,QAAQ,EAClB,YAAY,EAAE,YAAY,EAC1B,cAAc,EAAE,cAAc,IAChC,CACL,CACM,CACd,CAAC;AACN,CAAC,CAAC;AAEF,kBAAe,IAAI,CAAC"}
|
|
@@ -21,6 +21,9 @@ const useSlot = (name) => {
|
|
|
21
21
|
setSlot(getSlot(name));
|
|
22
22
|
});
|
|
23
23
|
return unsubscribe;
|
|
24
|
+
// Ignore reason: Modifying this dep array could introduce unexpected changes in behavior,
|
|
25
|
+
// so we'll leave it as=is until the hook can be properly refactored for exhaustive-deps.
|
|
26
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
24
27
|
}, [name]);
|
|
25
28
|
return slot;
|
|
26
29
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-slot.js","sourceRoot":"","sources":["../../../src/slot-fill/base/use-slot.ts"],"names":[],"mappings":";;;;;;AAAA,iCAAwD;AACxD,wDAAwC;AAExC;;;;;GAKG;AACI,MAAM,OAAO,GAAG,CAAC,IAAI,EAAE,EAAE;
|
|
1
|
+
{"version":3,"file":"use-slot.js","sourceRoot":"","sources":["../../../src/slot-fill/base/use-slot.ts"],"names":[],"mappings":";;;;;;AAAA,iCAAwD;AACxD,wDAAwC;AAExC;;;;;GAKG;AACI,MAAM,OAAO,GAAG,CAAC,IAAI,EAAE,EAAE;IAC5B,MAAM,EAAE,OAAO,EAAE,SAAS,EAAE,GAAG,IAAA,kBAAU,EAAC,iBAAe,CAAC,CAAC;IAC3D,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC,GAAG,IAAA,gBAAQ,EAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC;IAEhD,IAAA,iBAAS,EAAC,GAAG,EAAE;QACX,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC;QACvB,MAAM,WAAW,GAAG,SAAS,CAAC,GAAG,EAAE;YAC/B,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC;QAC3B,CAAC,CAAC,CAAC;QACH,OAAO,WAAW,CAAC;QACnB,0FAA0F;QAC1F,yFAAyF;QACzF,uDAAuD;IAC3D,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC;IACX,OAAO,IAAI,CAAC;AAChB,CAAC,CAAC;AAfW,QAAA,OAAO,WAelB"}
|
|
@@ -1,4 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
3
|
+
var t = {};
|
|
4
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
5
|
+
t[p] = s[p];
|
|
6
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
7
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
8
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
9
|
+
t[p[i]] = s[p[i]];
|
|
10
|
+
}
|
|
11
|
+
return t;
|
|
12
|
+
};
|
|
2
13
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
14
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
15
|
};
|
|
@@ -21,17 +32,17 @@ function useForceUpdate() {
|
|
|
21
32
|
};
|
|
22
33
|
}
|
|
23
34
|
function Fill({ name, children }) {
|
|
24
|
-
const
|
|
35
|
+
const _a = (0, use_slot_1.default)(name), { registerFill, unregisterFill } = _a, slot = __rest(_a, ["registerFill", "unregisterFill"]);
|
|
25
36
|
const ref = (0, react_1.useRef)({ rerender: useForceUpdate() });
|
|
26
37
|
(0, react_1.useEffect)(() => {
|
|
27
|
-
// We register fills so we can keep track of their
|
|
38
|
+
// We register fills so we can keep track of their existence.
|
|
28
39
|
// Some Slot implementations need to know if there're already fills
|
|
29
40
|
// registered so they can choose to render themselves or not.
|
|
30
|
-
|
|
41
|
+
registerFill(ref);
|
|
31
42
|
return () => {
|
|
32
|
-
|
|
43
|
+
unregisterFill(ref);
|
|
33
44
|
};
|
|
34
|
-
}, [
|
|
45
|
+
}, [registerFill, unregisterFill]);
|
|
35
46
|
if (!slot.ref || !slot.ref.current) {
|
|
36
47
|
return null;
|
|
37
48
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fill.js","sourceRoot":"","sources":["../../../src/slot-fill/bubbles-virtually/fill.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"fill.js","sourceRoot":"","sources":["../../../src/slot-fill/bubbles-virtually/fill.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,iCAAoD;AACpD,yCAAyC;AACzC,0DAAiC;AAEjC,SAAS,cAAc;IACtB,MAAM,CAAE,AAAD,EAAG,QAAQ,CAAE,GAAG,IAAA,gBAAQ,EAAE,EAAE,CAAE,CAAC;IACtC,MAAM,OAAO,GAAG,IAAA,cAAM,EAAE,IAAI,CAAE,CAAC;IAE/B,IAAA,iBAAS,EAAE,GAAG,EAAE;QACf,OAAO,GAAG,EAAE;YACX,OAAO,CAAC,OAAO,GAAG,KAAK,CAAC;QACzB,CAAC,CAAC;IACH,CAAC,EAAE,EAAE,CAAE,CAAC;IAER,OAAO,GAAG,EAAE;QACX,IAAK,OAAO,CAAC,OAAO,EAAG;YACtB,QAAQ,CAAE,EAAE,CAAE,CAAC;SACf;IACF,CAAC,CAAC;AACH,CAAC;AAED,SAAwB,IAAI,CAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;IAC/C,MAAM,KAA4C,IAAA,kBAAO,EAAE,IAAI,CAAE,EAA3D,EAAE,YAAY,EAAE,cAAc,OAA6B,EAAxB,IAAI,cAAvC,kCAAyC,CAAkB,CAAC;IAClE,MAAM,GAAG,GAAG,IAAA,cAAM,EAAE,EAAE,QAAQ,EAAE,cAAc,EAAE,EAAE,CAAE,CAAC;IAErD,IAAA,iBAAS,EAAE,GAAG,EAAE;QACf,6DAA6D;QAC7D,mEAAmE;QACnE,6DAA6D;QAC7D,YAAY,CAAE,GAAG,CAAE,CAAC;QACpB,OAAO,GAAG,EAAE;YACX,cAAc,CAAE,GAAG,CAAE,CAAC;QACvB,CAAC,CAAC;IACH,CAAC,EAAE,CAAE,YAAY,EAAE,cAAc,CAAE,CAAE,CAAC;IAEtC,IAAK,CAAE,IAAI,CAAC,GAAG,IAAI,CAAE,IAAI,CAAC,GAAG,CAAC,OAAO,EAAG;QACvC,OAAO,IAAI,CAAC;KACZ;IAED,IAAK,OAAO,QAAQ,KAAK,UAAU,EAAG;QACrC,QAAQ,GAAG,QAAQ,CAAE,IAAI,CAAC,SAAS,CAAE,CAAC;KACtC;IAEE,4EAA4E;IAC/E,8EAA8E;IAC9E,8EAA8E;IAC9E,2EAA2E;IAC3E,mCAAmC;IACnC,4BAA4B;IAC5B,+DAA+D;IAC/D,iBAAiB;IACjB,oBAAoB;IACpB,KAAK;IAEL,OAAO,IAAA,wBAAY,EAAE,QAAQ,EAAE,IAAI,CAAC,GAAG,CAAC,OAAO,CAAE,CAAC;AACnD,CAAC;AAlCD,uBAkCC"}
|
|
@@ -4,10 +4,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const react_1 = require("react");
|
|
7
|
+
const utils_1 = require("valtio/utils");
|
|
7
8
|
const warning_1 = __importDefault(require("@wordpress/warning"));
|
|
8
9
|
const SlotFillContext = (0, react_1.createContext)({
|
|
9
|
-
slots:
|
|
10
|
-
fills:
|
|
10
|
+
slots: (0, utils_1.proxyMap)(),
|
|
11
|
+
fills: (0, utils_1.proxyMap)(),
|
|
11
12
|
registerSlot: () => {
|
|
12
13
|
(0, warning_1.default)('Components must be wrapped within `SlotFillProvider`. ' +
|
|
13
14
|
'See https://developer.wordpress.org/block-editor/components/slot-fill/');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"slot-fill-context.js","sourceRoot":"","sources":["../../../src/slot-fill/bubbles-virtually/slot-fill-context.ts"],"names":[],"mappings":";;;;;AAAA,iCAAsC;AACtC,iEAAyC;AAGzC,MAAM,eAAe,GAAG,IAAA,qBAAa,EAAwB;IAC5D,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"slot-fill-context.js","sourceRoot":"","sources":["../../../src/slot-fill/bubbles-virtually/slot-fill-context.ts"],"names":[],"mappings":";;;;;AAAA,iCAAsC;AACtC,wCAAwC;AACxC,iEAAyC;AAGzC,MAAM,eAAe,GAAG,IAAA,qBAAa,EAAwB;IAC5D,KAAK,EAAE,IAAA,gBAAQ,GAAE;IACjB,KAAK,EAAE,IAAA,gBAAQ,GAAE;IACjB,YAAY,EAAE,GAAG,EAAE;QAClB,IAAA,iBAAO,EACN,wDAAwD;YACvD,wEAAwE,CACzE,CAAC;IACH,CAAC;IACD,UAAU,EAAE,GAAG,EAAE,GAAE,CAAC;IACpB,cAAc,EAAE,GAAG,EAAE,GAAE,CAAC;IACxB,YAAY,EAAE,GAAG,EAAE,GAAE,CAAC;IACtB,cAAc,EAAE,GAAG,EAAE,GAAE,CAAC;CACxB,CAAE,CAAC;AAEJ,kBAAe,eAAe,CAAC"}
|
|
@@ -22,95 +22,70 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
22
22
|
__setModuleDefault(result, mod);
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
|
-
var __rest = (this && this.__rest) || function (s, e) {
|
|
26
|
-
var t = {};
|
|
27
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
28
|
-
t[p] = s[p];
|
|
29
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
30
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
31
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
32
|
-
t[p[i]] = s[p[i]];
|
|
33
|
-
}
|
|
34
|
-
return t;
|
|
35
|
-
};
|
|
36
25
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
37
26
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
38
27
|
};
|
|
39
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
40
29
|
const react_1 = __importStar(require("react"));
|
|
30
|
+
const valtio_1 = require("valtio");
|
|
31
|
+
const utils_1 = require("valtio/utils");
|
|
41
32
|
const is_shallow_equal_1 = __importDefault(require("@wordpress/is-shallow-equal"));
|
|
42
33
|
/**
|
|
43
34
|
* Internal dependencies
|
|
44
35
|
*/
|
|
45
36
|
const slot_fill_context_1 = __importDefault(require("./slot-fill-context"));
|
|
46
37
|
function useSlotRegistry() {
|
|
47
|
-
const
|
|
48
|
-
const
|
|
38
|
+
const slots = (0, react_1.useRef)((0, utils_1.proxyMap)()); // TODO remove any
|
|
39
|
+
const fills = (0, react_1.useRef)((0, utils_1.proxyMap)()); // TODO remove any
|
|
49
40
|
const registerSlot = (0, react_1.useCallback)((name, ref, fillProps) => {
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
return Object.assign(Object.assign({}, prevSlots), { [name]: Object.assign(Object.assign({}, slot), { ref: ref || slot.ref, fillProps: fillProps || slot.fillProps || {} }) });
|
|
53
|
-
});
|
|
41
|
+
const slot = slots.current.get(name) || {};
|
|
42
|
+
slots.current.set(name, (0, valtio_1.ref)(Object.assign(Object.assign({}, slot), { ref: ref || slot.ref, fillProps: fillProps || slot.fillProps || {} })));
|
|
54
43
|
}, []);
|
|
55
44
|
const unregisterSlot = (0, react_1.useCallback)((name, ref) => {
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
}
|
|
63
|
-
return prevSlots;
|
|
64
|
-
});
|
|
45
|
+
var _a;
|
|
46
|
+
// Make sure we're not unregistering a slot registered by another element
|
|
47
|
+
// See https://github.com/WordPress/gutenberg/pull/19242#issuecomment-590295412
|
|
48
|
+
if (((_a = slots.current.get(name)) === null || _a === void 0 ? void 0 : _a.ref) === ref) {
|
|
49
|
+
slots.current.delete(name);
|
|
50
|
+
}
|
|
65
51
|
}, []);
|
|
66
52
|
const updateSlot = (0, react_1.useCallback)((name, fillProps) => {
|
|
67
|
-
const slot = slots
|
|
53
|
+
const slot = slots.current.get(name);
|
|
68
54
|
if (!slot) {
|
|
69
55
|
return;
|
|
70
56
|
}
|
|
71
57
|
if (!(0, is_shallow_equal_1.default)(slot.fillProps, fillProps)) {
|
|
72
58
|
slot.fillProps = fillProps;
|
|
73
|
-
const slotFills = fills
|
|
59
|
+
const slotFills = fills.current.get(name);
|
|
74
60
|
if (slotFills) {
|
|
75
61
|
// Force update fills.
|
|
76
62
|
slotFills.map((fill) => fill.current.rerender());
|
|
77
63
|
}
|
|
78
64
|
}
|
|
79
|
-
}, [
|
|
65
|
+
}, []);
|
|
80
66
|
const registerFill = (0, react_1.useCallback)((name, ref) => {
|
|
81
|
-
|
|
67
|
+
fills.current.set(name, (0, valtio_1.ref)([...(fills.current.get(name) || []), ref]));
|
|
82
68
|
}, []);
|
|
83
69
|
const unregisterFill = (0, react_1.useCallback)((name, ref) => {
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
}
|
|
88
|
-
return prevFills;
|
|
89
|
-
});
|
|
70
|
+
if (fills.current.get(name)) {
|
|
71
|
+
fills.current.set(name, (0, valtio_1.ref)(fills.current.get(name).filter((fillRef) => fillRef !== ref)));
|
|
72
|
+
}
|
|
90
73
|
}, []);
|
|
91
74
|
// Memoizing the return value so it can be directly passed to Provider value
|
|
92
75
|
const registry = (0, react_1.useMemo)(() => ({
|
|
93
|
-
slots,
|
|
94
|
-
fills,
|
|
95
|
-
registerSlot,
|
|
96
|
-
updateSlot,
|
|
97
|
-
unregisterSlot,
|
|
98
|
-
registerFill,
|
|
99
|
-
unregisterFill,
|
|
100
|
-
}), [
|
|
101
|
-
slots,
|
|
102
|
-
fills,
|
|
76
|
+
slots: slots.current,
|
|
77
|
+
fills: fills.current,
|
|
103
78
|
registerSlot,
|
|
104
79
|
updateSlot,
|
|
105
80
|
unregisterSlot,
|
|
106
81
|
registerFill,
|
|
107
82
|
unregisterFill,
|
|
108
|
-
]);
|
|
83
|
+
}), [registerSlot, updateSlot, unregisterSlot, registerFill, unregisterFill]);
|
|
109
84
|
return registry;
|
|
110
85
|
}
|
|
111
86
|
function SlotFillProvider({ children }) {
|
|
112
87
|
const registry = useSlotRegistry();
|
|
113
|
-
return
|
|
88
|
+
return react_1.default.createElement(slot_fill_context_1.default.Provider, { value: registry }, children);
|
|
114
89
|
}
|
|
115
90
|
exports.default = SlotFillProvider;
|
|
116
91
|
//# sourceMappingURL=slot-fill-provider.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"slot-fill-provider.js","sourceRoot":"","sources":["../../../src/slot-fill/bubbles-virtually/slot-fill-provider.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"slot-fill-provider.js","sourceRoot":"","sources":["../../../src/slot-fill/bubbles-virtually/slot-fill-provider.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+CAA4D;AAC5D,mCAAuC;AACvC,wCAAwC;AACxC,mFAAyD;AAEzD;;GAEG;AACH,4EAAkD;AAGlD,SAAS,eAAe;IACpB,MAAM,KAAK,GAAG,IAAA,cAAM,EAAC,IAAA,gBAAQ,GAAY,CAAC,CAAC,CAAC,kBAAkB;IAC9D,MAAM,KAAK,GAAG,IAAA,cAAM,EAAC,IAAA,gBAAQ,GAAY,CAAC,CAAC,CAAC,kBAAkB;IAE9D,MAAM,YAAY,GAAG,IAAA,mBAAW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C,2BAAe,CAAC,QAAQ,IAAC,KAAK,EAAE,QAAQ,IAAG,QAAQ,CAA4B,CAAC;AAC5F,CAAC;AAHD,mCAGC"}
|
|
@@ -42,24 +42,23 @@ const compose_1 = require("@wordpress/compose");
|
|
|
42
42
|
const slot_fill_context_1 = __importDefault(require("./slot-fill-context"));
|
|
43
43
|
function Slot(_a, forwardedRef) {
|
|
44
44
|
var { name, fillProps = {}, as: Component = 'div' } = _a, props = __rest(_a, ["name", "fillProps", "as"]);
|
|
45
|
-
const
|
|
45
|
+
const _b = (0, react_1.useContext)(slot_fill_context_1.default), { registerSlot, unregisterSlot } = _b, registry = __rest(_b, ["registerSlot", "unregisterSlot"]);
|
|
46
46
|
const ref = (0, react_1.useRef)();
|
|
47
47
|
(0, react_1.useLayoutEffect)(() => {
|
|
48
|
-
|
|
48
|
+
registerSlot(name, ref, fillProps);
|
|
49
49
|
return () => {
|
|
50
|
-
|
|
50
|
+
unregisterSlot(name, ref);
|
|
51
51
|
};
|
|
52
|
-
//
|
|
53
|
-
//
|
|
54
|
-
//
|
|
55
|
-
|
|
56
|
-
}, [registry.registerSlot, registry.unregisterSlot, name]);
|
|
52
|
+
// Ignore reason: We don't want to unregister and register the slot whenever
|
|
53
|
+
// `fillProps` change, which would cause the fill to be re-mounted. Instead,
|
|
54
|
+
// we can just update the slot (see hook below).
|
|
55
|
+
}, [registerSlot, unregisterSlot, name]);
|
|
57
56
|
// fillProps may be an update that interacts with the layout, so we
|
|
58
57
|
// useLayoutEffect.
|
|
59
58
|
(0, react_1.useLayoutEffect)(() => {
|
|
60
59
|
registry.updateSlot(name, fillProps);
|
|
61
60
|
});
|
|
62
|
-
return
|
|
61
|
+
return react_1.default.createElement(Component, Object.assign({ ref: (0, compose_1.useMergeRefs)([forwardedRef, ref]) }, props));
|
|
63
62
|
}
|
|
64
63
|
exports.default = (0, react_1.forwardRef)(Slot);
|
|
65
64
|
//# sourceMappingURL=slot.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"slot.js","sourceRoot":"","sources":["../../../src/slot-fill/bubbles-virtually/slot.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+
|
|
1
|
+
{"version":3,"file":"slot.js","sourceRoot":"","sources":["../../../src/slot-fill/bubbles-virtually/slot.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+CAA+E;AAC/E,gDAAkD;AAClD,4EAAkD;AAGlD,SAAS,IAAI,CAAC,EAAoF,EAAE,YAAY;QAAlG,EAAE,IAAI,EAAE,SAAS,GAAG,EAAE,EAAE,EAAE,EAAE,SAAS,GAAG,KAAK,OAAuC,EAAlC,KAAK,cAAvD,2BAAyD,CAAF;IACjE,MAAM,KAAgD,IAAA,kBAAU,EAAC,2BAAe,CAAC,EAA3E,EAAE,YAAY,EAAE,cAAc,OAA6C,EAAxC,QAAQ,cAA3C,kCAA6C,CAA8B,CAAC;IAClF,MAAM,GAAG,GAAG,IAAA,cAAM,GAAE,CAAC;IAErB,IAAA,uBAAe,EAAC,GAAG,EAAE;QACjB,YAAY,CAAC,IAAI,EAAE,GAAG,EAAE,SAAS,CAAC,CAAC;QACnC,OAAO,GAAG,EAAE;YACR,cAAc,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;QAC9B,CAAC,CAAC;QACF,4EAA4E;QAC5E,4EAA4E;QAC5E,gDAAgD;IACpD,CAAC,EAAE,CAAC,YAAY,EAAE,cAAc,EAAE,IAAI,CAAC,CAAC,CAAC;IACzC,mEAAmE;IACnE,mBAAmB;IACnB,IAAA,uBAAe,EAAC,GAAG,EAAE;QACjB,QAAQ,CAAC,UAAU,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC;IACzC,CAAC,CAAC,CAAC;IAEH,OAAO,8BAAC,SAAS,kBAAC,GAAG,EAAE,IAAA,sBAAY,EAAC,CAAC,YAAY,EAAE,GAAG,CAAC,CAAC,IAAM,KAAK,EAAI,CAAC;AAC5E,CAAC;AAED,kBAAe,IAAA,kBAAU,EAAC,IAAI,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function useSlotFills(name: any): any;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const react_1 = require("react");
|
|
7
|
+
const valtio_1 = require("valtio");
|
|
8
|
+
const slot_fill_context_1 = __importDefault(require("./slot-fill-context"));
|
|
9
|
+
function useSlotFills(name) {
|
|
10
|
+
const registry = (0, react_1.useContext)(slot_fill_context_1.default);
|
|
11
|
+
const fills = (0, valtio_1.useSnapshot)(registry.fills, { sync: true });
|
|
12
|
+
// The important bit here is that this call ensures that the hook
|
|
13
|
+
// only causes a re-render if the "fills" of a given slot name
|
|
14
|
+
// change change, not any fills.
|
|
15
|
+
return fills.get(name);
|
|
16
|
+
}
|
|
17
|
+
exports.default = useSlotFills;
|
|
18
|
+
//# sourceMappingURL=use-slot-fills.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-slot-fills.js","sourceRoot":"","sources":["../../../src/slot-fill/bubbles-virtually/use-slot-fills.ts"],"names":[],"mappings":";;;;;AAAA,iCAAoC;AACpC,mCAAqC;AAErC,4EAAkD;AAElD,SAAwB,YAAY,CAAE,IAAI;IACzC,MAAM,QAAQ,GAAG,IAAA,kBAAU,EAAE,2BAAe,CAAE,CAAC;IAC/C,MAAM,KAAK,GAAG,IAAA,oBAAW,EAAE,QAAQ,CAAC,KAAK,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,CAAE,CAAC;IAC5D,iEAAiE;IACjE,8DAA8D;IAC9D,gCAAgC;IAChC,OAAO,KAAK,CAAC,GAAG,CAAE,IAAI,CAAE,CAAC;AAC1B,CAAC;AAPD,+BAOC"}
|
|
@@ -1,30 +1,43 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
3
|
+
var t = {};
|
|
4
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
5
|
+
t[p] = s[p];
|
|
6
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
7
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
8
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
9
|
+
t[p[i]] = s[p[i]];
|
|
10
|
+
}
|
|
11
|
+
return t;
|
|
12
|
+
};
|
|
2
13
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
14
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
15
|
};
|
|
5
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
17
|
const react_1 = require("react");
|
|
18
|
+
const valtio_1 = require("valtio");
|
|
7
19
|
const slot_fill_context_1 = __importDefault(require("./slot-fill-context"));
|
|
8
20
|
function useSlot(name) {
|
|
9
|
-
const
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
|
|
21
|
+
const _a = (0, react_1.useContext)(slot_fill_context_1.default), { updateSlot: registryUpdateSlot, unregisterSlot: registryUnregisterSlot, registerFill: registryRegisterFill, unregisterFill: registryUnregisterFill } = _a, registry = __rest(_a, ["updateSlot", "unregisterSlot", "registerFill", "unregisterFill"]);
|
|
22
|
+
const slots = (0, valtio_1.useSnapshot)(registry.slots, { sync: true });
|
|
23
|
+
// The important bit here is that this call ensures
|
|
24
|
+
// the hook only causes a re-render if the slot
|
|
25
|
+
// with the given name change, not any other slot.
|
|
26
|
+
const slot = slots.get(name);
|
|
13
27
|
const updateSlot = (0, react_1.useCallback)((fillProps) => {
|
|
14
|
-
|
|
15
|
-
}, [name,
|
|
28
|
+
registryUpdateSlot(name, fillProps);
|
|
29
|
+
}, [name, registryUpdateSlot]);
|
|
16
30
|
const unregisterSlot = (0, react_1.useCallback)((slotRef) => {
|
|
17
|
-
|
|
18
|
-
}, [name,
|
|
31
|
+
registryUnregisterSlot(name, slotRef);
|
|
32
|
+
}, [name, registryUnregisterSlot]);
|
|
19
33
|
const registerFill = (0, react_1.useCallback)((fillRef) => {
|
|
20
|
-
|
|
21
|
-
}, [name,
|
|
34
|
+
registryRegisterFill(name, fillRef);
|
|
35
|
+
}, [name, registryRegisterFill]);
|
|
22
36
|
const unregisterFill = (0, react_1.useCallback)((fillRef) => {
|
|
23
|
-
|
|
24
|
-
}, [name,
|
|
37
|
+
registryUnregisterFill(name, fillRef);
|
|
38
|
+
}, [name, registryUnregisterFill]);
|
|
25
39
|
return Object.assign(Object.assign({}, slot), { updateSlot,
|
|
26
40
|
unregisterSlot,
|
|
27
|
-
fills,
|
|
28
41
|
registerFill,
|
|
29
42
|
unregisterFill });
|
|
30
43
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-slot.js","sourceRoot":"","sources":["../../../src/slot-fill/bubbles-virtually/use-slot.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"use-slot.js","sourceRoot":"","sources":["../../../src/slot-fill/bubbles-virtually/use-slot.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,iCAAyD;AACzD,mCAAqC;AAErC,4EAAkD;AAElD,SAAwB,OAAO,CAAC,IAAU;IACtC,MAAM,KAMF,IAAA,kBAAU,EAAC,2BAAe,CAAC,EANzB,EACF,UAAU,EAAE,kBAAkB,EAC9B,cAAc,EAAE,sBAAsB,EACtC,YAAY,EAAE,oBAAoB,EAClC,cAAc,EAAE,sBAAsB,OAEX,EADxB,QAAQ,cALT,kEAML,CAA8B,CAAC;IAChC,MAAM,KAAK,GAAG,IAAA,oBAAW,EAAC,QAAQ,CAAC,KAAK,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;IAC1D,mDAAmD;IACnD,+CAA+C;IAC/C,kDAAkD;IAClD,MAAM,IAAI,GAAG,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IAE7B,MAAM,UAAU,GAAG,IAAA,mBAAW,EAC1B,CAAC,SAAS,EAAE,EAAE;QACV,kBAAkB,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC;IACxC,CAAC,EACD,CAAC,IAAI,EAAE,kBAAkB,CAAC,CAC7B,CAAC;IAEF,MAAM,cAAc,GAAG,IAAA,mBAAW,EAC9B,CAAC,OAAO,EAAE,EAAE;QACR,sBAAsB,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IAC1C,CAAC,EACD,CAAC,IAAI,EAAE,sBAAsB,CAAC,CACjC,CAAC;IAEF,MAAM,YAAY,GAAG,IAAA,mBAAW,EAC5B,CAAC,OAAO,EAAE,EAAE;QACR,oBAAoB,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IACxC,CAAC,EACD,CAAC,IAAI,EAAE,oBAAoB,CAAC,CAC/B,CAAC;IAEF,MAAM,cAAc,GAAG,IAAA,mBAAW,EAC9B,CAAC,OAAO,EAAE,EAAE;QACR,sBAAsB,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IAC1C,CAAC,EACD,CAAC,IAAI,EAAE,sBAAsB,CAAC,CACjC,CAAC;IAEF,uCACO,IAAI,KACP,UAAU;QACV,cAAc;QACd,YAAY;QACZ,cAAc,IAChB;AACN,CAAC;AAjDD,0BAiDC"}
|
package/lib/slot-fill/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React, { ReactNode } from 'react';
|
|
2
2
|
import SlotFillProvider from './base/provider';
|
|
3
3
|
import useSlot from './bubbles-virtually/use-slot';
|
|
4
|
+
export { default as useSlotFills } from './bubbles-virtually/use-slot-fills';
|
|
4
5
|
import { IFillProps, ISlotProps } from './interfaces';
|
|
5
6
|
declare type RenderProps<T> = {
|
|
6
7
|
children: (api: T) => ReactNode;
|
package/lib/slot-fill/index.js
CHANGED
|
@@ -37,7 +37,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
37
37
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
38
38
|
};
|
|
39
39
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
40
|
-
exports.useSlot = exports.SlotFillProvider = exports.createSlotFill = exports.Provider = exports.Slot = exports.Fill = void 0;
|
|
40
|
+
exports.useSlot = exports.SlotFillProvider = exports.createSlotFill = exports.Provider = exports.Slot = exports.Fill = exports.useSlotFills = void 0;
|
|
41
41
|
const react_1 = __importStar(require("react"));
|
|
42
42
|
const fill_1 = __importDefault(require("./base/fill"));
|
|
43
43
|
const slot_1 = __importDefault(require("./base/slot"));
|
|
@@ -48,6 +48,8 @@ const provider_1 = __importDefault(require("./base/provider"));
|
|
|
48
48
|
exports.SlotFillProvider = provider_1.default;
|
|
49
49
|
const use_slot_1 = __importDefault(require("./bubbles-virtually/use-slot"));
|
|
50
50
|
exports.useSlot = use_slot_1.default;
|
|
51
|
+
var use_slot_fills_1 = require("./bubbles-virtually/use-slot-fills");
|
|
52
|
+
Object.defineProperty(exports, "useSlotFills", { enumerable: true, get: function () { return __importDefault(use_slot_fills_1).default; } });
|
|
51
53
|
function Fill(props) {
|
|
52
54
|
// We're adding both Fills here so they can register themselves before
|
|
53
55
|
// their respective slot has been registered. Only the Fill that has a slot
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/slot-fill/index.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+CAAqD;AACrD,uDAAmC;AACnC,uDAAmC;AACnC,oEAA4D;AAC5D,oEAA4D;AAC5D,gGAAsF;AACtF,+DAA+C;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/slot-fill/index.tsx"],"names":[],"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GAAG,MAAM,CAAC;IAE1C,MAAM,aAAa,GAAG,CAAC,KAAuB,EAAE,EAAE,CAAC,8BAAC,YAAI,kBAAC,IAAI,EAAE,IAAI,IAAM,KAAK,EAAI,CAAC;IACnF,aAAa,CAAC,WAAW,GAAG,IAAI,GAAG,MAAM,CAAC;IAC1C,aAAa,CAAC,cAAc,GAAG,IAAI,CAAC;IAEpC,OAAO;QACL,IAAI,EAAE,aAAa;QACnB,IAAI,EAAE,aAAa;KACpB,CAAC;AACJ,CAAC;AAZD,wCAYC"}
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
1
|
/**
|
|
3
2
|
* Checks if the provided element to check.
|
|
4
3
|
*
|
|
5
4
|
* @param element React Component to check.
|
|
6
5
|
* @returns True when an element is considered empty.
|
|
7
6
|
*/
|
|
8
|
-
export declare const isEmptyElement: (element:
|
|
7
|
+
export declare const isEmptyElement: (element: any) => boolean;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.isEmptyElement = void 0;
|
|
4
|
-
const lodash_1 = require("lodash");
|
|
5
4
|
/**
|
|
6
5
|
* Checks if the provided element to check.
|
|
7
6
|
*
|
|
@@ -9,10 +8,10 @@ const lodash_1 = require("lodash");
|
|
|
9
8
|
* @returns True when an element is considered empty.
|
|
10
9
|
*/
|
|
11
10
|
const isEmptyElement = (element) => {
|
|
12
|
-
if (
|
|
11
|
+
if (typeof element === 'number') {
|
|
13
12
|
return false;
|
|
14
13
|
}
|
|
15
|
-
if ((0
|
|
14
|
+
if (typeof (element === null || element === void 0 ? void 0 : element.valueOf()) === 'string' || Array.isArray(element)) {
|
|
16
15
|
return !element.length;
|
|
17
16
|
}
|
|
18
17
|
return !element;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"isEmptyElement.js","sourceRoot":"","sources":["../../../src/slot-fill/utils/isEmptyElement.
|
|
1
|
+
{"version":3,"file":"isEmptyElement.js","sourceRoot":"","sources":["../../../src/slot-fill/utils/isEmptyElement.ts"],"names":[],"mappings":";;;AAEA;;;;;GAKG;AAEI,MAAM,cAAc,GAAG,CAAE,OAAO,EAAG,EAAE;IAC3C,IAAK,OAAO,OAAO,KAAK,QAAQ,EAAG;QAClC,OAAO,KAAK,CAAC;KACb;IAED,IAAK,OAAO,CAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,OAAO,EAAE,CAAA,KAAK,QAAQ,IAAI,KAAK,CAAC,OAAO,CAAE,OAAO,CAAE,EAAG;QACzE,OAAO,CAAE,OAAO,CAAC,MAAM,CAAC;KACxB;IAED,OAAO,CAAE,OAAO,CAAC;AAClB,CAAC,CAAC;AAVW,QAAA,cAAc,kBAUzB"}
|
package/package.json
CHANGED
|
@@ -1,60 +1,61 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
"
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
"
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
"
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
"
|
|
59
|
-
|
|
2
|
+
"name": "@common-stack/components-pro",
|
|
3
|
+
"version": "0.3.1-alpha.1",
|
|
4
|
+
"description": "browser plugin for git",
|
|
5
|
+
"homepage": "https://github.com/cdmbase/fullstack-pro#readme",
|
|
6
|
+
"bugs": {
|
|
7
|
+
"url": "https://github.com/cdmbase/fullstack-pro/issues"
|
|
8
|
+
},
|
|
9
|
+
"repository": {
|
|
10
|
+
"type": "git",
|
|
11
|
+
"url": "git+https://github.com/cdmbase/fullstack-pro.git"
|
|
12
|
+
},
|
|
13
|
+
"license": "MIT",
|
|
14
|
+
"author": "CDMBase LLC",
|
|
15
|
+
"main": "lib/index.js",
|
|
16
|
+
"react-native": "lib/index.native.js",
|
|
17
|
+
"typings": "lib/index.d.ts",
|
|
18
|
+
"scripts": {
|
|
19
|
+
"build": "npm run build:clean && npm run build:lib",
|
|
20
|
+
"build:clean": "rimraf esm",
|
|
21
|
+
"build:lib": "tsc",
|
|
22
|
+
"build:lib:watch": "npm run build:lib -- --watch",
|
|
23
|
+
"jest": "./node_modules/.bin/jest",
|
|
24
|
+
"prepublish": "npm run build",
|
|
25
|
+
"test": "jest",
|
|
26
|
+
"test:debug": "npm test -- --runInBand",
|
|
27
|
+
"test:watch": "npm test -- --watch",
|
|
28
|
+
"watch": "npm run build:lib:watch"
|
|
29
|
+
},
|
|
30
|
+
"resolutions": {
|
|
31
|
+
"@wordpress/element": "~4.12.0",
|
|
32
|
+
"is-plain-obj": "^3.0.0"
|
|
33
|
+
},
|
|
34
|
+
"dependencies": {
|
|
35
|
+
"@wordpress/compose": "~5.12.0",
|
|
36
|
+
"@wordpress/element": "~4.12.0",
|
|
37
|
+
"@wordpress/hooks": "~3.14.0",
|
|
38
|
+
"@wordpress/is-shallow-equal": "~4.14.0",
|
|
39
|
+
"@wordpress/warning": "~2.14.0",
|
|
40
|
+
"history-with-query": "^4.10.4",
|
|
41
|
+
"sort-keys": "^4.1.0",
|
|
42
|
+
"valtio": "^1.7.0"
|
|
43
|
+
},
|
|
44
|
+
"devDependencies": {
|
|
45
|
+
"@umijs/route-utils": "^1.0.34"
|
|
46
|
+
},
|
|
47
|
+
"peerDependencies": {
|
|
48
|
+
"@apollo/client": ">=3.0.0",
|
|
49
|
+
"react": ">=16.8.6",
|
|
50
|
+
"react-dom": ">=16.8.6",
|
|
51
|
+
"react-router": ">=5.0.0",
|
|
52
|
+
"redux": ">=4.0.1"
|
|
53
|
+
},
|
|
54
|
+
"publishConfig": {
|
|
55
|
+
"access": "public"
|
|
56
|
+
},
|
|
57
|
+
"gitHead": "a32bf55e87df6d821213ad90ed6279d466d4027e",
|
|
58
|
+
"typescript": {
|
|
59
|
+
"definition": "lib/index.d.ts"
|
|
60
|
+
}
|
|
60
61
|
}
|