@d3plus/text 3.0.0-alpha.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/README.md ADDED
@@ -0,0 +1,229 @@
1
+ # @d3plus/text
2
+
3
+ A smart SVG text box with line wrapping and automatic font size scaling.
4
+
5
+ ## Installing
6
+
7
+ If using npm, `npm install @d3plus/text`. Otherwise, you can download the [latest release from GitHub](https://github.com/d3plus/d3plus/releases/latest) or load from a [CDN](https://cdn.jsdelivr.net/npm/@d3plus/text@3.0.0-alpha.0/+esm).
8
+
9
+ ```js
10
+ import modules from "@d3plus/text";
11
+ ```
12
+
13
+ In vanilla JavaScript, a `d3plus` global is exported from the pre-bundled version:
14
+
15
+ ```html
16
+ <script src="https://cdn.jsdelivr.net/npm/@d3plus/text@3.0.0-alpha.0"></script>
17
+ <script>
18
+ console.log(d3plus);
19
+ </script>
20
+ ```
21
+
22
+ ## Examples
23
+
24
+ Live examples can be found on [d3plus.org](https://d3plus.org/), which includes a collection of example visualizations using @d3plus/react.
25
+
26
+ ## API Reference
27
+
28
+ #####
29
+ * [stringify](#stringify) - Coerces value into a String.
30
+ * [strip](#strip) - Removes all non ASCII characters from a string.
31
+ * [textSplit](#textSplit) - Splits a given sentence into an array of words.
32
+ * [textWrap](#textWrap) - Based on the defined styles and dimensions, breaks a string into an array of strings for each line of text.
33
+ * [titleCase](#titleCase) - Capitalizes the first letter of each word in a phrase/sentence.
34
+ * [trim](#trim) - Cross-browser implementation of [trim](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/Trim).
35
+ * [trimLeft](#trimLeft) - Cross-browser implementation of [trimLeft](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/TrimLeft).
36
+ * [trimRight](#trimRight) - Cross-browser implementation of [trimRight](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/TrimRight).
37
+
38
+ #####
39
+ * [fontFamily](#fontFamily) - The default fallback font list used for all text labels as an Array of Strings.
40
+ * [fontFamilyStringify](#fontFamilyStringify) - Converts an Array of font-family names into a CSS font-family string.
41
+
42
+ ---
43
+
44
+ <a name="stringify"></a>
45
+ #### d3plus.**stringify**(value) [<>](https://github.com/d3plus/d3plus/blob/main/packages/text/src/stringify.js#L1)
46
+
47
+ Coerces value into a String.
48
+
49
+
50
+ This is a global function
51
+
52
+ ---
53
+
54
+ <a name="strip"></a>
55
+ #### d3plus.**strip**(value, [spacer]) [<>](https://github.com/d3plus/d3plus/blob/main/packages/text/src/strip.js#L18)
56
+
57
+ Removes all non ASCII characters from a string.
58
+
59
+
60
+ This is a global function
61
+
62
+ ---
63
+
64
+ <a name="textSplit"></a>
65
+ #### d3plus.**textSplit**(sentence) [<>](https://github.com/d3plus/d3plus/blob/main/packages/text/src/textSplit.js#L51)
66
+
67
+ Splits a given sentence into an array of words.
68
+
69
+
70
+ This is a global function
71
+
72
+ ---
73
+
74
+ <a name="textWrap"></a>
75
+ #### d3plus.**textWrap**() [<>](https://github.com/d3plus/d3plus/blob/main/packages/text/src/textWrap.js#L7)
76
+
77
+ Based on the defined styles and dimensions, breaks a string into an array of strings for each line of text.
78
+
79
+
80
+ This is a global function
81
+
82
+
83
+ * [textWrap()](#textWrap)
84
+ * [.fontFamily([*value*])](#textWrap.fontFamily)
85
+ * [.fontSize([*value*])](#textWrap.fontSize)
86
+ * [.fontWeight([*value*])](#textWrap.fontWeight)
87
+ * [.height([*value*])](#textWrap.height)
88
+ * [.lineHeight([*value*])](#textWrap.lineHeight)
89
+ * [.maxLines([*value*])](#textWrap.maxLines)
90
+ * [.overflow([*value*])](#textWrap.overflow)
91
+ * [.split([*value*])](#textWrap.split)
92
+ * [.width([*value*])](#textWrap.width)
93
+
94
+
95
+ <a name="textWrap.fontFamily" href="#textWrap.fontFamily">#</a> d3plus..**fontFamily**([*value*]) [<>](https://github.com/d3plus/d3plus/blob/main/packages/text/src/textWrap.js#L90)
96
+
97
+ If *value* is specified, sets the font family accessor to the specified function or string and returns this generator. If *value* is not specified, returns the current font family.
98
+
99
+
100
+ This is a static method of [<code>textWrap</code>](#textWrap)
101
+
102
+
103
+ <a name="textWrap.fontSize" href="#textWrap.fontSize">#</a> d3plus..**fontSize**([*value*]) [<>](https://github.com/d3plus/d3plus/blob/main/packages/text/src/textWrap.js#L99)
104
+
105
+ If *value* is specified, sets the font size accessor to the specified function or number and returns this generator. If *value* is not specified, returns the current font size.
106
+
107
+
108
+ This is a static method of [<code>textWrap</code>](#textWrap)
109
+
110
+
111
+ <a name="textWrap.fontWeight" href="#textWrap.fontWeight">#</a> d3plus..**fontWeight**([*value*]) [<>](https://github.com/d3plus/d3plus/blob/main/packages/text/src/textWrap.js#L108)
112
+
113
+ If *value* is specified, sets the font weight accessor to the specified function or number and returns this generator. If *value* is not specified, returns the current font weight.
114
+
115
+
116
+ This is a static method of [<code>textWrap</code>](#textWrap)
117
+
118
+
119
+ <a name="textWrap.height" href="#textWrap.height">#</a> d3plus..**height**([*value*]) [<>](https://github.com/d3plus/d3plus/blob/main/packages/text/src/textWrap.js#L117)
120
+
121
+ If *value* is specified, sets height limit to the specified value and returns this generator. If *value* is not specified, returns the current value.
122
+
123
+
124
+ This is a static method of [<code>textWrap</code>](#textWrap)
125
+
126
+
127
+ <a name="textWrap.lineHeight" href="#textWrap.lineHeight">#</a> d3plus..**lineHeight**([*value*]) [<>](https://github.com/d3plus/d3plus/blob/main/packages/text/src/textWrap.js#L126)
128
+
129
+ If *value* is specified, sets the line height accessor to the specified function or number and returns this generator. If *value* is not specified, returns the current line height accessor, which is 1.1 times the [font size](#textWrap.fontSize) by default.
130
+
131
+
132
+ This is a static method of [<code>textWrap</code>](#textWrap)
133
+
134
+
135
+ <a name="textWrap.maxLines" href="#textWrap.maxLines">#</a> d3plus..**maxLines**([*value*]) [<>](https://github.com/d3plus/d3plus/blob/main/packages/text/src/textWrap.js#L135)
136
+
137
+ If *value* is specified, sets the maximum number of lines allowed when wrapping.
138
+
139
+
140
+ This is a static method of [<code>textWrap</code>](#textWrap)
141
+
142
+
143
+ <a name="textWrap.overflow" href="#textWrap.overflow">#</a> d3plus..**overflow**([*value*]) [<>](https://github.com/d3plus/d3plus/blob/main/packages/text/src/textWrap.js#L144)
144
+
145
+ If *value* is specified, sets the overflow to the specified boolean and returns this generator. If *value* is not specified, returns the current overflow value.
146
+
147
+
148
+ This is a static method of [<code>textWrap</code>](#textWrap)
149
+
150
+
151
+ <a name="textWrap.split" href="#textWrap.split">#</a> d3plus..**split**([*value*]) [<>](https://github.com/d3plus/d3plus/blob/main/packages/text/src/textWrap.js#L153)
152
+
153
+ If *value* is specified, sets the word split function to the specified function and returns this generator. If *value* is not specified, returns the current word split function.
154
+
155
+
156
+ This is a static method of [<code>textWrap</code>](#textWrap)
157
+
158
+
159
+ <a name="textWrap.width" href="#textWrap.width">#</a> d3plus..**width**([*value*]) [<>](https://github.com/d3plus/d3plus/blob/main/packages/text/src/textWrap.js#L162)
160
+
161
+ If *value* is specified, sets width limit to the specified value and returns this generator. If *value* is not specified, returns the current value.
162
+
163
+
164
+ This is a static method of [<code>textWrap</code>](#textWrap)
165
+
166
+ ---
167
+
168
+ <a name="titleCase"></a>
169
+ #### d3plus.**titleCase**(str) [<>](https://github.com/d3plus/d3plus/blob/main/packages/text/src/titleCase.js#L6)
170
+
171
+ Capitalizes the first letter of each word in a phrase/sentence.
172
+
173
+
174
+ This is a global function
175
+
176
+ ---
177
+
178
+ <a name="trim"></a>
179
+ #### d3plus.**trim**(str) [<>](https://github.com/d3plus/d3plus/blob/main/packages/text/src/trim.js#L1)
180
+
181
+ Cross-browser implementation of [trim](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/Trim).
182
+
183
+
184
+ This is a global function
185
+
186
+ ---
187
+
188
+ <a name="trimLeft"></a>
189
+ #### d3plus.**trimLeft**(str) [<>](https://github.com/d3plus/d3plus/blob/main/packages/text/src/trim.js#L10)
190
+
191
+ Cross-browser implementation of [trimLeft](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/TrimLeft).
192
+
193
+
194
+ This is a global function
195
+
196
+ ---
197
+
198
+ <a name="trimRight"></a>
199
+ #### d3plus.**trimRight**(str) [<>](https://github.com/d3plus/d3plus/blob/main/packages/text/src/trim.js#L19)
200
+
201
+ Cross-browser implementation of [trimRight](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/TrimRight).
202
+
203
+
204
+ This is a global function
205
+
206
+ ---
207
+
208
+ <a name="fontFamily"></a>
209
+ #### **fontFamily** [<>](https://github.com/d3plus/d3plus/blob/main/packages/text/src/fontFamily.js#L1)
210
+
211
+ The default fallback font list used for all text labels as an Array of Strings.
212
+
213
+
214
+ This is a global constant
215
+
216
+ ---
217
+
218
+ <a name="fontFamilyStringify"></a>
219
+ #### **fontFamilyStringify** [<>](https://github.com/d3plus/d3plus/blob/main/packages/text/src/fontFamily.js#L8)
220
+
221
+ Converts an Array of font-family names into a CSS font-family string.
222
+
223
+
224
+ This is a global constant
225
+
226
+ ---
227
+
228
+
229
+ ###### <sub>Documentation generated on Thu, 13 Mar 2025 19:58:30 GMT</sub>
package/es/index.js ADDED
@@ -0,0 +1,7 @@
1
+ export { fontFamily, fontFamilyStringify } from "./src/fontFamily.js";
2
+ export { default as stringify } from "./src/stringify.js";
3
+ export { default as strip } from "./src/strip.js";
4
+ export { default as textSplit } from "./src/textSplit.js";
5
+ export { default as textWrap } from "./src/textWrap.js";
6
+ export { default as titleCase } from "./src/titleCase.js";
7
+ export { trim, trimLeft, trimRight } from "./src/trim.js";