smoothly 0.1.84 → 0.1.85

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.
@@ -1555,7 +1555,7 @@ var Symmetric;
1555
1555
  Symmetric.is = is;
1556
1556
  })(Symmetric || (Symmetric = {}));
1557
1557
 
1558
- var Name$3;
1558
+ var Name$4;
1559
1559
  (function (Name) {
1560
1560
  function is(value) {
1561
1561
  return value == "none" || Symmetric.is(value) || Asymmetric.is(value);
@@ -1569,7 +1569,7 @@ var Name$3;
1569
1569
  (function (Asymmetric$1) {
1570
1570
  Asymmetric$1.is = Asymmetric.is;
1571
1571
  })(Asymmetric$1 = Name.Asymmetric || (Name.Asymmetric = {}));
1572
- })(Name$3 || (Name$3 = {}));
1572
+ })(Name$4 || (Name$4 = {}));
1573
1573
 
1574
1574
  var __awaiter$2 = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
1575
1575
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
@@ -1681,14 +1681,14 @@ class Algorithm {
1681
1681
  (function (Algorithm) {
1682
1682
  let Name;
1683
1683
  (function (Name) {
1684
- Name.is = Name$3.is;
1684
+ Name.is = Name$4.is;
1685
1685
  let Symmetric;
1686
1686
  (function (Symmetric) {
1687
- Symmetric.is = Name$3.Symmetric.is;
1687
+ Symmetric.is = Name$4.Symmetric.is;
1688
1688
  })(Symmetric = Name.Symmetric || (Name.Symmetric = {}));
1689
1689
  let Asymmetric;
1690
1690
  (function (Asymmetric) {
1691
- Asymmetric.is = Name$3.Asymmetric.is;
1691
+ Asymmetric.is = Name$4.Asymmetric.is;
1692
1692
  })(Asymmetric = Name.Asymmetric || (Name.Asymmetric = {}));
1693
1693
  })(Name = Algorithm.Name || (Algorithm.Name = {}));
1694
1694
  })(Algorithm || (Algorithm = {}));
@@ -1989,7 +1989,52 @@ class Trigger {
1989
1989
  }
1990
1990
  }
1991
1991
 
1992
- const colorNames = {
1992
+ var Hex;
1993
+ (function (Hex) {
1994
+ function is(value) {
1995
+ const matchArray = (typeof value == "string" && value.match(/[0-9a-fA-F]/g)) || undefined;
1996
+ return (typeof value == "string" &&
1997
+ value.length > 3 &&
1998
+ value[0] == "#" &&
1999
+ ((matchArray === null || matchArray === void 0 ? void 0 : matchArray.length) == 3 || (matchArray === null || matchArray === void 0 ? void 0 : matchArray.length) == 6));
2000
+ }
2001
+ Hex.is = is;
2002
+ })(Hex || (Hex = {}));
2003
+
2004
+ var Hsl;
2005
+ (function (Hsl) {
2006
+ function is(value) {
2007
+ const values = typeof value == "string" && value.length > 11 ? value.substring(4, value.length - 1).split(",") : [];
2008
+ return (typeof value == "string" &&
2009
+ value.length > 11 &&
2010
+ value.substr(0, 4) == "hsl(" &&
2011
+ value.substr(value.length - 1, 1) == ")" &&
2012
+ values.length == 3 &&
2013
+ values.every((single, index) => {
2014
+ var _a, _b;
2015
+ let result = false;
2016
+ if (index == 0)
2017
+ result =
2018
+ !Number.isNaN(single) &&
2019
+ ((_a = single.match(/[0-9]/g)) === null || _a === void 0 ? void 0 : _a.length) == single.length &&
2020
+ Number(single) >= 0 &&
2021
+ Number(single) <= 360;
2022
+ else {
2023
+ const number = single.substr(0, single.length - 1);
2024
+ result =
2025
+ single[single.length - 1] == "%" &&
2026
+ !Number.isNaN(number) &&
2027
+ ((_b = number.match(/[0-9]/g)) === null || _b === void 0 ? void 0 : _b.length) == number.length &&
2028
+ Number(number) >= 0 &&
2029
+ Number(number) <= 100;
2030
+ }
2031
+ return result;
2032
+ }));
2033
+ }
2034
+ Hsl.is = is;
2035
+ })(Hsl || (Hsl = {}));
2036
+
2037
+ const Names = {
1993
2038
  aliceblue: "#f0f8ff",
1994
2039
  antiquewhite: "#faebd7",
1995
2040
  aqua: "#00ffff",
@@ -2139,126 +2184,180 @@ const colorNames = {
2139
2184
  yellow: "#ffff00",
2140
2185
  yellowgreen: "#9acd32",
2141
2186
  };
2187
+ var Name$3;
2188
+ (function (Name) {
2189
+ Name.types = () => Object.keys(Names);
2190
+ function is(value) {
2191
+ return typeof value == "string" && Name.types().includes(value.toLowerCase());
2192
+ }
2193
+ Name.is = is;
2194
+ })(Name$3 || (Name$3 = {}));
2142
2195
 
2143
- function toCommaRgb(color) {
2144
- let result;
2145
- const colorWithoutSpace = color.replace(/ /g, "").toLowerCase();
2146
- if (isCommaRgb(colorWithoutSpace))
2147
- result = colorWithoutSpace;
2148
- else if (isHex(colorWithoutSpace))
2149
- result = hexToCommaRgb(colorWithoutSpace);
2150
- else if (isRgb(colorWithoutSpace))
2151
- result = rgbToCommaRgb(colorWithoutSpace);
2152
- else if (colorWithoutSpace in colorNames)
2153
- result = hexToCommaRgb(colorNames[colorWithoutSpace]);
2154
- else if (isHsl(colorWithoutSpace))
2155
- result = hslToCommaRgb(colorWithoutSpace);
2156
- return result;
2157
- }
2158
- function isCommaRgb(commaRgb) {
2159
- const values = commaRgb.split(",");
2160
- return (values.length == 3 &&
2161
- values.every(value => {
2162
- var _a;
2163
- return !Number.isNaN(value) &&
2164
- ((_a = value.match(/[0-9]/g)) === null || _a === void 0 ? void 0 : _a.length) == value.length &&
2165
- Number(value) >= 0 &&
2166
- Number(value) <= 255;
2167
- }));
2168
- }
2169
- function isHex(hex) {
2170
- const matchArray = hex.match(/[0-9a-fA-F]/g);
2171
- return hex[0] == "#" && ((matchArray === null || matchArray === void 0 ? void 0 : matchArray.length) == 3 || (matchArray === null || matchArray === void 0 ? void 0 : matchArray.length) == 6);
2172
- }
2173
- function hexToCommaRgb(hex) {
2174
- let result = "0,0,0";
2175
- if (hex.length == 7)
2176
- result = `${parseInt(hex.substr(1, 2), 16)},${parseInt(hex.substr(3, 2), 16)},${parseInt(hex.substr(5, 2), 16)}`;
2177
- else if (hex.length == 4)
2178
- result = hexToCommaRgb(`#${hex[1]}${hex[1]}${hex[2]}${hex[2]}${hex[3]}${hex[3]}`);
2179
- return result;
2180
- }
2181
- function isRgb(rgb) {
2182
- const values = rgb.substring(4, rgb.length - 1).split(",");
2183
- return (rgb.substr(0, 4) == "rgb(" &&
2184
- rgb.substr(rgb.length - 1, 1) == ")" &&
2185
- values.length == 3 &&
2186
- values.every(value => {
2187
- var _a;
2188
- return !Number.isNaN(value) &&
2189
- ((_a = value.match(/[0-9]/g)) === null || _a === void 0 ? void 0 : _a.length) == value.length &&
2190
- Number(value) >= 0 &&
2191
- Number(value) <= 255;
2192
- }));
2193
- }
2194
- function rgbToCommaRgb(rgb) {
2195
- return rgb.substring(4, rgb.length - 1);
2196
- }
2197
- function isHsl(hsl) {
2198
- const values = hsl.substring(4, hsl.length - 1).split(",");
2199
- return (hsl.substr(0, 4) == "hsl(" &&
2200
- hsl.substr(hsl.length - 1, 1) == ")" &&
2201
- values.length == 3 &&
2202
- values.every((value, index) => {
2203
- var _a, _b;
2204
- let result = false;
2205
- if (index == 0)
2206
- result =
2207
- !Number.isNaN(value) &&
2208
- ((_a = value.match(/[0-9]/g)) === null || _a === void 0 ? void 0 : _a.length) == value.length &&
2209
- Number(value) >= 0 &&
2210
- Number(value) <= 360;
2196
+ var Rgb;
2197
+ (function (Rgb) {
2198
+ function is(value) {
2199
+ const values = typeof value == "string" && value.length > 9 ? value.substring(4, value.length - 1).split(",") : [];
2200
+ return (typeof value == "string" &&
2201
+ value.length > 9 &&
2202
+ value.substr(0, 4) == "rgb(" &&
2203
+ value.substr(value.length - 1, 1) == ")" &&
2204
+ values.length == 3 &&
2205
+ values.every((value) => {
2206
+ var _a;
2207
+ return !Number.isNaN(value) &&
2208
+ ((_a = value.match(/[0-9]/g)) === null || _a === void 0 ? void 0 : _a.length) == value.length &&
2209
+ Number(value) >= 0 &&
2210
+ Number(value) <= 255;
2211
+ }));
2212
+ }
2213
+ Rgb.is = is;
2214
+ })(Rgb || (Rgb = {}));
2215
+
2216
+ var CommaRgb;
2217
+ (function (CommaRgb) {
2218
+ function is(value) {
2219
+ const values = typeof value == "string" ? value.split(",") : [];
2220
+ return (values.length == 3 &&
2221
+ values.every((value) => {
2222
+ var _a;
2223
+ return !Number.isNaN(value) &&
2224
+ ((_a = value.match(/[0-9]/g)) === null || _a === void 0 ? void 0 : _a.length) == value.length &&
2225
+ Number(value) >= 0 &&
2226
+ Number(value) <= 255;
2227
+ }));
2228
+ }
2229
+ CommaRgb.is = is;
2230
+ function from(color) {
2231
+ let result;
2232
+ const colorWithoutSpace = typeof color == "string" ? color.replace(/ /g, "").toLowerCase() : undefined;
2233
+ if (!colorWithoutSpace)
2234
+ result = undefined;
2235
+ else if (CommaRgb.is(colorWithoutSpace))
2236
+ result = colorWithoutSpace;
2237
+ else if (Hex.is(colorWithoutSpace))
2238
+ result = fromHex(colorWithoutSpace);
2239
+ else if (Rgb.is(colorWithoutSpace))
2240
+ result = fromRgb(colorWithoutSpace);
2241
+ else if (Name$3.is(colorWithoutSpace))
2242
+ result = fromHex(Names[colorWithoutSpace]);
2243
+ else if (Hsl.is(colorWithoutSpace))
2244
+ result = fromHsl(colorWithoutSpace);
2245
+ return result;
2246
+ }
2247
+ CommaRgb.from = from;
2248
+ function fromHex(hex) {
2249
+ let result = "0,0,0";
2250
+ if (hex.length == 7)
2251
+ result = `${parseInt(hex.substr(1, 2), 16)},${parseInt(hex.substr(3, 2), 16)},${parseInt(hex.substr(5, 2), 16)}`;
2252
+ else if (hex.length == 4)
2253
+ result = fromHex(`#${hex[1]}${hex[1]}${hex[2]}${hex[2]}${hex[3]}${hex[3]}`);
2254
+ return result;
2255
+ }
2256
+ CommaRgb.fromHex = fromHex;
2257
+ function fromRgb(rgb) {
2258
+ return rgb.substring(4, rgb.length - 1);
2259
+ }
2260
+ CommaRgb.fromRgb = fromRgb;
2261
+ function fromHsl(hsl) {
2262
+ let result = "";
2263
+ let h, s, l;
2264
+ let r, g, b;
2265
+ const HSL = hsl
2266
+ .substring(4, hsl.length - 1)
2267
+ .split(",")
2268
+ .map((value, index) => Number(index == 0 ? value : value.substr(0, value.length - 1)));
2269
+ if (HSL.length == 3) {
2270
+ h = HSL[0] / 360;
2271
+ s = HSL[1] / 100;
2272
+ l = HSL[2] / 100;
2273
+ if (s == 0)
2274
+ r = g = b = l;
2211
2275
  else {
2212
- const number = value.substr(0, value.length - 1);
2213
- result =
2214
- value[value.length - 1] == "%" &&
2215
- !Number.isNaN(number) &&
2216
- ((_b = number.match(/[0-9]/g)) === null || _b === void 0 ? void 0 : _b.length) == number.length &&
2217
- Number(number) >= 0 &&
2218
- Number(number) <= 100;
2276
+ const q = l < 0.5 ? l * (1 + s) : l + s - l * s;
2277
+ const p = 2 * l - q;
2278
+ r = hue2rgb(p, q, h + 1 / 3);
2279
+ g = hue2rgb(p, q, h);
2280
+ b = hue2rgb(p, q, h - 1 / 3);
2219
2281
  }
2220
- return result;
2221
- }));
2222
- }
2223
- function hue2rgb(p, q, t) {
2224
- let result = p;
2225
- if (t < 0)
2226
- t += 1;
2227
- if (t > 1)
2228
- t -= 1;
2229
- if (t < 1 / 6)
2230
- result = p + (q - p) * 6 * t;
2231
- else if (t < 1 / 2)
2232
- result = q;
2233
- else if (t < 2 / 3)
2234
- result = p + (q - p) * (2 / 3 - t) * 6;
2235
- return result;
2236
- }
2237
- function hslToCommaRgb(hsl) {
2238
- let result;
2239
- let h, s, l;
2240
- let r, g, b;
2241
- const HSL = hsl
2242
- .substring(4, hsl.length - 1)
2243
- .split(",")
2244
- .map((value, index) => Number(index == 0 ? value : value.substr(0, value.length - 1)));
2245
- if (HSL.length == 3) {
2246
- h = HSL[0] / 360;
2247
- s = HSL[1] / 100;
2248
- l = HSL[2] / 100;
2249
- if (s == 0)
2250
- r = g = b = l;
2251
- else {
2252
- const q = l < 0.5 ? l * (1 + s) : l + s - l * s;
2253
- const p = 2 * l - q;
2254
- r = hue2rgb(p, q, h + 1 / 3);
2255
- g = hue2rgb(p, q, h);
2256
- b = hue2rgb(p, q, h - 1 / 3);
2282
+ result = `${Math.round(255 * r)},${Math.round(255 * g)},${Math.round(255 * b)}`;
2257
2283
  }
2258
- result = `${Math.round(255 * r)},${Math.round(255 * g)},${Math.round(255 * b)}`;
2284
+ return result;
2259
2285
  }
2260
- return result;
2261
- }
2286
+ CommaRgb.fromHsl = fromHsl;
2287
+ function hue2rgb(p, q, t) {
2288
+ let result = p;
2289
+ if (t < 0)
2290
+ t += 1;
2291
+ if (t > 1)
2292
+ t -= 1;
2293
+ if (t < 1 / 6)
2294
+ result = p + (q - p) * 6 * t;
2295
+ else if (t < 1 / 2)
2296
+ result = q;
2297
+ else if (t < 2 / 3)
2298
+ result = p + (q - p) * (2 / 3 - t) * 6;
2299
+ return result;
2300
+ }
2301
+ })(CommaRgb || (CommaRgb = {}));
2302
+
2303
+ var Color;
2304
+ (function (Color) {
2305
+ function is(value) {
2306
+ return (typeof value == "string" &&
2307
+ (CommaRgb.is(value) || Hex.is(value) || Hsl.is(value) || Name$3.is(value) || Rgb.is(value)));
2308
+ }
2309
+ Color.is = is;
2310
+ function from(value) {
2311
+ return is(value) ? value : undefined;
2312
+ }
2313
+ Color.from = from;
2314
+ Color.Names = Names;
2315
+ Color.Name = Name$3;
2316
+ Color.CommaRgb = CommaRgb;
2317
+ Color.Rgb = Rgb;
2318
+ Color.Hex = Hex;
2319
+ Color.Hsl = Hsl;
2320
+ })(Color || (Color = {}));
2321
+
2322
+ function reduce(types, value) {
2323
+ return types.reduce((r, c) => typeof value == "object" && value != null && typeof value[c] == "string"
2324
+ ? Object.assign(Object.assign({}, r), { [c]: value[c] }) : r, {});
2325
+ }
2326
+ var Cosmetic;
2327
+ (function (Cosmetic) {
2328
+ Cosmetic.types = Cosmetic;
2329
+ function from(value) {
2330
+ let result = {};
2331
+ if (typeof value == "object" && value) {
2332
+ result = {
2333
+ text: reduce(["background", "color"], value.text),
2334
+ border: reduce(["background", "color", "style", "radius", "width"], value.border),
2335
+ gap: typeof value.gap == "string" ? value.gap : undefined,
2336
+ dangerColor: typeof value.dangerColor == "string"
2337
+ ? value.dangerColor
2338
+ : typeof value.danger_color == "string"
2339
+ ? value.danger_color
2340
+ : undefined,
2341
+ fontFamily: typeof value.fontFamily == "string"
2342
+ ? value.fontFamily
2343
+ : typeof value.font_family == "string"
2344
+ ? value.font_family
2345
+ : undefined,
2346
+ background: typeof value.background == "string" ? value.background : undefined,
2347
+ };
2348
+ Object.keys(result).forEach((key) => {
2349
+ var _a;
2350
+ if (result[key] == undefined ||
2351
+ (typeof result[key] == "object" && result[key] && Object.keys((_a = result[key]) !== null && _a !== void 0 ? _a : {}).length == 0)) {
2352
+ delete result[key];
2353
+ }
2354
+ });
2355
+ }
2356
+ return result;
2357
+ }
2358
+ Cosmetic.from = from;
2359
+ Cosmetic.Color = Color;
2360
+ })(Cosmetic || (Cosmetic = {}));
2262
2361
 
2263
2362
  const globalScripts = () => {};
2264
2363
 
@@ -62251,4 +62350,4 @@ const defineCustomElements = (opts) => {
62251
62350
  }
62252
62351
  };
62253
62352
 
62254
- export { App, ClientIdentifier, Message, Notice, SmoothlyAccordion, SmoothlyAccordionItem, SmoothlyApp, SmoothlyAppDemo, SmoothlyCalendar, SmoothlyCheckbox, SmoothlyDialog, SmoothlyDialogDemo, SmoothlyDisplay, SmoothlyDisplayAmount, SmoothlyDisplayDateTime, SmoothlyDisplayDemo, SmoothlyFrame, SmoothlyIcon, SmoothlyIconDemo, SmoothlyInput, SmoothlyInputDate, SmoothlyInputDateRange, SmoothlyInputDemo, SmoothlyInputMonth, SmoothlyItem, SmoothlyMenuOptions, SmoothlyNotification, SmoothlyNotifier, SmoothlyOption, SmoothlyPicker, SmoothlyPopup, SmoothlyQuiet, SmoothlyRadio, SmoothlyRadioGroup, SmoothlyReorder, SmoothlyRoom, SmoothlySelect, SmoothlySelectDemo, SmoothlySelector, SmoothlySpinner, SmoothlySubmit, SmoothlyTab, SmoothlyTabSwitch, SmoothlyTable, SmoothlyTableCell, SmoothlyTableDemo, SmoothlyTableExpandableCell, SmoothlyTableExpandableRow, SmoothlyTableHeader, SmoothlyTableRow, SmoothlyTrigger, SmoothlyTriggerSink, SmoothlyTriggerSource, SmoothlyTuple, SmoothlyUrlencoded, Trigger, defineCustomElements, toCommaRgb };
62353
+ export { App, ClientIdentifier, Cosmetic, Message, Notice, SmoothlyAccordion, SmoothlyAccordionItem, SmoothlyApp, SmoothlyAppDemo, SmoothlyCalendar, SmoothlyCheckbox, SmoothlyDialog, SmoothlyDialogDemo, SmoothlyDisplay, SmoothlyDisplayAmount, SmoothlyDisplayDateTime, SmoothlyDisplayDemo, SmoothlyFrame, SmoothlyIcon, SmoothlyIconDemo, SmoothlyInput, SmoothlyInputDate, SmoothlyInputDateRange, SmoothlyInputDemo, SmoothlyInputMonth, SmoothlyItem, SmoothlyMenuOptions, SmoothlyNotification, SmoothlyNotifier, SmoothlyOption, SmoothlyPicker, SmoothlyPopup, SmoothlyQuiet, SmoothlyRadio, SmoothlyRadioGroup, SmoothlyReorder, SmoothlyRoom, SmoothlySelect, SmoothlySelectDemo, SmoothlySelector, SmoothlySpinner, SmoothlySubmit, SmoothlyTab, SmoothlyTabSwitch, SmoothlyTable, SmoothlyTableCell, SmoothlyTableDemo, SmoothlyTableExpandableCell, SmoothlyTableExpandableRow, SmoothlyTableHeader, SmoothlyTableRow, SmoothlyTrigger, SmoothlyTriggerSink, SmoothlyTriggerSource, SmoothlyTuple, SmoothlyUrlencoded, Trigger, defineCustomElements };