@flodesk/grain 10.11.0 → 10.12.1
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
|
@@ -96,11 +96,13 @@ var spaceProps = styleConfig.spaceProps,
|
|
|
96
96
|
borderSideProps = styleConfig.borderSideProps,
|
|
97
97
|
alignProps = styleConfig.alignProps,
|
|
98
98
|
weightProps = styleConfig.weightProps,
|
|
99
|
-
|
|
100
|
-
zIndexProps = styleConfig.zIndexProps
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
var
|
|
99
|
+
textDisplayProps = styleConfig.textDisplayProps,
|
|
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, textDisplayProps, 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;
|
package/es/types.js
CHANGED
|
@@ -22,6 +22,9 @@ export var positions = ['static', 'relative', 'fixed', 'absolute', 'sticky'];
|
|
|
22
22
|
export var cursors = ['default', 'pointer'];
|
|
23
23
|
export var sides = ['all', 'left', 'right', 'top', 'bottom', 'x', 'y'];
|
|
24
24
|
export var borderWidths = ['1px', '2px', '3px', '4px'];
|
|
25
|
+
export var textTransforms = ['capitalize', 'uppercase', 'lowercase'];
|
|
26
|
+
export var textDisplays = ['block', 'inline-block', 'inline'];
|
|
27
|
+
export var textAlignments = ['left', 'center', 'right'];
|
|
25
28
|
export var types = {
|
|
26
29
|
color: PropTypes.oneOfType([PropTypes.oneOf(Object.keys(vars.colors)), PropTypes.string]),
|
|
27
30
|
responsiveSpace: PropTypes.oneOfType([PropTypes.oneOf(Object.keys(vars.spaces)), PropTypes.number, PropTypes.string, PropTypes.object]),
|
|
@@ -32,12 +35,12 @@ export var types = {
|
|
|
32
35
|
shadow: PropTypes.oneOfType([PropTypes.oneOf(Object.keys(vars.shadows)), PropTypes.string]),
|
|
33
36
|
position: PropTypes.oneOf(positions),
|
|
34
37
|
responsiveTextSize: PropTypes.oneOfType([PropTypes.oneOf(Object.keys(vars.texts)), PropTypes.string, PropTypes.object]),
|
|
35
|
-
responsiveTextAlign: PropTypes.oneOfType([PropTypes.oneOf(
|
|
38
|
+
responsiveTextAlign: PropTypes.oneOfType([PropTypes.oneOf(textAlignments), PropTypes.string, PropTypes.object]),
|
|
36
39
|
iconSize: PropTypes.oneOfType([PropTypes.oneOf(Object.keys(vars.icons)), PropTypes.number, PropTypes.string]),
|
|
37
40
|
weight: PropTypes.oneOf(Object.keys(vars.weights)),
|
|
38
41
|
overflow: PropTypes.oneOf(overflows),
|
|
39
42
|
textTag: PropTypes.oneOf(['h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'p', 'span', 'label']),
|
|
40
|
-
textDisplay: PropTypes.oneOf(
|
|
43
|
+
textDisplay: PropTypes.oneOf(textDisplays),
|
|
41
44
|
responsiveColumns: PropTypes.oneOfType([PropTypes.string, PropTypes.object]),
|
|
42
45
|
responsiveRows: PropTypes.oneOfType([PropTypes.string, PropTypes.object]),
|
|
43
46
|
autoFlow: PropTypes.oneOfType([PropTypes.oneOf(autoFlows), PropTypes.string, PropTypes.object]),
|
|
@@ -28,7 +28,7 @@ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToAr
|
|
|
28
28
|
|
|
29
29
|
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
30
30
|
|
|
31
|
-
import { alignSelfs, borderWidths, cursors, overflows, positions, sides } from '../types';
|
|
31
|
+
import { alignSelfs, borderWidths, cursors, overflows, positions, sides, textAlignments, textDisplays, textTransforms } from '../types';
|
|
32
32
|
import { vars } from '../variables';
|
|
33
33
|
import { getDimension, getSpace, getTextSize, isSpaceVar } from './responsive';
|
|
34
34
|
import { getColor, getRadius, getShadow, getTransition, getWeight, isColorVar, isRadiusVar, isShadowVar, isTrasitionVar } from './styles';
|
|
@@ -38,6 +38,7 @@ var shadows = Object.keys(vars.shadows);
|
|
|
38
38
|
var radii = Object.keys(vars.radii);
|
|
39
39
|
var transitions = [].concat(_toConsumableArray(Object.keys(vars.transitions)), _toConsumableArray(Object.keys(vars.transitionUtils)));
|
|
40
40
|
var sizes = Object.keys(vars.texts);
|
|
41
|
+
var weights = Object.keys(vars.weights);
|
|
41
42
|
|
|
42
43
|
var borderSideToStyle = function borderSideToStyle(side) {
|
|
43
44
|
if (side === 'all') return 'solid';
|
|
@@ -375,10 +376,11 @@ export var styleConfig = {
|
|
|
375
376
|
property: 'text-align',
|
|
376
377
|
short: 'al'
|
|
377
378
|
}],
|
|
378
|
-
variables:
|
|
379
|
+
variables: textAlignments,
|
|
379
380
|
variableChecker: function variableChecker(value) {
|
|
380
|
-
return
|
|
381
|
-
}
|
|
381
|
+
return textAlignments.includes(value);
|
|
382
|
+
},
|
|
383
|
+
isResponsive: true
|
|
382
384
|
},
|
|
383
385
|
weightProps: {
|
|
384
386
|
props: [{
|
|
@@ -386,21 +388,39 @@ export var styleConfig = {
|
|
|
386
388
|
property: 'font-weight',
|
|
387
389
|
short: 'w'
|
|
388
390
|
}],
|
|
389
|
-
variables:
|
|
391
|
+
variables: weights,
|
|
390
392
|
variableChecker: function variableChecker(value) {
|
|
391
|
-
return
|
|
393
|
+
return weights.includes(value);
|
|
392
394
|
},
|
|
393
395
|
valueTransformer: getWeight
|
|
394
396
|
},
|
|
395
|
-
|
|
397
|
+
textDisplayProps: {
|
|
396
398
|
props: [{
|
|
397
399
|
propName: 'display',
|
|
398
400
|
property: 'display',
|
|
399
401
|
short: 'd'
|
|
400
402
|
}],
|
|
401
|
-
variables:
|
|
403
|
+
variables: textDisplays,
|
|
404
|
+
variableChecker: function variableChecker(value) {
|
|
405
|
+
return textDisplays.includes(value);
|
|
406
|
+
}
|
|
407
|
+
},
|
|
408
|
+
letterSpacingProps: {
|
|
409
|
+
props: [{
|
|
410
|
+
propName: 'letterSpacing',
|
|
411
|
+
property: 'letter-spacing',
|
|
412
|
+
short: 'ls'
|
|
413
|
+
}]
|
|
414
|
+
},
|
|
415
|
+
textTransformProps: {
|
|
416
|
+
props: [{
|
|
417
|
+
propName: 'textTransform',
|
|
418
|
+
property: 'text-transform',
|
|
419
|
+
short: 'tt'
|
|
420
|
+
}],
|
|
421
|
+
variables: textTransforms,
|
|
402
422
|
variableChecker: function variableChecker(value) {
|
|
403
|
-
return
|
|
423
|
+
return textTransforms.includes(value);
|
|
404
424
|
}
|
|
405
425
|
}
|
|
406
426
|
};
|