@tooark/react 1.6.1 → 1.7.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/README.md +17 -10
- package/README.pt-BR.md +17 -10
- package/dist/ark-alert.d.ts +6 -6
- package/dist/ark-avatar.d.ts +2 -2
- package/dist/ark-button.d.ts +6 -2
- package/dist/ark-button.js +14 -3
- package/dist/ark-card.d.ts +2 -2
- package/dist/ark-card.js +4 -2
- package/dist/ark-checkbox.d.ts +8 -8
- package/dist/ark-clock.d.ts +2 -2
- package/dist/ark-color-swatches.d.ts +4 -4
- package/dist/ark-command-palette.d.ts +18 -18
- package/dist/ark-copy-button.d.ts +2 -2
- package/dist/ark-data-view.d.ts +79 -0
- package/dist/ark-data-view.js +195 -0
- package/dist/ark-dialog.d.ts +12 -12
- package/dist/ark-dialog.js +4 -3
- package/dist/ark-drawer.d.ts +12 -12
- package/dist/ark-drawer.js +4 -3
- package/dist/ark-empty.d.ts +4 -4
- package/dist/ark-empty.js +3 -2
- package/dist/ark-file-input.d.ts +8 -8
- package/dist/ark-input.d.ts +2 -2
- package/dist/ark-kv-editor.d.ts +11 -11
- package/dist/ark-kv-editor.js +2 -2
- package/dist/ark-mark.d.ts +2 -2
- package/dist/ark-menu.d.ts +23 -11
- package/dist/ark-menu.js +8 -0
- package/dist/ark-nav.d.ts +111 -0
- package/dist/ark-nav.js +79 -0
- package/dist/ark-pagination.d.ts +36 -0
- package/dist/ark-pagination.js +31 -0
- package/dist/ark-progress.d.ts +8 -8
- package/dist/ark-radio.d.ts +10 -10
- package/dist/ark-scheduler.d.ts +1 -1
- package/dist/ark-shape-picker.d.ts +6 -6
- package/dist/ark-skeleton.d.ts +2 -2
- package/dist/ark-spinner.d.ts +2 -2
- package/dist/ark-split-pane.d.ts +4 -4
- package/dist/ark-status-dot.d.ts +2 -2
- package/dist/ark-switch.d.ts +6 -3
- package/dist/ark-switch.js +3 -2
- package/dist/ark-tabs.d.ts +6 -6
- package/dist/ark-textarea.d.ts +9 -9
- package/dist/ark-time.d.ts +18 -0
- package/dist/ark-time.js +22 -0
- package/dist/ark-tooltip.d.ts +4 -4
- package/dist/ark-tree.d.ts +86 -0
- package/dist/ark-tree.js +54 -0
- package/dist/chart.d.ts +65 -0
- package/dist/chart.js +35 -0
- package/dist/code.d.ts +148 -0
- package/dist/code.js +77 -0
- package/dist/index.d.ts +13 -3
- package/dist/index.js +7 -2
- package/dist/jsx-intrinsics.d.ts +126 -1
- package/dist/wysiwyg.d.ts +108 -0
- package/dist/wysiwyg.js +68 -0
- package/package.json +47 -3
package/dist/ark-time.js
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { createElement, forwardRef, useEffect } from "react";
|
|
2
|
+
import { ensureTooarkComponentsRegistered } from "./register.js";
|
|
3
|
+
/** `Date` e número viram ISO: o atributo é texto. */
|
|
4
|
+
function isoOf(value) {
|
|
5
|
+
if (value === undefined || typeof value === "string")
|
|
6
|
+
return value || undefined;
|
|
7
|
+
const date = new Date(value);
|
|
8
|
+
return Number.isNaN(date.getTime()) ? undefined : date.toISOString();
|
|
9
|
+
}
|
|
10
|
+
export const ArkTime = forwardRef(function ArkTime(props, forwardedRef) {
|
|
11
|
+
const { className, datetime, ...rest } = props;
|
|
12
|
+
useEffect(() => {
|
|
13
|
+
ensureTooarkComponentsRegistered();
|
|
14
|
+
}, []);
|
|
15
|
+
const attrs = {
|
|
16
|
+
...rest,
|
|
17
|
+
ref: forwardedRef,
|
|
18
|
+
class: className,
|
|
19
|
+
datetime: isoOf(datetime)
|
|
20
|
+
};
|
|
21
|
+
return createElement("ark-time", attrs);
|
|
22
|
+
});
|
package/dist/ark-tooltip.d.ts
CHANGED
|
@@ -3,16 +3,16 @@ import type { ArkTooltip as ArkTooltipElement } from "@tooark/web-components";
|
|
|
3
3
|
import React, { type PropsWithChildren } from "react";
|
|
4
4
|
import type { ArkDomProps } from "./dom-props.js";
|
|
5
5
|
export type ArkTooltipProps = PropsWithChildren<ArkDomProps<ArkTooltipStyleOptions & {
|
|
6
|
-
/** Texto do
|
|
6
|
+
/** Texto do balão; para conteúdo rico, passe um filho com slot="content". */
|
|
7
7
|
content?: string;
|
|
8
|
-
/** Aberto; refletido do estado do
|
|
8
|
+
/** Aberto; refletido do estado do balão. */
|
|
9
9
|
open?: boolean;
|
|
10
10
|
className?: string;
|
|
11
11
|
}>>;
|
|
12
12
|
export declare const ArkTooltip: React.ForwardRefExoticComponent<ArkTooltipStyleOptions & {
|
|
13
|
-
/** Texto do
|
|
13
|
+
/** Texto do balão; para conteúdo rico, passe um filho com slot="content". */
|
|
14
14
|
content?: string;
|
|
15
|
-
/** Aberto; refletido do estado do
|
|
15
|
+
/** Aberto; refletido do estado do balão. */
|
|
16
16
|
open?: boolean;
|
|
17
17
|
className?: string;
|
|
18
18
|
} & Omit<React.HTMLAttributes<HTMLElement>, "children" | "className" | "content" | "open" | keyof ArkTooltipStyleOptions> & {
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import type { ArkTreeItemStyleOptions, ArkTreeSelection, ArkTreeStyleOptions } from "@tooark/core";
|
|
2
|
+
import type { ArkTree as ArkTreeElement, ArkTreeItem as ArkTreeItemElement } from "@tooark/web-components";
|
|
3
|
+
import React, { type PropsWithChildren } from "react";
|
|
4
|
+
import type { ArkDomProps } from "./dom-props.js";
|
|
5
|
+
/** `detail` do `ark-toggle`: o item expandido ou recolhido. */
|
|
6
|
+
export type ArkTreeToggleDetail = {
|
|
7
|
+
value: string;
|
|
8
|
+
expanded: boolean;
|
|
9
|
+
item: ArkTreeItemElement;
|
|
10
|
+
};
|
|
11
|
+
/** `detail` do `ark-selection-change`: os valores escolhidos (`value` em `single`). */
|
|
12
|
+
export type ArkTreeSelectionDetail = {
|
|
13
|
+
values: string[];
|
|
14
|
+
value?: string | null;
|
|
15
|
+
};
|
|
16
|
+
/** `detail` do `ark-activate`: o item ativado (Enter ou clique na linha). */
|
|
17
|
+
export type ArkTreeActivateDetail = {
|
|
18
|
+
value: string;
|
|
19
|
+
item: ArkTreeItemElement;
|
|
20
|
+
};
|
|
21
|
+
export type ArkTreeProps = PropsWithChildren<ArkDomProps<ArkTreeStyleOptions & {
|
|
22
|
+
/** none (só navega, expande e ativa), single ou multiple. Padrão: "none". */
|
|
23
|
+
selection?: ArkTreeSelection;
|
|
24
|
+
/** Com `multiple`: uma caixa por nó. */
|
|
25
|
+
checkboxes?: boolean;
|
|
26
|
+
/** Com `checkboxes`: marcar um pai marca os descendentes, e o pai fica mixed com parte marcada. */
|
|
27
|
+
propagate?: boolean;
|
|
28
|
+
/** Valores selecionados: um em `single`, a lista em `multiple`. */
|
|
29
|
+
value?: string | string[];
|
|
30
|
+
/** Nome da árvore (vira `aria-label`). */
|
|
31
|
+
label?: string;
|
|
32
|
+
className?: string;
|
|
33
|
+
onToggle?: (event: CustomEvent<ArkTreeToggleDetail>) => void;
|
|
34
|
+
onSelectionChange?: (event: CustomEvent<ArkTreeSelectionDetail>) => void;
|
|
35
|
+
onActivate?: (event: CustomEvent<ArkTreeActivateDetail>) => void;
|
|
36
|
+
}>>;
|
|
37
|
+
export declare const ArkTree: React.ForwardRefExoticComponent<ArkTreeStyleOptions & {
|
|
38
|
+
/** none (só navega, expande e ativa), single ou multiple. Padrão: "none". */
|
|
39
|
+
selection?: ArkTreeSelection;
|
|
40
|
+
/** Com `multiple`: uma caixa por nó. */
|
|
41
|
+
checkboxes?: boolean;
|
|
42
|
+
/** Com `checkboxes`: marcar um pai marca os descendentes, e o pai fica mixed com parte marcada. */
|
|
43
|
+
propagate?: boolean;
|
|
44
|
+
/** Valores selecionados: um em `single`, a lista em `multiple`. */
|
|
45
|
+
value?: string | string[];
|
|
46
|
+
/** Nome da árvore (vira `aria-label`). */
|
|
47
|
+
label?: string;
|
|
48
|
+
className?: string;
|
|
49
|
+
onToggle?: (event: CustomEvent<ArkTreeToggleDetail>) => void;
|
|
50
|
+
onSelectionChange?: (event: CustomEvent<ArkTreeSelectionDetail>) => void;
|
|
51
|
+
onActivate?: (event: CustomEvent<ArkTreeActivateDetail>) => void;
|
|
52
|
+
} & Omit<React.HTMLAttributes<HTMLElement>, "children" | "className" | "onToggle" | "label" | "value" | "onSelectionChange" | keyof ArkTreeStyleOptions | "selection" | "checkboxes" | "propagate" | "onActivate"> & {
|
|
53
|
+
children?: React.ReactNode | undefined;
|
|
54
|
+
} & React.RefAttributes<ArkTreeElement>>;
|
|
55
|
+
export type ArkTreeItemProps = PropsWithChildren<ArkDomProps<ArkTreeItemStyleOptions & {
|
|
56
|
+
value?: string;
|
|
57
|
+
/** Texto do nó (também usado na busca por digitação). */
|
|
58
|
+
label?: string;
|
|
59
|
+
expanded?: boolean;
|
|
60
|
+
/** Mostra o chevron sem filhos: carregue os filhos no `onToggle` com `expanded: true`. */
|
|
61
|
+
lazy?: boolean;
|
|
62
|
+
/** Spinner no lugar do chevron enquanto os filhos carregam. */
|
|
63
|
+
loading?: boolean;
|
|
64
|
+
selected?: boolean;
|
|
65
|
+
/** Caixa com `checkboxes`: true, false ou "mixed". */
|
|
66
|
+
checked?: boolean | "mixed";
|
|
67
|
+
disabled?: boolean;
|
|
68
|
+
className?: string;
|
|
69
|
+
}>>;
|
|
70
|
+
export declare const ArkTreeItem: React.ForwardRefExoticComponent<ArkTreeItemStyleOptions & {
|
|
71
|
+
value?: string;
|
|
72
|
+
/** Texto do nó (também usado na busca por digitação). */
|
|
73
|
+
label?: string;
|
|
74
|
+
expanded?: boolean;
|
|
75
|
+
/** Mostra o chevron sem filhos: carregue os filhos no `onToggle` com `expanded: true`. */
|
|
76
|
+
lazy?: boolean;
|
|
77
|
+
/** Spinner no lugar do chevron enquanto os filhos carregam. */
|
|
78
|
+
loading?: boolean;
|
|
79
|
+
selected?: boolean;
|
|
80
|
+
/** Caixa com `checkboxes`: true, false ou "mixed". */
|
|
81
|
+
checked?: boolean | "mixed";
|
|
82
|
+
disabled?: boolean;
|
|
83
|
+
className?: string;
|
|
84
|
+
} & Omit<React.HTMLAttributes<HTMLElement>, "children" | "className" | "testid" | "label" | "loading" | "disabled" | "value" | "checked" | "selected" | "expanded" | "lazy"> & {
|
|
85
|
+
children?: React.ReactNode | undefined;
|
|
86
|
+
} & React.RefAttributes<ArkTreeItemElement>>;
|
package/dist/ark-tree.js
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { createElement, forwardRef, useEffect } from "react";
|
|
2
|
+
import { ensureTooarkComponentsRegistered } from "./register.js";
|
|
3
|
+
import { useForwardedRef } from "./use-forwarded-ref.js";
|
|
4
|
+
import { useIsomorphicLayoutEffect } from "./use-isomorphic-layout-effect.js";
|
|
5
|
+
export const ArkTree = forwardRef(function ArkTree(props, forwardedRef) {
|
|
6
|
+
const { children, className, checkboxes, propagate, value, onToggle, onSelectionChange, onActivate, ...rest } = props;
|
|
7
|
+
const [ref, setRef] = useForwardedRef(forwardedRef);
|
|
8
|
+
useEffect(() => {
|
|
9
|
+
ensureTooarkComponentsRegistered();
|
|
10
|
+
}, []);
|
|
11
|
+
useIsomorphicLayoutEffect(() => {
|
|
12
|
+
const el = ref.current;
|
|
13
|
+
if (!el)
|
|
14
|
+
return;
|
|
15
|
+
const handleToggle = (event) => onToggle?.(event);
|
|
16
|
+
const handleSelection = (event) => onSelectionChange?.(event);
|
|
17
|
+
const handleActivate = (event) => onActivate?.(event);
|
|
18
|
+
el.addEventListener("ark-toggle", handleToggle);
|
|
19
|
+
el.addEventListener("ark-selection-change", handleSelection);
|
|
20
|
+
el.addEventListener("ark-activate", handleActivate);
|
|
21
|
+
return () => {
|
|
22
|
+
el.removeEventListener("ark-toggle", handleToggle);
|
|
23
|
+
el.removeEventListener("ark-selection-change", handleSelection);
|
|
24
|
+
el.removeEventListener("ark-activate", handleActivate);
|
|
25
|
+
};
|
|
26
|
+
}, [ref, onToggle, onSelectionChange, onActivate]);
|
|
27
|
+
const attrs = {
|
|
28
|
+
...rest,
|
|
29
|
+
ref: setRef,
|
|
30
|
+
class: className,
|
|
31
|
+
checkboxes: checkboxes ? "" : undefined,
|
|
32
|
+
propagate: propagate ? "" : undefined,
|
|
33
|
+
value: Array.isArray(value) ? (value.length ? JSON.stringify(value) : undefined) : value || undefined
|
|
34
|
+
};
|
|
35
|
+
return createElement("ark-tree", attrs, children);
|
|
36
|
+
});
|
|
37
|
+
export const ArkTreeItem = forwardRef(function ArkTreeItem(props, forwardedRef) {
|
|
38
|
+
const { children, className, expanded, lazy, loading, selected, checked, disabled, ...rest } = props;
|
|
39
|
+
useEffect(() => {
|
|
40
|
+
ensureTooarkComponentsRegistered();
|
|
41
|
+
}, []);
|
|
42
|
+
const attrs = {
|
|
43
|
+
...rest,
|
|
44
|
+
ref: forwardedRef,
|
|
45
|
+
class: className,
|
|
46
|
+
expanded: expanded ? "" : undefined,
|
|
47
|
+
lazy: lazy ? "" : undefined,
|
|
48
|
+
loading: loading ? "" : undefined,
|
|
49
|
+
selected: selected ? "" : undefined,
|
|
50
|
+
checked: checked === "mixed" ? "mixed" : checked ? "" : undefined,
|
|
51
|
+
disabled: disabled ? "" : undefined
|
|
52
|
+
};
|
|
53
|
+
return createElement("ark-tree-item", attrs, children);
|
|
54
|
+
});
|
package/dist/chart.d.ts
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { type ArkChart as ArkChartElement, type EChartsOption } from "@tooark/chart";
|
|
2
|
+
import type React from "react";
|
|
3
|
+
import type { ArkDomProps } from "./dom-props.js";
|
|
4
|
+
/** Atributos da tag `ark-chart`, os mesmos da entrada principal, mais as propriedades JS. */
|
|
5
|
+
type ArkChartTagProps = React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement> & {
|
|
6
|
+
testid?: string;
|
|
7
|
+
theme?: "auto" | "light" | "dark";
|
|
8
|
+
palette?: "default" | "tokens";
|
|
9
|
+
renderer?: "canvas" | "svg";
|
|
10
|
+
height?: string;
|
|
11
|
+
"auto-resize"?: boolean | "false";
|
|
12
|
+
/** Opções nativas do ECharts (propriedade JS; o React 19 a atribui como propriedade). */
|
|
13
|
+
option?: EChartsOption | null;
|
|
14
|
+
};
|
|
15
|
+
declare module "react" {
|
|
16
|
+
namespace JSX {
|
|
17
|
+
interface IntrinsicElements {
|
|
18
|
+
"ark-chart": ArkChartTagProps;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
declare global {
|
|
23
|
+
namespace JSX {
|
|
24
|
+
interface IntrinsicElements {
|
|
25
|
+
"ark-chart": ArkChartTagProps;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
export type ArkChartProps = ArkDomProps<{
|
|
30
|
+
/** Opções nativas do ECharts; trocar a referência re-renderiza o gráfico (`notMerge`). */
|
|
31
|
+
option?: EChartsOption | null;
|
|
32
|
+
/** auto (segue o color-scheme da página), light ou dark. Padrão: "auto". */
|
|
33
|
+
theme?: "auto" | "light" | "dark";
|
|
34
|
+
/** default (paleta do ECharts) ou tokens (cores dos tokens `--ark-color-*`, @tooark/chart 1.7+). Padrão: "default". */
|
|
35
|
+
palette?: "default" | "tokens";
|
|
36
|
+
/** Padrão: "canvas". */
|
|
37
|
+
renderer?: "canvas" | "svg";
|
|
38
|
+
/** Altura do gráfico (comprimento CSS). Padrão: "320px". */
|
|
39
|
+
height?: string;
|
|
40
|
+
/** Redimensiona junto com o contêiner. Padrão: true. */
|
|
41
|
+
autoResize?: boolean;
|
|
42
|
+
testid?: string;
|
|
43
|
+
className?: string;
|
|
44
|
+
/** Clique numa série, com os params nativos do ECharts em `detail`. */
|
|
45
|
+
onChartClick?: (event: CustomEvent) => void;
|
|
46
|
+
}>;
|
|
47
|
+
export declare const ArkChart: React.ForwardRefExoticComponent<{
|
|
48
|
+
/** Opções nativas do ECharts; trocar a referência re-renderiza o gráfico (`notMerge`). */
|
|
49
|
+
option?: EChartsOption | null;
|
|
50
|
+
/** auto (segue o color-scheme da página), light ou dark. Padrão: "auto". */
|
|
51
|
+
theme?: "auto" | "light" | "dark";
|
|
52
|
+
/** default (paleta do ECharts) ou tokens (cores dos tokens `--ark-color-*`, @tooark/chart 1.7+). Padrão: "default". */
|
|
53
|
+
palette?: "default" | "tokens";
|
|
54
|
+
/** Padrão: "canvas". */
|
|
55
|
+
renderer?: "canvas" | "svg";
|
|
56
|
+
/** Altura do gráfico (comprimento CSS). Padrão: "320px". */
|
|
57
|
+
height?: string;
|
|
58
|
+
/** Redimensiona junto com o contêiner. Padrão: true. */
|
|
59
|
+
autoResize?: boolean;
|
|
60
|
+
testid?: string;
|
|
61
|
+
className?: string;
|
|
62
|
+
/** Clique numa série, com os params nativos do ECharts em `detail`. */
|
|
63
|
+
onChartClick?: (event: CustomEvent) => void;
|
|
64
|
+
} & Omit<React.HTMLAttributes<HTMLElement>, "children" | "className" | "testid" | "theme" | "option" | "height" | "palette" | "renderer" | "autoResize" | "onChartClick"> & React.RefAttributes<ArkChartElement>>;
|
|
65
|
+
export {};
|
package/dist/chart.js
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
// Entry point @tooark/react/chart: o wrapper do ark-chart, fora da entrada principal para que o ECharts (peer do
|
|
2
|
+
// @tooark/chart) só entre no app que importa este caminho. Também tipa a tag crua <ark-chart> com as propriedades JS.
|
|
3
|
+
import { registerTooarkChart } from "@tooark/chart";
|
|
4
|
+
import { createElement, forwardRef, useEffect } from "react";
|
|
5
|
+
import { useForwardedRef } from "./use-forwarded-ref.js";
|
|
6
|
+
import { useIsomorphicLayoutEffect } from "./use-isomorphic-layout-effect.js";
|
|
7
|
+
export const ArkChart = forwardRef(function ArkChart(props, forwardedRef) {
|
|
8
|
+
const { className, option, autoResize, onChartClick, ...rest } = props;
|
|
9
|
+
const [ref, setRef] = useForwardedRef(forwardedRef);
|
|
10
|
+
useEffect(() => {
|
|
11
|
+
registerTooarkChart();
|
|
12
|
+
}, []);
|
|
13
|
+
// Pela propriedade, como no React 18 (que gravaria o objeto como texto no atributo), e só quando a referência
|
|
14
|
+
// muda: cada atribuição re-renderiza o gráfico com notMerge.
|
|
15
|
+
useIsomorphicLayoutEffect(() => {
|
|
16
|
+
const el = ref.current;
|
|
17
|
+
if (el && el.option !== (option ?? null))
|
|
18
|
+
el.option = option ?? null;
|
|
19
|
+
}, [ref, option]);
|
|
20
|
+
useIsomorphicLayoutEffect(() => {
|
|
21
|
+
const el = ref.current;
|
|
22
|
+
if (!el || !onChartClick)
|
|
23
|
+
return;
|
|
24
|
+
const handle = (event) => onChartClick(event);
|
|
25
|
+
el.addEventListener("ark-chart-click", handle);
|
|
26
|
+
return () => el.removeEventListener("ark-chart-click", handle);
|
|
27
|
+
}, [ref, onChartClick]);
|
|
28
|
+
const attrs = {
|
|
29
|
+
...rest,
|
|
30
|
+
ref: setRef,
|
|
31
|
+
class: className,
|
|
32
|
+
"auto-resize": autoResize === false ? "false" : undefined
|
|
33
|
+
};
|
|
34
|
+
return createElement("ark-chart", attrs);
|
|
35
|
+
});
|
package/dist/code.d.ts
ADDED
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
import { type ArkCodeCompletion, type ArkCodeCompletionSource, type ArkCodeEditor as ArkCodeEditorElement, type ArkCodeExtension, type ArkCodeFormatter, type ArkCodeIndentStyle, type ArkCodeLanguage, type ArkCodeLineEnding, type ArkCodeVariable } from "@tooark/code";
|
|
2
|
+
import type { ArkSize } from "@tooark/core";
|
|
3
|
+
import type React from "react";
|
|
4
|
+
import type { ArkDomProps } from "./dom-props.js";
|
|
5
|
+
/** Atributos da tag `ark-code-editor`, os mesmos da entrada principal, mais as propriedades JS. */
|
|
6
|
+
type ArkCodeEditorTagProps = React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement> & {
|
|
7
|
+
testid?: string;
|
|
8
|
+
theme?: "auto" | "light" | "dark";
|
|
9
|
+
language?: "json" | "javascript" | "yaml" | "text";
|
|
10
|
+
readonly?: boolean;
|
|
11
|
+
placeholder?: string;
|
|
12
|
+
"min-height"?: string;
|
|
13
|
+
"max-height"?: string;
|
|
14
|
+
"line-numbers"?: boolean | "false";
|
|
15
|
+
fold?: boolean | "false";
|
|
16
|
+
wrap?: boolean;
|
|
17
|
+
"indent-style"?: "space" | "tab";
|
|
18
|
+
"indent-size"?: number;
|
|
19
|
+
"line-ending"?: "auto" | "lf" | "crlf";
|
|
20
|
+
"tab-indent"?: boolean | "false";
|
|
21
|
+
autocomplete?: boolean | "false";
|
|
22
|
+
"mark-unknown-variables"?: boolean;
|
|
23
|
+
"single-line"?: boolean;
|
|
24
|
+
size?: ArkSize;
|
|
25
|
+
/** Texto do editor (propriedade JS). */
|
|
26
|
+
value?: string;
|
|
27
|
+
variableKeys?: string[];
|
|
28
|
+
variables?: ArkCodeVariable[];
|
|
29
|
+
completions?: ArkCodeCompletion[];
|
|
30
|
+
completionSource?: ArkCodeCompletionSource;
|
|
31
|
+
formatter?: ArkCodeFormatter;
|
|
32
|
+
extensions?: ArkCodeExtension;
|
|
33
|
+
};
|
|
34
|
+
declare module "react" {
|
|
35
|
+
namespace JSX {
|
|
36
|
+
interface IntrinsicElements {
|
|
37
|
+
"ark-code-editor": ArkCodeEditorTagProps;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
declare global {
|
|
42
|
+
namespace JSX {
|
|
43
|
+
interface IntrinsicElements {
|
|
44
|
+
"ark-code-editor": ArkCodeEditorTagProps;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
export type ArkCodeEditorProps = ArkDomProps<{
|
|
49
|
+
/** Texto do editor. Controlado: o `onChange` devolve o texto e o app o repassa; atribuir não emite `change`. */
|
|
50
|
+
value?: string;
|
|
51
|
+
/** json, javascript, yaml ou text. Padrão: "text". */
|
|
52
|
+
language?: ArkCodeLanguage;
|
|
53
|
+
/** auto (segue a página), light ou dark. Padrão: "auto". */
|
|
54
|
+
theme?: "auto" | "light" | "dark";
|
|
55
|
+
readonly?: boolean;
|
|
56
|
+
placeholder?: string;
|
|
57
|
+
/** Altura mínima (comprimento CSS). Padrão: "8rem". */
|
|
58
|
+
minHeight?: string;
|
|
59
|
+
/** Altura máxima (comprimento CSS), com rolagem interna acima dela. Padrão: sem limite. */
|
|
60
|
+
maxHeight?: string;
|
|
61
|
+
/** Numeração das linhas. Padrão: true. */
|
|
62
|
+
lineNumbers?: boolean;
|
|
63
|
+
/** Calha de dobra. Padrão: true. */
|
|
64
|
+
fold?: boolean;
|
|
65
|
+
wrap?: boolean;
|
|
66
|
+
indentStyle?: ArkCodeIndentStyle;
|
|
67
|
+
indentSize?: number;
|
|
68
|
+
lineEnding?: ArkCodeLineEnding;
|
|
69
|
+
/** Tab recua (Esc e Tab saem). Padrão: true. */
|
|
70
|
+
tabIndent?: boolean;
|
|
71
|
+
/** Completions ao digitar. Padrão: true. */
|
|
72
|
+
autocomplete?: boolean;
|
|
73
|
+
markUnknownVariables?: boolean;
|
|
74
|
+
singleLine?: boolean;
|
|
75
|
+
size?: ArkSize;
|
|
76
|
+
variableKeys?: string[];
|
|
77
|
+
variables?: ArkCodeVariable[];
|
|
78
|
+
completions?: ArkCodeCompletion[];
|
|
79
|
+
completionSource?: ArkCodeCompletionSource;
|
|
80
|
+
formatter?: ArkCodeFormatter;
|
|
81
|
+
/** Extensões do CodeMirror do app; mantenha a referência estável (useMemo), uma nova reconfigura o editor. */
|
|
82
|
+
extensions?: ArkCodeExtension;
|
|
83
|
+
testid?: string;
|
|
84
|
+
className?: string;
|
|
85
|
+
/** Cada edição do usuário, com `detail: { value }`. */
|
|
86
|
+
onChange?: (event: CustomEvent<{
|
|
87
|
+
value: string;
|
|
88
|
+
}>) => void;
|
|
89
|
+
/** Enter em `singleLine`, com `detail: { value }`. */
|
|
90
|
+
onSubmit?: (event: CustomEvent<{
|
|
91
|
+
value: string;
|
|
92
|
+
}>) => void;
|
|
93
|
+
/** `format()` falhou, com `detail: { error }`. */
|
|
94
|
+
onFormatError?: (event: CustomEvent<{
|
|
95
|
+
error: unknown;
|
|
96
|
+
}>) => void;
|
|
97
|
+
}>;
|
|
98
|
+
export declare const ArkCodeEditor: React.ForwardRefExoticComponent<{
|
|
99
|
+
/** Texto do editor. Controlado: o `onChange` devolve o texto e o app o repassa; atribuir não emite `change`. */
|
|
100
|
+
value?: string;
|
|
101
|
+
/** json, javascript, yaml ou text. Padrão: "text". */
|
|
102
|
+
language?: ArkCodeLanguage;
|
|
103
|
+
/** auto (segue a página), light ou dark. Padrão: "auto". */
|
|
104
|
+
theme?: "auto" | "light" | "dark";
|
|
105
|
+
readonly?: boolean;
|
|
106
|
+
placeholder?: string;
|
|
107
|
+
/** Altura mínima (comprimento CSS). Padrão: "8rem". */
|
|
108
|
+
minHeight?: string;
|
|
109
|
+
/** Altura máxima (comprimento CSS), com rolagem interna acima dela. Padrão: sem limite. */
|
|
110
|
+
maxHeight?: string;
|
|
111
|
+
/** Numeração das linhas. Padrão: true. */
|
|
112
|
+
lineNumbers?: boolean;
|
|
113
|
+
/** Calha de dobra. Padrão: true. */
|
|
114
|
+
fold?: boolean;
|
|
115
|
+
wrap?: boolean;
|
|
116
|
+
indentStyle?: ArkCodeIndentStyle;
|
|
117
|
+
indentSize?: number;
|
|
118
|
+
lineEnding?: ArkCodeLineEnding;
|
|
119
|
+
/** Tab recua (Esc e Tab saem). Padrão: true. */
|
|
120
|
+
tabIndent?: boolean;
|
|
121
|
+
/** Completions ao digitar. Padrão: true. */
|
|
122
|
+
autocomplete?: boolean;
|
|
123
|
+
markUnknownVariables?: boolean;
|
|
124
|
+
singleLine?: boolean;
|
|
125
|
+
size?: ArkSize;
|
|
126
|
+
variableKeys?: string[];
|
|
127
|
+
variables?: ArkCodeVariable[];
|
|
128
|
+
completions?: ArkCodeCompletion[];
|
|
129
|
+
completionSource?: ArkCodeCompletionSource;
|
|
130
|
+
formatter?: ArkCodeFormatter;
|
|
131
|
+
/** Extensões do CodeMirror do app; mantenha a referência estável (useMemo), uma nova reconfigura o editor. */
|
|
132
|
+
extensions?: ArkCodeExtension;
|
|
133
|
+
testid?: string;
|
|
134
|
+
className?: string;
|
|
135
|
+
/** Cada edição do usuário, com `detail: { value }`. */
|
|
136
|
+
onChange?: (event: CustomEvent<{
|
|
137
|
+
value: string;
|
|
138
|
+
}>) => void;
|
|
139
|
+
/** Enter em `singleLine`, com `detail: { value }`. */
|
|
140
|
+
onSubmit?: (event: CustomEvent<{
|
|
141
|
+
value: string;
|
|
142
|
+
}>) => void;
|
|
143
|
+
/** `format()` falhou, com `detail: { error }`. */
|
|
144
|
+
onFormatError?: (event: CustomEvent<{
|
|
145
|
+
error: unknown;
|
|
146
|
+
}>) => void;
|
|
147
|
+
} & Omit<React.HTMLAttributes<HTMLElement>, "children" | "className" | "onChange" | "onSubmit" | "testid" | "theme" | "size" | "value" | "placeholder" | "readonly" | "autocomplete" | "wrap" | "language" | "minHeight" | "maxHeight" | "lineNumbers" | "fold" | "indentStyle" | "indentSize" | "lineEnding" | "tabIndent" | "markUnknownVariables" | "singleLine" | "variableKeys" | "variables" | "completions" | "completionSource" | "formatter" | "extensions" | "onFormatError"> & React.RefAttributes<ArkCodeEditorElement>>;
|
|
148
|
+
export {};
|
package/dist/code.js
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
// Entry point @tooark/react/code: o wrapper do ark-code-editor, fora da entrada principal para que o CodeMirror (peers
|
|
2
|
+
// do @tooark/code) só entre no app que importa este caminho. Também tipa a tag crua <ark-code-editor> com as
|
|
3
|
+
// propriedades JS.
|
|
4
|
+
import { registerTooarkCode } from "@tooark/code";
|
|
5
|
+
import { createElement, forwardRef, useEffect } from "react";
|
|
6
|
+
import { useForwardedRef } from "./use-forwarded-ref.js";
|
|
7
|
+
import { useIsomorphicLayoutEffect } from "./use-isomorphic-layout-effect.js";
|
|
8
|
+
/** Propriedades JS do editor, atribuídas pela ref e só quando a referência muda. */
|
|
9
|
+
const PROPERTY_KEYS = [
|
|
10
|
+
"variableKeys",
|
|
11
|
+
"variables",
|
|
12
|
+
"completions",
|
|
13
|
+
"completionSource",
|
|
14
|
+
"formatter",
|
|
15
|
+
"extensions"
|
|
16
|
+
];
|
|
17
|
+
export const ArkCodeEditor = forwardRef(function ArkCodeEditor(props, forwardedRef) {
|
|
18
|
+
const { className, value, readonly, minHeight, maxHeight, lineNumbers, fold, wrap, indentStyle, indentSize, lineEnding, tabIndent, autocomplete, markUnknownVariables, singleLine, variableKeys, variables, completions, completionSource, formatter, extensions, onChange, onSubmit, onFormatError, ...rest } = props;
|
|
19
|
+
const [ref, setRef] = useForwardedRef(forwardedRef);
|
|
20
|
+
const properties = { variableKeys, variables, completions, completionSource, formatter, extensions };
|
|
21
|
+
useEffect(() => {
|
|
22
|
+
registerTooarkCode();
|
|
23
|
+
}, []);
|
|
24
|
+
// O texto só é reatribuído quando difere do editor: o valor que o onChange acabou de devolver não move o cursor.
|
|
25
|
+
useIsomorphicLayoutEffect(() => {
|
|
26
|
+
const el = ref.current;
|
|
27
|
+
if (el && value !== undefined && el.value !== value)
|
|
28
|
+
el.value = value;
|
|
29
|
+
}, [ref, value]);
|
|
30
|
+
// Pela propriedade (o React 18 gravaria texto no atributo) e só com referência nova.
|
|
31
|
+
useIsomorphicLayoutEffect(() => {
|
|
32
|
+
const el = ref.current;
|
|
33
|
+
if (!el)
|
|
34
|
+
return;
|
|
35
|
+
for (const key of PROPERTY_KEYS) {
|
|
36
|
+
const next = properties[key];
|
|
37
|
+
if (next !== undefined && el[key] !== next)
|
|
38
|
+
el[key] = next;
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
useIsomorphicLayoutEffect(() => {
|
|
42
|
+
const el = ref.current;
|
|
43
|
+
if (!el)
|
|
44
|
+
return;
|
|
45
|
+
const handleChange = (event) => onChange?.(event);
|
|
46
|
+
const handleSubmit = (event) => onSubmit?.(event);
|
|
47
|
+
const handleError = (event) => onFormatError?.(event);
|
|
48
|
+
el.addEventListener("change", handleChange);
|
|
49
|
+
el.addEventListener("ark-submit", handleSubmit);
|
|
50
|
+
el.addEventListener("ark-format-error", handleError);
|
|
51
|
+
return () => {
|
|
52
|
+
el.removeEventListener("change", handleChange);
|
|
53
|
+
el.removeEventListener("ark-submit", handleSubmit);
|
|
54
|
+
el.removeEventListener("ark-format-error", handleError);
|
|
55
|
+
};
|
|
56
|
+
}, [ref, onChange, onSubmit, onFormatError]);
|
|
57
|
+
const off = (on) => (on === false ? "false" : undefined);
|
|
58
|
+
const attrs = {
|
|
59
|
+
...rest,
|
|
60
|
+
ref: setRef,
|
|
61
|
+
class: className,
|
|
62
|
+
readonly: readonly ? "" : undefined,
|
|
63
|
+
"min-height": minHeight,
|
|
64
|
+
"max-height": maxHeight,
|
|
65
|
+
"line-numbers": off(lineNumbers),
|
|
66
|
+
fold: off(fold),
|
|
67
|
+
wrap: wrap ? "" : undefined,
|
|
68
|
+
"indent-style": indentStyle,
|
|
69
|
+
"indent-size": indentSize,
|
|
70
|
+
"line-ending": lineEnding,
|
|
71
|
+
"tab-indent": off(tabIndent),
|
|
72
|
+
autocomplete: off(autocomplete),
|
|
73
|
+
"mark-unknown-variables": markUnknownVariables ? "" : undefined,
|
|
74
|
+
"single-line": singleLine ? "" : undefined
|
|
75
|
+
};
|
|
76
|
+
return createElement("ark-code-editor", attrs);
|
|
77
|
+
});
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference path="./jsx-intrinsics.d.ts" />
|
|
2
|
-
export { dismissToast, showToast, toast } from "@tooark/core";
|
|
2
|
+
export { dismissToast, getArkLocale, observeArkLocale, setArkLocale, showToast, toast } from "@tooark/core";
|
|
3
3
|
export type { ArkAlertProps } from "./ark-alert.js";
|
|
4
4
|
export { ArkAlert } from "./ark-alert.js";
|
|
5
5
|
export type { ArkAvatarProps } from "./ark-avatar.js";
|
|
@@ -24,6 +24,8 @@ export type { ArkCommandItemProps, ArkCommandPaletteProps } from "./ark-command-
|
|
|
24
24
|
export { ArkCommandItem, ArkCommandPalette } from "./ark-command-palette.js";
|
|
25
25
|
export type { ArkCopyButtonProps } from "./ark-copy-button.js";
|
|
26
26
|
export { ArkCopyButton } from "./ark-copy-button.js";
|
|
27
|
+
export type { ArkDataViewProps, ArkDataViewReactCardRender, ArkDataViewReactColumn } from "./ark-data-view.js";
|
|
28
|
+
export { ArkDataView } from "./ark-data-view.js";
|
|
27
29
|
export type { ArkDatepickerProps } from "./ark-datepicker.js";
|
|
28
30
|
export { ArkDatepicker } from "./ark-datepicker.js";
|
|
29
31
|
export type { ArkDialogProps } from "./ark-dialog.js";
|
|
@@ -42,8 +44,12 @@ export type { ArkKvEditorProps } from "./ark-kv-editor.js";
|
|
|
42
44
|
export { ArkKvEditor } from "./ark-kv-editor.js";
|
|
43
45
|
export type { ArkMarkProps } from "./ark-mark.js";
|
|
44
46
|
export { ArkMark } from "./ark-mark.js";
|
|
45
|
-
export type { ArkMenuItemProps, ArkMenuProps } from "./ark-menu.js";
|
|
46
|
-
export { ArkMenu, ArkMenuItem } from "./ark-menu.js";
|
|
47
|
+
export type { ArkMenuGroupProps, ArkMenuItemProps, ArkMenuProps } from "./ark-menu.js";
|
|
48
|
+
export { ArkMenu, ArkMenuGroup, ArkMenuItem } from "./ark-menu.js";
|
|
49
|
+
export type { ArkNavGroupProps, ArkNavItemProps, ArkNavNavigateDetail, ArkNavProps } from "./ark-nav.js";
|
|
50
|
+
export { ArkNav, ArkNavGroup, ArkNavItem } from "./ark-nav.js";
|
|
51
|
+
export type { ArkPaginationProps } from "./ark-pagination.js";
|
|
52
|
+
export { ArkPagination } from "./ark-pagination.js";
|
|
47
53
|
export type { ArkProgressProps } from "./ark-progress.js";
|
|
48
54
|
export { ArkProgress } from "./ark-progress.js";
|
|
49
55
|
export type { ArkRadioProps } from "./ark-radio.js";
|
|
@@ -68,9 +74,13 @@ export type { ArkTabProps, ArkTabsProps } from "./ark-tabs.js";
|
|
|
68
74
|
export { ArkTab, ArkTabs } from "./ark-tabs.js";
|
|
69
75
|
export type { ArkTextareaProps } from "./ark-textarea.js";
|
|
70
76
|
export { ArkTextarea } from "./ark-textarea.js";
|
|
77
|
+
export type { ArkTimeProps } from "./ark-time.js";
|
|
78
|
+
export { ArkTime } from "./ark-time.js";
|
|
71
79
|
export type { ArkToasterProps } from "./ark-toaster.js";
|
|
72
80
|
export { ArkToaster } from "./ark-toaster.js";
|
|
73
81
|
export type { ArkToggleGroupProps, ArkToggleProps } from "./ark-toggle.js";
|
|
74
82
|
export { ArkToggle, ArkToggleGroup } from "./ark-toggle.js";
|
|
75
83
|
export type { ArkTooltipProps } from "./ark-tooltip.js";
|
|
76
84
|
export { ArkTooltip } from "./ark-tooltip.js";
|
|
85
|
+
export type { ArkTreeActivateDetail, ArkTreeItemProps, ArkTreeProps, ArkTreeSelectionDetail, ArkTreeToggleDetail } from "./ark-tree.js";
|
|
86
|
+
export { ArkTree, ArkTreeItem } from "./ark-tree.js";
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { dismissToast, showToast, toast } from "@tooark/core";
|
|
1
|
+
export { dismissToast, getArkLocale, observeArkLocale, setArkLocale, showToast, toast } from "@tooark/core";
|
|
2
2
|
export { ArkAlert } from "./ark-alert.js";
|
|
3
3
|
export { ArkAvatar } from "./ark-avatar.js";
|
|
4
4
|
export { ArkBadge } from "./ark-badge.js";
|
|
@@ -11,6 +11,7 @@ export { ArkClock } from "./ark-clock.js";
|
|
|
11
11
|
export { ArkColorSwatches } from "./ark-color-swatches.js";
|
|
12
12
|
export { ArkCommandItem, ArkCommandPalette } from "./ark-command-palette.js";
|
|
13
13
|
export { ArkCopyButton } from "./ark-copy-button.js";
|
|
14
|
+
export { ArkDataView } from "./ark-data-view.js";
|
|
14
15
|
export { ArkDatepicker } from "./ark-datepicker.js";
|
|
15
16
|
export { ArkDialog } from "./ark-dialog.js";
|
|
16
17
|
export { ArkDrawer } from "./ark-drawer.js";
|
|
@@ -20,7 +21,9 @@ export { ArkInput } from "./ark-input.js";
|
|
|
20
21
|
export { ArkKbd } from "./ark-kbd.js";
|
|
21
22
|
export { ArkKvEditor } from "./ark-kv-editor.js";
|
|
22
23
|
export { ArkMark } from "./ark-mark.js";
|
|
23
|
-
export { ArkMenu, ArkMenuItem } from "./ark-menu.js";
|
|
24
|
+
export { ArkMenu, ArkMenuGroup, ArkMenuItem } from "./ark-menu.js";
|
|
25
|
+
export { ArkNav, ArkNavGroup, ArkNavItem } from "./ark-nav.js";
|
|
26
|
+
export { ArkPagination } from "./ark-pagination.js";
|
|
24
27
|
export { ArkProgress } from "./ark-progress.js";
|
|
25
28
|
export { ArkRadio } from "./ark-radio.js";
|
|
26
29
|
export { ArkScheduler } from "./ark-scheduler.js";
|
|
@@ -33,6 +36,8 @@ export { ArkStatusDot } from "./ark-status-dot.js";
|
|
|
33
36
|
export { ArkSwitch } from "./ark-switch.js";
|
|
34
37
|
export { ArkTab, ArkTabs } from "./ark-tabs.js";
|
|
35
38
|
export { ArkTextarea } from "./ark-textarea.js";
|
|
39
|
+
export { ArkTime } from "./ark-time.js";
|
|
36
40
|
export { ArkToaster } from "./ark-toaster.js";
|
|
37
41
|
export { ArkToggle, ArkToggleGroup } from "./ark-toggle.js";
|
|
38
42
|
export { ArkTooltip } from "./ark-tooltip.js";
|
|
43
|
+
export { ArkTree, ArkTreeItem } from "./ark-tree.js";
|