@blockle/blocks 0.11.1 → 0.11.2
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/dist/index.cjs +18 -18
- package/dist/momotaro.chunk.d.ts +69 -65
- package/dist/styles/components/display/Divider/Divider.cjs +13 -13
- package/dist/styles/components/form/Button/Button.cjs +2 -2
- package/dist/styles/components/form/Checkbox/Checkbox.cjs +2 -2
- package/dist/styles/components/form/Input/Input.cjs +3 -3
- package/dist/styles/components/form/Radio/Radio.cjs +2 -2
- package/dist/styles/components/form/Select/Select.cjs +2 -2
- package/dist/styles/components/form/Slider/Slider.cjs +7 -7
- package/dist/styles/components/form/Switch/Switch.cjs +6 -6
- package/dist/styles/components/other/BlocksProvider/BlocksProvider.cjs +5 -5
- package/dist/styles/components/overlay/Dialog/Dialog.cjs +28819 -23
- package/dist/styles/components/overlay/Dialog/Dialog.mjs +28797 -3
- package/dist/styles/components/typography/Text/Text.cjs +2 -2
- package/dist/styles/lib/css/atoms/sprinkles.css.cjs +314 -4
- package/dist/styles/lib/css/atoms/sprinkles.css.mjs +312 -2
- package/package.json +11 -9
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
const jsxRuntime = require("react/jsx-runtime");
|
|
3
|
-
const
|
|
3
|
+
const require$$0 = require("react");
|
|
4
4
|
const styles_components_display_Divider_Divider_cjs = require("../../display/Divider/Divider.cjs");
|
|
5
5
|
const styles_components_typography_Text_text_css_cjs = require("./text.css.cjs");
|
|
6
|
-
const Text =
|
|
6
|
+
const Text = require$$0.forwardRef(function Text2({ tag: Tag = "span", asChild, children, className, ...restProps }, ref) {
|
|
7
7
|
return /* @__PURE__ */ jsxRuntime.jsx(styles_components_display_Divider_Divider_cjs.Box, { ref, asChild: true, className: styles_components_display_Divider_Divider_cjs.classnames(styles_components_typography_Text_text_css_cjs.text, className), ...restProps, children: asChild ? children : /* @__PURE__ */ jsxRuntime.jsx(Tag, { children }) });
|
|
8
8
|
});
|
|
9
9
|
exports.Text = Text;
|
|
@@ -1,16 +1,326 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
const fileScope = require("@vanilla-extract/css/fileScope");
|
|
3
|
-
const
|
|
3
|
+
const css = require("@vanilla-extract/css");
|
|
4
|
+
const recipe = require("@vanilla-extract/css/recipe");
|
|
4
5
|
const styles_lib_css_atoms_atomicProperties_cjs = require("./atomicProperties.cjs");
|
|
5
6
|
const styles_lib_css_atoms_breakpoints_cjs = require("./breakpoints.cjs");
|
|
7
|
+
function _toPrimitive(input, hint) {
|
|
8
|
+
if (typeof input !== "object" || input === null)
|
|
9
|
+
return input;
|
|
10
|
+
var prim = input[Symbol.toPrimitive];
|
|
11
|
+
if (prim !== void 0) {
|
|
12
|
+
var res = prim.call(input, hint || "default");
|
|
13
|
+
if (typeof res !== "object")
|
|
14
|
+
return res;
|
|
15
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
16
|
+
}
|
|
17
|
+
return (hint === "string" ? String : Number)(input);
|
|
18
|
+
}
|
|
19
|
+
function _toPropertyKey(arg) {
|
|
20
|
+
var key = _toPrimitive(arg, "string");
|
|
21
|
+
return typeof key === "symbol" ? key : String(key);
|
|
22
|
+
}
|
|
23
|
+
function _defineProperty(obj, key, value) {
|
|
24
|
+
key = _toPropertyKey(key);
|
|
25
|
+
if (key in obj) {
|
|
26
|
+
Object.defineProperty(obj, key, {
|
|
27
|
+
value,
|
|
28
|
+
enumerable: true,
|
|
29
|
+
configurable: true,
|
|
30
|
+
writable: true
|
|
31
|
+
});
|
|
32
|
+
} else {
|
|
33
|
+
obj[key] = value;
|
|
34
|
+
}
|
|
35
|
+
return obj;
|
|
36
|
+
}
|
|
37
|
+
function ownKeys(object, enumerableOnly) {
|
|
38
|
+
var keys = Object.keys(object);
|
|
39
|
+
if (Object.getOwnPropertySymbols) {
|
|
40
|
+
var symbols = Object.getOwnPropertySymbols(object);
|
|
41
|
+
enumerableOnly && (symbols = symbols.filter(function(sym) {
|
|
42
|
+
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
43
|
+
})), keys.push.apply(keys, symbols);
|
|
44
|
+
}
|
|
45
|
+
return keys;
|
|
46
|
+
}
|
|
47
|
+
function _objectSpread2(target) {
|
|
48
|
+
for (var i = 1; i < arguments.length; i++) {
|
|
49
|
+
var source = null != arguments[i] ? arguments[i] : {};
|
|
50
|
+
i % 2 ? ownKeys(Object(source), true).forEach(function(key) {
|
|
51
|
+
_defineProperty(target, key, source[key]);
|
|
52
|
+
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function(key) {
|
|
53
|
+
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
return target;
|
|
57
|
+
}
|
|
58
|
+
var createSprinkles$1 = (composeStyles) => function() {
|
|
59
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
60
|
+
args[_key] = arguments[_key];
|
|
61
|
+
}
|
|
62
|
+
var sprinklesStyles = Object.assign({}, ...args.map((a) => a.styles));
|
|
63
|
+
var sprinklesKeys = Object.keys(sprinklesStyles);
|
|
64
|
+
var shorthandNames = sprinklesKeys.filter((property) => "mappings" in sprinklesStyles[property]);
|
|
65
|
+
var sprinklesFn = (props) => {
|
|
66
|
+
var classNames = [];
|
|
67
|
+
var shorthands = {};
|
|
68
|
+
var nonShorthands = _objectSpread2({}, props);
|
|
69
|
+
var hasShorthands = false;
|
|
70
|
+
for (var shorthand of shorthandNames) {
|
|
71
|
+
var value = props[shorthand];
|
|
72
|
+
if (value != null) {
|
|
73
|
+
var sprinkle = sprinklesStyles[shorthand];
|
|
74
|
+
hasShorthands = true;
|
|
75
|
+
for (var propMapping of sprinkle.mappings) {
|
|
76
|
+
shorthands[propMapping] = value;
|
|
77
|
+
if (nonShorthands[propMapping] == null) {
|
|
78
|
+
delete nonShorthands[propMapping];
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
var finalProps = hasShorthands ? _objectSpread2(_objectSpread2({}, shorthands), nonShorthands) : props;
|
|
84
|
+
var _loop = function _loop2() {
|
|
85
|
+
var propValue = finalProps[prop];
|
|
86
|
+
var sprinkle2 = sprinklesStyles[prop];
|
|
87
|
+
try {
|
|
88
|
+
if (sprinkle2.mappings) {
|
|
89
|
+
return "continue";
|
|
90
|
+
}
|
|
91
|
+
if (typeof propValue === "string" || typeof propValue === "number") {
|
|
92
|
+
if (process.env.NODE_ENV !== "production") {
|
|
93
|
+
if (!sprinkle2.values[propValue].defaultClass) {
|
|
94
|
+
throw new Error();
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
classNames.push(sprinkle2.values[propValue].defaultClass);
|
|
98
|
+
} else if (Array.isArray(propValue)) {
|
|
99
|
+
for (var responsiveIndex = 0; responsiveIndex < propValue.length; responsiveIndex++) {
|
|
100
|
+
var responsiveValue = propValue[responsiveIndex];
|
|
101
|
+
if (responsiveValue != null) {
|
|
102
|
+
var conditionName = sprinkle2.responsiveArray[responsiveIndex];
|
|
103
|
+
if (process.env.NODE_ENV !== "production") {
|
|
104
|
+
if (!sprinkle2.values[responsiveValue].conditions[conditionName]) {
|
|
105
|
+
throw new Error();
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
classNames.push(sprinkle2.values[responsiveValue].conditions[conditionName]);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
} else {
|
|
112
|
+
for (var _conditionName in propValue) {
|
|
113
|
+
var _value = propValue[_conditionName];
|
|
114
|
+
if (_value != null) {
|
|
115
|
+
if (process.env.NODE_ENV !== "production") {
|
|
116
|
+
if (!sprinkle2.values[_value].conditions[_conditionName]) {
|
|
117
|
+
throw new Error();
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
classNames.push(sprinkle2.values[_value].conditions[_conditionName]);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
} catch (e) {
|
|
125
|
+
if (process.env.NODE_ENV !== "production") {
|
|
126
|
+
class SprinklesError extends Error {
|
|
127
|
+
constructor(message) {
|
|
128
|
+
super(message);
|
|
129
|
+
this.name = "SprinklesError";
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
var format = (v) => typeof v === "string" ? '"'.concat(v, '"') : v;
|
|
133
|
+
var invalidPropValue = (prop2, value2, possibleValues) => {
|
|
134
|
+
throw new SprinklesError('"'.concat(prop2, '" has no value ').concat(format(value2), ". Possible values are ").concat(Object.keys(possibleValues).map(format).join(", ")));
|
|
135
|
+
};
|
|
136
|
+
if (!sprinkle2) {
|
|
137
|
+
throw new SprinklesError('"'.concat(prop, '" is not a valid sprinkle'));
|
|
138
|
+
}
|
|
139
|
+
if (typeof propValue === "string" || typeof propValue === "number") {
|
|
140
|
+
if (!(propValue in sprinkle2.values)) {
|
|
141
|
+
invalidPropValue(prop, propValue, sprinkle2.values);
|
|
142
|
+
}
|
|
143
|
+
if (!sprinkle2.values[propValue].defaultClass) {
|
|
144
|
+
throw new SprinklesError('"'.concat(prop, '" has no default condition. You must specify which conditions to target explicitly. Possible options are ').concat(Object.keys(sprinkle2.values[propValue].conditions).map(format).join(", ")));
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
if (typeof propValue === "object") {
|
|
148
|
+
if (!("conditions" in sprinkle2.values[Object.keys(sprinkle2.values)[0]])) {
|
|
149
|
+
throw new SprinklesError('"'.concat(prop, '" is not a conditional property'));
|
|
150
|
+
}
|
|
151
|
+
if (Array.isArray(propValue)) {
|
|
152
|
+
if (!("responsiveArray" in sprinkle2)) {
|
|
153
|
+
throw new SprinklesError('"'.concat(prop, '" does not support responsive arrays'));
|
|
154
|
+
}
|
|
155
|
+
var breakpointCount = sprinkle2.responsiveArray.length;
|
|
156
|
+
if (breakpointCount < propValue.length) {
|
|
157
|
+
throw new SprinklesError('"'.concat(prop, '" only supports up to ').concat(breakpointCount, " breakpoints. You passed ").concat(propValue.length));
|
|
158
|
+
}
|
|
159
|
+
for (var _responsiveValue of propValue) {
|
|
160
|
+
if (!sprinkle2.values[_responsiveValue]) {
|
|
161
|
+
invalidPropValue(prop, _responsiveValue, sprinkle2.values);
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
} else {
|
|
165
|
+
for (var _conditionName2 in propValue) {
|
|
166
|
+
var _value2 = propValue[_conditionName2];
|
|
167
|
+
if (_value2 != null) {
|
|
168
|
+
if (!sprinkle2.values[_value2]) {
|
|
169
|
+
invalidPropValue(prop, _value2, sprinkle2.values);
|
|
170
|
+
}
|
|
171
|
+
if (!sprinkle2.values[_value2].conditions[_conditionName2]) {
|
|
172
|
+
throw new SprinklesError('"'.concat(prop, '" has no condition named ').concat(format(_conditionName2), ". Possible values are ").concat(Object.keys(sprinkle2.values[_value2].conditions).map(format).join(", ")));
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
throw e;
|
|
180
|
+
}
|
|
181
|
+
};
|
|
182
|
+
for (var prop in finalProps) {
|
|
183
|
+
var _ret = _loop();
|
|
184
|
+
if (_ret === "continue")
|
|
185
|
+
continue;
|
|
186
|
+
}
|
|
187
|
+
return composeStyles(classNames.join(" "));
|
|
188
|
+
};
|
|
189
|
+
return Object.assign(sprinklesFn, {
|
|
190
|
+
properties: new Set(sprinklesKeys)
|
|
191
|
+
});
|
|
192
|
+
};
|
|
193
|
+
function defineProperties(options) {
|
|
194
|
+
var styles = "shorthands" in options ? Object.fromEntries(Object.entries(options.shorthands).map((_ref) => {
|
|
195
|
+
var [prop, mappings] = _ref;
|
|
196
|
+
return [prop, {
|
|
197
|
+
mappings
|
|
198
|
+
}];
|
|
199
|
+
})) : {};
|
|
200
|
+
var _loop = function _loop2(key2) {
|
|
201
|
+
var property = options.properties[key2];
|
|
202
|
+
styles[key2] = {
|
|
203
|
+
values: {}
|
|
204
|
+
};
|
|
205
|
+
if ("responsiveArray" in options) {
|
|
206
|
+
styles[key2].responsiveArray = options.responsiveArray;
|
|
207
|
+
}
|
|
208
|
+
var processValue = (valueName2, value2) => {
|
|
209
|
+
if ("conditions" in options) {
|
|
210
|
+
styles[key2].values[valueName2] = {
|
|
211
|
+
conditions: {}
|
|
212
|
+
};
|
|
213
|
+
var defaultConditions = options.defaultCondition ? Array.isArray(options.defaultCondition) ? options.defaultCondition : [options.defaultCondition] : [];
|
|
214
|
+
var defaultClasses = [];
|
|
215
|
+
for (var _conditionName in options.conditions) {
|
|
216
|
+
var styleValue = typeof value2 === "object" ? value2 : {
|
|
217
|
+
[key2]: value2
|
|
218
|
+
};
|
|
219
|
+
var condition = options.conditions[_conditionName];
|
|
220
|
+
if (condition["@supports"]) {
|
|
221
|
+
styleValue = {
|
|
222
|
+
"@supports": {
|
|
223
|
+
[condition["@supports"]]: styleValue
|
|
224
|
+
}
|
|
225
|
+
};
|
|
226
|
+
}
|
|
227
|
+
if (condition["@container"]) {
|
|
228
|
+
styleValue = {
|
|
229
|
+
"@container": {
|
|
230
|
+
[condition["@container"]]: styleValue
|
|
231
|
+
}
|
|
232
|
+
};
|
|
233
|
+
}
|
|
234
|
+
if (condition["@media"]) {
|
|
235
|
+
styleValue = {
|
|
236
|
+
"@media": {
|
|
237
|
+
[condition["@media"]]: styleValue
|
|
238
|
+
}
|
|
239
|
+
};
|
|
240
|
+
}
|
|
241
|
+
if (condition.selector) {
|
|
242
|
+
styleValue = {
|
|
243
|
+
selectors: {
|
|
244
|
+
[condition.selector]: styleValue
|
|
245
|
+
}
|
|
246
|
+
};
|
|
247
|
+
}
|
|
248
|
+
if (options["@layer"]) {
|
|
249
|
+
styleValue = {
|
|
250
|
+
"@layer": {
|
|
251
|
+
[options["@layer"]]: styleValue
|
|
252
|
+
}
|
|
253
|
+
};
|
|
254
|
+
}
|
|
255
|
+
var className = css.style(styleValue, "".concat(key2, "_").concat(String(valueName2), "_").concat(_conditionName));
|
|
256
|
+
styles[key2].values[valueName2].conditions[_conditionName] = className;
|
|
257
|
+
if (defaultConditions.indexOf(_conditionName) > -1) {
|
|
258
|
+
defaultClasses.push(className);
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
if (defaultClasses.length > 0) {
|
|
262
|
+
styles[key2].values[valueName2].defaultClass = defaultClasses.join(" ");
|
|
263
|
+
}
|
|
264
|
+
} else {
|
|
265
|
+
var _styleValue = typeof value2 === "object" ? value2 : {
|
|
266
|
+
[key2]: value2
|
|
267
|
+
};
|
|
268
|
+
if (options["@layer"]) {
|
|
269
|
+
_styleValue = {
|
|
270
|
+
"@layer": {
|
|
271
|
+
[options["@layer"]]: _styleValue
|
|
272
|
+
}
|
|
273
|
+
};
|
|
274
|
+
}
|
|
275
|
+
styles[key2].values[valueName2] = {
|
|
276
|
+
defaultClass: css.style(_styleValue, "".concat(key2, "_").concat(String(valueName2)))
|
|
277
|
+
};
|
|
278
|
+
}
|
|
279
|
+
};
|
|
280
|
+
if (Array.isArray(property)) {
|
|
281
|
+
for (var value of property) {
|
|
282
|
+
processValue(value, value);
|
|
283
|
+
}
|
|
284
|
+
} else {
|
|
285
|
+
for (var valueName in property) {
|
|
286
|
+
var _value = property[valueName];
|
|
287
|
+
processValue(valueName, _value);
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
};
|
|
291
|
+
for (var key in options.properties) {
|
|
292
|
+
_loop(key);
|
|
293
|
+
}
|
|
294
|
+
var conditions = "conditions" in options ? {
|
|
295
|
+
defaultCondition: options.defaultCondition,
|
|
296
|
+
conditionNames: Object.keys(options.conditions),
|
|
297
|
+
responsiveArray: options.responsiveArray
|
|
298
|
+
} : void 0;
|
|
299
|
+
return {
|
|
300
|
+
conditions,
|
|
301
|
+
styles
|
|
302
|
+
};
|
|
303
|
+
}
|
|
304
|
+
var mockComposeStyles = (classList) => classList;
|
|
305
|
+
function createSprinkles() {
|
|
306
|
+
for (var _len = arguments.length, config = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
307
|
+
config[_key] = arguments[_key];
|
|
308
|
+
}
|
|
309
|
+
var sprinkles = createSprinkles$1(fileScope.hasFileScope() ? css.composeStyles : mockComposeStyles)(...config);
|
|
310
|
+
return recipe.addRecipe(sprinkles, {
|
|
311
|
+
importPath: "@vanilla-extract/sprinkles/createRuntimeSprinkles",
|
|
312
|
+
importName: "createSprinkles",
|
|
313
|
+
args: config
|
|
314
|
+
});
|
|
315
|
+
}
|
|
6
316
|
fileScope.setFileScope("src/lib/css/atoms/sprinkles.css.ts", "@blockle/blocks");
|
|
7
|
-
const unresponsiveAtomicProperties =
|
|
317
|
+
const unresponsiveAtomicProperties = defineProperties({
|
|
8
318
|
properties: styles_lib_css_atoms_atomicProperties_cjs.unresponsiveProperties,
|
|
9
319
|
shorthands: {
|
|
10
320
|
inset: ["insetBlockStart", "insetBlockEnd", "insetInlineStart", "insetInlineEnd"]
|
|
11
321
|
}
|
|
12
322
|
});
|
|
13
|
-
const responsiveAtomicProperties =
|
|
323
|
+
const responsiveAtomicProperties = defineProperties({
|
|
14
324
|
defaultCondition: "mobile",
|
|
15
325
|
conditions: {
|
|
16
326
|
mobile: {},
|
|
@@ -33,6 +343,6 @@ const responsiveAtomicProperties = sprinkles.defineProperties({
|
|
|
33
343
|
placeItems: ["justifyContent", "alignItems"]
|
|
34
344
|
}
|
|
35
345
|
});
|
|
36
|
-
const atoms =
|
|
346
|
+
const atoms = createSprinkles(unresponsiveAtomicProperties, responsiveAtomicProperties);
|
|
37
347
|
fileScope.endFileScope();
|
|
38
348
|
exports.atoms = atoms;
|
|
@@ -1,7 +1,317 @@
|
|
|
1
|
-
import { setFileScope, endFileScope } from "@vanilla-extract/css/fileScope";
|
|
2
|
-
import {
|
|
1
|
+
import { hasFileScope, setFileScope, endFileScope } from "@vanilla-extract/css/fileScope";
|
|
2
|
+
import { composeStyles, style } from "@vanilla-extract/css";
|
|
3
|
+
import { addRecipe } from "@vanilla-extract/css/recipe";
|
|
3
4
|
import { unresponsiveProperties, responsiveProperties } from "./atomicProperties.mjs";
|
|
4
5
|
import { breakpointQuery, breakpointNames } from "./breakpoints.mjs";
|
|
6
|
+
function _toPrimitive(input, hint) {
|
|
7
|
+
if (typeof input !== "object" || input === null)
|
|
8
|
+
return input;
|
|
9
|
+
var prim = input[Symbol.toPrimitive];
|
|
10
|
+
if (prim !== void 0) {
|
|
11
|
+
var res = prim.call(input, hint || "default");
|
|
12
|
+
if (typeof res !== "object")
|
|
13
|
+
return res;
|
|
14
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
15
|
+
}
|
|
16
|
+
return (hint === "string" ? String : Number)(input);
|
|
17
|
+
}
|
|
18
|
+
function _toPropertyKey(arg) {
|
|
19
|
+
var key = _toPrimitive(arg, "string");
|
|
20
|
+
return typeof key === "symbol" ? key : String(key);
|
|
21
|
+
}
|
|
22
|
+
function _defineProperty(obj, key, value) {
|
|
23
|
+
key = _toPropertyKey(key);
|
|
24
|
+
if (key in obj) {
|
|
25
|
+
Object.defineProperty(obj, key, {
|
|
26
|
+
value,
|
|
27
|
+
enumerable: true,
|
|
28
|
+
configurable: true,
|
|
29
|
+
writable: true
|
|
30
|
+
});
|
|
31
|
+
} else {
|
|
32
|
+
obj[key] = value;
|
|
33
|
+
}
|
|
34
|
+
return obj;
|
|
35
|
+
}
|
|
36
|
+
function ownKeys(object, enumerableOnly) {
|
|
37
|
+
var keys = Object.keys(object);
|
|
38
|
+
if (Object.getOwnPropertySymbols) {
|
|
39
|
+
var symbols = Object.getOwnPropertySymbols(object);
|
|
40
|
+
enumerableOnly && (symbols = symbols.filter(function(sym) {
|
|
41
|
+
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
42
|
+
})), keys.push.apply(keys, symbols);
|
|
43
|
+
}
|
|
44
|
+
return keys;
|
|
45
|
+
}
|
|
46
|
+
function _objectSpread2(target) {
|
|
47
|
+
for (var i = 1; i < arguments.length; i++) {
|
|
48
|
+
var source = null != arguments[i] ? arguments[i] : {};
|
|
49
|
+
i % 2 ? ownKeys(Object(source), true).forEach(function(key) {
|
|
50
|
+
_defineProperty(target, key, source[key]);
|
|
51
|
+
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function(key) {
|
|
52
|
+
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
return target;
|
|
56
|
+
}
|
|
57
|
+
var createSprinkles$1 = (composeStyles2) => function() {
|
|
58
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
59
|
+
args[_key] = arguments[_key];
|
|
60
|
+
}
|
|
61
|
+
var sprinklesStyles = Object.assign({}, ...args.map((a) => a.styles));
|
|
62
|
+
var sprinklesKeys = Object.keys(sprinklesStyles);
|
|
63
|
+
var shorthandNames = sprinklesKeys.filter((property) => "mappings" in sprinklesStyles[property]);
|
|
64
|
+
var sprinklesFn = (props) => {
|
|
65
|
+
var classNames = [];
|
|
66
|
+
var shorthands = {};
|
|
67
|
+
var nonShorthands = _objectSpread2({}, props);
|
|
68
|
+
var hasShorthands = false;
|
|
69
|
+
for (var shorthand of shorthandNames) {
|
|
70
|
+
var value = props[shorthand];
|
|
71
|
+
if (value != null) {
|
|
72
|
+
var sprinkle = sprinklesStyles[shorthand];
|
|
73
|
+
hasShorthands = true;
|
|
74
|
+
for (var propMapping of sprinkle.mappings) {
|
|
75
|
+
shorthands[propMapping] = value;
|
|
76
|
+
if (nonShorthands[propMapping] == null) {
|
|
77
|
+
delete nonShorthands[propMapping];
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
var finalProps = hasShorthands ? _objectSpread2(_objectSpread2({}, shorthands), nonShorthands) : props;
|
|
83
|
+
var _loop = function _loop2() {
|
|
84
|
+
var propValue = finalProps[prop];
|
|
85
|
+
var sprinkle2 = sprinklesStyles[prop];
|
|
86
|
+
try {
|
|
87
|
+
if (sprinkle2.mappings) {
|
|
88
|
+
return "continue";
|
|
89
|
+
}
|
|
90
|
+
if (typeof propValue === "string" || typeof propValue === "number") {
|
|
91
|
+
if (process.env.NODE_ENV !== "production") {
|
|
92
|
+
if (!sprinkle2.values[propValue].defaultClass) {
|
|
93
|
+
throw new Error();
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
classNames.push(sprinkle2.values[propValue].defaultClass);
|
|
97
|
+
} else if (Array.isArray(propValue)) {
|
|
98
|
+
for (var responsiveIndex = 0; responsiveIndex < propValue.length; responsiveIndex++) {
|
|
99
|
+
var responsiveValue = propValue[responsiveIndex];
|
|
100
|
+
if (responsiveValue != null) {
|
|
101
|
+
var conditionName = sprinkle2.responsiveArray[responsiveIndex];
|
|
102
|
+
if (process.env.NODE_ENV !== "production") {
|
|
103
|
+
if (!sprinkle2.values[responsiveValue].conditions[conditionName]) {
|
|
104
|
+
throw new Error();
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
classNames.push(sprinkle2.values[responsiveValue].conditions[conditionName]);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
} else {
|
|
111
|
+
for (var _conditionName in propValue) {
|
|
112
|
+
var _value = propValue[_conditionName];
|
|
113
|
+
if (_value != null) {
|
|
114
|
+
if (process.env.NODE_ENV !== "production") {
|
|
115
|
+
if (!sprinkle2.values[_value].conditions[_conditionName]) {
|
|
116
|
+
throw new Error();
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
classNames.push(sprinkle2.values[_value].conditions[_conditionName]);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
} catch (e) {
|
|
124
|
+
if (process.env.NODE_ENV !== "production") {
|
|
125
|
+
class SprinklesError extends Error {
|
|
126
|
+
constructor(message) {
|
|
127
|
+
super(message);
|
|
128
|
+
this.name = "SprinklesError";
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
var format = (v) => typeof v === "string" ? '"'.concat(v, '"') : v;
|
|
132
|
+
var invalidPropValue = (prop2, value2, possibleValues) => {
|
|
133
|
+
throw new SprinklesError('"'.concat(prop2, '" has no value ').concat(format(value2), ". Possible values are ").concat(Object.keys(possibleValues).map(format).join(", ")));
|
|
134
|
+
};
|
|
135
|
+
if (!sprinkle2) {
|
|
136
|
+
throw new SprinklesError('"'.concat(prop, '" is not a valid sprinkle'));
|
|
137
|
+
}
|
|
138
|
+
if (typeof propValue === "string" || typeof propValue === "number") {
|
|
139
|
+
if (!(propValue in sprinkle2.values)) {
|
|
140
|
+
invalidPropValue(prop, propValue, sprinkle2.values);
|
|
141
|
+
}
|
|
142
|
+
if (!sprinkle2.values[propValue].defaultClass) {
|
|
143
|
+
throw new SprinklesError('"'.concat(prop, '" has no default condition. You must specify which conditions to target explicitly. Possible options are ').concat(Object.keys(sprinkle2.values[propValue].conditions).map(format).join(", ")));
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
if (typeof propValue === "object") {
|
|
147
|
+
if (!("conditions" in sprinkle2.values[Object.keys(sprinkle2.values)[0]])) {
|
|
148
|
+
throw new SprinklesError('"'.concat(prop, '" is not a conditional property'));
|
|
149
|
+
}
|
|
150
|
+
if (Array.isArray(propValue)) {
|
|
151
|
+
if (!("responsiveArray" in sprinkle2)) {
|
|
152
|
+
throw new SprinklesError('"'.concat(prop, '" does not support responsive arrays'));
|
|
153
|
+
}
|
|
154
|
+
var breakpointCount = sprinkle2.responsiveArray.length;
|
|
155
|
+
if (breakpointCount < propValue.length) {
|
|
156
|
+
throw new SprinklesError('"'.concat(prop, '" only supports up to ').concat(breakpointCount, " breakpoints. You passed ").concat(propValue.length));
|
|
157
|
+
}
|
|
158
|
+
for (var _responsiveValue of propValue) {
|
|
159
|
+
if (!sprinkle2.values[_responsiveValue]) {
|
|
160
|
+
invalidPropValue(prop, _responsiveValue, sprinkle2.values);
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
} else {
|
|
164
|
+
for (var _conditionName2 in propValue) {
|
|
165
|
+
var _value2 = propValue[_conditionName2];
|
|
166
|
+
if (_value2 != null) {
|
|
167
|
+
if (!sprinkle2.values[_value2]) {
|
|
168
|
+
invalidPropValue(prop, _value2, sprinkle2.values);
|
|
169
|
+
}
|
|
170
|
+
if (!sprinkle2.values[_value2].conditions[_conditionName2]) {
|
|
171
|
+
throw new SprinklesError('"'.concat(prop, '" has no condition named ').concat(format(_conditionName2), ". Possible values are ").concat(Object.keys(sprinkle2.values[_value2].conditions).map(format).join(", ")));
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
throw e;
|
|
179
|
+
}
|
|
180
|
+
};
|
|
181
|
+
for (var prop in finalProps) {
|
|
182
|
+
var _ret = _loop();
|
|
183
|
+
if (_ret === "continue")
|
|
184
|
+
continue;
|
|
185
|
+
}
|
|
186
|
+
return composeStyles2(classNames.join(" "));
|
|
187
|
+
};
|
|
188
|
+
return Object.assign(sprinklesFn, {
|
|
189
|
+
properties: new Set(sprinklesKeys)
|
|
190
|
+
});
|
|
191
|
+
};
|
|
192
|
+
function defineProperties(options) {
|
|
193
|
+
var styles = "shorthands" in options ? Object.fromEntries(Object.entries(options.shorthands).map((_ref) => {
|
|
194
|
+
var [prop, mappings] = _ref;
|
|
195
|
+
return [prop, {
|
|
196
|
+
mappings
|
|
197
|
+
}];
|
|
198
|
+
})) : {};
|
|
199
|
+
var _loop = function _loop2(key2) {
|
|
200
|
+
var property = options.properties[key2];
|
|
201
|
+
styles[key2] = {
|
|
202
|
+
values: {}
|
|
203
|
+
};
|
|
204
|
+
if ("responsiveArray" in options) {
|
|
205
|
+
styles[key2].responsiveArray = options.responsiveArray;
|
|
206
|
+
}
|
|
207
|
+
var processValue = (valueName2, value2) => {
|
|
208
|
+
if ("conditions" in options) {
|
|
209
|
+
styles[key2].values[valueName2] = {
|
|
210
|
+
conditions: {}
|
|
211
|
+
};
|
|
212
|
+
var defaultConditions = options.defaultCondition ? Array.isArray(options.defaultCondition) ? options.defaultCondition : [options.defaultCondition] : [];
|
|
213
|
+
var defaultClasses = [];
|
|
214
|
+
for (var _conditionName in options.conditions) {
|
|
215
|
+
var styleValue = typeof value2 === "object" ? value2 : {
|
|
216
|
+
[key2]: value2
|
|
217
|
+
};
|
|
218
|
+
var condition = options.conditions[_conditionName];
|
|
219
|
+
if (condition["@supports"]) {
|
|
220
|
+
styleValue = {
|
|
221
|
+
"@supports": {
|
|
222
|
+
[condition["@supports"]]: styleValue
|
|
223
|
+
}
|
|
224
|
+
};
|
|
225
|
+
}
|
|
226
|
+
if (condition["@container"]) {
|
|
227
|
+
styleValue = {
|
|
228
|
+
"@container": {
|
|
229
|
+
[condition["@container"]]: styleValue
|
|
230
|
+
}
|
|
231
|
+
};
|
|
232
|
+
}
|
|
233
|
+
if (condition["@media"]) {
|
|
234
|
+
styleValue = {
|
|
235
|
+
"@media": {
|
|
236
|
+
[condition["@media"]]: styleValue
|
|
237
|
+
}
|
|
238
|
+
};
|
|
239
|
+
}
|
|
240
|
+
if (condition.selector) {
|
|
241
|
+
styleValue = {
|
|
242
|
+
selectors: {
|
|
243
|
+
[condition.selector]: styleValue
|
|
244
|
+
}
|
|
245
|
+
};
|
|
246
|
+
}
|
|
247
|
+
if (options["@layer"]) {
|
|
248
|
+
styleValue = {
|
|
249
|
+
"@layer": {
|
|
250
|
+
[options["@layer"]]: styleValue
|
|
251
|
+
}
|
|
252
|
+
};
|
|
253
|
+
}
|
|
254
|
+
var className = style(styleValue, "".concat(key2, "_").concat(String(valueName2), "_").concat(_conditionName));
|
|
255
|
+
styles[key2].values[valueName2].conditions[_conditionName] = className;
|
|
256
|
+
if (defaultConditions.indexOf(_conditionName) > -1) {
|
|
257
|
+
defaultClasses.push(className);
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
if (defaultClasses.length > 0) {
|
|
261
|
+
styles[key2].values[valueName2].defaultClass = defaultClasses.join(" ");
|
|
262
|
+
}
|
|
263
|
+
} else {
|
|
264
|
+
var _styleValue = typeof value2 === "object" ? value2 : {
|
|
265
|
+
[key2]: value2
|
|
266
|
+
};
|
|
267
|
+
if (options["@layer"]) {
|
|
268
|
+
_styleValue = {
|
|
269
|
+
"@layer": {
|
|
270
|
+
[options["@layer"]]: _styleValue
|
|
271
|
+
}
|
|
272
|
+
};
|
|
273
|
+
}
|
|
274
|
+
styles[key2].values[valueName2] = {
|
|
275
|
+
defaultClass: style(_styleValue, "".concat(key2, "_").concat(String(valueName2)))
|
|
276
|
+
};
|
|
277
|
+
}
|
|
278
|
+
};
|
|
279
|
+
if (Array.isArray(property)) {
|
|
280
|
+
for (var value of property) {
|
|
281
|
+
processValue(value, value);
|
|
282
|
+
}
|
|
283
|
+
} else {
|
|
284
|
+
for (var valueName in property) {
|
|
285
|
+
var _value = property[valueName];
|
|
286
|
+
processValue(valueName, _value);
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
};
|
|
290
|
+
for (var key in options.properties) {
|
|
291
|
+
_loop(key);
|
|
292
|
+
}
|
|
293
|
+
var conditions = "conditions" in options ? {
|
|
294
|
+
defaultCondition: options.defaultCondition,
|
|
295
|
+
conditionNames: Object.keys(options.conditions),
|
|
296
|
+
responsiveArray: options.responsiveArray
|
|
297
|
+
} : void 0;
|
|
298
|
+
return {
|
|
299
|
+
conditions,
|
|
300
|
+
styles
|
|
301
|
+
};
|
|
302
|
+
}
|
|
303
|
+
var mockComposeStyles = (classList) => classList;
|
|
304
|
+
function createSprinkles() {
|
|
305
|
+
for (var _len = arguments.length, config = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
306
|
+
config[_key] = arguments[_key];
|
|
307
|
+
}
|
|
308
|
+
var sprinkles = createSprinkles$1(hasFileScope() ? composeStyles : mockComposeStyles)(...config);
|
|
309
|
+
return addRecipe(sprinkles, {
|
|
310
|
+
importPath: "@vanilla-extract/sprinkles/createRuntimeSprinkles",
|
|
311
|
+
importName: "createSprinkles",
|
|
312
|
+
args: config
|
|
313
|
+
});
|
|
314
|
+
}
|
|
5
315
|
setFileScope("src/lib/css/atoms/sprinkles.css.ts", "@blockle/blocks");
|
|
6
316
|
const unresponsiveAtomicProperties = defineProperties({
|
|
7
317
|
properties: unresponsiveProperties,
|