@kemu-io/hs-react 0.2.38 → 0.2.39

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.
@@ -3,6 +3,11 @@ export type WrapperProps = {
3
3
  cHeight?: number | string;
4
4
  noPadding?: boolean;
5
5
  noBorderRadius?: boolean;
6
+ /**
7
+ * Overrides the default widget color from the manifest.
8
+ * If not set, the widget will use the color defined in its manifest file.
9
+ */
10
+ overrideColor?: string;
6
11
  };
7
12
  export type WidthLessProps = Omit<WrapperProps, "cWidth" | "cHeight"> & {
8
13
  width?: number | string;
@@ -1,12 +1,13 @@
1
1
  "use strict";var __importDefault=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(exports,"__esModule",{value:!0});const jsx_runtime_1=require("react/jsx-runtime"),styled_1=__importDefault(require("@emotion/styled")),constants_js_1=require("../constants.js"),react_1=require("react"),InstanceContext_js_1=require("../lib/InstanceContext.js"),WidgetContainer=styled_1.default.div`
2
2
  width: ${({cWidth:e})=>"number"==typeof e?`${e}px`:e||"64px"};
3
3
  height: ${({cHeight:e})=>"number"==typeof e?`${e}px`:e||"64px"};
4
- background-color: ${({manifest:e,disabled:t,serviceOnline:s})=>t||!s?"#bbb":e.color};
4
+ background-color: ${({manifest:e,disabled:t,serviceOnline:r,overrideColor:i})=>t||!r?"#bbb":i||e.color};
5
5
  ${({noBorderRadius:e})=>e?"":"border-radius: 8px;"}
6
6
  ${({noPadding:e})=>e?"":"padding: 6px;"}
7
7
 
8
8
  /* Add a shadow when the widget is selected */
9
9
  .${constants_js_1.WIDGET_SELECTED_CLS} & {
10
- box-shadow: 0px 0px 7px 1px ${({manifest:e,disabled:t,serviceOnline:s})=>t||!s?"#bbb":e.color};
10
+ box-shadow: 0px 0px 7px 1px
11
+ ${({manifest:e,disabled:t,serviceOnline:r,overrideColor:i})=>t||!r?"#bbb":i||e.color};
11
12
  }
12
- `,Wrap=e=>{const t=(0,react_1.useContext)(InstanceContext_js_1.WidgetInstanceContext).getWidgetProps(),{className:s,width:r,height:n,...i}=e;return(0,jsx_runtime_1.jsx)(WidgetContainer,{cWidth:r,cHeight:n,...i,...t,className:`k-hs-wrap ${s||""}`,children:e.children})};exports.default=Wrap;
13
+ `,Wrap=e=>{const t=(0,react_1.useContext)(InstanceContext_js_1.WidgetInstanceContext).getWidgetProps(),{className:r,width:i,height:n,...o}=e,s=t.variantId?t.manifest.variants?.find((e=>e.id===t.variantId)):null,a=s?s.color||t.manifest.color:void 0;return(0,jsx_runtime_1.jsx)(WidgetContainer,{cWidth:i,cHeight:n,...o,...t,className:`k-hs-wrap ${r||""}`,overrideColor:e.overrideColor||a,children:e.children})};exports.default=Wrap;
@@ -68,6 +68,11 @@ type WrapperProps$1 = {
68
68
  cHeight?: number | string;
69
69
  noPadding?: boolean;
70
70
  noBorderRadius?: boolean;
71
+ /**
72
+ * Overrides the default widget color from the manifest.
73
+ * If not set, the widget will use the color defined in its manifest file.
74
+ */
75
+ overrideColor?: string;
71
76
  };
72
77
  export type WidthLessProps = Omit<WrapperProps$1, "cWidth" | "cHeight"> & {
73
78
  width?: number | string;
@@ -3,6 +3,11 @@ export type WrapperProps = {
3
3
  cHeight?: number | string;
4
4
  noPadding?: boolean;
5
5
  noBorderRadius?: boolean;
6
+ /**
7
+ * Overrides the default widget color from the manifest.
8
+ * If not set, the widget will use the color defined in its manifest file.
9
+ */
10
+ overrideColor?: string;
6
11
  };
7
12
  export type WidthLessProps = Omit<WrapperProps, "cWidth" | "cHeight"> & {
8
13
  width?: number | string;
@@ -1,12 +1,13 @@
1
1
  import{jsx as _jsx}from"react/jsx-runtime";import styled from"@emotion/styled";import{WIDGET_SELECTED_CLS}from"../constants.js";import{useContext}from"react";import{WidgetInstanceContext}from"../lib/InstanceContext.js";const WidgetContainer=styled.div`
2
2
  width: ${({cWidth:e})=>"number"==typeof e?`${e}px`:e||"64px"};
3
3
  height: ${({cHeight:e})=>"number"==typeof e?`${e}px`:e||"64px"};
4
- background-color: ${({manifest:e,disabled:t,serviceOnline:i})=>t||!i?"#bbb":e.color};
4
+ background-color: ${({manifest:e,disabled:t,serviceOnline:o,overrideColor:r})=>t||!o?"#bbb":r||e.color};
5
5
  ${({noBorderRadius:e})=>e?"":"border-radius: 8px;"}
6
6
  ${({noPadding:e})=>e?"":"padding: 6px;"}
7
7
 
8
8
  /* Add a shadow when the widget is selected */
9
9
  .${WIDGET_SELECTED_CLS} & {
10
- box-shadow: 0px 0px 7px 1px ${({manifest:e,disabled:t,serviceOnline:i})=>t||!i?"#bbb":e.color};
10
+ box-shadow: 0px 0px 7px 1px
11
+ ${({manifest:e,disabled:t,serviceOnline:o,overrideColor:r})=>t||!o?"#bbb":r||e.color};
11
12
  }
12
- `,Wrap=e=>{const t=useContext(WidgetInstanceContext).getWidgetProps(),{className:i,width:o,height:n,...r}=e;return _jsx(WidgetContainer,{cWidth:o,cHeight:n,...r,...t,className:`k-hs-wrap ${i||""}`,children:e.children})};export default Wrap;
13
+ `,Wrap=e=>{const t=useContext(WidgetInstanceContext).getWidgetProps(),{className:o,width:r,height:i,...n}=e,d=t.variantId?t.manifest.variants?.find((e=>e.id===t.variantId)):null,s=d?d.color||t.manifest.color:void 0;return _jsx(WidgetContainer,{cWidth:r,cHeight:i,...n,...t,className:`k-hs-wrap ${o||""}`,overrideColor:e.overrideColor||s,children:e.children})};export default Wrap;
@@ -68,6 +68,11 @@ type WrapperProps$1 = {
68
68
  cHeight?: number | string;
69
69
  noPadding?: boolean;
70
70
  noBorderRadius?: boolean;
71
+ /**
72
+ * Overrides the default widget color from the manifest.
73
+ * If not set, the widget will use the color defined in its manifest file.
74
+ */
75
+ overrideColor?: string;
71
76
  };
72
77
  export type WidthLessProps = Omit<WrapperProps$1, "cWidth" | "cHeight"> & {
73
78
  width?: number | string;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@kemu-io/hs-react",
3
3
  "type": "module",
4
- "version": "0.2.38",
4
+ "version": "0.2.39",
5
5
  "description": "Kemu Hub Service library for React",
6
6
  "author": "Kemu Pty Ltd",
7
7
  "main": "cjs/WidgetWrapper.js",