@mirai/ui 1.0.90 → 1.0.91

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.
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.MAGNITUDES = exports.DOMAIN = exports.COLORS = void 0;
7
+ var COLORS = ['accent'];
8
+ exports.COLORS = COLORS;
9
+ var DOMAIN = '--mirai-ui-';
10
+ exports.DOMAIN = DOMAIN;
11
+ var MAGNITUDES = [400, 300, 200];
12
+ exports.MAGNITUDES = MAGNITUDES;
13
+ //# sourceMappingURL=theme.constants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"theme.constants.js","names":["COLORS","DOMAIN","MAGNITUDES"],"sources":["../../src/theme/theme.constants.js"],"sourcesContent":["const COLORS = ['accent'];\n\nconst DOMAIN = '--mirai-ui-';\n\nconst MAGNITUDES = [400, 300, 200];\n\nexport { COLORS, DOMAIN, MAGNITUDES };\n"],"mappings":";;;;;;AAAA,IAAMA,MAAM,GAAG,CAAC,QAAQ,CAAC;AAAC;AAE1B,IAAMC,MAAM,GAAG,aAAa;AAAC;AAE7B,IAAMC,UAAU,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC;AAAC"}
@@ -5,50 +5,55 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.Theme = void 0;
7
7
  var _helpers = require("./helpers");
8
+ var _theme = require("./theme.constants");
8
9
  function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
9
10
  function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
10
11
  function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
11
12
  function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
12
13
  function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
13
14
  function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
14
- var VAR_DOMAIN = '--mirai-ui-';
15
- var COLORS = ['accent'];
16
- var MAGNITUDES = [400, 300, 200];
17
15
  var Theme = {
18
16
  get: function get() {
19
- var domain = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : VAR_DOMAIN;
17
+ var domain = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : _theme.DOMAIN;
20
18
  var style = getComputedStyle(document.querySelector(':root'));
21
19
  var variables = {};
22
- _toConsumableArray(document.styleSheets).filter(function (stylesheet) {
23
- return !!stylesheet.ownerRule;
24
- }).forEach(function (stylesheet) {
25
- _toConsumableArray(stylesheet.cssRules).filter(function () {
26
- var rule = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
27
- return rule.type === 1;
28
- }).forEach(function () {
29
- var rule = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
30
- _toConsumableArray(rule.style).filter(function (name) {
31
- return name.includes(domain);
32
- }).forEach(function (name) {
33
- return variables[(0, _helpers.camelcase)(name.replace(domain, ''))] = style.getPropertyValue(name).trim();
34
- });
35
- });
20
+ var keys = Array.from(document.styleSheets).filter(function (stylesheet) {
21
+ return stylesheet.href === null || stylesheet.href.startsWith(window.location.origin);
22
+ }).reduce(function (stylesheet) {
23
+ var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
24
+ cssRules = _ref.cssRules;
25
+ return [].concat(_toConsumableArray(stylesheet), _toConsumableArray(Array.from(cssRules).reduce(function (value) {
26
+ var _ref2 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
27
+ _ref2$selectorText = _ref2.selectorText,
28
+ selectorText = _ref2$selectorText === void 0 ? '' : _ref2$selectorText,
29
+ _ref2$style = _ref2.style,
30
+ style = _ref2$style === void 0 ? [] : _ref2$style;
31
+ return selectorText === ':root' ? [].concat(_toConsumableArray(value), _toConsumableArray(Array.from(style).filter(function (name) {
32
+ return name.startsWith(domain);
33
+ }))) : value;
34
+ }, [])));
35
+ }, []);
36
+ keys.forEach(function (key) {
37
+ return variables[(0, _helpers.camelcase)(key.replace(domain, ''))] = style.getPropertyValue(key);
36
38
  });
37
39
  return variables;
38
40
  },
39
41
  setVariable: function setVariable(variable, value) {
40
- var domain = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : VAR_DOMAIN;
42
+ var domain = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : _theme.DOMAIN;
41
43
  var _document$querySelect = document.querySelector(':root'),
42
44
  style = _document$querySelect.style;
43
45
  style.setProperty("".concat(domain).concat(variable), value);
44
- Theme.shadeColors();
46
+
47
+ // ! TODO: Should revisit this "algo"
48
+ // Theme.shadeColors();
45
49
  },
50
+
46
51
  shadeColors: function shadeColors() {
47
52
  var theme = Theme.get();
48
- COLORS.filter(function (color) {
53
+ _theme.COLORS.filter(function (color) {
49
54
  return theme[color] !== undefined;
50
55
  }).forEach(function (color) {
51
- return MAGNITUDES.forEach(function (magnitude) {
56
+ return _theme.MAGNITUDES.forEach(function (magnitude) {
52
57
  return Theme.setVariable("".concat(color, "-").concat(magnitude), (0, _helpers.colorShade)(theme[color], magnitude));
53
58
  });
54
59
  });
@@ -1 +1 @@
1
- {"version":3,"file":"theme.js","names":["VAR_DOMAIN","COLORS","MAGNITUDES","Theme","get","domain","style","getComputedStyle","document","querySelector","variables","styleSheets","filter","stylesheet","ownerRule","forEach","cssRules","rule","type","name","includes","camelcase","replace","getPropertyValue","trim","setVariable","variable","value","setProperty","shadeColors","theme","color","undefined","magnitude","colorShade"],"sources":["../../src/theme/theme.js"],"sourcesContent":["const VAR_DOMAIN = '--mirai-ui-';\n\nimport { camelcase, colorShade } from './helpers';\n\nconst COLORS = ['accent'];\nconst MAGNITUDES = [400, 300, 200];\n\nexport const Theme = {\n get: (domain = VAR_DOMAIN) => {\n const style = getComputedStyle(document.querySelector(':root'));\n\n const variables = {};\n [...document.styleSheets]\n .filter((stylesheet) => !!stylesheet.ownerRule)\n .forEach((stylesheet) => {\n [...stylesheet.cssRules]\n .filter((rule = {}) => rule.type === 1)\n .forEach((rule = {}) => {\n [...rule.style]\n .filter((name) => name.includes(domain))\n .forEach(\n (name) => (variables[camelcase(name.replace(domain, ''))] = style.getPropertyValue(name).trim()),\n );\n });\n });\n\n return variables;\n },\n\n setVariable: (variable, value, domain = VAR_DOMAIN) => {\n const { style } = document.querySelector(':root');\n\n style.setProperty(`${domain}${variable}`, value);\n\n Theme.shadeColors();\n },\n\n shadeColors: () => {\n const theme = Theme.get();\n\n COLORS.filter((color) => theme[color] !== undefined).forEach((color) =>\n MAGNITUDES.forEach((magnitude) =>\n Theme.setVariable(`${color}-${magnitude}`, colorShade(theme[color], magnitude)),\n ),\n );\n },\n};\n"],"mappings":";;;;;;AAEA;AAAkD;AAAA;AAAA;AAAA;AAAA;AAAA;AAFlD,IAAMA,UAAU,GAAG,aAAa;AAIhC,IAAMC,MAAM,GAAG,CAAC,QAAQ,CAAC;AACzB,IAAMC,UAAU,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC;AAE3B,IAAMC,KAAK,GAAG;EACnBC,GAAG,EAAE,eAAyB;IAAA,IAAxBC,MAAM,uEAAGL,UAAU;IACvB,IAAMM,KAAK,GAAGC,gBAAgB,CAACC,QAAQ,CAACC,aAAa,CAAC,OAAO,CAAC,CAAC;IAE/D,IAAMC,SAAS,GAAG,CAAC,C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AAK,CAAC,KAAKC,SAAS;IAAA,EAAC,CAACjB,OAAO,CAAC,UAACgB,KAAK;MAAA,OACjE7B,UAAU,CAACa,OAAO,CAAC,UAACkB,SAAS;QAAA,OAC3B9B,KAAK,CAACsB,WAAW,WAAIM,KAAK,cAAIE,SAAS,GAAI,IAAAC,mBAAU,EAACJ,KAAK,CAACC,KAAK,CAAC,EAAEE,SAAS,CAAC,CAAC;MAAA,EAChF;IAAA,EACF;EACH;AACF,CAAC;AAAC"}
1
+ {"version":3,"file":"theme.js","names":["Theme","get","domain","DOMAIN","style","getComputedStyle","document","querySelector","variables","keys","Array","from","styleSheets","filter","stylesheet","href","startsWith","window","location","origin","reduce","cssRules","value","selectorText","name","forEach","key","camelcase","replace","getPropertyValue","setVariable","variable","setProperty","shadeColors","theme","COLORS","color","undefined","MAGNITUDES","magnitude","colorShade"],"sources":["../../src/theme/theme.js"],"sourcesContent":["import { camelcase, colorShade } from './helpers';\nimport { COLORS, DOMAIN, MAGNITUDES } from './theme.constants';\n\nexport const Theme = {\n get: (domain = DOMAIN) => {\n const style = getComputedStyle(document.querySelector(':root'));\n const variables = {};\n\n const keys = Array.from(document.styleSheets)\n .filter((stylesheet) => stylesheet.href === null || stylesheet.href.startsWith(window.location.origin))\n .reduce(\n (stylesheet, { cssRules } = {}) => [\n ...stylesheet,\n ...Array.from(cssRules).reduce(\n (value, { selectorText = '', style = [] } = {}) =>\n selectorText === ':root'\n ? [...value, ...Array.from(style).filter((name) => name.startsWith(domain))]\n : value,\n [],\n ),\n ],\n [],\n );\n\n keys.forEach((key) => (variables[camelcase(key.replace(domain, ''))] = style.getPropertyValue(key)));\n\n return variables;\n },\n\n setVariable: (variable, value, domain = DOMAIN) => {\n const { style } = document.querySelector(':root');\n\n style.setProperty(`${domain}${variable}`, value);\n\n // ! TODO: Should revisit this \"algo\"\n // Theme.shadeColors();\n },\n\n shadeColors: () => {\n const theme = Theme.get();\n\n COLORS.filter((color) => theme[color] !== undefined).forEach((color) =>\n MAGNITUDES.forEach((magnitude) =>\n Theme.setVariable(`${color}-${magnitude}`, colorShade(theme[color], magnitude)),\n ),\n );\n },\n};\n"],"mappings":";;;;;;AAAA;AACA;AAA+D;AAAA;AAAA;AAAA;AAAA;AAAA;AAExD,IAAMA,KAAK,GAAG;EACnBC,GAAG,EAAE,eAAqB;IAAA,IAApBC,MAAM,uEAAGC,aAAM;IACnB,IAAMC,KAAK,GAAGC,gBAAgB,CAACC,QAAQ,CAACC,aAAa,CAAC,OAAO,CAAC,CAAC;IAC/D,IAAMC,SAAS,GAAG,CAAC,CAAC;IAEpB,IAAMC,IAAI,GAAGC,KAAK,CAACC,IAAI,CAACL,QAAQ,CAACM,WAAW,CAAC,CAC1CC,MAAM,CAAC,UAACC,UAAU;MAAA,OAAKA,UAAU,CAACC,IAAI,KAAK,IAAI,IAAID,UAAU,CAACC,IAAI,CAACC,UAAU,CAACC,MAAM,CAACC,QAAQ,CAACC,MAAM,CAAC;IAAA,EAAC,CACtGC,MAAM,CACL,UAACN,UAAU;MAAA,+EAAiB,CAAC,CAAC;QAAfO,QAAQ,QAARA,QAAQ;MAAA,oCAClBP,UAAU,sBACVJ,KAAK,CAACC,IAAI,CAACU,QAAQ,CAAC,CAACD,MAAM,CAC5B,UAACE,KAAK;QAAA,gFAAsC,CAAC,CAAC;UAAA,2BAApCC,YAAY;UAAZA,YAAY,mCAAG,EAAE;UAAA,oBAAEnB,KAAK;UAALA,KAAK,4BAAG,EAAE;QAAA,OACrCmB,YAAY,KAAK,OAAO,gCAChBD,KAAK,sBAAKZ,KAAK,CAACC,IAAI,CAACP,KAAK,CAAC,CAACS,MAAM,CAAC,UAACW,IAAI;UAAA,OAAKA,IAAI,CAACR,UAAU,CAACd,MAAM,CAAC;QAAA,EAAC,KACzEoB,KAAK;MAAA,GACX,EAAE,CACH;IAAA,CACF,EACD,EAAE,CACH;IAEHb,IAAI,CAACgB,OAAO,CAAC,UAACC,GAAG;MAAA,OAAMlB,SAAS,CAAC,IAAAmB,kBAAS,EAACD,GAAG,CAACE,OAAO,CAAC1B,MAAM,EAAE,EAAE,CAAC,CAAC,CAAC,GAAGE,KAAK,CAACyB,gBAAgB,CAACH,GAAG,CAAC;IAAA,CAAC,CAAC;IAEpG,OAAOlB,SAAS;EAClB,CAAC;EAEDsB,WAAW,EAAE,qBAACC,QAAQ,EAAET,KAAK,EAAsB;IAAA,IAApBpB,MAAM,uEAAGC,aAAM;IAC5C,4BAAkBG,QAAQ,CAACC,aAAa,CAAC,OAAO,CAAC;MAAzCH,KAAK,yBAALA,KAAK;IAEbA,KAAK,CAAC4B,WAAW,WAAI9B,MAAM,SAAG6B,QAAQ,GAAIT,KAAK,CAAC;;IAEhD;IACA;EACF,CAAC;;EAEDW,WAAW,EAAE,uBAAM;IACjB,IAAMC,KAAK,GAAGlC,KAAK,CAACC,GAAG,EAAE;IAEzBkC,aAAM,CAACtB,MAAM,CAAC,UAACuB,KAAK;MAAA,OAAKF,KAAK,CAACE,KAAK,CAAC,KAAKC,SAAS;IAAA,EAAC,CAACZ,OAAO,CAAC,UAACW,KAAK;MAAA,OACjEE,iBAAU,CAACb,OAAO,CAAC,UAACc,SAAS;QAAA,OAC3BvC,KAAK,CAAC8B,WAAW,WAAIM,KAAK,cAAIG,SAAS,GAAI,IAAAC,mBAAU,EAACN,KAAK,CAACE,KAAK,CAAC,EAAEG,SAAS,CAAC,CAAC;MAAA,EAChF;IAAA,EACF;EACH;AACF,CAAC;AAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mirai/ui",
3
- "version": "1.0.90",
3
+ "version": "1.0.91",
4
4
  "repository": "git@gitlab.com:miraicorp/dev/frontend/ui.git",
5
5
  "author": "JΛVI <hello@soyjavi.com>",
6
6
  "license": "MIT",