@grasp-labs/ds-react-components 1.3.0 → 1.4.1

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.
@@ -1,6 +1,7 @@
1
- import { ButtonHTMLAttributes } from 'react';
1
+ import { default as React, ButtonHTMLAttributes } from 'react';
2
2
  import { Variant } from './BaseButton.styles';
3
3
  export type BaseButtonProps = Omit<ButtonHTMLAttributes<HTMLButtonElement>, "prefix" | "suffix"> & {
4
+ ref?: React.Ref<HTMLButtonElement>;
4
5
  variant?: Variant;
5
6
  };
6
7
  /**
@@ -10,4 +11,7 @@ export type BaseButtonProps = Omit<ButtonHTMLAttributes<HTMLButtonElement>, "pre
10
11
  * @param props - The props for the BaseButton component.
11
12
  * @returns The rendered button element.
12
13
  */
13
- export declare const BaseButton: ({ variant, className, children, ...props }: BaseButtonProps) => import("react/jsx-runtime").JSX.Element;
14
+ export declare const BaseButton: {
15
+ ({ variant, className, children, ref, ...props }: BaseButtonProps): import("react/jsx-runtime").JSX.Element;
16
+ displayName: string;
17
+ };
@@ -7,11 +7,4 @@ export type ButtonProps = BaseButtonProps & {
7
7
  suffix?: ReactNode;
8
8
  isLoading?: boolean;
9
9
  };
10
- /**
11
- * A button component with size variants and optional prefix/suffix content.
12
- * Extends BaseButton with additional size and content functionality.
13
- *
14
- * @param props - The props for the Button component.
15
- * @returns The rendered button with optional prefix/suffix content.
16
- */
17
10
  export declare const Button: ({ size, className, children, prefix, suffix, isLoading, disabled, variant, "aria-busy": ariaBusy, ...props }: ButtonProps) => import("react/jsx-runtime").JSX.Element;
@@ -1,15 +1,4 @@
1
- export declare const DatePickerTextBox: import('react').ForwardRefExoticComponent<Omit<Omit<import('react').InputHTMLAttributes<HTMLInputElement>, "prefix" | "suffix" | "children"> & {
2
- prefix?: import('react').ReactNode;
3
- suffix?: import('react').ReactNode;
4
- error?: boolean;
5
- disabled?: boolean;
6
- id?: string;
7
- name?: string;
8
- className?: string;
9
- rootClassName?: string;
10
- placeholder?: string;
11
- ref?: React.Ref<HTMLInputElement>;
12
- acceptOnly?: import('../baseTextBox').AcceptOnlyPattern | ((value: string) => string);
13
- } & {
1
+ import { BaseTextBoxProps } from '../baseTextBox';
2
+ export declare const DatePickerTextBox: ({ onCalendarToggle, ref, ...props }: BaseTextBoxProps & {
14
3
  onCalendarToggle: () => void;
15
- }, "ref"> & import('react').RefAttributes<HTMLInputElement>>;
4
+ }) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,12 @@
1
+ import { FieldType, ObjectBuilderTexts } from './types';
2
+ type AddBuilderButtonProps = {
3
+ label: string;
4
+ onClick: () => void;
5
+ disabled?: boolean;
6
+ disabledMessage?: string;
7
+ addType: FieldType;
8
+ onAddTypeChange: (newType: FieldType) => void;
9
+ texts: ObjectBuilderTexts;
10
+ };
11
+ export declare function AddBuilderButton({ label, onClick, disabled, disabledMessage, addType, onAddTypeChange, texts, }: AddBuilderButtonProps): import("react/jsx-runtime").JSX.Element;
12
+ export {};
@@ -0,0 +1,9 @@
1
+ import { ObjectBuilderTexts } from './types';
2
+ export type ArrayBuilderProps = {
3
+ value: unknown[];
4
+ onChange: (value: unknown[]) => void;
5
+ disabled?: boolean;
6
+ className?: string;
7
+ texts: ObjectBuilderTexts;
8
+ };
9
+ export declare function ArrayBuilder({ value, onChange, disabled, className, texts, }: ArrayBuilderProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,29 @@
1
+ import { ExpandState, FieldType, ObjectBuilderTexts, ValueOf } from './types';
2
+ type KeyInputConfig = {
3
+ value: string;
4
+ onChange: (value: string) => void;
5
+ error?: boolean;
6
+ errorMessage?: string;
7
+ placeholder?: string;
8
+ };
9
+ type BuilderItemRowBaseProps = {
10
+ disabled?: boolean;
11
+ keyInput?: KeyInputConfig;
12
+ indexLabel?: number;
13
+ onDelete: () => void;
14
+ expandState?: ExpandState;
15
+ onToggleExpand?: () => void;
16
+ className?: string;
17
+ texts: ObjectBuilderTexts;
18
+ };
19
+ type BuilderItemRowDiscriminatedProps = {
20
+ [T in FieldType]: {
21
+ type: T;
22
+ value: ValueOf<T>;
23
+ onTypeChange: (newType: FieldType) => void;
24
+ onValueChange: (newValue: ValueOf<T>) => void;
25
+ };
26
+ }[FieldType];
27
+ export type BuilderItemRowProps = BuilderItemRowBaseProps & BuilderItemRowDiscriminatedProps;
28
+ export declare function BuilderItemRow({ type, value, disabled, keyInput, indexLabel, onTypeChange, onValueChange, onDelete, expandState, onToggleExpand, className, texts, }: BuilderItemRowProps): import("react/jsx-runtime").JSX.Element;
29
+ export {};
@@ -0,0 +1,2 @@
1
+ import { ObjectBuilderProps } from './types';
2
+ export declare function ObjectBuilder({ value, onChange, disabled, className, texts: textOverrides, }: ObjectBuilderProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,9 @@
1
+ import { FieldType, ObjectBuilderTexts } from './types';
2
+ type TypePanelContentProps = {
3
+ currentType: FieldType;
4
+ onSelect: (type: FieldType) => void;
5
+ disabled?: boolean;
6
+ texts: ObjectBuilderTexts;
7
+ };
8
+ export declare function TypePanelContent({ currentType, onSelect, disabled, texts, }: TypePanelContentProps): import("react/jsx-runtime").JSX.Element;
9
+ export {};
@@ -0,0 +1,17 @@
1
+ import { FieldData, FieldEntry, FieldType, FieldValue, ObjectBuilderTexts, ObjectValue } from './types';
2
+ export declare function getTypeLabel(type: FieldType, texts: ObjectBuilderTexts): string;
3
+ export type BuilderItem = {
4
+ id: string;
5
+ } & FieldData;
6
+ export declare function updateItemType<T extends BuilderItem>(items: T[], id: string, newType: FieldType): T[];
7
+ export declare function updateItemValue<T extends BuilderItem>(items: T[], id: string, newValue: FieldValue): T[];
8
+ export declare function removeFromCollapsedSet(prev: Set<string>, id: string): Set<string>;
9
+ export declare function toggleInSet(prev: Set<string>, id: string): Set<string>;
10
+ export type KeyValidationResult = {
11
+ errorsById: Record<string, string>;
12
+ hasEmptyKeys: boolean;
13
+ hasDuplicateKeys: boolean;
14
+ };
15
+ export declare function validateFieldKeys(fields: FieldEntry[], keyRequiredError: string, duplicateKeyError: string): KeyValidationResult;
16
+ export declare function buildDraftFields(value: ObjectValue, previousFields?: FieldEntry[]): FieldEntry[];
17
+ export declare function buildArrayItems(value: unknown[], previousItems?: BuilderItem[]): BuilderItem[];
@@ -0,0 +1,2 @@
1
+ export { ObjectBuilder } from './ObjectBuilder';
2
+ export type { FieldType, ObjectBuilderProps, ObjectBuilderTexts, ObjectValue, } from './types';
@@ -0,0 +1,71 @@
1
+ export type ObjectValue = Record<string, unknown>;
2
+ export type FieldData = {
3
+ type: "string";
4
+ value: string;
5
+ } | {
6
+ type: "number";
7
+ value: number;
8
+ } | {
9
+ type: "boolean";
10
+ value: boolean;
11
+ } | {
12
+ type: "null";
13
+ value: null;
14
+ } | {
15
+ type: "object";
16
+ value: ObjectValue;
17
+ } | {
18
+ type: "array";
19
+ value: unknown[];
20
+ } | {
21
+ type: "date";
22
+ value: Date | null;
23
+ };
24
+ export type FieldType = FieldData["type"];
25
+ export declare const FIELD_TYPES: FieldType[];
26
+ export type ExpandState = "static" | "expanded" | "collapsed";
27
+ export type FieldValue = FieldData["value"];
28
+ export type ValueOf<T extends FieldType> = Extract<FieldData, {
29
+ type: T;
30
+ }>["value"];
31
+ export type FieldEntry = {
32
+ id: string;
33
+ key: string;
34
+ } & FieldData;
35
+ export declare const isObjectValue: (value: unknown) => value is ObjectValue;
36
+ export declare function inferFieldType(value: unknown): FieldType;
37
+ export declare function getTypedFieldValue(value: unknown): FieldData;
38
+ export declare function getDefaultTypedFieldValue(type: FieldType): FieldData;
39
+ export declare function objectToFieldEntries(obj: ObjectValue): FieldEntry[];
40
+ export declare function fieldEntriesToObject(entries: FieldEntry[]): ObjectValue;
41
+ export type ObjectBuilderTexts = {
42
+ addFieldLabel: string;
43
+ emptyMessage: string;
44
+ keyRequiredError: string;
45
+ duplicateKeyError: string;
46
+ emptyKeyDisabledMessage: string;
47
+ duplicateKeyDisabledMessage: string;
48
+ keyPlaceholder: string;
49
+ stringPlaceholder: string;
50
+ booleanYes: string;
51
+ booleanNo: string;
52
+ nullDisplay: string;
53
+ expandAriaLabel: string;
54
+ collapseAriaLabel: string;
55
+ changeTypeAriaLabel: string;
56
+ deleteAriaLabel: string;
57
+ typeText: string;
58
+ typeNumber: string;
59
+ typeBoolean: string;
60
+ typeDate: string;
61
+ typeList: string;
62
+ typeObject: string;
63
+ typeNull: string;
64
+ };
65
+ export type ObjectBuilderProps = {
66
+ value: ObjectValue;
67
+ onChange: (value: ObjectValue) => void;
68
+ disabled?: boolean;
69
+ className?: string;
70
+ texts?: Partial<ObjectBuilderTexts>;
71
+ };
@@ -14,9 +14,14 @@ export type TabProps = {
14
14
  className?: string;
15
15
  /** Icon to display before the text */
16
16
  icon?: ReactNode;
17
+ /** Ref for the tab button element */
18
+ ref?: React.Ref<HTMLButtonElement>;
17
19
  };
18
20
  /**
19
21
  * A single tab component that can be used within a TabPanel.
20
22
  * Contains both the tab button and the content to display when active.
21
23
  */
22
- export declare const Tab: import('react').ForwardRefExoticComponent<TabProps & import('react').RefAttributes<HTMLButtonElement>>;
24
+ export declare const Tab: {
25
+ ({ label, name, children: _children, isActive, onClick, className, icon, ref, }: TabProps): import("react/jsx-runtime").JSX.Element;
26
+ displayName: string;
27
+ };
@@ -2,5 +2,5 @@ import { JSX } from 'react';
2
2
  import { TableProps } from './types';
3
3
  declare function Table<T extends {
4
4
  id?: string | number;
5
- }>({ data, columns, className, scrollWrapperClassName, getCoreRowModel, enableRowSelection, enableMultiRowSelection, enablePagination, paginationProps, ...options }: TableProps<T>): JSX.Element;
5
+ }>({ data, columns, rootClassName, className, scrollWrapperClassName, getCoreRowModel, enableRowSelection, enableMultiRowSelection, enablePagination, paginationProps, ...options }: TableProps<T>): JSX.Element;
6
6
  export default Table;
@@ -31,6 +31,7 @@ import { TableOptions } from '@tanstack/react-table';
31
31
  * />
32
32
  */
33
33
  export type TableProps<T> = Omit<TableOptions<T>, "getCoreRowModel" | "getSortedRowModel" | "getPaginationRowModel" | "manualPagination" | "pageCount" | "autoResetPageIndex"> & {
34
+ rootClassName?: string;
34
35
  className?: string;
35
36
  scrollWrapperClassName?: string;
36
37
  getCoreRowModel?: TableOptions<T>["getCoreRowModel"];