@ceed/cds 1.2.2-next.3 → 1.2.2-next.5

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.
@@ -1,5 +1,5 @@
1
1
  import React from "react";
2
- import { Options } from "react-markdown";
2
+ import { type Options } from "react-markdown";
3
3
  import { MotionProps } from "framer-motion";
4
4
  import { TypographyProps } from "@mui/joy";
5
5
  import { TypographySystem } from "@mui/joy";
@@ -27,7 +27,7 @@ declare const Markdown: {
27
27
  defaultLinkAction?: "_self" | "_blank" | "_parent" | "_top" | "_unfencedTop" | undefined;
28
28
  markdownOptions?: import("react-markdown").Options | undefined;
29
29
  boldFontWeight?: "sm" | "md" | "lg" | "xl" | undefined;
30
- }): React.JSX.Element;
30
+ }): React.JSX.Element | null;
31
31
  displayName: string;
32
32
  };
33
33
  export { Markdown };
package/dist/index.cjs CHANGED
@@ -5,6 +5,9 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
5
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
6
  var __getProtoOf = Object.getPrototypeOf;
7
7
  var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __esm = (fn, res) => function __init() {
9
+ return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
10
+ };
8
11
  var __export = (target, all) => {
9
12
  for (var name in all)
10
13
  __defProp(target, name, { get: all[name], enumerable: true });
@@ -27,6 +30,53 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
27
30
  ));
28
31
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
32
 
33
+ // src/libs/rehype-accent/index.ts
34
+ var rehype_accent_exports = {};
35
+ __export(rehype_accent_exports, {
36
+ rehypeAccent: () => rehypeAccent
37
+ });
38
+ function rehypeAccent(options) {
39
+ const { accentColor } = options;
40
+ return (tree) => {
41
+ (0, import_unist_util_visit.visit)(tree, "text", (node, index, parent) => {
42
+ const value = node.value;
43
+ const regex = /\|\|.*?\|\|/g;
44
+ let match;
45
+ let lastIndex = 0;
46
+ const newNodes = [];
47
+ while ((match = regex.exec(value)) !== null) {
48
+ if (match.index > lastIndex) {
49
+ newNodes.push({
50
+ type: "text",
51
+ value: value.slice(lastIndex, match.index)
52
+ });
53
+ }
54
+ const innerText = match[0].split("||")[1];
55
+ newNodes.push({
56
+ type: "element",
57
+ tagName: "p",
58
+ properties: { textColor: accentColor },
59
+ children: [{ type: "text", value: innerText }]
60
+ });
61
+ lastIndex = match.index + match[0].length;
62
+ }
63
+ if (lastIndex < value.length) {
64
+ newNodes.push({ type: "text", value: value.slice(lastIndex) });
65
+ }
66
+ if (newNodes.length) {
67
+ parent.children.splice(index, 1, ...newNodes);
68
+ }
69
+ });
70
+ };
71
+ }
72
+ var import_unist_util_visit;
73
+ var init_rehype_accent = __esm({
74
+ "src/libs/rehype-accent/index.ts"() {
75
+ "use strict";
76
+ import_unist_util_visit = require("unist-util-visit");
77
+ }
78
+ });
79
+
30
80
  // src/index.ts
31
81
  var index_exports = {};
32
82
  __export(index_exports, {
@@ -4235,48 +4285,17 @@ var import_joy41 = require("@mui/joy");
4235
4285
 
4236
4286
  // src/components/Markdown/Markdown.tsx
4237
4287
  var import_react31 = __toESM(require("react"));
4238
- var import_react_markdown = __toESM(require("react-markdown"));
4239
4288
  var import_joy42 = require("@mui/joy");
4240
-
4241
- // src/libs/rehype-accent/index.ts
4242
- var import_unist_util_visit = require("unist-util-visit");
4243
- function rehypeAccent(options) {
4244
- const { accentColor } = options;
4245
- return (tree) => {
4246
- (0, import_unist_util_visit.visit)(tree, "text", (node, index, parent) => {
4247
- const value = node.value;
4248
- const regex = /\|\|.*?\|\|/g;
4249
- let match;
4250
- let lastIndex = 0;
4251
- const newNodes = [];
4252
- while ((match = regex.exec(value)) !== null) {
4253
- if (match.index > lastIndex) {
4254
- newNodes.push({
4255
- type: "text",
4256
- value: value.slice(lastIndex, match.index)
4257
- });
4258
- }
4259
- const innerText = match[0].split("||")[1];
4260
- newNodes.push({
4261
- type: "element",
4262
- tagName: "p",
4263
- properties: { textColor: accentColor },
4264
- children: [{ type: "text", value: innerText }]
4265
- });
4266
- lastIndex = match.index + match[0].length;
4267
- }
4268
- if (lastIndex < value.length) {
4269
- newNodes.push({ type: "text", value: value.slice(lastIndex) });
4270
- }
4271
- if (newNodes.length) {
4272
- parent.children.splice(index, 1, ...newNodes);
4273
- }
4274
- });
4275
- };
4276
- }
4277
-
4278
- // src/components/Markdown/Markdown.tsx
4289
+ var LazyReactMarkdown = (0, import_react31.lazy)(() => import("react-markdown"));
4279
4290
  var Markdown = (props) => {
4291
+ const [rehypeAccent2, setRehypeAccent] = (0, import_react31.useState)(null);
4292
+ (0, import_react31.useEffect)(() => {
4293
+ const loadRehypeAccent = async () => {
4294
+ const module2 = await Promise.resolve().then(() => (init_rehype_accent(), rehype_accent_exports));
4295
+ setRehypeAccent(() => module2.rehypeAccent);
4296
+ };
4297
+ loadRehypeAccent();
4298
+ }, []);
4280
4299
  const {
4281
4300
  color,
4282
4301
  textColor,
@@ -4288,6 +4307,9 @@ var Markdown = (props) => {
4288
4307
  content,
4289
4308
  ...innerProps
4290
4309
  } = props;
4310
+ if (!rehypeAccent2) {
4311
+ return null;
4312
+ }
4291
4313
  return /* @__PURE__ */ import_react31.default.createElement(
4292
4314
  Typography,
4293
4315
  {
@@ -4297,29 +4319,27 @@ var Markdown = (props) => {
4297
4319
  level: defaultLevel,
4298
4320
  ...innerProps
4299
4321
  },
4300
- /* @__PURE__ */ import_react31.default.createElement(
4301
- import_react_markdown.default,
4322
+ /* @__PURE__ */ import_react31.default.createElement(import_react31.Suspense, { fallback: null }, /* @__PURE__ */ import_react31.default.createElement(
4323
+ LazyReactMarkdown,
4302
4324
  {
4303
4325
  ...markdownOptions,
4304
4326
  children: content,
4305
- rehypePlugins: [[rehypeAccent, { accentColor }]],
4327
+ rehypePlugins: [[rehypeAccent2, { accentColor }]],
4306
4328
  components: {
4307
4329
  h1: ({ children }) => /* @__PURE__ */ import_react31.default.createElement(Typography, { color, textColor, level: "h1" }, children),
4308
4330
  h2: ({ children }) => /* @__PURE__ */ import_react31.default.createElement(Typography, { color, textColor, level: "h2" }, children),
4309
4331
  h3: ({ children }) => /* @__PURE__ */ import_react31.default.createElement(Typography, { color, textColor, level: "h3" }, children),
4310
4332
  h4: ({ children }) => /* @__PURE__ */ import_react31.default.createElement(Typography, { color, textColor, level: "h4" }, children),
4311
- p: ({ children, node }) => {
4312
- return /* @__PURE__ */ import_react31.default.createElement(
4313
- Typography,
4314
- {
4315
- color,
4316
- textColor,
4317
- level: defaultLevel,
4318
- ...node?.properties
4319
- },
4320
- children
4321
- );
4322
- },
4333
+ p: ({ children, node }) => /* @__PURE__ */ import_react31.default.createElement(
4334
+ Typography,
4335
+ {
4336
+ color,
4337
+ textColor,
4338
+ level: defaultLevel,
4339
+ ...node?.properties
4340
+ },
4341
+ children
4342
+ ),
4323
4343
  a: ({ children, href }) => /* @__PURE__ */ import_react31.default.createElement(import_joy42.Link, { href, target: defaultLinkAction }, children),
4324
4344
  hr: () => /* @__PURE__ */ import_react31.default.createElement(Divider, null),
4325
4345
  b: ({ children }) => /* @__PURE__ */ import_react31.default.createElement(Typography, { fontWeight: boldFontWeight }, children),
@@ -4327,7 +4347,7 @@ var Markdown = (props) => {
4327
4347
  ...markdownOptions?.components
4328
4348
  }
4329
4349
  }
4330
- )
4350
+ ))
4331
4351
  );
4332
4352
  };
4333
4353
  Markdown.displayName = "Markdown";
package/dist/index.js CHANGED
@@ -1,3 +1,59 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropNames = Object.getOwnPropertyNames;
3
+ var __esm = (fn, res) => function __init() {
4
+ return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
5
+ };
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+
11
+ // src/libs/rehype-accent/index.ts
12
+ var rehype_accent_exports = {};
13
+ __export(rehype_accent_exports, {
14
+ rehypeAccent: () => rehypeAccent
15
+ });
16
+ import { visit } from "unist-util-visit";
17
+ function rehypeAccent(options) {
18
+ const { accentColor } = options;
19
+ return (tree) => {
20
+ visit(tree, "text", (node, index, parent) => {
21
+ const value = node.value;
22
+ const regex = /\|\|.*?\|\|/g;
23
+ let match;
24
+ let lastIndex = 0;
25
+ const newNodes = [];
26
+ while ((match = regex.exec(value)) !== null) {
27
+ if (match.index > lastIndex) {
28
+ newNodes.push({
29
+ type: "text",
30
+ value: value.slice(lastIndex, match.index)
31
+ });
32
+ }
33
+ const innerText = match[0].split("||")[1];
34
+ newNodes.push({
35
+ type: "element",
36
+ tagName: "p",
37
+ properties: { textColor: accentColor },
38
+ children: [{ type: "text", value: innerText }]
39
+ });
40
+ lastIndex = match.index + match[0].length;
41
+ }
42
+ if (lastIndex < value.length) {
43
+ newNodes.push({ type: "text", value: value.slice(lastIndex) });
44
+ }
45
+ if (newNodes.length) {
46
+ parent.children.splice(index, 1, ...newNodes);
47
+ }
48
+ });
49
+ };
50
+ }
51
+ var init_rehype_accent = __esm({
52
+ "src/libs/rehype-accent/index.ts"() {
53
+ "use strict";
54
+ }
55
+ });
56
+
1
57
  // src/index.ts
2
58
  import {
3
59
  useTheme as useTheme3,
@@ -4202,49 +4258,18 @@ InsetDrawer.displayName = "InsetDrawer";
4202
4258
  import { Grid } from "@mui/joy";
4203
4259
 
4204
4260
  // src/components/Markdown/Markdown.tsx
4205
- import React29 from "react";
4206
- import ReactMarkdown from "react-markdown";
4261
+ import React29, { lazy, Suspense, useEffect as useEffect7, useState as useState8 } from "react";
4207
4262
  import { Link as Link2 } from "@mui/joy";
4208
-
4209
- // src/libs/rehype-accent/index.ts
4210
- import { visit } from "unist-util-visit";
4211
- function rehypeAccent(options) {
4212
- const { accentColor } = options;
4213
- return (tree) => {
4214
- visit(tree, "text", (node, index, parent) => {
4215
- const value = node.value;
4216
- const regex = /\|\|.*?\|\|/g;
4217
- let match;
4218
- let lastIndex = 0;
4219
- const newNodes = [];
4220
- while ((match = regex.exec(value)) !== null) {
4221
- if (match.index > lastIndex) {
4222
- newNodes.push({
4223
- type: "text",
4224
- value: value.slice(lastIndex, match.index)
4225
- });
4226
- }
4227
- const innerText = match[0].split("||")[1];
4228
- newNodes.push({
4229
- type: "element",
4230
- tagName: "p",
4231
- properties: { textColor: accentColor },
4232
- children: [{ type: "text", value: innerText }]
4233
- });
4234
- lastIndex = match.index + match[0].length;
4235
- }
4236
- if (lastIndex < value.length) {
4237
- newNodes.push({ type: "text", value: value.slice(lastIndex) });
4238
- }
4239
- if (newNodes.length) {
4240
- parent.children.splice(index, 1, ...newNodes);
4241
- }
4242
- });
4243
- };
4244
- }
4245
-
4246
- // src/components/Markdown/Markdown.tsx
4263
+ var LazyReactMarkdown = lazy(() => import("react-markdown"));
4247
4264
  var Markdown = (props) => {
4265
+ const [rehypeAccent2, setRehypeAccent] = useState8(null);
4266
+ useEffect7(() => {
4267
+ const loadRehypeAccent = async () => {
4268
+ const module = await Promise.resolve().then(() => (init_rehype_accent(), rehype_accent_exports));
4269
+ setRehypeAccent(() => module.rehypeAccent);
4270
+ };
4271
+ loadRehypeAccent();
4272
+ }, []);
4248
4273
  const {
4249
4274
  color,
4250
4275
  textColor,
@@ -4256,6 +4281,9 @@ var Markdown = (props) => {
4256
4281
  content,
4257
4282
  ...innerProps
4258
4283
  } = props;
4284
+ if (!rehypeAccent2) {
4285
+ return null;
4286
+ }
4259
4287
  return /* @__PURE__ */ React29.createElement(
4260
4288
  Typography,
4261
4289
  {
@@ -4265,29 +4293,27 @@ var Markdown = (props) => {
4265
4293
  level: defaultLevel,
4266
4294
  ...innerProps
4267
4295
  },
4268
- /* @__PURE__ */ React29.createElement(
4269
- ReactMarkdown,
4296
+ /* @__PURE__ */ React29.createElement(Suspense, { fallback: null }, /* @__PURE__ */ React29.createElement(
4297
+ LazyReactMarkdown,
4270
4298
  {
4271
4299
  ...markdownOptions,
4272
4300
  children: content,
4273
- rehypePlugins: [[rehypeAccent, { accentColor }]],
4301
+ rehypePlugins: [[rehypeAccent2, { accentColor }]],
4274
4302
  components: {
4275
4303
  h1: ({ children }) => /* @__PURE__ */ React29.createElement(Typography, { color, textColor, level: "h1" }, children),
4276
4304
  h2: ({ children }) => /* @__PURE__ */ React29.createElement(Typography, { color, textColor, level: "h2" }, children),
4277
4305
  h3: ({ children }) => /* @__PURE__ */ React29.createElement(Typography, { color, textColor, level: "h3" }, children),
4278
4306
  h4: ({ children }) => /* @__PURE__ */ React29.createElement(Typography, { color, textColor, level: "h4" }, children),
4279
- p: ({ children, node }) => {
4280
- return /* @__PURE__ */ React29.createElement(
4281
- Typography,
4282
- {
4283
- color,
4284
- textColor,
4285
- level: defaultLevel,
4286
- ...node?.properties
4287
- },
4288
- children
4289
- );
4290
- },
4307
+ p: ({ children, node }) => /* @__PURE__ */ React29.createElement(
4308
+ Typography,
4309
+ {
4310
+ color,
4311
+ textColor,
4312
+ level: defaultLevel,
4313
+ ...node?.properties
4314
+ },
4315
+ children
4316
+ ),
4291
4317
  a: ({ children, href }) => /* @__PURE__ */ React29.createElement(Link2, { href, target: defaultLinkAction }, children),
4292
4318
  hr: () => /* @__PURE__ */ React29.createElement(Divider, null),
4293
4319
  b: ({ children }) => /* @__PURE__ */ React29.createElement(Typography, { fontWeight: boldFontWeight }, children),
@@ -4295,7 +4321,7 @@ var Markdown = (props) => {
4295
4321
  ...markdownOptions?.components
4296
4322
  }
4297
4323
  }
4298
- )
4324
+ ))
4299
4325
  );
4300
4326
  };
4301
4327
  Markdown.displayName = "Markdown";
@@ -4367,10 +4393,10 @@ MenuButton.displayName = "MenuButton";
4367
4393
  import React31, {
4368
4394
  forwardRef as forwardRef9,
4369
4395
  useCallback as useCallback11,
4370
- useEffect as useEffect7,
4396
+ useEffect as useEffect8,
4371
4397
  useImperativeHandle as useImperativeHandle4,
4372
4398
  useRef as useRef6,
4373
- useState as useState8
4399
+ useState as useState9
4374
4400
  } from "react";
4375
4401
  import { IMaskInput as IMaskInput3, IMask as IMask3 } from "react-imask";
4376
4402
  import CalendarTodayIcon3 from "@mui/icons-material/CalendarToday";
@@ -4483,9 +4509,9 @@ var MonthPicker = forwardRef9(
4483
4509
  ),
4484
4510
  { disableStrict: true }
4485
4511
  );
4486
- const [anchorEl, setAnchorEl] = useState8(null);
4512
+ const [anchorEl, setAnchorEl] = useState9(null);
4487
4513
  const open = Boolean(anchorEl);
4488
- useEffect7(() => {
4514
+ useEffect8(() => {
4489
4515
  if (!anchorEl) {
4490
4516
  innerRef.current?.blur();
4491
4517
  }
@@ -4616,11 +4642,11 @@ var MonthPicker = forwardRef9(
4616
4642
  import React32, {
4617
4643
  forwardRef as forwardRef10,
4618
4644
  useCallback as useCallback12,
4619
- useEffect as useEffect8,
4645
+ useEffect as useEffect9,
4620
4646
  useImperativeHandle as useImperativeHandle5,
4621
4647
  useMemo as useMemo10,
4622
4648
  useRef as useRef7,
4623
- useState as useState9
4649
+ useState as useState10
4624
4650
  } from "react";
4625
4651
  import { IMaskInput as IMaskInput4, IMask as IMask4 } from "react-imask";
4626
4652
  import CalendarTodayIcon4 from "@mui/icons-material/CalendarToday";
@@ -4742,13 +4768,13 @@ var MonthRangePicker = forwardRef10(
4742
4768
  ),
4743
4769
  { disableStrict: true }
4744
4770
  );
4745
- const [anchorEl, setAnchorEl] = useState9(null);
4771
+ const [anchorEl, setAnchorEl] = useState10(null);
4746
4772
  const open = Boolean(anchorEl);
4747
4773
  const calendarValue = useMemo10(
4748
4774
  () => value ? parseDates2(value) : void 0,
4749
4775
  [value]
4750
4776
  );
4751
- useEffect8(() => {
4777
+ useEffect9(() => {
4752
4778
  if (!anchorEl) {
4753
4779
  innerRef.current?.blur();
4754
4780
  }
@@ -4997,7 +5023,7 @@ function Navigator(props) {
4997
5023
  Navigator.displayName = "Navigator";
4998
5024
 
4999
5025
  // src/components/PercentageInput/PercentageInput.tsx
5000
- import React36, { useCallback as useCallback13, useMemo as useMemo11, useState as useState10 } from "react";
5026
+ import React36, { useCallback as useCallback13, useMemo as useMemo11, useState as useState11 } from "react";
5001
5027
  import { NumericFormat as NumericFormat2 } from "react-number-format";
5002
5028
  import { styled as styled21, useThemeProps as useThemeProps8 } from "@mui/joy";
5003
5029
  var padDecimal = (value, decimalScale) => {
@@ -5060,7 +5086,7 @@ var PercentageInput = React36.forwardRef(function PercentageInput2(inProps, ref)
5060
5086
  [onChange, name]
5061
5087
  )
5062
5088
  );
5063
- const [internalError, setInternalError] = useState10(
5089
+ const [internalError, setInternalError] = useState11(
5064
5090
  max && _value && _value > max || min && _value && _value < min
5065
5091
  );
5066
5092
  const value = useMemo11(() => {
@@ -5543,10 +5569,10 @@ ThemeProvider.displayName = "ThemeProvider";
5543
5569
  // src/components/Uploader/Uploader.tsx
5544
5570
  import React41, {
5545
5571
  useCallback as useCallback14,
5546
- useEffect as useEffect9,
5572
+ useEffect as useEffect10,
5547
5573
  useMemo as useMemo12,
5548
5574
  useRef as useRef8,
5549
- useState as useState11
5575
+ useState as useState12
5550
5576
  } from "react";
5551
5577
  import { styled as styled24, Input as Input2 } from "@mui/joy";
5552
5578
  import MuiFileUploadIcon from "@mui/icons-material/CloudUploadRounded";
@@ -5728,12 +5754,12 @@ var Uploader = React41.memo(
5728
5754
  } = props;
5729
5755
  const dropZoneRef = useRef8(null);
5730
5756
  const inputRef = useRef8(null);
5731
- const [errorText, setErrorText] = useState11();
5732
- const [files, setFiles] = useState11([]);
5733
- const [uploaded, setUploaded] = useState11(
5757
+ const [errorText, setErrorText] = useState12();
5758
+ const [files, setFiles] = useState12([]);
5759
+ const [uploaded, setUploaded] = useState12(
5734
5760
  props.uploaded || []
5735
5761
  );
5736
- const [previewState, setPreviewState] = useState11("idle");
5762
+ const [previewState, setPreviewState] = useState12("idle");
5737
5763
  const accepts = useMemo12(
5738
5764
  () => accept.split(",").map((accept2) => accept2.trim()),
5739
5765
  [accept]
@@ -5845,7 +5871,7 @@ var Uploader = React41.memo(
5845
5871
  onChange
5846
5872
  ]
5847
5873
  );
5848
- useEffect9(() => {
5874
+ useEffect10(() => {
5849
5875
  if (!dropZoneRef.current || disabled) {
5850
5876
  return;
5851
5877
  }
@@ -5893,7 +5919,7 @@ var Uploader = React41.memo(
5893
5919
  );
5894
5920
  return () => cleanup?.();
5895
5921
  }, [disabled, addFiles]);
5896
- useEffect9(() => {
5922
+ useEffect10(() => {
5897
5923
  if (inputRef.current && minCount) {
5898
5924
  if (files.length < minCount) {
5899
5925
  inputRef.current.setCustomValidity(