tailwindcss-3d-styles 1.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.
Potentially problematic release.
This version of tailwindcss-3d-styles might be problematic. Click here for more details.
- package/LICENSE.md +21 -0
- package/README.md +586 -0
- package/common/index.js +4 -0
- package/css-animations/base.js +19 -0
- package/css-animations/bounce-and-spin.js +121 -0
- package/css-animations/bounce.js +106 -0
- package/css-animations/index.js +8 -0
- package/css-animations/spin.js +106 -0
- package/css-utilities/backface.js +40 -0
- package/css-utilities/base.js +23 -0
- package/css-utilities/index.js +14 -0
- package/css-utilities/perspective-origin.js +39 -0
- package/css-utilities/perspective.js +69 -0
- package/css-utilities/scale.js +124 -0
- package/css-utilities/transform-box.js +43 -0
- package/css-utilities/transform-core.js +71 -0
- package/css-utilities/transform-style.js +40 -0
- package/css-utilities/transform.js +204 -0
- package/css-utilities/translate.js +104 -0
- package/index.js +94 -0
- package/package.json +19 -0
- package/types/common/index.d.ts +7 -0
- package/types/css-animations/base.d.ts +4 -0
- package/types/css-animations/bounce-and-spin.d.ts +19 -0
- package/types/css-animations/bounce.d.ts +15 -0
- package/types/css-animations/index.d.ts +12 -0
- package/types/css-animations/spin.d.ts +16 -0
- package/types/css-utilities/backface.d.ts +9 -0
- package/types/css-utilities/base.d.ts +6 -0
- package/types/css-utilities/index.d.ts +18 -0
- package/types/css-utilities/perspective-origin.d.ts +6 -0
- package/types/css-utilities/perspective.d.ts +26 -0
- package/types/css-utilities/scale.d.ts +24 -0
- package/types/css-utilities/transform-box.d.ts +12 -0
- package/types/css-utilities/transform-core.d.ts +5 -0
- package/types/css-utilities/transform-style.d.ts +9 -0
- package/types/css-utilities/transform.d.ts +38 -0
- package/types/css-utilities/translate.d.ts +24 -0
- package/types/index.d.ts +11 -0
- package/types/utils/css-value.d.ts +48 -0
- package/types/utils/dimension.d.ts +3 -0
- package/types/utils/ensure.d.ts +5 -0
- package/types/utils/generate-guard.d.ts +8 -0
- package/types/utils/lodash-transformers.d.ts +6 -0
- package/utils/css-value.js +386 -0
- package/utils/dimension.js +34 -0
- package/utils/ensure.js +33 -0
- package/utils/generate-guard.js +75 -0
- package/utils/lodash-transformers.js +108 -0
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "TransformBox", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return TransformBox;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
var _call_super = require("@swc/helpers/_/_call_super");
|
|
12
|
+
var _class_call_check = require("@swc/helpers/_/_class_call_check");
|
|
13
|
+
var _define_property = require("@swc/helpers/_/_define_property");
|
|
14
|
+
var _inherits = require("@swc/helpers/_/_inherits");
|
|
15
|
+
var _base = require("./base");
|
|
16
|
+
var TransformBox = /*#__PURE__*/ function(Base) {
|
|
17
|
+
"use strict";
|
|
18
|
+
_inherits._(TransformBox, Base);
|
|
19
|
+
function TransformBox() {
|
|
20
|
+
_class_call_check._(this, TransformBox);
|
|
21
|
+
var _this;
|
|
22
|
+
_this = _call_super._(this, TransformBox, arguments), _define_property._(_this, "utilities", function() {
|
|
23
|
+
_this.api.matchUtilities({
|
|
24
|
+
'transform-box': function(value) {
|
|
25
|
+
return {
|
|
26
|
+
'transform-box': value
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
}, {
|
|
30
|
+
values: _this.api.theme('transformBox')
|
|
31
|
+
});
|
|
32
|
+
});
|
|
33
|
+
return _this;
|
|
34
|
+
}
|
|
35
|
+
return TransformBox;
|
|
36
|
+
}(_base.Base);
|
|
37
|
+
_define_property._(TransformBox, "defaultTheme", {
|
|
38
|
+
content: 'content-box',
|
|
39
|
+
border: 'border-box',
|
|
40
|
+
fill: 'fill-box',
|
|
41
|
+
stroke: 'stroke-box',
|
|
42
|
+
view: 'view-box'
|
|
43
|
+
});
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "TransformCore", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return TransformCore;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
var _call_super = require("@swc/helpers/_/_call_super");
|
|
12
|
+
var _class_call_check = require("@swc/helpers/_/_class_call_check");
|
|
13
|
+
var _define_property = require("@swc/helpers/_/_define_property");
|
|
14
|
+
var _inherits = require("@swc/helpers/_/_inherits");
|
|
15
|
+
var _object_spread = require("@swc/helpers/_/_object_spread");
|
|
16
|
+
var _base = require("./base");
|
|
17
|
+
var _scale = require("./scale");
|
|
18
|
+
var _transform = require("./transform");
|
|
19
|
+
var _translate = require("./translate");
|
|
20
|
+
var TransformCore = /*#__PURE__*/ function(Base) {
|
|
21
|
+
"use strict";
|
|
22
|
+
_inherits._(TransformCore, Base);
|
|
23
|
+
function TransformCore() {
|
|
24
|
+
_class_call_check._(this, TransformCore);
|
|
25
|
+
var _this;
|
|
26
|
+
_this = _call_super._(this, TransformCore, arguments), _define_property._(_this, "utilities", function() {
|
|
27
|
+
var transformValue2d = _this.legacy ? _transform.Transform.normaliseLegacyFunctionValues({
|
|
28
|
+
dimension: '2d'
|
|
29
|
+
}) : _transform.Transform.normaliseFunctionValues({
|
|
30
|
+
dimension: '2d'
|
|
31
|
+
});
|
|
32
|
+
var transformValue3d = _this.legacy ? _transform.Transform.normaliseLegacyFunctionValues() : _transform.Transform.normaliseFunctionValues();
|
|
33
|
+
var transformDeclarations2d = {
|
|
34
|
+
'--webkit-transform': transformValue2d,
|
|
35
|
+
transform: transformValue2d
|
|
36
|
+
};
|
|
37
|
+
var transformDeclarations3d = {
|
|
38
|
+
'--webkit-transform': transformValue3d,
|
|
39
|
+
transform: transformValue3d
|
|
40
|
+
};
|
|
41
|
+
_this.api.addUtilities({
|
|
42
|
+
// Leaving `.transform` utility here for backward compatibility,
|
|
43
|
+
// not really sure what purpose it serves though
|
|
44
|
+
'.transform': transformDeclarations2d,
|
|
45
|
+
'.transform-cpu': _this.legacy ? transformDeclarations2d : _object_spread._({
|
|
46
|
+
translate: _translate.Translate.normaliseFunctionValues({
|
|
47
|
+
dimension: '2d'
|
|
48
|
+
}),
|
|
49
|
+
scale: _scale.Scale.normaliseFunctionValues({
|
|
50
|
+
dimension: '2d'
|
|
51
|
+
})
|
|
52
|
+
}, transformDeclarations2d),
|
|
53
|
+
'.transform-gpu': _this.legacy ? transformDeclarations3d : _object_spread._({
|
|
54
|
+
translate: _translate.Translate.normaliseFunctionValues(),
|
|
55
|
+
scale: _scale.Scale.normaliseFunctionValues()
|
|
56
|
+
}, transformDeclarations3d),
|
|
57
|
+
'.transform-none': _this.legacy ? {
|
|
58
|
+
'--webkit-transform': 'none',
|
|
59
|
+
transform: 'none'
|
|
60
|
+
} : {
|
|
61
|
+
translate: 'none',
|
|
62
|
+
scale: 'none',
|
|
63
|
+
'--webkit-transform': 'none',
|
|
64
|
+
transform: 'none'
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
});
|
|
68
|
+
return _this;
|
|
69
|
+
}
|
|
70
|
+
return TransformCore;
|
|
71
|
+
}(_base.Base);
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "TransformStyle", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return TransformStyle;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
var _call_super = require("@swc/helpers/_/_call_super");
|
|
12
|
+
var _class_call_check = require("@swc/helpers/_/_class_call_check");
|
|
13
|
+
var _define_property = require("@swc/helpers/_/_define_property");
|
|
14
|
+
var _inherits = require("@swc/helpers/_/_inherits");
|
|
15
|
+
var _base = require("./base");
|
|
16
|
+
var TransformStyle = /*#__PURE__*/ function(Base) {
|
|
17
|
+
"use strict";
|
|
18
|
+
_inherits._(TransformStyle, Base);
|
|
19
|
+
function TransformStyle() {
|
|
20
|
+
_class_call_check._(this, TransformStyle);
|
|
21
|
+
var _this;
|
|
22
|
+
_this = _call_super._(this, TransformStyle, arguments), _define_property._(_this, "utilities", function() {
|
|
23
|
+
_this.api.matchUtilities({
|
|
24
|
+
'transform-style': function(value) {
|
|
25
|
+
return {
|
|
26
|
+
'transform-style': value
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
}, {
|
|
30
|
+
values: _this.api.theme('transformStyle')
|
|
31
|
+
});
|
|
32
|
+
});
|
|
33
|
+
return _this;
|
|
34
|
+
}
|
|
35
|
+
return TransformStyle;
|
|
36
|
+
}(_base.Base);
|
|
37
|
+
_define_property._(TransformStyle, "defaultTheme", {
|
|
38
|
+
flat: 'flat',
|
|
39
|
+
'3d': 'preserve-3d'
|
|
40
|
+
});
|
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "Transform", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return Transform;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
var _call_super = require("@swc/helpers/_/_call_super");
|
|
12
|
+
var _class_call_check = require("@swc/helpers/_/_class_call_check");
|
|
13
|
+
var _define_property = require("@swc/helpers/_/_define_property");
|
|
14
|
+
var _inherits = require("@swc/helpers/_/_inherits");
|
|
15
|
+
var _object_spread = require("@swc/helpers/_/_object_spread");
|
|
16
|
+
var _object_spread_props = require("@swc/helpers/_/_object_spread_props");
|
|
17
|
+
var _lodash = require("lodash");
|
|
18
|
+
var _base = require("./base");
|
|
19
|
+
var _cssvalue = require("../utils/css-value");
|
|
20
|
+
var _dimension = require("../utils/dimension");
|
|
21
|
+
var _generateguard = require("../utils/generate-guard");
|
|
22
|
+
var Transform = /*#__PURE__*/ function(Base) {
|
|
23
|
+
"use strict";
|
|
24
|
+
_inherits._(Transform, Base);
|
|
25
|
+
function Transform() {
|
|
26
|
+
_class_call_check._(this, Transform);
|
|
27
|
+
var _this;
|
|
28
|
+
_this = _call_super._(this, Transform, arguments), _define_property._(_this, "isProcessableValue", (0, _generateguard.generateGuard)(_lodash.isString, _lodash.isUndefined)), _define_property._(_this, "isProcessableValues", (0, _generateguard.generateGuard)([
|
|
29
|
+
_lodash.isPlainObject,
|
|
30
|
+
function(maybe) {
|
|
31
|
+
return (0, _lodash.every)((0, _lodash.keys)(maybe), _lodash.isString);
|
|
32
|
+
},
|
|
33
|
+
function(maybe) {
|
|
34
|
+
return (0, _lodash.every)((0, _lodash.values)(maybe), _this.isProcessableValue);
|
|
35
|
+
}
|
|
36
|
+
])), _define_property._(_this, "normaliseValues", function(values) {
|
|
37
|
+
return _this.isProcessableValues(values) ? (0, _lodash.chain)(values).mapValues(function(angle) {
|
|
38
|
+
return (0, _cssvalue.normaliseAngleValue)(angle);
|
|
39
|
+
}).pickBy(function(angle, modifier) {
|
|
40
|
+
return (0, _lodash.isString)(modifier) && modifier !== '' && (0, _lodash.isString)(angle);
|
|
41
|
+
}).value() : {};
|
|
42
|
+
}), _define_property._(_this, "utilities", function() {
|
|
43
|
+
var rotateValues = _this.normaliseValues(_this.api.theme('rotate'));
|
|
44
|
+
var skewValues = _this.normaliseValues(_this.api.theme('skew'));
|
|
45
|
+
var transformDeclarations = _this.legacy ? Transform.legacyDeclarations() : Transform.declarations();
|
|
46
|
+
_this.api.matchUtilities({
|
|
47
|
+
rotate: function(value) {
|
|
48
|
+
return _object_spread._({
|
|
49
|
+
'@defaults transform': {},
|
|
50
|
+
'--tw-rotate-z': value
|
|
51
|
+
}, _this.legacy ? transformDeclarations : {
|
|
52
|
+
rotate: 'var(--tw-rotate-z)'
|
|
53
|
+
});
|
|
54
|
+
},
|
|
55
|
+
'rotate-x': function(value) {
|
|
56
|
+
return _object_spread._({
|
|
57
|
+
'@defaults transform': {},
|
|
58
|
+
'--tw-rotate-x': value
|
|
59
|
+
}, transformDeclarations);
|
|
60
|
+
},
|
|
61
|
+
'rotate-y': function(value) {
|
|
62
|
+
return _object_spread._({
|
|
63
|
+
'@defaults transform': {},
|
|
64
|
+
'--tw-rotate-y': value
|
|
65
|
+
}, transformDeclarations);
|
|
66
|
+
},
|
|
67
|
+
'rotate-z': function(value) {
|
|
68
|
+
return _object_spread._({
|
|
69
|
+
'@defaults transform': {},
|
|
70
|
+
'--tw-rotate-z': value
|
|
71
|
+
}, _this.legacy ? transformDeclarations : {
|
|
72
|
+
rotate: 'var(--tw-rotate-z)'
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
}, {
|
|
76
|
+
values: rotateValues,
|
|
77
|
+
supportsNegativeValues: true
|
|
78
|
+
});
|
|
79
|
+
_this.api.matchUtilities({
|
|
80
|
+
'skew-x': function(value) {
|
|
81
|
+
return _object_spread._({
|
|
82
|
+
'@defaults transform': {},
|
|
83
|
+
'--tw-skew-x': value
|
|
84
|
+
}, transformDeclarations);
|
|
85
|
+
},
|
|
86
|
+
'skew-y': function(value) {
|
|
87
|
+
return _object_spread._({
|
|
88
|
+
'@defaults transform': {},
|
|
89
|
+
'--tw-skew-y': value
|
|
90
|
+
}, transformDeclarations);
|
|
91
|
+
}
|
|
92
|
+
}, {
|
|
93
|
+
values: skewValues,
|
|
94
|
+
supportsNegativeValues: true
|
|
95
|
+
});
|
|
96
|
+
});
|
|
97
|
+
return _this;
|
|
98
|
+
}
|
|
99
|
+
return Transform;
|
|
100
|
+
}(_base.Base);
|
|
101
|
+
_define_property._(Transform, "defaultFunctionValues", {
|
|
102
|
+
rotateX: 'var(--tw-rotate-x)',
|
|
103
|
+
rotateY: 'var(--tw-rotate-y)',
|
|
104
|
+
skewX: 'var(--tw-skew-x)',
|
|
105
|
+
skewY: 'var(--tw-skew-y)'
|
|
106
|
+
});
|
|
107
|
+
_define_property._(Transform, "defaultLegacyFunctionValues", _object_spread_props._(_object_spread._({}, Transform.defaultFunctionValues), {
|
|
108
|
+
translateX: 'var(--tw-translate-x)',
|
|
109
|
+
translateY: 'var(--tw-translate-y)',
|
|
110
|
+
translateZ: 'var(--tw-translate-z)',
|
|
111
|
+
rotateZ: 'var(--tw-rotate-z)',
|
|
112
|
+
scaleX: 'var(--tw-scale-x)',
|
|
113
|
+
scaleY: 'var(--tw-scale-y)',
|
|
114
|
+
scaleZ: 'var(--tw-scale-z)',
|
|
115
|
+
perspective: 'var(--tw-perspective)'
|
|
116
|
+
}));
|
|
117
|
+
_define_property._(Transform, "normaliseFunctionValues", function() {
|
|
118
|
+
var _ref = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {}, dimension = _ref.dimension, rotateX = _ref.rotateX, rotateY = _ref.rotateY, skewX = _ref.skewX, skewY = _ref.skewY;
|
|
119
|
+
var safeDimension = (0, _dimension.normaliseDimension)(dimension);
|
|
120
|
+
var safeValues = {
|
|
121
|
+
rotateX: (0, _cssvalue.normaliseAngleValue)(rotateX, Transform.defaultFunctionValues.rotateX),
|
|
122
|
+
rotateY: (0, _cssvalue.normaliseAngleValue)(rotateY, Transform.defaultFunctionValues.rotateY),
|
|
123
|
+
skewX: (0, _cssvalue.normaliseAngleValue)(skewX, Transform.defaultFunctionValues.skewX),
|
|
124
|
+
skewY: (0, _cssvalue.normaliseAngleValue)(skewY, Transform.defaultFunctionValues.skewY)
|
|
125
|
+
};
|
|
126
|
+
return [
|
|
127
|
+
{
|
|
128
|
+
'3d': "rotateX(".concat(safeValues.rotateX, ") rotateY(").concat(safeValues.rotateY, ")"),
|
|
129
|
+
'2d': ''
|
|
130
|
+
},
|
|
131
|
+
"skewX(".concat(safeValues.skewX, ")"),
|
|
132
|
+
"skewY(".concat(safeValues.skewY, ")")
|
|
133
|
+
].map(function(value) {
|
|
134
|
+
return (0, _lodash.isString)(value) ? value : value[safeDimension];
|
|
135
|
+
}).filter(function(value) {
|
|
136
|
+
return value !== '';
|
|
137
|
+
}).join(' ');
|
|
138
|
+
});
|
|
139
|
+
_define_property._(Transform, "normaliseLegacyFunctionValues", function() {
|
|
140
|
+
var _ref = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {}, dimension = _ref.dimension, translateX = _ref.translateX, translateY = _ref.translateY, translateZ = _ref.translateZ, rotateX = _ref.rotateX, rotateY = _ref.rotateY, rotateZ = _ref.rotateZ, skewX = _ref.skewX, skewY = _ref.skewY, scaleX = _ref.scaleX, scaleY = _ref.scaleY, scaleZ = _ref.scaleZ, perspective = _ref.perspective;
|
|
141
|
+
var safeDimension = (0, _dimension.normaliseDimension)(dimension);
|
|
142
|
+
var safeValues = {
|
|
143
|
+
translateX: (0, _cssvalue.normaliseLengthPercentageValue)(translateX, Transform.defaultLegacyFunctionValues.translateX),
|
|
144
|
+
translateY: (0, _cssvalue.normaliseLengthPercentageValue)(translateY, Transform.defaultLegacyFunctionValues.translateY),
|
|
145
|
+
translateZ: (0, _cssvalue.normaliseLengthPercentageValue)(translateZ, Transform.defaultLegacyFunctionValues.translateZ),
|
|
146
|
+
rotateX: (0, _cssvalue.normaliseAngleValue)(rotateX, Transform.defaultLegacyFunctionValues.rotateX),
|
|
147
|
+
rotateY: (0, _cssvalue.normaliseAngleValue)(rotateY, Transform.defaultLegacyFunctionValues.rotateY),
|
|
148
|
+
rotateZ: (0, _cssvalue.normaliseAngleValue)(rotateZ, Transform.defaultLegacyFunctionValues.rotateZ),
|
|
149
|
+
skewX: (0, _cssvalue.normaliseAngleValue)(skewX, Transform.defaultLegacyFunctionValues.skewX),
|
|
150
|
+
skewY: (0, _cssvalue.normaliseAngleValue)(skewY, Transform.defaultLegacyFunctionValues.skewY),
|
|
151
|
+
scaleX: (0, _cssvalue.normaliseNumberPercentageValue)(scaleX, Transform.defaultLegacyFunctionValues.scaleX, {
|
|
152
|
+
lowerLimit: 0
|
|
153
|
+
}),
|
|
154
|
+
scaleY: (0, _cssvalue.normaliseNumberPercentageValue)(scaleY, Transform.defaultLegacyFunctionValues.scaleY, {
|
|
155
|
+
lowerLimit: 0
|
|
156
|
+
}),
|
|
157
|
+
scaleZ: (0, _cssvalue.normaliseNumberPercentageValue)(scaleZ, Transform.defaultLegacyFunctionValues.scaleZ, {
|
|
158
|
+
lowerLimit: 0
|
|
159
|
+
}),
|
|
160
|
+
perspective: (0, _cssvalue.normaliseLengthValue)(perspective, Transform.defaultLegacyFunctionValues.perspective)
|
|
161
|
+
};
|
|
162
|
+
return [
|
|
163
|
+
{
|
|
164
|
+
'3d': "translate3d(".concat(safeValues.translateX, ", ").concat(safeValues.translateY, ", ").concat(safeValues.translateZ, ")"),
|
|
165
|
+
'2d': "translate(".concat(safeValues.translateX, ", ").concat(safeValues.translateY, ")")
|
|
166
|
+
},
|
|
167
|
+
{
|
|
168
|
+
'3d': "rotateX(".concat(safeValues.rotateX, ") rotateY(").concat(safeValues.rotateY, ") rotateZ(").concat(safeValues.rotateZ, ")"),
|
|
169
|
+
'2d': "rotate(".concat(safeValues.rotateZ, ")")
|
|
170
|
+
},
|
|
171
|
+
"skewX(".concat(safeValues.skewX, ")"),
|
|
172
|
+
"skewY(".concat(safeValues.skewY, ")"),
|
|
173
|
+
"scaleX(".concat(safeValues.scaleX, ")"),
|
|
174
|
+
"scaleY(".concat(safeValues.scaleY, ")"),
|
|
175
|
+
{
|
|
176
|
+
'3d': "scaleZ(".concat(safeValues.scaleZ, ")"),
|
|
177
|
+
'2d': ''
|
|
178
|
+
},
|
|
179
|
+
{
|
|
180
|
+
'3d': "perspective(".concat(safeValues.perspective, ")"),
|
|
181
|
+
'2d': ''
|
|
182
|
+
}
|
|
183
|
+
].map(function(value) {
|
|
184
|
+
return (0, _lodash.isString)(value) ? value : value[safeDimension];
|
|
185
|
+
}).filter(function(value) {
|
|
186
|
+
return value !== '';
|
|
187
|
+
}).join(' ');
|
|
188
|
+
});
|
|
189
|
+
_define_property._(Transform, "declarations", function() {
|
|
190
|
+
var values = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
|
|
191
|
+
var functionValues = Transform.normaliseFunctionValues(values);
|
|
192
|
+
return {
|
|
193
|
+
'--webkit-transform': functionValues,
|
|
194
|
+
transform: functionValues
|
|
195
|
+
};
|
|
196
|
+
});
|
|
197
|
+
_define_property._(Transform, "legacyDeclarations", function() {
|
|
198
|
+
var values = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
|
|
199
|
+
var functionValues = Transform.normaliseLegacyFunctionValues(values);
|
|
200
|
+
return {
|
|
201
|
+
'--webkit-transform': functionValues,
|
|
202
|
+
transform: functionValues
|
|
203
|
+
};
|
|
204
|
+
});
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "Translate", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return Translate;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
var _call_super = require("@swc/helpers/_/_call_super");
|
|
12
|
+
var _class_call_check = require("@swc/helpers/_/_class_call_check");
|
|
13
|
+
var _define_property = require("@swc/helpers/_/_define_property");
|
|
14
|
+
var _inherits = require("@swc/helpers/_/_inherits");
|
|
15
|
+
var _object_spread = require("@swc/helpers/_/_object_spread");
|
|
16
|
+
var _lodash = require("lodash");
|
|
17
|
+
var _base = require("./base");
|
|
18
|
+
var _transform = require("./transform");
|
|
19
|
+
var _cssvalue = require("../utils/css-value");
|
|
20
|
+
var _dimension = require("../utils/dimension");
|
|
21
|
+
var _generateguard = require("../utils/generate-guard");
|
|
22
|
+
var Translate = /*#__PURE__*/ function(Base) {
|
|
23
|
+
"use strict";
|
|
24
|
+
_inherits._(Translate, Base);
|
|
25
|
+
function Translate() {
|
|
26
|
+
_class_call_check._(this, Translate);
|
|
27
|
+
var _this;
|
|
28
|
+
_this = _call_super._(this, Translate, arguments), _define_property._(_this, "isProcessableValue", (0, _generateguard.generateGuard)(_lodash.isString, _lodash.isUndefined)), _define_property._(_this, "isProcessableValues", (0, _generateguard.generateGuard)([
|
|
29
|
+
_lodash.isPlainObject,
|
|
30
|
+
function(maybe) {
|
|
31
|
+
return (0, _lodash.every)((0, _lodash.keys)(maybe), _lodash.isString);
|
|
32
|
+
},
|
|
33
|
+
function(maybe) {
|
|
34
|
+
return (0, _lodash.every)((0, _lodash.values)(maybe), _this.isProcessableValue);
|
|
35
|
+
}
|
|
36
|
+
])), _define_property._(_this, "normaliseValues", function(values) {
|
|
37
|
+
return _this.isProcessableValues(values) ? (0, _lodash.chain)(values).mapValues(function(duration) {
|
|
38
|
+
return (0, _cssvalue.normaliseLengthPercentageValue)(duration);
|
|
39
|
+
}).pickBy(function(duration, modifier) {
|
|
40
|
+
return (0, _lodash.isString)(modifier) && modifier !== '' && (0, _lodash.isString)(duration);
|
|
41
|
+
}).value() : {};
|
|
42
|
+
}), _define_property._(_this, "utilities", function() {
|
|
43
|
+
var values = _this.normaliseValues(_this.api.theme('translate'));
|
|
44
|
+
var cssDeclarations = _this.legacy ? Translate.legacyDeclarations() : Translate.declarations();
|
|
45
|
+
_this.api.matchUtilities({
|
|
46
|
+
'translate-x': function(value) {
|
|
47
|
+
return _object_spread._({
|
|
48
|
+
'@defaults transform': {},
|
|
49
|
+
'--tw-translate-x': value
|
|
50
|
+
}, cssDeclarations);
|
|
51
|
+
},
|
|
52
|
+
'translate-y': function(value) {
|
|
53
|
+
return _object_spread._({
|
|
54
|
+
'@defaults transform': {},
|
|
55
|
+
'--tw-translate-y': value
|
|
56
|
+
}, cssDeclarations);
|
|
57
|
+
}
|
|
58
|
+
}, {
|
|
59
|
+
values: values,
|
|
60
|
+
supportsNegativeValues: true
|
|
61
|
+
});
|
|
62
|
+
_this.api.matchUtilities({
|
|
63
|
+
'translate-z': function(value) {
|
|
64
|
+
return _object_spread._({
|
|
65
|
+
'@defaults transform': {},
|
|
66
|
+
'--tw-translate-z': value
|
|
67
|
+
}, cssDeclarations);
|
|
68
|
+
}
|
|
69
|
+
}, {
|
|
70
|
+
values: (0, _lodash.pickBy)(values, function(value) {
|
|
71
|
+
return !value.endsWith('%');
|
|
72
|
+
}),
|
|
73
|
+
supportsNegativeValues: true
|
|
74
|
+
});
|
|
75
|
+
});
|
|
76
|
+
return _this;
|
|
77
|
+
}
|
|
78
|
+
return Translate;
|
|
79
|
+
}(_base.Base);
|
|
80
|
+
_define_property._(Translate, "defaultFunctionValues", {
|
|
81
|
+
translateX: 'var(--tw-translate-x)',
|
|
82
|
+
translateY: 'var(--tw-translate-y)',
|
|
83
|
+
translateZ: 'var(--tw-translate-z)'
|
|
84
|
+
});
|
|
85
|
+
_define_property._(Translate, "normaliseFunctionValues", function() {
|
|
86
|
+
var _ref = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {}, dimension = _ref.dimension, translateX = _ref.translateX, translateY = _ref.translateY, translateZ = _ref.translateZ;
|
|
87
|
+
var safeValues = [
|
|
88
|
+
(0, _cssvalue.normaliseLengthPercentageValue)(translateX, Translate.defaultFunctionValues.translateX),
|
|
89
|
+
(0, _cssvalue.normaliseLengthPercentageValue)(translateY, Translate.defaultFunctionValues.translateY)
|
|
90
|
+
];
|
|
91
|
+
if ((0, _dimension.normaliseDimension)(dimension) === '3d') {
|
|
92
|
+
safeValues.push((0, _cssvalue.normaliseLengthValue)(translateZ, Translate.defaultFunctionValues.translateZ));
|
|
93
|
+
}
|
|
94
|
+
return safeValues.join(' ');
|
|
95
|
+
});
|
|
96
|
+
_define_property._(Translate, "declarations", function() {
|
|
97
|
+
var values = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
|
|
98
|
+
return {
|
|
99
|
+
translate: Translate.normaliseFunctionValues(values)
|
|
100
|
+
};
|
|
101
|
+
});
|
|
102
|
+
_define_property._(Translate, "legacyDeclarations", function() {
|
|
103
|
+
return _transform.Transform.legacyDeclarations();
|
|
104
|
+
});
|
package/index.js
ADDED
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var _interop_require_default = require("@swc/helpers/_/_interop_require_default");
|
|
3
|
+
var _object_spread = require("@swc/helpers/_/_object_spread");
|
|
4
|
+
var _plugin = /*#__PURE__*/ _interop_require_default._(require("tailwindcss/plugin"));
|
|
5
|
+
var _cssanimations = require("./css-animations");
|
|
6
|
+
var _cssutilities = require("./css-utilities");
|
|
7
|
+
var _ensure = require("./utils/ensure");
|
|
8
|
+
// Default CSS variables, modelled from core
|
|
9
|
+
var DEFAULT_VARIABLE_VALUES = {
|
|
10
|
+
'--tw-perspective': 'none',
|
|
11
|
+
'--tw-translate-x': '0',
|
|
12
|
+
'--tw-translate-y': '0',
|
|
13
|
+
'--tw-translate-z': '0',
|
|
14
|
+
'--tw-rotate-x': '0',
|
|
15
|
+
'--tw-rotate-y': '0',
|
|
16
|
+
'--tw-rotate-z': '0',
|
|
17
|
+
'--tw-skew-x': '0',
|
|
18
|
+
'--tw-skew-y': '0',
|
|
19
|
+
'--tw-scale-x': '1',
|
|
20
|
+
'--tw-scale-y': '1',
|
|
21
|
+
'--tw-scale-z': '1'
|
|
22
|
+
};
|
|
23
|
+
var optionDefaults = {
|
|
24
|
+
legacy: false
|
|
25
|
+
};
|
|
26
|
+
var tailwindCss3d = _plugin.default.withOptions(function() {
|
|
27
|
+
var _ref = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : optionDefaults, _ref_legacy = _ref.legacy, legacy = _ref_legacy === void 0 ? optionDefaults.legacy : _ref_legacy;
|
|
28
|
+
var safeLegacy = (0, _ensure.ensureBoolean)(legacy, optionDefaults.legacy);
|
|
29
|
+
return function(api) {
|
|
30
|
+
var localAPI = api;
|
|
31
|
+
// Replace the transform core plugin defaults and add some new ones
|
|
32
|
+
localAPI.addDefaults('transform', DEFAULT_VARIABLE_VALUES);
|
|
33
|
+
var perspective = new _cssutilities.Perspective(localAPI, safeLegacy);
|
|
34
|
+
var transformStyle = new _cssutilities.TransformStyle(localAPI);
|
|
35
|
+
var translate = new _cssutilities.Translate(localAPI, safeLegacy);
|
|
36
|
+
var transform = new _cssutilities.Transform(localAPI, safeLegacy);
|
|
37
|
+
var scale = new _cssutilities.Scale(localAPI, safeLegacy);
|
|
38
|
+
var backface = new _cssutilities.Backface(localAPI);
|
|
39
|
+
var perspectiveOrigin = new _cssutilities.PerspectiveOrigin(localAPI);
|
|
40
|
+
var transformBox = new _cssutilities.TransformBox(localAPI);
|
|
41
|
+
var transformCore = new _cssutilities.TransformCore(localAPI, safeLegacy);
|
|
42
|
+
// New CSS Utilities
|
|
43
|
+
perspective.utilities();
|
|
44
|
+
transformStyle.utilities();
|
|
45
|
+
translate.utilities();
|
|
46
|
+
transform.utilities();
|
|
47
|
+
scale.utilities();
|
|
48
|
+
backface.utilities();
|
|
49
|
+
perspectiveOrigin.utilities();
|
|
50
|
+
transformBox.utilities();
|
|
51
|
+
transformCore.utilities();
|
|
52
|
+
};
|
|
53
|
+
}, function() {
|
|
54
|
+
var _ref = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : optionDefaults, _ref_legacy = _ref.legacy, legacy = _ref_legacy === void 0 ? optionDefaults.legacy : _ref_legacy;
|
|
55
|
+
var safeLegacy = (0, _ensure.ensureBoolean)(legacy, optionDefaults.legacy);
|
|
56
|
+
var spin = new _cssanimations.Spin(safeLegacy);
|
|
57
|
+
var bounce = new _cssanimations.Bounce(safeLegacy);
|
|
58
|
+
var bounceAndSpin = new _cssanimations.BounceAndSpin(safeLegacy);
|
|
59
|
+
return {
|
|
60
|
+
theme: {
|
|
61
|
+
// Set new theme defaults
|
|
62
|
+
perspective: _cssutilities.Perspective.defaultTheme,
|
|
63
|
+
transformStyle: _cssutilities.TransformStyle.defaultTheme,
|
|
64
|
+
backface: _cssutilities.Backface.defaultTheme,
|
|
65
|
+
perspectiveOrigin: _cssutilities.PerspectiveOrigin.defaultTheme,
|
|
66
|
+
transformBox: _cssutilities.TransformBox.defaultTheme,
|
|
67
|
+
spin: spin.defaultTheme,
|
|
68
|
+
bounce: bounce.defaultTheme,
|
|
69
|
+
bounceAndSpin: bounceAndSpin.defaultTheme,
|
|
70
|
+
extend: {
|
|
71
|
+
// Update the core transform transition property
|
|
72
|
+
transitionProperty: {
|
|
73
|
+
transform: safeLegacy ? 'transform' : 'perspective, translate, scale, transform, perspective, rotate'
|
|
74
|
+
},
|
|
75
|
+
// New CSS keyframes and animations
|
|
76
|
+
keyframes: function(pluginUtilities) {
|
|
77
|
+
return _object_spread._({}, spin.keyframes(), bounce.keyframes(pluginUtilities), bounceAndSpin.keyframes(pluginUtilities));
|
|
78
|
+
},
|
|
79
|
+
animation: function(pluginUtilities) {
|
|
80
|
+
return _object_spread._({}, spin.animation(pluginUtilities), bounce.animation(pluginUtilities), bounceAndSpin.animation(pluginUtilities));
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
},
|
|
84
|
+
// Disable some core plugins which are superceded by this plugin
|
|
85
|
+
corePlugins: {
|
|
86
|
+
rotate: false,
|
|
87
|
+
scale: false,
|
|
88
|
+
skew: false,
|
|
89
|
+
transform: false,
|
|
90
|
+
translate: false
|
|
91
|
+
}
|
|
92
|
+
};
|
|
93
|
+
});
|
|
94
|
+
module.exports = tailwindCss3d;
|
package/package.json
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "tailwindcss-3d-styles",
|
|
3
|
+
"displayName": "3D Plugin for Tailwind CSS",
|
|
4
|
+
"description": "Add 3D transforms to your TailwindCSS project",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"TailwindCSS"
|
|
7
|
+
],
|
|
8
|
+
"version": "1.2.0",
|
|
9
|
+
"license": "MIT",
|
|
10
|
+
"peerDependencies": {
|
|
11
|
+
"tailwindcss": ">=3.2.0 <4.0.0"
|
|
12
|
+
},
|
|
13
|
+
"dependencies": {
|
|
14
|
+
"@swc/helpers": "0.5.17",
|
|
15
|
+
"lodash": "4.17.21"
|
|
16
|
+
},
|
|
17
|
+
"main": "index.js",
|
|
18
|
+
"types": "types/index.d.ts"
|
|
19
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { type PluginAPI } from 'tailwindcss/types/config';
|
|
2
|
+
declare module '@/common' {
|
|
3
|
+
type KeyValuePair<K extends keyof any = string, V = string> = Record<K, V>;
|
|
4
|
+
interface LocalPluginAPI extends PluginAPI {
|
|
5
|
+
addDefaults: (group: string, declarations: Record<string, string | string[]>) => void;
|
|
6
|
+
}
|
|
7
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { type PluginUtils } from 'tailwindcss/types/config';
|
|
2
|
+
import { type CSSAnimation } from '@/css-animations';
|
|
3
|
+
import { Base } from '@/css-animations/base';
|
|
4
|
+
type Value = [string, string];
|
|
5
|
+
type Values = Record<string, Value>;
|
|
6
|
+
export declare class BounceAndSpin extends Base implements CSSAnimation {
|
|
7
|
+
private isProcessablePrimitive;
|
|
8
|
+
private isProcessableValue;
|
|
9
|
+
private isProcessableValues;
|
|
10
|
+
private normaliseValues;
|
|
11
|
+
defaultTheme: Values;
|
|
12
|
+
keyframes: ({ theme }: PluginUtils) => {
|
|
13
|
+
[x: string]: boolean;
|
|
14
|
+
};
|
|
15
|
+
animation: ({ theme }: PluginUtils) => {
|
|
16
|
+
[x: string]: boolean;
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
export {};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { type PluginUtils } from 'tailwindcss/types/config';
|
|
2
|
+
import { type CSSAnimation } from '@/css-animations';
|
|
3
|
+
import { Base } from '@/css-animations/base';
|
|
4
|
+
type Value = [string, string];
|
|
5
|
+
type Values = Record<string, Value>;
|
|
6
|
+
export declare class Bounce extends Base implements CSSAnimation {
|
|
7
|
+
private isProcessablePrimitive;
|
|
8
|
+
private isProcessableValue;
|
|
9
|
+
private isProcessableValues;
|
|
10
|
+
private normaliseValues;
|
|
11
|
+
defaultTheme: Values;
|
|
12
|
+
keyframes: ({ theme }: PluginUtils) => {};
|
|
13
|
+
animation: ({ theme }: PluginUtils) => {};
|
|
14
|
+
}
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { type PluginUtils, type ResolvableTo } from 'tailwindcss/types/config';
|
|
2
|
+
import { type KeyValuePair } from '@/common';
|
|
3
|
+
declare module '@/css-animations' {
|
|
4
|
+
interface CSSAnimation {
|
|
5
|
+
defaultTheme?: ResolvableTo<KeyValuePair<string, any>>;
|
|
6
|
+
keyframes: (pluginUtilities: PluginUtils) => void;
|
|
7
|
+
animation: (pluginUtilities: PluginUtils) => void;
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
export * from './bounce';
|
|
11
|
+
export * from './bounce-and-spin';
|
|
12
|
+
export * from './spin';
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { type PluginUtils } from 'tailwindcss/types/config';
|
|
2
|
+
import { type CSSAnimation } from '@/css-animations';
|
|
3
|
+
import { Base } from '@/css-animations/base';
|
|
4
|
+
type Value = string;
|
|
5
|
+
type Values = Record<string, Value>;
|
|
6
|
+
export declare class Spin extends Base implements CSSAnimation {
|
|
7
|
+
private isProcessableValue;
|
|
8
|
+
private isProcessableValues;
|
|
9
|
+
private normaliseValues;
|
|
10
|
+
defaultTheme: Values;
|
|
11
|
+
private xyKeyframes;
|
|
12
|
+
private zKeyframes;
|
|
13
|
+
keyframes: () => {};
|
|
14
|
+
animation: ({ theme }: PluginUtils) => {};
|
|
15
|
+
}
|
|
16
|
+
export {};
|