@flodesk/grain 10.11.0 → 10.12.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/es/components/index.js
CHANGED
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import "core-js/modules/es.object.keys.js";
|
|
2
|
+
import "core-js/modules/es.array.index-of.js";
|
|
3
|
+
import "core-js/modules/es.symbol.js";
|
|
4
|
+
import "core-js/modules/es.object.define-property.js";
|
|
5
|
+
import "core-js/modules/es.array.filter.js";
|
|
6
|
+
import "core-js/modules/es.object.to-string.js";
|
|
7
|
+
import "core-js/modules/es.object.get-own-property-descriptor.js";
|
|
8
|
+
import "core-js/modules/web.dom-collections.for-each.js";
|
|
9
|
+
import "core-js/modules/es.object.get-own-property-descriptors.js";
|
|
10
|
+
import "core-js/modules/es.object.define-properties.js";
|
|
11
|
+
import "core-js/modules/es.object.assign.js";
|
|
12
|
+
var _excluded = ["children", "size", "weight", "color", "tag", "display", "hasEllipsis", "ellipsisLines", "align", "letterSpacing", "textTransform", "variant", "trimTop", "className"];
|
|
13
|
+
|
|
14
|
+
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
15
|
+
|
|
16
|
+
import "core-js/modules/es.string.trim.js";
|
|
17
|
+
import "core-js/modules/es.regexp.exec.js";
|
|
18
|
+
import "core-js/modules/es.string.replace.js";
|
|
19
|
+
|
|
20
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
21
|
+
|
|
22
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
23
|
+
|
|
24
|
+
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
25
|
+
|
|
26
|
+
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; }
|
|
27
|
+
|
|
28
|
+
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; }
|
|
29
|
+
|
|
30
|
+
import { generateStyleAttributes, generateClassNameAttributes } from '../../utilities';
|
|
31
|
+
import PropTypes from 'prop-types';
|
|
32
|
+
import React, { forwardRef } from 'react';
|
|
33
|
+
import { types } from '../../types';
|
|
34
|
+
import styles from './styles.module.css';
|
|
35
|
+
import { jsx as ___EmotionJSX } from "@emotion/react";
|
|
36
|
+
export var Text2 = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
37
|
+
var children = _ref.children,
|
|
38
|
+
_ref$size = _ref.size,
|
|
39
|
+
size = _ref$size === void 0 ? 'm' : _ref$size,
|
|
40
|
+
weight = _ref.weight,
|
|
41
|
+
color = _ref.color,
|
|
42
|
+
_ref$tag = _ref.tag,
|
|
43
|
+
tag = _ref$tag === void 0 ? 'span' : _ref$tag,
|
|
44
|
+
_ref$display = _ref.display,
|
|
45
|
+
display = _ref$display === void 0 ? 'block' : _ref$display,
|
|
46
|
+
hasEllipsis = _ref.hasEllipsis,
|
|
47
|
+
ellipsisLines = _ref.ellipsisLines,
|
|
48
|
+
align = _ref.align,
|
|
49
|
+
letterSpacing = _ref.letterSpacing,
|
|
50
|
+
textTransform = _ref.textTransform,
|
|
51
|
+
variant = _ref.variant,
|
|
52
|
+
trimTop = _ref.trimTop,
|
|
53
|
+
className = _ref.className,
|
|
54
|
+
props = _objectWithoutProperties(_ref, _excluded);
|
|
55
|
+
|
|
56
|
+
var Tag = tag;
|
|
57
|
+
|
|
58
|
+
if (variant === 'caps') {
|
|
59
|
+
size = 's';
|
|
60
|
+
weight = 'medium';
|
|
61
|
+
textTransform = 'uppercase';
|
|
62
|
+
letterSpacing = '0.05em';
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
var genStyles = _objectSpread(_objectSpread({}, generateStyleAttributes({
|
|
66
|
+
size: size,
|
|
67
|
+
align: align,
|
|
68
|
+
color: color,
|
|
69
|
+
letterSpacing: letterSpacing
|
|
70
|
+
})), ellipsisLines && _defineProperty({}, '--el', ellipsisLines));
|
|
71
|
+
|
|
72
|
+
var propClassName = className ? className : '';
|
|
73
|
+
var classNames = [generateClassNameAttributes({
|
|
74
|
+
size: size,
|
|
75
|
+
align: align,
|
|
76
|
+
color: color,
|
|
77
|
+
weight: weight,
|
|
78
|
+
display: !ellipsisLines ? display : undefined,
|
|
79
|
+
textTransform: textTransform
|
|
80
|
+
}), propClassName, trimTop && styles.trimTop, hasEllipsis && !ellipsisLines ? styles.ellipsis : undefined, hasEllipsis && ellipsisLines ? styles.ellipsisMulti : undefined].join(' ').replace(/\s+/g, ' ').trim();
|
|
81
|
+
return ___EmotionJSX(Tag, _extends({
|
|
82
|
+
ref: ref,
|
|
83
|
+
className: classNames,
|
|
84
|
+
style: genStyles
|
|
85
|
+
}, props), children);
|
|
86
|
+
});
|
|
87
|
+
Text2.propTypes = {
|
|
88
|
+
size: types.responsiveTextSize,
|
|
89
|
+
weight: types.weight,
|
|
90
|
+
color: types.color,
|
|
91
|
+
align: types.responsiveTextAlign,
|
|
92
|
+
tag: types.textTag,
|
|
93
|
+
hasEllipsis: PropTypes.bool,
|
|
94
|
+
ellipsisLines: PropTypes.number,
|
|
95
|
+
letterSpacing: PropTypes.string,
|
|
96
|
+
textTransform: PropTypes.oneOf(['capitalize', 'uppercase', 'lowercase']),
|
|
97
|
+
variant: PropTypes.oneOf(['caps']),
|
|
98
|
+
trimTop: PropTypes.bool,
|
|
99
|
+
display: types.textDisplay
|
|
100
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
.trimTop:before {
|
|
2
|
+
--capHeight: 0.74em;
|
|
3
|
+
--lineHeightAndCapHeightOffset: calc((var(--grn-lineHeight-global) - var(--capHeight)) / 2);
|
|
4
|
+
|
|
5
|
+
content: '';
|
|
6
|
+
margin-top: calc(-1 * var(--lineHeightAndCapHeightOffset));
|
|
7
|
+
display: block;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
.ellipsis {
|
|
11
|
+
overflow: hidden;
|
|
12
|
+
text-overflow: ellipsis;
|
|
13
|
+
white-space: nowrap;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
.ellipsisMulti {
|
|
17
|
+
overflow: hidden;
|
|
18
|
+
text-overflow: ellipsis;
|
|
19
|
+
display: -webkit-box;
|
|
20
|
+
-webkit-line-clamp: var(--el);
|
|
21
|
+
-webkit-box-orient: vertical;
|
|
22
|
+
}
|
package/es/styles/utilities.js
CHANGED
|
@@ -97,10 +97,12 @@ var spaceProps = styleConfig.spaceProps,
|
|
|
97
97
|
alignProps = styleConfig.alignProps,
|
|
98
98
|
weightProps = styleConfig.weightProps,
|
|
99
99
|
displayProps = styleConfig.displayProps,
|
|
100
|
-
zIndexProps = styleConfig.zIndexProps
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
var
|
|
100
|
+
zIndexProps = styleConfig.zIndexProps,
|
|
101
|
+
letterSpacingProps = styleConfig.letterSpacingProps,
|
|
102
|
+
textTransformProps = styleConfig.textTransformProps;
|
|
103
|
+
var classAndStyleDeclarationProps = [spaceProps, colorProps, shadowProps, radiusProps, transitionProps, sizeProps, borderColorProps, alignProps];
|
|
104
|
+
var classDeclarationProps = [].concat(classAndStyleDeclarationProps, [positionProps, overflowProps, cursorProps, sizeProps, alignSelfProps, borderWidthProps, weightProps, displayProps, borderSideProps, textTransformProps]);
|
|
105
|
+
var styleDeclarationProps = [].concat(classAndStyleDeclarationProps, [dimensionProps, aspectRatioProps, orderProps, flexProps, opacityProps, zIndexProps, letterSpacingProps]);
|
|
104
106
|
var defaultBorder = "\n [class*=\"bd\"] {\n border-color: var(--grn-color-border);\n border-width: 1px;\n }\n";
|
|
105
107
|
var utilities = "\n ".concat(defaultBorder, "\n ").concat(generateUtilityClassDeclarations(classDeclarationProps), ";\n ").concat(generateStyleClassDeclarations(styleDeclarationProps), ";\n");
|
|
106
108
|
export default utilities;
|
|
@@ -378,7 +378,8 @@ export var styleConfig = {
|
|
|
378
378
|
variables: ['left', 'center', 'right'],
|
|
379
379
|
variableChecker: function variableChecker(value) {
|
|
380
380
|
return ['left', 'center', 'right'].includes(value);
|
|
381
|
-
}
|
|
381
|
+
},
|
|
382
|
+
isResponsive: true
|
|
382
383
|
},
|
|
383
384
|
weightProps: {
|
|
384
385
|
props: [{
|
|
@@ -402,6 +403,24 @@ export var styleConfig = {
|
|
|
402
403
|
variableChecker: function variableChecker(value) {
|
|
403
404
|
return ['block', 'inline', 'inline-block'].includes(value);
|
|
404
405
|
}
|
|
406
|
+
},
|
|
407
|
+
letterSpacingProps: {
|
|
408
|
+
props: [{
|
|
409
|
+
propName: 'letterSpacing',
|
|
410
|
+
property: 'letter-spacing',
|
|
411
|
+
short: 'ls'
|
|
412
|
+
}]
|
|
413
|
+
},
|
|
414
|
+
textTransformProps: {
|
|
415
|
+
props: [{
|
|
416
|
+
propName: 'textTransform',
|
|
417
|
+
property: 'text-transform',
|
|
418
|
+
short: 'tt'
|
|
419
|
+
}],
|
|
420
|
+
variables: ['capitalize', 'uppercase', 'lowercase'],
|
|
421
|
+
variableChecker: function variableChecker(value) {
|
|
422
|
+
return ['capitalize', 'uppercase', 'lowercase'].includes(value);
|
|
423
|
+
}
|
|
405
424
|
}
|
|
406
425
|
};
|
|
407
426
|
export var propNameToShort = function propNameToShort(propName) {
|