@storybook/addon-docs 10.1.0-alpha.10 → 10.1.0-alpha.12
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/_browser-chunks/Color-S5NAVK5F.js +1096 -0
- package/dist/_browser-chunks/{DocsRenderer-HT7GNKAR.js → DocsRenderer-GHJI37HO.js} +2 -2
- package/dist/_browser-chunks/{chunk-MM7DTO55.js → chunk-A242L54C.js} +10 -16
- package/dist/_browser-chunks/chunk-CYSK6WYR.js +7 -0
- package/dist/_browser-chunks/chunk-DDRHE7EB.js +949 -0
- package/dist/_browser-chunks/{chunk-74ZUTOZN.js → chunk-OATZR77O.js} +9 -22
- package/dist/_browser-chunks/chunk-UUESKCKV.js +31 -0
- package/dist/_node-chunks/{chunk-AAP3IT42.js → chunk-C335KFTP.js} +13 -19
- package/dist/_node-chunks/chunk-KYCOJTNB.js +168 -0
- package/dist/_node-chunks/chunk-O7PYD3IJ.js +22630 -0
- package/dist/_node-chunks/chunk-W3QUNYQ5.js +196 -0
- package/dist/_node-chunks/mdx-plugin-DEILFM7O.js +1032 -0
- package/dist/_node-chunks/rehype-external-links-5BFMYXOM.js +121 -0
- package/dist/_node-chunks/{rehype-slug-NPV5OLTF.js → rehype-slug-WW2KPWVT.js} +24 -58
- package/dist/angular/index.js +3 -5
- package/dist/blocks.d.ts +4 -2
- package/dist/blocks.js +1833 -3846
- package/dist/ember/index.js +3 -5
- package/dist/index.js +4 -6
- package/dist/manager.js +11 -22
- package/dist/mdx-loader.js +13 -19
- package/dist/preset.js +155 -454
- package/dist/preview.js +2 -2
- package/package.json +6 -6
- package/dist/_browser-chunks/Color-553OW3OY.js +0 -1694
- package/dist/_browser-chunks/chunk-DMNQCVA2.js +0 -12
- package/dist/_browser-chunks/chunk-UZFOWTVP.js +0 -974
- package/dist/_browser-chunks/chunk-YDZYZRYC.js +0 -39
- package/dist/_node-chunks/chunk-BHIBLL2L.js +0 -36332
- package/dist/_node-chunks/chunk-RAVRMRBT.js +0 -248
- package/dist/_node-chunks/chunk-TSMODHW2.js +0 -231
- package/dist/_node-chunks/mdx-plugin-OGZHIA54.js +0 -1654
- package/dist/_node-chunks/rehype-external-links-32F3YIMH.js +0 -168
|
@@ -0,0 +1,949 @@
|
|
|
1
|
+
// src/blocks/components/Source.tsx
|
|
2
|
+
import React2 from "react";
|
|
3
|
+
import { SyntaxHighlighter } from "storybook/internal/components";
|
|
4
|
+
import {
|
|
5
|
+
ThemeProvider,
|
|
6
|
+
convert,
|
|
7
|
+
ignoreSsrWarning,
|
|
8
|
+
styled as styled2,
|
|
9
|
+
themes,
|
|
10
|
+
useTheme
|
|
11
|
+
} from "storybook/theming";
|
|
12
|
+
|
|
13
|
+
// src/blocks/components/EmptyBlock.tsx
|
|
14
|
+
import React from "react";
|
|
15
|
+
import { withReset } from "storybook/internal/components";
|
|
16
|
+
|
|
17
|
+
// ../../node_modules/@babel/runtime/helpers/esm/extends.js
|
|
18
|
+
function _extends() {
|
|
19
|
+
return _extends = Object.assign ? Object.assign.bind() : function(n) {
|
|
20
|
+
for (var e = 1; e < arguments.length; e++) {
|
|
21
|
+
var t = arguments[e];
|
|
22
|
+
for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]);
|
|
23
|
+
}
|
|
24
|
+
return n;
|
|
25
|
+
}, _extends.apply(null, arguments);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
// ../../node_modules/@babel/runtime/helpers/esm/assertThisInitialized.js
|
|
29
|
+
function _assertThisInitialized(e) {
|
|
30
|
+
if (e === void 0) throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
|
31
|
+
return e;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// ../../node_modules/@babel/runtime/helpers/esm/setPrototypeOf.js
|
|
35
|
+
function _setPrototypeOf(t, e) {
|
|
36
|
+
return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function(t2, e2) {
|
|
37
|
+
return t2.__proto__ = e2, t2;
|
|
38
|
+
}, _setPrototypeOf(t, e);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
// ../../node_modules/@babel/runtime/helpers/esm/inheritsLoose.js
|
|
42
|
+
function _inheritsLoose(t, o) {
|
|
43
|
+
t.prototype = Object.create(o.prototype), t.prototype.constructor = t, _setPrototypeOf(t, o);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
// ../../node_modules/@babel/runtime/helpers/esm/getPrototypeOf.js
|
|
47
|
+
function _getPrototypeOf(t) {
|
|
48
|
+
return _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function(t2) {
|
|
49
|
+
return t2.__proto__ || Object.getPrototypeOf(t2);
|
|
50
|
+
}, _getPrototypeOf(t);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// ../../node_modules/@babel/runtime/helpers/esm/isNativeFunction.js
|
|
54
|
+
function _isNativeFunction(t) {
|
|
55
|
+
try {
|
|
56
|
+
return Function.toString.call(t).indexOf("[native code]") !== -1;
|
|
57
|
+
} catch {
|
|
58
|
+
return typeof t == "function";
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
// ../../node_modules/@babel/runtime/helpers/esm/isNativeReflectConstruct.js
|
|
63
|
+
function _isNativeReflectConstruct() {
|
|
64
|
+
try {
|
|
65
|
+
var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {
|
|
66
|
+
}));
|
|
67
|
+
} catch {
|
|
68
|
+
}
|
|
69
|
+
return (_isNativeReflectConstruct = function() {
|
|
70
|
+
return !!t;
|
|
71
|
+
})();
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
// ../../node_modules/@babel/runtime/helpers/esm/construct.js
|
|
75
|
+
function _construct(t, e, r) {
|
|
76
|
+
if (_isNativeReflectConstruct()) return Reflect.construct.apply(null, arguments);
|
|
77
|
+
var o = [null];
|
|
78
|
+
o.push.apply(o, e);
|
|
79
|
+
var p = new (t.bind.apply(t, o))();
|
|
80
|
+
return r && _setPrototypeOf(p, r.prototype), p;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
// ../../node_modules/@babel/runtime/helpers/esm/wrapNativeSuper.js
|
|
84
|
+
function _wrapNativeSuper(t) {
|
|
85
|
+
var r = typeof Map == "function" ? /* @__PURE__ */ new Map() : void 0;
|
|
86
|
+
return _wrapNativeSuper = function(t2) {
|
|
87
|
+
if (t2 === null || !_isNativeFunction(t2)) return t2;
|
|
88
|
+
if (typeof t2 != "function") throw new TypeError("Super expression must either be null or a function");
|
|
89
|
+
if (r !== void 0) {
|
|
90
|
+
if (r.has(t2)) return r.get(t2);
|
|
91
|
+
r.set(t2, Wrapper2);
|
|
92
|
+
}
|
|
93
|
+
function Wrapper2() {
|
|
94
|
+
return _construct(t2, arguments, _getPrototypeOf(this).constructor);
|
|
95
|
+
}
|
|
96
|
+
return Wrapper2.prototype = Object.create(t2.prototype, {
|
|
97
|
+
constructor: {
|
|
98
|
+
value: Wrapper2,
|
|
99
|
+
enumerable: !1,
|
|
100
|
+
writable: !0,
|
|
101
|
+
configurable: !0
|
|
102
|
+
}
|
|
103
|
+
}), _setPrototypeOf(Wrapper2, t2);
|
|
104
|
+
}, _wrapNativeSuper(t);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
// ../../node_modules/polished/dist/polished.esm.js
|
|
108
|
+
var ERRORS = {
|
|
109
|
+
1: `Passed invalid arguments to hsl, please pass multiple numbers e.g. hsl(360, 0.75, 0.4) or an object e.g. rgb({ hue: 255, saturation: 0.4, lightness: 0.75 }).
|
|
110
|
+
|
|
111
|
+
`,
|
|
112
|
+
2: `Passed invalid arguments to hsla, please pass multiple numbers e.g. hsla(360, 0.75, 0.4, 0.7) or an object e.g. rgb({ hue: 255, saturation: 0.4, lightness: 0.75, alpha: 0.7 }).
|
|
113
|
+
|
|
114
|
+
`,
|
|
115
|
+
3: `Passed an incorrect argument to a color function, please pass a string representation of a color.
|
|
116
|
+
|
|
117
|
+
`,
|
|
118
|
+
4: `Couldn't generate valid rgb string from %s, it returned %s.
|
|
119
|
+
|
|
120
|
+
`,
|
|
121
|
+
5: `Couldn't parse the color string. Please provide the color as a string in hex, rgb, rgba, hsl or hsla notation.
|
|
122
|
+
|
|
123
|
+
`,
|
|
124
|
+
6: `Passed invalid arguments to rgb, please pass multiple numbers e.g. rgb(255, 205, 100) or an object e.g. rgb({ red: 255, green: 205, blue: 100 }).
|
|
125
|
+
|
|
126
|
+
`,
|
|
127
|
+
7: `Passed invalid arguments to rgba, please pass multiple numbers e.g. rgb(255, 205, 100, 0.75) or an object e.g. rgb({ red: 255, green: 205, blue: 100, alpha: 0.75 }).
|
|
128
|
+
|
|
129
|
+
`,
|
|
130
|
+
8: `Passed invalid argument to toColorString, please pass a RgbColor, RgbaColor, HslColor or HslaColor object.
|
|
131
|
+
|
|
132
|
+
`,
|
|
133
|
+
9: `Please provide a number of steps to the modularScale helper.
|
|
134
|
+
|
|
135
|
+
`,
|
|
136
|
+
10: `Please pass a number or one of the predefined scales to the modularScale helper as the ratio.
|
|
137
|
+
|
|
138
|
+
`,
|
|
139
|
+
11: `Invalid value passed as base to modularScale, expected number or em string but got "%s"
|
|
140
|
+
|
|
141
|
+
`,
|
|
142
|
+
12: `Expected a string ending in "px" or a number passed as the first argument to %s(), got "%s" instead.
|
|
143
|
+
|
|
144
|
+
`,
|
|
145
|
+
13: `Expected a string ending in "px" or a number passed as the second argument to %s(), got "%s" instead.
|
|
146
|
+
|
|
147
|
+
`,
|
|
148
|
+
14: `Passed invalid pixel value ("%s") to %s(), please pass a value like "12px" or 12.
|
|
149
|
+
|
|
150
|
+
`,
|
|
151
|
+
15: `Passed invalid base value ("%s") to %s(), please pass a value like "12px" or 12.
|
|
152
|
+
|
|
153
|
+
`,
|
|
154
|
+
16: `You must provide a template to this method.
|
|
155
|
+
|
|
156
|
+
`,
|
|
157
|
+
17: `You passed an unsupported selector state to this method.
|
|
158
|
+
|
|
159
|
+
`,
|
|
160
|
+
18: `minScreen and maxScreen must be provided as stringified numbers with the same units.
|
|
161
|
+
|
|
162
|
+
`,
|
|
163
|
+
19: `fromSize and toSize must be provided as stringified numbers with the same units.
|
|
164
|
+
|
|
165
|
+
`,
|
|
166
|
+
20: `expects either an array of objects or a single object with the properties prop, fromSize, and toSize.
|
|
167
|
+
|
|
168
|
+
`,
|
|
169
|
+
21: "expects the objects in the first argument array to have the properties `prop`, `fromSize`, and `toSize`.\n\n",
|
|
170
|
+
22: "expects the first argument object to have the properties `prop`, `fromSize`, and `toSize`.\n\n",
|
|
171
|
+
23: `fontFace expects a name of a font-family.
|
|
172
|
+
|
|
173
|
+
`,
|
|
174
|
+
24: `fontFace expects either the path to the font file(s) or a name of a local copy.
|
|
175
|
+
|
|
176
|
+
`,
|
|
177
|
+
25: `fontFace expects localFonts to be an array.
|
|
178
|
+
|
|
179
|
+
`,
|
|
180
|
+
26: `fontFace expects fileFormats to be an array.
|
|
181
|
+
|
|
182
|
+
`,
|
|
183
|
+
27: `radialGradient requries at least 2 color-stops to properly render.
|
|
184
|
+
|
|
185
|
+
`,
|
|
186
|
+
28: `Please supply a filename to retinaImage() as the first argument.
|
|
187
|
+
|
|
188
|
+
`,
|
|
189
|
+
29: `Passed invalid argument to triangle, please pass correct pointingDirection e.g. 'right'.
|
|
190
|
+
|
|
191
|
+
`,
|
|
192
|
+
30: "Passed an invalid value to `height` or `width`. Please provide a pixel based unit.\n\n",
|
|
193
|
+
31: `The animation shorthand only takes 8 arguments. See the specification for more information: http://mdn.io/animation
|
|
194
|
+
|
|
195
|
+
`,
|
|
196
|
+
32: `To pass multiple animations please supply them in arrays, e.g. animation(['rotate', '2s'], ['move', '1s'])
|
|
197
|
+
To pass a single animation please supply them in simple values, e.g. animation('rotate', '2s')
|
|
198
|
+
|
|
199
|
+
`,
|
|
200
|
+
33: `The animation shorthand arrays can only have 8 elements. See the specification for more information: http://mdn.io/animation
|
|
201
|
+
|
|
202
|
+
`,
|
|
203
|
+
34: `borderRadius expects a radius value as a string or number as the second argument.
|
|
204
|
+
|
|
205
|
+
`,
|
|
206
|
+
35: `borderRadius expects one of "top", "bottom", "left" or "right" as the first argument.
|
|
207
|
+
|
|
208
|
+
`,
|
|
209
|
+
36: `Property must be a string value.
|
|
210
|
+
|
|
211
|
+
`,
|
|
212
|
+
37: `Syntax Error at %s.
|
|
213
|
+
|
|
214
|
+
`,
|
|
215
|
+
38: `Formula contains a function that needs parentheses at %s.
|
|
216
|
+
|
|
217
|
+
`,
|
|
218
|
+
39: `Formula is missing closing parenthesis at %s.
|
|
219
|
+
|
|
220
|
+
`,
|
|
221
|
+
40: `Formula has too many closing parentheses at %s.
|
|
222
|
+
|
|
223
|
+
`,
|
|
224
|
+
41: `All values in a formula must have the same unit or be unitless.
|
|
225
|
+
|
|
226
|
+
`,
|
|
227
|
+
42: `Please provide a number of steps to the modularScale helper.
|
|
228
|
+
|
|
229
|
+
`,
|
|
230
|
+
43: `Please pass a number or one of the predefined scales to the modularScale helper as the ratio.
|
|
231
|
+
|
|
232
|
+
`,
|
|
233
|
+
44: `Invalid value passed as base to modularScale, expected number or em/rem string but got %s.
|
|
234
|
+
|
|
235
|
+
`,
|
|
236
|
+
45: `Passed invalid argument to hslToColorString, please pass a HslColor or HslaColor object.
|
|
237
|
+
|
|
238
|
+
`,
|
|
239
|
+
46: `Passed invalid argument to rgbToColorString, please pass a RgbColor or RgbaColor object.
|
|
240
|
+
|
|
241
|
+
`,
|
|
242
|
+
47: `minScreen and maxScreen must be provided as stringified numbers with the same units.
|
|
243
|
+
|
|
244
|
+
`,
|
|
245
|
+
48: `fromSize and toSize must be provided as stringified numbers with the same units.
|
|
246
|
+
|
|
247
|
+
`,
|
|
248
|
+
49: `Expects either an array of objects or a single object with the properties prop, fromSize, and toSize.
|
|
249
|
+
|
|
250
|
+
`,
|
|
251
|
+
50: `Expects the objects in the first argument array to have the properties prop, fromSize, and toSize.
|
|
252
|
+
|
|
253
|
+
`,
|
|
254
|
+
51: `Expects the first argument object to have the properties prop, fromSize, and toSize.
|
|
255
|
+
|
|
256
|
+
`,
|
|
257
|
+
52: `fontFace expects either the path to the font file(s) or a name of a local copy.
|
|
258
|
+
|
|
259
|
+
`,
|
|
260
|
+
53: `fontFace expects localFonts to be an array.
|
|
261
|
+
|
|
262
|
+
`,
|
|
263
|
+
54: `fontFace expects fileFormats to be an array.
|
|
264
|
+
|
|
265
|
+
`,
|
|
266
|
+
55: `fontFace expects a name of a font-family.
|
|
267
|
+
|
|
268
|
+
`,
|
|
269
|
+
56: `linearGradient requries at least 2 color-stops to properly render.
|
|
270
|
+
|
|
271
|
+
`,
|
|
272
|
+
57: `radialGradient requries at least 2 color-stops to properly render.
|
|
273
|
+
|
|
274
|
+
`,
|
|
275
|
+
58: `Please supply a filename to retinaImage() as the first argument.
|
|
276
|
+
|
|
277
|
+
`,
|
|
278
|
+
59: `Passed invalid argument to triangle, please pass correct pointingDirection e.g. 'right'.
|
|
279
|
+
|
|
280
|
+
`,
|
|
281
|
+
60: "Passed an invalid value to `height` or `width`. Please provide a pixel based unit.\n\n",
|
|
282
|
+
61: `Property must be a string value.
|
|
283
|
+
|
|
284
|
+
`,
|
|
285
|
+
62: `borderRadius expects a radius value as a string or number as the second argument.
|
|
286
|
+
|
|
287
|
+
`,
|
|
288
|
+
63: `borderRadius expects one of "top", "bottom", "left" or "right" as the first argument.
|
|
289
|
+
|
|
290
|
+
`,
|
|
291
|
+
64: `The animation shorthand only takes 8 arguments. See the specification for more information: http://mdn.io/animation.
|
|
292
|
+
|
|
293
|
+
`,
|
|
294
|
+
65: `To pass multiple animations please supply them in arrays, e.g. animation(['rotate', '2s'], ['move', '1s'])\\nTo pass a single animation please supply them in simple values, e.g. animation('rotate', '2s').
|
|
295
|
+
|
|
296
|
+
`,
|
|
297
|
+
66: `The animation shorthand arrays can only have 8 elements. See the specification for more information: http://mdn.io/animation.
|
|
298
|
+
|
|
299
|
+
`,
|
|
300
|
+
67: `You must provide a template to this method.
|
|
301
|
+
|
|
302
|
+
`,
|
|
303
|
+
68: `You passed an unsupported selector state to this method.
|
|
304
|
+
|
|
305
|
+
`,
|
|
306
|
+
69: `Expected a string ending in "px" or a number passed as the first argument to %s(), got %s instead.
|
|
307
|
+
|
|
308
|
+
`,
|
|
309
|
+
70: `Expected a string ending in "px" or a number passed as the second argument to %s(), got %s instead.
|
|
310
|
+
|
|
311
|
+
`,
|
|
312
|
+
71: `Passed invalid pixel value %s to %s(), please pass a value like "12px" or 12.
|
|
313
|
+
|
|
314
|
+
`,
|
|
315
|
+
72: `Passed invalid base value %s to %s(), please pass a value like "12px" or 12.
|
|
316
|
+
|
|
317
|
+
`,
|
|
318
|
+
73: `Please provide a valid CSS variable.
|
|
319
|
+
|
|
320
|
+
`,
|
|
321
|
+
74: `CSS variable not found and no default was provided.
|
|
322
|
+
|
|
323
|
+
`,
|
|
324
|
+
75: `important requires a valid style object, got a %s instead.
|
|
325
|
+
|
|
326
|
+
`,
|
|
327
|
+
76: `fromSize and toSize must be provided as stringified numbers with the same units as minScreen and maxScreen.
|
|
328
|
+
|
|
329
|
+
`,
|
|
330
|
+
77: `remToPx expects a value in "rem" but you provided it in "%s".
|
|
331
|
+
|
|
332
|
+
`,
|
|
333
|
+
78: `base must be set in "px" or "%" but you set it in "%s".
|
|
334
|
+
`
|
|
335
|
+
};
|
|
336
|
+
function format() {
|
|
337
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++)
|
|
338
|
+
args[_key] = arguments[_key];
|
|
339
|
+
var a = args[0], b = [], c;
|
|
340
|
+
for (c = 1; c < args.length; c += 1)
|
|
341
|
+
b.push(args[c]);
|
|
342
|
+
return b.forEach(function(d) {
|
|
343
|
+
a = a.replace(/%[a-z]/, d);
|
|
344
|
+
}), a;
|
|
345
|
+
}
|
|
346
|
+
var PolishedError = (function(_Error) {
|
|
347
|
+
_inheritsLoose(PolishedError2, _Error);
|
|
348
|
+
function PolishedError2(code) {
|
|
349
|
+
var _this;
|
|
350
|
+
if (process.env.NODE_ENV === "production")
|
|
351
|
+
_this = _Error.call(this, "An error occurred. See https://github.com/styled-components/polished/blob/main/src/internalHelpers/errors.md#" + code + " for more information.") || this;
|
|
352
|
+
else {
|
|
353
|
+
for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++)
|
|
354
|
+
args[_key2 - 1] = arguments[_key2];
|
|
355
|
+
_this = _Error.call(this, format.apply(void 0, [ERRORS[code]].concat(args))) || this;
|
|
356
|
+
}
|
|
357
|
+
return _assertThisInitialized(_this);
|
|
358
|
+
}
|
|
359
|
+
return PolishedError2;
|
|
360
|
+
})(_wrapNativeSuper(Error));
|
|
361
|
+
function endsWith(string, suffix) {
|
|
362
|
+
return string.substr(-suffix.length) === suffix;
|
|
363
|
+
}
|
|
364
|
+
var cssRegex$1 = /^([+-]?(?:\d+|\d*\.\d+))([a-z]*|%)$/;
|
|
365
|
+
function stripUnit(value) {
|
|
366
|
+
if (typeof value != "string") return value;
|
|
367
|
+
var matchedValue = value.match(cssRegex$1);
|
|
368
|
+
return matchedValue ? parseFloat(value) : value;
|
|
369
|
+
}
|
|
370
|
+
var pxtoFactory = function(to) {
|
|
371
|
+
return function(pxval, base) {
|
|
372
|
+
base === void 0 && (base = "16px");
|
|
373
|
+
var newPxval = pxval, newBase = base;
|
|
374
|
+
if (typeof pxval == "string") {
|
|
375
|
+
if (!endsWith(pxval, "px"))
|
|
376
|
+
throw new PolishedError(69, to, pxval);
|
|
377
|
+
newPxval = stripUnit(pxval);
|
|
378
|
+
}
|
|
379
|
+
if (typeof base == "string") {
|
|
380
|
+
if (!endsWith(base, "px"))
|
|
381
|
+
throw new PolishedError(70, to, base);
|
|
382
|
+
newBase = stripUnit(base);
|
|
383
|
+
}
|
|
384
|
+
if (typeof newPxval == "string")
|
|
385
|
+
throw new PolishedError(71, pxval, to);
|
|
386
|
+
if (typeof newBase == "string")
|
|
387
|
+
throw new PolishedError(72, base, to);
|
|
388
|
+
return "" + newPxval / newBase + to;
|
|
389
|
+
};
|
|
390
|
+
}, pixelsto = pxtoFactory, em = pixelsto("em");
|
|
391
|
+
var rem = pixelsto("rem");
|
|
392
|
+
function colorToInt(color) {
|
|
393
|
+
return Math.round(color * 255);
|
|
394
|
+
}
|
|
395
|
+
function convertToInt(red, green, blue) {
|
|
396
|
+
return colorToInt(red) + "," + colorToInt(green) + "," + colorToInt(blue);
|
|
397
|
+
}
|
|
398
|
+
function hslToRgb(hue, saturation, lightness, convert2) {
|
|
399
|
+
if (convert2 === void 0 && (convert2 = convertToInt), saturation === 0)
|
|
400
|
+
return convert2(lightness, lightness, lightness);
|
|
401
|
+
var huePrime = (hue % 360 + 360) % 360 / 60, chroma = (1 - Math.abs(2 * lightness - 1)) * saturation, secondComponent = chroma * (1 - Math.abs(huePrime % 2 - 1)), red = 0, green = 0, blue = 0;
|
|
402
|
+
huePrime >= 0 && huePrime < 1 ? (red = chroma, green = secondComponent) : huePrime >= 1 && huePrime < 2 ? (red = secondComponent, green = chroma) : huePrime >= 2 && huePrime < 3 ? (green = chroma, blue = secondComponent) : huePrime >= 3 && huePrime < 4 ? (green = secondComponent, blue = chroma) : huePrime >= 4 && huePrime < 5 ? (red = secondComponent, blue = chroma) : huePrime >= 5 && huePrime < 6 && (red = chroma, blue = secondComponent);
|
|
403
|
+
var lightnessModification = lightness - chroma / 2, finalRed = red + lightnessModification, finalGreen = green + lightnessModification, finalBlue = blue + lightnessModification;
|
|
404
|
+
return convert2(finalRed, finalGreen, finalBlue);
|
|
405
|
+
}
|
|
406
|
+
var namedColorMap = {
|
|
407
|
+
aliceblue: "f0f8ff",
|
|
408
|
+
antiquewhite: "faebd7",
|
|
409
|
+
aqua: "00ffff",
|
|
410
|
+
aquamarine: "7fffd4",
|
|
411
|
+
azure: "f0ffff",
|
|
412
|
+
beige: "f5f5dc",
|
|
413
|
+
bisque: "ffe4c4",
|
|
414
|
+
black: "000",
|
|
415
|
+
blanchedalmond: "ffebcd",
|
|
416
|
+
blue: "0000ff",
|
|
417
|
+
blueviolet: "8a2be2",
|
|
418
|
+
brown: "a52a2a",
|
|
419
|
+
burlywood: "deb887",
|
|
420
|
+
cadetblue: "5f9ea0",
|
|
421
|
+
chartreuse: "7fff00",
|
|
422
|
+
chocolate: "d2691e",
|
|
423
|
+
coral: "ff7f50",
|
|
424
|
+
cornflowerblue: "6495ed",
|
|
425
|
+
cornsilk: "fff8dc",
|
|
426
|
+
crimson: "dc143c",
|
|
427
|
+
cyan: "00ffff",
|
|
428
|
+
darkblue: "00008b",
|
|
429
|
+
darkcyan: "008b8b",
|
|
430
|
+
darkgoldenrod: "b8860b",
|
|
431
|
+
darkgray: "a9a9a9",
|
|
432
|
+
darkgreen: "006400",
|
|
433
|
+
darkgrey: "a9a9a9",
|
|
434
|
+
darkkhaki: "bdb76b",
|
|
435
|
+
darkmagenta: "8b008b",
|
|
436
|
+
darkolivegreen: "556b2f",
|
|
437
|
+
darkorange: "ff8c00",
|
|
438
|
+
darkorchid: "9932cc",
|
|
439
|
+
darkred: "8b0000",
|
|
440
|
+
darksalmon: "e9967a",
|
|
441
|
+
darkseagreen: "8fbc8f",
|
|
442
|
+
darkslateblue: "483d8b",
|
|
443
|
+
darkslategray: "2f4f4f",
|
|
444
|
+
darkslategrey: "2f4f4f",
|
|
445
|
+
darkturquoise: "00ced1",
|
|
446
|
+
darkviolet: "9400d3",
|
|
447
|
+
deeppink: "ff1493",
|
|
448
|
+
deepskyblue: "00bfff",
|
|
449
|
+
dimgray: "696969",
|
|
450
|
+
dimgrey: "696969",
|
|
451
|
+
dodgerblue: "1e90ff",
|
|
452
|
+
firebrick: "b22222",
|
|
453
|
+
floralwhite: "fffaf0",
|
|
454
|
+
forestgreen: "228b22",
|
|
455
|
+
fuchsia: "ff00ff",
|
|
456
|
+
gainsboro: "dcdcdc",
|
|
457
|
+
ghostwhite: "f8f8ff",
|
|
458
|
+
gold: "ffd700",
|
|
459
|
+
goldenrod: "daa520",
|
|
460
|
+
gray: "808080",
|
|
461
|
+
green: "008000",
|
|
462
|
+
greenyellow: "adff2f",
|
|
463
|
+
grey: "808080",
|
|
464
|
+
honeydew: "f0fff0",
|
|
465
|
+
hotpink: "ff69b4",
|
|
466
|
+
indianred: "cd5c5c",
|
|
467
|
+
indigo: "4b0082",
|
|
468
|
+
ivory: "fffff0",
|
|
469
|
+
khaki: "f0e68c",
|
|
470
|
+
lavender: "e6e6fa",
|
|
471
|
+
lavenderblush: "fff0f5",
|
|
472
|
+
lawngreen: "7cfc00",
|
|
473
|
+
lemonchiffon: "fffacd",
|
|
474
|
+
lightblue: "add8e6",
|
|
475
|
+
lightcoral: "f08080",
|
|
476
|
+
lightcyan: "e0ffff",
|
|
477
|
+
lightgoldenrodyellow: "fafad2",
|
|
478
|
+
lightgray: "d3d3d3",
|
|
479
|
+
lightgreen: "90ee90",
|
|
480
|
+
lightgrey: "d3d3d3",
|
|
481
|
+
lightpink: "ffb6c1",
|
|
482
|
+
lightsalmon: "ffa07a",
|
|
483
|
+
lightseagreen: "20b2aa",
|
|
484
|
+
lightskyblue: "87cefa",
|
|
485
|
+
lightslategray: "789",
|
|
486
|
+
lightslategrey: "789",
|
|
487
|
+
lightsteelblue: "b0c4de",
|
|
488
|
+
lightyellow: "ffffe0",
|
|
489
|
+
lime: "0f0",
|
|
490
|
+
limegreen: "32cd32",
|
|
491
|
+
linen: "faf0e6",
|
|
492
|
+
magenta: "f0f",
|
|
493
|
+
maroon: "800000",
|
|
494
|
+
mediumaquamarine: "66cdaa",
|
|
495
|
+
mediumblue: "0000cd",
|
|
496
|
+
mediumorchid: "ba55d3",
|
|
497
|
+
mediumpurple: "9370db",
|
|
498
|
+
mediumseagreen: "3cb371",
|
|
499
|
+
mediumslateblue: "7b68ee",
|
|
500
|
+
mediumspringgreen: "00fa9a",
|
|
501
|
+
mediumturquoise: "48d1cc",
|
|
502
|
+
mediumvioletred: "c71585",
|
|
503
|
+
midnightblue: "191970",
|
|
504
|
+
mintcream: "f5fffa",
|
|
505
|
+
mistyrose: "ffe4e1",
|
|
506
|
+
moccasin: "ffe4b5",
|
|
507
|
+
navajowhite: "ffdead",
|
|
508
|
+
navy: "000080",
|
|
509
|
+
oldlace: "fdf5e6",
|
|
510
|
+
olive: "808000",
|
|
511
|
+
olivedrab: "6b8e23",
|
|
512
|
+
orange: "ffa500",
|
|
513
|
+
orangered: "ff4500",
|
|
514
|
+
orchid: "da70d6",
|
|
515
|
+
palegoldenrod: "eee8aa",
|
|
516
|
+
palegreen: "98fb98",
|
|
517
|
+
paleturquoise: "afeeee",
|
|
518
|
+
palevioletred: "db7093",
|
|
519
|
+
papayawhip: "ffefd5",
|
|
520
|
+
peachpuff: "ffdab9",
|
|
521
|
+
peru: "cd853f",
|
|
522
|
+
pink: "ffc0cb",
|
|
523
|
+
plum: "dda0dd",
|
|
524
|
+
powderblue: "b0e0e6",
|
|
525
|
+
purple: "800080",
|
|
526
|
+
rebeccapurple: "639",
|
|
527
|
+
red: "f00",
|
|
528
|
+
rosybrown: "bc8f8f",
|
|
529
|
+
royalblue: "4169e1",
|
|
530
|
+
saddlebrown: "8b4513",
|
|
531
|
+
salmon: "fa8072",
|
|
532
|
+
sandybrown: "f4a460",
|
|
533
|
+
seagreen: "2e8b57",
|
|
534
|
+
seashell: "fff5ee",
|
|
535
|
+
sienna: "a0522d",
|
|
536
|
+
silver: "c0c0c0",
|
|
537
|
+
skyblue: "87ceeb",
|
|
538
|
+
slateblue: "6a5acd",
|
|
539
|
+
slategray: "708090",
|
|
540
|
+
slategrey: "708090",
|
|
541
|
+
snow: "fffafa",
|
|
542
|
+
springgreen: "00ff7f",
|
|
543
|
+
steelblue: "4682b4",
|
|
544
|
+
tan: "d2b48c",
|
|
545
|
+
teal: "008080",
|
|
546
|
+
thistle: "d8bfd8",
|
|
547
|
+
tomato: "ff6347",
|
|
548
|
+
turquoise: "40e0d0",
|
|
549
|
+
violet: "ee82ee",
|
|
550
|
+
wheat: "f5deb3",
|
|
551
|
+
white: "fff",
|
|
552
|
+
whitesmoke: "f5f5f5",
|
|
553
|
+
yellow: "ff0",
|
|
554
|
+
yellowgreen: "9acd32"
|
|
555
|
+
};
|
|
556
|
+
function nameToHex(color) {
|
|
557
|
+
if (typeof color != "string") return color;
|
|
558
|
+
var normalizedColorName = color.toLowerCase();
|
|
559
|
+
return namedColorMap[normalizedColorName] ? "#" + namedColorMap[normalizedColorName] : color;
|
|
560
|
+
}
|
|
561
|
+
var hexRegex = /^#[a-fA-F0-9]{6}$/, hexRgbaRegex = /^#[a-fA-F0-9]{8}$/, reducedHexRegex = /^#[a-fA-F0-9]{3}$/, reducedRgbaHexRegex = /^#[a-fA-F0-9]{4}$/, rgbRegex = /^rgb\(\s*(\d{1,3})\s*(?:,)?\s*(\d{1,3})\s*(?:,)?\s*(\d{1,3})\s*\)$/i, rgbaRegex = /^rgb(?:a)?\(\s*(\d{1,3})\s*(?:,)?\s*(\d{1,3})\s*(?:,)?\s*(\d{1,3})\s*(?:,|\/)\s*([-+]?\d*[.]?\d+[%]?)\s*\)$/i, hslRegex = /^hsl\(\s*(\d{0,3}[.]?[0-9]+(?:deg)?)\s*(?:,)?\s*(\d{1,3}[.]?[0-9]?)%\s*(?:,)?\s*(\d{1,3}[.]?[0-9]?)%\s*\)$/i, hslaRegex = /^hsl(?:a)?\(\s*(\d{0,3}[.]?[0-9]+(?:deg)?)\s*(?:,)?\s*(\d{1,3}[.]?[0-9]?)%\s*(?:,)?\s*(\d{1,3}[.]?[0-9]?)%\s*(?:,|\/)\s*([-+]?\d*[.]?\d+[%]?)\s*\)$/i;
|
|
562
|
+
function parseToRgb(color) {
|
|
563
|
+
if (typeof color != "string")
|
|
564
|
+
throw new PolishedError(3);
|
|
565
|
+
var normalizedColor = nameToHex(color);
|
|
566
|
+
if (normalizedColor.match(hexRegex))
|
|
567
|
+
return {
|
|
568
|
+
red: parseInt("" + normalizedColor[1] + normalizedColor[2], 16),
|
|
569
|
+
green: parseInt("" + normalizedColor[3] + normalizedColor[4], 16),
|
|
570
|
+
blue: parseInt("" + normalizedColor[5] + normalizedColor[6], 16)
|
|
571
|
+
};
|
|
572
|
+
if (normalizedColor.match(hexRgbaRegex)) {
|
|
573
|
+
var alpha = parseFloat((parseInt("" + normalizedColor[7] + normalizedColor[8], 16) / 255).toFixed(2));
|
|
574
|
+
return {
|
|
575
|
+
red: parseInt("" + normalizedColor[1] + normalizedColor[2], 16),
|
|
576
|
+
green: parseInt("" + normalizedColor[3] + normalizedColor[4], 16),
|
|
577
|
+
blue: parseInt("" + normalizedColor[5] + normalizedColor[6], 16),
|
|
578
|
+
alpha
|
|
579
|
+
};
|
|
580
|
+
}
|
|
581
|
+
if (normalizedColor.match(reducedHexRegex))
|
|
582
|
+
return {
|
|
583
|
+
red: parseInt("" + normalizedColor[1] + normalizedColor[1], 16),
|
|
584
|
+
green: parseInt("" + normalizedColor[2] + normalizedColor[2], 16),
|
|
585
|
+
blue: parseInt("" + normalizedColor[3] + normalizedColor[3], 16)
|
|
586
|
+
};
|
|
587
|
+
if (normalizedColor.match(reducedRgbaHexRegex)) {
|
|
588
|
+
var _alpha = parseFloat((parseInt("" + normalizedColor[4] + normalizedColor[4], 16) / 255).toFixed(2));
|
|
589
|
+
return {
|
|
590
|
+
red: parseInt("" + normalizedColor[1] + normalizedColor[1], 16),
|
|
591
|
+
green: parseInt("" + normalizedColor[2] + normalizedColor[2], 16),
|
|
592
|
+
blue: parseInt("" + normalizedColor[3] + normalizedColor[3], 16),
|
|
593
|
+
alpha: _alpha
|
|
594
|
+
};
|
|
595
|
+
}
|
|
596
|
+
var rgbMatched = rgbRegex.exec(normalizedColor);
|
|
597
|
+
if (rgbMatched)
|
|
598
|
+
return {
|
|
599
|
+
red: parseInt("" + rgbMatched[1], 10),
|
|
600
|
+
green: parseInt("" + rgbMatched[2], 10),
|
|
601
|
+
blue: parseInt("" + rgbMatched[3], 10)
|
|
602
|
+
};
|
|
603
|
+
var rgbaMatched = rgbaRegex.exec(normalizedColor.substring(0, 50));
|
|
604
|
+
if (rgbaMatched)
|
|
605
|
+
return {
|
|
606
|
+
red: parseInt("" + rgbaMatched[1], 10),
|
|
607
|
+
green: parseInt("" + rgbaMatched[2], 10),
|
|
608
|
+
blue: parseInt("" + rgbaMatched[3], 10),
|
|
609
|
+
alpha: parseFloat("" + rgbaMatched[4]) > 1 ? parseFloat("" + rgbaMatched[4]) / 100 : parseFloat("" + rgbaMatched[4])
|
|
610
|
+
};
|
|
611
|
+
var hslMatched = hslRegex.exec(normalizedColor);
|
|
612
|
+
if (hslMatched) {
|
|
613
|
+
var hue = parseInt("" + hslMatched[1], 10), saturation = parseInt("" + hslMatched[2], 10) / 100, lightness = parseInt("" + hslMatched[3], 10) / 100, rgbColorString = "rgb(" + hslToRgb(hue, saturation, lightness) + ")", hslRgbMatched = rgbRegex.exec(rgbColorString);
|
|
614
|
+
if (!hslRgbMatched)
|
|
615
|
+
throw new PolishedError(4, normalizedColor, rgbColorString);
|
|
616
|
+
return {
|
|
617
|
+
red: parseInt("" + hslRgbMatched[1], 10),
|
|
618
|
+
green: parseInt("" + hslRgbMatched[2], 10),
|
|
619
|
+
blue: parseInt("" + hslRgbMatched[3], 10)
|
|
620
|
+
};
|
|
621
|
+
}
|
|
622
|
+
var hslaMatched = hslaRegex.exec(normalizedColor.substring(0, 50));
|
|
623
|
+
if (hslaMatched) {
|
|
624
|
+
var _hue = parseInt("" + hslaMatched[1], 10), _saturation = parseInt("" + hslaMatched[2], 10) / 100, _lightness = parseInt("" + hslaMatched[3], 10) / 100, _rgbColorString = "rgb(" + hslToRgb(_hue, _saturation, _lightness) + ")", _hslRgbMatched = rgbRegex.exec(_rgbColorString);
|
|
625
|
+
if (!_hslRgbMatched)
|
|
626
|
+
throw new PolishedError(4, normalizedColor, _rgbColorString);
|
|
627
|
+
return {
|
|
628
|
+
red: parseInt("" + _hslRgbMatched[1], 10),
|
|
629
|
+
green: parseInt("" + _hslRgbMatched[2], 10),
|
|
630
|
+
blue: parseInt("" + _hslRgbMatched[3], 10),
|
|
631
|
+
alpha: parseFloat("" + hslaMatched[4]) > 1 ? parseFloat("" + hslaMatched[4]) / 100 : parseFloat("" + hslaMatched[4])
|
|
632
|
+
};
|
|
633
|
+
}
|
|
634
|
+
throw new PolishedError(5);
|
|
635
|
+
}
|
|
636
|
+
function rgbToHsl(color) {
|
|
637
|
+
var red = color.red / 255, green = color.green / 255, blue = color.blue / 255, max = Math.max(red, green, blue), min = Math.min(red, green, blue), lightness = (max + min) / 2;
|
|
638
|
+
if (max === min)
|
|
639
|
+
return color.alpha !== void 0 ? {
|
|
640
|
+
hue: 0,
|
|
641
|
+
saturation: 0,
|
|
642
|
+
lightness,
|
|
643
|
+
alpha: color.alpha
|
|
644
|
+
} : {
|
|
645
|
+
hue: 0,
|
|
646
|
+
saturation: 0,
|
|
647
|
+
lightness
|
|
648
|
+
};
|
|
649
|
+
var hue, delta = max - min, saturation = lightness > 0.5 ? delta / (2 - max - min) : delta / (max + min);
|
|
650
|
+
switch (max) {
|
|
651
|
+
case red:
|
|
652
|
+
hue = (green - blue) / delta + (green < blue ? 6 : 0);
|
|
653
|
+
break;
|
|
654
|
+
case green:
|
|
655
|
+
hue = (blue - red) / delta + 2;
|
|
656
|
+
break;
|
|
657
|
+
default:
|
|
658
|
+
hue = (red - green) / delta + 4;
|
|
659
|
+
break;
|
|
660
|
+
}
|
|
661
|
+
return hue *= 60, color.alpha !== void 0 ? {
|
|
662
|
+
hue,
|
|
663
|
+
saturation,
|
|
664
|
+
lightness,
|
|
665
|
+
alpha: color.alpha
|
|
666
|
+
} : {
|
|
667
|
+
hue,
|
|
668
|
+
saturation,
|
|
669
|
+
lightness
|
|
670
|
+
};
|
|
671
|
+
}
|
|
672
|
+
function parseToHsl(color) {
|
|
673
|
+
return rgbToHsl(parseToRgb(color));
|
|
674
|
+
}
|
|
675
|
+
var reduceHexValue = function(value) {
|
|
676
|
+
return value.length === 7 && value[1] === value[2] && value[3] === value[4] && value[5] === value[6] ? "#" + value[1] + value[3] + value[5] : value;
|
|
677
|
+
}, reduceHexValue$1 = reduceHexValue;
|
|
678
|
+
function numberToHex(value) {
|
|
679
|
+
var hex = value.toString(16);
|
|
680
|
+
return hex.length === 1 ? "0" + hex : hex;
|
|
681
|
+
}
|
|
682
|
+
function colorToHex(color) {
|
|
683
|
+
return numberToHex(Math.round(color * 255));
|
|
684
|
+
}
|
|
685
|
+
function convertToHex(red, green, blue) {
|
|
686
|
+
return reduceHexValue$1("#" + colorToHex(red) + colorToHex(green) + colorToHex(blue));
|
|
687
|
+
}
|
|
688
|
+
function hslToHex(hue, saturation, lightness) {
|
|
689
|
+
return hslToRgb(hue, saturation, lightness, convertToHex);
|
|
690
|
+
}
|
|
691
|
+
function hsl(value, saturation, lightness) {
|
|
692
|
+
if (typeof value == "number" && typeof saturation == "number" && typeof lightness == "number")
|
|
693
|
+
return hslToHex(value, saturation, lightness);
|
|
694
|
+
if (typeof value == "object" && saturation === void 0 && lightness === void 0)
|
|
695
|
+
return hslToHex(value.hue, value.saturation, value.lightness);
|
|
696
|
+
throw new PolishedError(1);
|
|
697
|
+
}
|
|
698
|
+
function hsla(value, saturation, lightness, alpha) {
|
|
699
|
+
if (typeof value == "number" && typeof saturation == "number" && typeof lightness == "number" && typeof alpha == "number")
|
|
700
|
+
return alpha >= 1 ? hslToHex(value, saturation, lightness) : "rgba(" + hslToRgb(value, saturation, lightness) + "," + alpha + ")";
|
|
701
|
+
if (typeof value == "object" && saturation === void 0 && lightness === void 0 && alpha === void 0)
|
|
702
|
+
return value.alpha >= 1 ? hslToHex(value.hue, value.saturation, value.lightness) : "rgba(" + hslToRgb(value.hue, value.saturation, value.lightness) + "," + value.alpha + ")";
|
|
703
|
+
throw new PolishedError(2);
|
|
704
|
+
}
|
|
705
|
+
function rgb(value, green, blue) {
|
|
706
|
+
if (typeof value == "number" && typeof green == "number" && typeof blue == "number")
|
|
707
|
+
return reduceHexValue$1("#" + numberToHex(value) + numberToHex(green) + numberToHex(blue));
|
|
708
|
+
if (typeof value == "object" && green === void 0 && blue === void 0)
|
|
709
|
+
return reduceHexValue$1("#" + numberToHex(value.red) + numberToHex(value.green) + numberToHex(value.blue));
|
|
710
|
+
throw new PolishedError(6);
|
|
711
|
+
}
|
|
712
|
+
function rgba(firstValue, secondValue, thirdValue, fourthValue) {
|
|
713
|
+
if (typeof firstValue == "string" && typeof secondValue == "number") {
|
|
714
|
+
var rgbValue = parseToRgb(firstValue);
|
|
715
|
+
return "rgba(" + rgbValue.red + "," + rgbValue.green + "," + rgbValue.blue + "," + secondValue + ")";
|
|
716
|
+
} else {
|
|
717
|
+
if (typeof firstValue == "number" && typeof secondValue == "number" && typeof thirdValue == "number" && typeof fourthValue == "number")
|
|
718
|
+
return fourthValue >= 1 ? rgb(firstValue, secondValue, thirdValue) : "rgba(" + firstValue + "," + secondValue + "," + thirdValue + "," + fourthValue + ")";
|
|
719
|
+
if (typeof firstValue == "object" && secondValue === void 0 && thirdValue === void 0 && fourthValue === void 0)
|
|
720
|
+
return firstValue.alpha >= 1 ? rgb(firstValue.red, firstValue.green, firstValue.blue) : "rgba(" + firstValue.red + "," + firstValue.green + "," + firstValue.blue + "," + firstValue.alpha + ")";
|
|
721
|
+
}
|
|
722
|
+
throw new PolishedError(7);
|
|
723
|
+
}
|
|
724
|
+
var isRgb = function(color) {
|
|
725
|
+
return typeof color.red == "number" && typeof color.green == "number" && typeof color.blue == "number" && (typeof color.alpha != "number" || typeof color.alpha > "u");
|
|
726
|
+
}, isRgba = function(color) {
|
|
727
|
+
return typeof color.red == "number" && typeof color.green == "number" && typeof color.blue == "number" && typeof color.alpha == "number";
|
|
728
|
+
}, isHsl = function(color) {
|
|
729
|
+
return typeof color.hue == "number" && typeof color.saturation == "number" && typeof color.lightness == "number" && (typeof color.alpha != "number" || typeof color.alpha > "u");
|
|
730
|
+
}, isHsla = function(color) {
|
|
731
|
+
return typeof color.hue == "number" && typeof color.saturation == "number" && typeof color.lightness == "number" && typeof color.alpha == "number";
|
|
732
|
+
};
|
|
733
|
+
function toColorString(color) {
|
|
734
|
+
if (typeof color != "object") throw new PolishedError(8);
|
|
735
|
+
if (isRgba(color)) return rgba(color);
|
|
736
|
+
if (isRgb(color)) return rgb(color);
|
|
737
|
+
if (isHsla(color)) return hsla(color);
|
|
738
|
+
if (isHsl(color)) return hsl(color);
|
|
739
|
+
throw new PolishedError(8);
|
|
740
|
+
}
|
|
741
|
+
function curried(f, length, acc) {
|
|
742
|
+
return function() {
|
|
743
|
+
var combined = acc.concat(Array.prototype.slice.call(arguments));
|
|
744
|
+
return combined.length >= length ? f.apply(this, combined) : curried(f, length, combined);
|
|
745
|
+
};
|
|
746
|
+
}
|
|
747
|
+
function curry(f) {
|
|
748
|
+
return curried(f, f.length, []);
|
|
749
|
+
}
|
|
750
|
+
function adjustHue(degree, color) {
|
|
751
|
+
if (color === "transparent") return color;
|
|
752
|
+
var hslColor = parseToHsl(color);
|
|
753
|
+
return toColorString(_extends({}, hslColor, {
|
|
754
|
+
hue: hslColor.hue + parseFloat(degree)
|
|
755
|
+
}));
|
|
756
|
+
}
|
|
757
|
+
var curriedAdjustHue = curry(adjustHue);
|
|
758
|
+
function guard(lowerBoundary, upperBoundary, value) {
|
|
759
|
+
return Math.max(lowerBoundary, Math.min(upperBoundary, value));
|
|
760
|
+
}
|
|
761
|
+
function darken(amount, color) {
|
|
762
|
+
if (color === "transparent") return color;
|
|
763
|
+
var hslColor = parseToHsl(color);
|
|
764
|
+
return toColorString(_extends({}, hslColor, {
|
|
765
|
+
lightness: guard(0, 1, hslColor.lightness - parseFloat(amount))
|
|
766
|
+
}));
|
|
767
|
+
}
|
|
768
|
+
var curriedDarken = curry(darken), curriedDarken$1 = curriedDarken;
|
|
769
|
+
function desaturate(amount, color) {
|
|
770
|
+
if (color === "transparent") return color;
|
|
771
|
+
var hslColor = parseToHsl(color);
|
|
772
|
+
return toColorString(_extends({}, hslColor, {
|
|
773
|
+
saturation: guard(0, 1, hslColor.saturation - parseFloat(amount))
|
|
774
|
+
}));
|
|
775
|
+
}
|
|
776
|
+
var curriedDesaturate = curry(desaturate);
|
|
777
|
+
function lighten(amount, color) {
|
|
778
|
+
if (color === "transparent") return color;
|
|
779
|
+
var hslColor = parseToHsl(color);
|
|
780
|
+
return toColorString(_extends({}, hslColor, {
|
|
781
|
+
lightness: guard(0, 1, hslColor.lightness + parseFloat(amount))
|
|
782
|
+
}));
|
|
783
|
+
}
|
|
784
|
+
var curriedLighten = curry(lighten), curriedLighten$1 = curriedLighten;
|
|
785
|
+
function mix(weight, color, otherColor) {
|
|
786
|
+
if (color === "transparent") return otherColor;
|
|
787
|
+
if (otherColor === "transparent") return color;
|
|
788
|
+
if (weight === 0) return otherColor;
|
|
789
|
+
var parsedColor1 = parseToRgb(color), color1 = _extends({}, parsedColor1, {
|
|
790
|
+
alpha: typeof parsedColor1.alpha == "number" ? parsedColor1.alpha : 1
|
|
791
|
+
}), parsedColor2 = parseToRgb(otherColor), color2 = _extends({}, parsedColor2, {
|
|
792
|
+
alpha: typeof parsedColor2.alpha == "number" ? parsedColor2.alpha : 1
|
|
793
|
+
}), alphaDelta = color1.alpha - color2.alpha, x = parseFloat(weight) * 2 - 1, y = x * alphaDelta === -1 ? x : x + alphaDelta, z = 1 + x * alphaDelta, weight1 = (y / z + 1) / 2, weight2 = 1 - weight1, mixedColor = {
|
|
794
|
+
red: Math.floor(color1.red * weight1 + color2.red * weight2),
|
|
795
|
+
green: Math.floor(color1.green * weight1 + color2.green * weight2),
|
|
796
|
+
blue: Math.floor(color1.blue * weight1 + color2.blue * weight2),
|
|
797
|
+
alpha: color1.alpha * parseFloat(weight) + color2.alpha * (1 - parseFloat(weight))
|
|
798
|
+
};
|
|
799
|
+
return rgba(mixedColor);
|
|
800
|
+
}
|
|
801
|
+
var curriedMix = curry(mix), mix$1 = curriedMix;
|
|
802
|
+
function opacify(amount, color) {
|
|
803
|
+
if (color === "transparent") return color;
|
|
804
|
+
var parsedColor = parseToRgb(color), alpha = typeof parsedColor.alpha == "number" ? parsedColor.alpha : 1, colorWithAlpha = _extends({}, parsedColor, {
|
|
805
|
+
alpha: guard(0, 1, (alpha * 100 + parseFloat(amount) * 100) / 100)
|
|
806
|
+
});
|
|
807
|
+
return rgba(colorWithAlpha);
|
|
808
|
+
}
|
|
809
|
+
var curriedOpacify = curry(opacify), curriedOpacify$1 = curriedOpacify;
|
|
810
|
+
function saturate(amount, color) {
|
|
811
|
+
if (color === "transparent") return color;
|
|
812
|
+
var hslColor = parseToHsl(color);
|
|
813
|
+
return toColorString(_extends({}, hslColor, {
|
|
814
|
+
saturation: guard(0, 1, hslColor.saturation + parseFloat(amount))
|
|
815
|
+
}));
|
|
816
|
+
}
|
|
817
|
+
var curriedSaturate = curry(saturate);
|
|
818
|
+
function setHue(hue, color) {
|
|
819
|
+
return color === "transparent" ? color : toColorString(_extends({}, parseToHsl(color), {
|
|
820
|
+
hue: parseFloat(hue)
|
|
821
|
+
}));
|
|
822
|
+
}
|
|
823
|
+
var curriedSetHue = curry(setHue);
|
|
824
|
+
function setLightness(lightness, color) {
|
|
825
|
+
return color === "transparent" ? color : toColorString(_extends({}, parseToHsl(color), {
|
|
826
|
+
lightness: parseFloat(lightness)
|
|
827
|
+
}));
|
|
828
|
+
}
|
|
829
|
+
var curriedSetLightness = curry(setLightness);
|
|
830
|
+
function setSaturation(saturation, color) {
|
|
831
|
+
return color === "transparent" ? color : toColorString(_extends({}, parseToHsl(color), {
|
|
832
|
+
saturation: parseFloat(saturation)
|
|
833
|
+
}));
|
|
834
|
+
}
|
|
835
|
+
var curriedSetSaturation = curry(setSaturation);
|
|
836
|
+
function shade(percentage, color) {
|
|
837
|
+
return color === "transparent" ? color : mix$1(parseFloat(percentage), "rgb(0, 0, 0)", color);
|
|
838
|
+
}
|
|
839
|
+
var curriedShade = curry(shade);
|
|
840
|
+
function tint(percentage, color) {
|
|
841
|
+
return color === "transparent" ? color : mix$1(parseFloat(percentage), "rgb(255, 255, 255)", color);
|
|
842
|
+
}
|
|
843
|
+
var curriedTint = curry(tint);
|
|
844
|
+
function transparentize(amount, color) {
|
|
845
|
+
if (color === "transparent") return color;
|
|
846
|
+
var parsedColor = parseToRgb(color), alpha = typeof parsedColor.alpha == "number" ? parsedColor.alpha : 1, colorWithAlpha = _extends({}, parsedColor, {
|
|
847
|
+
alpha: guard(0, 1, +(alpha * 100 - parseFloat(amount) * 100).toFixed(2) / 100)
|
|
848
|
+
});
|
|
849
|
+
return rgba(colorWithAlpha);
|
|
850
|
+
}
|
|
851
|
+
var curriedTransparentize = curry(transparentize), curriedTransparentize$1 = curriedTransparentize;
|
|
852
|
+
|
|
853
|
+
// src/blocks/components/EmptyBlock.tsx
|
|
854
|
+
import { styled } from "storybook/theming";
|
|
855
|
+
var Wrapper = styled.div(withReset, ({ theme }) => ({
|
|
856
|
+
backgroundColor: theme.base === "light" ? "rgba(0,0,0,.01)" : "rgba(255,255,255,.01)",
|
|
857
|
+
borderRadius: theme.appBorderRadius,
|
|
858
|
+
border: `1px dashed ${theme.appBorderColor}`,
|
|
859
|
+
display: "flex",
|
|
860
|
+
alignItems: "center",
|
|
861
|
+
justifyContent: "center",
|
|
862
|
+
padding: 20,
|
|
863
|
+
margin: "25px 0 40px",
|
|
864
|
+
color: curriedTransparentize$1(0.3, theme.color.defaultText),
|
|
865
|
+
fontSize: theme.typography.size.s2
|
|
866
|
+
})), EmptyBlock = (props) => React.createElement(Wrapper, { ...props, className: "docblock-emptyblock sb-unstyled" });
|
|
867
|
+
|
|
868
|
+
// src/blocks/components/Source.tsx
|
|
869
|
+
var StyledSyntaxHighlighter = styled2(
|
|
870
|
+
SyntaxHighlighter
|
|
871
|
+
)(({ theme }) => ({
|
|
872
|
+
// DocBlocks-specific styling and overrides
|
|
873
|
+
fontSize: `${theme.typography.size.s2 - 1}px`,
|
|
874
|
+
lineHeight: "19px",
|
|
875
|
+
margin: "25px 0 40px",
|
|
876
|
+
borderRadius: theme.appBorderRadius,
|
|
877
|
+
boxShadow: theme.base === "light" ? "rgba(0, 0, 0, 0.10) 0 1px 3px 0" : "rgba(0, 0, 0, 0.20) 0 2px 5px 0",
|
|
878
|
+
"pre.prismjs": {
|
|
879
|
+
padding: 20,
|
|
880
|
+
background: "inherit"
|
|
881
|
+
}
|
|
882
|
+
}));
|
|
883
|
+
var SourceSkeletonWrapper = styled2.div(({ theme }) => ({
|
|
884
|
+
background: theme.background.content,
|
|
885
|
+
borderRadius: theme.appBorderRadius,
|
|
886
|
+
border: `1px solid ${theme.appBorderColor}`,
|
|
887
|
+
boxShadow: theme.base === "light" ? "rgba(0, 0, 0, 0.10) 0 1px 3px 0" : "rgba(0, 0, 0, 0.20) 0 2px 5px 0",
|
|
888
|
+
margin: "25px 0 40px",
|
|
889
|
+
padding: "20px 20px 20px 22px"
|
|
890
|
+
})), SourceSkeletonPlaceholder = styled2.div(({ theme }) => ({
|
|
891
|
+
animation: `${theme.animation.glow} 1.5s ease-in-out infinite`,
|
|
892
|
+
background: theme.appBorderColor,
|
|
893
|
+
height: 17,
|
|
894
|
+
marginTop: 1,
|
|
895
|
+
width: "60%",
|
|
896
|
+
[`&:first-child${ignoreSsrWarning}`]: {
|
|
897
|
+
margin: 0
|
|
898
|
+
}
|
|
899
|
+
})), SourceSkeleton = () => React2.createElement(SourceSkeletonWrapper, null, React2.createElement(SourceSkeletonPlaceholder, null), React2.createElement(SourceSkeletonPlaceholder, { style: { width: "80%" } }), React2.createElement(SourceSkeletonPlaceholder, { style: { width: "30%" } }), React2.createElement(SourceSkeletonPlaceholder, { style: { width: "80%" } })), Source = ({
|
|
900
|
+
isLoading,
|
|
901
|
+
error,
|
|
902
|
+
language,
|
|
903
|
+
code,
|
|
904
|
+
dark,
|
|
905
|
+
format: format2 = !0,
|
|
906
|
+
...rest
|
|
907
|
+
}) => {
|
|
908
|
+
let { typography } = useTheme();
|
|
909
|
+
if (isLoading)
|
|
910
|
+
return React2.createElement(SourceSkeleton, null);
|
|
911
|
+
if (error)
|
|
912
|
+
return React2.createElement(EmptyBlock, null, error);
|
|
913
|
+
let syntaxHighlighter = React2.createElement(
|
|
914
|
+
StyledSyntaxHighlighter,
|
|
915
|
+
{
|
|
916
|
+
bordered: !0,
|
|
917
|
+
copyable: !0,
|
|
918
|
+
format: format2,
|
|
919
|
+
language: language ?? "jsx",
|
|
920
|
+
className: "docblock-source sb-unstyled",
|
|
921
|
+
...rest
|
|
922
|
+
},
|
|
923
|
+
code
|
|
924
|
+
);
|
|
925
|
+
if (typeof dark > "u")
|
|
926
|
+
return syntaxHighlighter;
|
|
927
|
+
let overrideTheme = dark ? themes.dark : themes.light;
|
|
928
|
+
return React2.createElement(
|
|
929
|
+
ThemeProvider,
|
|
930
|
+
{
|
|
931
|
+
theme: convert({
|
|
932
|
+
...overrideTheme,
|
|
933
|
+
fontCode: typography.fonts.mono,
|
|
934
|
+
fontBase: typography.fonts.base
|
|
935
|
+
})
|
|
936
|
+
},
|
|
937
|
+
syntaxHighlighter
|
|
938
|
+
);
|
|
939
|
+
};
|
|
940
|
+
|
|
941
|
+
export {
|
|
942
|
+
rgba,
|
|
943
|
+
curriedDarken$1,
|
|
944
|
+
curriedLighten$1,
|
|
945
|
+
curriedOpacify$1,
|
|
946
|
+
curriedTransparentize$1,
|
|
947
|
+
EmptyBlock,
|
|
948
|
+
Source
|
|
949
|
+
};
|