@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
|
@@ -1,32 +1,7 @@
|
|
|
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 lodash_1 = require("lodash");
|
|
28
|
-
const context_1 = require("./context");
|
|
29
|
-
class SlotFillProvider extends react_1.Component {
|
|
1
|
+
import React, { Component } from 'react';
|
|
2
|
+
import { sortBy } from 'lodash';
|
|
3
|
+
import { Provider } from './context';
|
|
4
|
+
class SlotFillProvider extends Component {
|
|
30
5
|
constructor(props) {
|
|
31
6
|
super(props);
|
|
32
7
|
this.registerSlot = this.registerSlot.bind(this);
|
|
@@ -98,7 +73,7 @@ class SlotFillProvider extends react_1.Component {
|
|
|
98
73
|
// if (this.slots[name] !== slotInstance) {
|
|
99
74
|
// return [];
|
|
100
75
|
// }
|
|
101
|
-
return
|
|
76
|
+
return sortBy(this.fills[name]);
|
|
102
77
|
}
|
|
103
78
|
hasFills(name) {
|
|
104
79
|
return this.fills[name] && !!this.fills[name].length;
|
|
@@ -119,8 +94,8 @@ class SlotFillProvider extends react_1.Component {
|
|
|
119
94
|
};
|
|
120
95
|
}
|
|
121
96
|
render() {
|
|
122
|
-
return
|
|
97
|
+
return React.createElement(Provider, { value: this.contextValue }, this.props.children);
|
|
123
98
|
}
|
|
124
99
|
}
|
|
125
|
-
|
|
100
|
+
export default SlotFillProvider;
|
|
126
101
|
//# sourceMappingURL=provider.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"provider.js","sourceRoot":"","sources":["../../../src/slot-fill/base/provider.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"provider.js","sourceRoot":"","sources":["../../../src/slot-fill/base/provider.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,SAAS,EAAa,MAAM,OAAO,CAAC;AACpD,OAAO,EAAE,MAAM,EAAW,MAAM,QAAQ,CAAC;AAEzC,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAErC,MAAM,gBAAiB,SAAQ,SAAsC;IAMjE,YAAY,KAAK;QACb,KAAK,CAAC,KAAK,CAAC,CAAC;QAEb,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC,YAAY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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 context_1 = require("./context");
|
|
28
|
-
const isEmptyElement_1 = require("../utils/isEmptyElement");
|
|
1
|
+
import React, { Component, cloneElement, Children } from 'react';
|
|
2
|
+
import { Consumer } from './context';
|
|
3
|
+
import { isEmptyElement } from '../utils/isEmptyElement';
|
|
29
4
|
/**
|
|
30
5
|
* Whether the argument is a function.
|
|
31
6
|
*
|
|
@@ -35,7 +10,7 @@ const isEmptyElement_1 = require("../utils/isEmptyElement");
|
|
|
35
10
|
function isFunction(maybeFunc) {
|
|
36
11
|
return typeof maybeFunc === 'function';
|
|
37
12
|
}
|
|
38
|
-
class SlotComponent extends
|
|
13
|
+
class SlotComponent extends Component {
|
|
39
14
|
constructor(props) {
|
|
40
15
|
super(props);
|
|
41
16
|
this.isUnmounted = false;
|
|
@@ -80,7 +55,7 @@ class SlotComponent extends react_1.Component {
|
|
|
80
55
|
// unregisterFill(name, fill);
|
|
81
56
|
if (typeof fill === 'function') {
|
|
82
57
|
const child = fill(Object.assign(Object.assign({}, fillProps), { key: i }));
|
|
83
|
-
return
|
|
58
|
+
return React.createElement("div", { "data-slot-name": `slot-${name}` }, child);
|
|
84
59
|
}
|
|
85
60
|
return null;
|
|
86
61
|
});
|
|
@@ -89,28 +64,28 @@ class SlotComponent extends react_1.Component {
|
|
|
89
64
|
const fills = ((_b = getFills(name, this)) !== null && _b !== void 0 ? _b : [])
|
|
90
65
|
.map((fill) => {
|
|
91
66
|
const fillChildren = isFunction(fill.children) ? fill.children(fillProps) : fill.children;
|
|
92
|
-
return
|
|
67
|
+
return Children.map(fillChildren, (child, childIndex) => {
|
|
93
68
|
if (!child || typeof child === 'string') {
|
|
94
69
|
return child;
|
|
95
70
|
}
|
|
96
71
|
const childKey = child.key || childIndex;
|
|
97
|
-
return
|
|
72
|
+
return cloneElement(child, { key: childKey });
|
|
98
73
|
});
|
|
99
74
|
})
|
|
100
75
|
.filter(
|
|
101
76
|
// In some cases fills are rendered only when some conditions apply.
|
|
102
77
|
// This ensures that we only use non-empty fills when rendering, i.e.,
|
|
103
78
|
// it allows us to render wrappers only when the fills are actually present.
|
|
104
|
-
(element) => !
|
|
105
|
-
return
|
|
79
|
+
(element) => !isEmptyElement(element));
|
|
80
|
+
return React.createElement(React.Fragment, null, isFunction(children) ? children(fills) : fills);
|
|
106
81
|
}
|
|
107
82
|
}
|
|
108
83
|
const Slot = (props) => {
|
|
109
84
|
const serverMode = (typeof window === 'undefined');
|
|
110
|
-
return (
|
|
85
|
+
return (React.createElement(Consumer, null, ({ registerSlot, unregisterSlot, getFills }) => (React.createElement(SlotComponent, Object.assign({}, props, {
|
|
111
86
|
// We need to add id to fillProps with slot name,
|
|
112
87
|
// so that we can use it when remove the component during hydration.
|
|
113
88
|
getFills: getFills, registerSlot: registerSlot, unregisterSlot: unregisterSlot, serverMode: serverMode })))));
|
|
114
89
|
};
|
|
115
|
-
|
|
90
|
+
export default Slot;
|
|
116
91
|
//# sourceMappingURL=slot.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"slot.js","sourceRoot":"","sources":["../../../src/slot-fill/base/slot.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"slot.js","sourceRoot":"","sources":["../../../src/slot-fill/base/slot.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,SAAS,EAAgB,YAAY,EAAM,QAAQ,EAAE,MAAM,OAAO,CAAC;AACnF,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAErC,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAMzD;;;;;GAKG;AACH,SAAS,UAAU,CAAC,SAAS;IACzB,OAAO,OAAO,SAAS,KAAK,UAAU,CAAC;AAC3C,CAAC;AAED,MAAM,aAAc,SAAQ,SAAmC;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,UAAU,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC;QAChD,IAAI,CAAC,UAAU,EAAE;YACb,YAAY,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;SACvC;IACL,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,S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
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.useSlot = void 0;
|
|
7
|
-
const react_1 = require("react");
|
|
8
|
-
const context_1 = __importDefault(require("./context"));
|
|
1
|
+
import { useContext, useState, useEffect } from 'react';
|
|
2
|
+
import SlotFillContext from './context';
|
|
9
3
|
/**
|
|
10
4
|
* React hook returning the active slot given a name.
|
|
11
5
|
*
|
|
12
6
|
* @param {string} name Slot name.
|
|
13
7
|
* @return {Object} Slot object.
|
|
14
8
|
*/
|
|
15
|
-
const useSlot = (name) => {
|
|
16
|
-
const { getSlot, subscribe } =
|
|
17
|
-
const [slot, setSlot] =
|
|
18
|
-
|
|
9
|
+
export const useSlot = (name) => {
|
|
10
|
+
const { getSlot, subscribe } = useContext(SlotFillContext);
|
|
11
|
+
const [slot, setSlot] = useState(getSlot(name));
|
|
12
|
+
useEffect(() => {
|
|
19
13
|
setSlot(getSlot(name));
|
|
20
14
|
const unsubscribe = subscribe(() => {
|
|
21
15
|
setSlot(getSlot(name));
|
|
@@ -27,5 +21,4 @@ const useSlot = (name) => {
|
|
|
27
21
|
}, [name]);
|
|
28
22
|
return slot;
|
|
29
23
|
};
|
|
30
|
-
exports.useSlot = useSlot;
|
|
31
24
|
//# sourceMappingURL=use-slot.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-slot.js","sourceRoot":"","sources":["../../../src/slot-fill/base/use-slot.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"use-slot.js","sourceRoot":"","sources":["../../../src/slot-fill/base/use-slot.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACxD,OAAO,eAAe,MAAM,WAAW,CAAC;AAExC;;;;;GAKG;AACH,MAAM,CAAC,MAAM,OAAO,GAAG,CAAC,IAAI,EAAE,EAAE;IAC5B,MAAM,EAAE,OAAO,EAAE,SAAS,EAAE,GAAG,UAAU,CAAC,eAAe,CAAC,CAAC;IAC3D,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC,GAAG,QAAQ,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC;IAEhD,SAAS,CAAC,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"}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
var __rest = (this && this.__rest) || function (s, e) {
|
|
3
2
|
var t = {};
|
|
4
3
|
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
@@ -10,17 +9,13 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
10
9
|
}
|
|
11
10
|
return t;
|
|
12
11
|
};
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
const react_1 = require("react");
|
|
18
|
-
const react_dom_1 = require("react-dom");
|
|
19
|
-
const use_slot_1 = __importDefault(require("./use-slot"));
|
|
12
|
+
import { useRef, useState, useEffect } from 'react';
|
|
13
|
+
import { createPortal } from 'react-dom';
|
|
14
|
+
import useSlot from './use-slot';
|
|
20
15
|
function useForceUpdate() {
|
|
21
|
-
const [, setState] =
|
|
22
|
-
const mounted =
|
|
23
|
-
|
|
16
|
+
const [, setState] = useState({});
|
|
17
|
+
const mounted = useRef(true);
|
|
18
|
+
useEffect(() => {
|
|
24
19
|
return () => {
|
|
25
20
|
mounted.current = false;
|
|
26
21
|
};
|
|
@@ -31,10 +26,10 @@ function useForceUpdate() {
|
|
|
31
26
|
}
|
|
32
27
|
};
|
|
33
28
|
}
|
|
34
|
-
function Fill({ name, children }) {
|
|
35
|
-
const _a = (
|
|
36
|
-
const ref =
|
|
37
|
-
|
|
29
|
+
export default function Fill({ name, children }) {
|
|
30
|
+
const _a = useSlot(name), { registerFill, unregisterFill } = _a, slot = __rest(_a, ["registerFill", "unregisterFill"]);
|
|
31
|
+
const ref = useRef({ rerender: useForceUpdate() });
|
|
32
|
+
useEffect(() => {
|
|
38
33
|
// We register fills so we can keep track of their existence.
|
|
39
34
|
// Some Slot implementations need to know if there're already fills
|
|
40
35
|
// registered so they can choose to render themselves or not.
|
|
@@ -59,7 +54,6 @@ function Fill({ name, children }) {
|
|
|
59
54
|
// { children }
|
|
60
55
|
// </StyleProvider>
|
|
61
56
|
// );
|
|
62
|
-
return
|
|
57
|
+
return createPortal(children, slot.ref.current);
|
|
63
58
|
}
|
|
64
|
-
exports.default = Fill;
|
|
65
59
|
//# sourceMappingURL=fill.js.map
|
|
@@ -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,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACpD,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,OAAO,MAAM,YAAY,CAAC;AAEjC,SAAS,cAAc;IACtB,MAAM,CAAE,AAAD,EAAG,QAAQ,CAAE,GAAG,QAAQ,CAAE,EAAE,CAAE,CAAC;IACtC,MAAM,OAAO,GAAG,MAAM,CAAE,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AE,IAAI,CAAC,GAAG,CAAC,OAAO,CAAE,CAAC;AACnD,CAAC"}
|
|
@@ -1,16 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const utils_1 = require("valtio/utils");
|
|
8
|
-
const warning_1 = __importDefault(require("@wordpress/warning"));
|
|
9
|
-
const SlotFillContext = (0, react_1.createContext)({
|
|
10
|
-
slots: (0, utils_1.proxyMap)(),
|
|
11
|
-
fills: (0, utils_1.proxyMap)(),
|
|
1
|
+
import { createContext } from 'react';
|
|
2
|
+
import { proxyMap } from 'valtio/utils';
|
|
3
|
+
import warning from '@wordpress/warning';
|
|
4
|
+
const SlotFillContext = createContext({
|
|
5
|
+
slots: proxyMap(),
|
|
6
|
+
fills: proxyMap(),
|
|
12
7
|
registerSlot: () => {
|
|
13
|
-
(
|
|
8
|
+
warning('Components must be wrapped within `SlotFillProvider`. ' +
|
|
14
9
|
'See https://developer.wordpress.org/block-editor/components/slot-fill/');
|
|
15
10
|
},
|
|
16
11
|
updateSlot: () => { },
|
|
@@ -18,5 +13,5 @@ const SlotFillContext = (0, react_1.createContext)({
|
|
|
18
13
|
registerFill: () => { },
|
|
19
14
|
unregisterFill: () => { },
|
|
20
15
|
});
|
|
21
|
-
|
|
16
|
+
export default SlotFillContext;
|
|
22
17
|
//# sourceMappingURL=slot-fill-context.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"slot-fill-context.js","sourceRoot":"","sources":["../../../src/slot-fill/bubbles-virtually/slot-fill-context.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"slot-fill-context.js","sourceRoot":"","sources":["../../../src/slot-fill/bubbles-virtually/slot-fill-context.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AACtC,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AACxC,OAAO,OAAO,MAAM,oBAAoB,CAAC;AAGzC,MAAM,eAAe,GAAG,aAAa,CAAwB;IAC5D,KAAK,EAAE,QAAQ,EAAE;IACjB,KAAK,EAAE,QAAQ,EAAE;IACjB,YAAY,EAAE,GAAG,EAAE;QAClB,OAAO,CACN,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,eAAe,eAAe,CAAC"}
|
|
@@ -1,47 +1,19 @@
|
|
|
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
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
-
};
|
|
28
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
const react_1 = __importStar(require("react"));
|
|
30
|
-
const valtio_1 = require("valtio");
|
|
31
|
-
const utils_1 = require("valtio/utils");
|
|
32
|
-
const is_shallow_equal_1 = __importDefault(require("@wordpress/is-shallow-equal"));
|
|
1
|
+
import React, { useMemo, useCallback, useRef } from 'react';
|
|
2
|
+
import { ref as valRef } from 'valtio';
|
|
3
|
+
import { proxyMap } from 'valtio/utils';
|
|
4
|
+
import isShallowEqual from '@wordpress/is-shallow-equal';
|
|
33
5
|
/**
|
|
34
6
|
* Internal dependencies
|
|
35
7
|
*/
|
|
36
|
-
|
|
8
|
+
import SlotFillContext from './slot-fill-context';
|
|
37
9
|
function useSlotRegistry() {
|
|
38
|
-
const slots =
|
|
39
|
-
const fills =
|
|
40
|
-
const registerSlot =
|
|
10
|
+
const slots = useRef(proxyMap()); // TODO remove any
|
|
11
|
+
const fills = useRef(proxyMap()); // TODO remove any
|
|
12
|
+
const registerSlot = useCallback((name, ref, fillProps) => {
|
|
41
13
|
const slot = slots.current.get(name) || {};
|
|
42
|
-
slots.current.set(name, (
|
|
14
|
+
slots.current.set(name, valRef(Object.assign(Object.assign({}, slot), { ref: ref || slot.ref, fillProps: fillProps || slot.fillProps || {} })));
|
|
43
15
|
}, []);
|
|
44
|
-
const unregisterSlot =
|
|
16
|
+
const unregisterSlot = useCallback((name, ref) => {
|
|
45
17
|
var _a;
|
|
46
18
|
// Make sure we're not unregistering a slot registered by another element
|
|
47
19
|
// See https://github.com/WordPress/gutenberg/pull/19242#issuecomment-590295412
|
|
@@ -49,12 +21,12 @@ function useSlotRegistry() {
|
|
|
49
21
|
slots.current.delete(name);
|
|
50
22
|
}
|
|
51
23
|
}, []);
|
|
52
|
-
const updateSlot =
|
|
24
|
+
const updateSlot = useCallback((name, fillProps) => {
|
|
53
25
|
const slot = slots.current.get(name);
|
|
54
26
|
if (!slot) {
|
|
55
27
|
return;
|
|
56
28
|
}
|
|
57
|
-
if (!(
|
|
29
|
+
if (!isShallowEqual(slot.fillProps, fillProps)) {
|
|
58
30
|
slot.fillProps = fillProps;
|
|
59
31
|
const slotFills = fills.current.get(name);
|
|
60
32
|
if (slotFills) {
|
|
@@ -63,16 +35,16 @@ function useSlotRegistry() {
|
|
|
63
35
|
}
|
|
64
36
|
}
|
|
65
37
|
}, []);
|
|
66
|
-
const registerFill =
|
|
67
|
-
fills.current.set(name, (
|
|
38
|
+
const registerFill = useCallback((name, ref) => {
|
|
39
|
+
fills.current.set(name, valRef([...(fills.current.get(name) || []), ref]));
|
|
68
40
|
}, []);
|
|
69
|
-
const unregisterFill =
|
|
41
|
+
const unregisterFill = useCallback((name, ref) => {
|
|
70
42
|
if (fills.current.get(name)) {
|
|
71
|
-
fills.current.set(name, (
|
|
43
|
+
fills.current.set(name, valRef(fills.current.get(name).filter((fillRef) => fillRef !== ref)));
|
|
72
44
|
}
|
|
73
45
|
}, []);
|
|
74
46
|
// Memoizing the return value so it can be directly passed to Provider value
|
|
75
|
-
const registry =
|
|
47
|
+
const registry = useMemo(() => ({
|
|
76
48
|
slots: slots.current,
|
|
77
49
|
fills: fills.current,
|
|
78
50
|
registerSlot,
|
|
@@ -83,9 +55,8 @@ function useSlotRegistry() {
|
|
|
83
55
|
}), [registerSlot, updateSlot, unregisterSlot, registerFill, unregisterFill]);
|
|
84
56
|
return registry;
|
|
85
57
|
}
|
|
86
|
-
function SlotFillProvider({ children }) {
|
|
58
|
+
export default function SlotFillProvider({ children }) {
|
|
87
59
|
const registry = useSlotRegistry();
|
|
88
|
-
return
|
|
60
|
+
return React.createElement(SlotFillContext.Provider, { value: registry }, children);
|
|
89
61
|
}
|
|
90
|
-
exports.default = SlotFillProvider;
|
|
91
62
|
//# 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,OAAO,KAAK,EAAE,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAC5D,OAAO,EAAE,GAAG,IAAI,MAAM,EAAE,MAAM,QAAQ,CAAC;AACvC,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AACxC,OAAO,cAAc,MAAM,6BAA6B,CAAC;AAEzD;;GAEG;AACH,OAAO,eAAe,MAAM,qBAAqB,CAAC;AAGlD,SAAS,eAAe;IACpB,MAAM,KAAK,GAAG,MAAM,CAAC,QAAQ,EAAY,CAAC,CAAC,CAAC,kBAAkB;IAC9D,MAAM,KAAK,GAAG,MAAM,CAAC,QAAQ,EAAY,CAAC,CAAC,CAAC,kBAAkB;IAE9D,MAAM,YAAY,GAAG,WAAW,CAAC,CAAC,IAAI,EAAE,GAAG,EAAE,SAAS,EAAE,EAAE;QACtD,MAAM,IAAI,GAAG,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC;QAC3C,KAAK,CAAC,OAAO,CAAC,GAAG,CACb,IAAI,EACJ,MAAM,iCACC,IAAI,KACP,GAAG,EAAE,GAAG,IAAI,IAAI,CAAC,GAAG,EACpB,SAAS,EAAE,SAAS,IAAI,IAAI,CAAC,SAAS,IAAI,EAAE,IAC9C,CACL,CAAC;IACN,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,MAAM,cAAc,GAAG,WAAW,CAAC,CAAC,IAAI,EAAE,GAAG,EAAE,EAAE;;QAC7C,yEAAyE;QACzE,+EAA+E;QAC/E,IAAI,CAAA,MAAA,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,0CAAE,GAAG,MAAK,GAAG,EAAE;YACtC,K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C,CAAC,MAAM,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,KAAK,GAAG,CAAC,CAAC,CAAC,CAAC;SACjG;IACL,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,4EAA4E;IAC5E,MAAM,QAAQ,GAAG,OAAO,CACpB,GAAG,EAAE,CAAC,CAAC;QACH,KAAK,EAAE,KAAK,CAAC,OAAO;QACpB,KAAK,EAAE,KAAK,CAAC,OAAO;QACpB,YAAY;QACZ,UAAU;QACV,cAAc;QACd,YAAY;QACZ,cAAc;KACjB,CAAC,EACF,CAAC,YAAY,EAAE,UAAU,EAAE,cAAc,EAAE,YAAY,EAAE,cAAc,CAAC,CAC3E,CAAC;IAEF,OAAO,QAAQ,CAAC;AACpB,CAAC;AAED,MAAM,CAAC,OAAO,UAAU,gBAAgB,CAAC,EAAE,QAAQ,EAAE;IACjD,MAAM,QAAQ,GAAG,eAAe,EAAE,CAAC;IACnC,OAAO,oBAAC,eAAe,CAAC,QAAQ,IAAC,KAAK,EAAE,QAAQ,IAAG,QAAQ,CAA4B,CAAC;AAC5F,CAAC"}
|
|
@@ -1,27 +1,3 @@
|
|
|
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
1
|
var __rest = (this && this.__rest) || function (s, e) {
|
|
26
2
|
var t = {};
|
|
27
3
|
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
@@ -33,18 +9,14 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
33
9
|
}
|
|
34
10
|
return t;
|
|
35
11
|
};
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
40
|
-
const react_1 = __importStar(require("react"));
|
|
41
|
-
const compose_1 = require("@wordpress/compose");
|
|
42
|
-
const slot_fill_context_1 = __importDefault(require("./slot-fill-context"));
|
|
12
|
+
import React, { useRef, useLayoutEffect, useContext, forwardRef } from 'react';
|
|
13
|
+
import { useMergeRefs } from '@wordpress/compose';
|
|
14
|
+
import SlotFillContext from './slot-fill-context';
|
|
43
15
|
function Slot(_a, forwardedRef) {
|
|
44
16
|
var { name, fillProps = {}, as: Component = 'div' } = _a, props = __rest(_a, ["name", "fillProps", "as"]);
|
|
45
|
-
const _b =
|
|
46
|
-
const ref =
|
|
47
|
-
|
|
17
|
+
const _b = useContext(SlotFillContext), { registerSlot, unregisterSlot } = _b, registry = __rest(_b, ["registerSlot", "unregisterSlot"]);
|
|
18
|
+
const ref = useRef();
|
|
19
|
+
useLayoutEffect(() => {
|
|
48
20
|
registerSlot(name, ref, fillProps);
|
|
49
21
|
return () => {
|
|
50
22
|
unregisterSlot(name, ref);
|
|
@@ -55,10 +27,10 @@ function Slot(_a, forwardedRef) {
|
|
|
55
27
|
}, [registerSlot, unregisterSlot, name]);
|
|
56
28
|
// fillProps may be an update that interacts with the layout, so we
|
|
57
29
|
// useLayoutEffect.
|
|
58
|
-
|
|
30
|
+
useLayoutEffect(() => {
|
|
59
31
|
registry.updateSlot(name, fillProps);
|
|
60
32
|
});
|
|
61
|
-
return
|
|
33
|
+
return React.createElement(Component, Object.assign({ ref: useMergeRefs([forwardedRef, ref]) }, props));
|
|
62
34
|
}
|
|
63
|
-
|
|
35
|
+
export default forwardRef(Slot);
|
|
64
36
|
//# sourceMappingURL=slot.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"slot.js","sourceRoot":"","sources":["../../../src/slot-fill/bubbles-virtually/slot.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"slot.js","sourceRoot":"","sources":["../../../src/slot-fill/bubbles-virtually/slot.tsx"],"names":[],"mappings":";;;;;;;;;;;AAAA,OAAO,KAAK,EAAE,EAAE,MAAM,EAAE,eAAe,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAC/E,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,eAAe,MAAM,qBAAqB,CAAC;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,UAAU,CAAC,eAAe,CAAC,EAA3E,EAAE,YAAY,EAAE,cAAc,OAA6C,EAAxC,QAAQ,cAA3C,kCAA6C,CAA8B,CAAC;IAClF,MAAM,GAAG,GAAG,MAAM,EAAE,CAAC;IAErB,eAAe,CAAC,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,eAAe,CAAC,GAAG,EAAE;QACjB,QAAQ,CAAC,UAAU,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC;IACzC,CAAC,CAAC,CAAC;IAEH,OAAO,oBAAC,SAAS,kBAAC,GAAG,EAAE,YAAY,CAAC,CAAC,YAAY,EAAE,GAAG,CAAC,CAAC,IAAM,KAAK,EAAI,CAAC;AAC5E,CAAC;AAED,eAAe,UAAU,CAAC,IAAI,CAAC,CAAC"}
|
|
@@ -1,18 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const
|
|
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 });
|
|
1
|
+
import { useContext } from 'react';
|
|
2
|
+
import { useSnapshot } from 'valtio';
|
|
3
|
+
import SlotFillContext from './slot-fill-context';
|
|
4
|
+
export default function useSlotFills(name) {
|
|
5
|
+
const registry = useContext(SlotFillContext);
|
|
6
|
+
const fills = useSnapshot(registry.fills, { sync: true });
|
|
12
7
|
// The important bit here is that this call ensures that the hook
|
|
13
8
|
// only causes a re-render if the "fills" of a given slot name
|
|
14
9
|
// change change, not any fills.
|
|
15
10
|
return fills.get(name);
|
|
16
11
|
}
|
|
17
|
-
exports.default = useSlotFills;
|
|
18
12
|
//# sourceMappingURL=use-slot-fills.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-slot-fills.js","sourceRoot":"","sources":["../../../src/slot-fill/bubbles-virtually/use-slot-fills.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"use-slot-fills.js","sourceRoot":"","sources":["../../../src/slot-fill/bubbles-virtually/use-slot-fills.ts"],"names":[],"mappings":"AAAA,OAAQ,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AACpC,OAAO,EAAE,WAAW,EAAE,MAAM,QAAQ,CAAC;AAErC,OAAO,eAAe,MAAM,qBAAqB,CAAC;AAElD,MAAM,CAAC,OAAO,UAAU,YAAY,CAAE,IAAI;IACzC,MAAM,QAAQ,GAAG,UAAU,CAAE,eAAe,CAAE,CAAC;IAC/C,MAAM,KAAK,GAAG,WAAW,CAAE,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"}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
var __rest = (this && this.__rest) || function (s, e) {
|
|
3
2
|
var t = {};
|
|
4
3
|
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
@@ -10,30 +9,26 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
10
9
|
}
|
|
11
10
|
return t;
|
|
12
11
|
};
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
const
|
|
18
|
-
const
|
|
19
|
-
const slot_fill_context_1 = __importDefault(require("./slot-fill-context"));
|
|
20
|
-
function useSlot(name) {
|
|
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 });
|
|
12
|
+
import { useCallback, useContext } from 'react';
|
|
13
|
+
import { useSnapshot } from 'valtio';
|
|
14
|
+
import SlotFillContext from './slot-fill-context';
|
|
15
|
+
export default function useSlot(name) {
|
|
16
|
+
const _a = useContext(SlotFillContext), { updateSlot: registryUpdateSlot, unregisterSlot: registryUnregisterSlot, registerFill: registryRegisterFill, unregisterFill: registryUnregisterFill } = _a, registry = __rest(_a, ["updateSlot", "unregisterSlot", "registerFill", "unregisterFill"]);
|
|
17
|
+
const slots = useSnapshot(registry.slots, { sync: true });
|
|
23
18
|
// The important bit here is that this call ensures
|
|
24
19
|
// the hook only causes a re-render if the slot
|
|
25
20
|
// with the given name change, not any other slot.
|
|
26
21
|
const slot = slots.get(name);
|
|
27
|
-
const updateSlot =
|
|
22
|
+
const updateSlot = useCallback((fillProps) => {
|
|
28
23
|
registryUpdateSlot(name, fillProps);
|
|
29
24
|
}, [name, registryUpdateSlot]);
|
|
30
|
-
const unregisterSlot =
|
|
25
|
+
const unregisterSlot = useCallback((slotRef) => {
|
|
31
26
|
registryUnregisterSlot(name, slotRef);
|
|
32
27
|
}, [name, registryUnregisterSlot]);
|
|
33
|
-
const registerFill =
|
|
28
|
+
const registerFill = useCallback((fillRef) => {
|
|
34
29
|
registryRegisterFill(name, fillRef);
|
|
35
30
|
}, [name, registryRegisterFill]);
|
|
36
|
-
const unregisterFill =
|
|
31
|
+
const unregisterFill = useCallback((fillRef) => {
|
|
37
32
|
registryUnregisterFill(name, fillRef);
|
|
38
33
|
}, [name, registryUnregisterFill]);
|
|
39
34
|
return Object.assign(Object.assign({}, slot), { updateSlot,
|
|
@@ -41,5 +36,4 @@ function useSlot(name) {
|
|
|
41
36
|
registerFill,
|
|
42
37
|
unregisterFill });
|
|
43
38
|
}
|
|
44
|
-
exports.default = useSlot;
|
|
45
39
|
//# sourceMappingURL=use-slot.js.map
|
|
@@ -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,OAAO,EAAE,WAAW,EAAE,UAAU,EAAW,MAAM,OAAO,CAAC;AACzD,OAAO,EAAE,WAAW,EAAE,MAAM,QAAQ,CAAC;AAErC,OAAO,eAAe,MAAM,qBAAqB,CAAC;AAElD,MAAM,CAAC,OAAO,UAAU,OAAO,CAAC,IAAU;IACtC,MAAM,KAMF,UAAU,CAAC,eAAe,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,WAAW,CAAC,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,WAAW,CAC1B,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,WAAW,CAC9B,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,WAA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