@tooark/react 1.2.2 → 1.4.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 +42 -4
- package/README.pt-BR.md +42 -4
- package/dist/ark-alert.d.ts +12 -1
- package/dist/ark-alert.js +7 -6
- package/dist/ark-avatar.d.ts +8 -1
- package/dist/ark-avatar.js +4 -3
- package/dist/ark-badge.d.ts +6 -1
- package/dist/ark-badge.js +4 -3
- package/dist/ark-button.d.ts +7 -1
- package/dist/ark-button.js +4 -3
- package/dist/ark-calendar.d.ts +15 -2
- package/dist/ark-calendar.js +7 -6
- package/dist/ark-card.d.ts +8 -1
- package/dist/ark-card.js +4 -3
- package/dist/ark-carousel.d.ts +10 -1
- package/dist/ark-carousel.js +7 -6
- package/dist/ark-checkbox.d.ts +20 -1
- package/dist/ark-checkbox.js +7 -6
- package/dist/ark-clock.d.ts +10 -2
- package/dist/ark-clock.js +7 -6
- package/dist/ark-color-swatches.d.ts +15 -1
- package/dist/ark-color-swatches.js +7 -6
- package/dist/ark-command-palette.d.ts +48 -2
- package/dist/ark-command-palette.js +11 -8
- package/dist/ark-copy-button.d.ts +16 -1
- package/dist/ark-copy-button.js +7 -6
- package/dist/ark-datepicker.d.ts +13 -1
- package/dist/ark-datepicker.js +7 -6
- package/dist/ark-dialog.d.ts +22 -1
- package/dist/ark-dialog.js +6 -5
- package/dist/ark-drawer.d.ts +22 -1
- package/dist/ark-drawer.js +6 -5
- package/dist/ark-empty.d.ts +10 -1
- package/dist/ark-empty.js +4 -3
- package/dist/ark-file-input.d.ts +23 -1
- package/dist/ark-file-input.js +7 -6
- package/dist/ark-input.d.ts +34 -1
- package/dist/ark-input.js +7 -6
- package/dist/ark-kbd.d.ts +6 -1
- package/dist/ark-kbd.js +4 -3
- package/dist/ark-kv-editor.d.ts +39 -2
- package/dist/ark-kv-editor.js +16 -8
- package/dist/ark-mark.d.ts +6 -1
- package/dist/ark-mark.js +4 -3
- package/dist/ark-menu.d.ts +34 -2
- package/dist/ark-menu.js +9 -7
- package/dist/ark-progress.d.ts +14 -1
- package/dist/ark-progress.js +4 -3
- package/dist/ark-radio.d.ts +21 -1
- package/dist/ark-radio.js +7 -6
- package/dist/ark-scheduler.d.ts +25 -2
- package/dist/ark-scheduler.js +7 -6
- package/dist/ark-select.d.ts +20 -1
- package/dist/ark-select.js +7 -6
- package/dist/ark-shape-picker.d.ts +17 -1
- package/dist/ark-shape-picker.js +9 -7
- package/dist/ark-skeleton.d.ts +11 -1
- package/dist/ark-skeleton.js +4 -3
- package/dist/ark-spinner.d.ts +6 -1
- package/dist/ark-spinner.js +4 -3
- package/dist/ark-split-pane.d.ts +12 -1
- package/dist/ark-split-pane.js +7 -6
- package/dist/ark-status-dot.d.ts +6 -1
- package/dist/ark-status-dot.js +4 -3
- package/dist/ark-switch.d.ts +12 -2
- package/dist/ark-switch.js +7 -6
- package/dist/ark-tabs.d.ts +30 -2
- package/dist/ark-tabs.js +10 -8
- package/dist/ark-textarea.d.ts +34 -1
- package/dist/ark-textarea.js +7 -6
- package/dist/ark-toaster.d.ts +9 -1
- package/dist/ark-toaster.js +7 -6
- package/dist/ark-toggle.d.ts +21 -2
- package/dist/ark-toggle.js +12 -11
- package/dist/ark-tooltip.d.ts +10 -1
- package/dist/ark-tooltip.js +4 -3
- package/dist/jsx-intrinsics.d.ts +14 -0
- package/dist/use-forwarded-ref.d.ts +3 -0
- package/dist/use-forwarded-ref.js +31 -0
- package/package.json +3 -3
package/dist/ark-split-pane.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { createElement,
|
|
1
|
+
import { createElement, forwardRef, useEffect } from "react";
|
|
2
2
|
import { ensureTooarkComponentsRegistered } from "./register.js";
|
|
3
|
-
|
|
3
|
+
import { useForwardedRef } from "./use-forwarded-ref.js";
|
|
4
|
+
export const ArkSplitPane = forwardRef(function ArkSplitPane(props, forwardedRef) {
|
|
4
5
|
const { children, className, sizes, localeJson, onResize, ...rest } = props;
|
|
5
|
-
const ref =
|
|
6
|
+
const [ref, setRef] = useForwardedRef(forwardedRef);
|
|
6
7
|
useEffect(() => {
|
|
7
8
|
ensureTooarkComponentsRegistered();
|
|
8
9
|
}, []);
|
|
@@ -13,13 +14,13 @@ export function ArkSplitPane(props) {
|
|
|
13
14
|
const handler = (event) => onResize(event);
|
|
14
15
|
el.addEventListener("ark-resize", handler);
|
|
15
16
|
return () => el.removeEventListener("ark-resize", handler);
|
|
16
|
-
}, [onResize]);
|
|
17
|
+
}, [ref, onResize]);
|
|
17
18
|
const attrs = {
|
|
18
19
|
...rest,
|
|
19
|
-
ref,
|
|
20
|
+
ref: setRef,
|
|
20
21
|
class: className,
|
|
21
22
|
sizes: sizes ? sizes.join(",") : undefined,
|
|
22
23
|
"locale-json": localeJson
|
|
23
24
|
};
|
|
24
25
|
return createElement("ark-split-pane", attrs, children);
|
|
25
|
-
}
|
|
26
|
+
});
|
package/dist/ark-status-dot.d.ts
CHANGED
|
@@ -1,8 +1,13 @@
|
|
|
1
1
|
import type { ArkStatusDotStyleOptions } from "@tooark/core";
|
|
2
|
+
import type { ArkStatusDot as ArkStatusDotElement } from "@tooark/web-components";
|
|
2
3
|
import type React from "react";
|
|
3
4
|
export type ArkStatusDotProps = ArkStatusDotStyleOptions & {
|
|
4
5
|
/** Com rotulo o ponto vira role="img" nomeado; sem ele e decorativo (aria-hidden). */
|
|
5
6
|
label?: string;
|
|
6
7
|
className?: string;
|
|
7
8
|
};
|
|
8
|
-
export declare
|
|
9
|
+
export declare const ArkStatusDot: React.ForwardRefExoticComponent<ArkStatusDotStyleOptions & {
|
|
10
|
+
/** Com rotulo o ponto vira role="img" nomeado; sem ele e decorativo (aria-hidden). */
|
|
11
|
+
label?: string;
|
|
12
|
+
className?: string;
|
|
13
|
+
} & React.RefAttributes<ArkStatusDotElement>>;
|
package/dist/ark-status-dot.js
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
import { createElement, useEffect } from "react";
|
|
1
|
+
import { createElement, forwardRef, useEffect } from "react";
|
|
2
2
|
import { ensureTooarkComponentsRegistered } from "./register.js";
|
|
3
|
-
export function ArkStatusDot(props) {
|
|
3
|
+
export const ArkStatusDot = forwardRef(function ArkStatusDot(props, forwardedRef) {
|
|
4
4
|
const { className, ...rest } = props;
|
|
5
5
|
useEffect(() => {
|
|
6
6
|
ensureTooarkComponentsRegistered();
|
|
7
7
|
}, []);
|
|
8
8
|
const attrs = {
|
|
9
9
|
...rest,
|
|
10
|
+
ref: forwardedRef,
|
|
10
11
|
class: className
|
|
11
12
|
};
|
|
12
13
|
return createElement("ark-status-dot", attrs);
|
|
13
|
-
}
|
|
14
|
+
});
|
package/dist/ark-switch.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { ArkSwitchStyleOptions } from "@tooark/core";
|
|
2
|
-
import
|
|
2
|
+
import type { ArkSwitch as ArkSwitchElement } from "@tooark/web-components";
|
|
3
|
+
import type React from "react";
|
|
3
4
|
export type ArkSwitchProps = ArkSwitchStyleOptions & {
|
|
4
5
|
disabled?: boolean;
|
|
5
6
|
name?: string;
|
|
@@ -10,4 +11,13 @@ export type ArkSwitchProps = ArkSwitchStyleOptions & {
|
|
|
10
11
|
checked: boolean;
|
|
11
12
|
}>) => void;
|
|
12
13
|
};
|
|
13
|
-
export declare
|
|
14
|
+
export declare const ArkSwitch: React.ForwardRefExoticComponent<ArkSwitchStyleOptions & {
|
|
15
|
+
disabled?: boolean;
|
|
16
|
+
name?: string;
|
|
17
|
+
value?: string;
|
|
18
|
+
label?: string;
|
|
19
|
+
className?: string;
|
|
20
|
+
onChange?: (event: CustomEvent<{
|
|
21
|
+
checked: boolean;
|
|
22
|
+
}>) => void;
|
|
23
|
+
} & React.RefAttributes<ArkSwitchElement>>;
|
package/dist/ark-switch.js
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { createElement, forwardRef, useEffect } from "react";
|
|
2
2
|
import { ensureTooarkComponentsRegistered } from "./register.js";
|
|
3
|
-
|
|
3
|
+
import { useForwardedRef } from "./use-forwarded-ref.js";
|
|
4
|
+
export const ArkSwitch = forwardRef(function ArkSwitch(props, forwardedRef) {
|
|
4
5
|
const { className, checked, labels, labelOn, labelOff, icons, disabled, onChange, ...rest } = props;
|
|
5
6
|
useEffect(() => {
|
|
6
7
|
ensureTooarkComponentsRegistered();
|
|
7
8
|
}, []);
|
|
8
|
-
const ref =
|
|
9
|
+
const [ref, setRef] = useForwardedRef(forwardedRef);
|
|
9
10
|
useEffect(() => {
|
|
10
11
|
const el = ref.current;
|
|
11
12
|
if (!el || !onChange)
|
|
@@ -13,10 +14,10 @@ export function ArkSwitch(props) {
|
|
|
13
14
|
const handler = (event) => onChange(event);
|
|
14
15
|
el.addEventListener("change", handler);
|
|
15
16
|
return () => el.removeEventListener("change", handler);
|
|
16
|
-
}, [onChange]);
|
|
17
|
+
}, [ref, onChange]);
|
|
17
18
|
const attrs = {
|
|
18
19
|
...rest,
|
|
19
|
-
ref,
|
|
20
|
+
ref: setRef,
|
|
20
21
|
class: className,
|
|
21
22
|
checked: checked ? "" : undefined,
|
|
22
23
|
disabled: disabled ? "" : undefined,
|
|
@@ -26,4 +27,4 @@ export function ArkSwitch(props) {
|
|
|
26
27
|
"label-off": labelOff
|
|
27
28
|
};
|
|
28
29
|
return createElement("ark-switch", attrs);
|
|
29
|
-
}
|
|
30
|
+
});
|
package/dist/ark-tabs.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { ArkTabStyleOptions, ArkTabsStyleOptions } from "@tooark/core";
|
|
2
|
+
import type { ArkTab as ArkTabElement, ArkTabs as ArkTabsElement } from "@tooark/web-components";
|
|
2
3
|
import React, { type PropsWithChildren } from "react";
|
|
3
4
|
export type ArkTabsProps = PropsWithChildren<ArkTabsStyleOptions & {
|
|
4
5
|
/** Value da aba ativa; sem ele a primeira habilitada assume. */
|
|
@@ -14,7 +15,22 @@ export type ArkTabsProps = PropsWithChildren<ArkTabsStyleOptions & {
|
|
|
14
15
|
value: string;
|
|
15
16
|
}>) => void;
|
|
16
17
|
}>;
|
|
17
|
-
export declare
|
|
18
|
+
export declare const ArkTabs: React.ForwardRefExoticComponent<ArkTabsStyleOptions & {
|
|
19
|
+
/** Value da aba ativa; sem ele a primeira habilitada assume. */
|
|
20
|
+
value?: string;
|
|
21
|
+
/** Vira aria-label da faixa. */
|
|
22
|
+
label?: string;
|
|
23
|
+
className?: string;
|
|
24
|
+
onChange?: (event: CustomEvent<{
|
|
25
|
+
value: string;
|
|
26
|
+
}>) => void;
|
|
27
|
+
/** Uma aba fechavel pediu para fechar; remover a aba e do app. */
|
|
28
|
+
onClose?: (event: CustomEvent<{
|
|
29
|
+
value: string;
|
|
30
|
+
}>) => void;
|
|
31
|
+
} & {
|
|
32
|
+
children?: React.ReactNode | undefined;
|
|
33
|
+
} & React.RefAttributes<ArkTabsElement>>;
|
|
18
34
|
export type ArkTabProps = PropsWithChildren<ArkTabStyleOptions & {
|
|
19
35
|
value: string;
|
|
20
36
|
disabled?: boolean;
|
|
@@ -26,4 +42,16 @@ export type ArkTabProps = PropsWithChildren<ArkTabStyleOptions & {
|
|
|
26
42
|
dirty?: boolean;
|
|
27
43
|
className?: string;
|
|
28
44
|
}>;
|
|
29
|
-
export declare
|
|
45
|
+
export declare const ArkTab: React.ForwardRefExoticComponent<ArkTabStyleOptions & {
|
|
46
|
+
value: string;
|
|
47
|
+
disabled?: boolean;
|
|
48
|
+
/** id do painel que a aba controla (aria-controls). */
|
|
49
|
+
controls?: string;
|
|
50
|
+
/** Botao de fechar, clique do meio e Delete (so na variante editor). */
|
|
51
|
+
closable?: boolean;
|
|
52
|
+
/** Ponto de alteracoes nao salvas. */
|
|
53
|
+
dirty?: boolean;
|
|
54
|
+
className?: string;
|
|
55
|
+
} & {
|
|
56
|
+
children?: React.ReactNode | undefined;
|
|
57
|
+
} & React.RefAttributes<ArkTabElement>>;
|
package/dist/ark-tabs.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { createElement, forwardRef, useEffect } from "react";
|
|
2
2
|
import { ensureTooarkComponentsRegistered } from "./register.js";
|
|
3
|
-
|
|
3
|
+
import { useForwardedRef } from "./use-forwarded-ref.js";
|
|
4
|
+
export const ArkTabs = forwardRef(function ArkTabs(props, forwardedRef) {
|
|
4
5
|
const { children, className, localeJson, onChange, onClose, ...rest } = props;
|
|
5
|
-
const ref =
|
|
6
|
+
const [ref, setRef] = useForwardedRef(forwardedRef);
|
|
6
7
|
useEffect(() => {
|
|
7
8
|
ensureTooarkComponentsRegistered();
|
|
8
9
|
}, []);
|
|
@@ -18,26 +19,27 @@ export function ArkTabs(props) {
|
|
|
18
19
|
el.removeEventListener("change", handleChange);
|
|
19
20
|
el.removeEventListener("ark-close", handleClose);
|
|
20
21
|
};
|
|
21
|
-
}, [onChange, onClose]);
|
|
22
|
+
}, [ref, onChange, onClose]);
|
|
22
23
|
const attrs = {
|
|
23
24
|
...rest,
|
|
24
|
-
ref,
|
|
25
|
+
ref: setRef,
|
|
25
26
|
class: className,
|
|
26
27
|
"locale-json": localeJson
|
|
27
28
|
};
|
|
28
29
|
return createElement("ark-tabs", attrs, children);
|
|
29
|
-
}
|
|
30
|
-
export function ArkTab(props) {
|
|
30
|
+
});
|
|
31
|
+
export const ArkTab = forwardRef(function ArkTab(props, forwardedRef) {
|
|
31
32
|
const { children, className, disabled, closable, dirty, ...rest } = props;
|
|
32
33
|
useEffect(() => {
|
|
33
34
|
ensureTooarkComponentsRegistered();
|
|
34
35
|
}, []);
|
|
35
36
|
const attrs = {
|
|
36
37
|
...rest,
|
|
38
|
+
ref: forwardedRef,
|
|
37
39
|
class: className,
|
|
38
40
|
disabled: disabled ? "" : undefined,
|
|
39
41
|
closable: closable ? "" : undefined,
|
|
40
42
|
dirty: dirty ? "" : undefined
|
|
41
43
|
};
|
|
42
44
|
return createElement("ark-tab", attrs, children);
|
|
43
|
-
}
|
|
45
|
+
});
|
package/dist/ark-textarea.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { ArkTextareaResize, ArkTextareaStyleOptions } from "@tooark/core";
|
|
2
|
+
import type { ArkTextarea as ArkTextareaElement } from "@tooark/web-components";
|
|
2
3
|
import React, { type PropsWithChildren } from "react";
|
|
3
4
|
export type ArkTextareaProps = PropsWithChildren<ArkTextareaStyleOptions & {
|
|
4
5
|
label?: string;
|
|
@@ -31,4 +32,36 @@ export type ArkTextareaProps = PropsWithChildren<ArkTextareaStyleOptions & {
|
|
|
31
32
|
onInput?: (event: Event) => void;
|
|
32
33
|
onChange?: (event: Event) => void;
|
|
33
34
|
}>;
|
|
34
|
-
export declare
|
|
35
|
+
export declare const ArkTextarea: React.ForwardRefExoticComponent<ArkTextareaStyleOptions & {
|
|
36
|
+
label?: string;
|
|
37
|
+
placeholder?: string;
|
|
38
|
+
value?: string;
|
|
39
|
+
name?: string;
|
|
40
|
+
/** Linhas visiveis iniciais. Padrao: 3. */
|
|
41
|
+
rows?: number;
|
|
42
|
+
/** Cresce com o conteudo (field-sizing nativo, fallback por JS). */
|
|
43
|
+
autosize?: boolean;
|
|
44
|
+
/** Fonte monoespacada, para codigo e dados. */
|
|
45
|
+
monospace?: boolean;
|
|
46
|
+
/** Direcoes de redimensionamento pelo usuario. Padrao: "vertical". */
|
|
47
|
+
resize?: ArkTextareaResize;
|
|
48
|
+
helper?: string;
|
|
49
|
+
error?: boolean;
|
|
50
|
+
errorMessage?: string;
|
|
51
|
+
disabled?: boolean;
|
|
52
|
+
required?: boolean;
|
|
53
|
+
readonly?: boolean;
|
|
54
|
+
autocomplete?: string;
|
|
55
|
+
autofocus?: boolean;
|
|
56
|
+
maxlength?: number;
|
|
57
|
+
minlength?: number;
|
|
58
|
+
spellcheck?: boolean;
|
|
59
|
+
/** Quebra de linha do valor enviado (soft/hard) ou sem quebra visual (off), como no <textarea>. */
|
|
60
|
+
wrap?: "soft" | "hard" | "off";
|
|
61
|
+
"aria-label"?: string;
|
|
62
|
+
className?: string;
|
|
63
|
+
onInput?: (event: Event) => void;
|
|
64
|
+
onChange?: (event: Event) => void;
|
|
65
|
+
} & {
|
|
66
|
+
children?: React.ReactNode | undefined;
|
|
67
|
+
} & React.RefAttributes<ArkTextareaElement>>;
|
package/dist/ark-textarea.js
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { createElement, forwardRef, useEffect } from "react";
|
|
2
2
|
import { ensureTooarkComponentsRegistered } from "./register.js";
|
|
3
|
+
import { useForwardedRef } from "./use-forwarded-ref.js";
|
|
3
4
|
// Atributo do custom element: string ou ausente.
|
|
4
5
|
function attr(value) {
|
|
5
6
|
return value === undefined ? undefined : String(value);
|
|
6
7
|
}
|
|
7
|
-
export function ArkTextarea(props) {
|
|
8
|
+
export const ArkTextarea = forwardRef(function ArkTextarea(props, forwardedRef) {
|
|
8
9
|
const { children, className, rows, autosize, monospace, errorMessage, error, disabled, required, readonly, autofocus, maxlength, minlength, spellcheck, onInput, onChange, ...rest } = props;
|
|
9
|
-
const ref =
|
|
10
|
+
const [ref, setRef] = useForwardedRef(forwardedRef);
|
|
10
11
|
useEffect(() => {
|
|
11
12
|
ensureTooarkComponentsRegistered();
|
|
12
13
|
}, []);
|
|
@@ -22,10 +23,10 @@ export function ArkTextarea(props) {
|
|
|
22
23
|
el.removeEventListener("input", handleInput);
|
|
23
24
|
el.removeEventListener("change", handleChange);
|
|
24
25
|
};
|
|
25
|
-
}, [onInput, onChange]);
|
|
26
|
+
}, [ref, onInput, onChange]);
|
|
26
27
|
const attrs = {
|
|
27
28
|
...rest,
|
|
28
|
-
ref,
|
|
29
|
+
ref: setRef,
|
|
29
30
|
class: className,
|
|
30
31
|
rows: attr(rows),
|
|
31
32
|
autosize: autosize ? "" : undefined,
|
|
@@ -43,4 +44,4 @@ export function ArkTextarea(props) {
|
|
|
43
44
|
spellcheck
|
|
44
45
|
};
|
|
45
46
|
return createElement("ark-textarea", attrs, children);
|
|
46
|
-
}
|
|
47
|
+
});
|
package/dist/ark-toaster.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { ArkToasterStyleOptions } from "@tooark/core";
|
|
2
|
+
import type { ArkToaster as ArkToasterElement } from "@tooark/web-components";
|
|
2
3
|
import type React from "react";
|
|
3
4
|
export type ArkToasterProps = ArkToasterStyleOptions & {
|
|
4
5
|
className?: string;
|
|
@@ -8,4 +9,11 @@ export type ArkToasterProps = ArkToasterStyleOptions & {
|
|
|
8
9
|
actionId: string | null;
|
|
9
10
|
}>) => void;
|
|
10
11
|
};
|
|
11
|
-
export declare
|
|
12
|
+
export declare const ArkToaster: React.ForwardRefExoticComponent<ArkToasterStyleOptions & {
|
|
13
|
+
className?: string;
|
|
14
|
+
/** Botão de ação de um toast: detail traz o id do toast e o actionId das opções. */
|
|
15
|
+
onAction?: (event: CustomEvent<{
|
|
16
|
+
id: string;
|
|
17
|
+
actionId: string | null;
|
|
18
|
+
}>) => void;
|
|
19
|
+
} & React.RefAttributes<ArkToasterElement>>;
|
package/dist/ark-toaster.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { createElement,
|
|
1
|
+
import { createElement, forwardRef, useEffect } from "react";
|
|
2
2
|
import { ensureTooarkComponentsRegistered } from "./register.js";
|
|
3
|
-
|
|
3
|
+
import { useForwardedRef } from "./use-forwarded-ref.js";
|
|
4
|
+
export const ArkToaster = forwardRef(function ArkToaster(props, forwardedRef) {
|
|
4
5
|
const { position, richColors, closeButton, maxVisible, className, onAction, ...rest } = props;
|
|
5
|
-
const ref =
|
|
6
|
+
const [ref, setRef] = useForwardedRef(forwardedRef);
|
|
6
7
|
useEffect(() => {
|
|
7
8
|
ensureTooarkComponentsRegistered();
|
|
8
9
|
}, []);
|
|
@@ -13,11 +14,11 @@ export function ArkToaster(props) {
|
|
|
13
14
|
const handler = (event) => onAction(event);
|
|
14
15
|
el.addEventListener("ark-toast-action", handler);
|
|
15
16
|
return () => el.removeEventListener("ark-toast-action", handler);
|
|
16
|
-
}, [onAction]);
|
|
17
|
+
}, [ref, onAction]);
|
|
17
18
|
// O rest leva theme, duration, lang, testid e o que mais vier (data-*, aria-*) ao elemento.
|
|
18
19
|
const attrs = {
|
|
19
20
|
...rest,
|
|
20
|
-
ref,
|
|
21
|
+
ref: setRef,
|
|
21
22
|
position,
|
|
22
23
|
"max-visible": maxVisible,
|
|
23
24
|
class: className,
|
|
@@ -25,4 +26,4 @@ export function ArkToaster(props) {
|
|
|
25
26
|
"close-button": closeButton === undefined ? undefined : closeButton ? true : "false"
|
|
26
27
|
};
|
|
27
28
|
return createElement("ark-toaster", attrs);
|
|
28
|
-
}
|
|
29
|
+
});
|
package/dist/ark-toggle.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { ArkToggleGroupStyleOptions, ArkToggleStyleOptions } from "@tooark/core";
|
|
2
|
+
import type { ArkToggle as ArkToggleElement, ArkToggleGroup as ArkToggleGroupElement } from "@tooark/web-components";
|
|
2
3
|
import React, { type PropsWithChildren } from "react";
|
|
3
4
|
export type ArkToggleProps = PropsWithChildren<ArkToggleStyleOptions & {
|
|
4
5
|
disabled?: boolean;
|
|
@@ -8,7 +9,16 @@ export type ArkToggleProps = PropsWithChildren<ArkToggleStyleOptions & {
|
|
|
8
9
|
value: string;
|
|
9
10
|
}>) => void;
|
|
10
11
|
}>;
|
|
11
|
-
export declare
|
|
12
|
+
export declare const ArkToggle: React.ForwardRefExoticComponent<ArkToggleStyleOptions & {
|
|
13
|
+
disabled?: boolean;
|
|
14
|
+
className?: string;
|
|
15
|
+
onChange?: (event: CustomEvent<{
|
|
16
|
+
pressed: boolean;
|
|
17
|
+
value: string;
|
|
18
|
+
}>) => void;
|
|
19
|
+
} & {
|
|
20
|
+
children?: React.ReactNode | undefined;
|
|
21
|
+
} & React.RefAttributes<ArkToggleElement>>;
|
|
12
22
|
export type ArkToggleGroupProps = PropsWithChildren<ArkToggleGroupStyleOptions & {
|
|
13
23
|
disabled?: boolean;
|
|
14
24
|
className?: string;
|
|
@@ -17,4 +27,13 @@ export type ArkToggleGroupProps = PropsWithChildren<ArkToggleGroupStyleOptions &
|
|
|
17
27
|
values?: string[];
|
|
18
28
|
}>) => void;
|
|
19
29
|
}>;
|
|
20
|
-
export declare
|
|
30
|
+
export declare const ArkToggleGroup: React.ForwardRefExoticComponent<ArkToggleGroupStyleOptions & {
|
|
31
|
+
disabled?: boolean;
|
|
32
|
+
className?: string;
|
|
33
|
+
onChange?: (event: CustomEvent<{
|
|
34
|
+
value?: string;
|
|
35
|
+
values?: string[];
|
|
36
|
+
}>) => void;
|
|
37
|
+
} & {
|
|
38
|
+
children?: React.ReactNode | undefined;
|
|
39
|
+
} & React.RefAttributes<ArkToggleGroupElement>>;
|
package/dist/ark-toggle.js
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { createElement, forwardRef, useEffect } from "react";
|
|
2
2
|
import { ensureTooarkComponentsRegistered } from "./register.js";
|
|
3
|
-
|
|
3
|
+
import { useForwardedRef } from "./use-forwarded-ref.js";
|
|
4
|
+
export const ArkToggle = forwardRef(function ArkToggle(props, forwardedRef) {
|
|
4
5
|
const { children, className, pressed, disabled, onChange, ...rest } = props;
|
|
5
6
|
useEffect(() => {
|
|
6
7
|
ensureTooarkComponentsRegistered();
|
|
7
8
|
}, []);
|
|
8
|
-
const ref =
|
|
9
|
+
const [ref, setRef] = useForwardedRef(forwardedRef);
|
|
9
10
|
useEffect(() => {
|
|
10
11
|
const el = ref.current;
|
|
11
12
|
if (!el || !onChange)
|
|
@@ -13,22 +14,22 @@ export function ArkToggle(props) {
|
|
|
13
14
|
const handler = (event) => onChange(event);
|
|
14
15
|
el.addEventListener("change", handler);
|
|
15
16
|
return () => el.removeEventListener("change", handler);
|
|
16
|
-
}, [onChange]);
|
|
17
|
+
}, [ref, onChange]);
|
|
17
18
|
const attrs = {
|
|
18
19
|
...rest,
|
|
19
|
-
ref,
|
|
20
|
+
ref: setRef,
|
|
20
21
|
class: className,
|
|
21
22
|
pressed: pressed ? "" : undefined,
|
|
22
23
|
disabled: disabled ? "" : undefined
|
|
23
24
|
};
|
|
24
25
|
return createElement("ark-toggle", attrs, children);
|
|
25
|
-
}
|
|
26
|
-
export function ArkToggleGroup(props) {
|
|
26
|
+
});
|
|
27
|
+
export const ArkToggleGroup = forwardRef(function ArkToggleGroup(props, forwardedRef) {
|
|
27
28
|
const { children, className, multiple, disabled, onChange, ...rest } = props;
|
|
28
29
|
useEffect(() => {
|
|
29
30
|
ensureTooarkComponentsRegistered();
|
|
30
31
|
}, []);
|
|
31
|
-
const ref =
|
|
32
|
+
const [ref, setRef] = useForwardedRef(forwardedRef);
|
|
32
33
|
useEffect(() => {
|
|
33
34
|
const el = ref.current;
|
|
34
35
|
if (!el || !onChange)
|
|
@@ -36,13 +37,13 @@ export function ArkToggleGroup(props) {
|
|
|
36
37
|
const handler = (event) => onChange(event);
|
|
37
38
|
el.addEventListener("change", handler);
|
|
38
39
|
return () => el.removeEventListener("change", handler);
|
|
39
|
-
}, [onChange]);
|
|
40
|
+
}, [ref, onChange]);
|
|
40
41
|
const attrs = {
|
|
41
42
|
...rest,
|
|
42
|
-
ref,
|
|
43
|
+
ref: setRef,
|
|
43
44
|
class: className,
|
|
44
45
|
multiple: multiple ? "" : undefined,
|
|
45
46
|
disabled: disabled ? "" : undefined
|
|
46
47
|
};
|
|
47
48
|
return createElement("ark-toggle-group", attrs, children);
|
|
48
|
-
}
|
|
49
|
+
});
|
package/dist/ark-tooltip.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { ArkTooltipStyleOptions } from "@tooark/core";
|
|
2
|
+
import type { ArkTooltip as ArkTooltipElement } from "@tooark/web-components";
|
|
2
3
|
import React, { type PropsWithChildren } from "react";
|
|
3
4
|
export type ArkTooltipProps = PropsWithChildren<ArkTooltipStyleOptions & {
|
|
4
5
|
/** Texto do balao; para conteudo rico, passe um filho com slot="content". */
|
|
@@ -7,4 +8,12 @@ export type ArkTooltipProps = PropsWithChildren<ArkTooltipStyleOptions & {
|
|
|
7
8
|
open?: boolean;
|
|
8
9
|
className?: string;
|
|
9
10
|
}>;
|
|
10
|
-
export declare
|
|
11
|
+
export declare const ArkTooltip: React.ForwardRefExoticComponent<ArkTooltipStyleOptions & {
|
|
12
|
+
/** Texto do balao; para conteudo rico, passe um filho com slot="content". */
|
|
13
|
+
content?: string;
|
|
14
|
+
/** Aberto; refletido do estado do balao. */
|
|
15
|
+
open?: boolean;
|
|
16
|
+
className?: string;
|
|
17
|
+
} & {
|
|
18
|
+
children?: React.ReactNode | undefined;
|
|
19
|
+
} & React.RefAttributes<ArkTooltipElement>>;
|
package/dist/ark-tooltip.js
CHANGED
|
@@ -1,15 +1,16 @@
|
|
|
1
|
-
import { createElement, useEffect } from "react";
|
|
1
|
+
import { createElement, forwardRef, useEffect } from "react";
|
|
2
2
|
import { ensureTooarkComponentsRegistered } from "./register.js";
|
|
3
|
-
export function ArkTooltip(props) {
|
|
3
|
+
export const ArkTooltip = forwardRef(function ArkTooltip(props, forwardedRef) {
|
|
4
4
|
const { children, className, open, delay, ...rest } = props;
|
|
5
5
|
useEffect(() => {
|
|
6
6
|
ensureTooarkComponentsRegistered();
|
|
7
7
|
}, []);
|
|
8
8
|
const attrs = {
|
|
9
9
|
...rest,
|
|
10
|
+
ref: forwardedRef,
|
|
10
11
|
class: className,
|
|
11
12
|
open: open ? "" : undefined,
|
|
12
13
|
delay: delay === undefined ? undefined : String(delay)
|
|
13
14
|
};
|
|
14
15
|
return createElement("ark-tooltip", attrs, children);
|
|
15
|
-
}
|
|
16
|
+
});
|
package/dist/jsx-intrinsics.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ import type {
|
|
|
2
2
|
ArkAlertLive,
|
|
3
3
|
ArkAlertVariant,
|
|
4
4
|
ArkAvatarShape,
|
|
5
|
+
ArkAvatarVariant,
|
|
5
6
|
ArkBadgeSize,
|
|
6
7
|
ArkBadgeVariant,
|
|
7
8
|
ArkButtonStatus,
|
|
@@ -49,6 +50,7 @@ interface ArkIntrinsicElements {
|
|
|
49
50
|
size?: ArkSize;
|
|
50
51
|
shape?: ArkAvatarShape;
|
|
51
52
|
color?: string;
|
|
53
|
+
variant?: ArkAvatarVariant;
|
|
52
54
|
theme?: ArkTheme;
|
|
53
55
|
};
|
|
54
56
|
"ark-badge": React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement> & {
|
|
@@ -90,6 +92,7 @@ interface ArkIntrinsicElements {
|
|
|
90
92
|
name?: string;
|
|
91
93
|
value?: string;
|
|
92
94
|
label?: string;
|
|
95
|
+
helper?: string;
|
|
93
96
|
};
|
|
94
97
|
"ark-progress": React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement> & {
|
|
95
98
|
testid?: string;
|
|
@@ -112,6 +115,7 @@ interface ArkIntrinsicElements {
|
|
|
112
115
|
name?: string;
|
|
113
116
|
value?: string;
|
|
114
117
|
label?: string;
|
|
118
|
+
helper?: string;
|
|
115
119
|
};
|
|
116
120
|
"ark-spinner": React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement> & {
|
|
117
121
|
testid?: string;
|
|
@@ -212,6 +216,8 @@ interface ArkIntrinsicElements {
|
|
|
212
216
|
"no-scroll-lock"?: boolean;
|
|
213
217
|
"query-delay"?: number | string;
|
|
214
218
|
label?: string;
|
|
219
|
+
hint?: string;
|
|
220
|
+
busy?: boolean;
|
|
215
221
|
theme?: ArkTheme;
|
|
216
222
|
lang?: ArkLang;
|
|
217
223
|
"locale-json"?: string;
|
|
@@ -364,6 +370,8 @@ interface ArkIntrinsicElements {
|
|
|
364
370
|
"ark-shape-picker": React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement> & {
|
|
365
371
|
testid?: string;
|
|
366
372
|
value?: ArkMarkShape;
|
|
373
|
+
/** Formas oferecidas, separadas por vírgula, ou "all"; sem ele, as dez. */
|
|
374
|
+
shapes?: string;
|
|
367
375
|
color?: string;
|
|
368
376
|
label?: string;
|
|
369
377
|
disabled?: boolean;
|
|
@@ -537,12 +545,14 @@ interface ArkIntrinsicElements {
|
|
|
537
545
|
lang?: ArkLang;
|
|
538
546
|
};
|
|
539
547
|
"ark-chart": React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement> & {
|
|
548
|
+
testid?: string;
|
|
540
549
|
theme?: ArkTheme;
|
|
541
550
|
renderer?: "canvas" | "svg";
|
|
542
551
|
height?: string;
|
|
543
552
|
"auto-resize"?: boolean | "false";
|
|
544
553
|
};
|
|
545
554
|
"ark-wysiwyg-editor": React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement> & {
|
|
555
|
+
testid?: string;
|
|
546
556
|
theme?: ArkTheme;
|
|
547
557
|
placeholder?: string;
|
|
548
558
|
editable?: boolean | "false";
|
|
@@ -554,6 +564,7 @@ interface ArkIntrinsicElements {
|
|
|
554
564
|
"max-file-size"?: number;
|
|
555
565
|
};
|
|
556
566
|
"ark-wysiwyg-viewer": React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement> & {
|
|
567
|
+
testid?: string;
|
|
557
568
|
theme?: ArkTheme;
|
|
558
569
|
};
|
|
559
570
|
"ark-code-editor": React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement> & {
|
|
@@ -571,6 +582,9 @@ interface ArkIntrinsicElements {
|
|
|
571
582
|
"line-ending"?: "auto" | "lf" | "crlf";
|
|
572
583
|
"tab-indent"?: boolean | "false";
|
|
573
584
|
autocomplete?: boolean | "false";
|
|
585
|
+
"mark-unknown-variables"?: boolean;
|
|
586
|
+
"single-line"?: boolean;
|
|
587
|
+
size?: ArkSize;
|
|
574
588
|
};
|
|
575
589
|
}
|
|
576
590
|
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type React from "react";
|
|
2
|
+
/** Ref interna do wrapper e a callback ref que a preenche junto com a `ref` encaminhada pelo app. */
|
|
3
|
+
export declare function useForwardedRef<T extends HTMLElement>(forwarded: React.ForwardedRef<T>): [React.RefObject<T | null>, (node: T | null) => void];
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { useCallback, useRef } from "react";
|
|
2
|
+
// O wrapper precisa do elemento (liga eventos e grava propriedades) e o app também pode pedir o mesmo nó por `ref`.
|
|
3
|
+
// Uma callback ref só, que preenche as duas: a interna e a encaminhada. Callback ref do app que devolve limpeza
|
|
4
|
+
// (React 19) é respeitada como o React faria: ao desmontar roda a limpeza, e não uma chamada com null.
|
|
5
|
+
// A ref interna é o mesmo objeto em todo render (useRef): os efeitos dos wrappers a listam nas dependências só porque
|
|
6
|
+
// o Biome não sabe que este hook devolve algo estável, e ela nunca faz um efeito rodar de novo.
|
|
7
|
+
/** Ref interna do wrapper e a callback ref que a preenche junto com a `ref` encaminhada pelo app. */
|
|
8
|
+
export function useForwardedRef(forwarded) {
|
|
9
|
+
const local = useRef(null);
|
|
10
|
+
const cleanup = useRef(null);
|
|
11
|
+
const setRef = useCallback((node) => {
|
|
12
|
+
local.current = node;
|
|
13
|
+
if (typeof forwarded === "function") {
|
|
14
|
+
if (node) {
|
|
15
|
+
const result = forwarded(node);
|
|
16
|
+
cleanup.current = typeof result === "function" ? result : null;
|
|
17
|
+
}
|
|
18
|
+
else if (cleanup.current) {
|
|
19
|
+
cleanup.current();
|
|
20
|
+
cleanup.current = null;
|
|
21
|
+
}
|
|
22
|
+
else {
|
|
23
|
+
forwarded(null);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
else if (forwarded) {
|
|
27
|
+
forwarded.current = node;
|
|
28
|
+
}
|
|
29
|
+
}, [forwarded]);
|
|
30
|
+
return [local, setRef];
|
|
31
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tooark/react",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.4.0",
|
|
4
4
|
"description": "Tooark React — typed wrappers for ark-* components for React 18 and 19",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"tooark",
|
|
@@ -61,8 +61,8 @@
|
|
|
61
61
|
"react-dom": ">=18"
|
|
62
62
|
},
|
|
63
63
|
"dependencies": {
|
|
64
|
-
"@tooark/core": "^1.
|
|
65
|
-
"@tooark/web-components": "^1.
|
|
64
|
+
"@tooark/core": "^1.4.0",
|
|
65
|
+
"@tooark/web-components": "^1.4.0"
|
|
66
66
|
},
|
|
67
67
|
"scripts": {
|
|
68
68
|
"build": "tsc -p tsconfig.json && node postbuild.mjs",
|