@sia.soul/sia-react-ui 0.1.3 → 0.1.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.
- package/dist/{Select-CJJ5LQap.d.ts → Select-GiTHMScg.d.cts} +4 -5
- package/dist/{Select-CJJ5LQap.d.cts → Select-rtDktLYY.d.ts} +4 -5
- package/dist/chart.cjs +731 -707
- package/dist/chart.css +1 -1
- package/dist/chart.js +3 -2
- package/dist/{chunk-6VXOLMKZ.js → chunk-5ZTWY3PG.js} +18 -1
- package/dist/{chunk-2RRTDU3N.js → chunk-EJ23MVR6.js} +3 -18
- package/dist/chunk-EJDPRAU2.js +36 -0
- package/dist/{chunk-IMZT6VCU.js → chunk-IHTODT53.js} +8 -5
- package/dist/{chunk-R4OWKIXJ.js → chunk-MJUTLEEE.js} +20 -8
- package/dist/{chunk-OQLDEVCF.js → chunk-PX6BOFTW.js} +10 -3
- package/dist/{chunk-OAC7BSUR.js → chunk-R7BVDN3Q.js} +91 -43
- package/dist/{chunk-Q4XNFMUH.js → chunk-S2JAJCLN.js} +6 -4
- package/dist/{chunk-NZAT2RUM.js → chunk-WHARTF2I.js} +10 -1
- package/dist/{chunk-I342FGQY.js → chunk-Z3T6RDQP.js} +1 -1
- package/dist/{core-DFYheaoJ.d.ts → core-CBtbeAms.d.cts} +2 -1
- package/dist/{core-De2pRX5w.d.cts → core-D8BSMfHD.d.ts} +2 -1
- package/dist/core.cjs +275 -210
- package/dist/core.css +294 -41
- package/dist/core.d.cts +3 -2
- package/dist/core.d.ts +3 -2
- package/dist/core.js +6 -5
- package/dist/index.cjs +2709 -2434
- package/dist/index.css +295 -42
- package/dist/index.d.cts +23 -9
- package/dist/index.d.ts +23 -9
- package/dist/index.js +414 -224
- package/dist/markdown-editor.cjs +52 -20
- package/dist/markdown-editor.d.cts +3 -1
- package/dist/markdown-editor.d.ts +3 -1
- package/dist/markdown-editor.js +2 -1
- package/dist/rich-text-editor.cjs +884 -864
- package/dist/rich-text-editor.d.cts +3 -1
- package/dist/rich-text-editor.d.ts +3 -1
- package/dist/rich-text-editor.js +4 -3
- package/dist/{select-date-range-DOyG1DGp.d.ts → select-date-range-CQ1vmze_.d.ts} +7 -4
- package/dist/{select-date-range-UyYrHex6.d.cts → select-date-range-DRmGaEzP.d.cts} +7 -4
- package/dist/select-date-range.cjs +972 -903
- package/dist/select-date-range.d.cts +3 -2
- package/dist/select-date-range.d.ts +3 -2
- package/dist/select-date-range.js +4 -3
- package/dist/shared-DAYZvZVu.d.cts +5 -0
- package/dist/shared-DAYZvZVu.d.ts +5 -0
- package/package.json +1 -1
package/dist/markdown-editor.cjs
CHANGED
|
@@ -34,8 +34,27 @@ __export(markdown_editor_exports, {
|
|
|
34
34
|
});
|
|
35
35
|
module.exports = __toCommonJS(markdown_editor_exports);
|
|
36
36
|
|
|
37
|
-
// src/components/
|
|
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
|
|
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,
|
|
265
|
-
const editorRef = (0,
|
|
266
|
-
const onChangeRef = (0,
|
|
267
|
-
const saveShortcutRef = (0,
|
|
268
|
-
const uploadImageRef = (0,
|
|
269
|
-
const disabledRef = (0,
|
|
270
|
-
const smartMarkdownPasteRef = (0,
|
|
271
|
-
const valueRef = (0,
|
|
272
|
-
const lastEmittedValueRef = (0,
|
|
273
|
-
const [
|
|
274
|
-
const
|
|
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,
|
|
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,
|
|
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,
|
|
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,
|
|
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
|
-
|
|
409
|
-
|
|
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 };
|