@stackone/malachite 2.131.0 → 2.132.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/COMPONENTS.md +3 -3
- package/dist/assets/icons/hexagon_fill.svg.js +6 -0
- package/dist/assets/icons/hexagon_fill.svg.js.map +1 -0
- package/dist/assets/icons/shield_star_fill.svg.js +6 -0
- package/dist/assets/icons/shield_star_fill.svg.js.map +1 -0
- package/dist/components/CodeBlock.js +130 -130
- package/dist/components/CodeBlock.js.map +1 -1
- package/dist/components/CodeBlockHighlighter.js +65 -65
- package/dist/components/CodeBlockHighlighter.js.map +1 -1
- package/dist/components/CodePreview.js +74 -63
- package/dist/components/CodePreview.js.map +1 -1
- package/dist/components/Hexagon.js +33 -26
- package/dist/components/Hexagon.js.map +1 -1
- package/dist/components/HexagonScale.js +20 -19
- package/dist/components/HexagonScale.js.map +1 -1
- package/dist/components/QueryInput.js +91 -90
- package/dist/components/QueryInput.js.map +1 -1
- package/dist/components/codeBlockStyles.js +11 -6
- package/dist/components/codeBlockStyles.js.map +1 -1
- package/dist/components/codePreviewJson.js +25 -0
- package/dist/components/codePreviewJson.js.map +1 -0
- package/dist/index.d.ts +9 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"codeBlockStyles.js","sources":["../../src/components/codeBlockStyles.ts"],"sourcesContent":["import type React from 'react';\n\nexport const CODE_FONT: React.CSSProperties = {\n color: 'var(--malachite-codeblock-foreground)',\n fontSize: '14px',\n lineHeight: '20px',\n fontFamily: 'var(--malachite-font-mono, monospace)',\n textAlign: 'left',\n background: 'transparent',\n};\n\n/**\n * The element around a block's rows. Unwrapped, it is as wide as the widest line, floored at\n * the view, so rows filling it end level when one scrolls out. Wrapped, it is the view's width:\n * at `max-content` a line has nothing narrower to wrap against and scrolls anyway.\n */\nexport const rowsWrapperStyle = (wrap: boolean): React.CSSProperties =>\n wrap ? { width: '100%' } : { width: 'max-content', minWidth: '100%' };\n\n/** Anchored, so prose containing a colon falls through to {@link INDENT_COLUMN} instead. */\nconst VALUE_COLUMN = /^ *(?:- +)*(?:\"[^\"]*\"|'[^']*'|[^\\s:'\"][^\\s:]*): +(?=\\S)/;\n\nconst INDENT_COLUMN = /^ *(?:- +)*/;\n\n/**\n * Backstop, not a fit-to-width rule: `padding-left` counts toward the flex item's\n * `min-width: auto`, so a pathological key could otherwise widen the row past its panel. Set\n * well past any realistic key (the deepest in connector step YAML is ~18ch) because a clamped\n * row stops aligning under its value, which is the whole point of the hang.\n */\nconst MAX_HANG_CH = 32;\n\n/**\n * Hangs a wrapped row under the start of its line's value, so it can't read as a new key.\n * Measured in `ch` — the block is monospace, so one `ch` is one space (tabs are not counted).\n */\nexport const hangingIndentStyle = (line: string): React.CSSProperties => {\n const column = (VALUE_COLUMN.exec(line) ?? INDENT_COLUMN.exec(line))?.[0].length ?? 0;\n const hang = Math.min(column, MAX_HANG_CH);\n if (hang === 0) {\n return {};\n }\n const hangingIndent = `${hang}ch`;\n return { paddingLeft: hangingIndent, textIndent: `-${hangingIndent}` };\n};\n"],"names":["CODE_FONT","rowsWrapperStyle","wrap","VALUE_COLUMN","INDENT_COLUMN","MAX_HANG_CH","hangingIndentStyle","line","_a","column","hang","hangingIndent"],"mappings":"AAEO,MAAMA,IAAiC;AAAA,EAC1C,OAAO;AAAA,EACP,UAAU;AAAA,EACV,YAAY;AAAA,EACZ,YAAY;AAAA,EACZ,WAAW;AAAA,EACX,YAAY;AAChB,GAOaC,IAAmB,CAACC,MAC7BA,IAAO,EAAE,OAAO,OAAA,IAAW,EAAE,OAAO,eAAe,UAAU,OAAA,GAG3DC,IAAe,2DAEfC,IAAgB,eAQhBC,IAAc,IAMPC,IAAqB,CAACC,MAAsC;
|
|
1
|
+
{"version":3,"file":"codeBlockStyles.js","sources":["../../src/components/codeBlockStyles.ts"],"sourcesContent":["import type React from 'react';\n\nexport const CODE_FONT: React.CSSProperties = {\n color: 'var(--malachite-codeblock-foreground)',\n fontSize: '14px',\n lineHeight: '20px',\n fontFamily: 'var(--malachite-font-mono, monospace)',\n textAlign: 'left',\n background: 'transparent',\n};\n\n/** The shared keyword, string and number colours for code surfaces. */\nexport const CODE_TOKEN_COLOR = {\n keyword: 'var(--malachite-codeblock-keyword, rgb(12, 88, 174))',\n string: 'var(--malachite-codeblock-string, rgb(2, 122, 66))',\n number: 'var(--malachite-codeblock-number, rgb(150, 88, 10))',\n} as const;\n\n/**\n * The element around a block's rows. Unwrapped, it is as wide as the widest line, floored at\n * the view, so rows filling it end level when one scrolls out. Wrapped, it is the view's width:\n * at `max-content` a line has nothing narrower to wrap against and scrolls anyway.\n */\nexport const rowsWrapperStyle = (wrap: boolean): React.CSSProperties =>\n wrap ? { width: '100%' } : { width: 'max-content', minWidth: '100%' };\n\n/** Anchored, so prose containing a colon falls through to {@link INDENT_COLUMN} instead. */\nconst VALUE_COLUMN = /^ *(?:- +)*(?:\"[^\"]*\"|'[^']*'|[^\\s:'\"][^\\s:]*): +(?=\\S)/;\n\nconst INDENT_COLUMN = /^ *(?:- +)*/;\n\n/**\n * Backstop, not a fit-to-width rule: `padding-left` counts toward the flex item's\n * `min-width: auto`, so a pathological key could otherwise widen the row past its panel. Set\n * well past any realistic key (the deepest in connector step YAML is ~18ch) because a clamped\n * row stops aligning under its value, which is the whole point of the hang.\n */\nconst MAX_HANG_CH = 32;\n\n/**\n * Hangs a wrapped row under the start of its line's value, so it can't read as a new key.\n * Measured in `ch` — the block is monospace, so one `ch` is one space (tabs are not counted).\n */\nexport const hangingIndentStyle = (line: string): React.CSSProperties => {\n const column = (VALUE_COLUMN.exec(line) ?? INDENT_COLUMN.exec(line))?.[0].length ?? 0;\n const hang = Math.min(column, MAX_HANG_CH);\n if (hang === 0) {\n return {};\n }\n const hangingIndent = `${hang}ch`;\n return { paddingLeft: hangingIndent, textIndent: `-${hangingIndent}` };\n};\n"],"names":["CODE_FONT","CODE_TOKEN_COLOR","rowsWrapperStyle","wrap","VALUE_COLUMN","INDENT_COLUMN","MAX_HANG_CH","hangingIndentStyle","line","_a","column","hang","hangingIndent"],"mappings":"AAEO,MAAMA,IAAiC;AAAA,EAC1C,OAAO;AAAA,EACP,UAAU;AAAA,EACV,YAAY;AAAA,EACZ,YAAY;AAAA,EACZ,WAAW;AAAA,EACX,YAAY;AAChB,GAGaC,IAAmB;AAAA,EAC5B,SAAS;AAAA,EACT,QAAQ;AAAA,EACR,QAAQ;AACZ,GAOaC,IAAmB,CAACC,MAC7BA,IAAO,EAAE,OAAO,OAAA,IAAW,EAAE,OAAO,eAAe,UAAU,OAAA,GAG3DC,IAAe,2DAEfC,IAAgB,eAQhBC,IAAc,IAMPC,IAAqB,CAACC,MAAsC;AAzClE,MAAAC;AA0CH,QAAMC,MAAUD,IAAAL,EAAa,KAAKI,CAAI,KAAKH,EAAc,KAAKG,CAAI,MAAlD,gBAAAC,EAAuD,GAAG,WAAU,GAC9EE,IAAO,KAAK,IAAID,GAAQJ,CAAW;AACzC,MAAIK,MAAS;AACT,WAAO,CAAA;AAEX,QAAMC,IAAgB,GAAGD,CAAI;AAC7B,SAAO,EAAE,aAAaC,GAAe,YAAY,IAAIA,CAAa,GAAA;AACtE;"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { CODE_TOKEN_COLOR as s } from "./codeBlockStyles.js";
|
|
2
|
+
const c = 1e4, k = new RegExp('("(?:[^"\\\\]|\\\\.)*(?:"|\\\\?$))(\\s*:)?|(?<![\\w.\\-])(-?\\d+(?:\\.\\d+)?(?:[eE][+-]?\\d+)?)(?![\\w.])|\\b(true|false|null)\\b', "g"), f = {
|
|
3
|
+
key: s.keyword,
|
|
4
|
+
string: s.string,
|
|
5
|
+
number: s.number,
|
|
6
|
+
literal: s.keyword
|
|
7
|
+
}, p = (e) => {
|
|
8
|
+
if (e.length > c)
|
|
9
|
+
return [{ text: e, kind: "plain" }];
|
|
10
|
+
const t = [];
|
|
11
|
+
let n = 0;
|
|
12
|
+
for (const i of e.matchAll(k)) {
|
|
13
|
+
const o = i.index ?? 0;
|
|
14
|
+
o > n && t.push({ text: e.slice(n, o), kind: "plain" });
|
|
15
|
+
const [, l, r, d, u] = i;
|
|
16
|
+
l !== void 0 ? (t.push({ text: l, kind: r ? "key" : "string" }), r && t.push({ text: r, kind: "plain" })) : d !== void 0 ? t.push({ text: d, kind: "number" }) : u !== void 0 && t.push({ text: u, kind: "literal" }), n = o + i[0].length;
|
|
17
|
+
}
|
|
18
|
+
return n < e.length && t.push({ text: e.slice(n), kind: "plain" }), t;
|
|
19
|
+
};
|
|
20
|
+
export {
|
|
21
|
+
f as JSON_TOKEN_COLORS,
|
|
22
|
+
c as MAX_TOKENIZED_LINE_LENGTH,
|
|
23
|
+
p as jsonTokensOf
|
|
24
|
+
};
|
|
25
|
+
//# sourceMappingURL=codePreviewJson.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"codePreviewJson.js","sources":["../../src/components/codePreviewJson.ts"],"sourcesContent":["import { CODE_TOKEN_COLOR } from './codeBlockStyles';\n\nexport type JsonTokenKind = 'key' | 'string' | 'number' | 'literal' | 'plain';\n\nexport interface JsonToken {\n text: string;\n kind: JsonTokenKind;\n}\n\n/** Past this a line stays plain: minified payloads arrive as one line, and every token is a span. */\nexport const MAX_TOKENIZED_LINE_LENGTH = 10_000;\n\n// An unterminated string runs to the end of the line, so a truncated payload is one string\n// token rather than a retry from every later quote.\nconst TOKEN =\n /(\"(?:[^\"\\\\]|\\\\.)*(?:\"|\\\\?$))(\\s*:)?|(?<![\\w.\\-])(-?\\d+(?:\\.\\d+)?(?:[eE][+-]?\\d+)?)(?![\\w.])|\\b(true|false|null)\\b/g;\n\nexport const JSON_TOKEN_COLORS: Record<Exclude<JsonTokenKind, 'plain'>, string> = {\n key: CODE_TOKEN_COLOR.keyword,\n string: CODE_TOKEN_COLOR.string,\n number: CODE_TOKEN_COLOR.number,\n literal: CODE_TOKEN_COLOR.keyword,\n};\n\n/** One line of pretty-printed JSON, split into coloured runs. Anything unrecognised stays plain. */\nexport const jsonTokensOf = (line: string): JsonToken[] => {\n if (line.length > MAX_TOKENIZED_LINE_LENGTH) {\n return [{ text: line, kind: 'plain' }];\n }\n const tokens: JsonToken[] = [];\n let last = 0;\n for (const match of line.matchAll(TOKEN)) {\n const start = match.index ?? 0;\n if (start > last) {\n tokens.push({ text: line.slice(last, start), kind: 'plain' });\n }\n const [, quoted, colon, number, literal] = match;\n if (quoted !== undefined) {\n tokens.push({ text: quoted, kind: colon ? 'key' : 'string' });\n if (colon) {\n tokens.push({ text: colon, kind: 'plain' });\n }\n } else if (number !== undefined) {\n tokens.push({ text: number, kind: 'number' });\n } else if (literal !== undefined) {\n tokens.push({ text: literal, kind: 'literal' });\n }\n last = start + match[0].length;\n }\n if (last < line.length) {\n tokens.push({ text: line.slice(last), kind: 'plain' });\n }\n return tokens;\n};\n"],"names":["MAX_TOKENIZED_LINE_LENGTH","TOKEN","JSON_TOKEN_COLORS","CODE_TOKEN_COLOR","jsonTokensOf","line","tokens","last","match","start","quoted","colon","number","literal"],"mappings":";AAUO,MAAMA,IAA4B,KAInCC,IACF,WAAA,qIAAA,GAAA,GAESC,IAAqE;AAAA,EAC9E,KAAKC,EAAiB;AAAA,EACtB,QAAQA,EAAiB;AAAA,EACzB,QAAQA,EAAiB;AAAA,EACzB,SAASA,EAAiB;AAC9B,GAGaC,IAAe,CAACC,MAA8B;AACvD,MAAIA,EAAK,SAASL;AACd,WAAO,CAAC,EAAE,MAAMK,GAAM,MAAM,SAAS;AAEzC,QAAMC,IAAsB,CAAA;AAC5B,MAAIC,IAAO;AACX,aAAWC,KAASH,EAAK,SAASJ,CAAK,GAAG;AACtC,UAAMQ,IAAQD,EAAM,SAAS;AAC7B,IAAIC,IAAQF,KACRD,EAAO,KAAK,EAAE,MAAMD,EAAK,MAAME,GAAME,CAAK,GAAG,MAAM,SAAS;AAEhE,UAAM,CAAA,EAAGC,GAAQC,GAAOC,GAAQC,CAAO,IAAIL;AAC3C,IAAIE,MAAW,UACXJ,EAAO,KAAK,EAAE,MAAMI,GAAQ,MAAMC,IAAQ,QAAQ,UAAU,GACxDA,KACAL,EAAO,KAAK,EAAE,MAAMK,GAAO,MAAM,SAAS,KAEvCC,MAAW,SAClBN,EAAO,KAAK,EAAE,MAAMM,GAAQ,MAAM,UAAU,IACrCC,MAAY,UACnBP,EAAO,KAAK,EAAE,MAAMO,GAAS,MAAM,WAAW,GAElDN,IAAOE,IAAQD,EAAM,CAAC,EAAE;AAAA,EAC5B;AACA,SAAID,IAAOF,EAAK,UACZC,EAAO,KAAK,EAAE,MAAMD,EAAK,MAAME,CAAI,GAAG,MAAM,SAAS,GAElDD;AACX;"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1316,6 +1316,8 @@ export declare interface CodePreviewProps {
|
|
|
1316
1316
|
* title still names it for assistive tech. */
|
|
1317
1317
|
titleHidden?: boolean;
|
|
1318
1318
|
code: string;
|
|
1319
|
+
/** `json` colours keys, strings, numbers and literals line by line. Plain text by default. */
|
|
1320
|
+
language?: 'json';
|
|
1319
1321
|
/** How many lines show until the reader asks for all of them. `Infinity` shows them all. */
|
|
1320
1322
|
previewLines?: number;
|
|
1321
1323
|
/** 1-based line numbers to flag, such as the fields a scanner caught. Colour alone, so say why nearby. */
|
|
@@ -2570,6 +2572,8 @@ export declare interface HexagonProps {
|
|
|
2570
2572
|
tone?: HexagonTone;
|
|
2571
2573
|
/** `small` is 16px, `medium` 18px. */
|
|
2572
2574
|
size?: HexagonSize;
|
|
2575
|
+
/** `hexagon` for an outcome; `shield`, a shield with a star cut out, for a protection or risk level. Same tones and sizes. */
|
|
2576
|
+
shape?: HexagonShape;
|
|
2573
2577
|
/** Draws it at 20% strength, for a step of a scale that isn't the current one. */
|
|
2574
2578
|
dimmed?: boolean;
|
|
2575
2579
|
className?: string;
|
|
@@ -2578,8 +2582,10 @@ export declare interface HexagonProps {
|
|
|
2578
2582
|
export declare const HexagonScale: default_2.FC<HexagonScaleProps>;
|
|
2579
2583
|
|
|
2580
2584
|
export declare interface HexagonScaleProps {
|
|
2581
|
-
/** One
|
|
2585
|
+
/** One mark per step, in order. */
|
|
2582
2586
|
steps: readonly HexagonTone[];
|
|
2587
|
+
/** Every step's outline; default `hexagon`. */
|
|
2588
|
+
shape?: HexagonShape;
|
|
2583
2589
|
/** Index of the step drawn at full strength; the rest are dimmed. Omit to dim them all. */
|
|
2584
2590
|
current?: number;
|
|
2585
2591
|
/** Only when it stands alone; beside text naming the step it is decorative. */
|
|
@@ -2589,6 +2595,8 @@ export declare interface HexagonScaleProps {
|
|
|
2589
2595
|
className?: string;
|
|
2590
2596
|
}
|
|
2591
2597
|
|
|
2598
|
+
export declare type HexagonShape = 'hexagon' | 'shield';
|
|
2599
|
+
|
|
2592
2600
|
export declare type HexagonSize = 'small' | 'medium';
|
|
2593
2601
|
|
|
2594
2602
|
export declare type HexagonTone = 'neutral' | 'success' | 'caution' | 'warning' | 'error';
|
package/package.json
CHANGED