@sia.soul/sia-react-ui 0.1.3 → 0.1.4

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 (44) hide show
  1. package/dist/{Select-CJJ5LQap.d.ts → Select-GiTHMScg.d.cts} +4 -5
  2. package/dist/{Select-CJJ5LQap.d.cts → Select-rtDktLYY.d.ts} +4 -5
  3. package/dist/chart.cjs +731 -707
  4. package/dist/chart.css +1 -1
  5. package/dist/chart.js +3 -2
  6. package/dist/{chunk-6VXOLMKZ.js → chunk-5ZTWY3PG.js} +18 -1
  7. package/dist/{chunk-2RRTDU3N.js → chunk-EJ23MVR6.js} +3 -18
  8. package/dist/chunk-EJDPRAU2.js +36 -0
  9. package/dist/{chunk-IMZT6VCU.js → chunk-IHTODT53.js} +8 -5
  10. package/dist/{chunk-R4OWKIXJ.js → chunk-MJUTLEEE.js} +20 -8
  11. package/dist/{chunk-OQLDEVCF.js → chunk-PX6BOFTW.js} +10 -3
  12. package/dist/{chunk-OAC7BSUR.js → chunk-R7BVDN3Q.js} +91 -43
  13. package/dist/{chunk-Q4XNFMUH.js → chunk-S2JAJCLN.js} +6 -4
  14. package/dist/{chunk-NZAT2RUM.js → chunk-WHARTF2I.js} +10 -1
  15. package/dist/{chunk-I342FGQY.js → chunk-Z3T6RDQP.js} +1 -1
  16. package/dist/{core-DFYheaoJ.d.ts → core-CBtbeAms.d.cts} +2 -1
  17. package/dist/{core-De2pRX5w.d.cts → core-D8BSMfHD.d.ts} +2 -1
  18. package/dist/core.cjs +275 -210
  19. package/dist/core.css +211 -27
  20. package/dist/core.d.cts +3 -2
  21. package/dist/core.d.ts +3 -2
  22. package/dist/core.js +6 -5
  23. package/dist/index.cjs +2531 -2412
  24. package/dist/index.css +212 -28
  25. package/dist/index.d.cts +17 -9
  26. package/dist/index.d.ts +17 -9
  27. package/dist/index.js +224 -190
  28. package/dist/markdown-editor.cjs +52 -20
  29. package/dist/markdown-editor.d.cts +3 -1
  30. package/dist/markdown-editor.d.ts +3 -1
  31. package/dist/markdown-editor.js +2 -1
  32. package/dist/rich-text-editor.cjs +884 -864
  33. package/dist/rich-text-editor.d.cts +3 -1
  34. package/dist/rich-text-editor.d.ts +3 -1
  35. package/dist/rich-text-editor.js +4 -3
  36. package/dist/{select-date-range-DOyG1DGp.d.ts → select-date-range-CQ1vmze_.d.ts} +7 -4
  37. package/dist/{select-date-range-UyYrHex6.d.cts → select-date-range-DRmGaEzP.d.cts} +7 -4
  38. package/dist/select-date-range.cjs +972 -903
  39. package/dist/select-date-range.d.cts +3 -2
  40. package/dist/select-date-range.d.ts +3 -2
  41. package/dist/select-date-range.js +4 -3
  42. package/dist/shared-DAYZvZVu.d.cts +5 -0
  43. package/dist/shared-DAYZvZVu.d.ts +5 -0
  44. package/package.json +1 -1
@@ -34,8 +34,27 @@ __export(markdown_editor_exports, {
34
34
  });
35
35
  module.exports = __toCommonJS(markdown_editor_exports);
36
36
 
37
- // src/components/MarkdownEditor.tsx
37
+ // src/components/shared.ts
38
38
  var import_react = require("react");
39
+ var PlaceholderModeContext = (0, import_react.createContext)("default");
40
+ function usePlaceholderMode(mode) {
41
+ const inherited = (0, import_react.useContext)(PlaceholderModeContext);
42
+ return mode ?? inherited;
43
+ }
44
+
45
+ // src/components/FloatingPlaceholder.tsx
46
+ var import_jsx_runtime = require("react/jsx-runtime");
47
+ function useFloatingPlaceholder({ mode, placeholder, filled, active = false }) {
48
+ const enabled = usePlaceholderMode(mode) === "floating" && Boolean(placeholder);
49
+ return {
50
+ enabled,
51
+ className: enabled ? ` sia-placeholder-floating${filled ? " sia-placeholder-floating--filled" : ""}${active ? " sia-placeholder-floating--active" : ""}` : "",
52
+ label: enabled ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "sia-floating-placeholder", "aria-hidden": "true", children: placeholder }) : null
53
+ };
54
+ }
55
+
56
+ // src/components/MarkdownEditor.tsx
57
+ var import_react2 = require("react");
39
58
  var import_dist = require("vditor/dist/index.css");
40
59
 
41
60
  // src/components/markdownPaste.ts
@@ -144,7 +163,7 @@ var VDITOR_ZH_CN = {
144
163
  };
145
164
 
146
165
  // src/components/MarkdownEditor.tsx
147
- var import_jsx_runtime = require("react/jsx-runtime");
166
+ var import_jsx_runtime2 = require("react/jsx-runtime");
148
167
  var vditorLoaders = /* @__PURE__ */ new Map();
149
168
  var BASE_TOOLBAR = [
150
169
  "headings",
@@ -250,6 +269,7 @@ function MarkdownEditor({
250
269
  onChange,
251
270
  mode = "wysiwyg",
252
271
  placeholder = "\u8BF7\u8F93\u5165 Markdown \u6B63\u6587",
272
+ placeholderMode,
253
273
  minHeight = 320,
254
274
  disabled = false,
255
275
  ariaLabel = "Markdown \u7F16\u8F91\u5668",
@@ -261,25 +281,30 @@ function MarkdownEditor({
261
281
  style,
262
282
  ...props
263
283
  }) {
264
- const mountRef = (0, import_react.useRef)(null);
265
- const editorRef = (0, import_react.useRef)(null);
266
- const onChangeRef = (0, import_react.useRef)(onChange);
267
- const saveShortcutRef = (0, import_react.useRef)(saveShortcut);
268
- const uploadImageRef = (0, import_react.useRef)(onUploadImage);
269
- const disabledRef = (0, import_react.useRef)(disabled);
270
- const smartMarkdownPasteRef = (0, import_react.useRef)(smartMarkdownPaste);
271
- const valueRef = (0, import_react.useRef)(value ?? defaultValue);
272
- const lastEmittedValueRef = (0, import_react.useRef)(value ?? defaultValue);
273
- const [ready, setReady] = (0, import_react.useState)(false);
274
- const [loadError, setLoadError] = (0, import_react.useState)("");
284
+ const mountRef = (0, import_react2.useRef)(null);
285
+ const editorRef = (0, import_react2.useRef)(null);
286
+ const onChangeRef = (0, import_react2.useRef)(onChange);
287
+ const saveShortcutRef = (0, import_react2.useRef)(saveShortcut);
288
+ const uploadImageRef = (0, import_react2.useRef)(onUploadImage);
289
+ const disabledRef = (0, import_react2.useRef)(disabled);
290
+ const smartMarkdownPasteRef = (0, import_react2.useRef)(smartMarkdownPaste);
291
+ const valueRef = (0, import_react2.useRef)(value ?? defaultValue);
292
+ const lastEmittedValueRef = (0, import_react2.useRef)(value ?? defaultValue);
293
+ const [hasContent, setHasContent] = (0, import_react2.useState)(Boolean((value ?? defaultValue).trim()));
294
+ const floating = useFloatingPlaceholder({ mode: placeholderMode, placeholder, filled: hasContent });
295
+ const [ready, setReady] = (0, import_react2.useState)(false);
296
+ const [loadError, setLoadError] = (0, import_react2.useState)("");
275
297
  const hasImageUpload = Boolean(onUploadImage);
298
+ (0, import_react2.useEffect)(() => {
299
+ if (value !== void 0) setHasContent(Boolean(value.trim()));
300
+ }, [value]);
276
301
  onChangeRef.current = onChange;
277
302
  saveShortcutRef.current = saveShortcut;
278
303
  uploadImageRef.current = onUploadImage;
279
304
  disabledRef.current = disabled;
280
305
  smartMarkdownPasteRef.current = smartMarkdownPaste;
281
306
  valueRef.current = value ?? valueRef.current;
282
- (0, import_react.useEffect)(() => {
307
+ (0, import_react2.useEffect)(() => {
283
308
  const mount = mountRef.current;
284
309
  if (!mount) return;
285
310
  let disposed = false;
@@ -332,6 +357,7 @@ function MarkdownEditor({
332
357
  }
333
358
  } } : {},
334
359
  input: (markdown) => {
360
+ setHasContent(Boolean(markdown.trim()));
335
361
  lastEmittedValueRef.current = markdown;
336
362
  onChangeRef.current?.(markdown);
337
363
  },
@@ -380,14 +406,14 @@ function MarkdownEditor({
380
406
  if (editorInitialized) createdEditor?.destroy();
381
407
  };
382
408
  }, [ariaLabel, assetBaseUrl, hasImageUpload, minHeight, mode, placeholder]);
383
- (0, import_react.useEffect)(() => {
409
+ (0, import_react2.useEffect)(() => {
384
410
  const editor = editorRef.current;
385
411
  if (!editor || value === void 0) return;
386
412
  if (value === lastEmittedValueRef.current || editor.getValue() === value) return;
387
413
  lastEmittedValueRef.current = value;
388
414
  editor.setValue(value, true);
389
415
  }, [ready, value]);
390
- (0, import_react.useEffect)(() => {
416
+ (0, import_react2.useEffect)(() => {
391
417
  const editor = editorRef.current;
392
418
  if (!editor) return;
393
419
  if (disabled) editor.disabled();
@@ -397,16 +423,22 @@ function MarkdownEditor({
397
423
  ...style,
398
424
  "--sia-markdown-editor-min-height": typeof minHeight === "number" ? `${minHeight}px` : minHeight
399
425
  };
400
- return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
426
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
401
427
  "div",
402
428
  {
403
- className: ["sia-markdown-editor", className].filter(Boolean).join(" "),
429
+ className: ["sia-markdown-editor", floating.className, disabled ? "is-disabled" : "", className].filter(Boolean).join(" "),
404
430
  style: editorStyle,
405
431
  "data-ready": ready ? "true" : "false",
406
432
  ...props,
433
+ onBlurCapture: (event) => {
434
+ props.onBlurCapture?.(event);
435
+ const current = editorRef.current?.getValue();
436
+ if (current !== void 0) setHasContent(Boolean(current.trim()));
437
+ },
407
438
  children: [
408
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { ref: mountRef, className: "sia-markdown-editor__mount" }),
409
- !ready ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "sia-markdown-editor__loading", "aria-live": "polite", children: loadError || "\u6B63\u5728\u52A0\u8F7D\u7F16\u8F91\u5668\u2026" }) : null
439
+ floating.label,
440
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { ref: mountRef, className: "sia-markdown-editor__mount" }),
441
+ !ready ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "sia-markdown-editor__loading", "aria-live": "polite", children: loadError || "\u6B63\u5728\u52A0\u8F7D\u7F16\u8F91\u5668\u2026" }) : null
410
442
  ]
411
443
  }
412
444
  );
@@ -1,6 +1,7 @@
1
1
  import * as react from 'react';
2
2
  import { HTMLAttributes } from 'react';
3
3
  import * as vditor from 'vditor';
4
+ import { I as InputPlaceholderMode } from './shared-DAYZvZVu.cjs';
4
5
 
5
6
  type VditorConstructor = typeof vditor["default"];
6
7
  declare global {
@@ -15,6 +16,7 @@ interface MarkdownEditorProps extends Omit<HTMLAttributes<HTMLDivElement>, "defa
15
16
  onChange?: (markdown: string) => void;
16
17
  mode?: MarkdownEditorMode;
17
18
  placeholder?: string;
19
+ placeholderMode?: InputPlaceholderMode;
18
20
  minHeight?: number | string;
19
21
  disabled?: boolean;
20
22
  ariaLabel?: string;
@@ -23,6 +25,6 @@ interface MarkdownEditorProps extends Omit<HTMLAttributes<HTMLDivElement>, "defa
23
25
  onUploadImage?: (file: File) => Promise<string> | string;
24
26
  smartMarkdownPaste?: boolean;
25
27
  }
26
- declare function MarkdownEditor({ value, defaultValue, onChange, mode, placeholder, minHeight, disabled, ariaLabel, assetBaseUrl, saveShortcut, onUploadImage, smartMarkdownPaste, className, style, ...props }: MarkdownEditorProps): react.JSX.Element;
28
+ declare function MarkdownEditor({ value, defaultValue, onChange, mode, placeholder, placeholderMode, minHeight, disabled, ariaLabel, assetBaseUrl, saveShortcut, onUploadImage, smartMarkdownPaste, className, style, ...props }: MarkdownEditorProps): react.JSX.Element;
27
29
 
28
30
  export { MarkdownEditor, type MarkdownEditorMode, type MarkdownEditorProps };
@@ -1,6 +1,7 @@
1
1
  import * as react from 'react';
2
2
  import { HTMLAttributes } from 'react';
3
3
  import * as vditor from 'vditor';
4
+ import { I as InputPlaceholderMode } from './shared-DAYZvZVu.js';
4
5
 
5
6
  type VditorConstructor = typeof vditor["default"];
6
7
  declare global {
@@ -15,6 +16,7 @@ interface MarkdownEditorProps extends Omit<HTMLAttributes<HTMLDivElement>, "defa
15
16
  onChange?: (markdown: string) => void;
16
17
  mode?: MarkdownEditorMode;
17
18
  placeholder?: string;
19
+ placeholderMode?: InputPlaceholderMode;
18
20
  minHeight?: number | string;
19
21
  disabled?: boolean;
20
22
  ariaLabel?: string;
@@ -23,6 +25,6 @@ interface MarkdownEditorProps extends Omit<HTMLAttributes<HTMLDivElement>, "defa
23
25
  onUploadImage?: (file: File) => Promise<string> | string;
24
26
  smartMarkdownPaste?: boolean;
25
27
  }
26
- declare function MarkdownEditor({ value, defaultValue, onChange, mode, placeholder, minHeight, disabled, ariaLabel, assetBaseUrl, saveShortcut, onUploadImage, smartMarkdownPaste, className, style, ...props }: MarkdownEditorProps): react.JSX.Element;
28
+ declare function MarkdownEditor({ value, defaultValue, onChange, mode, placeholder, placeholderMode, minHeight, disabled, ariaLabel, assetBaseUrl, saveShortcut, onUploadImage, smartMarkdownPaste, className, style, ...props }: MarkdownEditorProps): react.JSX.Element;
27
29
 
28
30
  export { MarkdownEditor, type MarkdownEditorMode, type MarkdownEditorProps };
@@ -1,6 +1,7 @@
1
1
  import {
2
2
  MarkdownEditor
3
- } from "./chunk-6VXOLMKZ.js";
3
+ } from "./chunk-5ZTWY3PG.js";
4
+ import "./chunk-EJDPRAU2.js";
4
5
  export {
5
6
  MarkdownEditor
6
7
  };