@yklyklpackages/message-card 0.5.0 → 0.6.1

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/index.umd.js CHANGED
@@ -165,7 +165,7 @@
165
165
  }
166
166
  return defaultValue;
167
167
  }
168
- const defaultTheme$1 = {
168
+ const defaultTheme$2 = {
169
169
  fontSize: {
170
170
  FontSizes_JDH_Headline1: 46,
171
171
  FontSizes_JDH_Headline2: 34,
@@ -182,6 +182,9 @@
182
182
  Color_JDH_Red_Price: "#FF0F23",
183
183
  Color_JDH_Red_Discount: "#FF0F23",
184
184
  Color_JDH_Green_Success: "#67CC52",
185
+ Color_JDH_Green_Background: "#17CB8E1F",
186
+ Color_JDH_Red_Background: "#FF0F231F",
187
+ Color_JDH_Yellow_Background: "#FF80001F",
185
188
  Color_JDH_Gray_Headline: "#222222",
186
189
  Color_JDH_Gray_Text: "#222222",
187
190
  Color_JDH_Gray_SecondText: "#575859",
@@ -207,14 +210,68 @@
207
210
  Spacing_JDH_xxs: 4
208
211
  },
209
212
  borderRadius: {
210
- Radius_JDH_LargeExtra: 32,
211
- Radius_JDH_Large: 24,
212
- Radius_JDH_Medium: 16,
213
- Radius_JDH_Small: 8,
214
- Radius_JDH_Mini: 6
213
+ Radius_JDH_xxl: 32,
214
+ Radius_JDH_xl: 24,
215
+ Radius_JDH_lg: 16,
216
+ Radius_JDH_sm: 8,
217
+ Radius_JDH_xs: 6
218
+ },
219
+ components: {}
220
+ };
221
+ const defaultTheme$1 = {
222
+ fontSize: {
223
+ FontSizes_JDH_Headline1: 23,
224
+ FontSizes_JDH_Headline2: 17,
225
+ FontSizes_JDH_Title: 15,
226
+ FontSizes_JDH_Text: 14,
227
+ FontSizes_JDH_AccentText: 12,
228
+ FontSizes_JDH_TagText: 10
229
+ },
230
+ color: {
231
+ Color_JDH_Primary: "#17CB8E",
232
+ Color_JDH_Accent1: "#FF8000",
233
+ Color_JDH_Accent2: "#73B0FF",
234
+ Color_JDH_Red_Danger: "#FF0F23",
235
+ Color_JDH_Red_Price: "#FF0F23",
236
+ Color_JDH_Red_Discount: "#FF0F23",
237
+ Color_JDH_Green_Success: "#67CC52",
238
+ Color_JDH_Green_Background: "#17CB8E1F",
239
+ Color_JDH_Red_Background: "#FF0F231F",
240
+ Color_JDH_Yellow_Background: "#FF80001F",
241
+ Color_JDH_Gray_Headline: "#222222",
242
+ Color_JDH_Gray_Text: "#222222",
243
+ Color_JDH_Gray_SecondText: "#575859",
244
+ Color_JDH_Gray_AccentText: "#858687",
245
+ Color_JDH_Gray_DividingLine: "#D3D3D3",
246
+ Color_JDH_Gray_Background: "#F5F5F6",
247
+ Color_JDH_Gray_CardBackground: "#E5E9EB",
248
+ Color_JDH_Gray_Card: "#FFFFFF",
249
+ Color_JDH_Gray_Mask: "#00000080"
250
+ },
251
+ fontWeight: {
252
+ FontWeight_JDH_Normal: 400,
253
+ FontWeight_JDH_Medium: 500
254
+ },
255
+ space: {
256
+ Spacing_JDH_4xl: 16,
257
+ Spacing_JDH_xxxl: 14,
258
+ Spacing_JDH_xxl: 12,
259
+ Spacing_JDH_xl: 10,
260
+ Spacing_JDH_lg: 8,
261
+ Spacing_JDH_sm: 6,
262
+ Spacing_JDH_xs: 4,
263
+ Spacing_JDH_xxs: 2
264
+ },
265
+ borderRadius: {
266
+ Radius_JDH_xxl: 16,
267
+ Radius_JDH_xl: 12,
268
+ Radius_JDH_lg: 8,
269
+ Radius_JDH_sm: 4,
270
+ Radius_JDH_xs: 3
215
271
  },
216
272
  components: {}
217
273
  };
274
+ const DEFAULT_SCALE = 0.5;
218
275
  var __defProp$v = Object.defineProperty;
219
276
  var __defProps$q = Object.defineProperties;
220
277
  var __getOwnPropDescs$q = Object.getOwnPropertyDescriptors;
@@ -234,13 +291,14 @@
234
291
  return a;
235
292
  };
236
293
  var __spreadProps$q = (a, b) => __defProps$q(a, __getOwnPropDescs$q(b));
237
- const ThemeContext = React.createContext(defaultTheme$1);
294
+ const ThemeContext = React.createContext(defaultTheme$2);
238
295
  const ThemeProvider = ({
296
+ scale = DEFAULT_SCALE,
239
297
  theme,
240
298
  children
241
299
  }) => {
242
300
  const merged = React.useMemo(() => {
243
- const base = defaultTheme$1;
301
+ const base = scale <= DEFAULT_SCALE ? defaultTheme$2 : defaultTheme$1;
244
302
  return __spreadProps$q(__spreadValues$s({}, base), {
245
303
  fontSize: __spreadValues$s(__spreadValues$s({}, base.fontSize), (theme == null ? void 0 : theme.fontSize) || {}),
246
304
  color: __spreadValues$s(__spreadValues$s({}, base.color), (theme == null ? void 0 : theme.color) || {}),
@@ -4573,6 +4631,7 @@
4573
4631
  const buildItemContainerStyle = (index2, count, props, horizontal = false, scale = 1) => {
4574
4632
  const style2 = __spreadValues$q({
4575
4633
  width: (props == null ? void 0 : props.flexDirection) === "row" ? "auto" : "100%",
4634
+ flexDirection: props.direction || "column",
4576
4635
  height: "auto",
4577
4636
  boxSizing: "border-box",
4578
4637
  display: "flex",
@@ -5476,6 +5535,16 @@
5476
5535
  if (!node2) return null;
5477
5536
  const { layoutType, props, subType } = node2;
5478
5537
  const layoutProps = props;
5538
+ if (typeof (customLayoutComponent == null ? void 0 : customLayoutComponent[subType]) !== "undefined") {
5539
+ return /* @__PURE__ */ jsxRuntime.jsx(
5540
+ CustomLayout,
5541
+ {
5542
+ customComponent: customLayoutComponent[subType],
5543
+ props: layoutProps,
5544
+ children
5545
+ }
5546
+ );
5547
+ }
5479
5548
  switch (subType) {
5480
5549
  case "full-row":
5481
5550
  return /* @__PURE__ */ jsxRuntime.jsx(FullRowLayout, __spreadProps$c(__spreadValues$e({ props: layoutProps }, { originProps }), { children }));
@@ -5500,14 +5569,7 @@
5500
5569
  case "scroll-view":
5501
5570
  return /* @__PURE__ */ jsxRuntime.jsx(ScrollViewLayout, __spreadProps$c(__spreadValues$e({}, node2), { children }));
5502
5571
  default:
5503
- return typeof (customLayoutComponent == null ? void 0 : customLayoutComponent[subType]) !== "undefined" ? /* @__PURE__ */ jsxRuntime.jsx(
5504
- CustomLayout,
5505
- {
5506
- customComponent: customLayoutComponent[subType],
5507
- props: layoutProps,
5508
- children
5509
- }
5510
- ) : /* @__PURE__ */ jsxRuntime.jsx(UnknownRenderer, { type: String(layoutType), prefix: "未知布局类型" });
5572
+ return /* @__PURE__ */ jsxRuntime.jsx(UnknownRenderer, { type: String(layoutType), prefix: "未知布局类型" });
5511
5573
  }
5512
5574
  };
5513
5575
  const isPlainObject$1 = (obj) => Object.prototype.toString.call(obj) === "[object Object]";
@@ -29963,6 +30025,15 @@
29963
30025
  );
29964
30026
  if (!node2) return null;
29965
30027
  const { renderType, props, subType } = node2;
30028
+ if (typeof (customRenderComponent == null ? void 0 : customRenderComponent[subType]) !== "undefined") {
30029
+ return /* @__PURE__ */ jsxRuntime.jsx(
30030
+ CustomRenderFromProps,
30031
+ {
30032
+ props,
30033
+ component: customRenderComponent[subType]
30034
+ }
30035
+ );
30036
+ }
29966
30037
  switch (subType) {
29967
30038
  case "text":
29968
30039
  return /* @__PURE__ */ jsxRuntime.jsx(TextRender, __spreadValues$4({}, props));
@@ -30026,13 +30097,7 @@
30026
30097
  return /* @__PURE__ */ jsxRuntime.jsx(CustomRenderFromIM, __spreadProps$3(__spreadValues$4({}, props), { originProps }));
30027
30098
  }
30028
30099
  default:
30029
- return typeof (customRenderComponent == null ? void 0 : customRenderComponent[subType]) !== "undefined" ? /* @__PURE__ */ jsxRuntime.jsx(
30030
- CustomRenderFromProps,
30031
- {
30032
- props,
30033
- component: customRenderComponent[subType]
30034
- }
30035
- ) : /* @__PURE__ */ jsxRuntime.jsx(UnknownRenderer, { type: String(renderType), prefix: "未知渲染类型" });
30100
+ return /* @__PURE__ */ jsxRuntime.jsx(UnknownRenderer, { type: String(renderType), prefix: "未知渲染类型" });
30036
30101
  }
30037
30102
  };
30038
30103
  const ComponentRenderer = ({
@@ -30123,6 +30188,11 @@
30123
30188
  } = props;
30124
30189
  const { template, referenceComponentList, data } = component;
30125
30190
  const { editorMode: editorMode2 } = useForEditor({});
30191
+ const responsiveValue = React.useMemo(() => {
30192
+ return {
30193
+ scale: props.devicePixelRatio ? 1 / props.devicePixelRatio : DEFAULT_SCALE
30194
+ };
30195
+ }, []);
30126
30196
  const [values, setValues] = React.useState({});
30127
30197
  const [dsValues, setDsValues] = React.useState({});
30128
30198
  const [nodes, setNodes] = React.useState([]);
@@ -30192,7 +30262,7 @@
30192
30262
  },
30193
30263
  [onAction]
30194
30264
  );
30195
- const content = /* @__PURE__ */ jsxRuntime.jsx(
30265
+ const content = /* @__PURE__ */ jsxRuntime.jsx(ResponsiveContext.Provider, { value: responsiveValue, children: /* @__PURE__ */ jsxRuntime.jsx(
30196
30266
  ActionProvider,
30197
30267
  {
30198
30268
  onAction,
@@ -30221,11 +30291,8 @@
30221
30291
  )
30222
30292
  ] })
30223
30293
  }
30224
- );
30225
- if (theme) {
30226
- return /* @__PURE__ */ jsxRuntime.jsx(ThemeProvider, { theme, children: content });
30227
- }
30228
- return content;
30294
+ ) });
30295
+ return /* @__PURE__ */ jsxRuntime.jsx(ThemeProvider, { scale: responsiveValue.scale, theme, children: content });
30229
30296
  };
30230
30297
  var __defProp$5 = Object.defineProperty;
30231
30298
  var __defNormalProp$5 = (obj, key, value) => key in obj ? __defProp$5(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
@@ -33928,11 +33995,6 @@
33928
33995
  };
33929
33996
  var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
33930
33997
  const MessageCard = (props) => {
33931
- const responsiveValue = React.useMemo(() => {
33932
- return {
33933
- scale: 0.5
33934
- };
33935
- }, []);
33936
33998
  const {
33937
33999
  templateJson,
33938
34000
  templateData,
@@ -33943,7 +34005,7 @@
33943
34005
  theme
33944
34006
  } = useMessageCardLogic(props);
33945
34007
  const { data = {} } = props;
33946
- return /* @__PURE__ */ jsxRuntime.jsx(ResponsiveContext.Provider, { value: responsiveValue, children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "message-card-wrapper", children: /* @__PURE__ */ jsxRuntime.jsx(
34008
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "message-card-wrapper", children: /* @__PURE__ */ jsxRuntime.jsx(
33947
34009
  Render,
33948
34010
  __spreadValues$1({
33949
34011
  component: __spreadProps(__spreadValues$1({}, templateJson), {
@@ -33964,7 +34026,7 @@
33964
34026
  },
33965
34027
  externalActions: props.externalActions
33966
34028
  }, props)
33967
- ) }) });
34029
+ ) });
33968
34030
  };
33969
34031
  const MessageCard_default = React.forwardRef(MessageCard);
33970
34032
  var __defProp = Object.defineProperty;
@@ -33993,7 +34055,7 @@
33993
34055
  exports2.ThemeProvider = ThemeProvider;
33994
34056
  exports2.createRenderComponent = createRenderComponent;
33995
34057
  exports2.default = MessageCard_default;
33996
- exports2.defaultTheme = defaultTheme$1;
34058
+ exports2.defaultTheme = defaultTheme$2;
33997
34059
  exports2.isLayoutNode = isLayoutNode;
33998
34060
  exports2.isRenderNode = isRenderNode;
33999
34061
  exports2.useTheme = useTheme$1;