@wavemaker/app-rn-runtime 11.14.2-rc.6311 → 11.14.4-rc.647538

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.
Files changed (111) hide show
  1. package/components/advanced/carousel/carousel.component.js +3 -2
  2. package/components/advanced/carousel/carousel.component.js.map +1 -1
  3. package/components/advanced/carousel/carousel.styles.js +0 -3
  4. package/components/advanced/carousel/carousel.styles.js.map +1 -1
  5. package/components/basic/anchor/anchor.styles.js +0 -5
  6. package/components/basic/anchor/anchor.styles.js.map +1 -1
  7. package/components/basic/bottomsheet/bottomsheet.component.js +0 -30
  8. package/components/basic/bottomsheet/bottomsheet.component.js.map +1 -1
  9. package/components/basic/icon/icon.component.js +3 -5
  10. package/components/basic/icon/icon.component.js.map +1 -1
  11. package/components/basic/icon/icon.styles.js +0 -5
  12. package/components/basic/icon/icon.styles.js.map +1 -1
  13. package/components/basic/message/message.component.js.map +1 -1
  14. package/components/basic/picture/picture.component.js +15 -42
  15. package/components/basic/picture/picture.component.js.map +1 -1
  16. package/components/basic/progress-circle/progress-circle.component.js +3 -3
  17. package/components/basic/progress-circle/progress-circle.component.js.map +1 -1
  18. package/components/basic/search/search.component.js +3 -4
  19. package/components/basic/search/search.component.js.map +1 -1
  20. package/components/container/accordion/accordion.component.js +3 -3
  21. package/components/container/accordion/accordion.component.js.map +1 -1
  22. package/components/container/accordion/accordion.styles.js +1 -4
  23. package/components/container/accordion/accordion.styles.js.map +1 -1
  24. package/components/container/container.component.js +11 -182
  25. package/components/container/container.component.js.map +1 -1
  26. package/components/container/container.props.js +0 -5
  27. package/components/container/container.props.js.map +1 -1
  28. package/components/container/linearlayout/linearlayout.component.js +1 -1
  29. package/components/container/linearlayout/linearlayout.component.js.map +1 -1
  30. package/components/container/tabs/tabheader/tabheader.component.js +17 -23
  31. package/components/container/tabs/tabheader/tabheader.component.js.map +1 -1
  32. package/components/container/tabs/tabs.component.js +4 -5
  33. package/components/container/tabs/tabs.component.js.map +1 -1
  34. package/components/container/tabs/tabs.styles.js +0 -4
  35. package/components/container/tabs/tabs.styles.js.map +1 -1
  36. package/components/container/wizard/wizard.component.js +1 -1
  37. package/components/container/wizard/wizard.component.js.map +1 -1
  38. package/components/container/wizard/wizard.props.js +0 -1
  39. package/components/container/wizard/wizard.props.js.map +1 -1
  40. package/components/container/wizard/wizard.styles.js +3 -1
  41. package/components/container/wizard/wizard.styles.js.map +1 -1
  42. package/components/container/wizard/wizardstep/wizardstep.component.js +2 -2
  43. package/components/container/wizard/wizardstep/wizardstep.component.js.map +1 -1
  44. package/components/data/form/form-body/form-body.component.js +1 -2
  45. package/components/data/form/form-body/form-body.component.js.map +1 -1
  46. package/components/data/form/form-footer/form-footer.component.js +1 -2
  47. package/components/data/form/form-footer/form-footer.component.js.map +1 -1
  48. package/components/data/form/form.styles.js +0 -8
  49. package/components/data/form/form.styles.js.map +1 -1
  50. package/components/input/chips/chips.component.js +20 -66
  51. package/components/input/chips/chips.component.js.map +1 -1
  52. package/components/input/chips/chips.styles.js +0 -43
  53. package/components/input/chips/chips.styles.js.map +1 -1
  54. package/components/input/currency/currency.component.js +1 -2
  55. package/components/input/currency/currency.component.js.map +1 -1
  56. package/components/input/currency/currency.styles.js +1 -6
  57. package/components/input/currency/currency.styles.js.map +1 -1
  58. package/components/input/epoch/base-datetime.component.js.map +1 -1
  59. package/components/input/epoch/datetime/datetime.styles.js.map +1 -1
  60. package/components/input/number/number.component.js +1 -2
  61. package/components/input/number/number.component.js.map +1 -1
  62. package/components/input/radioset/radioset.component.js +3 -6
  63. package/components/input/radioset/radioset.component.js.map +1 -1
  64. package/components/input/radioset/radioset.styles.js.map +1 -1
  65. package/components/input/select/select.component.js +1 -2
  66. package/components/input/select/select.component.js.map +1 -1
  67. package/components/input/slider/slider.component.js +21 -18
  68. package/components/input/slider/slider.component.js.map +1 -1
  69. package/components/input/text/text.component.js +1 -2
  70. package/components/input/text/text.component.js.map +1 -1
  71. package/components/input/text/text.styles.js +0 -12
  72. package/components/input/text/text.styles.js.map +1 -1
  73. package/components/input/textarea/textarea.component.js +1 -2
  74. package/components/input/textarea/textarea.component.js.map +1 -1
  75. package/components/input/toggle/toggle.component.js +1 -26
  76. package/components/input/toggle/toggle.component.js.map +1 -1
  77. package/components/input/toggle/toggle.props.js +0 -2
  78. package/components/input/toggle/toggle.props.js.map +1 -1
  79. package/components/input/toggle/toggle.styles.js +1 -27
  80. package/components/input/toggle/toggle.styles.js.map +1 -1
  81. package/components/navigation/popover/popover.component.js +4 -4
  82. package/components/navigation/popover/popover.component.js.map +1 -1
  83. package/components/navigation/popover/popover.props.js +0 -1
  84. package/components/navigation/popover/popover.props.js.map +1 -1
  85. package/components/navigation/popover/popover.styles.js +0 -13
  86. package/components/navigation/popover/popover.styles.js.map +1 -1
  87. package/core/base.component.js +10 -76
  88. package/core/base.component.js.map +1 -1
  89. package/core/components/textinput.component.js +1 -5
  90. package/core/components/textinput.component.js.map +1 -1
  91. package/core/tappable.component.js +1 -1
  92. package/core/tappable.component.js.map +1 -1
  93. package/npm-shrinkwrap.json +3574 -2200
  94. package/package-lock.json +3574 -2200
  95. package/package.json +2 -3
  96. package/styles/background.component.js +2 -2
  97. package/styles/background.component.js.map +1 -1
  98. package/styles/theme.js +23 -104
  99. package/styles/theme.js.map +1 -1
  100. package/components/advanced/customwidgetcontainer/customwidgetcontainer.component.js +0 -14
  101. package/components/advanced/customwidgetcontainer/customwidgetcontainer.component.js.map +0 -1
  102. package/components/advanced/customwidgetcontainer/customwidgetcontainer.props.js +0 -11
  103. package/components/advanced/customwidgetcontainer/customwidgetcontainer.props.js.map +0 -1
  104. package/components/advanced/customwidgetcontainer/customwidgetcontainer.styles.js +0 -14
  105. package/components/advanced/customwidgetcontainer/customwidgetcontainer.styles.js.map +0 -1
  106. package/runtime/base-customwidget.component.js +0 -52
  107. package/runtime/base-customwidget.component.js.map +0 -1
  108. package/styles/calc.js +0 -165
  109. package/styles/calc.js.map +0 -1
  110. package/styles/color-mix.js +0 -82
  111. package/styles/color-mix.js.map +0 -1
@@ -1,14 +0,0 @@
1
- import React from 'react';
2
- import { BaseComponent, BaseComponentState } from '@wavemaker/app-rn-runtime/core/base.component';
3
- import WmCustomWidgetContainerProps from './customwidgetcontainer.props';
4
- import { DEFAULT_CLASS } from './customwidgetcontainer.styles';
5
- export class WmCustomWidgetContainerState extends BaseComponentState {}
6
- export default class WmCustomWidgetContainer extends BaseComponent {
7
- constructor(props) {
8
- super(props, DEFAULT_CLASS, new WmCustomWidgetContainerProps(), new WmCustomWidgetContainerState());
9
- }
10
- renderWidget(props) {
11
- return /*#__PURE__*/React.createElement(React.Fragment, null, props.children);
12
- }
13
- }
14
- //# sourceMappingURL=customwidgetcontainer.component.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["React","BaseComponent","BaseComponentState","WmCustomWidgetContainerProps","DEFAULT_CLASS","WmCustomWidgetContainerState","WmCustomWidgetContainer","constructor","props","renderWidget","createElement","Fragment","children"],"sources":["customwidgetcontainer.component.tsx"],"sourcesContent":["import React from 'react';\nimport { View } from 'react-native';\nimport { BaseComponent, BaseComponentState } from '@wavemaker/app-rn-runtime/core/base.component';\n\nimport WmCustomWidgetContainerProps from './customwidgetcontainer.props';\nimport { DEFAULT_CLASS, WmCustomWidgetContainerStyles } from './customwidgetcontainer.styles';\n\nexport class WmCustomWidgetContainerState extends BaseComponentState<WmCustomWidgetContainerProps> {}\n\nexport default class WmCustomWidgetContainer extends BaseComponent<WmCustomWidgetContainerProps, WmCustomWidgetContainerState, WmCustomWidgetContainerStyles> {\n\n constructor(props: WmCustomWidgetContainerProps) {\n super(props, DEFAULT_CLASS, new WmCustomWidgetContainerProps(), new WmCustomWidgetContainerState());\n }\n\n renderWidget(props: WmCustomWidgetContainerProps) {\n return (\n <>\n {props.children}\n </>\n ); \n }\n}\n"],"mappings":"AAAA,OAAOA,KAAK,MAAM,OAAO;AAEzB,SAASC,aAAa,EAAEC,kBAAkB,QAAQ,+CAA+C;AAEjG,OAAOC,4BAA4B,MAAM,+BAA+B;AACxE,SAASC,aAAa,QAAuC,gCAAgC;AAE7F,OAAO,MAAMC,4BAA4B,SAASH,kBAAkB,CAA+B;AAEnG,eAAe,MAAMI,uBAAuB,SAASL,aAAa,CAA4F;EAE5JM,WAAWA,CAACC,KAAmC,EAAE;IAC/C,KAAK,CAACA,KAAK,EAAEJ,aAAa,EAAE,IAAID,4BAA4B,CAAC,CAAC,EAAE,IAAIE,4BAA4B,CAAC,CAAC,CAAC;EACrG;EAEAI,YAAYA,CAACD,KAAmC,EAAE;IAChD,oBACER,KAAA,CAAAU,aAAA,CAAAV,KAAA,CAAAW,QAAA,QACGH,KAAK,CAACI,QACP,CAAC;EAEP;AACF","ignoreList":[]}
@@ -1,11 +0,0 @@
1
- function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
2
- function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
3
- function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
4
- import { BaseProps } from "@wavemaker/app-rn-runtime/core/base.component";
5
- export default class WmCustomWidgetContainerProps extends BaseProps {
6
- constructor(...args) {
7
- super(...args);
8
- _defineProperty(this, "children", null);
9
- }
10
- }
11
- //# sourceMappingURL=customwidgetcontainer.props.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["BaseProps","WmCustomWidgetContainerProps","constructor","args","_defineProperty"],"sources":["customwidgetcontainer.props.ts"],"sourcesContent":["import { BaseProps } from \"@wavemaker/app-rn-runtime/core/base.component\";\n\nexport default class WmCustomWidgetContainerProps extends BaseProps {\n children: any[] = null as any;\n}"],"mappings":";;;AAAA,SAASA,SAAS,QAAQ,+CAA+C;AAEzE,eAAe,MAAMC,4BAA4B,SAASD,SAAS,CAAC;EAAAE,YAAA,GAAAC,IAAA;IAAA,SAAAA,IAAA;IAAAC,eAAA,mBAC9C,IAAI;EAAA;AAC1B","ignoreList":[]}
@@ -1,14 +0,0 @@
1
- import BASE_THEME from '@wavemaker/app-rn-runtime/styles/theme';
2
- import { defineStyles } from '@wavemaker/app-rn-runtime/core/base.component';
3
- export const DEFAULT_CLASS = 'app-CustomWidgetContainer';
4
- BASE_THEME.registerStyle((themeVariables, addStyle) => {
5
- const defaultStyles = defineStyles({
6
- root: {},
7
- text: {},
8
- skeleton: {
9
- root: {}
10
- }
11
- });
12
- addStyle(DEFAULT_CLASS, '', defaultStyles);
13
- });
14
- //# sourceMappingURL=customwidgetcontainer.styles.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["BASE_THEME","defineStyles","DEFAULT_CLASS","registerStyle","themeVariables","addStyle","defaultStyles","root","text","skeleton"],"sources":["customwidgetcontainer.styles.ts"],"sourcesContent":["import BASE_THEME from '@wavemaker/app-rn-runtime/styles/theme';\nimport { BaseStyles, defineStyles } from '@wavemaker/app-rn-runtime/core/base.component';\nimport { WmSkeletonStyles } from '../../basic/skeleton/skeleton.styles';\n\nexport type WmCustomWidgetContainerStyles = BaseStyles & {\n skeleton: WmSkeletonStyles\n};\n\nexport const DEFAULT_CLASS = 'app-CustomWidgetContainer';\nBASE_THEME.registerStyle((themeVariables, addStyle) => {\n const defaultStyles = defineStyles<WmCustomWidgetContainerStyles>({\n root: {},\n text: {},\n skeleton: {\n root: {\n }\n } as WmSkeletonStyles\n });\n addStyle(DEFAULT_CLASS, '', defaultStyles);\n});"],"mappings":"AAAA,OAAOA,UAAU,MAAM,wCAAwC;AAC/D,SAAqBC,YAAY,QAAQ,+CAA+C;AAOxF,OAAO,MAAMC,aAAa,GAAG,2BAA2B;AACxDF,UAAU,CAACG,aAAa,CAAC,CAACC,cAAc,EAAEC,QAAQ,KAAK;EACnD,MAAMC,aAAa,GAAGL,YAAY,CAAgC;IAC9DM,IAAI,EAAE,CAAC,CAAC;IACRC,IAAI,EAAE,CAAC,CAAC;IACRC,QAAQ,EAAE;MACNF,IAAI,EAAE,CACN;IACJ;EACJ,CAAC,CAAC;EACFF,QAAQ,CAACH,aAAa,EAAE,EAAE,EAAEI,aAAa,CAAC;AAC9C,CAAC,CAAC","ignoreList":[]}
@@ -1,52 +0,0 @@
1
- function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
2
- function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
3
- function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
4
- import React from 'react';
5
- import { PartialProvider } from '@wavemaker/app-rn-runtime/core/partial.service';
6
- import WmPrefabContainer from '@wavemaker/app-rn-runtime/components/prefab/prefab-container.component';
7
- import BaseFragment from './base-fragment.component';
8
- export default class BaseCustomWidget extends BaseFragment {
9
- constructor(props, defualtProps, partialService) {
10
- super(props, defualtProps);
11
- this.partialService = partialService;
12
- _defineProperty(this, "appUrl", '');
13
- _defineProperty(this, "widgetParams", {});
14
- _defineProperty(this, "_renderCustomWidget", null);
15
- this.App = this.appConfig.app;
16
- this.Actions = {};
17
- this.Variables = {};
18
- this.appUrl = this.appConfig.url;
19
- this.resourceBaseUrl = `${this.baseUrl}/app/custom-widgets/${props.widgetname}`;
20
- this.baseUrl = `${this.baseUrl}/custom-widgets/${props.widgetname}`;
21
- this.watcher = props.parentWatcher.create();
22
- }
23
- onComponentInit(w) {
24
- super.onComponentInit(w);
25
- if (w instanceof WmPrefabContainer) {
26
- this.targetWidget = w;
27
- }
28
- }
29
- onFragmentReady() {
30
- this._renderCustomWidget = () => {
31
- const component = this.renderCustomWidget();
32
- super.onFragmentReady().then(() => {
33
- this.onContentReady();
34
- this.invokeEventCallback('onLoad', [null, this]);
35
- });
36
- this._renderCustomWidget = () => this.renderCustomWidget();
37
- return component;
38
- };
39
- this.refresh();
40
- return Promise.resolve();
41
- }
42
- componentWillUnmount() {
43
- super.componentWillUnmount();
44
- this.invokeEventCallback('onDestroy', [null, this]);
45
- }
46
- renderWidget(props) {
47
- return /*#__PURE__*/React.createElement(PartialProvider, {
48
- value: this.partialService
49
- }, this._renderCustomWidget ? this._renderCustomWidget() : null);
50
- }
51
- }
52
- //# sourceMappingURL=base-customwidget.component.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["React","PartialProvider","WmPrefabContainer","BaseFragment","BaseCustomWidget","constructor","props","defualtProps","partialService","_defineProperty","App","appConfig","app","Actions","Variables","appUrl","url","resourceBaseUrl","baseUrl","widgetname","watcher","parentWatcher","create","onComponentInit","w","targetWidget","onFragmentReady","_renderCustomWidget","component","renderCustomWidget","then","onContentReady","invokeEventCallback","refresh","Promise","resolve","componentWillUnmount","renderWidget","createElement","value"],"sources":["base-customwidget.component.tsx"],"sourcesContent":["import React from 'react';\nimport { View } from 'react-native';\n\nimport { BaseComponent } from '@wavemaker/app-rn-runtime/core/base.component';\nimport PartialService, { PartialProvider } from '@wavemaker/app-rn-runtime/core/partial.service';\nimport WmPrefabContainer from '@wavemaker/app-rn-runtime/components/prefab/prefab-container.component';\nimport BaseFragment, { FragmentProps, FragmentState } from './base-fragment.component';\nimport { Watcher } from './watcher';\n\n\nexport interface CustomWidgetProps extends FragmentProps {\n widgetname: string;\n parentWatcher: Watcher;\n}\n\nexport interface CustomWidgetState extends FragmentState<CustomWidgetProps> {}\n\nexport default abstract class BaseCustomWidget extends BaseFragment<CustomWidgetProps, CustomWidgetState> {\n\n private appUrl = '';\n private widgetParams: any = {};\n private _renderCustomWidget:() => React.ReactNode = null as any;\n\n constructor(props: CustomWidgetProps, defualtProps: CustomWidgetProps, private partialService: PartialService) {\n super(props, defualtProps);\n this.App = this.appConfig.app;\n this.Actions = {};\n this.Variables = {};\n this.appUrl = this.appConfig.url;\n this.resourceBaseUrl = `${this.baseUrl}/app/custom-widgets/${props.widgetname}`;\n this.baseUrl = `${this.baseUrl}/custom-widgets/${props.widgetname}`;\n this.watcher = props.parentWatcher.create();\n }\n onComponentInit(w: BaseComponent<any, any, any>) {\n super.onComponentInit(w);\n if (w instanceof WmPrefabContainer) {\n this.targetWidget = w;\n }\n }\n\n onFragmentReady(): Promise<void> {\n this._renderCustomWidget = () => {\n const component = this.renderCustomWidget();\n super.onFragmentReady()\n .then(() => {\n this.onContentReady();\n this.invokeEventCallback('onLoad', [null, this]);\n });\n this._renderCustomWidget = () => this.renderCustomWidget();\n return component;\n };\n this.refresh();\n return Promise.resolve();\n }\n\n componentWillUnmount() {\n super.componentWillUnmount();\n this.invokeEventCallback('onDestroy', [null, this]);\n }\n\n abstract renderCustomWidget(): React.ReactNode;\n \n renderWidget(props: CustomWidgetProps) {\n return (\n <PartialProvider value={this.partialService}>\n {this._renderCustomWidget ? this._renderCustomWidget(): null}\n </PartialProvider>\n );\n }\n}\n"],"mappings":";;;AAAA,OAAOA,KAAK,MAAM,OAAO;AAIzB,SAAyBC,eAAe,QAAQ,gDAAgD;AAChG,OAAOC,iBAAiB,MAAM,wEAAwE;AACtG,OAAOC,YAAY,MAAwC,2BAA2B;AAWtF,eAAe,MAAeC,gBAAgB,SAASD,YAAY,CAAuC;EAMtGE,WAAWA,CAACC,KAAwB,EAAEC,YAA+B,EAAUC,cAA8B,EAAE;IAC7G,KAAK,CAACF,KAAK,EAAEC,YAAY,CAAC;IAAC,KADkDC,cAA8B,GAA9BA,cAA8B;IAAAC,eAAA,iBAJ5F,EAAE;IAAAA,eAAA,uBACS,CAAC,CAAC;IAAAA,eAAA,8BACsB,IAAI;IAItD,IAAI,CAACC,GAAG,GAAG,IAAI,CAACC,SAAS,CAACC,GAAG;IA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EACrD;EAIAK,YAAYA,CAAC/B,KAAwB,EAAE;IACrC,oBACEN,KAAA,CAAAsC,aAAA,CAACrC,eAAe;MAACsC,KAAK,EAAE,IAAI,CAAC/B;IAAe,GACvC,IAAI,CAACmB,mBAAmB,GAAG,IAAI,CAACA,mBAAmB,CAAC,CAAC,GAAE,IAC3C,CAAC;EAEtB;AACJ","ignoreList":[]}
package/styles/calc.js DELETED
@@ -1,165 +0,0 @@
1
- function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
2
- function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
3
- function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
4
- export class CalcExpression {
5
- constructor(expression, initialVariables = {}) {
6
- _defineProperty(this, "expression", '');
7
- _defineProperty(this, "currentIndex", 0);
8
- _defineProperty(this, "variables", {});
9
- this.expression = expression.trim();
10
- this.expression = this.expression.replace(/%/g, " * (p / 100)");
11
- this.expression = this.expression.replace(/vw/g, " * (vw / 100)");
12
- this.expression = this.expression.replace(/vh/g, " * (vh / 100)");
13
- if (this.expression.startsWith('calc(')) {
14
- this.expression = this.expression.substring(5, this.expression.length - 1);
15
- }
16
- this.variables = {
17
- ...initialVariables
18
- };
19
- this.resolveInnerCalc();
20
- }
21
- resolveInnerCalc() {
22
- if (this.expression.indexOf('calc') >= 0) {
23
- var _this$expression$matc;
24
- (_this$expression$matc = this.expression.match(/calc\([^\c)]*\)/g)) === null || _this$expression$matc === void 0 || _this$expression$matc.map(m => {
25
- this.expression = this.expression.replace(m, new CalcExpression(m, this.variables).evaluate() + "");
26
- });
27
- }
28
- }
29
- peek() {
30
- if (this.currentIndex < this.expression.length) {
31
- return this.expression[this.currentIndex];
32
- }
33
- return null;
34
- }
35
- consume() {
36
- const char = this.peek();
37
- if (char !== null) {
38
- this.currentIndex++;
39
- }
40
- return char;
41
- }
42
- skipWhitespace() {
43
- while (this.peek() !== null && /\s/.test(this.peek())) {
44
- this.consume();
45
- }
46
- }
47
- parseNumber() {
48
- let numberStr = "";
49
- let decimalSeen = false;
50
- while (this.peek() !== null && (/\d/.test(this.peek()) || this.peek() === "." && !decimalSeen)) {
51
- if (this.peek() === ".") {
52
- decimalSeen = true;
53
- }
54
- numberStr += this.consume();
55
- }
56
- if (this.peek() === 'p') {
57
- this.consume();
58
- this.consume();
59
- }
60
- if (numberStr.length === 0) {
61
- throw new Error(`Expected a number but found: ${this.peek()}`);
62
- }
63
- return parseFloat(numberStr);
64
- }
65
- parseVariable() {
66
- let variableName = "";
67
- while (this.peek() !== null && /[a-zA-Z0-9_]/.test(this.peek()) && (variableName.length > 0 || /[a-zA-Z_]/.test(this.peek()))) {
68
- variableName += this.consume();
69
- }
70
- if (variableName.length === 0) {
71
- throw new Error(`Expected a variable but found: ${this.peek()}`);
72
- }
73
- if (!(variableName in this.variables)) {
74
- throw new Error(`Undefined variable: ${variableName}`);
75
- }
76
- return this.variables[variableName];
77
- }
78
- parseFactor() {
79
- this.skipWhitespace();
80
- const char = this.peek();
81
- if (char === "(") {
82
- this.consume();
83
- const result = this.parseExpression();
84
- this.skipWhitespace();
85
- if (this.consume() !== ")") {
86
- throw new Error("Expected ')'");
87
- }
88
- return result;
89
- } else if (char === "-") {
90
- this.consume();
91
- return -this.parseFactor();
92
- } else if (/\d/.test(char)) {
93
- return this.parseNumber();
94
- } else if (/[a-zA-Z_]/.test(char)) {
95
- return this.parseVariable();
96
- }
97
- throw new Error(`Unexpected token: ${char}`);
98
- }
99
- parseTerm() {
100
- let left = this.parseFactor();
101
- this.skipWhitespace();
102
- while (this.peek() === "*" || this.peek() === "/") {
103
- const operator = this.consume();
104
- const right = this.parseFactor();
105
- if (operator === "*") {
106
- left *= right;
107
- } else if (operator === "/") {
108
- if (right === 0) {
109
- throw new Error("Division by zero");
110
- }
111
- left /= right;
112
- }
113
- this.skipWhitespace();
114
- }
115
- return left;
116
- }
117
- parseExponent() {
118
- let base = this.parseTerm();
119
- this.skipWhitespace();
120
- while (this.peek() === "^") {
121
- this.consume();
122
- const exponent = this.parseFactor();
123
- base = Math.pow(base, exponent);
124
- this.skipWhitespace();
125
- }
126
- return base;
127
- }
128
- parseExpression() {
129
- let left = this.parseExponent();
130
- this.skipWhitespace();
131
- while (this.peek() === "+" || this.peek() === "-") {
132
- const operator = this.consume();
133
- const right = this.parseExponent();
134
- if (operator === "+") {
135
- left += right;
136
- } else if (operator === "-") {
137
- left -= right;
138
- }
139
- this.skipWhitespace();
140
- }
141
- return left;
142
- }
143
- evaluate(variables) {
144
- this.variables = {
145
- ...this.variables,
146
- ...(variables || {})
147
- };
148
- this.currentIndex = 0;
149
- const result = this.parseExpression();
150
- this.skipWhitespace();
151
- if (this.peek() !== null) {
152
- throw new Error(`Unexpected end of expression: ${this.peek()}`);
153
- }
154
- return result;
155
- }
156
- setVariable(variableName, value) {
157
- this.variables[variableName] = value;
158
- }
159
- getVariables() {
160
- return {
161
- ...this.variables
162
- };
163
- }
164
- }
165
- //# sourceMappingURL=calc.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["CalcExpression","constructor","expression","initialVariables","_defineProperty","trim","replace","startsWith","substring","length","variables","resolveInnerCalc","indexOf","_this$expression$matc","match","map","m","evaluate","peek","currentIndex","consume","char","skipWhitespace","test","parseNumber","numberStr","decimalSeen","Error","parseFloat","parseVariable","variableName","parseFactor","result","parseExpression","parseTerm","left","operator","right","parseExponent","base","exponent","Math","pow","setVariable","value","getVariables"],"sources":["calc.ts"],"sourcesContent":["interface VariableMap {\n [key: string]: number;\n}\n\nexport class CalcExpression {\n \n private expression = '';\n private currentIndex: number = 0;\n private variables: VariableMap = {};\n\n constructor(expression: string, initialVariables: VariableMap = {}) {\n this.expression = expression.trim();\n this.expression = this.expression.replace(/%/g, \" * (p / 100)\");\n this.expression = this.expression.replace(/vw/g, \" * (vw / 100)\");\n this.expression = this.expression.replace(/vh/g, \" * (vh / 100)\");\n if (this.expression.startsWith('calc(')) {\n this.expression = this.expression.substring(5, this.expression.length - 1);\n }\n this.variables = { ...initialVariables };\n this.resolveInnerCalc();\n }\n\n private resolveInnerCalc() {\n if (this.expression.indexOf('calc') >= 0) {\n this.expression.match(/calc\\([^\\c)]*\\)/g)?.map(m => {\n this.expression = this.expression.replace(m, new CalcExpression(m, this.variables).evaluate() + \"\");\n })\n }\n }\n \n private peek(): string | null {\n if (this.currentIndex < this.expression.length) {\n return this.expression[this.currentIndex];\n }\n return null;\n }\n\n private consume(): string | null {\n const char = this.peek();\n if (char !== null) {\n this.currentIndex++;\n }\n return char;\n }\n\n private skipWhitespace(): void {\n while (this.peek() !== null && /\\s/.test(this.peek()!)) {\n this.consume();\n }\n }\n\n private parseNumber(): number {\n let numberStr = \"\";\n let decimalSeen = false;\n while (this.peek() !== null && (/\\d/.test(this.peek()!) || (this.peek() === \".\" && !decimalSeen))) {\n if (this.peek() === \".\") {\n decimalSeen = true;\n }\n numberStr += this.consume();\n }\n if (this.peek() === 'p') {\n this.consume();\n this.consume();\n }\n if (numberStr.length === 0) {\n throw new Error(`Expected a number but found: ${this.peek()}`);\n }\n return parseFloat(numberStr);\n }\n\n private parseVariable(): number {\n let variableName = \"\";\n while (this.peek() !== null && /[a-zA-Z0-9_]/.test(this.peek()!) && (variableName.length > 0 || /[a-zA-Z_]/.test(this.peek()!))) {\n variableName += this.consume();\n }\n if (variableName.length === 0) {\n throw new Error(`Expected a variable but found: ${this.peek()}`);\n }\n if (!(variableName in this.variables)) {\n throw new Error(`Undefined variable: ${variableName}`);\n }\n return this.variables[variableName];\n }\n\n private parseFactor(): number {\n this.skipWhitespace();\n const char = this.peek();\n\n if (char === \"(\") {\n this.consume();\n const result = this.parseExpression();\n this.skipWhitespace();\n if (this.consume() !== \")\") {\n throw new Error(\"Expected ')'\");\n }\n return result;\n } else if (char === \"-\") {\n this.consume();\n return -this.parseFactor();\n } else if (/\\d/.test(char!)) {\n return this.parseNumber();\n } else if (/[a-zA-Z_]/.test(char!)) {\n return this.parseVariable();\n }\n\n throw new Error(`Unexpected token: ${char}`);\n }\n\n private parseTerm(): number {\n let left = this.parseFactor();\n this.skipWhitespace();\n while (this.peek() === \"*\" || this.peek() === \"/\") {\n const operator = this.consume();\n const right = this.parseFactor();\n if (operator === \"*\") {\n left *= right;\n } else if (operator === \"/\") {\n if (right === 0) {\n throw new Error(\"Division by zero\");\n }\n left /= right;\n }\n this.skipWhitespace();\n }\n return left;\n }\n\n private parseExponent(): number {\n let base = this.parseTerm();\n this.skipWhitespace();\n while (this.peek() === \"^\") {\n this.consume();\n const exponent = this.parseFactor();\n base = Math.pow(base, exponent);\n this.skipWhitespace();\n }\n return base;\n }\n\n private parseExpression(): number {\n let left = this.parseExponent();\n this.skipWhitespace();\n while (this.peek() === \"+\" || this.peek() === \"-\") {\n const operator = this.consume();\n const right = this.parseExponent();\n if (operator === \"+\") {\n left += right;\n } else if (operator === \"-\") {\n left -= right;\n }\n this.skipWhitespace();\n }\n return left;\n }\n\n evaluate(variables?: any): number {\n this.variables = {\n ...this.variables,\n ...(variables || {})\n };\n this.currentIndex = 0;\n const result = this.parseExpression();\n this.skipWhitespace();\n if (this.peek() !== null) {\n throw new Error(`Unexpected end of expression: ${this.peek()}`);\n }\n return result;\n }\n\n setVariable(variableName: string, value: number): void {\n this.variables[variableName] = value;\n }\n\n getVariables(): VariableMap {\n return { ...this.variables };\n }\n}"],"mappings":";;;AAIA,OAAO,MAAMA,cAAc,CAAC;EAM1BC,WAAWA,CAACC,UAAkB,EAAEC,gBAA6B,GAAG,CAAC,CAAC,EAAE;IAAAC,eAAA,qBAJ/C,EAAE;IAAAA,eAAA,uBACQ,CAAC;IAAAA,eAAA,oBACC,CAAC,CAAC;IAGjC,IAAI,CAACF,U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I,CAACnC;IAAU,CAAC;EAC9B;AACF","ignoreList":[]}
@@ -1,82 +0,0 @@
1
- var _ColorMix;
2
- function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
3
- function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
4
- function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
5
- import Color from "colorjs.io";
6
- const ColorMixSpace = [
7
- //rectangular
8
- "srgb", "srgb-linear", "display-p3", "a98-rgb", "prophoto-rgb", "rec2020", "lab", "oklab", "xyz", "xyz-d50", "xyz-d65",
9
- //triangle
10
- "hsl", "hwb", "lch", "oklch"];
11
- const HueInterpolationMethod = ["shorter", "longer", "increasing", "decreasing"];
12
- class ColorMix {
13
- valueOf(expression) {
14
- const {
15
- colorInterpolationMethod,
16
- colorPercent1,
17
- colorPercent2
18
- } = this.parse(expression);
19
- let p1 = colorPercent1.percent;
20
- let p2 = colorPercent2.percent;
21
- if (p1 && !p2) {
22
- p2 = 100 - p1;
23
- } else if (!p1 && p2) {
24
- p1 = 100 - p2;
25
- } else if (p1 + p2 > 100) {
26
- const sum = p1 + p2;
27
- p1 = p1 / sum * 100;
28
- p2 = p2 / sum * 100;
29
- }
30
- p1 = p1 / 100;
31
- p2 = p2 / 100;
32
- return new Color(colorPercent1.color).mix(colorPercent2.color, p2, {
33
- space: colorInterpolationMethod.space,
34
- hue: colorInterpolationMethod.hueInterpolationMethod
35
- }).to("srgb").toString({
36
- format: "hex"
37
- });
38
- }
39
- parseColorInterpolationMethod(expression) {
40
- const splits = expression.split(' ');
41
- return {
42
- space: splits[1],
43
- hueInterpolationMethod: splits[2] || 'shorter'
44
- };
45
- }
46
- parseColorPercent(expression) {
47
- let colorCode = '';
48
- let percent = 0;
49
- if (expression.indexOf(')') > 0) {
50
- const splits = expression.split(')').map(s => s.trim());
51
- colorCode = splits[0] + ')';
52
- percent = splits[1] ? parseFloat(splits[1].replace('%', '')) : 0;
53
- } else {
54
- const splits = expression.split(' ');
55
- colorCode = splits[0];
56
- percent = splits[1] ? parseFloat(splits[1].replace('%', '')) : 0;
57
- }
58
- return {
59
- color: colorCode,
60
- percent: percent
61
- };
62
- }
63
- parse(expression) {
64
- const splits = expression.split(',').map(s => s.trim());
65
- return {
66
- colorInterpolationMethod: this.parseColorInterpolationMethod(splits[0]),
67
- colorPercent1: this.parseColorPercent(splits[1]),
68
- colorPercent2: this.parseColorPercent(splits[2])
69
- };
70
- }
71
- }
72
- _ColorMix = ColorMix;
73
- _defineProperty(ColorMix, "INSTANCE", new _ColorMix());
74
- export default {
75
- "valueOf": expression => {
76
- if (expression.startsWith("color-mix")) {
77
- expression = expression.substring("color-mix(".length, expression.length - 1);
78
- }
79
- return ColorMix.INSTANCE.valueOf(expression);
80
- }
81
- };
82
- //# sourceMappingURL=color-mix.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["Color","ColorMixSpace","HueInterpolationMethod","ColorMix","valueOf","expression","colorInterpolationMethod","colorPercent1","colorPercent2","parse","p1","percent","p2","sum","color","mix","space","hue","hueInterpolationMethod","to","toString","format","parseColorInterpolationMethod","splits","split","parseColorPercent","colorCode","indexOf","map","s","trim","parseFloat","replace","_ColorMix","_defineProperty","startsWith","substring","length","INSTANCE"],"sources":["color-mix.ts"],"sourcesContent":["import Color from \"colorjs.io\";\n\nconst ColorMixSpace = [\n //rectangular\n \"srgb\", \"srgb-linear\", \"display-p3\" , \"a98-rgb\" , \"prophoto-rgb\" , \"rec2020\" ,\n \"lab\" , \"oklab\" , \"xyz\" , \"xyz-d50\" , \"xyz-d65\" ,\n //triangle\n \"hsl\" , \"hwb\" , \"lch\" , \"oklch\"\n];\n\nconst HueInterpolationMethod = [\n \"shorter\", \"longer\", \"increasing\", \"decreasing\"\n];\n\ninterface ColorInterpolationMethod {\n space: string,\n hueInterpolationMethod: string \n}\n\ninterface ColorPercent {\n color: string;\n percent: number;\n}\n\nclass ColorMix {\n static INSTANCE = new ColorMix();\n \n valueOf(expression: string) {\n const {\n colorInterpolationMethod, \n colorPercent1,\n colorPercent2\n } = this.parse(expression);\n let p1 = colorPercent1.percent;\n let p2 = colorPercent2.percent;\n if (p1 && !p2) {\n p2 = 100 - p1;\n } else if (!p1 && p2) {\n p1 = 100 - p2;\n } else if (p1 + p2 > 100) {\n const sum = p1 + p2;\n p1 = p1 / sum * 100;\n p2 = p2 / sum * 100;\n }\n p1 = p1/ 100;\n p2 = p2/ 100;\n \n return new Color(colorPercent1.color).mix(colorPercent2.color, p2, {\n space: colorInterpolationMethod.space,\n hue: colorInterpolationMethod.hueInterpolationMethod as any\n }).to(\"srgb\").toString({format: \"hex\"});\n }\n\n parseColorInterpolationMethod(expression: string): ColorInterpolationMethod {\n const splits = (expression.split(' ')) as string[];\n return {\n space: splits[1],\n hueInterpolationMethod: splits[2] || 'shorter'\n }\n }\n\n parseColorPercent(expression: string): ColorPercent {\n let colorCode = '';\n let percent = 0;\n if (expression.indexOf(')') > 0) {\n const splits = expression.split(')').map(s => s.trim());\n colorCode = splits[0] + ')';\n percent = splits[1] ? parseFloat((splits[1].replace('%', ''))) : 0;\n } else {\n const splits = (expression.split(' ')) as string[];\n colorCode = splits[0];\n percent = splits[1] ? parseFloat((splits[1].replace('%', ''))) : 0;\n }\n return {\n color: colorCode,\n percent: percent\n }\n }\n\n parse(expression: string): {\n colorInterpolationMethod : ColorInterpolationMethod,\n colorPercent1: ColorPercent,\n colorPercent2: ColorPercent\n } {\n const splits = expression.split(',').map(s => s.trim());\n return {\n colorInterpolationMethod: this.parseColorInterpolationMethod(splits[0]),\n colorPercent1: this.parseColorPercent(splits[1]),\n colorPercent2: this.parseColorPercent(splits[2])\n } as any;\n }\n\n}\n\nexport default {\n \"valueOf\" : (expression: string) => {\n if (expression.startsWith(\"color-mix\")) {\n expression = expression.substring(\"color-mix(\".length, expression.length - 1);\n }\n return ColorMix.INSTANCE.valueOf(expression);\n }\n};"],"mappings":";;;;AAAA,OAAOA,KAAK,MAAM,YAAY;AAE9B,MAAMC,aAAa,GAAG;AAClB;AACA,MAAM,EAAE,aAAa,EAAE,YAAY,EAAG,SAAS,EAAG,cAAc,EAAG,SAAS,EAC5E,KAAK,EAAG,OAAO,EAAG,KAAK,EAAG,SAAS,EAAG,SAAS;AAC/C;AACA,KAAK,EAAG,KAAK,EAAG,KAAK,EAAG,OAAO,CAClC;AAED,MAAMC,sBAAsB,GAAG,CAC3B,SAAS,EAAE,QAAQ,EAAE,YAAY,EAAE,YAAY,CAClD;AAYD,MAAMC,QAAQ,CAAC;EAGXC,OAAOA,CAACC,UAAkB,EAAE;IACxB,MAAM;MACFC,wBAAwB;MACxBC,aAAa;MACbC;IACJ,CAAC,GAAG,IAAI,CAACC,KAAK,CAACJ,UAAU,CAAC;IAC1B,IAAIK,EAAE,GAAGH,aAAa,CAACI,OAAO;IAC9B,IAAIC,EAAE,GAAGJ,aAAa,CAACG,OAAO;IAC9B,IAAID,EAAE,IAAI,CAACE,EAAE,EAAE;MACXA,EAAE,GAAG,GAAG,GAAGF,EAAE;IACjB,CAAC,MAAM,IAAI,CAACA,EAAE,IAAIE,EAAE,EAAE;MAClBF,EAAE,GAAG,GAAG,GAAGE,EAAE;IACjB,CAAC,MAAM,IAAIF,EAAE,GAAGE,EAAE,GAAG,GAAG,EAAE;MACtB,MAAMC,GAAG,GAAGH,EAAE,GAAGE,EAAE;MACnBF,EAAE,GAAGA,EAAE,GAAGG,GAAG,GAAG,GAAG;MACnBD,EAAE,GAAGA,EAAE,GAAGC,GAAG,GAAG,GAAG;IACvB;IACAH,EAAE,GAAGA,EAAE,GAAE,GAAG;IACZE,EAAE,GAAGA,EAAE,GAAE,GAAG;IAEZ,OAAO,IAAIZ,KA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