@spark-web/text 5.1.0 → 5.2.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/CHANGELOG.md +11 -0
- package/dist/declarations/src/context.d.ts +2 -2
- package/dist/declarations/src/default-text-props.d.ts +1 -1
- package/dist/declarations/src/text.d.ts +4 -0
- package/dist/declarations/src/use-text.d.ts +4 -3
- package/dist/spark-web-text.cjs.dev.js +17 -12
- package/dist/spark-web-text.cjs.prod.js +17 -12
- package/dist/spark-web-text.esm.js +17 -12
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,16 @@
|
|
|
1
1
|
# @spark-web/text
|
|
2
2
|
|
|
3
|
+
## 5.2.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#554](https://github.com/brighte-labs/spark-web/pull/554)
|
|
8
|
+
[`8e67e65`](https://github.com/brighte-labs/spark-web/commit/8e67e658cff29a4819417142c989f3c3de1e46c1)
|
|
9
|
+
Thanks [@ralcoriza-brighte](https://github.com/ralcoriza-brighte)! - Add
|
|
10
|
+
support for `css` prop in <Text />
|
|
11
|
+
|
|
12
|
+
Fixed issues with the `weight` prop in text
|
|
13
|
+
|
|
3
14
|
## 5.1.0
|
|
4
15
|
|
|
5
16
|
### Minor Changes
|
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
export declare const TextContext: import("react").Context<{
|
|
3
3
|
size: import("@spark-web/theme/src/themes/_types/typography").TypographySizing;
|
|
4
4
|
tone: string | number;
|
|
5
|
-
weight: "bold" | "medium" | "light" | "thin" | "black" | "extralight" | "regular" | "semibold" | "extrabold";
|
|
5
|
+
weight: "bold" | "medium" | "light" | "thin" | "black" | "extralight" | "regular" | "semibold" | "extrabold" | undefined;
|
|
6
6
|
} | undefined>;
|
|
7
7
|
export declare function useTextContext(): {
|
|
8
8
|
size: import("@spark-web/theme/src/themes/_types/typography").TypographySizing;
|
|
9
9
|
tone: string | number;
|
|
10
|
-
weight: "bold" | "medium" | "light" | "thin" | "black" | "extralight" | "regular" | "semibold" | "extrabold";
|
|
10
|
+
weight: "bold" | "medium" | "light" | "thin" | "black" | "extralight" | "regular" | "semibold" | "extrabold" | undefined;
|
|
11
11
|
} | undefined;
|
|
@@ -11,6 +11,6 @@ export declare function DefaultTextPropsProvider({ children, size, tone, weight,
|
|
|
11
11
|
export declare const useDefaultTextProps: ({ size: sizeProp, tone: toneProp, weight: weightProp, }: DefaultTextProps) => {
|
|
12
12
|
size: import("@spark-web/theme/src/themes/_types/typography").TypographySizing;
|
|
13
13
|
tone: string | number;
|
|
14
|
-
weight: "bold" | "medium" | "light" | "thin" | "black" | "extralight" | "regular" | "semibold" | "extrabold";
|
|
14
|
+
weight: "bold" | "medium" | "light" | "thin" | "black" | "extralight" | "regular" | "semibold" | "extrabold" | undefined;
|
|
15
15
|
};
|
|
16
16
|
export {};
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
/** @jsxImportSource @emotion/react */
|
|
2
|
+
import type { CSSObject } from '@emotion/react';
|
|
1
3
|
import type { BoxProps } from '@spark-web/box';
|
|
2
4
|
import type { DataAttributeMap } from '@spark-web/utils/internal';
|
|
3
5
|
import type { CSSProperties, ReactNode } from 'react';
|
|
@@ -19,6 +21,8 @@ declare type BlockProps = {
|
|
|
19
21
|
export declare type TextProps = Partial<UseTextProps> & {
|
|
20
22
|
/** The text content. */
|
|
21
23
|
children?: ReactNode;
|
|
24
|
+
/** Customizes the component element. */
|
|
25
|
+
css?: CSSObject;
|
|
22
26
|
/** Sets data attributes on the component. */
|
|
23
27
|
data?: DataAttributeMap;
|
|
24
28
|
/** An identifier which must be unique in the whole document. */
|
|
@@ -8,11 +8,12 @@ export declare type UseTextProps = {
|
|
|
8
8
|
/** The tone of the text. */
|
|
9
9
|
tone: ForegroundTone;
|
|
10
10
|
/** The weight of the text. */
|
|
11
|
-
weight
|
|
11
|
+
weight?: keyof SparkTheme['typography']['fontWeight'];
|
|
12
12
|
};
|
|
13
13
|
export declare function useText({ baseline, size, tone, weight }: UseTextProps): (import("@emotion/serialize").CSSObject | undefined)[];
|
|
14
|
-
export declare function createTextStyles({ fontSize, fontWeight, lineHeight, trims }: SparkTextDefinition, { includeTrims }?: {
|
|
14
|
+
export declare function createTextStyles({ fontSize, fontWeight, lineHeight, trims }: SparkTextDefinition, { includeTrims, includeWeight }?: {
|
|
15
15
|
includeTrims?: boolean | undefined;
|
|
16
|
+
includeWeight?: boolean | undefined;
|
|
16
17
|
}): {
|
|
17
18
|
'::before'?: {
|
|
18
19
|
marginBottom: string;
|
|
@@ -25,6 +26,6 @@ export declare function createTextStyles({ fontSize, fontWeight, lineHeight, tri
|
|
|
25
26
|
display: string;
|
|
26
27
|
} | undefined;
|
|
27
28
|
fontSize: string;
|
|
28
|
-
fontWeight: number;
|
|
29
|
+
fontWeight: number | undefined;
|
|
29
30
|
lineHeight: string;
|
|
30
31
|
};
|
|
@@ -39,7 +39,7 @@ function DefaultTextPropsProvider(_ref) {
|
|
|
39
39
|
});
|
|
40
40
|
}
|
|
41
41
|
var useDefaultTextProps = function useDefaultTextProps(_ref2) {
|
|
42
|
-
var _ref3, _ref4
|
|
42
|
+
var _ref3, _ref4;
|
|
43
43
|
var sizeProp = _ref2.size,
|
|
44
44
|
toneProp = _ref2.tone,
|
|
45
45
|
weightProp = _ref2.weight;
|
|
@@ -50,7 +50,7 @@ var useDefaultTextProps = function useDefaultTextProps(_ref2) {
|
|
|
50
50
|
return {
|
|
51
51
|
size: (_ref3 = sizeProp !== null && sizeProp !== void 0 ? sizeProp : size) !== null && _ref3 !== void 0 ? _ref3 : 'standard',
|
|
52
52
|
tone: (_ref4 = toneProp !== null && toneProp !== void 0 ? toneProp : tone) !== null && _ref4 !== void 0 ? _ref4 : 'neutral',
|
|
53
|
-
weight:
|
|
53
|
+
weight: weightProp !== null && weightProp !== void 0 ? weightProp : weight
|
|
54
54
|
};
|
|
55
55
|
};
|
|
56
56
|
|
|
@@ -127,17 +127,19 @@ function useText(_ref) {
|
|
|
127
127
|
tablet = _theme$typography$tex.tablet;
|
|
128
128
|
var responsiveStyles = theme$1.utils.responsiveStyles({
|
|
129
129
|
mobile: createTextStyles(mobile, {
|
|
130
|
-
includeTrims: baseline
|
|
130
|
+
includeTrims: baseline,
|
|
131
|
+
includeWeight: !weight
|
|
131
132
|
}),
|
|
132
133
|
tablet: createTextStyles(tablet, {
|
|
133
|
-
includeTrims: baseline
|
|
134
|
+
includeTrims: baseline,
|
|
135
|
+
includeWeight: !weight
|
|
134
136
|
})
|
|
135
137
|
});
|
|
136
|
-
var styles = [{
|
|
138
|
+
var styles = [responsiveStyles, {
|
|
137
139
|
color: color,
|
|
138
140
|
fontFamily: theme$1.typography.fontFamily.sans.name,
|
|
139
|
-
fontWeight: theme$1.typography.fontWeight[weight]
|
|
140
|
-
}
|
|
141
|
+
fontWeight: weight ? theme$1.typography.fontWeight[weight] : undefined
|
|
142
|
+
}];
|
|
141
143
|
return styles;
|
|
142
144
|
}
|
|
143
145
|
function createTextStyles(_ref2) {
|
|
@@ -147,7 +149,9 @@ function createTextStyles(_ref2) {
|
|
|
147
149
|
trims = _ref2.trims;
|
|
148
150
|
var _ref3 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
|
|
149
151
|
_ref3$includeTrims = _ref3.includeTrims,
|
|
150
|
-
includeTrims = _ref3$includeTrims === void 0 ? true : _ref3$includeTrims
|
|
152
|
+
includeTrims = _ref3$includeTrims === void 0 ? true : _ref3$includeTrims,
|
|
153
|
+
_ref3$includeWeight = _ref3.includeWeight,
|
|
154
|
+
includeWeight = _ref3$includeWeight === void 0 ? true : _ref3$includeWeight;
|
|
151
155
|
var pseudo = {
|
|
152
156
|
content: '" "',
|
|
153
157
|
display: 'table'
|
|
@@ -162,12 +166,12 @@ function createTextStyles(_ref2) {
|
|
|
162
166
|
} : null;
|
|
163
167
|
return _objectSpread({
|
|
164
168
|
fontSize: fontSize,
|
|
165
|
-
fontWeight: fontWeight,
|
|
169
|
+
fontWeight: includeWeight ? fontWeight : undefined,
|
|
166
170
|
lineHeight: lineHeight
|
|
167
171
|
}, leadingTrim);
|
|
168
172
|
}
|
|
169
173
|
|
|
170
|
-
var _excluded = ["as", "children", "data", "id", "align", "baseline", "inline", "overflowStrategy", "size", "tabularNumbers", "tone", "transform", "weight"];
|
|
174
|
+
var _excluded = ["as", "children", "data", "id", "align", "baseline", "css", "inline", "overflowStrategy", "size", "tabularNumbers", "tone", "transform", "weight"];
|
|
171
175
|
var Text = ts.forwardRefWithAs(function (_ref, forwardedRef) {
|
|
172
176
|
var as = _ref.as,
|
|
173
177
|
children = _ref.children,
|
|
@@ -175,6 +179,7 @@ var Text = ts.forwardRefWithAs(function (_ref, forwardedRef) {
|
|
|
175
179
|
id = _ref.id,
|
|
176
180
|
align = _ref.align,
|
|
177
181
|
baselineProp = _ref.baseline,
|
|
182
|
+
cssProps = _ref.css,
|
|
178
183
|
inline = _ref.inline,
|
|
179
184
|
overflowStrategy = _ref.overflowStrategy,
|
|
180
185
|
sizeProp = _ref.size,
|
|
@@ -214,7 +219,7 @@ var Text = ts.forwardRefWithAs(function (_ref, forwardedRef) {
|
|
|
214
219
|
data: data,
|
|
215
220
|
ref: forwardedRef,
|
|
216
221
|
id: id,
|
|
217
|
-
css: react$1.css(styles),
|
|
222
|
+
css: react$1.css(styles, cssProps),
|
|
218
223
|
children: children
|
|
219
224
|
}));
|
|
220
225
|
}
|
|
@@ -240,7 +245,7 @@ var Text = ts.forwardRefWithAs(function (_ref, forwardedRef) {
|
|
|
240
245
|
data: data,
|
|
241
246
|
ref: forwardedRef,
|
|
242
247
|
id: id,
|
|
243
|
-
css: react$1.css(styles),
|
|
248
|
+
css: react$1.css(styles, cssProps),
|
|
244
249
|
children: content
|
|
245
250
|
}))
|
|
246
251
|
});
|
|
@@ -39,7 +39,7 @@ function DefaultTextPropsProvider(_ref) {
|
|
|
39
39
|
});
|
|
40
40
|
}
|
|
41
41
|
var useDefaultTextProps = function useDefaultTextProps(_ref2) {
|
|
42
|
-
var _ref3, _ref4
|
|
42
|
+
var _ref3, _ref4;
|
|
43
43
|
var sizeProp = _ref2.size,
|
|
44
44
|
toneProp = _ref2.tone,
|
|
45
45
|
weightProp = _ref2.weight;
|
|
@@ -50,7 +50,7 @@ var useDefaultTextProps = function useDefaultTextProps(_ref2) {
|
|
|
50
50
|
return {
|
|
51
51
|
size: (_ref3 = sizeProp !== null && sizeProp !== void 0 ? sizeProp : size) !== null && _ref3 !== void 0 ? _ref3 : 'standard',
|
|
52
52
|
tone: (_ref4 = toneProp !== null && toneProp !== void 0 ? toneProp : tone) !== null && _ref4 !== void 0 ? _ref4 : 'neutral',
|
|
53
|
-
weight:
|
|
53
|
+
weight: weightProp !== null && weightProp !== void 0 ? weightProp : weight
|
|
54
54
|
};
|
|
55
55
|
};
|
|
56
56
|
|
|
@@ -127,17 +127,19 @@ function useText(_ref) {
|
|
|
127
127
|
tablet = _theme$typography$tex.tablet;
|
|
128
128
|
var responsiveStyles = theme$1.utils.responsiveStyles({
|
|
129
129
|
mobile: createTextStyles(mobile, {
|
|
130
|
-
includeTrims: baseline
|
|
130
|
+
includeTrims: baseline,
|
|
131
|
+
includeWeight: !weight
|
|
131
132
|
}),
|
|
132
133
|
tablet: createTextStyles(tablet, {
|
|
133
|
-
includeTrims: baseline
|
|
134
|
+
includeTrims: baseline,
|
|
135
|
+
includeWeight: !weight
|
|
134
136
|
})
|
|
135
137
|
});
|
|
136
|
-
var styles = [{
|
|
138
|
+
var styles = [responsiveStyles, {
|
|
137
139
|
color: color,
|
|
138
140
|
fontFamily: theme$1.typography.fontFamily.sans.name,
|
|
139
|
-
fontWeight: theme$1.typography.fontWeight[weight]
|
|
140
|
-
}
|
|
141
|
+
fontWeight: weight ? theme$1.typography.fontWeight[weight] : undefined
|
|
142
|
+
}];
|
|
141
143
|
return styles;
|
|
142
144
|
}
|
|
143
145
|
function createTextStyles(_ref2) {
|
|
@@ -147,7 +149,9 @@ function createTextStyles(_ref2) {
|
|
|
147
149
|
trims = _ref2.trims;
|
|
148
150
|
var _ref3 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
|
|
149
151
|
_ref3$includeTrims = _ref3.includeTrims,
|
|
150
|
-
includeTrims = _ref3$includeTrims === void 0 ? true : _ref3$includeTrims
|
|
152
|
+
includeTrims = _ref3$includeTrims === void 0 ? true : _ref3$includeTrims,
|
|
153
|
+
_ref3$includeWeight = _ref3.includeWeight,
|
|
154
|
+
includeWeight = _ref3$includeWeight === void 0 ? true : _ref3$includeWeight;
|
|
151
155
|
var pseudo = {
|
|
152
156
|
content: '" "',
|
|
153
157
|
display: 'table'
|
|
@@ -162,12 +166,12 @@ function createTextStyles(_ref2) {
|
|
|
162
166
|
} : null;
|
|
163
167
|
return _objectSpread({
|
|
164
168
|
fontSize: fontSize,
|
|
165
|
-
fontWeight: fontWeight,
|
|
169
|
+
fontWeight: includeWeight ? fontWeight : undefined,
|
|
166
170
|
lineHeight: lineHeight
|
|
167
171
|
}, leadingTrim);
|
|
168
172
|
}
|
|
169
173
|
|
|
170
|
-
var _excluded = ["as", "children", "data", "id", "align", "baseline", "inline", "overflowStrategy", "size", "tabularNumbers", "tone", "transform", "weight"];
|
|
174
|
+
var _excluded = ["as", "children", "data", "id", "align", "baseline", "css", "inline", "overflowStrategy", "size", "tabularNumbers", "tone", "transform", "weight"];
|
|
171
175
|
var Text = ts.forwardRefWithAs(function (_ref, forwardedRef) {
|
|
172
176
|
var as = _ref.as,
|
|
173
177
|
children = _ref.children,
|
|
@@ -175,6 +179,7 @@ var Text = ts.forwardRefWithAs(function (_ref, forwardedRef) {
|
|
|
175
179
|
id = _ref.id,
|
|
176
180
|
align = _ref.align,
|
|
177
181
|
baselineProp = _ref.baseline,
|
|
182
|
+
cssProps = _ref.css,
|
|
178
183
|
inline = _ref.inline,
|
|
179
184
|
overflowStrategy = _ref.overflowStrategy,
|
|
180
185
|
sizeProp = _ref.size,
|
|
@@ -214,7 +219,7 @@ var Text = ts.forwardRefWithAs(function (_ref, forwardedRef) {
|
|
|
214
219
|
data: data,
|
|
215
220
|
ref: forwardedRef,
|
|
216
221
|
id: id,
|
|
217
|
-
css: react$1.css(styles),
|
|
222
|
+
css: react$1.css(styles, cssProps),
|
|
218
223
|
children: children
|
|
219
224
|
}));
|
|
220
225
|
}
|
|
@@ -240,7 +245,7 @@ var Text = ts.forwardRefWithAs(function (_ref, forwardedRef) {
|
|
|
240
245
|
data: data,
|
|
241
246
|
ref: forwardedRef,
|
|
242
247
|
id: id,
|
|
243
|
-
css: react$1.css(styles),
|
|
248
|
+
css: react$1.css(styles, cssProps),
|
|
244
249
|
children: content
|
|
245
250
|
}))
|
|
246
251
|
});
|
|
@@ -35,7 +35,7 @@ function DefaultTextPropsProvider(_ref) {
|
|
|
35
35
|
});
|
|
36
36
|
}
|
|
37
37
|
var useDefaultTextProps = function useDefaultTextProps(_ref2) {
|
|
38
|
-
var _ref3, _ref4
|
|
38
|
+
var _ref3, _ref4;
|
|
39
39
|
var sizeProp = _ref2.size,
|
|
40
40
|
toneProp = _ref2.tone,
|
|
41
41
|
weightProp = _ref2.weight;
|
|
@@ -46,7 +46,7 @@ var useDefaultTextProps = function useDefaultTextProps(_ref2) {
|
|
|
46
46
|
return {
|
|
47
47
|
size: (_ref3 = sizeProp !== null && sizeProp !== void 0 ? sizeProp : size) !== null && _ref3 !== void 0 ? _ref3 : 'standard',
|
|
48
48
|
tone: (_ref4 = toneProp !== null && toneProp !== void 0 ? toneProp : tone) !== null && _ref4 !== void 0 ? _ref4 : 'neutral',
|
|
49
|
-
weight:
|
|
49
|
+
weight: weightProp !== null && weightProp !== void 0 ? weightProp : weight
|
|
50
50
|
};
|
|
51
51
|
};
|
|
52
52
|
|
|
@@ -123,17 +123,19 @@ function useText(_ref) {
|
|
|
123
123
|
tablet = _theme$typography$tex.tablet;
|
|
124
124
|
var responsiveStyles = theme.utils.responsiveStyles({
|
|
125
125
|
mobile: createTextStyles(mobile, {
|
|
126
|
-
includeTrims: baseline
|
|
126
|
+
includeTrims: baseline,
|
|
127
|
+
includeWeight: !weight
|
|
127
128
|
}),
|
|
128
129
|
tablet: createTextStyles(tablet, {
|
|
129
|
-
includeTrims: baseline
|
|
130
|
+
includeTrims: baseline,
|
|
131
|
+
includeWeight: !weight
|
|
130
132
|
})
|
|
131
133
|
});
|
|
132
|
-
var styles = [{
|
|
134
|
+
var styles = [responsiveStyles, {
|
|
133
135
|
color: color,
|
|
134
136
|
fontFamily: theme.typography.fontFamily.sans.name,
|
|
135
|
-
fontWeight: theme.typography.fontWeight[weight]
|
|
136
|
-
}
|
|
137
|
+
fontWeight: weight ? theme.typography.fontWeight[weight] : undefined
|
|
138
|
+
}];
|
|
137
139
|
return styles;
|
|
138
140
|
}
|
|
139
141
|
function createTextStyles(_ref2) {
|
|
@@ -143,7 +145,9 @@ function createTextStyles(_ref2) {
|
|
|
143
145
|
trims = _ref2.trims;
|
|
144
146
|
var _ref3 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
|
|
145
147
|
_ref3$includeTrims = _ref3.includeTrims,
|
|
146
|
-
includeTrims = _ref3$includeTrims === void 0 ? true : _ref3$includeTrims
|
|
148
|
+
includeTrims = _ref3$includeTrims === void 0 ? true : _ref3$includeTrims,
|
|
149
|
+
_ref3$includeWeight = _ref3.includeWeight,
|
|
150
|
+
includeWeight = _ref3$includeWeight === void 0 ? true : _ref3$includeWeight;
|
|
147
151
|
var pseudo = {
|
|
148
152
|
content: '" "',
|
|
149
153
|
display: 'table'
|
|
@@ -158,12 +162,12 @@ function createTextStyles(_ref2) {
|
|
|
158
162
|
} : null;
|
|
159
163
|
return _objectSpread({
|
|
160
164
|
fontSize: fontSize,
|
|
161
|
-
fontWeight: fontWeight,
|
|
165
|
+
fontWeight: includeWeight ? fontWeight : undefined,
|
|
162
166
|
lineHeight: lineHeight
|
|
163
167
|
}, leadingTrim);
|
|
164
168
|
}
|
|
165
169
|
|
|
166
|
-
var _excluded = ["as", "children", "data", "id", "align", "baseline", "inline", "overflowStrategy", "size", "tabularNumbers", "tone", "transform", "weight"];
|
|
170
|
+
var _excluded = ["as", "children", "data", "id", "align", "baseline", "css", "inline", "overflowStrategy", "size", "tabularNumbers", "tone", "transform", "weight"];
|
|
167
171
|
var Text = forwardRefWithAs(function (_ref, forwardedRef) {
|
|
168
172
|
var as = _ref.as,
|
|
169
173
|
children = _ref.children,
|
|
@@ -171,6 +175,7 @@ var Text = forwardRefWithAs(function (_ref, forwardedRef) {
|
|
|
171
175
|
id = _ref.id,
|
|
172
176
|
align = _ref.align,
|
|
173
177
|
baselineProp = _ref.baseline,
|
|
178
|
+
cssProps = _ref.css,
|
|
174
179
|
inline = _ref.inline,
|
|
175
180
|
overflowStrategy = _ref.overflowStrategy,
|
|
176
181
|
sizeProp = _ref.size,
|
|
@@ -210,7 +215,7 @@ var Text = forwardRefWithAs(function (_ref, forwardedRef) {
|
|
|
210
215
|
data: data,
|
|
211
216
|
ref: forwardedRef,
|
|
212
217
|
id: id,
|
|
213
|
-
css: css(styles),
|
|
218
|
+
css: css(styles, cssProps),
|
|
214
219
|
children: children
|
|
215
220
|
}));
|
|
216
221
|
}
|
|
@@ -236,7 +241,7 @@ var Text = forwardRefWithAs(function (_ref, forwardedRef) {
|
|
|
236
241
|
data: data,
|
|
237
242
|
ref: forwardedRef,
|
|
238
243
|
id: id,
|
|
239
|
-
css: css(styles),
|
|
244
|
+
css: css(styles, cssProps),
|
|
240
245
|
children: content
|
|
241
246
|
}))
|
|
242
247
|
});
|