@tooark/react 1.0.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/LICENSE +201 -0
- package/NOTICE +12 -0
- package/README.md +163 -0
- package/README.pt-BR.md +163 -0
- package/dist/ark-alert.d.ts +12 -0
- package/dist/ark-alert.js +25 -0
- package/dist/ark-avatar.d.ts +10 -0
- package/dist/ark-avatar.js +13 -0
- package/dist/ark-badge.d.ts +6 -0
- package/dist/ark-badge.js +13 -0
- package/dist/ark-button.d.ts +9 -0
- package/dist/ark-button.js +19 -0
- package/dist/ark-calendar.d.ts +16 -0
- package/dist/ark-calendar.js +36 -0
- package/dist/ark-card.d.ts +8 -0
- package/dist/ark-card.js +13 -0
- package/dist/ark-carousel.d.ts +10 -0
- package/dist/ark-carousel.js +39 -0
- package/dist/ark-checkbox.d.ts +16 -0
- package/dist/ark-checkbox.js +26 -0
- package/dist/ark-clock.d.ts +11 -0
- package/dist/ark-clock.js +26 -0
- package/dist/ark-color-swatches.d.ts +17 -0
- package/dist/ark-color-swatches.js +25 -0
- package/dist/ark-command-palette.d.ts +40 -0
- package/dist/ark-command-palette.js +51 -0
- package/dist/ark-copy-button.d.ts +17 -0
- package/dist/ark-copy-button.js +31 -0
- package/dist/ark-datepicker.d.ts +15 -0
- package/dist/ark-datepicker.js +46 -0
- package/dist/ark-dialog.d.ts +22 -0
- package/dist/ark-dialog.js +36 -0
- package/dist/ark-drawer.d.ts +23 -0
- package/dist/ark-drawer.js +35 -0
- package/dist/ark-empty.d.ts +10 -0
- package/dist/ark-empty.js +13 -0
- package/dist/ark-file-input.d.ts +23 -0
- package/dist/ark-file-input.js +28 -0
- package/dist/ark-input.d.ts +34 -0
- package/dist/ark-input.js +46 -0
- package/dist/ark-kbd.d.ts +7 -0
- package/dist/ark-kbd.js +13 -0
- package/dist/ark-kv-editor.d.ts +30 -0
- package/dist/ark-kv-editor.js +46 -0
- package/dist/ark-mark.d.ts +8 -0
- package/dist/ark-mark.js +14 -0
- package/dist/ark-menu.d.ts +33 -0
- package/dist/ark-menu.js +48 -0
- package/dist/ark-progress.d.ts +16 -0
- package/dist/ark-progress.js +17 -0
- package/dist/ark-radio.d.ts +17 -0
- package/dist/ark-radio.js +25 -0
- package/dist/ark-scheduler.d.ts +24 -0
- package/dist/ark-scheduler.js +42 -0
- package/dist/ark-select.d.ts +20 -0
- package/dist/ark-select.js +33 -0
- package/dist/ark-shape-picker.d.ts +15 -0
- package/dist/ark-shape-picker.js +25 -0
- package/dist/ark-skeleton.d.ts +11 -0
- package/dist/ark-skeleton.js +15 -0
- package/dist/ark-spinner.d.ts +8 -0
- package/dist/ark-spinner.js +14 -0
- package/dist/ark-split-pane.d.ts +13 -0
- package/dist/ark-split-pane.js +25 -0
- package/dist/ark-status-dot.d.ts +8 -0
- package/dist/ark-status-dot.js +13 -0
- package/dist/ark-switch.d.ts +13 -0
- package/dist/ark-switch.js +29 -0
- package/dist/ark-tabs.d.ts +29 -0
- package/dist/ark-tabs.js +43 -0
- package/dist/ark-textarea.d.ts +32 -0
- package/dist/ark-textarea.js +44 -0
- package/dist/ark-toaster.d.ts +6 -0
- package/dist/ark-toaster.js +19 -0
- package/dist/ark-toggle.d.ts +20 -0
- package/dist/ark-toggle.js +48 -0
- package/dist/ark-tooltip.d.ts +10 -0
- package/dist/ark-tooltip.js +15 -0
- package/dist/index.d.ts +76 -0
- package/dist/index.js +38 -0
- package/dist/jsx-intrinsics.d.ts +538 -0
- package/dist/register.d.ts +1 -0
- package/dist/register.js +8 -0
- package/package.json +71 -0
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { ArkCalendarEvent, ArkCalendarStyleOptions, ArkDatepickerLang, ArkLocale } from "@tooark/core";
|
|
2
|
+
import React from "react";
|
|
3
|
+
export type ArkCalendarProps = ArkCalendarStyleOptions & {
|
|
4
|
+
lang?: ArkDatepickerLang;
|
|
5
|
+
localeJson?: Partial<ArkLocale>;
|
|
6
|
+
value?: string;
|
|
7
|
+
min?: string;
|
|
8
|
+
max?: string;
|
|
9
|
+
onChange?: (detail: {
|
|
10
|
+
value: string | null;
|
|
11
|
+
date: Date | null;
|
|
12
|
+
events: ArkCalendarEvent[];
|
|
13
|
+
}) => void;
|
|
14
|
+
className?: string;
|
|
15
|
+
};
|
|
16
|
+
export declare function ArkCalendar(props: ArkCalendarProps): React.JSX.Element;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import React, { createElement, useCallback, useEffect } from "react";
|
|
2
|
+
import { ensureTooarkComponentsRegistered } from "./register.js";
|
|
3
|
+
export function ArkCalendar(props) {
|
|
4
|
+
const { lang, localeJson, theme, intent, accentColor, value, min, max, onChange, className, testid, events, eventDisplay } = props;
|
|
5
|
+
const ref = React.useRef(null);
|
|
6
|
+
useEffect(() => {
|
|
7
|
+
ensureTooarkComponentsRegistered();
|
|
8
|
+
}, []);
|
|
9
|
+
const handleChange = useCallback((e) => {
|
|
10
|
+
if (onChange) {
|
|
11
|
+
onChange(e.detail);
|
|
12
|
+
}
|
|
13
|
+
}, [onChange]);
|
|
14
|
+
useEffect(() => {
|
|
15
|
+
const el = ref.current;
|
|
16
|
+
if (!el)
|
|
17
|
+
return;
|
|
18
|
+
el.addEventListener("ark-change", handleChange);
|
|
19
|
+
return () => el.removeEventListener("ark-change", handleChange);
|
|
20
|
+
}, [handleChange]);
|
|
21
|
+
const attrs = {
|
|
22
|
+
lang,
|
|
23
|
+
theme,
|
|
24
|
+
intent,
|
|
25
|
+
value,
|
|
26
|
+
min,
|
|
27
|
+
max,
|
|
28
|
+
testid,
|
|
29
|
+
class: className,
|
|
30
|
+
"accent-color": accentColor,
|
|
31
|
+
"locale-json": localeJson ? JSON.stringify(localeJson) : undefined,
|
|
32
|
+
events: events ? JSON.stringify(events) : undefined,
|
|
33
|
+
"event-display": eventDisplay
|
|
34
|
+
};
|
|
35
|
+
return createElement("ark-calendar", { ...attrs, ref });
|
|
36
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { ArkCardStyleOptions } from "@tooark/core";
|
|
2
|
+
import React, { type PropsWithChildren } from "react";
|
|
3
|
+
export type ArkCardProps = PropsWithChildren<ArkCardStyleOptions & {
|
|
4
|
+
/** Titulo (h2) na linha de cima; com ele o filho slot="header" vira a linha seguinte do cabecalho. */
|
|
5
|
+
heading?: string;
|
|
6
|
+
className?: string;
|
|
7
|
+
}>;
|
|
8
|
+
export declare function ArkCard(props: ArkCardProps): React.JSX.Element;
|
package/dist/ark-card.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { createElement, useEffect } from "react";
|
|
2
|
+
import { ensureTooarkComponentsRegistered } from "./register.js";
|
|
3
|
+
export function ArkCard(props) {
|
|
4
|
+
const { children, className, ...rest } = props;
|
|
5
|
+
useEffect(() => {
|
|
6
|
+
ensureTooarkComponentsRegistered();
|
|
7
|
+
}, []);
|
|
8
|
+
const attrs = {
|
|
9
|
+
...rest,
|
|
10
|
+
class: className
|
|
11
|
+
};
|
|
12
|
+
return createElement("ark-card", attrs, children);
|
|
13
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { ArkCarouselSnap, ArkCarouselStyleOptions } from "@tooark/core";
|
|
2
|
+
import React, { type PropsWithChildren } from "react";
|
|
3
|
+
export type ArkCarouselProps = PropsWithChildren<ArkCarouselStyleOptions & {
|
|
4
|
+
snap?: ArkCarouselSnap;
|
|
5
|
+
onSlideChange?: (detail: {
|
|
6
|
+
index: number;
|
|
7
|
+
}) => void;
|
|
8
|
+
className?: string;
|
|
9
|
+
}>;
|
|
10
|
+
export declare function ArkCarousel(props: ArkCarouselProps): React.JSX.Element;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import React, { createElement, useCallback, useEffect } from "react";
|
|
2
|
+
import { ensureTooarkComponentsRegistered } from "./register.js";
|
|
3
|
+
export function ArkCarousel(props) {
|
|
4
|
+
const { children, theme, intent, accentColor, slidesPerView, gap, startIndex, loop, autoplay, autoplayDelay, showDots, showArrows, dragFree, snap, onSlideChange, className, testid } = props;
|
|
5
|
+
const ref = React.useRef(null);
|
|
6
|
+
useEffect(() => {
|
|
7
|
+
ensureTooarkComponentsRegistered();
|
|
8
|
+
}, []);
|
|
9
|
+
const handleSlideChange = useCallback((event) => {
|
|
10
|
+
if (onSlideChange) {
|
|
11
|
+
onSlideChange(event.detail);
|
|
12
|
+
}
|
|
13
|
+
}, [onSlideChange]);
|
|
14
|
+
useEffect(() => {
|
|
15
|
+
const el = ref.current;
|
|
16
|
+
if (!el)
|
|
17
|
+
return;
|
|
18
|
+
el.addEventListener("ark-slide-change", handleSlideChange);
|
|
19
|
+
return () => el.removeEventListener("ark-slide-change", handleSlideChange);
|
|
20
|
+
}, [handleSlideChange]);
|
|
21
|
+
const attrs = {
|
|
22
|
+
theme,
|
|
23
|
+
intent,
|
|
24
|
+
"accent-color": accentColor,
|
|
25
|
+
"slides-per-view": slidesPerView,
|
|
26
|
+
gap,
|
|
27
|
+
"start-index": startIndex,
|
|
28
|
+
"autoplay-delay": autoplayDelay,
|
|
29
|
+
snap,
|
|
30
|
+
testid,
|
|
31
|
+
class: className,
|
|
32
|
+
loop: loop ? true : undefined,
|
|
33
|
+
autoplay: autoplay ? true : undefined,
|
|
34
|
+
"drag-free": dragFree ? true : undefined,
|
|
35
|
+
"show-dots": showDots === undefined ? undefined : showDots ? true : "false",
|
|
36
|
+
"show-arrows": showArrows === undefined ? undefined : showArrows ? true : "false"
|
|
37
|
+
};
|
|
38
|
+
return createElement("ark-carousel", { ...attrs, ref }, children);
|
|
39
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { ArkCheckboxStyleOptions } from "@tooark/core";
|
|
2
|
+
import React, { type PropsWithChildren } from "react";
|
|
3
|
+
export type ArkCheckboxProps = PropsWithChildren<ArkCheckboxStyleOptions & {
|
|
4
|
+
disabled?: boolean;
|
|
5
|
+
/** Nome no formulario (submete `value` quando marcado). */
|
|
6
|
+
name?: string;
|
|
7
|
+
/** Valor submetido quando marcado. Padrao: "on". */
|
|
8
|
+
value?: string;
|
|
9
|
+
/** Rotulo proprio (<label for>); sem ele use aria-label ou filhos como rotulo livre. */
|
|
10
|
+
label?: string;
|
|
11
|
+
className?: string;
|
|
12
|
+
onChange?: (event: CustomEvent<{
|
|
13
|
+
checked: boolean;
|
|
14
|
+
}>) => void;
|
|
15
|
+
}>;
|
|
16
|
+
export declare function ArkCheckbox(props: ArkCheckboxProps): React.JSX.Element;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import React, { createElement, useEffect } from "react";
|
|
2
|
+
import { ensureTooarkComponentsRegistered } from "./register.js";
|
|
3
|
+
export function ArkCheckbox(props) {
|
|
4
|
+
const { children, className, checked, indeterminate, disabled, onChange, ...rest } = props;
|
|
5
|
+
const ref = React.useRef(null);
|
|
6
|
+
useEffect(() => {
|
|
7
|
+
ensureTooarkComponentsRegistered();
|
|
8
|
+
}, []);
|
|
9
|
+
useEffect(() => {
|
|
10
|
+
const el = ref.current;
|
|
11
|
+
if (!el || !onChange)
|
|
12
|
+
return;
|
|
13
|
+
const handler = (event) => onChange(event);
|
|
14
|
+
el.addEventListener("change", handler);
|
|
15
|
+
return () => el.removeEventListener("change", handler);
|
|
16
|
+
}, [onChange]);
|
|
17
|
+
const attrs = {
|
|
18
|
+
...rest,
|
|
19
|
+
ref,
|
|
20
|
+
class: className,
|
|
21
|
+
checked: checked ? "" : undefined,
|
|
22
|
+
indeterminate: indeterminate ? "" : undefined,
|
|
23
|
+
disabled: disabled ? "" : undefined
|
|
24
|
+
};
|
|
25
|
+
return createElement("ark-checkbox", attrs, children);
|
|
26
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { ArkClockStyleOptions, ArkDatepickerLang } from "@tooark/core";
|
|
2
|
+
import React from "react";
|
|
3
|
+
export type ArkClockProps = ArkClockStyleOptions & {
|
|
4
|
+
value?: string;
|
|
5
|
+
lang?: ArkDatepickerLang;
|
|
6
|
+
className?: string;
|
|
7
|
+
onChange?: (detail: {
|
|
8
|
+
value: string;
|
|
9
|
+
}) => void;
|
|
10
|
+
};
|
|
11
|
+
export declare function ArkClock(props: ArkClockProps): React.JSX.Element;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import React, { createElement, useEffect } from "react";
|
|
2
|
+
import { ensureTooarkComponentsRegistered } from "./register.js";
|
|
3
|
+
export function ArkClock(props) {
|
|
4
|
+
const { className, seconds, stepMinutes, hoursFormat, onChange, ...rest } = props;
|
|
5
|
+
const ref = React.useRef(null);
|
|
6
|
+
useEffect(() => {
|
|
7
|
+
ensureTooarkComponentsRegistered();
|
|
8
|
+
}, []);
|
|
9
|
+
useEffect(() => {
|
|
10
|
+
const el = ref.current;
|
|
11
|
+
if (!el || !onChange)
|
|
12
|
+
return;
|
|
13
|
+
const handler = (event) => onChange(event.detail);
|
|
14
|
+
el.addEventListener("ark-change", handler);
|
|
15
|
+
return () => el.removeEventListener("ark-change", handler);
|
|
16
|
+
}, [onChange]);
|
|
17
|
+
const attrs = {
|
|
18
|
+
...rest,
|
|
19
|
+
ref,
|
|
20
|
+
class: className,
|
|
21
|
+
seconds: seconds ? "" : undefined,
|
|
22
|
+
"step-minutes": stepMinutes !== undefined ? String(stepMinutes) : undefined,
|
|
23
|
+
"hours-format": hoursFormat
|
|
24
|
+
};
|
|
25
|
+
return createElement("ark-clock", attrs);
|
|
26
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { ArkColorSwatch, ArkColorSwatchesStyleOptions } from "@tooark/core";
|
|
2
|
+
import type React from "react";
|
|
3
|
+
export type ArkColorSwatchesProps = ArkColorSwatchesStyleOptions & {
|
|
4
|
+
/** Cor selecionada (o value da amostra). */
|
|
5
|
+
value?: string;
|
|
6
|
+
/** Amostras { name, value }[]; vai como JSON no atributo. */
|
|
7
|
+
colors?: ArkColorSwatch[];
|
|
8
|
+
/** Nome acessivel do radiogroup. */
|
|
9
|
+
label?: string;
|
|
10
|
+
disabled?: boolean;
|
|
11
|
+
className?: string;
|
|
12
|
+
/** Selecao mudou pelo usuario: detail.value e a cor. */
|
|
13
|
+
onChange?: (event: CustomEvent<{
|
|
14
|
+
value: string;
|
|
15
|
+
}>) => void;
|
|
16
|
+
};
|
|
17
|
+
export declare function ArkColorSwatches(props: ArkColorSwatchesProps): React.JSX.Element;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { createElement, useEffect, useRef } from "react";
|
|
2
|
+
import { ensureTooarkComponentsRegistered } from "./register.js";
|
|
3
|
+
export function ArkColorSwatches(props) {
|
|
4
|
+
const { className, colors, disabled, onChange, ...rest } = props;
|
|
5
|
+
const ref = useRef(null);
|
|
6
|
+
useEffect(() => {
|
|
7
|
+
ensureTooarkComponentsRegistered();
|
|
8
|
+
}, []);
|
|
9
|
+
useEffect(() => {
|
|
10
|
+
const el = ref.current;
|
|
11
|
+
if (!el || !onChange)
|
|
12
|
+
return;
|
|
13
|
+
const handler = (event) => onChange(event);
|
|
14
|
+
el.addEventListener("change", handler);
|
|
15
|
+
return () => el.removeEventListener("change", handler);
|
|
16
|
+
}, [onChange]);
|
|
17
|
+
const attrs = {
|
|
18
|
+
...rest,
|
|
19
|
+
ref,
|
|
20
|
+
class: className,
|
|
21
|
+
colors: colors ? JSON.stringify(colors) : undefined,
|
|
22
|
+
disabled: disabled ? "" : undefined
|
|
23
|
+
};
|
|
24
|
+
return createElement("ark-color-swatches", attrs);
|
|
25
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { ArkCommandItemStyleOptions, ArkCommandPaletteStyleOptions } from "@tooark/core";
|
|
2
|
+
import type React from "react";
|
|
3
|
+
import { type PropsWithChildren } from "react";
|
|
4
|
+
export type ArkCommandPaletteProps = PropsWithChildren<ArkCommandPaletteStyleOptions & {
|
|
5
|
+
/** Aberta; a saida anima antes de sair do top layer. */
|
|
6
|
+
open?: boolean;
|
|
7
|
+
/** Placeholder e nome do campo de busca. Padrao: a string `search` do idioma. */
|
|
8
|
+
placeholder?: string;
|
|
9
|
+
/** Atalho global: "/", "mod+k" (Ctrl ou Cmd), "ctrl+shift+p"... */
|
|
10
|
+
hotkey?: string;
|
|
11
|
+
/** Filtra localmente pelo label dos itens. */
|
|
12
|
+
filter?: boolean;
|
|
13
|
+
/** Debounce de ark-query em ms. Padrao: 150. */
|
|
14
|
+
queryDelay?: number;
|
|
15
|
+
/** Nome acessivel do dialogo. */
|
|
16
|
+
label?: string;
|
|
17
|
+
/** A pagina continua rolando com a paleta aberta. */
|
|
18
|
+
noScrollLock?: boolean;
|
|
19
|
+
"aria-label"?: string;
|
|
20
|
+
className?: string;
|
|
21
|
+
onSelect?: (event: CustomEvent<{
|
|
22
|
+
value: string;
|
|
23
|
+
}>) => void;
|
|
24
|
+
onQuery?: (event: CustomEvent<{
|
|
25
|
+
query: string;
|
|
26
|
+
}>) => void;
|
|
27
|
+
onOpen?: (event: CustomEvent) => void;
|
|
28
|
+
onClose?: (event: CustomEvent) => void;
|
|
29
|
+
}>;
|
|
30
|
+
export declare function ArkCommandPalette(props: ArkCommandPaletteProps): React.JSX.Element;
|
|
31
|
+
export type ArkCommandItemProps = PropsWithChildren<ArkCommandItemStyleOptions & {
|
|
32
|
+
value: string;
|
|
33
|
+
/** Secao em que a paleta lista o item. */
|
|
34
|
+
group?: string;
|
|
35
|
+
/** Texto do filtro e nome da opcao. Padrao: o texto dos filhos sem slot. */
|
|
36
|
+
label?: string;
|
|
37
|
+
disabled?: boolean;
|
|
38
|
+
className?: string;
|
|
39
|
+
}>;
|
|
40
|
+
export declare function ArkCommandItem(props: ArkCommandItemProps): React.JSX.Element;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { createElement, useEffect, useRef } from "react";
|
|
2
|
+
import { ensureTooarkComponentsRegistered } from "./register.js";
|
|
3
|
+
export function ArkCommandPalette(props) {
|
|
4
|
+
const { children, className, open, filter, queryDelay, noScrollLock, localeJson, onSelect, onQuery, onOpen, onClose, ...rest } = props;
|
|
5
|
+
const ref = useRef(null);
|
|
6
|
+
useEffect(() => {
|
|
7
|
+
ensureTooarkComponentsRegistered();
|
|
8
|
+
}, []);
|
|
9
|
+
useEffect(() => {
|
|
10
|
+
const el = ref.current;
|
|
11
|
+
if (!el)
|
|
12
|
+
return;
|
|
13
|
+
const handleSelect = (event) => onSelect?.(event);
|
|
14
|
+
const handleQuery = (event) => onQuery?.(event);
|
|
15
|
+
const handleOpen = (event) => onOpen?.(event);
|
|
16
|
+
const handleClose = (event) => onClose?.(event);
|
|
17
|
+
el.addEventListener("ark-select", handleSelect);
|
|
18
|
+
el.addEventListener("ark-query", handleQuery);
|
|
19
|
+
el.addEventListener("ark-open", handleOpen);
|
|
20
|
+
el.addEventListener("ark-close", handleClose);
|
|
21
|
+
return () => {
|
|
22
|
+
el.removeEventListener("ark-select", handleSelect);
|
|
23
|
+
el.removeEventListener("ark-query", handleQuery);
|
|
24
|
+
el.removeEventListener("ark-open", handleOpen);
|
|
25
|
+
el.removeEventListener("ark-close", handleClose);
|
|
26
|
+
};
|
|
27
|
+
}, [onSelect, onQuery, onOpen, onClose]);
|
|
28
|
+
const attrs = {
|
|
29
|
+
...rest,
|
|
30
|
+
ref,
|
|
31
|
+
class: className,
|
|
32
|
+
open: open ? "" : undefined,
|
|
33
|
+
filter: filter ? "" : undefined,
|
|
34
|
+
"no-scroll-lock": noScrollLock ? "" : undefined,
|
|
35
|
+
"query-delay": queryDelay === undefined ? undefined : String(queryDelay),
|
|
36
|
+
"locale-json": localeJson
|
|
37
|
+
};
|
|
38
|
+
return createElement("ark-command-palette", attrs, children);
|
|
39
|
+
}
|
|
40
|
+
export function ArkCommandItem(props) {
|
|
41
|
+
const { children, className, disabled, ...rest } = props;
|
|
42
|
+
useEffect(() => {
|
|
43
|
+
ensureTooarkComponentsRegistered();
|
|
44
|
+
}, []);
|
|
45
|
+
const attrs = {
|
|
46
|
+
...rest,
|
|
47
|
+
class: className,
|
|
48
|
+
disabled: disabled ? "" : undefined
|
|
49
|
+
};
|
|
50
|
+
return createElement("ark-command-item", attrs, children);
|
|
51
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { ArkCopyButtonStyleOptions } from "@tooark/core";
|
|
2
|
+
import type React from "react";
|
|
3
|
+
import { type PropsWithChildren } from "react";
|
|
4
|
+
export type ArkCopyButtonProps = PropsWithChildren<ArkCopyButtonStyleOptions & {
|
|
5
|
+
/** Texto a copiar. */
|
|
6
|
+
value?: string;
|
|
7
|
+
/** id de um elemento (vira o atributo for): copia o value de inputs/textareas ou o textContent. */
|
|
8
|
+
htmlFor?: string;
|
|
9
|
+
/** Duracao do feedback "copiado" em ms. Padrao: 1500. */
|
|
10
|
+
feedbackMs?: number;
|
|
11
|
+
disabled?: boolean;
|
|
12
|
+
className?: string;
|
|
13
|
+
onCopy?: (event: CustomEvent<{
|
|
14
|
+
value: string;
|
|
15
|
+
}>) => void;
|
|
16
|
+
}>;
|
|
17
|
+
export declare function ArkCopyButton(props: ArkCopyButtonProps): React.JSX.Element;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { createElement, useEffect, useRef } from "react";
|
|
2
|
+
import { ensureTooarkComponentsRegistered } from "./register.js";
|
|
3
|
+
export function ArkCopyButton(props) {
|
|
4
|
+
const { children, className, htmlFor, feedbackMs, textColor, localeJson, loading, iconOnly, fullWidth, disabled, onCopy, ...rest } = props;
|
|
5
|
+
const ref = useRef(null);
|
|
6
|
+
useEffect(() => {
|
|
7
|
+
ensureTooarkComponentsRegistered();
|
|
8
|
+
}, []);
|
|
9
|
+
useEffect(() => {
|
|
10
|
+
const el = ref.current;
|
|
11
|
+
if (!el || !onCopy)
|
|
12
|
+
return;
|
|
13
|
+
const handler = (event) => onCopy(event);
|
|
14
|
+
el.addEventListener("ark-copy", handler);
|
|
15
|
+
return () => el.removeEventListener("ark-copy", handler);
|
|
16
|
+
}, [onCopy]);
|
|
17
|
+
const attrs = {
|
|
18
|
+
...rest,
|
|
19
|
+
ref,
|
|
20
|
+
class: className,
|
|
21
|
+
for: htmlFor,
|
|
22
|
+
"feedback-ms": feedbackMs === undefined ? undefined : String(feedbackMs),
|
|
23
|
+
"text-color": textColor,
|
|
24
|
+
"locale-json": localeJson,
|
|
25
|
+
loading: loading ? "" : undefined,
|
|
26
|
+
disabled: disabled ? "" : undefined,
|
|
27
|
+
"icon-only": iconOnly ? "" : undefined,
|
|
28
|
+
"full-width": fullWidth ? "" : undefined
|
|
29
|
+
};
|
|
30
|
+
return createElement("ark-copy-button", attrs, children);
|
|
31
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { ArkDatepickerLang, ArkDatepickerStyleOptions, ArkLocale } from "@tooark/core";
|
|
2
|
+
import React from "react";
|
|
3
|
+
export type ArkDatepickerProps = ArkDatepickerStyleOptions & {
|
|
4
|
+
lang?: ArkDatepickerLang;
|
|
5
|
+
localeJson?: Partial<ArkLocale>;
|
|
6
|
+
value?: string;
|
|
7
|
+
min?: string;
|
|
8
|
+
max?: string;
|
|
9
|
+
onChange?: (detail: {
|
|
10
|
+
value: string | null;
|
|
11
|
+
date: Date | null;
|
|
12
|
+
}) => void;
|
|
13
|
+
className?: string;
|
|
14
|
+
};
|
|
15
|
+
export declare function ArkDatepicker(props: ArkDatepickerProps): React.JSX.Element;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import React, { useCallback, useEffect } from "react";
|
|
2
|
+
import { ensureTooarkComponentsRegistered } from "./register.js";
|
|
3
|
+
export function ArkDatepicker(props) {
|
|
4
|
+
const { lang, localeJson, theme, intent, accentColor, value, min, max, onChange, className, testid, mode, input, placeholder, name, format, seconds, disabled, events, eventDisplay, stepMinutes, hoursFormat } = props;
|
|
5
|
+
const ref = React.useRef(null);
|
|
6
|
+
useEffect(() => {
|
|
7
|
+
ensureTooarkComponentsRegistered();
|
|
8
|
+
}, []);
|
|
9
|
+
const handleChange = useCallback((e) => {
|
|
10
|
+
if (onChange) {
|
|
11
|
+
const detail = e.detail;
|
|
12
|
+
onChange(detail);
|
|
13
|
+
}
|
|
14
|
+
}, [onChange]);
|
|
15
|
+
useEffect(() => {
|
|
16
|
+
const el = ref.current;
|
|
17
|
+
if (!el)
|
|
18
|
+
return;
|
|
19
|
+
el.addEventListener("ark-change", handleChange);
|
|
20
|
+
return () => el.removeEventListener("ark-change", handleChange);
|
|
21
|
+
}, [handleChange]);
|
|
22
|
+
const attrs = {
|
|
23
|
+
lang,
|
|
24
|
+
theme,
|
|
25
|
+
intent,
|
|
26
|
+
value,
|
|
27
|
+
min,
|
|
28
|
+
max,
|
|
29
|
+
testid,
|
|
30
|
+
mode,
|
|
31
|
+
placeholder,
|
|
32
|
+
name,
|
|
33
|
+
format,
|
|
34
|
+
input: input ? "" : undefined,
|
|
35
|
+
seconds: seconds ? "" : undefined,
|
|
36
|
+
disabled: disabled ? "" : undefined,
|
|
37
|
+
class: className,
|
|
38
|
+
"accent-color": accentColor,
|
|
39
|
+
"locale-json": localeJson ? JSON.stringify(localeJson) : undefined,
|
|
40
|
+
events: events ? JSON.stringify(events) : undefined,
|
|
41
|
+
"event-display": eventDisplay,
|
|
42
|
+
"step-minutes": stepMinutes !== undefined ? String(stepMinutes) : undefined,
|
|
43
|
+
"hours-format": hoursFormat
|
|
44
|
+
};
|
|
45
|
+
return React.createElement("ark-datepicker", { ...attrs, ref });
|
|
46
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { ArkDialogCloseReason, ArkDialogStyleOptions } from "@tooark/core";
|
|
2
|
+
import React, { type PropsWithChildren } from "react";
|
|
3
|
+
export type ArkDialogProps = PropsWithChildren<ArkDialogStyleOptions & {
|
|
4
|
+
/** Aberto; a saida anima antes de sair do top layer. */
|
|
5
|
+
open?: boolean;
|
|
6
|
+
/** Titulo (h2) e nome acessivel. Sem ele, passe aria-label. */
|
|
7
|
+
label?: string;
|
|
8
|
+
/** Esconde o botao de fechar do cabecalho. */
|
|
9
|
+
noCloseButton?: boolean;
|
|
10
|
+
/** Esc e clique no scrim nao fecham. */
|
|
11
|
+
persistent?: boolean;
|
|
12
|
+
/** A pagina continua rolando com o dialogo aberto. */
|
|
13
|
+
noScrollLock?: boolean;
|
|
14
|
+
"aria-label"?: string;
|
|
15
|
+
className?: string;
|
|
16
|
+
onOpen?: (event: CustomEvent) => void;
|
|
17
|
+
/** O fechamento comecou; detail.reason diz por que (escape, backdrop, close-button, api). */
|
|
18
|
+
onClose?: (event: CustomEvent<{
|
|
19
|
+
reason: ArkDialogCloseReason;
|
|
20
|
+
}>) => void;
|
|
21
|
+
}>;
|
|
22
|
+
export declare function ArkDialog(props: ArkDialogProps): React.JSX.Element;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import React, { createElement, useEffect } from "react";
|
|
2
|
+
import { ensureTooarkComponentsRegistered } from "./register.js";
|
|
3
|
+
export function ArkDialog(props) {
|
|
4
|
+
const { children, className, open, width, height, noCloseButton, persistent, noScrollLock, localeJson, onOpen, onClose, ...rest } = props;
|
|
5
|
+
const ref = React.useRef(null);
|
|
6
|
+
useEffect(() => {
|
|
7
|
+
ensureTooarkComponentsRegistered();
|
|
8
|
+
}, []);
|
|
9
|
+
useEffect(() => {
|
|
10
|
+
const el = ref.current;
|
|
11
|
+
if (!el)
|
|
12
|
+
return;
|
|
13
|
+
const handleOpen = (event) => onOpen?.(event);
|
|
14
|
+
const handleClose = (event) => onClose?.(event);
|
|
15
|
+
el.addEventListener("ark-open", handleOpen);
|
|
16
|
+
el.addEventListener("ark-close", handleClose);
|
|
17
|
+
return () => {
|
|
18
|
+
el.removeEventListener("ark-open", handleOpen);
|
|
19
|
+
el.removeEventListener("ark-close", handleClose);
|
|
20
|
+
};
|
|
21
|
+
}, [onOpen, onClose]);
|
|
22
|
+
const attrs = {
|
|
23
|
+
...rest,
|
|
24
|
+
ref,
|
|
25
|
+
class: className,
|
|
26
|
+
open: open ? "" : undefined,
|
|
27
|
+
// Numero vira string aqui; o componente acrescenta px a numeros sem unidade.
|
|
28
|
+
width: width === undefined ? undefined : String(width),
|
|
29
|
+
height: height === undefined ? undefined : String(height),
|
|
30
|
+
"no-close-button": noCloseButton ? "" : undefined,
|
|
31
|
+
persistent: persistent ? "" : undefined,
|
|
32
|
+
"no-scroll-lock": noScrollLock ? "" : undefined,
|
|
33
|
+
"locale-json": localeJson
|
|
34
|
+
};
|
|
35
|
+
return createElement("ark-dialog", attrs, children);
|
|
36
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { ArkDrawerCloseReason, ArkDrawerStyleOptions } from "@tooark/core";
|
|
2
|
+
import type React from "react";
|
|
3
|
+
import { type PropsWithChildren } from "react";
|
|
4
|
+
export type ArkDrawerProps = PropsWithChildren<ArkDrawerStyleOptions & {
|
|
5
|
+
/** Aberta; a saida anima antes de esconder. */
|
|
6
|
+
open?: boolean;
|
|
7
|
+
/** Titulo (h2) e nome acessivel. Sem ele, passe aria-label. */
|
|
8
|
+
label?: string;
|
|
9
|
+
/** Esconde o botao de fechar do cabecalho. */
|
|
10
|
+
noCloseButton?: boolean;
|
|
11
|
+
/** Esc e clique no scrim nao fecham (so no overlay). */
|
|
12
|
+
persistent?: boolean;
|
|
13
|
+
/** A pagina continua rolando com a gaveta aberta em overlay. */
|
|
14
|
+
noScrollLock?: boolean;
|
|
15
|
+
"aria-label"?: string;
|
|
16
|
+
className?: string;
|
|
17
|
+
onOpen?: (event: CustomEvent) => void;
|
|
18
|
+
/** O fechamento comecou; detail.reason diz por que (escape, backdrop, close-button, api). */
|
|
19
|
+
onClose?: (event: CustomEvent<{
|
|
20
|
+
reason: ArkDrawerCloseReason;
|
|
21
|
+
}>) => void;
|
|
22
|
+
}>;
|
|
23
|
+
export declare function ArkDrawer(props: ArkDrawerProps): React.JSX.Element;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { createElement, useEffect, useRef } from "react";
|
|
2
|
+
import { ensureTooarkComponentsRegistered } from "./register.js";
|
|
3
|
+
export function ArkDrawer(props) {
|
|
4
|
+
const { children, className, open, size, noCloseButton, persistent, noScrollLock, localeJson, onOpen, onClose, ...rest } = props;
|
|
5
|
+
const ref = useRef(null);
|
|
6
|
+
useEffect(() => {
|
|
7
|
+
ensureTooarkComponentsRegistered();
|
|
8
|
+
}, []);
|
|
9
|
+
useEffect(() => {
|
|
10
|
+
const el = ref.current;
|
|
11
|
+
if (!el)
|
|
12
|
+
return;
|
|
13
|
+
const handleOpen = (event) => onOpen?.(event);
|
|
14
|
+
const handleClose = (event) => onClose?.(event);
|
|
15
|
+
el.addEventListener("ark-open", handleOpen);
|
|
16
|
+
el.addEventListener("ark-close", handleClose);
|
|
17
|
+
return () => {
|
|
18
|
+
el.removeEventListener("ark-open", handleOpen);
|
|
19
|
+
el.removeEventListener("ark-close", handleClose);
|
|
20
|
+
};
|
|
21
|
+
}, [onOpen, onClose]);
|
|
22
|
+
const attrs = {
|
|
23
|
+
...rest,
|
|
24
|
+
ref,
|
|
25
|
+
class: className,
|
|
26
|
+
open: open ? "" : undefined,
|
|
27
|
+
// Numero vira string aqui; o componente acrescenta px a numeros sem unidade.
|
|
28
|
+
size: size === undefined ? undefined : String(size),
|
|
29
|
+
"no-close-button": noCloseButton ? "" : undefined,
|
|
30
|
+
persistent: persistent ? "" : undefined,
|
|
31
|
+
"no-scroll-lock": noScrollLock ? "" : undefined,
|
|
32
|
+
"locale-json": localeJson
|
|
33
|
+
};
|
|
34
|
+
return createElement("ark-drawer", attrs, children);
|
|
35
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { ArkEmptyStyleOptions } from "@tooark/core";
|
|
2
|
+
import React, { type PropsWithChildren } from "react";
|
|
3
|
+
export type ArkEmptyProps = PropsWithChildren<ArkEmptyStyleOptions & {
|
|
4
|
+
/** Titulo (h3). */
|
|
5
|
+
heading?: string;
|
|
6
|
+
/** Texto abaixo do titulo. */
|
|
7
|
+
description?: string;
|
|
8
|
+
className?: string;
|
|
9
|
+
}>;
|
|
10
|
+
export declare function ArkEmpty(props: ArkEmptyProps): React.JSX.Element;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { createElement, useEffect } from "react";
|
|
2
|
+
import { ensureTooarkComponentsRegistered } from "./register.js";
|
|
3
|
+
export function ArkEmpty(props) {
|
|
4
|
+
const { children, className, ...rest } = props;
|
|
5
|
+
useEffect(() => {
|
|
6
|
+
ensureTooarkComponentsRegistered();
|
|
7
|
+
}, []);
|
|
8
|
+
const attrs = {
|
|
9
|
+
...rest,
|
|
10
|
+
class: className
|
|
11
|
+
};
|
|
12
|
+
return createElement("ark-empty", attrs, children);
|
|
13
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { ArkFileInputStyleOptions } from "@tooark/core";
|
|
2
|
+
import type React from "react";
|
|
3
|
+
export type ArkFileInputProps = ArkFileInputStyleOptions & {
|
|
4
|
+
/** Tipos aceitos pelo seletor nativo (accept). */
|
|
5
|
+
accept?: string;
|
|
6
|
+
/** Aceita varios arquivos; sem ele o drop fica com o primeiro. */
|
|
7
|
+
multiple?: boolean;
|
|
8
|
+
/** Rotulo do campo (label for o input oculto; nomeia o botao junto do texto dele). */
|
|
9
|
+
label?: string;
|
|
10
|
+
helper?: string;
|
|
11
|
+
/** Mensagem de erro; liga aria-invalid e a borda de erro. */
|
|
12
|
+
errorMessage?: string;
|
|
13
|
+
disabled?: boolean;
|
|
14
|
+
required?: boolean;
|
|
15
|
+
/** Nome no formulario (input nativo oculto). */
|
|
16
|
+
name?: string;
|
|
17
|
+
className?: string;
|
|
18
|
+
/** Arquivos escolhidos ou soltos: detail.files e um array de File. */
|
|
19
|
+
onChange?: (event: CustomEvent<{
|
|
20
|
+
files: File[];
|
|
21
|
+
}>) => void;
|
|
22
|
+
};
|
|
23
|
+
export declare function ArkFileInput(props: ArkFileInputProps): React.JSX.Element;
|