@spark-web/text 1.0.5 → 1.1.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 +3 -0
- package/dist/declarations/src/Text.d.ts +1 -1
- package/dist/declarations/src/context.d.ts +4 -4
- package/dist/declarations/src/defaultTextProps.d.ts +2 -2
- package/dist/spark-web-text.cjs.dev.js +10 -6
- package/dist/spark-web-text.cjs.prod.js +10 -6
- package/dist/spark-web-text.esm.js +10 -6
- package/package.json +5 -5
package/README.md
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
title: Text
|
|
3
3
|
storybookPath: typography-text--default
|
|
4
|
+
isExperimentalPackage: false
|
|
4
5
|
---
|
|
5
6
|
|
|
6
7
|
Constrained, purposeful text styles as a component.
|
|
@@ -150,6 +151,8 @@ tones “neutral” and “muted” will be inverted.
|
|
|
150
151
|
| transform? | CSSProperties['textTransform'] | | Transforms the text casing. |
|
|
151
152
|
| weight? | keyof [BrighteTheme][brighte-theme]['typography']['fontweight'] | | The weight of the text. |
|
|
152
153
|
|
|
154
|
+
Extra props are also passed into the underlying [`Box`](/package/box) component.
|
|
155
|
+
|
|
153
156
|
[brighte-theme]:
|
|
154
157
|
https://github.com/brighte-labs/spark-web/blob/e503bea4f7668d187ec7a78f99c5ed374417588b/packages/theme/src/makeTheme.ts#L158
|
|
155
158
|
[data-attribute-map]:
|
|
@@ -30,6 +30,6 @@ export declare type TextProps = Partial<UseTextProps> & {
|
|
|
30
30
|
} & (InlineProps | BlockProps);
|
|
31
31
|
export declare const Text: <Comp extends import("react").ElementType<any> = "div">(props: {
|
|
32
32
|
as?: Comp | undefined;
|
|
33
|
-
ref?: import("react").Ref<Comp extends "symbol" | "
|
|
33
|
+
ref?: import("react").Ref<Comp extends "symbol" | "svg" | "animate" | "animateMotion" | "animateTransform" | "circle" | "clipPath" | "defs" | "desc" | "ellipse" | "feBlend" | "feColorMatrix" | "feComponentTransfer" | "feComposite" | "feConvolveMatrix" | "feDiffuseLighting" | "feDisplacementMap" | "feDistantLight" | "feDropShadow" | "feFlood" | "feFuncA" | "feFuncB" | "feFuncG" | "feFuncR" | "feGaussianBlur" | "feImage" | "feMerge" | "feMergeNode" | "feMorphology" | "feOffset" | "fePointLight" | "feSpecularLighting" | "feSpotLight" | "feTile" | "feTurbulence" | "filter" | "foreignObject" | "g" | "image" | "line" | "linearGradient" | "marker" | "mask" | "metadata" | "mpath" | "path" | "pattern" | "polygon" | "polyline" | "radialGradient" | "rect" | "stop" | "switch" | "text" | "textPath" | "tspan" | "use" | "view" | "set" | keyof HTMLElementTagNameMap ? (HTMLElementTagNameMap & Pick<SVGElementTagNameMap, "symbol" | "svg" | "animate" | "animateMotion" | "animateTransform" | "circle" | "clipPath" | "defs" | "desc" | "ellipse" | "feBlend" | "feColorMatrix" | "feComponentTransfer" | "feComposite" | "feConvolveMatrix" | "feDiffuseLighting" | "feDisplacementMap" | "feDistantLight" | "feDropShadow" | "feFlood" | "feFuncA" | "feFuncB" | "feFuncG" | "feFuncR" | "feGaussianBlur" | "feImage" | "feMerge" | "feMergeNode" | "feMorphology" | "feOffset" | "fePointLight" | "feSpecularLighting" | "feSpotLight" | "feTile" | "feTurbulence" | "filter" | "foreignObject" | "g" | "image" | "line" | "linearGradient" | "marker" | "mask" | "metadata" | "mpath" | "path" | "pattern" | "polygon" | "polyline" | "radialGradient" | "rect" | "stop" | "switch" | "text" | "textPath" | "tspan" | "use" | "view" | "set">)[Comp] : Comp extends new (...args: any) => any ? InstanceType<Comp> : undefined> | undefined;
|
|
34
34
|
} & Omit<import("react").PropsWithoutRef<import("react").ComponentProps<Comp>>, "as"> & TextProps) => import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>>;
|
|
35
35
|
export {};
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
export declare const TextContext: import("react").Context<{
|
|
3
|
-
size: "
|
|
4
|
-
tone: "
|
|
3
|
+
size: "small" | "xsmall" | "standard" | "large";
|
|
4
|
+
tone: "link" | "muted" | "disabled" | "fieldAccent" | "accent" | "neutral" | "primary" | "secondary" | "caution" | "critical" | "info" | "positive" | "placeholder" | "primaryHover" | "primaryActive" | "secondaryHover" | "secondaryActive";
|
|
5
5
|
weight: "regular" | "semibold";
|
|
6
6
|
} | undefined>;
|
|
7
7
|
export declare function useTextContext(): {
|
|
8
|
-
size: "
|
|
9
|
-
tone: "
|
|
8
|
+
size: "small" | "xsmall" | "standard" | "large";
|
|
9
|
+
tone: "link" | "muted" | "disabled" | "fieldAccent" | "accent" | "neutral" | "primary" | "secondary" | "caution" | "critical" | "info" | "positive" | "placeholder" | "primaryHover" | "primaryActive" | "secondaryHover" | "secondaryActive";
|
|
10
10
|
weight: "regular" | "semibold";
|
|
11
11
|
} | undefined;
|
|
@@ -9,8 +9,8 @@ export declare function DefaultTextPropsProvider({ children, size, tone, weight,
|
|
|
9
9
|
children: ReactNode;
|
|
10
10
|
}): JSX.Element;
|
|
11
11
|
export declare const useDefaultTextProps: ({ size: sizeProp, tone: toneProp, weight: weightProp, }: DefaultTextProps) => {
|
|
12
|
-
size: "
|
|
13
|
-
tone: "
|
|
12
|
+
size: "small" | "xsmall" | "standard" | "large";
|
|
13
|
+
tone: "link" | "muted" | "disabled" | "fieldAccent" | "accent" | "neutral" | "primary" | "secondary" | "caution" | "critical" | "info" | "positive" | "placeholder" | "primaryHover" | "primaryActive" | "secondaryHover" | "secondaryActive";
|
|
14
14
|
weight: "regular" | "semibold";
|
|
15
15
|
};
|
|
16
16
|
export {};
|
|
@@ -6,9 +6,10 @@ var react = require('react');
|
|
|
6
6
|
var jsxRuntime = require('react/jsx-runtime');
|
|
7
7
|
var css = require('@emotion/css');
|
|
8
8
|
var theme = require('@spark-web/theme');
|
|
9
|
+
var _objectSpread = require('@babel/runtime/helpers/objectSpread2');
|
|
10
|
+
var _objectWithoutProperties = require('@babel/runtime/helpers/objectWithoutProperties');
|
|
9
11
|
var box = require('@spark-web/box');
|
|
10
12
|
var ts = require('@spark-web/utils/ts');
|
|
11
|
-
var _objectSpread = require('@babel/runtime/helpers/objectSpread2');
|
|
12
13
|
|
|
13
14
|
var TextContext = /*#__PURE__*/react.createContext(undefined);
|
|
14
15
|
function useTextContext() {
|
|
@@ -179,6 +180,7 @@ function createTextStyles(_ref2) {
|
|
|
179
180
|
}, leadingTrim);
|
|
180
181
|
}
|
|
181
182
|
|
|
183
|
+
var _excluded = ["as", "children", "data", "id", "align", "baseline", "inline", "overflowStrategy", "size", "tabularNumbers", "tone", "transform", "weight"];
|
|
182
184
|
var Text = ts.forwardRefWithAs(function (_ref, forwardedRef) {
|
|
183
185
|
var as = _ref.as,
|
|
184
186
|
children = _ref.children,
|
|
@@ -192,7 +194,9 @@ var Text = ts.forwardRefWithAs(function (_ref, forwardedRef) {
|
|
|
192
194
|
tabularNumbers = _ref.tabularNumbers,
|
|
193
195
|
toneProp = _ref.tone,
|
|
194
196
|
transform = _ref.transform,
|
|
195
|
-
weightProp = _ref.weight
|
|
197
|
+
weightProp = _ref.weight,
|
|
198
|
+
consumerProps = _objectWithoutProperties(_ref, _excluded);
|
|
199
|
+
|
|
196
200
|
var overflowStyles = useOverflowStrategy(overflowStrategy);
|
|
197
201
|
var textContext = useTextContext();
|
|
198
202
|
|
|
@@ -220,14 +224,14 @@ var Text = ts.forwardRefWithAs(function (_ref, forwardedRef) {
|
|
|
220
224
|
}]; // early exit for inline variant
|
|
221
225
|
|
|
222
226
|
if (inline) {
|
|
223
|
-
return /*#__PURE__*/jsxRuntime.jsx(box.Box, {
|
|
227
|
+
return /*#__PURE__*/jsxRuntime.jsx(box.Box, _objectSpread(_objectSpread({}, consumerProps), {}, {
|
|
224
228
|
as: as !== null && as !== void 0 ? as : 'span',
|
|
225
229
|
data: data,
|
|
226
230
|
ref: forwardedRef,
|
|
227
231
|
id: id,
|
|
228
232
|
className: css.css(styles),
|
|
229
233
|
children: children
|
|
230
|
-
});
|
|
234
|
+
}));
|
|
231
235
|
} // prepare block variant
|
|
232
236
|
|
|
233
237
|
|
|
@@ -244,14 +248,14 @@ var Text = ts.forwardRefWithAs(function (_ref, forwardedRef) {
|
|
|
244
248
|
}, [size, tone, weight]);
|
|
245
249
|
return /*#__PURE__*/jsxRuntime.jsx(TextContext.Provider, {
|
|
246
250
|
value: textContextValue,
|
|
247
|
-
children: /*#__PURE__*/jsxRuntime.jsx(box.Box, {
|
|
251
|
+
children: /*#__PURE__*/jsxRuntime.jsx(box.Box, _objectSpread(_objectSpread({}, consumerProps), {}, {
|
|
248
252
|
as: as,
|
|
249
253
|
data: data,
|
|
250
254
|
ref: forwardedRef,
|
|
251
255
|
id: id,
|
|
252
256
|
className: css.css(styles),
|
|
253
257
|
children: content
|
|
254
|
-
})
|
|
258
|
+
}))
|
|
255
259
|
});
|
|
256
260
|
});
|
|
257
261
|
|
|
@@ -6,9 +6,10 @@ var react = require('react');
|
|
|
6
6
|
var jsxRuntime = require('react/jsx-runtime');
|
|
7
7
|
var css = require('@emotion/css');
|
|
8
8
|
var theme = require('@spark-web/theme');
|
|
9
|
+
var _objectSpread = require('@babel/runtime/helpers/objectSpread2');
|
|
10
|
+
var _objectWithoutProperties = require('@babel/runtime/helpers/objectWithoutProperties');
|
|
9
11
|
var box = require('@spark-web/box');
|
|
10
12
|
var ts = require('@spark-web/utils/ts');
|
|
11
|
-
var _objectSpread = require('@babel/runtime/helpers/objectSpread2');
|
|
12
13
|
|
|
13
14
|
var TextContext = /*#__PURE__*/react.createContext(undefined);
|
|
14
15
|
function useTextContext() {
|
|
@@ -179,6 +180,7 @@ function createTextStyles(_ref2) {
|
|
|
179
180
|
}, leadingTrim);
|
|
180
181
|
}
|
|
181
182
|
|
|
183
|
+
var _excluded = ["as", "children", "data", "id", "align", "baseline", "inline", "overflowStrategy", "size", "tabularNumbers", "tone", "transform", "weight"];
|
|
182
184
|
var Text = ts.forwardRefWithAs(function (_ref, forwardedRef) {
|
|
183
185
|
var as = _ref.as,
|
|
184
186
|
children = _ref.children,
|
|
@@ -192,7 +194,9 @@ var Text = ts.forwardRefWithAs(function (_ref, forwardedRef) {
|
|
|
192
194
|
tabularNumbers = _ref.tabularNumbers,
|
|
193
195
|
toneProp = _ref.tone,
|
|
194
196
|
transform = _ref.transform,
|
|
195
|
-
weightProp = _ref.weight
|
|
197
|
+
weightProp = _ref.weight,
|
|
198
|
+
consumerProps = _objectWithoutProperties(_ref, _excluded);
|
|
199
|
+
|
|
196
200
|
var overflowStyles = useOverflowStrategy(overflowStrategy);
|
|
197
201
|
var textContext = useTextContext();
|
|
198
202
|
|
|
@@ -220,14 +224,14 @@ var Text = ts.forwardRefWithAs(function (_ref, forwardedRef) {
|
|
|
220
224
|
}]; // early exit for inline variant
|
|
221
225
|
|
|
222
226
|
if (inline) {
|
|
223
|
-
return /*#__PURE__*/jsxRuntime.jsx(box.Box, {
|
|
227
|
+
return /*#__PURE__*/jsxRuntime.jsx(box.Box, _objectSpread(_objectSpread({}, consumerProps), {}, {
|
|
224
228
|
as: as !== null && as !== void 0 ? as : 'span',
|
|
225
229
|
data: data,
|
|
226
230
|
ref: forwardedRef,
|
|
227
231
|
id: id,
|
|
228
232
|
className: css.css(styles),
|
|
229
233
|
children: children
|
|
230
|
-
});
|
|
234
|
+
}));
|
|
231
235
|
} // prepare block variant
|
|
232
236
|
|
|
233
237
|
|
|
@@ -244,14 +248,14 @@ var Text = ts.forwardRefWithAs(function (_ref, forwardedRef) {
|
|
|
244
248
|
}, [size, tone, weight]);
|
|
245
249
|
return /*#__PURE__*/jsxRuntime.jsx(TextContext.Provider, {
|
|
246
250
|
value: textContextValue,
|
|
247
|
-
children: /*#__PURE__*/jsxRuntime.jsx(box.Box, {
|
|
251
|
+
children: /*#__PURE__*/jsxRuntime.jsx(box.Box, _objectSpread(_objectSpread({}, consumerProps), {}, {
|
|
248
252
|
as: as,
|
|
249
253
|
data: data,
|
|
250
254
|
ref: forwardedRef,
|
|
251
255
|
id: id,
|
|
252
256
|
className: css.css(styles),
|
|
253
257
|
children: content
|
|
254
|
-
})
|
|
258
|
+
}))
|
|
255
259
|
});
|
|
256
260
|
});
|
|
257
261
|
|
|
@@ -2,9 +2,10 @@ import { useContext, createContext, useMemo } from 'react';
|
|
|
2
2
|
import { jsx } from 'react/jsx-runtime';
|
|
3
3
|
import { css } from '@emotion/css';
|
|
4
4
|
import { useTheme } from '@spark-web/theme';
|
|
5
|
+
import _objectSpread from '@babel/runtime/helpers/esm/objectSpread2';
|
|
6
|
+
import _objectWithoutProperties from '@babel/runtime/helpers/esm/objectWithoutProperties';
|
|
5
7
|
import { useBackgroundLightness, Box } from '@spark-web/box';
|
|
6
8
|
import { forwardRefWithAs } from '@spark-web/utils/ts';
|
|
7
|
-
import _objectSpread from '@babel/runtime/helpers/esm/objectSpread2';
|
|
8
9
|
|
|
9
10
|
var TextContext = /*#__PURE__*/createContext(undefined);
|
|
10
11
|
function useTextContext() {
|
|
@@ -175,6 +176,7 @@ function createTextStyles(_ref2) {
|
|
|
175
176
|
}, leadingTrim);
|
|
176
177
|
}
|
|
177
178
|
|
|
179
|
+
var _excluded = ["as", "children", "data", "id", "align", "baseline", "inline", "overflowStrategy", "size", "tabularNumbers", "tone", "transform", "weight"];
|
|
178
180
|
var Text = forwardRefWithAs(function (_ref, forwardedRef) {
|
|
179
181
|
var as = _ref.as,
|
|
180
182
|
children = _ref.children,
|
|
@@ -188,7 +190,9 @@ var Text = forwardRefWithAs(function (_ref, forwardedRef) {
|
|
|
188
190
|
tabularNumbers = _ref.tabularNumbers,
|
|
189
191
|
toneProp = _ref.tone,
|
|
190
192
|
transform = _ref.transform,
|
|
191
|
-
weightProp = _ref.weight
|
|
193
|
+
weightProp = _ref.weight,
|
|
194
|
+
consumerProps = _objectWithoutProperties(_ref, _excluded);
|
|
195
|
+
|
|
192
196
|
var overflowStyles = useOverflowStrategy(overflowStrategy);
|
|
193
197
|
var textContext = useTextContext();
|
|
194
198
|
|
|
@@ -216,14 +220,14 @@ var Text = forwardRefWithAs(function (_ref, forwardedRef) {
|
|
|
216
220
|
}]; // early exit for inline variant
|
|
217
221
|
|
|
218
222
|
if (inline) {
|
|
219
|
-
return /*#__PURE__*/jsx(Box, {
|
|
223
|
+
return /*#__PURE__*/jsx(Box, _objectSpread(_objectSpread({}, consumerProps), {}, {
|
|
220
224
|
as: as !== null && as !== void 0 ? as : 'span',
|
|
221
225
|
data: data,
|
|
222
226
|
ref: forwardedRef,
|
|
223
227
|
id: id,
|
|
224
228
|
className: css(styles),
|
|
225
229
|
children: children
|
|
226
|
-
});
|
|
230
|
+
}));
|
|
227
231
|
} // prepare block variant
|
|
228
232
|
|
|
229
233
|
|
|
@@ -240,14 +244,14 @@ var Text = forwardRefWithAs(function (_ref, forwardedRef) {
|
|
|
240
244
|
}, [size, tone, weight]);
|
|
241
245
|
return /*#__PURE__*/jsx(TextContext.Provider, {
|
|
242
246
|
value: textContextValue,
|
|
243
|
-
children: /*#__PURE__*/jsx(Box, {
|
|
247
|
+
children: /*#__PURE__*/jsx(Box, _objectSpread(_objectSpread({}, consumerProps), {}, {
|
|
244
248
|
as: as,
|
|
245
249
|
data: data,
|
|
246
250
|
ref: forwardedRef,
|
|
247
251
|
id: id,
|
|
248
252
|
className: css(styles),
|
|
249
253
|
children: content
|
|
250
|
-
})
|
|
254
|
+
}))
|
|
251
255
|
});
|
|
252
256
|
});
|
|
253
257
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@spark-web/text",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"main": "dist/spark-web-text.cjs.js",
|
|
6
6
|
"module": "dist/spark-web-text.esm.js",
|
|
@@ -8,11 +8,11 @@
|
|
|
8
8
|
"dist"
|
|
9
9
|
],
|
|
10
10
|
"dependencies": {
|
|
11
|
-
"@babel/runtime": "^7.18.
|
|
11
|
+
"@babel/runtime": "^7.18.9",
|
|
12
12
|
"@emotion/css": "^11.9.0",
|
|
13
|
-
"@spark-web/box": "^1.0.
|
|
14
|
-
"@spark-web/theme": "^3.0.
|
|
15
|
-
"@spark-web/utils": "^1.1
|
|
13
|
+
"@spark-web/box": "^1.0.8",
|
|
14
|
+
"@spark-web/theme": "^3.0.5",
|
|
15
|
+
"@spark-web/utils": "^1.2.1"
|
|
16
16
|
},
|
|
17
17
|
"devDependencies": {
|
|
18
18
|
"@types/react": "^17.0.12",
|