1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | exports.UIDConsumer = exports.UIDFork = exports.UIDReset = void 0;
|
4 | var React = require("react");
|
5 | var react_1 = require("react");
|
6 | var UIDComponent_1 = require("./UIDComponent");
|
7 | var context_1 = require("./context");
|
8 | var hooks_1 = require("./hooks");
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 |
|
18 |
|
19 | var UIDReset = function (_a) {
|
20 | var children = _a.children, _b = _a.prefix, prefix = _b === void 0 ? '' : _b;
|
21 | var valueSource = (0, react_1.useState)(function () { return (0, context_1.createSource)(prefix); })[0];
|
22 | return React.createElement(context_1.source.Provider, { value: valueSource }, children);
|
23 | };
|
24 | exports.UIDReset = UIDReset;
|
25 |
|
26 |
|
27 |
|
28 |
|
29 |
|
30 | var UIDFork = function (_a) {
|
31 | var children = _a.children, _b = _a.prefix, prefix = _b === void 0 ? '' : _b;
|
32 | var id = (0, hooks_1.useUID)();
|
33 | var valueSource = (0, react_1.useState)(function () { return (0, context_1.createSource)(id + '-' + prefix); })[0];
|
34 | return React.createElement(context_1.source.Provider, { value: valueSource }, children);
|
35 | };
|
36 | exports.UIDFork = UIDFork;
|
37 |
|
38 |
|
39 |
|
40 |
|
41 |
|
42 |
|
43 |
|
44 |
|
45 |
|
46 |
|
47 |
|
48 |
|
49 |
|
50 |
|
51 |
|
52 |
|
53 |
|
54 |
|
55 | var UIDConsumer = function (_a) {
|
56 | var name = _a.name, children = _a.children;
|
57 | return (React.createElement(context_1.source.Consumer, null, function (value) { return React.createElement(UIDComponent_1.UID, { name: name, idSource: value, children: children }); }));
|
58 | };
|
59 | exports.UIDConsumer = UIDConsumer;
|