pge-front-common 14.0.39 → 14.0.41

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.
@@ -0,0 +1,36 @@
1
+ import React from "react";
2
+ import { SwitchProps } from "./index.types";
3
+ /**
4
+ * Componente Switch suportado por eventos de mouse e teclado.
5
+ *
6
+ * @description
7
+ * Componente que mostra um estado boolean, informando se a opção está ligada/desligada.
8
+ *
9
+ * @param {boolean} props.checked - Mostra se o componente está marcado (`true`) ou desmarcado (`false`).
10
+ * @param {(newValue: boolean) => void} props.onChange
11
+ * - Função callback chamada no evento de clique e que retorna o novo estado (`true` ou `false`).
12
+ * @param {boolean} [props.disabled=false] - Se estiver como `true` o usuário fica impossibilitado de interagir com o elemento.
13
+ * @param {...any} [props.props] - Quaisquer outras props suportadas pelo elemento HTML do tipo input (e.g. `id`, `name`, `aria-*`).
14
+ *
15
+ * @example
16
+ * ```tsx
17
+ * import React, { useState } from "react";
18
+ * import { Switch } from "pge-front-common";
19
+ *
20
+ * export const Example = () => {
21
+ * const [enabled, setEnabled] = useState(false);
22
+ *
23
+ * return (
24
+ * <div>
25
+ * <Switch
26
+ * checked={enabled}
27
+ * onChange={(newState) => setEnabled(newState)}
28
+ * aria-label="Sim ou não"
29
+ * />
30
+ * <span>{enabled ? "Sim" : "Não"}</span>
31
+ * </div>
32
+ * );
33
+ * };
34
+ * ```
35
+ */
36
+ export declare const Switch: ({ checked, onChange, disabled, className, ...props }: SwitchProps) => React.JSX.Element;
@@ -0,0 +1,7 @@
1
+ import { InputHTMLAttributes } from "react";
2
+ export interface SwitchProps extends Omit<InputHTMLAttributes<HTMLInputElement>, "type" | "onChange"> {
3
+ checked: boolean;
4
+ onChange: (newValue: boolean) => void;
5
+ disabled?: boolean;
6
+ className?: string;
7
+ }
@@ -0,0 +1,9 @@
1
+ import { Meta } from "@storybook/react";
2
+ import { Switch } from "./index";
3
+ import type { SwitchProps } from "./index.types";
4
+ declare const _default: Meta<typeof Switch>;
5
+ export default _default;
6
+ export declare const Checked: import("@storybook/core/csf").AnnotatedStoryFn<import("@storybook/react").ReactRenderer, SwitchProps>;
7
+ export declare const DisabledUnchecked: import("@storybook/core/csf").AnnotatedStoryFn<import("@storybook/react").ReactRenderer, SwitchProps>;
8
+ export declare const DisabledChecked: import("@storybook/core/csf").AnnotatedStoryFn<import("@storybook/react").ReactRenderer, SwitchProps>;
9
+ export declare const WithCustomClass: import("@storybook/core/csf").AnnotatedStoryFn<import("@storybook/react").ReactRenderer, SwitchProps>;
package/lib/index.d.ts CHANGED
@@ -472,6 +472,48 @@ declare const TableRow: ({ children, ...props }: TableRowProps) => React__defaul
472
472
  declare const TableCell: ({ children, ...props }: TableCellProps) => React__default.JSX.Element;
473
473
  declare const TableFooter: ({ children, ...props }: TableFooterProps) => React__default.JSX.Element;
474
474
 
475
+ interface SwitchProps extends Omit<InputHTMLAttributes<HTMLInputElement>, "type" | "onChange"> {
476
+ checked: boolean;
477
+ onChange: (newValue: boolean) => void;
478
+ disabled?: boolean;
479
+ className?: string;
480
+ }
481
+
482
+ /**
483
+ * Componente Switch suportado por eventos de mouse e teclado.
484
+ *
485
+ * @description
486
+ * Componente que mostra um estado boolean, informando se a opção está ligada/desligada.
487
+ *
488
+ * @param {boolean} props.checked - Mostra se o componente está marcado (`true`) ou desmarcado (`false`).
489
+ * @param {(newValue: boolean) => void} props.onChange
490
+ * - Função callback chamada no evento de clique e que retorna o novo estado (`true` ou `false`).
491
+ * @param {boolean} [props.disabled=false] - Se estiver como `true` o usuário fica impossibilitado de interagir com o elemento.
492
+ * @param {...any} [props.props] - Quaisquer outras props suportadas pelo elemento HTML do tipo input (e.g. `id`, `name`, `aria-*`).
493
+ *
494
+ * @example
495
+ * ```tsx
496
+ * import React, { useState } from "react";
497
+ * import { Switch } from "pge-front-common";
498
+ *
499
+ * export const Example = () => {
500
+ * const [enabled, setEnabled] = useState(false);
501
+ *
502
+ * return (
503
+ * <div>
504
+ * <Switch
505
+ * checked={enabled}
506
+ * onChange={(newState) => setEnabled(newState)}
507
+ * aria-label="Sim ou não"
508
+ * />
509
+ * <span>{enabled ? "Sim" : "Não"}</span>
510
+ * </div>
511
+ * );
512
+ * };
513
+ * ```
514
+ */
515
+ declare const Switch: ({ checked, onChange, disabled, className, ...props }: SwitchProps) => React__default.JSX.Element;
516
+
475
517
  declare const IconDownload: (props?: SVGProps<SVGSVGElement>) => React__default.JSX.Element;
476
518
 
477
519
  declare const IconVisibility: (props?: SVGProps<SVGSVGElement>) => React__default.JSX.Element;
@@ -558,4 +600,4 @@ declare const IconUsers: ({ className, ...props }: SVGProps<SVGSVGElement>) => R
558
600
 
559
601
  declare function installPrimeReactStyles(): void;
560
602
 
561
- export { Accordion, AccordionItem, type AccordionItemProps, BasicSelect, Blanket, BoxError, BoxSuccess, Button, type ButtonProps, Checkbox, type Column, CommonDotIcon, DateInput, Dropdown, FileUpload, FooterPge as Footer, Header, HeaderPge, IconAdd, IconAddCell, IconArrowExpland, IconArrowRecall, IconCLose, IconCalendar, IconCheck, IconCheckCircle, IconCircleExpland, IconCircleRecall, IconDelete, IconDownload, IconEdit, IconEventAvaliable, IconExclude, IconHourglass, IconInfoRound, IconInvisibility, IconLeftDirection, IconLogout, IconMail, IconNewTab, IconPdf, IconPrint, IconProfile, IconQuestionMark, IconRemove, IconRightDirection, IconSearch, IconSwap, IconTriangleExpand, IconTriangleRecall, IconUpAndDownArror, IconUpload, IconUploadFile, IconUploadFile2, IconUploadV2, IconUsers, IconView, IconVisibility, IconWarning, InformativeBox, type InformativeBoxProps, InputBase, type InputProps, LoadingSpinner, Menu, MenuAction, MenuList, Modal, ModalBody, ModalFooter, ModalHeader, ModalUI, Option, type OptionsProps$2 as OptionsProps, PaginationTable, Pagination as PaginationV2, PasswordInput, PgeButton, RadioGroupBase, type RadioGroupBaseProps, SelectDefault, type SelectDefaultProps, SelectMult, type SelectMultProps, SkeletonLoader, Table, TableBody, TableCell, TableComponent, type TableComponentProps, TableFooter, TableHeader, TableRow, TextareaBase, type TextareaBaseProps, Title, Tooltip, TooltipWithPortal, installPrimeReactStyles };
603
+ export { Accordion, AccordionItem, type AccordionItemProps, BasicSelect, Blanket, BoxError, BoxSuccess, Button, type ButtonProps, Checkbox, type Column, CommonDotIcon, DateInput, Dropdown, FileUpload, FooterPge as Footer, Header, HeaderPge, IconAdd, IconAddCell, IconArrowExpland, IconArrowRecall, IconCLose, IconCalendar, IconCheck, IconCheckCircle, IconCircleExpland, IconCircleRecall, IconDelete, IconDownload, IconEdit, IconEventAvaliable, IconExclude, IconHourglass, IconInfoRound, IconInvisibility, IconLeftDirection, IconLogout, IconMail, IconNewTab, IconPdf, IconPrint, IconProfile, IconQuestionMark, IconRemove, IconRightDirection, IconSearch, IconSwap, IconTriangleExpand, IconTriangleRecall, IconUpAndDownArror, IconUpload, IconUploadFile, IconUploadFile2, IconUploadV2, IconUsers, IconView, IconVisibility, IconWarning, InformativeBox, type InformativeBoxProps, InputBase, type InputProps, LoadingSpinner, Menu, MenuAction, MenuList, Modal, ModalBody, ModalFooter, ModalHeader, ModalUI, Option, type OptionsProps$2 as OptionsProps, PaginationTable, Pagination as PaginationV2, PasswordInput, PgeButton, RadioGroupBase, type RadioGroupBaseProps, SelectDefault, type SelectDefaultProps, SelectMult, type SelectMultProps, SkeletonLoader, Switch, Table, TableBody, TableCell, TableComponent, type TableComponentProps, TableFooter, TableHeader, TableRow, TextareaBase, type TextareaBaseProps, Title, Tooltip, TooltipWithPortal, installPrimeReactStyles };