@tooark/react 1.2.2 → 1.3.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.
Files changed (80) hide show
  1. package/README.md +21 -3
  2. package/README.pt-BR.md +21 -3
  3. package/dist/ark-alert.d.ts +12 -1
  4. package/dist/ark-alert.js +7 -6
  5. package/dist/ark-avatar.d.ts +8 -1
  6. package/dist/ark-avatar.js +4 -3
  7. package/dist/ark-badge.d.ts +6 -1
  8. package/dist/ark-badge.js +4 -3
  9. package/dist/ark-button.d.ts +7 -1
  10. package/dist/ark-button.js +4 -3
  11. package/dist/ark-calendar.d.ts +15 -2
  12. package/dist/ark-calendar.js +7 -6
  13. package/dist/ark-card.d.ts +8 -1
  14. package/dist/ark-card.js +4 -3
  15. package/dist/ark-carousel.d.ts +10 -1
  16. package/dist/ark-carousel.js +7 -6
  17. package/dist/ark-checkbox.d.ts +16 -1
  18. package/dist/ark-checkbox.js +7 -6
  19. package/dist/ark-clock.d.ts +10 -2
  20. package/dist/ark-clock.js +7 -6
  21. package/dist/ark-color-swatches.d.ts +15 -1
  22. package/dist/ark-color-swatches.js +7 -6
  23. package/dist/ark-command-palette.d.ts +40 -2
  24. package/dist/ark-command-palette.js +9 -7
  25. package/dist/ark-copy-button.d.ts +16 -1
  26. package/dist/ark-copy-button.js +7 -6
  27. package/dist/ark-datepicker.d.ts +13 -1
  28. package/dist/ark-datepicker.js +7 -6
  29. package/dist/ark-dialog.d.ts +22 -1
  30. package/dist/ark-dialog.js +6 -5
  31. package/dist/ark-drawer.d.ts +22 -1
  32. package/dist/ark-drawer.js +6 -5
  33. package/dist/ark-empty.d.ts +10 -1
  34. package/dist/ark-empty.js +4 -3
  35. package/dist/ark-file-input.d.ts +23 -1
  36. package/dist/ark-file-input.js +7 -6
  37. package/dist/ark-input.d.ts +34 -1
  38. package/dist/ark-input.js +7 -6
  39. package/dist/ark-kbd.d.ts +6 -1
  40. package/dist/ark-kbd.js +4 -3
  41. package/dist/ark-kv-editor.d.ts +39 -2
  42. package/dist/ark-kv-editor.js +16 -8
  43. package/dist/ark-mark.d.ts +6 -1
  44. package/dist/ark-mark.js +4 -3
  45. package/dist/ark-menu.d.ts +34 -2
  46. package/dist/ark-menu.js +9 -7
  47. package/dist/ark-progress.d.ts +14 -1
  48. package/dist/ark-progress.js +4 -3
  49. package/dist/ark-radio.d.ts +17 -1
  50. package/dist/ark-radio.js +7 -6
  51. package/dist/ark-scheduler.d.ts +25 -2
  52. package/dist/ark-scheduler.js +7 -6
  53. package/dist/ark-select.d.ts +20 -1
  54. package/dist/ark-select.js +7 -6
  55. package/dist/ark-shape-picker.d.ts +17 -1
  56. package/dist/ark-shape-picker.js +9 -7
  57. package/dist/ark-skeleton.d.ts +11 -1
  58. package/dist/ark-skeleton.js +4 -3
  59. package/dist/ark-spinner.d.ts +6 -1
  60. package/dist/ark-spinner.js +4 -3
  61. package/dist/ark-split-pane.d.ts +12 -1
  62. package/dist/ark-split-pane.js +7 -6
  63. package/dist/ark-status-dot.d.ts +6 -1
  64. package/dist/ark-status-dot.js +4 -3
  65. package/dist/ark-switch.d.ts +12 -2
  66. package/dist/ark-switch.js +7 -6
  67. package/dist/ark-tabs.d.ts +30 -2
  68. package/dist/ark-tabs.js +10 -8
  69. package/dist/ark-textarea.d.ts +34 -1
  70. package/dist/ark-textarea.js +7 -6
  71. package/dist/ark-toaster.d.ts +9 -1
  72. package/dist/ark-toaster.js +7 -6
  73. package/dist/ark-toggle.d.ts +21 -2
  74. package/dist/ark-toggle.js +12 -11
  75. package/dist/ark-tooltip.d.ts +10 -1
  76. package/dist/ark-tooltip.js +4 -3
  77. package/dist/jsx-intrinsics.d.ts +8 -0
  78. package/dist/use-forwarded-ref.d.ts +3 -0
  79. package/dist/use-forwarded-ref.js +31 -0
  80. package/package.json +3 -3
@@ -1,4 +1,5 @@
1
1
  import type { ArkMenuAlign, ArkMenuDirection, ArkMenuItemStyleOptions, ArkMenuStyleOptions } from "@tooark/core";
2
+ import type { ArkMenu as ArkMenuElement, ArkMenuItem as ArkMenuItemElement } from "@tooark/web-components";
2
3
  import React, { type PropsWithChildren } from "react";
3
4
  export type ArkMenuProps = PropsWithChildren<ArkMenuStyleOptions & {
4
5
  /** id do gatilho (vira o atributo for): o menu escreve aria-* nele e escuta clique e setas. */
@@ -18,7 +19,26 @@ export type ArkMenuProps = PropsWithChildren<ArkMenuStyleOptions & {
18
19
  onOpen?: (event: CustomEvent) => void;
19
20
  onClose?: (event: CustomEvent) => void;
20
21
  }>;
21
- export declare function ArkMenu(props: ArkMenuProps): React.JSX.Element;
22
+ export declare const ArkMenu: React.ForwardRefExoticComponent<ArkMenuStyleOptions & {
23
+ /** id do gatilho (vira o atributo for): o menu escreve aria-* nele e escuta clique e setas. */
24
+ htmlFor?: string;
25
+ /** Aberto; refletido do estado do popover. */
26
+ open?: boolean;
27
+ /** Alinhamento em relacao ao gatilho. Padrao: "start". */
28
+ align?: ArkMenuAlign;
29
+ /** Lado do gatilho; vira quando nao cabe. Padrao: "down". */
30
+ direction?: ArkMenuDirection;
31
+ "aria-label"?: string;
32
+ className?: string;
33
+ /** Um item foi escolhido; o menu fecha em seguida. */
34
+ onSelect?: (event: CustomEvent<{
35
+ value: string;
36
+ }>) => void;
37
+ onOpen?: (event: CustomEvent) => void;
38
+ onClose?: (event: CustomEvent) => void;
39
+ } & {
40
+ children?: React.ReactNode | undefined;
41
+ } & React.RefAttributes<ArkMenuElement>>;
22
42
  export type ArkMenuItemProps = PropsWithChildren<ArkMenuItemStyleOptions & {
23
43
  value?: string;
24
44
  disabled?: boolean;
@@ -30,4 +50,16 @@ export type ArkMenuItemProps = PropsWithChildren<ArkMenuItemStyleOptions & {
30
50
  static?: boolean;
31
51
  className?: string;
32
52
  }>;
33
- export declare function ArkMenuItem(props: ArkMenuItemProps): React.JSX.Element;
53
+ export declare const ArkMenuItem: React.ForwardRefExoticComponent<ArkMenuItemStyleOptions & {
54
+ value?: string;
55
+ disabled?: boolean;
56
+ /** Item checkbox: true marcado, false desmarcado; omitido e um item comum. */
57
+ checked?: boolean;
58
+ /** Linha separadora (role separator). */
59
+ divider?: boolean;
60
+ /** Conteudo nao interativo (nome e e-mail), sem role de item. */
61
+ static?: boolean;
62
+ className?: string;
63
+ } & {
64
+ children?: React.ReactNode | undefined;
65
+ } & React.RefAttributes<ArkMenuItemElement>>;
package/dist/ark-menu.js CHANGED
@@ -1,9 +1,10 @@
1
- import React, { createElement, useEffect } from "react";
1
+ import { createElement, forwardRef, useEffect } from "react";
2
2
  import { ensureTooarkComponentsRegistered } from "./register.js";
3
+ import { useForwardedRef } from "./use-forwarded-ref.js";
3
4
  import { useIsomorphicLayoutEffect } from "./use-isomorphic-layout-effect.js";
4
- export function ArkMenu(props) {
5
+ export const ArkMenu = forwardRef(function ArkMenu(props, forwardedRef) {
5
6
  const { children, className, htmlFor, open, onSelect, onOpen, onClose, ...rest } = props;
6
- const ref = React.useRef(null);
7
+ const [ref, setRef] = useForwardedRef(forwardedRef);
7
8
  useEffect(() => {
8
9
  ensureTooarkComponentsRegistered();
9
10
  }, []);
@@ -25,20 +26,21 @@ export function ArkMenu(props) {
25
26
  }, [onSelect, onOpen, onClose]);
26
27
  const attrs = {
27
28
  ...rest,
28
- ref,
29
+ ref: setRef,
29
30
  class: className,
30
31
  for: htmlFor,
31
32
  open: open ? "" : undefined
32
33
  };
33
34
  return createElement("ark-menu", attrs, children);
34
- }
35
- export function ArkMenuItem(props) {
35
+ });
36
+ export const ArkMenuItem = forwardRef(function ArkMenuItem(props, forwardedRef) {
36
37
  const { children, className, disabled, checked, divider, static: isStatic, ...rest } = props;
37
38
  useEffect(() => {
38
39
  ensureTooarkComponentsRegistered();
39
40
  }, []);
40
41
  const attrs = {
41
42
  ...rest,
43
+ ref: forwardedRef,
42
44
  class: className,
43
45
  disabled: disabled ? "" : undefined,
44
46
  checked: checked === undefined ? undefined : checked ? "" : "false",
@@ -46,4 +48,4 @@ export function ArkMenuItem(props) {
46
48
  static: isStatic ? "" : undefined
47
49
  };
48
50
  return createElement("ark-menu-item", attrs, children);
49
- }
51
+ });
@@ -1,4 +1,5 @@
1
1
  import type { ArkProgressStyleOptions } from "@tooark/core";
2
+ import type { ArkProgress as ArkProgressElement } from "@tooark/web-components";
2
3
  import type React from "react";
3
4
  export type ArkProgressProps = ArkProgressStyleOptions & {
4
5
  /** Valor atual, de 0 a max. Padrao: 0. */
@@ -13,4 +14,16 @@ export type ArkProgressProps = ArkProgressStyleOptions & {
13
14
  showValue?: boolean;
14
15
  className?: string;
15
16
  };
16
- export declare function ArkProgress(props: ArkProgressProps): React.JSX.Element;
17
+ export declare const ArkProgress: React.ForwardRefExoticComponent<ArkProgressStyleOptions & {
18
+ /** Valor atual, de 0 a max. Padrao: 0. */
19
+ value?: number;
20
+ /** Valor maximo. Padrao: 100. */
21
+ max?: number;
22
+ /** Segmento em loop no lugar do valor (loader continuo, isento de movimento reduzido). */
23
+ indeterminate?: boolean;
24
+ /** Nome acessivel (aria-label). */
25
+ label?: string;
26
+ /** Mostra a porcentagem ao lado do trilho. */
27
+ showValue?: boolean;
28
+ className?: string;
29
+ } & React.RefAttributes<ArkProgressElement>>;
@@ -1,12 +1,13 @@
1
- import { createElement, useEffect } from "react";
1
+ import { createElement, forwardRef, useEffect } from "react";
2
2
  import { ensureTooarkComponentsRegistered } from "./register.js";
3
- export function ArkProgress(props) {
3
+ export const ArkProgress = forwardRef(function ArkProgress(props, forwardedRef) {
4
4
  const { className, value, max, indeterminate, showValue, ...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
  value: value === undefined ? undefined : String(value),
12
13
  max: max === undefined ? undefined : String(max),
@@ -14,4 +15,4 @@ export function ArkProgress(props) {
14
15
  "show-value": showValue ? "" : undefined
15
16
  };
16
17
  return createElement("ark-progress", attrs);
17
- }
18
+ });
@@ -1,4 +1,5 @@
1
1
  import type { ArkRadioStyleOptions } from "@tooark/core";
2
+ import type { ArkRadio as ArkRadioElement } from "@tooark/web-components";
2
3
  import React, { type PropsWithChildren } from "react";
3
4
  export type ArkRadioProps = PropsWithChildren<ArkRadioStyleOptions & {
4
5
  disabled?: boolean;
@@ -14,4 +15,19 @@ export type ArkRadioProps = PropsWithChildren<ArkRadioStyleOptions & {
14
15
  value: string;
15
16
  }>) => void;
16
17
  }>;
17
- export declare function ArkRadio(props: ArkRadioProps): React.JSX.Element;
18
+ export declare const ArkRadio: React.ForwardRefExoticComponent<ArkRadioStyleOptions & {
19
+ disabled?: boolean;
20
+ /** Nome do grupo: agrupa no formulario e para setas/roving tabindex. */
21
+ name?: string;
22
+ /** Valor submetido e publicado em `change` quando marcado. Padrao: "on". */
23
+ value?: string;
24
+ /** Rotulo proprio (<label for>); sem ele use aria-label ou filhos como rotulo livre. */
25
+ label?: string;
26
+ className?: string;
27
+ /** Dispara so no radio que ganhou a marca. */
28
+ onChange?: (event: CustomEvent<{
29
+ value: string;
30
+ }>) => void;
31
+ } & {
32
+ children?: React.ReactNode | undefined;
33
+ } & React.RefAttributes<ArkRadioElement>>;
package/dist/ark-radio.js CHANGED
@@ -1,8 +1,9 @@
1
- import React, { createElement, useEffect } from "react";
1
+ import { createElement, forwardRef, useEffect } from "react";
2
2
  import { ensureTooarkComponentsRegistered } from "./register.js";
3
- export function ArkRadio(props) {
3
+ import { useForwardedRef } from "./use-forwarded-ref.js";
4
+ export const ArkRadio = forwardRef(function ArkRadio(props, forwardedRef) {
4
5
  const { children, className, checked, disabled, onChange, ...rest } = props;
5
- const ref = React.useRef(null);
6
+ const [ref, setRef] = useForwardedRef(forwardedRef);
6
7
  useEffect(() => {
7
8
  ensureTooarkComponentsRegistered();
8
9
  }, []);
@@ -13,13 +14,13 @@ export function ArkRadio(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
23
24
  };
24
25
  return createElement("ark-radio", attrs, children);
25
- }
26
+ });
@@ -1,5 +1,6 @@
1
1
  import type { ArkDatepickerLang, ArkSchedulerEvent, ArkSchedulerStyleOptions } from "@tooark/core";
2
- import React from "react";
2
+ import type { ArkScheduler as ArkSchedulerElement } from "@tooark/web-components";
3
+ import type React from "react";
3
4
  export type ArkSchedulerProps = ArkSchedulerStyleOptions & {
4
5
  lang?: ArkDatepickerLang;
5
6
  /** JSON com strings próprias, mesclado sobre o inglês, quando lang é "custom". */
@@ -23,4 +24,26 @@ export type ArkSchedulerProps = ArkSchedulerStyleOptions & {
23
24
  view: string;
24
25
  }) => void;
25
26
  };
26
- export declare function ArkScheduler(props: ArkSchedulerProps): React.JSX.Element;
27
+ export declare const ArkScheduler: React.ForwardRefExoticComponent<ArkSchedulerStyleOptions & {
28
+ lang?: ArkDatepickerLang;
29
+ /** JSON com strings próprias, mesclado sobre o inglês, quando lang é "custom". */
30
+ localeJson?: string;
31
+ className?: string;
32
+ onEventClick?: (detail: {
33
+ event: ArkSchedulerEvent;
34
+ id: string | null;
35
+ }) => void;
36
+ onSlotClick?: (detail: {
37
+ start: string;
38
+ end: string;
39
+ allDay: boolean;
40
+ }) => void;
41
+ onViewChange?: (detail: {
42
+ view: string;
43
+ }) => void;
44
+ onRangeChange?: (detail: {
45
+ start: string;
46
+ end: string;
47
+ view: string;
48
+ }) => void;
49
+ } & React.RefAttributes<ArkSchedulerElement>>;
@@ -1,8 +1,9 @@
1
- import React, { createElement, useEffect } from "react";
1
+ import { createElement, forwardRef, useEffect } from "react";
2
2
  import { ensureTooarkComponentsRegistered } from "./register.js";
3
- export function ArkScheduler(props) {
3
+ import { useForwardedRef } from "./use-forwarded-ref.js";
4
+ export const ArkScheduler = forwardRef(function ArkScheduler(props, forwardedRef) {
4
5
  const { className, events, hourStart, hourEnd, slotMinutes, hoursFormat, localeJson, onEventClick, onSlotClick, onViewChange, onRangeChange, ...rest } = props;
5
- const ref = React.useRef(null);
6
+ const [ref, setRef] = useForwardedRef(forwardedRef);
6
7
  useEffect(() => {
7
8
  ensureTooarkComponentsRegistered();
8
9
  }, []);
@@ -27,10 +28,10 @@ export function ArkScheduler(props) {
27
28
  el.removeEventListener(name, listener);
28
29
  }
29
30
  };
30
- }, [onEventClick, onSlotClick, onViewChange, onRangeChange]);
31
+ }, [ref, onEventClick, onSlotClick, onViewChange, onRangeChange]);
31
32
  const attrs = {
32
33
  ...rest,
33
- ref,
34
+ ref: setRef,
34
35
  class: className,
35
36
  events: events ? JSON.stringify(events) : undefined,
36
37
  "hour-start": hourStart !== undefined ? String(hourStart) : undefined,
@@ -40,4 +41,4 @@ export function ArkScheduler(props) {
40
41
  "locale-json": localeJson
41
42
  };
42
43
  return createElement("ark-scheduler", attrs);
43
- }
44
+ });
@@ -1,4 +1,5 @@
1
1
  import type { ArkSelectOption, ArkSelectStyleOptions } from "@tooark/core";
2
+ import type { ArkSelect as ArkSelectElement } from "@tooark/web-components";
2
3
  import React, { type PropsWithChildren } from "react";
3
4
  export type ArkSelectProps = PropsWithChildren<ArkSelectStyleOptions & {
4
5
  label?: string;
@@ -17,4 +18,22 @@ export type ArkSelectProps = PropsWithChildren<ArkSelectStyleOptions & {
17
18
  value: string;
18
19
  }>) => void;
19
20
  }>;
20
- export declare function ArkSelect(props: ArkSelectProps): React.JSX.Element;
21
+ export declare const ArkSelect: React.ForwardRefExoticComponent<ArkSelectStyleOptions & {
22
+ label?: string;
23
+ placeholder?: string;
24
+ options?: ArkSelectOption[];
25
+ value?: string;
26
+ name?: string;
27
+ helper?: string;
28
+ error?: boolean;
29
+ errorMessage?: string;
30
+ disabled?: boolean;
31
+ required?: boolean;
32
+ className?: string;
33
+ onInput?: (event: Event) => void;
34
+ onChange?: (event: CustomEvent<{
35
+ value: string;
36
+ }>) => void;
37
+ } & {
38
+ children?: React.ReactNode | undefined;
39
+ } & React.RefAttributes<ArkSelectElement>>;
@@ -1,8 +1,9 @@
1
- import React, { createElement, useEffect } from "react";
1
+ import { createElement, forwardRef, useEffect } from "react";
2
2
  import { ensureTooarkComponentsRegistered } from "./register.js";
3
- export function ArkSelect(props) {
3
+ import { useForwardedRef } from "./use-forwarded-ref.js";
4
+ export const ArkSelect = forwardRef(function ArkSelect(props, forwardedRef) {
4
5
  const { children, className, options, errorMessage, error, disabled, required, onInput, onChange, ...rest } = props;
5
- const ref = React.useRef(null);
6
+ const [ref, setRef] = useForwardedRef(forwardedRef);
6
7
  useEffect(() => {
7
8
  ensureTooarkComponentsRegistered();
8
9
  }, []);
@@ -18,10 +19,10 @@ export function ArkSelect(props) {
18
19
  el.removeEventListener("input", handleInput);
19
20
  el.removeEventListener("change", handleChange);
20
21
  };
21
- }, [onInput, onChange]);
22
+ }, [ref, onInput, onChange]);
22
23
  const attrs = {
23
24
  ...rest,
24
- ref,
25
+ ref: setRef,
25
26
  class: className,
26
27
  options: options ? JSON.stringify(options) : undefined,
27
28
  "error-message": errorMessage,
@@ -30,4 +31,4 @@ export function ArkSelect(props) {
30
31
  required: required ? "" : undefined
31
32
  };
32
33
  return createElement("ark-select", attrs, children);
33
- }
34
+ });
@@ -1,8 +1,11 @@
1
1
  import type { ArkMarkShape, ArkShapePickerStyleOptions } from "@tooark/core";
2
+ import type { ArkShapePicker as ArkShapePickerElement } from "@tooark/web-components";
2
3
  import type React from "react";
3
4
  export type ArkShapePickerProps = ArkShapePickerStyleOptions & {
4
5
  /** Forma selecionada. */
5
6
  value?: ArkMarkShape;
7
+ /** Formas oferecidas, na ordem (ou "all"). Padrao: as dez. */
8
+ shapes?: ArkMarkShape[] | "all";
6
9
  /** Nome acessivel do radiogroup. */
7
10
  label?: string;
8
11
  disabled?: boolean;
@@ -12,4 +15,17 @@ export type ArkShapePickerProps = ArkShapePickerStyleOptions & {
12
15
  value: ArkMarkShape;
13
16
  }>) => void;
14
17
  };
15
- export declare function ArkShapePicker(props: ArkShapePickerProps): React.JSX.Element;
18
+ export declare const ArkShapePicker: React.ForwardRefExoticComponent<ArkShapePickerStyleOptions & {
19
+ /** Forma selecionada. */
20
+ value?: ArkMarkShape;
21
+ /** Formas oferecidas, na ordem (ou "all"). Padrao: as dez. */
22
+ shapes?: ArkMarkShape[] | "all";
23
+ /** Nome acessivel do radiogroup. */
24
+ label?: string;
25
+ disabled?: boolean;
26
+ className?: string;
27
+ /** Selecao mudou pelo usuario: detail.value e a forma. */
28
+ onChange?: (event: CustomEvent<{
29
+ value: ArkMarkShape;
30
+ }>) => void;
31
+ } & React.RefAttributes<ArkShapePickerElement>>;
@@ -1,8 +1,9 @@
1
- import { createElement, useEffect, useRef } from "react";
1
+ import { createElement, forwardRef, useEffect } from "react";
2
2
  import { ensureTooarkComponentsRegistered } from "./register.js";
3
- export function ArkShapePicker(props) {
4
- const { className, disabled, localeJson, onChange, ...rest } = props;
5
- const ref = useRef(null);
3
+ import { useForwardedRef } from "./use-forwarded-ref.js";
4
+ export const ArkShapePicker = forwardRef(function ArkShapePicker(props, forwardedRef) {
5
+ const { className, disabled, shapes, localeJson, onChange, ...rest } = props;
6
+ const [ref, setRef] = useForwardedRef(forwardedRef);
6
7
  useEffect(() => {
7
8
  ensureTooarkComponentsRegistered();
8
9
  }, []);
@@ -13,13 +14,14 @@ export function ArkShapePicker(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
  disabled: disabled ? "" : undefined,
23
+ shapes: Array.isArray(shapes) ? (shapes.length > 0 ? shapes.join(",") : undefined) : shapes,
22
24
  "locale-json": localeJson
23
25
  };
24
26
  return createElement("ark-shape-picker", attrs);
25
- }
27
+ });
@@ -1,4 +1,5 @@
1
1
  import type { ArkSkeletonStyleOptions } from "@tooark/core";
2
+ import type { ArkSkeleton as ArkSkeletonElement } from "@tooark/web-components";
2
3
  import React, { type PropsWithChildren } from "react";
3
4
  export type ArkSkeletonProps = PropsWithChildren<ArkSkeletonStyleOptions & {
4
5
  /** Numero de barras; acima de 1 troca o bloco por barras em coluna. Padrao: 1. */
@@ -8,4 +9,13 @@ export type ArkSkeletonProps = PropsWithChildren<ArkSkeletonStyleOptions & {
8
9
  className?: string;
9
10
  style?: React.CSSProperties;
10
11
  }>;
11
- export declare function ArkSkeleton(props: ArkSkeletonProps): React.JSX.Element;
12
+ export declare const ArkSkeleton: React.ForwardRefExoticComponent<ArkSkeletonStyleOptions & {
13
+ /** Numero de barras; acima de 1 troca o bloco por barras em coluna. Padrao: 1. */
14
+ rows?: number;
15
+ /** Liga o brilho que varre (opt-in; para sob movimento reduzido). */
16
+ animated?: boolean;
17
+ className?: string;
18
+ style?: React.CSSProperties;
19
+ } & {
20
+ children?: React.ReactNode | undefined;
21
+ } & React.RefAttributes<ArkSkeletonElement>>;
@@ -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 ArkSkeleton(props) {
3
+ export const ArkSkeleton = forwardRef(function ArkSkeleton(props, forwardedRef) {
4
4
  const { children, className, rows, animated, ...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
  rows: rows === undefined ? undefined : String(rows),
12
13
  animated: animated ? "" : undefined
13
14
  };
14
15
  return createElement("ark-skeleton", attrs, children);
15
- }
16
+ });
@@ -1,8 +1,13 @@
1
1
  import type { ArkSpinnerStyleOptions } from "@tooark/core";
2
+ import type { ArkSpinner as ArkSpinnerElement } from "@tooark/web-components";
2
3
  import type React from "react";
3
4
  export type ArkSpinnerProps = ArkSpinnerStyleOptions & {
4
5
  /** Rotulo so para leitores de tela. Padrao: a string `loading` do idioma. */
5
6
  label?: string;
6
7
  className?: string;
7
8
  };
8
- export declare function ArkSpinner(props: ArkSpinnerProps): React.JSX.Element;
9
+ export declare const ArkSpinner: React.ForwardRefExoticComponent<ArkSpinnerStyleOptions & {
10
+ /** Rotulo so para leitores de tela. Padrao: a string `loading` do idioma. */
11
+ label?: string;
12
+ className?: string;
13
+ } & React.RefAttributes<ArkSpinnerElement>>;
@@ -1,14 +1,15 @@
1
- import { createElement, useEffect } from "react";
1
+ import { createElement, forwardRef, useEffect } from "react";
2
2
  import { ensureTooarkComponentsRegistered } from "./register.js";
3
- export function ArkSpinner(props) {
3
+ export const ArkSpinner = forwardRef(function ArkSpinner(props, forwardedRef) {
4
4
  const { className, localeJson, ...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
  "locale-json": localeJson
12
13
  };
13
14
  return createElement("ark-spinner", attrs);
14
- }
15
+ });
@@ -1,4 +1,5 @@
1
1
  import type { ArkSplitPaneStyleOptions } from "@tooark/core";
2
+ import type { ArkSplitPane as ArkSplitPaneElement } from "@tooark/web-components";
2
3
  import type React from "react";
3
4
  import { type PropsWithChildren } from "react";
4
5
  export type ArkSplitPaneProps = PropsWithChildren<ArkSplitPaneStyleOptions & {
@@ -10,4 +11,14 @@ export type ArkSplitPaneProps = PropsWithChildren<ArkSplitPaneStyleOptions & {
10
11
  sizes: number[];
11
12
  }>) => void;
12
13
  }>;
13
- export declare function ArkSplitPane(props: ArkSplitPaneProps): React.JSX.Element;
14
+ export declare const ArkSplitPane: React.ForwardRefExoticComponent<ArkSplitPaneStyleOptions & {
15
+ /** Tamanhos dos paineis em percentuais, na ordem dos filhos (ex.: [30, 70]); faltantes sao distribuidos. */
16
+ sizes?: number[];
17
+ className?: string;
18
+ /** Tamanhos mudaram por arrasto ou teclado: detail.sizes e a lista normalizada. Persistir e do app. */
19
+ onResize?: (event: CustomEvent<{
20
+ sizes: number[];
21
+ }>) => void;
22
+ } & {
23
+ children?: React.ReactNode | undefined;
24
+ } & React.RefAttributes<ArkSplitPaneElement>>;
@@ -1,8 +1,9 @@
1
- import { createElement, useEffect, useRef } from "react";
1
+ import { createElement, forwardRef, useEffect } from "react";
2
2
  import { ensureTooarkComponentsRegistered } from "./register.js";
3
- export function ArkSplitPane(props) {
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 = useRef(null);
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
+ });
@@ -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 function ArkStatusDot(props: ArkStatusDotProps): React.JSX.Element;
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>>;
@@ -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
+ });
@@ -1,5 +1,6 @@
1
1
  import type { ArkSwitchStyleOptions } from "@tooark/core";
2
- import React from "react";
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 function ArkSwitch(props: ArkSwitchProps): React.JSX.Element;
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>>;
@@ -1,11 +1,12 @@
1
- import React, { createElement, useEffect } from "react";
1
+ import { createElement, forwardRef, useEffect } from "react";
2
2
  import { ensureTooarkComponentsRegistered } from "./register.js";
3
- export function ArkSwitch(props) {
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 = React.useRef(null);
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
+ });