ink 6.7.0 → 7.0.0
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/build/ansi-tokenizer.d.ts +38 -0
- package/build/ansi-tokenizer.js +316 -0
- package/build/ansi-tokenizer.js.map +1 -0
- package/build/components/AnimationContext.d.ts +9 -0
- package/build/components/AnimationContext.js +13 -0
- package/build/components/AnimationContext.js.map +1 -0
- package/build/components/App.d.ts +5 -2
- package/build/components/App.js +192 -41
- package/build/components/App.js.map +1 -1
- package/build/components/AppContext.d.ts +33 -3
- package/build/components/AppContext.js +2 -1
- package/build/components/AppContext.js.map +1 -1
- package/build/components/Box.d.ts +16 -3
- package/build/components/ErrorBoundary.d.ts +2 -2
- package/build/components/ErrorOverview.js +6 -6
- package/build/components/ErrorOverview.js.map +1 -1
- package/build/components/Static.js.map +1 -1
- package/build/components/StdinContext.d.ts +7 -1
- package/build/components/StdinContext.js +1 -0
- package/build/components/StdinContext.js.map +1 -1
- package/build/components/Text.d.ts +1 -1
- package/build/components/Text.js +1 -1
- package/build/components/Text.js.map +1 -1
- package/build/components/Transform.d.ts +1 -1
- package/build/devtools-window-polyfill.js +7 -4
- package/build/devtools-window-polyfill.js.map +1 -1
- package/build/devtools.js +31 -6
- package/build/devtools.js.map +1 -1
- package/build/dom.d.ts +5 -1
- package/build/dom.js +25 -5
- package/build/dom.js.map +1 -1
- package/build/hooks/use-animation.d.ts +49 -0
- package/build/hooks/use-animation.js +87 -0
- package/build/hooks/use-animation.js.map +1 -0
- package/build/hooks/use-app.d.ts +5 -2
- package/build/hooks/use-app.js +1 -1
- package/build/hooks/use-box-metrics.d.ts +59 -0
- package/build/hooks/use-box-metrics.js +88 -0
- package/build/hooks/use-box-metrics.js.map +1 -0
- package/build/hooks/use-cursor.d.ts +1 -1
- package/build/hooks/use-cursor.js +1 -1
- package/build/hooks/use-focus-manager.d.ts +17 -2
- package/build/hooks/use-focus-manager.js +2 -1
- package/build/hooks/use-focus-manager.js.map +1 -1
- package/build/hooks/use-focus.d.ts +2 -1
- package/build/hooks/use-focus.js +5 -4
- package/build/hooks/use-focus.js.map +1 -1
- package/build/hooks/use-input.d.ts +2 -1
- package/build/hooks/use-input.js +82 -80
- package/build/hooks/use-input.js.map +1 -1
- package/build/hooks/use-is-screen-reader-enabled.d.ts +2 -1
- package/build/hooks/use-is-screen-reader-enabled.js +2 -1
- package/build/hooks/use-is-screen-reader-enabled.js.map +1 -1
- package/build/hooks/use-paste.d.ts +35 -0
- package/build/hooks/use-paste.js +62 -0
- package/build/hooks/use-paste.js.map +1 -0
- package/build/hooks/use-stderr.d.ts +1 -1
- package/build/hooks/use-stderr.js +1 -1
- package/build/hooks/use-stdin.d.ts +4 -2
- package/build/hooks/use-stdin.js +2 -1
- package/build/hooks/use-stdin.js.map +1 -1
- package/build/hooks/use-stdout.d.ts +1 -1
- package/build/hooks/use-stdout.js +1 -1
- package/build/hooks/use-window-size.d.ts +18 -0
- package/build/hooks/use-window-size.js +22 -0
- package/build/hooks/use-window-size.js.map +1 -0
- package/build/index.d.ts +10 -1
- package/build/index.js +5 -0
- package/build/index.js.map +1 -1
- package/build/ink.d.ts +55 -6
- package/build/ink.js +433 -162
- package/build/ink.js.map +1 -1
- package/build/input-parser.d.ts +10 -0
- package/build/input-parser.js +194 -0
- package/build/input-parser.js.map +1 -0
- package/build/log-update.d.ts +1 -0
- package/build/log-update.js +13 -1
- package/build/log-update.js.map +1 -1
- package/build/measure-element.d.ts +4 -0
- package/build/measure-element.js +4 -0
- package/build/measure-element.js.map +1 -1
- package/build/output.d.ts +1 -0
- package/build/output.js +63 -5
- package/build/output.js.map +1 -1
- package/build/parse-keypress.d.ts +1 -3
- package/build/parse-keypress.js +19 -17
- package/build/parse-keypress.js.map +1 -1
- package/build/reconciler.js +48 -19
- package/build/reconciler.js.map +1 -1
- package/build/render-border.js +29 -18
- package/build/render-border.js.map +1 -1
- package/build/render-to-string.d.ts +38 -0
- package/build/render-to-string.js +116 -0
- package/build/render-to-string.js.map +1 -0
- package/build/render.d.ts +69 -3
- package/build/render.js +18 -11
- package/build/render.js.map +1 -1
- package/build/sanitize-ansi.d.ts +2 -0
- package/build/sanitize-ansi.js +27 -0
- package/build/sanitize-ansi.js.map +1 -0
- package/build/squash-text-nodes.js +2 -1
- package/build/squash-text-nodes.js.map +1 -1
- package/build/styles.d.ts +78 -16
- package/build/styles.js +102 -31
- package/build/styles.js.map +1 -1
- package/build/utils.d.ts +9 -0
- package/build/utils.js +19 -0
- package/build/utils.js.map +1 -0
- package/build/wrap-text.js +7 -0
- package/build/wrap-text.js.map +1 -1
- package/build/write-synchronized.d.ts +1 -1
- package/build/write-synchronized.js +4 -2
- package/build/write-synchronized.js.map +1 -1
- package/package.json +40 -101
- package/readme.md +674 -56
- package/build/apply-styles.js +0 -175
- package/build/build-layout.js +0 -77
- package/build/calculate-wrapped-text.js +0 -53
- package/build/components/Color.js +0 -62
- package/build/experimental/apply-style.js +0 -140
- package/build/experimental/dom.js +0 -123
- package/build/experimental/output.js +0 -91
- package/build/experimental/reconciler.js +0 -141
- package/build/experimental/renderer.js +0 -81
- package/build/hooks/useInput.js +0 -38
- package/build/instance.js +0 -205
- package/build/options.d.ts +0 -52
- package/build/options.js +0 -2
- package/build/options.js.map +0 -1
- package/build/screen-reader-update.d.ts +0 -13
- package/build/screen-reader-update.js +0 -38
- package/build/screen-reader-update.js.map +0 -1
package/build/apply-styles.js
DELETED
|
@@ -1,175 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
|
|
8
|
-
var _yogaLayoutPrebuilt = _interopRequireDefault(require("yoga-layout-prebuilt"));
|
|
9
|
-
|
|
10
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
|
-
|
|
12
|
-
const applyMarginStyles = (node, style) => {
|
|
13
|
-
if (style.margin) {
|
|
14
|
-
node.setMargin(_yogaLayoutPrebuilt.default.EDGE_TOP, style.margin);
|
|
15
|
-
node.setMargin(_yogaLayoutPrebuilt.default.EDGE_BOTTOM, style.margin);
|
|
16
|
-
node.setMargin(_yogaLayoutPrebuilt.default.EDGE_START, style.margin);
|
|
17
|
-
node.setMargin(_yogaLayoutPrebuilt.default.EDGE_END, style.margin);
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
if (style.marginX) {
|
|
21
|
-
node.setMargin(_yogaLayoutPrebuilt.default.EDGE_START, style.marginX);
|
|
22
|
-
node.setMargin(_yogaLayoutPrebuilt.default.EDGE_END, style.marginX);
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
if (style.marginY) {
|
|
26
|
-
node.setMargin(_yogaLayoutPrebuilt.default.EDGE_TOP, style.marginY);
|
|
27
|
-
node.setMargin(_yogaLayoutPrebuilt.default.EDGE_BOTTOM, style.marginY);
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
if (style.marginTop) {
|
|
31
|
-
node.setMargin(_yogaLayoutPrebuilt.default.EDGE_TOP, style.marginTop);
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
if (style.marginBottom) {
|
|
35
|
-
node.setMargin(_yogaLayoutPrebuilt.default.EDGE_BOTTOM, style.marginBottom);
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
if (style.marginLeft) {
|
|
39
|
-
node.setMargin(_yogaLayoutPrebuilt.default.EDGE_START, style.marginLeft);
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
if (style.marginRight) {
|
|
43
|
-
node.setMargin(_yogaLayoutPrebuilt.default.EDGE_END, style.marginRight);
|
|
44
|
-
}
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
const applyPaddingStyles = (node, style) => {
|
|
48
|
-
if (style.padding) {
|
|
49
|
-
node.setPadding(_yogaLayoutPrebuilt.default.EDGE_TOP, style.padding);
|
|
50
|
-
node.setPadding(_yogaLayoutPrebuilt.default.EDGE_BOTTOM, style.padding);
|
|
51
|
-
node.setPadding(_yogaLayoutPrebuilt.default.EDGE_LEFT, style.padding);
|
|
52
|
-
node.setPadding(_yogaLayoutPrebuilt.default.EDGE_RIGHT, style.padding);
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
if (style.paddingX) {
|
|
56
|
-
node.setPadding(_yogaLayoutPrebuilt.default.EDGE_LEFT, style.paddingX);
|
|
57
|
-
node.setPadding(_yogaLayoutPrebuilt.default.EDGE_RIGHT, style.paddingX);
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
if (style.paddingY) {
|
|
61
|
-
node.setPadding(_yogaLayoutPrebuilt.default.EDGE_TOP, style.paddingY);
|
|
62
|
-
node.setPadding(_yogaLayoutPrebuilt.default.EDGE_BOTTOM, style.paddingY);
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
if (style.paddingTop) {
|
|
66
|
-
node.setPadding(_yogaLayoutPrebuilt.default.EDGE_TOP, style.paddingTop);
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
if (style.paddingBottom) {
|
|
70
|
-
node.setPadding(_yogaLayoutPrebuilt.default.EDGE_BOTTOM, style.paddingBottom);
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
if (style.paddingLeft) {
|
|
74
|
-
node.setPadding(_yogaLayoutPrebuilt.default.EDGE_LEFT, style.paddingLeft);
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
if (style.paddingRight) {
|
|
78
|
-
node.setPadding(_yogaLayoutPrebuilt.default.EDGE_RIGHT, style.paddingRight);
|
|
79
|
-
}
|
|
80
|
-
};
|
|
81
|
-
|
|
82
|
-
const applyFlexStyles = (node, style) => {
|
|
83
|
-
if (style.flexGrow) {
|
|
84
|
-
node.setFlexGrow(style.flexGrow);
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
if (style.flexShrink) {
|
|
88
|
-
node.setFlexShrink(style.flexShrink);
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
if (style.flexDirection) {
|
|
92
|
-
if (style.flexDirection === 'row') {
|
|
93
|
-
node.setFlexDirection(_yogaLayoutPrebuilt.default.FLEX_DIRECTION_ROW);
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
if (style.flexDirection === 'row-reverse') {
|
|
97
|
-
node.setFlexDirection(_yogaLayoutPrebuilt.default.FLEX_DIRECTION_ROW_REVERSE);
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
if (style.flexDirection === 'column') {
|
|
101
|
-
node.setFlexDirection(_yogaLayoutPrebuilt.default.FLEX_DIRECTION_COLUMN);
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
if (style.flexDirection === 'column-reverse') {
|
|
105
|
-
node.setFlexDirection(_yogaLayoutPrebuilt.default.FLEX_DIRECTION_COLUMN_REVERSE);
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
if (style.flexBasis !== undefined) {
|
|
110
|
-
node.setFlexBasis(style.flexBasis);
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
if (style.alignItems) {
|
|
114
|
-
if (style.alignItems === 'flex-start') {
|
|
115
|
-
node.setAlignItems(_yogaLayoutPrebuilt.default.ALIGN_FLEX_START);
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
if (style.alignItems === 'center') {
|
|
119
|
-
node.setAlignItems(_yogaLayoutPrebuilt.default.ALIGN_CENTER);
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
if (style.alignItems === 'flex-end') {
|
|
123
|
-
node.setAlignItems(_yogaLayoutPrebuilt.default.ALIGN_FLEX_END);
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
if (style.justifyContent) {
|
|
128
|
-
if (style.justifyContent === 'flex-start') {
|
|
129
|
-
node.setJustifyContent(_yogaLayoutPrebuilt.default.JUSTIFY_FLEX_START);
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
if (style.justifyContent === 'center') {
|
|
133
|
-
node.setJustifyContent(_yogaLayoutPrebuilt.default.JUSTIFY_CENTER);
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
if (style.justifyContent === 'flex-end') {
|
|
137
|
-
node.setJustifyContent(_yogaLayoutPrebuilt.default.JUSTIFY_FLEX_END);
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
if (style.justifyContent === 'space-between') {
|
|
141
|
-
node.setJustifyContent(_yogaLayoutPrebuilt.default.JUSTIFY_SPACE_BETWEEN);
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
if (style.justifyContent === 'space-around') {
|
|
145
|
-
node.setJustifyContent(_yogaLayoutPrebuilt.default.JUSTIFY_SPACE_AROUND);
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
};
|
|
149
|
-
|
|
150
|
-
const applyDimensionStyles = (node, style) => {
|
|
151
|
-
if (style.width !== undefined) {
|
|
152
|
-
node.setWidth(style.width);
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
if (style.height !== undefined) {
|
|
156
|
-
node.setHeight(style.height);
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
if (style.minWidth !== undefined) {
|
|
160
|
-
node.setMinWidth(style.minWidth);
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
if (style.minHeight !== undefined) {
|
|
164
|
-
node.setMinHeight(style.minHeight);
|
|
165
|
-
}
|
|
166
|
-
};
|
|
167
|
-
|
|
168
|
-
var _default = (node, style = {}) => {
|
|
169
|
-
applyMarginStyles(node, style);
|
|
170
|
-
applyPaddingStyles(node, style);
|
|
171
|
-
applyFlexStyles(node, style);
|
|
172
|
-
applyDimensionStyles(node, style);
|
|
173
|
-
};
|
|
174
|
-
|
|
175
|
-
exports.default = _default;
|
package/build/build-layout.js
DELETED
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
|
|
8
|
-
var _yogaLayoutPrebuilt = _interopRequireDefault(require("yoga-layout-prebuilt"));
|
|
9
|
-
|
|
10
|
-
var _applyStyles = _interopRequireDefault(require("./apply-styles"));
|
|
11
|
-
|
|
12
|
-
var _measureText = _interopRequireDefault(require("./measure-text"));
|
|
13
|
-
|
|
14
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
15
|
-
|
|
16
|
-
// Traverse the node tree, create Yoga nodes and assign styles to each Yoga node
|
|
17
|
-
const buildLayout = (node, options) => {
|
|
18
|
-
const {
|
|
19
|
-
config,
|
|
20
|
-
terminalWidth,
|
|
21
|
-
skipStaticElements
|
|
22
|
-
} = options;
|
|
23
|
-
|
|
24
|
-
const yogaNode = _yogaLayoutPrebuilt.default.Node.create(config);
|
|
25
|
-
|
|
26
|
-
node.yogaNode = yogaNode;
|
|
27
|
-
const style = node.style || {}; // Root node of the tree
|
|
28
|
-
|
|
29
|
-
if (node.nodeName === 'ROOT') {
|
|
30
|
-
// `terminalWidth` can be `undefined` if env isn't a TTY
|
|
31
|
-
yogaNode.setWidth(terminalWidth || 100);
|
|
32
|
-
|
|
33
|
-
if (node.childNodes.length > 0) {
|
|
34
|
-
const childNodes = node.childNodes.filter(childNode => {
|
|
35
|
-
return skipStaticElements ? !childNode.unstable__static : true;
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
for (const [index, childNode] of Object.entries(childNodes)) {
|
|
39
|
-
const childYogaNode = buildLayout(childNode, options).yogaNode;
|
|
40
|
-
yogaNode.insertChild(childYogaNode, index);
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
return node;
|
|
45
|
-
} // Apply margin, padding, flex, etc styles
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
(0, _applyStyles.default)(yogaNode, style); // Nodes with only text have a child Yoga node dedicated for that text
|
|
49
|
-
|
|
50
|
-
if (node.textContent || node.nodeValue) {
|
|
51
|
-
const {
|
|
52
|
-
width,
|
|
53
|
-
height
|
|
54
|
-
} = (0, _measureText.default)(node.textContent || node.nodeValue);
|
|
55
|
-
yogaNode.setWidth(style.width || width);
|
|
56
|
-
yogaNode.setHeight(style.height || height);
|
|
57
|
-
return node;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
if (Array.isArray(node.childNodes) && node.childNodes.length > 0) {
|
|
61
|
-
const childNodes = node.childNodes.filter(childNode => {
|
|
62
|
-
return skipStaticElements ? !childNode.unstable__static : true;
|
|
63
|
-
});
|
|
64
|
-
|
|
65
|
-
for (const [index, childNode] of Object.entries(childNodes)) {
|
|
66
|
-
const {
|
|
67
|
-
yogaNode: childYogaNode
|
|
68
|
-
} = buildLayout(childNode, options);
|
|
69
|
-
yogaNode.insertChild(childYogaNode, index);
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
return node;
|
|
74
|
-
};
|
|
75
|
-
|
|
76
|
-
var _default = buildLayout;
|
|
77
|
-
exports.default = _default;
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
|
|
8
|
-
var _measureText = _interopRequireDefault(require("./measure-text"));
|
|
9
|
-
|
|
10
|
-
var _wrapText = _interopRequireDefault(require("./wrap-text"));
|
|
11
|
-
|
|
12
|
-
var _getMaxWidth = _interopRequireDefault(require("./get-max-width"));
|
|
13
|
-
|
|
14
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
15
|
-
|
|
16
|
-
// Since we need to know the width of text container to wrap text, we have to calculate layout twice
|
|
17
|
-
// This function is executed after first layout calculation to reassign width and height of text nodes
|
|
18
|
-
const calculateWrappedText = node => {
|
|
19
|
-
if (node.textContent && typeof node.parentNode.style.textWrap === 'string') {
|
|
20
|
-
const {
|
|
21
|
-
yogaNode
|
|
22
|
-
} = node;
|
|
23
|
-
const parentYogaNode = node.parentNode.yogaNode;
|
|
24
|
-
const maxWidth = (0, _getMaxWidth.default)(parentYogaNode);
|
|
25
|
-
const currentWidth = yogaNode.getComputedWidth();
|
|
26
|
-
|
|
27
|
-
if (currentWidth > maxWidth) {
|
|
28
|
-
const {
|
|
29
|
-
textWrap
|
|
30
|
-
} = node.parentNode.style;
|
|
31
|
-
const wrappedText = (0, _wrapText.default)(node.textContent, maxWidth, {
|
|
32
|
-
textWrap
|
|
33
|
-
});
|
|
34
|
-
const {
|
|
35
|
-
width,
|
|
36
|
-
height
|
|
37
|
-
} = (0, _measureText.default)(wrappedText);
|
|
38
|
-
yogaNode.setWidth(width);
|
|
39
|
-
yogaNode.setHeight(height);
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
return;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
if (Array.isArray(node.childNodes) && node.childNodes.length > 0) {
|
|
46
|
-
for (const childNode of node.childNodes) {
|
|
47
|
-
calculateWrappedText(childNode);
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
};
|
|
51
|
-
|
|
52
|
-
var _default = calculateWrappedText;
|
|
53
|
-
exports.default = _default;
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
|
|
8
|
-
var _react = _interopRequireDefault(require("react"));
|
|
9
|
-
|
|
10
|
-
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
11
|
-
|
|
12
|
-
var _arrify = _interopRequireDefault(require("arrify"));
|
|
13
|
-
|
|
14
|
-
var _chalk = _interopRequireDefault(require("chalk"));
|
|
15
|
-
|
|
16
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
17
|
-
|
|
18
|
-
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
19
|
-
|
|
20
|
-
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
21
|
-
|
|
22
|
-
const methods = ['hex', 'hsl', 'hsv', 'hwb', 'rgb', 'keyword', 'bgHex', 'bgHsl', 'bgHsv', 'bgHwb', 'bgRgb', 'bgKeyword'];
|
|
23
|
-
|
|
24
|
-
const Color = (_ref) => {
|
|
25
|
-
let {
|
|
26
|
-
children
|
|
27
|
-
} = _ref,
|
|
28
|
-
colorProps = _objectWithoutProperties(_ref, ["children"]);
|
|
29
|
-
|
|
30
|
-
if (children === '') {
|
|
31
|
-
return null;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
const transformChildren = children => {
|
|
35
|
-
Object.keys(colorProps).forEach(method => {
|
|
36
|
-
if (colorProps[method]) {
|
|
37
|
-
if (methods.includes(method)) {
|
|
38
|
-
children = _chalk.default[method](...(0, _arrify.default)(colorProps[method]))(children);
|
|
39
|
-
} else if (typeof _chalk.default[method] === 'function') {
|
|
40
|
-
children = _chalk.default[method](children);
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
});
|
|
44
|
-
return children;
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
return _react.default.createElement("span", {
|
|
48
|
-
style: {
|
|
49
|
-
flexDirection: 'row'
|
|
50
|
-
},
|
|
51
|
-
unstable__transformChildren: transformChildren
|
|
52
|
-
}, children);
|
|
53
|
-
};
|
|
54
|
-
|
|
55
|
-
Color.propTypes = {
|
|
56
|
-
children: _propTypes.default.node
|
|
57
|
-
};
|
|
58
|
-
Color.defaultProps = {
|
|
59
|
-
children: ''
|
|
60
|
-
};
|
|
61
|
-
var _default = Color;
|
|
62
|
-
exports.default = _default;
|
|
@@ -1,140 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
|
|
8
|
-
var _yogaLayoutPrebuilt = _interopRequireDefault(require("yoga-layout-prebuilt"));
|
|
9
|
-
|
|
10
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
|
-
|
|
12
|
-
const applyPositionStyles = (node, style) => {
|
|
13
|
-
if (!style.position) {
|
|
14
|
-
node.setPositionType(NaN);
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
if (style.position === 'absolute') {
|
|
18
|
-
node.setPositionType(_yogaLayoutPrebuilt.default.POSITION_TYPE_ABSOLUTE);
|
|
19
|
-
}
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
const applyMarginStyles = (node, style) => {
|
|
23
|
-
node.setMargin(_yogaLayoutPrebuilt.default.EDGE_START, style.marginLeft || style.marginX || style.margin || 0);
|
|
24
|
-
node.setMargin(_yogaLayoutPrebuilt.default.EDGE_END, style.marginRight || style.marginX || style.margin || 0);
|
|
25
|
-
node.setMargin(_yogaLayoutPrebuilt.default.EDGE_TOP, style.marginTop || style.marginY || style.margin || 0);
|
|
26
|
-
node.setMargin(_yogaLayoutPrebuilt.default.EDGE_BOTTOM, style.marginBottom || style.marginY || style.margin || 0);
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
const applyPaddingStyles = (node, style) => {
|
|
30
|
-
node.setPadding(_yogaLayoutPrebuilt.default.EDGE_LEFT, style.paddingLeft || style.paddingX || style.padding || 0);
|
|
31
|
-
node.setPadding(_yogaLayoutPrebuilt.default.EDGE_RIGHT, style.paddingRight || style.paddingX || style.padding || 0);
|
|
32
|
-
node.setPadding(_yogaLayoutPrebuilt.default.EDGE_TOP, style.paddingTop || style.paddingY || style.padding || 0);
|
|
33
|
-
node.setPadding(_yogaLayoutPrebuilt.default.EDGE_BOTTOM, style.paddingBottom || style.paddingY || style.padding || 0);
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
const applyFlexStyles = (node, style) => {
|
|
37
|
-
node.setFlexGrow(style.flexGrow || 0);
|
|
38
|
-
node.setFlexShrink(typeof style.flexShrink === 'number' ? style.flexShrink : 1);
|
|
39
|
-
|
|
40
|
-
if (style.flexDirection === 'row') {
|
|
41
|
-
node.setFlexDirection(_yogaLayoutPrebuilt.default.FLEX_DIRECTION_ROW);
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
if (style.flexDirection === 'row-reverse') {
|
|
45
|
-
node.setFlexDirection(_yogaLayoutPrebuilt.default.FLEX_DIRECTION_ROW_REVERSE);
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
if (style.flexDirection === 'column') {
|
|
49
|
-
node.setFlexDirection(_yogaLayoutPrebuilt.default.FLEX_DIRECTION_COLUMN);
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
if (style.flexDirection === 'column-reverse') {
|
|
53
|
-
node.setFlexDirection(_yogaLayoutPrebuilt.default.FLEX_DIRECTION_COLUMN_REVERSE);
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
if (typeof style.flexBasis === 'number') {
|
|
57
|
-
node.setFlexBasis(style.flexBasis);
|
|
58
|
-
} else if (typeof style.flexBasis === 'string') {
|
|
59
|
-
node.setFlexBasisPercent(parseInt(style.flexBasis, 10));
|
|
60
|
-
} else {
|
|
61
|
-
// This should be replaced with node.setFlexBasisAuto() when new Yoga release is out
|
|
62
|
-
node.setFlexBasis(NaN);
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
if (style.alignItems === 'stretch' || !style.alignItems) {
|
|
66
|
-
node.setAlignItems(_yogaLayoutPrebuilt.default.ALIGN_STRETCH);
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
if (style.alignItems === 'flex-start') {
|
|
70
|
-
node.setAlignItems(_yogaLayoutPrebuilt.default.ALIGN_FLEX_START);
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
if (style.alignItems === 'center') {
|
|
74
|
-
node.setAlignItems(_yogaLayoutPrebuilt.default.ALIGN_CENTER);
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
if (style.alignItems === 'flex-end') {
|
|
78
|
-
node.setAlignItems(_yogaLayoutPrebuilt.default.ALIGN_FLEX_END);
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
if (style.justifyContent === 'flex-start' || !style.justifyContent) {
|
|
82
|
-
node.setJustifyContent(_yogaLayoutPrebuilt.default.JUSTIFY_FLEX_START);
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
if (style.justifyContent === 'center') {
|
|
86
|
-
node.setJustifyContent(_yogaLayoutPrebuilt.default.JUSTIFY_CENTER);
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
if (style.justifyContent === 'flex-end') {
|
|
90
|
-
node.setJustifyContent(_yogaLayoutPrebuilt.default.JUSTIFY_FLEX_END);
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
if (style.justifyContent === 'space-between') {
|
|
94
|
-
node.setJustifyContent(_yogaLayoutPrebuilt.default.JUSTIFY_SPACE_BETWEEN);
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
if (style.justifyContent === 'space-around') {
|
|
98
|
-
node.setJustifyContent(_yogaLayoutPrebuilt.default.JUSTIFY_SPACE_AROUND);
|
|
99
|
-
}
|
|
100
|
-
};
|
|
101
|
-
|
|
102
|
-
const applyDimensionStyles = (node, style) => {
|
|
103
|
-
if (typeof style.width === 'number') {
|
|
104
|
-
node.setWidth(style.width);
|
|
105
|
-
} else if (typeof style.width === 'string') {
|
|
106
|
-
node.setWidthPercent(parseInt(style.width, 10));
|
|
107
|
-
} else {
|
|
108
|
-
node.setWidthAuto();
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
if (typeof style.height === 'number') {
|
|
112
|
-
node.setHeight(style.height);
|
|
113
|
-
} else if (typeof style.height === 'string') {
|
|
114
|
-
node.setHeightPercent(parseInt(style.height, 10));
|
|
115
|
-
} else {
|
|
116
|
-
node.setHeightAuto();
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
if (typeof style.minWidth === 'string') {
|
|
120
|
-
node.setMinWidthPercent(parseInt(style.minWidth, 10));
|
|
121
|
-
} else {
|
|
122
|
-
node.setMinWidth(style.minWidth || 0);
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
if (typeof style.minHeight === 'string') {
|
|
126
|
-
node.setMinHeightPercent(parseInt(style.minHeight, 10));
|
|
127
|
-
} else {
|
|
128
|
-
node.setMinHeight(style.minHeight || 0);
|
|
129
|
-
}
|
|
130
|
-
};
|
|
131
|
-
|
|
132
|
-
var _default = (node, style = {}) => {
|
|
133
|
-
applyPositionStyles(node, style);
|
|
134
|
-
applyMarginStyles(node, style);
|
|
135
|
-
applyPaddingStyles(node, style);
|
|
136
|
-
applyFlexStyles(node, style);
|
|
137
|
-
applyDimensionStyles(node, style);
|
|
138
|
-
};
|
|
139
|
-
|
|
140
|
-
exports.default = _default;
|
|
@@ -1,123 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.setTextContent = exports.createTextNode = exports.setAttribute = exports.setStyle = exports.removeChildNode = exports.insertBeforeNode = exports.appendChildNode = exports.createNode = void 0;
|
|
7
|
-
|
|
8
|
-
var _yogaLayoutPrebuilt = _interopRequireDefault(require("yoga-layout-prebuilt"));
|
|
9
|
-
|
|
10
|
-
var _measureText = _interopRequireDefault(require("../measure-text"));
|
|
11
|
-
|
|
12
|
-
var _applyStyle = _interopRequireDefault(require("./apply-style"));
|
|
13
|
-
|
|
14
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
15
|
-
|
|
16
|
-
// Helper utilities implementing some common DOM methods to simplify reconciliation code
|
|
17
|
-
const createNode = tagName => ({
|
|
18
|
-
nodeName: tagName.toUpperCase(),
|
|
19
|
-
style: {},
|
|
20
|
-
attributes: {},
|
|
21
|
-
childNodes: [],
|
|
22
|
-
parentNode: null,
|
|
23
|
-
textContent: null,
|
|
24
|
-
yogaNode: _yogaLayoutPrebuilt.default.Node.create()
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
exports.createNode = createNode;
|
|
28
|
-
|
|
29
|
-
const appendChildNode = (node, childNode) => {
|
|
30
|
-
if (childNode.parentNode) {
|
|
31
|
-
removeChildNode(childNode.parentNode, childNode);
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
childNode.parentNode = node;
|
|
35
|
-
node.childNodes.push(childNode);
|
|
36
|
-
node.yogaNode.insertChild(childNode.yogaNode, node.yogaNode.getChildCount());
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
exports.appendChildNode = appendChildNode;
|
|
40
|
-
|
|
41
|
-
const insertBeforeNode = (node, newChildNode, beforeChildNode) => {
|
|
42
|
-
if (newChildNode.parentNode) {
|
|
43
|
-
removeChildNode(newChildNode.parentNode, newChildNode);
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
newChildNode.parentNode = node;
|
|
47
|
-
const index = node.childNodes.indexOf(beforeChildNode);
|
|
48
|
-
|
|
49
|
-
if (index >= 0) {
|
|
50
|
-
node.childNodes.splice(index, 0, newChildNode);
|
|
51
|
-
node.yogaNode.insertChild(newChildNode.yogaNode, index);
|
|
52
|
-
return;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
node.childNodes.push(newChildNode);
|
|
56
|
-
node.yogaNode.insertChild(newChildNode.yogaNode, node.yogaNode.getChildCount());
|
|
57
|
-
};
|
|
58
|
-
|
|
59
|
-
exports.insertBeforeNode = insertBeforeNode;
|
|
60
|
-
|
|
61
|
-
const removeChildNode = (node, removeNode) => {
|
|
62
|
-
removeNode.parentNode.yogaNode.removeChild(removeNode.yogaNode);
|
|
63
|
-
removeNode.parentNode = null;
|
|
64
|
-
const index = node.childNodes.indexOf(removeNode);
|
|
65
|
-
|
|
66
|
-
if (index >= 0) {
|
|
67
|
-
node.childNodes.splice(index, 1);
|
|
68
|
-
}
|
|
69
|
-
};
|
|
70
|
-
|
|
71
|
-
exports.removeChildNode = removeChildNode;
|
|
72
|
-
|
|
73
|
-
const setStyle = (node, style) => {
|
|
74
|
-
node.style = style;
|
|
75
|
-
(0, _applyStyle.default)(node.yogaNode, style);
|
|
76
|
-
};
|
|
77
|
-
|
|
78
|
-
exports.setStyle = setStyle;
|
|
79
|
-
|
|
80
|
-
const setAttribute = (node, key, value) => {
|
|
81
|
-
node.attributes[key] = value;
|
|
82
|
-
};
|
|
83
|
-
|
|
84
|
-
exports.setAttribute = setAttribute;
|
|
85
|
-
|
|
86
|
-
const createTextNode = text => {
|
|
87
|
-
const node = {
|
|
88
|
-
nodeName: '#text',
|
|
89
|
-
nodeValue: text,
|
|
90
|
-
yogaNode: _yogaLayoutPrebuilt.default.Node.create()
|
|
91
|
-
};
|
|
92
|
-
setTextContent(node, text);
|
|
93
|
-
return node;
|
|
94
|
-
};
|
|
95
|
-
|
|
96
|
-
exports.createTextNode = createTextNode;
|
|
97
|
-
|
|
98
|
-
const setTextContent = (node, text) => {
|
|
99
|
-
if (typeof text !== 'string') {
|
|
100
|
-
text = String(text);
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
let width = 0;
|
|
104
|
-
let height = 0;
|
|
105
|
-
|
|
106
|
-
if (text.length > 0) {
|
|
107
|
-
const dimensions = (0, _measureText.default)(text);
|
|
108
|
-
width = dimensions.width;
|
|
109
|
-
height = dimensions.height;
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
if (node.nodeName === '#text') {
|
|
113
|
-
node.nodeValue = text;
|
|
114
|
-
node.yogaNode.setWidth(width);
|
|
115
|
-
node.yogaNode.setHeight(height);
|
|
116
|
-
} else {
|
|
117
|
-
node.textContent = text;
|
|
118
|
-
node.yogaNode.setWidth(node.style.width || width);
|
|
119
|
-
node.yogaNode.setHeight(node.style.height || height);
|
|
120
|
-
}
|
|
121
|
-
};
|
|
122
|
-
|
|
123
|
-
exports.setTextContent = setTextContent;
|