@tooark/react 1.6.1 → 1.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/README.md +17 -10
- package/README.pt-BR.md +17 -10
- package/dist/ark-alert.d.ts +7 -7
- package/dist/ark-alert.js +2 -1
- package/dist/ark-avatar.d.ts +3 -3
- package/dist/ark-avatar.js +2 -1
- package/dist/ark-badge.d.ts +1 -1
- package/dist/ark-badge.js +2 -1
- package/dist/ark-button.d.ts +11 -3
- package/dist/ark-button.js +16 -4
- package/dist/ark-calendar.d.ts +1 -1
- package/dist/ark-calendar.js +2 -1
- package/dist/ark-card.d.ts +3 -3
- package/dist/ark-card.js +6 -3
- package/dist/ark-carousel.d.ts +1 -1
- package/dist/ark-carousel.js +2 -1
- package/dist/ark-checkbox.d.ts +9 -9
- package/dist/ark-checkbox.js +2 -1
- package/dist/ark-clock.d.ts +3 -3
- package/dist/ark-clock.js +2 -1
- package/dist/ark-color-swatches.d.ts +5 -5
- package/dist/ark-color-swatches.js +2 -1
- package/dist/ark-command-palette.d.ts +21 -21
- package/dist/ark-command-palette.js +3 -2
- package/dist/ark-copy-button.d.ts +3 -3
- package/dist/ark-copy-button.js +2 -1
- package/dist/ark-data-view.d.ts +79 -0
- package/dist/ark-data-view.js +196 -0
- package/dist/ark-datepicker.d.ts +1 -1
- package/dist/ark-datepicker.js +2 -1
- package/dist/ark-dialog.d.ts +13 -13
- package/dist/ark-dialog.js +6 -4
- package/dist/ark-drawer.d.ts +13 -13
- package/dist/ark-drawer.js +6 -4
- package/dist/ark-empty.d.ts +5 -5
- package/dist/ark-empty.js +5 -3
- package/dist/ark-file-input.d.ts +10 -10
- package/dist/ark-file-input.js +2 -1
- package/dist/ark-input.d.ts +8 -4
- package/dist/ark-input.js +2 -1
- package/dist/ark-kbd.d.ts +1 -1
- package/dist/ark-kbd.js +2 -1
- package/dist/ark-kv-editor.d.ts +12 -12
- package/dist/ark-kv-editor.js +4 -3
- package/dist/ark-mark.d.ts +3 -3
- package/dist/ark-mark.js +2 -1
- package/dist/ark-menu.d.ts +24 -12
- package/dist/ark-menu.js +11 -2
- package/dist/ark-nav.d.ts +111 -0
- package/dist/ark-nav.js +80 -0
- package/dist/ark-pagination.d.ts +36 -0
- package/dist/ark-pagination.js +32 -0
- package/dist/ark-progress.d.ts +9 -9
- package/dist/ark-progress.js +2 -1
- package/dist/ark-radio.d.ts +11 -11
- package/dist/ark-radio.js +2 -1
- package/dist/ark-scheduler.d.ts +2 -2
- package/dist/ark-scheduler.js +2 -1
- package/dist/ark-select.d.ts +1 -1
- package/dist/ark-select.js +2 -1
- package/dist/ark-shape-picker.d.ts +7 -7
- package/dist/ark-shape-picker.js +2 -1
- package/dist/ark-skeleton.d.ts +3 -3
- package/dist/ark-skeleton.js +2 -1
- package/dist/ark-spinner.d.ts +3 -3
- package/dist/ark-spinner.js +2 -1
- package/dist/ark-split-pane.d.ts +5 -5
- package/dist/ark-split-pane.js +2 -1
- package/dist/ark-status-dot.d.ts +3 -3
- package/dist/ark-status-dot.js +2 -1
- package/dist/ark-switch.d.ts +7 -4
- package/dist/ark-switch.js +5 -3
- package/dist/ark-tabs.d.ts +7 -7
- package/dist/ark-tabs.js +3 -2
- package/dist/ark-textarea.d.ts +10 -10
- package/dist/ark-textarea.js +2 -1
- package/dist/ark-time.d.ts +18 -0
- package/dist/ark-time.js +23 -0
- package/dist/ark-toaster.d.ts +1 -1
- package/dist/ark-toaster.js +2 -1
- package/dist/ark-toggle.d.ts +1 -1
- package/dist/ark-toggle.js +3 -2
- package/dist/ark-tooltip.d.ts +5 -5
- package/dist/ark-tooltip.js +2 -1
- package/dist/ark-tree.d.ts +86 -0
- package/dist/ark-tree.js +56 -0
- package/dist/chart.d.ts +65 -0
- package/dist/chart.js +36 -0
- package/dist/code.d.ts +148 -0
- package/dist/code.js +78 -0
- package/dist/dom-props.d.ts +6 -0
- package/dist/dom-props.js +13 -1
- package/dist/index.d.ts +13 -3
- package/dist/index.js +7 -2
- package/dist/jsx-intrinsics.d.ts +133 -1
- package/dist/wysiwyg.d.ts +108 -0
- package/dist/wysiwyg.js +69 -0
- package/package.json +47 -3
package/dist/code.js
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
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 { domAttrs } from "./dom-props.js";
|
|
7
|
+
import { useForwardedRef } from "./use-forwarded-ref.js";
|
|
8
|
+
import { useIsomorphicLayoutEffect } from "./use-isomorphic-layout-effect.js";
|
|
9
|
+
/** Propriedades JS do editor, atribuídas pela ref e só quando a referência muda. */
|
|
10
|
+
const PROPERTY_KEYS = [
|
|
11
|
+
"variableKeys",
|
|
12
|
+
"variables",
|
|
13
|
+
"completions",
|
|
14
|
+
"completionSource",
|
|
15
|
+
"formatter",
|
|
16
|
+
"extensions"
|
|
17
|
+
];
|
|
18
|
+
export const ArkCodeEditor = forwardRef(function ArkCodeEditor(props, forwardedRef) {
|
|
19
|
+
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;
|
|
20
|
+
const [ref, setRef] = useForwardedRef(forwardedRef);
|
|
21
|
+
const properties = { variableKeys, variables, completions, completionSource, formatter, extensions };
|
|
22
|
+
useEffect(() => {
|
|
23
|
+
registerTooarkCode();
|
|
24
|
+
}, []);
|
|
25
|
+
// O texto só é reatribuído quando difere do editor: o valor que o onChange acabou de devolver não move o cursor.
|
|
26
|
+
useIsomorphicLayoutEffect(() => {
|
|
27
|
+
const el = ref.current;
|
|
28
|
+
if (el && value !== undefined && el.value !== value)
|
|
29
|
+
el.value = value;
|
|
30
|
+
}, [ref, value]);
|
|
31
|
+
// Pela propriedade (o React 18 gravaria texto no atributo) e só com referência nova.
|
|
32
|
+
useIsomorphicLayoutEffect(() => {
|
|
33
|
+
const el = ref.current;
|
|
34
|
+
if (!el)
|
|
35
|
+
return;
|
|
36
|
+
for (const key of PROPERTY_KEYS) {
|
|
37
|
+
const next = properties[key];
|
|
38
|
+
if (next !== undefined && el[key] !== next)
|
|
39
|
+
el[key] = next;
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
useIsomorphicLayoutEffect(() => {
|
|
43
|
+
const el = ref.current;
|
|
44
|
+
if (!el)
|
|
45
|
+
return;
|
|
46
|
+
const handleChange = (event) => onChange?.(event);
|
|
47
|
+
const handleSubmit = (event) => onSubmit?.(event);
|
|
48
|
+
const handleError = (event) => onFormatError?.(event);
|
|
49
|
+
el.addEventListener("change", handleChange);
|
|
50
|
+
el.addEventListener("ark-submit", handleSubmit);
|
|
51
|
+
el.addEventListener("ark-format-error", handleError);
|
|
52
|
+
return () => {
|
|
53
|
+
el.removeEventListener("change", handleChange);
|
|
54
|
+
el.removeEventListener("ark-submit", handleSubmit);
|
|
55
|
+
el.removeEventListener("ark-format-error", handleError);
|
|
56
|
+
};
|
|
57
|
+
}, [ref, onChange, onSubmit, onFormatError]);
|
|
58
|
+
const off = (on) => (on === false ? "false" : undefined);
|
|
59
|
+
const attrs = {
|
|
60
|
+
...domAttrs(rest),
|
|
61
|
+
ref: setRef,
|
|
62
|
+
class: className,
|
|
63
|
+
readonly: readonly ? "" : undefined,
|
|
64
|
+
"min-height": minHeight,
|
|
65
|
+
"max-height": maxHeight,
|
|
66
|
+
"line-numbers": off(lineNumbers),
|
|
67
|
+
fold: off(fold),
|
|
68
|
+
wrap: wrap ? "" : undefined,
|
|
69
|
+
"indent-style": indentStyle,
|
|
70
|
+
"indent-size": indentSize,
|
|
71
|
+
"line-ending": lineEnding,
|
|
72
|
+
"tab-indent": off(tabIndent),
|
|
73
|
+
autocomplete: off(autocomplete),
|
|
74
|
+
"mark-unknown-variables": markUnknownVariables ? "" : undefined,
|
|
75
|
+
"single-line": singleLine ? "" : undefined
|
|
76
|
+
};
|
|
77
|
+
return createElement("ark-code-editor", attrs);
|
|
78
|
+
});
|
package/dist/dom-props.d.ts
CHANGED
|
@@ -6,3 +6,9 @@ import type React from "react";
|
|
|
6
6
|
* de fora: só os wrappers de elementos com conteúdo o declaram.
|
|
7
7
|
*/
|
|
8
8
|
export type ArkDomProps<Props> = Props & Omit<React.HTMLAttributes<HTMLElement>, keyof Props | "children">;
|
|
9
|
+
/**
|
|
10
|
+
* O `rest` de um wrapper pronto para o elemento, com os `aria-*` booleanos convertidos em texto. Num custom element
|
|
11
|
+
* o React 19 grava `true` como atributo vazio (`aria-pressed=""`, valor inválido em ARIA), enquanto num elemento
|
|
12
|
+
* nativo grava `"true"`; os tipos do React aceitam o booleano nos dois, então o wrapper iguala o resultado.
|
|
13
|
+
*/
|
|
14
|
+
export declare function domAttrs(rest: object): Record<string, unknown>;
|
package/dist/dom-props.js
CHANGED
|
@@ -1 +1,13 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* O `rest` de um wrapper pronto para o elemento, com os `aria-*` booleanos convertidos em texto. Num custom element
|
|
3
|
+
* o React 19 grava `true` como atributo vazio (`aria-pressed=""`, valor inválido em ARIA), enquanto num elemento
|
|
4
|
+
* nativo grava `"true"`; os tipos do React aceitam o booleano nos dois, então o wrapper iguala o resultado.
|
|
5
|
+
*/
|
|
6
|
+
export function domAttrs(rest) {
|
|
7
|
+
const attrs = { ...rest };
|
|
8
|
+
for (const name of Object.keys(attrs)) {
|
|
9
|
+
if (typeof attrs[name] === "boolean" && name.startsWith("aria-"))
|
|
10
|
+
attrs[name] = String(attrs[name]);
|
|
11
|
+
}
|
|
12
|
+
return attrs;
|
|
13
|
+
}
|
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";
|
package/dist/jsx-intrinsics.d.ts
CHANGED
|
@@ -10,23 +10,33 @@ import type {
|
|
|
10
10
|
ArkButtonVariant,
|
|
11
11
|
ArkCardPadding,
|
|
12
12
|
ArkCarouselSnap,
|
|
13
|
+
ArkDataViewMode,
|
|
14
|
+
ArkDataViewView,
|
|
13
15
|
ArkDatepickerLang,
|
|
14
16
|
ArkDialogSize,
|
|
15
17
|
ArkDrawerMode,
|
|
16
18
|
ArkDrawerSide,
|
|
19
|
+
ArkHeadingLevel,
|
|
17
20
|
ArkIntent,
|
|
18
21
|
ArkLang,
|
|
19
22
|
ArkMarkShape,
|
|
20
23
|
ArkMenuAlign,
|
|
21
24
|
ArkMenuDirection,
|
|
25
|
+
ArkNavCollapsible,
|
|
26
|
+
ArkNavSide,
|
|
27
|
+
ArkNavVariant,
|
|
22
28
|
ArkRounded,
|
|
23
29
|
ArkSize,
|
|
24
30
|
ArkTabsFill,
|
|
25
31
|
ArkTabsVariant,
|
|
26
32
|
ArkTextareaResize,
|
|
27
33
|
ArkTheme,
|
|
34
|
+
ArkTimeFormat,
|
|
28
35
|
ArkToastPosition,
|
|
29
|
-
ArkTooltipSide
|
|
36
|
+
ArkTooltipSide,
|
|
37
|
+
ArkTreeIcons,
|
|
38
|
+
ArkTreeItemIcon,
|
|
39
|
+
ArkTreeSelection
|
|
30
40
|
} from "@tooark/core";
|
|
31
41
|
import React from "react";
|
|
32
42
|
|
|
@@ -65,6 +75,7 @@ interface ArkIntrinsicElements {
|
|
|
65
75
|
"ark-button": React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement> & {
|
|
66
76
|
testid?: string;
|
|
67
77
|
type?: ArkButtonType;
|
|
78
|
+
form?: string;
|
|
68
79
|
disabled?: boolean;
|
|
69
80
|
variant?: ArkButtonVariant;
|
|
70
81
|
intent?: ArkIntent;
|
|
@@ -78,6 +89,7 @@ interface ArkIntrinsicElements {
|
|
|
78
89
|
"full-width"?: boolean;
|
|
79
90
|
href?: string;
|
|
80
91
|
target?: string;
|
|
92
|
+
download?: string;
|
|
81
93
|
color?: string;
|
|
82
94
|
"text-color"?: string;
|
|
83
95
|
};
|
|
@@ -278,6 +290,7 @@ interface ArkIntrinsicElements {
|
|
|
278
290
|
width?: string | number;
|
|
279
291
|
height?: string | number;
|
|
280
292
|
label?: string;
|
|
293
|
+
"heading-level"?: ArkHeadingLevel;
|
|
281
294
|
"no-close-button"?: boolean;
|
|
282
295
|
persistent?: boolean;
|
|
283
296
|
"no-scroll-lock"?: boolean;
|
|
@@ -307,6 +320,53 @@ interface ArkIntrinsicElements {
|
|
|
307
320
|
lang?: ArkLang;
|
|
308
321
|
"locale-json"?: string;
|
|
309
322
|
};
|
|
323
|
+
"ark-pagination": React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement> & {
|
|
324
|
+
testid?: string;
|
|
325
|
+
page?: number | string;
|
|
326
|
+
"page-size"?: number | string;
|
|
327
|
+
total?: number | string;
|
|
328
|
+
/** Opções do seletor de itens por página, separadas por vírgula; sem ele o seletor não aparece. */
|
|
329
|
+
"page-sizes"?: string;
|
|
330
|
+
siblings?: number | string;
|
|
331
|
+
disabled?: boolean;
|
|
332
|
+
size?: ArkSize;
|
|
333
|
+
intent?: ArkIntent;
|
|
334
|
+
theme?: ArkTheme;
|
|
335
|
+
lang?: ArkLang;
|
|
336
|
+
"locale-json"?: string;
|
|
337
|
+
};
|
|
338
|
+
"ark-data-view": React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement> & {
|
|
339
|
+
testid?: string;
|
|
340
|
+
/** JSON das colunas (sem `render`/`compare`, que só existem na propriedade JS). */
|
|
341
|
+
columns?: string;
|
|
342
|
+
rows?: string;
|
|
343
|
+
"row-key"?: string;
|
|
344
|
+
view?: ArkDataViewView;
|
|
345
|
+
/** Esconde o seletor de visualização; `view` continua valendo. */
|
|
346
|
+
"no-view-selector"?: boolean;
|
|
347
|
+
breakpoint?: number | string;
|
|
348
|
+
mode?: ArkDataViewMode;
|
|
349
|
+
page?: number | string;
|
|
350
|
+
"page-size"?: number | string;
|
|
351
|
+
"page-sizes"?: string;
|
|
352
|
+
total?: number | string;
|
|
353
|
+
/** "chave:asc" ou "chave:desc". */
|
|
354
|
+
sort?: string;
|
|
355
|
+
search?: string;
|
|
356
|
+
searchable?: boolean;
|
|
357
|
+
"search-placeholder"?: string;
|
|
358
|
+
"search-debounce"?: number | string;
|
|
359
|
+
selectable?: boolean;
|
|
360
|
+
reorderable?: boolean;
|
|
361
|
+
clickable?: boolean;
|
|
362
|
+
loading?: boolean;
|
|
363
|
+
"card-columns"?: number | string;
|
|
364
|
+
label?: string;
|
|
365
|
+
size?: ArkSize;
|
|
366
|
+
theme?: ArkTheme;
|
|
367
|
+
lang?: ArkLang;
|
|
368
|
+
"locale-json"?: string;
|
|
369
|
+
};
|
|
310
370
|
"ark-mark": React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement> & {
|
|
311
371
|
testid?: string;
|
|
312
372
|
shape?: ArkMarkShape;
|
|
@@ -324,6 +384,12 @@ interface ArkIntrinsicElements {
|
|
|
324
384
|
size?: ArkSize;
|
|
325
385
|
theme?: ArkTheme;
|
|
326
386
|
};
|
|
387
|
+
"ark-menu-group": React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement> & {
|
|
388
|
+
testid?: string;
|
|
389
|
+
label?: string;
|
|
390
|
+
size?: ArkSize;
|
|
391
|
+
theme?: ArkTheme;
|
|
392
|
+
};
|
|
327
393
|
"ark-menu-item": React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement> & {
|
|
328
394
|
testid?: string;
|
|
329
395
|
value?: string;
|
|
@@ -333,6 +399,36 @@ interface ArkIntrinsicElements {
|
|
|
333
399
|
divider?: boolean;
|
|
334
400
|
static?: boolean;
|
|
335
401
|
};
|
|
402
|
+
"ark-nav": React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement> & {
|
|
403
|
+
testid?: string;
|
|
404
|
+
variant?: ArkNavVariant;
|
|
405
|
+
side?: ArkNavSide;
|
|
406
|
+
value?: string;
|
|
407
|
+
collapsed?: boolean;
|
|
408
|
+
collapsible?: boolean | ArkNavCollapsible;
|
|
409
|
+
label?: string;
|
|
410
|
+
size?: ArkSize;
|
|
411
|
+
intent?: ArkIntent;
|
|
412
|
+
theme?: ArkTheme;
|
|
413
|
+
lang?: ArkLang;
|
|
414
|
+
"locale-json"?: string;
|
|
415
|
+
};
|
|
416
|
+
"ark-nav-item": React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement> & {
|
|
417
|
+
testid?: string;
|
|
418
|
+
href?: string;
|
|
419
|
+
target?: string;
|
|
420
|
+
label?: string;
|
|
421
|
+
value?: string;
|
|
422
|
+
current?: boolean;
|
|
423
|
+
disabled?: boolean;
|
|
424
|
+
divider?: boolean;
|
|
425
|
+
};
|
|
426
|
+
"ark-nav-group": React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement> & {
|
|
427
|
+
testid?: string;
|
|
428
|
+
label?: string;
|
|
429
|
+
expandable?: boolean;
|
|
430
|
+
open?: boolean;
|
|
431
|
+
};
|
|
336
432
|
"ark-tooltip": React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement> & {
|
|
337
433
|
testid?: string;
|
|
338
434
|
content?: string;
|
|
@@ -341,12 +437,38 @@ interface ArkIntrinsicElements {
|
|
|
341
437
|
open?: boolean;
|
|
342
438
|
theme?: ArkTheme;
|
|
343
439
|
};
|
|
440
|
+
"ark-tree": React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement> & {
|
|
441
|
+
testid?: string;
|
|
442
|
+
selection?: ArkTreeSelection;
|
|
443
|
+
checkboxes?: boolean;
|
|
444
|
+
propagate?: boolean;
|
|
445
|
+
value?: string;
|
|
446
|
+
label?: string;
|
|
447
|
+
icons?: ArkTreeIcons;
|
|
448
|
+
"icon-color"?: string;
|
|
449
|
+
size?: ArkSize;
|
|
450
|
+
theme?: ArkTheme;
|
|
451
|
+
};
|
|
452
|
+
"ark-tree-item": React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement> & {
|
|
453
|
+
testid?: string;
|
|
454
|
+
value?: string;
|
|
455
|
+
label?: string;
|
|
456
|
+
icon?: ArkTreeItemIcon;
|
|
457
|
+
expanded?: boolean;
|
|
458
|
+
lazy?: boolean;
|
|
459
|
+
loading?: boolean;
|
|
460
|
+
selected?: boolean;
|
|
461
|
+
checked?: boolean | "mixed" | "false";
|
|
462
|
+
disabled?: boolean;
|
|
463
|
+
};
|
|
344
464
|
"ark-card": React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement> & {
|
|
345
465
|
testid?: string;
|
|
346
466
|
heading?: string;
|
|
467
|
+
"heading-level"?: ArkHeadingLevel;
|
|
347
468
|
padding?: ArkCardPadding;
|
|
348
469
|
rounded?: ArkRounded;
|
|
349
470
|
theme?: ArkTheme;
|
|
471
|
+
"wrap-actions"?: boolean;
|
|
350
472
|
};
|
|
351
473
|
"ark-drawer": React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement> & {
|
|
352
474
|
testid?: string;
|
|
@@ -355,6 +477,7 @@ interface ArkIntrinsicElements {
|
|
|
355
477
|
mode?: ArkDrawerMode;
|
|
356
478
|
size?: string | number;
|
|
357
479
|
label?: string;
|
|
480
|
+
"heading-level"?: ArkHeadingLevel;
|
|
358
481
|
"no-close-button"?: boolean;
|
|
359
482
|
persistent?: boolean;
|
|
360
483
|
"no-scroll-lock"?: boolean;
|
|
@@ -365,6 +488,7 @@ interface ArkIntrinsicElements {
|
|
|
365
488
|
"ark-empty": React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement> & {
|
|
366
489
|
testid?: string;
|
|
367
490
|
heading?: string;
|
|
491
|
+
"heading-level"?: ArkHeadingLevel;
|
|
368
492
|
description?: string;
|
|
369
493
|
theme?: ArkTheme;
|
|
370
494
|
};
|
|
@@ -464,6 +588,7 @@ interface ArkIntrinsicElements {
|
|
|
464
588
|
autocomplete?: string;
|
|
465
589
|
autofocus?: boolean;
|
|
466
590
|
inputmode?: string;
|
|
591
|
+
list?: string;
|
|
467
592
|
maxlength?: number | string;
|
|
468
593
|
minlength?: number | string;
|
|
469
594
|
pattern?: string;
|
|
@@ -520,6 +645,11 @@ interface ArkIntrinsicElements {
|
|
|
520
645
|
minlength?: number | string;
|
|
521
646
|
spellcheck?: boolean | "true" | "false";
|
|
522
647
|
};
|
|
648
|
+
"ark-time": React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement> & {
|
|
649
|
+
testid?: string;
|
|
650
|
+
datetime?: string;
|
|
651
|
+
format?: ArkTimeFormat;
|
|
652
|
+
};
|
|
523
653
|
"ark-carousel": React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement> & {
|
|
524
654
|
testid?: string;
|
|
525
655
|
theme?: ArkTheme;
|
|
@@ -549,6 +679,7 @@ interface ArkIntrinsicElements {
|
|
|
549
679
|
"ark-chart": React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement> & {
|
|
550
680
|
testid?: string;
|
|
551
681
|
theme?: ArkTheme;
|
|
682
|
+
palette?: "default" | "tokens";
|
|
552
683
|
renderer?: "canvas" | "svg";
|
|
553
684
|
height?: string;
|
|
554
685
|
"auto-resize"?: boolean | "false";
|
|
@@ -576,6 +707,7 @@ interface ArkIntrinsicElements {
|
|
|
576
707
|
readonly?: boolean;
|
|
577
708
|
placeholder?: string;
|
|
578
709
|
"min-height"?: string;
|
|
710
|
+
"max-height"?: string;
|
|
579
711
|
"line-numbers"?: boolean | "false";
|
|
580
712
|
fold?: boolean | "false";
|
|
581
713
|
wrap?: boolean;
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import type { ArkLang } from "@tooark/core";
|
|
2
|
+
import { type ArkWysiwygContent, type ArkWysiwygEditor as ArkWysiwygEditorElement, type ArkWysiwygUploadError, type ArkWysiwygUploader, type ArkWysiwygViewer as ArkWysiwygViewerElement } from "@tooark/wysiwyg";
|
|
3
|
+
import type React from "react";
|
|
4
|
+
import { type ArkDomProps } from "./dom-props.js";
|
|
5
|
+
/** Atributos da tag `ark-wysiwyg-editor`, os mesmos da entrada principal, mais as propriedades JS. */
|
|
6
|
+
type ArkWysiwygEditorTagProps = React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement> & {
|
|
7
|
+
testid?: string;
|
|
8
|
+
theme?: "auto" | "light" | "dark";
|
|
9
|
+
placeholder?: string;
|
|
10
|
+
editable?: boolean | "false";
|
|
11
|
+
toolbar?: string;
|
|
12
|
+
lang?: ArkLang;
|
|
13
|
+
"locale-json"?: string;
|
|
14
|
+
colors?: string;
|
|
15
|
+
highlights?: string;
|
|
16
|
+
"max-file-size"?: number;
|
|
17
|
+
/** Gancho de upload de imagem e vídeo (propriedade JS). */
|
|
18
|
+
uploadFile?: ArkWysiwygUploader | null;
|
|
19
|
+
};
|
|
20
|
+
declare module "react" {
|
|
21
|
+
namespace JSX {
|
|
22
|
+
interface IntrinsicElements {
|
|
23
|
+
"ark-wysiwyg-editor": ArkWysiwygEditorTagProps;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
declare global {
|
|
28
|
+
namespace JSX {
|
|
29
|
+
interface IntrinsicElements {
|
|
30
|
+
"ark-wysiwyg-editor": ArkWysiwygEditorTagProps;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
export type ArkWysiwygEditorProps = ArkDomProps<{
|
|
35
|
+
/**
|
|
36
|
+
* Conteúdo como JSON do Tiptap. Atribuído só quando a referência muda e fora do histórico de desfazer: o objeto que
|
|
37
|
+
* o `onChange` devolve, repassado, não reescreve o editor.
|
|
38
|
+
*/
|
|
39
|
+
content?: ArkWysiwygContent | null;
|
|
40
|
+
/** Gancho de upload; sem ele não há botões de mídia e arquivos colados são recusados. */
|
|
41
|
+
uploadFile?: ArkWysiwygUploader | null;
|
|
42
|
+
/** Grupos e itens da toolbar (`style,marks,...`, `all`, `none`). */
|
|
43
|
+
toolbar?: string;
|
|
44
|
+
theme?: "auto" | "light" | "dark";
|
|
45
|
+
placeholder?: string;
|
|
46
|
+
/** false desabilita a edição. Padrão: true. */
|
|
47
|
+
editable?: boolean;
|
|
48
|
+
lang?: ArkLang;
|
|
49
|
+
/** Rótulos próprios (objeto ou JSON), por cima do idioma. */
|
|
50
|
+
localeJson?: string | Record<string, string>;
|
|
51
|
+
/** Paleta da cor do texto (cores CSS). */
|
|
52
|
+
colors?: string[];
|
|
53
|
+
/** Paleta do marca-texto (cores CSS). */
|
|
54
|
+
highlights?: string[];
|
|
55
|
+
/** Tamanho máximo de arquivo em bytes. Padrão: 10 MiB. */
|
|
56
|
+
maxFileSize?: number;
|
|
57
|
+
testid?: string;
|
|
58
|
+
className?: string;
|
|
59
|
+
/** Cada edição, com o JSON do Tiptap em `detail`. */
|
|
60
|
+
onChange?: (event: CustomEvent<ArkWysiwygContent>) => void;
|
|
61
|
+
/** Arquivo recusado ou upload que falhou, com o motivo em `detail`. */
|
|
62
|
+
onUploadError?: (event: CustomEvent<ArkWysiwygUploadError>) => void;
|
|
63
|
+
}>;
|
|
64
|
+
export declare const ArkWysiwygEditor: React.ForwardRefExoticComponent<{
|
|
65
|
+
/**
|
|
66
|
+
* Conteúdo como JSON do Tiptap. Atribuído só quando a referência muda e fora do histórico de desfazer: o objeto que
|
|
67
|
+
* o `onChange` devolve, repassado, não reescreve o editor.
|
|
68
|
+
*/
|
|
69
|
+
content?: ArkWysiwygContent | null;
|
|
70
|
+
/** Gancho de upload; sem ele não há botões de mídia e arquivos colados são recusados. */
|
|
71
|
+
uploadFile?: ArkWysiwygUploader | null;
|
|
72
|
+
/** Grupos e itens da toolbar (`style,marks,...`, `all`, `none`). */
|
|
73
|
+
toolbar?: string;
|
|
74
|
+
theme?: "auto" | "light" | "dark";
|
|
75
|
+
placeholder?: string;
|
|
76
|
+
/** false desabilita a edição. Padrão: true. */
|
|
77
|
+
editable?: boolean;
|
|
78
|
+
lang?: ArkLang;
|
|
79
|
+
/** Rótulos próprios (objeto ou JSON), por cima do idioma. */
|
|
80
|
+
localeJson?: string | Record<string, string>;
|
|
81
|
+
/** Paleta da cor do texto (cores CSS). */
|
|
82
|
+
colors?: string[];
|
|
83
|
+
/** Paleta do marca-texto (cores CSS). */
|
|
84
|
+
highlights?: string[];
|
|
85
|
+
/** Tamanho máximo de arquivo em bytes. Padrão: 10 MiB. */
|
|
86
|
+
maxFileSize?: number;
|
|
87
|
+
testid?: string;
|
|
88
|
+
className?: string;
|
|
89
|
+
/** Cada edição, com o JSON do Tiptap em `detail`. */
|
|
90
|
+
onChange?: (event: CustomEvent<ArkWysiwygContent>) => void;
|
|
91
|
+
/** Arquivo recusado ou upload que falhou, com o motivo em `detail`. */
|
|
92
|
+
onUploadError?: (event: CustomEvent<ArkWysiwygUploadError>) => void;
|
|
93
|
+
} & Omit<React.HTMLAttributes<HTMLElement>, "children" | "className" | "lang" | "content" | "onChange" | "testid" | "theme" | "localeJson" | "colors" | "placeholder" | "toolbar" | "uploadFile" | "editable" | "highlights" | "maxFileSize" | "onUploadError"> & React.RefAttributes<ArkWysiwygEditorElement>>;
|
|
94
|
+
export type ArkWysiwygViewerProps = ArkDomProps<{
|
|
95
|
+
/** Conteúdo como JSON do Tiptap, sanitizado ao entrar. */
|
|
96
|
+
content?: ArkWysiwygContent | null;
|
|
97
|
+
theme?: "auto" | "light" | "dark";
|
|
98
|
+
testid?: string;
|
|
99
|
+
className?: string;
|
|
100
|
+
}>;
|
|
101
|
+
export declare const ArkWysiwygViewer: React.ForwardRefExoticComponent<{
|
|
102
|
+
/** Conteúdo como JSON do Tiptap, sanitizado ao entrar. */
|
|
103
|
+
content?: ArkWysiwygContent | null;
|
|
104
|
+
theme?: "auto" | "light" | "dark";
|
|
105
|
+
testid?: string;
|
|
106
|
+
className?: string;
|
|
107
|
+
} & Omit<React.HTMLAttributes<HTMLElement>, "children" | "className" | "content" | "testid" | "theme"> & React.RefAttributes<ArkWysiwygViewerElement>>;
|
|
108
|
+
export {};
|
package/dist/wysiwyg.js
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { registerTooarkWysiwyg } from "@tooark/wysiwyg";
|
|
2
|
+
import { createElement, forwardRef, useEffect, useRef } from "react";
|
|
3
|
+
import { domAttrs } from "./dom-props.js";
|
|
4
|
+
import { useForwardedRef } from "./use-forwarded-ref.js";
|
|
5
|
+
import { useIsomorphicLayoutEffect } from "./use-isomorphic-layout-effect.js";
|
|
6
|
+
export const ArkWysiwygEditor = forwardRef(function ArkWysiwygEditor(props, forwardedRef) {
|
|
7
|
+
const { className, content, uploadFile, editable, localeJson, colors, highlights, maxFileSize, onChange, onUploadError, ...rest } = props;
|
|
8
|
+
const [ref, setRef] = useForwardedRef(forwardedRef);
|
|
9
|
+
// O último JSON que o editor emitiu e o último atribuído: o getter `content` monta um objeto novo a cada leitura,
|
|
10
|
+
// então a comparação é com o que passou por aqui.
|
|
11
|
+
const known = useRef(undefined);
|
|
12
|
+
useEffect(() => {
|
|
13
|
+
registerTooarkWysiwyg();
|
|
14
|
+
}, []);
|
|
15
|
+
// Conteúdo e gancho pela propriedade, só com referência nova: setContent troca o documento fora do histórico, e
|
|
16
|
+
// o objeto que o onChange acabou de entregar, repassado pelo app, não reescreve o editor nem move o cursor.
|
|
17
|
+
useIsomorphicLayoutEffect(() => {
|
|
18
|
+
const el = ref.current;
|
|
19
|
+
if (!el || content === undefined || content === known.current)
|
|
20
|
+
return;
|
|
21
|
+
known.current = content;
|
|
22
|
+
el.content = content;
|
|
23
|
+
}, [ref, content]);
|
|
24
|
+
useIsomorphicLayoutEffect(() => {
|
|
25
|
+
const el = ref.current;
|
|
26
|
+
if (el && uploadFile !== undefined && el.uploadFile !== uploadFile)
|
|
27
|
+
el.uploadFile = uploadFile;
|
|
28
|
+
}, [ref, uploadFile]);
|
|
29
|
+
useIsomorphicLayoutEffect(() => {
|
|
30
|
+
const el = ref.current;
|
|
31
|
+
if (!el)
|
|
32
|
+
return;
|
|
33
|
+
const handleChange = (event) => {
|
|
34
|
+
known.current = event.detail;
|
|
35
|
+
onChange?.(event);
|
|
36
|
+
};
|
|
37
|
+
const handleError = (event) => onUploadError?.(event);
|
|
38
|
+
el.addEventListener("ark-wysiwyg-change", handleChange);
|
|
39
|
+
el.addEventListener("ark-wysiwyg-upload-error", handleError);
|
|
40
|
+
return () => {
|
|
41
|
+
el.removeEventListener("ark-wysiwyg-change", handleChange);
|
|
42
|
+
el.removeEventListener("ark-wysiwyg-upload-error", handleError);
|
|
43
|
+
};
|
|
44
|
+
}, [ref, onChange, onUploadError]);
|
|
45
|
+
const attrs = {
|
|
46
|
+
...domAttrs(rest),
|
|
47
|
+
ref: setRef,
|
|
48
|
+
class: className,
|
|
49
|
+
editable: editable === false ? "false" : undefined,
|
|
50
|
+
"locale-json": localeJson === undefined || typeof localeJson === "string" ? localeJson : JSON.stringify(localeJson),
|
|
51
|
+
colors: colors ? JSON.stringify(colors) : undefined,
|
|
52
|
+
highlights: highlights ? JSON.stringify(highlights) : undefined,
|
|
53
|
+
"max-file-size": maxFileSize
|
|
54
|
+
};
|
|
55
|
+
return createElement("ark-wysiwyg-editor", attrs);
|
|
56
|
+
});
|
|
57
|
+
export const ArkWysiwygViewer = forwardRef(function ArkWysiwygViewer(props, forwardedRef) {
|
|
58
|
+
const { className, content, ...rest } = props;
|
|
59
|
+
const [ref, setRef] = useForwardedRef(forwardedRef);
|
|
60
|
+
useEffect(() => {
|
|
61
|
+
registerTooarkWysiwyg();
|
|
62
|
+
}, []);
|
|
63
|
+
useIsomorphicLayoutEffect(() => {
|
|
64
|
+
const el = ref.current;
|
|
65
|
+
if (el && content !== undefined && el.content !== content)
|
|
66
|
+
el.content = content;
|
|
67
|
+
}, [ref, content]);
|
|
68
|
+
return createElement("ark-wysiwyg-viewer", { ...domAttrs(rest), ref: setRef, class: className });
|
|
69
|
+
});
|