@apipass/design-system 5.7.0 → 5.8.0
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/lib/embedded-styles.js +2 -2
- package/dist/lib/style.css +1 -1
- package/dist/lib/ui/primitives/JsonViewer/JsonEditor.cjs +1 -1
- package/dist/lib/ui/primitives/JsonViewer/JsonEditor.cjs.map +1 -1
- package/dist/lib/ui/primitives/JsonViewer/JsonEditor.js +43 -42
- package/dist/lib/ui/primitives/JsonViewer/JsonEditor.js.map +1 -1
- package/dist/lib/ui/primitives/JsonViewer/JsonViewer.cjs +1 -1
- package/dist/lib/ui/primitives/JsonViewer/JsonViewer.cjs.map +1 -1
- package/dist/lib/ui/primitives/JsonViewer/JsonViewer.js +33 -26
- package/dist/lib/ui/primitives/JsonViewer/JsonViewer.js.map +1 -1
- package/dist/lib/ui/primitives/JsonViewer/json-code-mirror.cjs +1 -1
- package/dist/lib/ui/primitives/JsonViewer/json-code-mirror.cjs.map +1 -1
- package/dist/lib/ui/primitives/JsonViewer/json-code-mirror.js +36 -31
- package/dist/lib/ui/primitives/JsonViewer/json-code-mirror.js.map +1 -1
- package/dist/types/ui/primitives/JsonViewer/JsonEditor.d.ts +3 -3
- package/dist/types/ui/primitives/JsonViewer/JsonViewer.d.ts +3 -3
- package/dist/types/ui/primitives/JsonViewer/json-code-mirror.d.ts +7 -0
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"json-code-mirror.js","sources":["../../../../../src/ui/primitives/JsonViewer/json-code-mirror.ts"],"sourcesContent":["import { EditorView } from \"@codemirror/view\";\nimport { json } from \"@codemirror/lang-json\";\nimport { foldGutter, HighlightStyle, syntaxHighlighting } from \"@codemirror/language\";\nimport { tags as t } from \"@lezer/highlight\";\n\nexport const jsonHighlightStyle = HighlightStyle.define([\n { tag: t.propertyName, color: \"var(--json-viewer-color-key)\" },\n { tag: t.string, color: \"var(--json-viewer-color-string)\", fontWeight: 600 },\n { tag: [t.number, t.bool, t.null], color: \"var(--json-viewer-color-scalar)\" },\n { tag: [t.separator, t.squareBracket, t.brace], color: \"var(--json-viewer-color-punctuation)\" },\n]);\n\nexport const jsonEditorTheme = EditorView.theme({\n \"&\": { backgroundColor: \"transparent\", color: \"var(--json-viewer-color-punctuation)\", fontSize: \"13px\" },\n \"&.cm-focused\": { outline: \"none\" },\n \".cm-content\": { fontFamily: \"var(--sds-typography-family-mono)\", padding: \"8px 124px 12px 4px\" },\n \".cm-gutters\": {\n backgroundColor: \"transparent\",\n border: \"none\",\n color: \"var(--json-viewer-color-caret)\",\n paddingLeft: \"5px\",\n },\n \".cm-scroller\": { overflow: \"auto\" },\n});\n\nexport const jsonEditorExtensions = [json(), foldGutter(), syntaxHighlighting(jsonHighlightStyle)];\n\nexport function serializeJson(value: unknown): string {\n try {\n return JSON.stringify(value, null, 2) ?? \"null\";\n } catch {\n return String(value);\n }\n}\n\nexport function toCssSize(size: string | number): string {\n return typeof size === \"number\" ? `${size}px` : size;\n}\n\n/**\n * Finds the fold range of every direct child (depth 1) of the root object/array\n * by scanning the text itself for matching brackets. This mirrors what\n * CodeMirror's `foldable()` would compute, but doesn't depend on the lezer\n * parser having finished tokenizing the document — which for a multi-MB\n * document is not guaranteed synchronously at mount time.\n */\nexport function computeFirstLevelFoldRanges(text: string): { from: number; to: number }[] {\n const ranges: { from: number; to: number }[] = [];\n const n = text.length;\n let i = 0;\n while (i < n && text[i] !== \"{\" && text[i] !== \"[\") i++;\n if (i >= n) return ranges;\n\n let depth = 0;\n let inString = false;\n let pendingStart = -1;\n for (; i < n; i++) {\n const ch = text[i];\n if (inString) {\n if (ch === \"\\\\\") i++;\n else if (ch === '\"') inString = false;\n continue;\n }\n if (ch === '\"') {\n inString = true;\n continue;\n }\n if (ch === \"{\" || ch === \"[\") {\n depth++;\n if (depth === 2) pendingStart = i + 1;\n continue;\n }\n if (ch === \"}\" || ch === \"]\") {\n if (depth === 2 && pendingStart !== -1) {\n ranges.push({ from: pendingStart, to: i });\n pendingStart = -1;\n }\n depth--;\n }\n }\n return ranges;\n}\n"],"names":["jsonHighlightStyle","HighlightStyle","t","jsonEditorTheme","EditorView","jsonEditorExtensions","json","foldGutter","syntaxHighlighting","serializeJson","value","toCssSize","size","computeFirstLevelFoldRanges","text","ranges","n","i","depth","inString","pendingStart","ch"],"mappings":";;;;
|
|
1
|
+
{"version":3,"file":"json-code-mirror.js","sources":["../../../../../src/ui/primitives/JsonViewer/json-code-mirror.ts"],"sourcesContent":["import type { CSSProperties } from \"react\";\nimport { EditorView } from \"@codemirror/view\";\nimport { json } from \"@codemirror/lang-json\";\nimport { foldGutter, HighlightStyle, syntaxHighlighting } from \"@codemirror/language\";\nimport { tags as t } from \"@lezer/highlight\";\n\nexport const jsonHighlightStyle = HighlightStyle.define([\n { tag: t.propertyName, color: \"var(--json-viewer-color-key)\" },\n { tag: t.string, color: \"var(--json-viewer-color-string)\", fontWeight: 600 },\n { tag: [t.number, t.bool, t.null], color: \"var(--json-viewer-color-scalar)\" },\n { tag: [t.separator, t.squareBracket, t.brace], color: \"var(--json-viewer-color-punctuation)\" },\n]);\n\nexport const jsonEditorTheme = EditorView.theme({\n \"&\": { backgroundColor: \"transparent\", color: \"var(--json-viewer-color-punctuation)\", fontSize: \"13px\" },\n \"&.cm-focused\": { outline: \"none\" },\n \".cm-content\": { fontFamily: \"var(--sds-typography-family-mono)\", padding: \"8px 124px 12px 4px\" },\n \".cm-gutters\": {\n backgroundColor: \"transparent\",\n border: \"none\",\n color: \"var(--json-viewer-color-caret)\",\n paddingLeft: \"5px\",\n },\n \".cm-scroller\": { overflow: \"auto\" },\n});\n\nexport const jsonEditorExtensions = [json(), foldGutter(), syntaxHighlighting(jsonHighlightStyle)];\n\nexport function serializeJson(value: unknown): string {\n try {\n return JSON.stringify(value, null, 2) ?? \"null\";\n } catch {\n return String(value);\n }\n}\n\nexport function toCssSize(size: string | number): string {\n return typeof size === \"number\" ? `${size}px` : size;\n}\n\nexport interface JsonEditorSize {\n height?: string | number;\n minHeight?: string | number;\n maxHeight?: string | number;\n}\n\nexport function toEditorSizeStyle({ height, minHeight, maxHeight }: JsonEditorSize): CSSProperties {\n const sizeVariables: Record<string, string> = {};\n if (height !== undefined) sizeVariables[\"--json-viewer-height\"] = toCssSize(height);\n if (minHeight !== undefined) sizeVariables[\"--json-viewer-min-height\"] = toCssSize(minHeight);\n if (maxHeight !== undefined) sizeVariables[\"--json-viewer-max-height\"] = toCssSize(maxHeight);\n return sizeVariables as CSSProperties;\n}\n\n/**\n * Finds the fold range of every direct child (depth 1) of the root object/array\n * by scanning the text itself for matching brackets. This mirrors what\n * CodeMirror's `foldable()` would compute, but doesn't depend on the lezer\n * parser having finished tokenizing the document — which for a multi-MB\n * document is not guaranteed synchronously at mount time.\n */\nexport function computeFirstLevelFoldRanges(text: string): { from: number; to: number }[] {\n const ranges: { from: number; to: number }[] = [];\n const n = text.length;\n let i = 0;\n while (i < n && text[i] !== \"{\" && text[i] !== \"[\") i++;\n if (i >= n) return ranges;\n\n let depth = 0;\n let inString = false;\n let pendingStart = -1;\n for (; i < n; i++) {\n const ch = text[i];\n if (inString) {\n if (ch === \"\\\\\") i++;\n else if (ch === '\"') inString = false;\n continue;\n }\n if (ch === '\"') {\n inString = true;\n continue;\n }\n if (ch === \"{\" || ch === \"[\") {\n depth++;\n if (depth === 2) pendingStart = i + 1;\n continue;\n }\n if (ch === \"}\" || ch === \"]\") {\n if (depth === 2 && pendingStart !== -1) {\n ranges.push({ from: pendingStart, to: i });\n pendingStart = -1;\n }\n depth--;\n }\n }\n return ranges;\n}\n"],"names":["jsonHighlightStyle","HighlightStyle","t","jsonEditorTheme","EditorView","jsonEditorExtensions","json","foldGutter","syntaxHighlighting","serializeJson","value","toCssSize","size","toEditorSizeStyle","height","minHeight","maxHeight","sizeVariables","computeFirstLevelFoldRanges","text","ranges","n","i","depth","inString","pendingStart","ch"],"mappings":";;;;AAMO,MAAMA,IAAqBC,EAAe,OA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AASC,EAA4BC,GAA8C;AACxF,QAAMC,IAAyC,CAAA,GACzCC,IAAIF,EAAK;AACf,MAAIG,IAAI;AACR,SAAOA,IAAID,KAAKF,EAAKG,CAAC,MAAM,OAAOH,EAAKG,CAAC,MAAM,MAAK,CAAAA;AACpD,MAAIA,KAAKD,EAAG,QAAOD;AAEnB,MAAIG,IAAQ,GACRC,IAAW,IACXC,IAAe;AACnB,SAAOH,IAAID,GAAGC,KAAK;AACjB,UAAMI,IAAKP,EAAKG,CAAC;AACjB,QAAIE,GAAU;AACZ,MAAIE,MAAO,OAAMJ,MACRI,MAAO,QAAKF,IAAW;AAChC;AAAA,IACF;AACA,QAAIE,MAAO,KAAK;AACd,MAAAF,IAAW;AACX;AAAA,IACF;AACA,QAAIE,MAAO,OAAOA,MAAO,KAAK;AAC5B,MAAAH,KACIA,MAAU,MAAGE,IAAeH,IAAI;AACpC;AAAA,IACF;AACA,KAAII,MAAO,OAAOA,MAAO,SACnBH,MAAU,KAAKE,MAAiB,OAClCL,EAAO,KAAK,EAAE,MAAMK,GAAc,IAAIH,GAAG,GACzCG,IAAe,KAEjBF;AAAA,EAEJ;AACA,SAAOH;AACT;"}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
+
import type { JsonEditorSize } from "./json-code-mirror";
|
|
1
2
|
import "./jsonviewer.css";
|
|
2
|
-
export interface JsonEditorProps {
|
|
3
|
+
export interface JsonEditorProps extends JsonEditorSize {
|
|
3
4
|
value: string;
|
|
4
5
|
onChange?: (value: string) => void;
|
|
5
6
|
expandAllLabel: string;
|
|
6
7
|
className?: string;
|
|
7
|
-
height?: string | number;
|
|
8
8
|
isDisabled?: boolean;
|
|
9
9
|
isReadOnly?: boolean;
|
|
10
10
|
"aria-label"?: string;
|
|
@@ -15,4 +15,4 @@ export interface JsonEditorProps {
|
|
|
15
15
|
* `JsonViewer` stays read-only-only on purpose so its bundle keeps assuming
|
|
16
16
|
* a static document; this component owns the editable/controlled behavior.
|
|
17
17
|
*/
|
|
18
|
-
export declare function JsonEditor({ value, onChange, expandAllLabel, className, height, isDisabled, isReadOnly, "aria-label": ariaLabel, }: JsonEditorProps): import("react/jsx-runtime").JSX.Element;
|
|
18
|
+
export declare function JsonEditor({ value, onChange, expandAllLabel, className, height, minHeight, maxHeight, isDisabled, isReadOnly, "aria-label": ariaLabel, }: JsonEditorProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { ReactNode } from "react";
|
|
2
|
+
import type { JsonEditorSize } from "./json-code-mirror";
|
|
2
3
|
import "./jsonviewer.css";
|
|
3
4
|
export interface JsonViewerAction {
|
|
4
5
|
key: string;
|
|
@@ -6,11 +7,10 @@ export interface JsonViewerAction {
|
|
|
6
7
|
icon: ReactNode;
|
|
7
8
|
onPress: () => void;
|
|
8
9
|
}
|
|
9
|
-
export interface JsonViewerProps {
|
|
10
|
+
export interface JsonViewerProps extends JsonEditorSize {
|
|
10
11
|
value: unknown;
|
|
11
12
|
expandAllLabel: string;
|
|
12
13
|
actions?: JsonViewerAction[];
|
|
13
14
|
className?: string;
|
|
14
|
-
height?: string | number;
|
|
15
15
|
}
|
|
16
|
-
export declare function JsonViewer({ value, expandAllLabel, actions, className, height }: JsonViewerProps): import("react/jsx-runtime").JSX.Element;
|
|
16
|
+
export declare function JsonViewer({ value, expandAllLabel, actions, className, height, minHeight, maxHeight, }: JsonViewerProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,9 +1,16 @@
|
|
|
1
|
+
import type { CSSProperties } from "react";
|
|
1
2
|
import { HighlightStyle } from "@codemirror/language";
|
|
2
3
|
export declare const jsonHighlightStyle: HighlightStyle;
|
|
3
4
|
export declare const jsonEditorTheme: import("@codemirror/state").Extension;
|
|
4
5
|
export declare const jsonEditorExtensions: import("@codemirror/state").Extension[];
|
|
5
6
|
export declare function serializeJson(value: unknown): string;
|
|
6
7
|
export declare function toCssSize(size: string | number): string;
|
|
8
|
+
export interface JsonEditorSize {
|
|
9
|
+
height?: string | number;
|
|
10
|
+
minHeight?: string | number;
|
|
11
|
+
maxHeight?: string | number;
|
|
12
|
+
}
|
|
13
|
+
export declare function toEditorSizeStyle({ height, minHeight, maxHeight }: JsonEditorSize): CSSProperties;
|
|
7
14
|
/**
|
|
8
15
|
* Finds the fold range of every direct child (depth 1) of the root object/array
|
|
9
16
|
* by scanning the text itself for matching brackets. This mirrors what
|