@utk09/finra-ui 0.0.3 → 0.0.5

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,108 @@
1
+ import { HTMLAttributes, ReactNode, Ref } from 'react';
2
+ export interface ComboBoxOption<T = string> {
3
+ value: T;
4
+ label: string;
5
+ group?: string;
6
+ disabled?: boolean;
7
+ favourite?: boolean;
8
+ }
9
+ export interface ComboBoxRenderOptionState {
10
+ isSelected: boolean;
11
+ isHighlighted: boolean;
12
+ isDisabled: boolean;
13
+ isFavourite: boolean;
14
+ }
15
+ export interface ComboBoxGroup<T = string> {
16
+ label: string;
17
+ options: ComboBoxOption<T>[];
18
+ }
19
+ /**
20
+ * CSS class overrides that the styled layer injects into the unstyled base.
21
+ * Every key is optional — when absent, no className is applied.
22
+ */
23
+ export interface ComboBoxClassNames {
24
+ root?: string;
25
+ wrapper?: string;
26
+ multiValueContainer?: string;
27
+ pill?: string;
28
+ pillText?: string;
29
+ pillRemove?: string;
30
+ singleValue?: string;
31
+ input?: string;
32
+ inputHidden?: string;
33
+ indicator?: string;
34
+ indicatorOpen?: string;
35
+ listbox?: string;
36
+ header?: string;
37
+ footer?: string;
38
+ options?: string;
39
+ option?: string;
40
+ optionHighlighted?: string;
41
+ optionSelected?: string;
42
+ optionDisabled?: string;
43
+ optionCreate?: string;
44
+ optionLabel?: string;
45
+ checkIcon?: string;
46
+ group?: string;
47
+ groupLabel?: string;
48
+ loading?: string;
49
+ spinner?: string;
50
+ empty?: string;
51
+ }
52
+ export interface ComboBoxBaseProps<T = string> extends Omit<HTMLAttributes<HTMLDivElement>, "onChange" | "defaultValue"> {
53
+ /** Available options. */
54
+ options: ComboBoxOption<T>[];
55
+ /** Selected value(s). Single value or array for multiple. */
56
+ value?: T | T[] | null;
57
+ /** Called when selection changes. */
58
+ onChange?: (value: T | T[] | null) => void;
59
+ /** Enable multi-select mode. */
60
+ multiple?: boolean;
61
+ /** Controlled input text. */
62
+ inputValue?: string;
63
+ /** Called when input text changes. */
64
+ onInputChange?: (value: string) => void;
65
+ /** Custom filter function. Return true to keep option. */
66
+ filterFn?: (option: ComboBoxOption<T>, inputValue: string) => boolean;
67
+ /** Show loading indicator. */
68
+ loading?: boolean;
69
+ /** Called when input changes to trigger async loading. */
70
+ onLoadOptions?: (inputValue: string) => void;
71
+ /** Allow creating new options from input. */
72
+ creatable?: boolean;
73
+ /** Called when user creates a new option. */
74
+ onCreateOption?: (inputValue: string) => void;
75
+ /** Custom label for the create option. */
76
+ formatCreateLabel?: (inputValue: string) => string;
77
+ /** Content rendered above the options list. */
78
+ header?: ReactNode;
79
+ /** Content rendered below the options list. */
80
+ footer?: ReactNode;
81
+ placeholder?: string;
82
+ disabled?: boolean;
83
+ /** Message shown when no options match. */
84
+ noOptionsMessage?: string | ReactNode;
85
+ /** Custom option renderer. */
86
+ renderOption?: (option: ComboBoxOption<T>, state: ComboBoxRenderOptionState) => ReactNode;
87
+ /** Custom selected value renderer (single mode). */
88
+ renderValue?: (option: ComboBoxOption<T>) => ReactNode;
89
+ /** Render the "selected check" icon beside a selected option. Return null to suppress. */
90
+ renderCheckIcon?: () => ReactNode;
91
+ /** Render the chevron/indicator icon. */
92
+ renderIndicator?: (isOpen: boolean) => ReactNode;
93
+ /** Render the pill remove button icon. */
94
+ renderPillRemoveIcon?: () => ReactNode;
95
+ /** Render the loading spinner content. */
96
+ renderLoading?: () => ReactNode;
97
+ /** Controlled open state. */
98
+ open?: boolean;
99
+ /** Called when open state changes. */
100
+ onOpenChange?: (open: boolean) => void;
101
+ /** CSS class overrides injected by the styled layer. */
102
+ classNames?: ComboBoxClassNames;
103
+ /** Root element data attributes. */
104
+ dataAttributes?: Record<string, string>;
105
+ }
106
+ export declare const ComboBoxBase: <T = string>(props: ComboBoxBaseProps<T> & {
107
+ ref?: Ref<HTMLInputElement>;
108
+ }) => React.ReactElement | null;
@@ -0,0 +1,14 @@
1
+ import { HTMLAttributes, ReactNode } from 'react';
2
+ export interface FileDropZoneBaseProps extends Omit<HTMLAttributes<HTMLDivElement>, "onChange"> {
3
+ /** Called with selected files. */
4
+ onChange?: (files: File[]) => void;
5
+ /** Accepted file types (e.g. ".pdf,.csv" or "image/*"). */
6
+ accept?: string;
7
+ /** Allow multiple file selection. */
8
+ multiple?: boolean;
9
+ /** Disable the component. */
10
+ disabled?: boolean;
11
+ /** Custom content inside the drop zone. */
12
+ children?: ReactNode;
13
+ }
14
+ export declare const FileDropZoneBase: import('react').ForwardRefExoticComponent<FileDropZoneBaseProps & import('react').RefAttributes<HTMLInputElement>>;
@@ -0,0 +1,14 @@
1
+ import { ReactNode, HTMLAttributes } from 'react';
2
+ export type ValidationStatus = "error" | "warning" | "success";
3
+ export interface FormFieldBaseProps extends HTMLAttributes<HTMLDivElement> {
4
+ label: string;
5
+ helperText?: string;
6
+ errorMessage?: string;
7
+ validationStatus?: ValidationStatus;
8
+ required?: boolean;
9
+ disabled?: boolean;
10
+ /** Explicit id for the input element. Auto-generated if omitted. */
11
+ htmlFor?: string;
12
+ children: ReactNode;
13
+ }
14
+ export declare const FormFieldBase: import('react').ForwardRefExoticComponent<FormFieldBaseProps & import('react').RefAttributes<HTMLDivElement>>;
@@ -0,0 +1,16 @@
1
+ import { HTMLAttributes } from 'react';
2
+ export interface PillInputBaseProps extends Omit<HTMLAttributes<HTMLDivElement>, "onChange"> {
3
+ /** Current list of pills (controlled). */
4
+ values?: string[];
5
+ /** Called when the pill list changes. */
6
+ onChange?: (values: string[]) => void;
7
+ /** Placeholder shown when no pills and input is empty. */
8
+ placeholder?: string;
9
+ /** Disable the entire component. */
10
+ disabled?: boolean;
11
+ /** Maximum number of pills allowed. */
12
+ maxPills?: number;
13
+ /** Characters that trigger pill creation (default: Enter). */
14
+ delimiters?: string[];
15
+ }
16
+ export declare const PillInputBase: import('react').ForwardRefExoticComponent<PillInputBaseProps & import('react').RefAttributes<HTMLInputElement>>;
@@ -16,3 +16,11 @@ export { RadioButtonBase } from './unstyled/RadioButton/RadioButton';
16
16
  export type { RadioButtonBaseProps } from './unstyled/RadioButton/RadioButton';
17
17
  export { SliderBase } from './unstyled/Slider/Slider';
18
18
  export type { SliderBaseProps } from './unstyled/Slider/Slider';
19
+ export { FormFieldBase } from './unstyled/FormField/FormField';
20
+ export type { FormFieldBaseProps } from './unstyled/FormField/FormField';
21
+ export { PillInputBase } from './unstyled/PillInput/PillInput';
22
+ export type { PillInputBaseProps } from './unstyled/PillInput/PillInput';
23
+ export { FileDropZoneBase } from './unstyled/FileDropZone/FileDropZone';
24
+ export type { FileDropZoneBaseProps } from './unstyled/FileDropZone/FileDropZone';
25
+ export { ComboBoxBase } from './unstyled/ComboBox/ComboBox';
26
+ export type { ComboBoxBaseProps } from './unstyled/ComboBox/ComboBox';
package/dist/unstyled.js CHANGED
@@ -1,28 +1,219 @@
1
- import { b as s } from "./Slider-BXQjDfhb.js";
2
- import { B as d, C, I as x, R as I, a as N, S as b } from "./Slider-BXQjDfhb.js";
3
- import { jsx as o } from "react/jsx-runtime";
4
- import { forwardRef as r } from "react";
5
- const n = r(
6
- ({ asChild: a = !1, ...e }, t) => /* @__PURE__ */ o(a ? s : "input", { ref: t, ...e })
1
+ import { c as w, m as x } from "./ComboBox-CbLG-Ss1.js";
2
+ import { B as L, C as M, b as Q, I as U, R as W, a as X, S as Y } from "./ComboBox-CbLG-Ss1.js";
3
+ import { jsx as c, jsxs as k, Fragment as K } from "react/jsx-runtime";
4
+ import { forwardRef as I, useId as O, Children as S, isValidElement as V, cloneElement as j, useState as b, useRef as F, useCallback as l } from "react";
5
+ const P = I(
6
+ ({ asChild: a = !1, ...o }, s) => /* @__PURE__ */ c(a ? w : "input", { ref: s, ...o })
7
7
  );
8
- n.displayName = "InputBase";
9
- const m = r(
10
- ({ asChild: a = !1, ...e }, t) => /* @__PURE__ */ o(a ? s : "textarea", { ref: t, ...e })
8
+ P.displayName = "InputBase";
9
+ const $ = I(
10
+ ({ asChild: a = !1, ...o }, s) => /* @__PURE__ */ c(a ? w : "textarea", { ref: s, ...o })
11
11
  );
12
- m.displayName = "TextareaBase";
13
- const B = r(
14
- ({ asChild: a = !1, ...e }, t) => /* @__PURE__ */ o(a ? s : "input", { ref: t, inputMode: "decimal", ...e })
12
+ $.displayName = "TextareaBase";
13
+ const Z = I(
14
+ ({ asChild: a = !1, ...o }, s) => /* @__PURE__ */ c(a ? w : "input", { ref: s, inputMode: "decimal", ...o })
15
15
  );
16
- B.displayName = "NumberInputBase";
16
+ Z.displayName = "NumberInputBase";
17
+ const A = I(
18
+ ({
19
+ label: a,
20
+ helperText: o,
21
+ errorMessage: s,
22
+ validationStatus: e,
23
+ required: d,
24
+ disabled: D,
25
+ htmlFor: m,
26
+ children: g,
27
+ ...h
28
+ }, v) => {
29
+ const i = O(), u = m ?? i, f = `${u}-helper`, t = `${u}-error`, p = e === "error" && s, y = [p ? t : void 0, o ? f : void 0].filter(Boolean).join(" ") || void 0, B = S.map(g, (n) => V(n) ? j(n, {
30
+ id: u,
31
+ "aria-describedby": y,
32
+ "aria-invalid": e === "error" ? !0 : void 0,
33
+ disabled: D || void 0
34
+ }) : n);
35
+ return /* @__PURE__ */ k("div", { ref: v, ...h, children: [
36
+ /* @__PURE__ */ k("label", { htmlFor: u, children: [
37
+ a,
38
+ d ? " *" : null
39
+ ] }),
40
+ B,
41
+ p ? /* @__PURE__ */ c("p", { id: t, role: "alert", children: s }) : null,
42
+ o ? /* @__PURE__ */ c("p", { id: f, children: o }) : null
43
+ ] });
44
+ }
45
+ );
46
+ A.displayName = "FormFieldBase";
47
+ const T = I(
48
+ ({
49
+ values: a,
50
+ onChange: o,
51
+ placeholder: s,
52
+ disabled: e,
53
+ maxPills: d,
54
+ delimiters: D = [],
55
+ ...m
56
+ }, g) => {
57
+ const [h, v] = b([]), [i, u] = b(""), f = F(null), t = a ?? h, p = l(
58
+ (r) => {
59
+ a || v(r), o?.(r);
60
+ },
61
+ [a, o]
62
+ ), y = l(
63
+ (r) => {
64
+ const C = r.trim();
65
+ C && (t.includes(C) || d != null && t.length >= d || (p([...t, C]), u("")));
66
+ },
67
+ [t, d, p]
68
+ ), B = l(
69
+ (r) => {
70
+ p(t.filter((C, E) => E !== r)), f.current?.focus();
71
+ },
72
+ [t, p]
73
+ ), n = l(
74
+ (r) => {
75
+ if (r.key === "Enter") {
76
+ r.preventDefault(), y(i);
77
+ return;
78
+ }
79
+ if (r.key === "Backspace" && i === "" && t.length > 0) {
80
+ B(t.length - 1);
81
+ return;
82
+ }
83
+ D.includes(r.key) && (r.preventDefault(), y(i));
84
+ },
85
+ [i, t, D, y, B]
86
+ ), N = l(() => {
87
+ e || f.current?.focus();
88
+ }, [e]), R = l(
89
+ (r) => {
90
+ !e && (r.key === "Enter" || r.key === " ") && f.current?.focus();
91
+ },
92
+ [e]
93
+ );
94
+ return /* @__PURE__ */ k(
95
+ "div",
96
+ {
97
+ role: "toolbar",
98
+ onClick: N,
99
+ onKeyDown: R,
100
+ ...m,
101
+ children: [
102
+ t.map((r) => /* @__PURE__ */ k("span", { children: [
103
+ r,
104
+ e ? null : /* @__PURE__ */ c(
105
+ "button",
106
+ {
107
+ type: "button",
108
+ onClick: (C) => {
109
+ C.stopPropagation(), B(t.indexOf(r));
110
+ },
111
+ "aria-label": `Remove ${r}`,
112
+ tabIndex: -1,
113
+ children: "×"
114
+ }
115
+ )
116
+ ] }, r)),
117
+ /* @__PURE__ */ c(
118
+ "input",
119
+ {
120
+ ref: x(g, f),
121
+ type: "text",
122
+ value: i,
123
+ onChange: (r) => u(r.target.value),
124
+ onKeyDown: n,
125
+ placeholder: t.length === 0 ? s : void 0,
126
+ disabled: e,
127
+ "aria-label": m["aria-label"],
128
+ "aria-labelledby": m["aria-labelledby"]
129
+ }
130
+ )
131
+ ]
132
+ }
133
+ );
134
+ }
135
+ );
136
+ T.displayName = "PillInputBase";
137
+ const _ = I(
138
+ ({ onChange: a, accept: o, multiple: s, disabled: e, children: d, ...D }, m) => {
139
+ const [g, h] = b(!1), v = F(null), i = l(
140
+ (n) => {
141
+ !n || n.length === 0 || a?.(Array.from(n));
142
+ },
143
+ [a]
144
+ ), u = l(
145
+ (n) => {
146
+ n.preventDefault(), e || h(!0);
147
+ },
148
+ [e]
149
+ ), f = l((n) => {
150
+ n.preventDefault(), h(!1);
151
+ }, []), t = l(
152
+ (n) => {
153
+ n.preventDefault(), h(!1), e || i(n.dataTransfer.files);
154
+ },
155
+ [e, i]
156
+ ), p = l(
157
+ (n) => {
158
+ i(n.target.files), n.target.value = "";
159
+ },
160
+ [i]
161
+ ), y = l(() => {
162
+ e || v.current?.click();
163
+ }, [e]), B = l(
164
+ (n) => {
165
+ !e && (n.key === "Enter" || n.key === " ") && (n.preventDefault(), v.current?.click());
166
+ },
167
+ [e]
168
+ );
169
+ return /* @__PURE__ */ k(K, { children: [
170
+ /* @__PURE__ */ c(
171
+ "input",
172
+ {
173
+ ref: x(m, v),
174
+ type: "file",
175
+ style: { display: "none" },
176
+ accept: o,
177
+ multiple: s,
178
+ disabled: e,
179
+ onChange: p,
180
+ tabIndex: -1,
181
+ "aria-hidden": "true"
182
+ }
183
+ ),
184
+ /* @__PURE__ */ c(
185
+ "div",
186
+ {
187
+ role: "button",
188
+ tabIndex: e ? -1 : 0,
189
+ "aria-disabled": e || void 0,
190
+ "data-drag-over": g || void 0,
191
+ onClick: y,
192
+ onKeyDown: B,
193
+ onDragOver: u,
194
+ onDragLeave: f,
195
+ onDrop: t,
196
+ ...D,
197
+ children: d ?? /* @__PURE__ */ c("span", { children: "Drop files here or click to browse" })
198
+ }
199
+ )
200
+ ] });
201
+ }
202
+ );
203
+ _.displayName = "FileDropZoneBase";
17
204
  export {
18
- d as ButtonBase,
19
- C as CheckboxBase,
20
- x as IconButtonBase,
21
- n as InputBase,
22
- B as NumberInputBase,
23
- I as RadioButtonBase,
24
- N as SliderBase,
25
- b as SwitchBase,
26
- m as TextareaBase
205
+ L as ButtonBase,
206
+ M as CheckboxBase,
207
+ Q as ComboBoxBase,
208
+ _ as FileDropZoneBase,
209
+ A as FormFieldBase,
210
+ U as IconButtonBase,
211
+ P as InputBase,
212
+ Z as NumberInputBase,
213
+ T as PillInputBase,
214
+ W as RadioButtonBase,
215
+ X as SliderBase,
216
+ Y as SwitchBase,
217
+ $ as TextareaBase
27
218
  };
28
219
  //# sourceMappingURL=unstyled.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"unstyled.js","sources":["../src/unstyled/Input/Input.tsx","../src/unstyled/Textarea/Textarea.tsx","../src/unstyled/NumberInput/NumberInput.tsx"],"sourcesContent":["import { forwardRef, type InputHTMLAttributes } from \"react\";\nimport { Slot } from \"../Slot\";\n\nexport interface InputBaseProps extends InputHTMLAttributes<HTMLInputElement> {\n asChild?: boolean;\n}\n\nexport const InputBase = forwardRef<HTMLInputElement, InputBaseProps>(\n ({ asChild = false, ...props }, ref) => {\n const Comp = asChild ? Slot : \"input\";\n\n return <Comp ref={ref} {...props} />;\n },\n);\n\nInputBase.displayName = \"InputBase\";\n","import { forwardRef, type TextareaHTMLAttributes } from \"react\";\nimport { Slot } from \"../Slot\";\n\nexport interface TextareaBaseProps extends TextareaHTMLAttributes<HTMLTextAreaElement> {\n asChild?: boolean;\n}\n\nexport const TextareaBase = forwardRef<HTMLTextAreaElement, TextareaBaseProps>(\n ({ asChild = false, ...props }, ref) => {\n const Comp = asChild ? Slot : \"textarea\";\n\n return <Comp ref={ref} {...props} />;\n },\n);\n\nTextareaBase.displayName = \"TextareaBase\";\n","import { forwardRef, type InputHTMLAttributes } from \"react\";\nimport { Slot } from \"../Slot\";\n\nexport interface NumberInputBaseProps extends Omit<InputHTMLAttributes<HTMLInputElement>, \"type\"> {\n asChild?: boolean;\n}\n\nexport const NumberInputBase = forwardRef<HTMLInputElement, NumberInputBaseProps>(\n ({ asChild = false, ...props }, ref) => {\n const Comp = asChild ? Slot : \"input\";\n\n return <Comp ref={ref} inputMode=\"decimal\" {...props} />;\n },\n);\n\nNumberInputBase.displayName = \"NumberInputBase\";\n"],"names":["InputBase","forwardRef","asChild","props","ref","jsx","Slot","TextareaBase","NumberInputBase"],"mappings":";;;;AAOO,MAAMA,IAAYC;AAAA,EACvB,CAAC,EAAE,SAAAC,IAAU,IAAO,GAAGC,EAAA,GAASC,MAGvB,gBAAAC,EAFMH,IAAUI,IAAO,SAEtB,EAAK,KAAAF,GAAW,GAAGD,EAAA,CAAO;AAEtC;AAEAH,EAAU,cAAc;ACRjB,MAAMO,IAAeN;AAAA,EAC1B,CAAC,EAAE,SAAAC,IAAU,IAAO,GAAGC,EAAA,GAASC,MAGvB,gBAAAC,EAFMH,IAAUI,IAAO,YAEtB,EAAK,KAAAF,GAAW,GAAGD,EAAA,CAAO;AAEtC;AAEAI,EAAa,cAAc;ACRpB,MAAMC,IAAkBP;AAAA,EAC7B,CAAC,EAAE,SAAAC,IAAU,IAAO,GAAGC,EAAA,GAASC,wBACjBF,IAAUI,IAAO,SAEtB,EAAK,KAAAF,GAAU,WAAU,WAAW,GAAGD,GAAO;AAE1D;AAEAK,EAAgB,cAAc;"}
1
+ {"version":3,"file":"unstyled.js","sources":["../src/unstyled/Input/Input.tsx","../src/unstyled/Textarea/Textarea.tsx","../src/unstyled/NumberInput/NumberInput.tsx","../src/unstyled/FormField/FormField.tsx","../src/unstyled/PillInput/PillInput.tsx","../src/unstyled/FileDropZone/FileDropZone.tsx"],"sourcesContent":["import { forwardRef, type InputHTMLAttributes } from \"react\";\nimport { Slot } from \"../Slot\";\n\nexport interface InputBaseProps extends InputHTMLAttributes<HTMLInputElement> {\n asChild?: boolean;\n}\n\nexport const InputBase = forwardRef<HTMLInputElement, InputBaseProps>(\n ({ asChild = false, ...props }, ref) => {\n const Comp = asChild ? Slot : \"input\";\n\n return <Comp ref={ref} {...props} />;\n },\n);\n\nInputBase.displayName = \"InputBase\";\n","import { forwardRef, type TextareaHTMLAttributes } from \"react\";\nimport { Slot } from \"../Slot\";\n\nexport interface TextareaBaseProps extends TextareaHTMLAttributes<HTMLTextAreaElement> {\n asChild?: boolean;\n}\n\nexport const TextareaBase = forwardRef<HTMLTextAreaElement, TextareaBaseProps>(\n ({ asChild = false, ...props }, ref) => {\n const Comp = asChild ? Slot : \"textarea\";\n\n return <Comp ref={ref} {...props} />;\n },\n);\n\nTextareaBase.displayName = \"TextareaBase\";\n","import { forwardRef, type InputHTMLAttributes } from \"react\";\nimport { Slot } from \"../Slot\";\n\nexport interface NumberInputBaseProps extends Omit<InputHTMLAttributes<HTMLInputElement>, \"type\"> {\n asChild?: boolean;\n}\n\nexport const NumberInputBase = forwardRef<HTMLInputElement, NumberInputBaseProps>(\n ({ asChild = false, ...props }, ref) => {\n const Comp = asChild ? Slot : \"input\";\n\n return <Comp ref={ref} inputMode=\"decimal\" {...props} />;\n },\n);\n\nNumberInputBase.displayName = \"NumberInputBase\";\n","import {\n forwardRef,\n useId,\n Children,\n isValidElement,\n cloneElement,\n type ReactNode,\n type HTMLAttributes,\n} from \"react\";\n\nexport type ValidationStatus = \"error\" | \"warning\" | \"success\";\n\nexport interface FormFieldBaseProps extends HTMLAttributes<HTMLDivElement> {\n label: string;\n helperText?: string;\n errorMessage?: string;\n validationStatus?: ValidationStatus;\n required?: boolean;\n disabled?: boolean;\n /** Explicit id for the input element. Auto-generated if omitted. */\n htmlFor?: string;\n children: ReactNode;\n}\n\nexport const FormFieldBase = forwardRef<HTMLDivElement, FormFieldBaseProps>(\n (\n {\n label,\n helperText,\n errorMessage,\n validationStatus,\n required,\n disabled,\n htmlFor,\n children,\n ...props\n },\n ref,\n ) => {\n const autoId = useId();\n const fieldId = htmlFor ?? autoId;\n const helperId = `${fieldId}-helper`;\n const errorId = `${fieldId}-error`;\n\n const showError = validationStatus === \"error\" && errorMessage;\n\n const describedBy =\n [showError ? errorId : undefined, helperText ? helperId : undefined]\n .filter(Boolean)\n .join(\" \") || undefined;\n\n const enhancedChildren = Children.map(children, (child) => {\n if (!isValidElement(child)) return child;\n return cloneElement(child as React.ReactElement<Record<string, unknown>>, {\n id: fieldId,\n \"aria-describedby\": describedBy,\n \"aria-invalid\": validationStatus === \"error\" ? true : undefined,\n disabled: disabled || undefined,\n });\n });\n\n return (\n <div ref={ref} {...props}>\n <label htmlFor={fieldId}>\n {label}\n {required ? \" *\" : null}\n </label>\n\n {enhancedChildren}\n\n {showError ? (\n <p id={errorId} role=\"alert\">\n {errorMessage}\n </p>\n ) : null}\n\n {helperText ? <p id={helperId}>{helperText}</p> : null}\n </div>\n );\n },\n);\n\nFormFieldBase.displayName = \"FormFieldBase\";\n","import {\n forwardRef,\n useState,\n useRef,\n useCallback,\n type KeyboardEvent,\n type HTMLAttributes,\n} from \"react\";\nimport { mergeRefs } from \"../../utils/mergeRefs\";\n\nexport interface PillInputBaseProps extends Omit<HTMLAttributes<HTMLDivElement>, \"onChange\"> {\n /** Current list of pills (controlled). */\n values?: string[];\n /** Called when the pill list changes. */\n onChange?: (values: string[]) => void;\n /** Placeholder shown when no pills and input is empty. */\n placeholder?: string;\n /** Disable the entire component. */\n disabled?: boolean;\n /** Maximum number of pills allowed. */\n maxPills?: number;\n /** Characters that trigger pill creation (default: Enter). */\n delimiters?: string[];\n}\n\nexport const PillInputBase = forwardRef<HTMLInputElement, PillInputBaseProps>(\n (\n {\n values: controlledValues,\n onChange,\n placeholder,\n disabled,\n maxPills,\n delimiters = [],\n ...props\n },\n forwardedRef,\n ) => {\n const [internalValues, setInternalValues] = useState<string[]>([]);\n const [inputValue, setInputValue] = useState(\"\");\n const internalRef = useRef<HTMLInputElement>(null);\n\n const values = controlledValues ?? internalValues;\n\n const updateValues = useCallback(\n (next: string[]) => {\n if (!controlledValues) {\n setInternalValues(next);\n }\n onChange?.(next);\n },\n [controlledValues, onChange],\n );\n\n const addPill = useCallback(\n (text: string) => {\n const trimmed = text.trim();\n if (!trimmed) return;\n if (values.includes(trimmed)) return;\n if (maxPills != null && values.length >= maxPills) return;\n updateValues([...values, trimmed]);\n setInputValue(\"\");\n },\n [values, maxPills, updateValues],\n );\n\n const removePill = useCallback(\n (index: number) => {\n updateValues(values.filter((_, i) => i !== index));\n internalRef.current?.focus();\n },\n [values, updateValues],\n );\n\n const handleKeyDown = useCallback(\n (e: KeyboardEvent<HTMLInputElement>) => {\n if (e.key === \"Enter\") {\n e.preventDefault();\n addPill(inputValue);\n return;\n }\n if (e.key === \"Backspace\" && inputValue === \"\" && values.length > 0) {\n removePill(values.length - 1);\n return;\n }\n if (delimiters.includes(e.key)) {\n e.preventDefault();\n addPill(inputValue);\n }\n },\n [inputValue, values, delimiters, addPill, removePill],\n );\n\n const handleContainerClick = useCallback(() => {\n if (!disabled) {\n internalRef.current?.focus();\n }\n }, [disabled]);\n\n const handleContainerKeyDown = useCallback(\n (e: React.KeyboardEvent<HTMLDivElement>) => {\n if (!disabled && (e.key === \"Enter\" || e.key === \" \")) {\n internalRef.current?.focus();\n }\n },\n [disabled],\n );\n\n return (\n <div\n role=\"toolbar\"\n onClick={handleContainerClick}\n onKeyDown={handleContainerKeyDown}\n {...props}>\n {values.map((pill) => (\n <span key={pill}>\n {pill}\n {!disabled ? (\n <button\n type=\"button\"\n onClick={(e) => {\n e.stopPropagation();\n removePill(values.indexOf(pill));\n }}\n aria-label={`Remove ${pill}`}\n tabIndex={-1}>\n ×\n </button>\n ) : null}\n </span>\n ))}\n <input\n ref={mergeRefs(forwardedRef, internalRef)}\n type=\"text\"\n value={inputValue}\n onChange={(e) => setInputValue(e.target.value)}\n onKeyDown={handleKeyDown}\n placeholder={values.length === 0 ? placeholder : undefined}\n disabled={disabled}\n aria-label={props[\"aria-label\"]}\n aria-labelledby={props[\"aria-labelledby\"]}\n />\n </div>\n );\n },\n);\n\nPillInputBase.displayName = \"PillInputBase\";\n","import {\n forwardRef,\n useState,\n useRef,\n useCallback,\n type DragEvent,\n type ChangeEvent,\n type HTMLAttributes,\n type ReactNode,\n} from \"react\";\nimport { mergeRefs } from \"../../utils/mergeRefs\";\n\nexport interface FileDropZoneBaseProps extends Omit<HTMLAttributes<HTMLDivElement>, \"onChange\"> {\n /** Called with selected files. */\n onChange?: (files: File[]) => void;\n /** Accepted file types (e.g. \".pdf,.csv\" or \"image/*\"). */\n accept?: string;\n /** Allow multiple file selection. */\n multiple?: boolean;\n /** Disable the component. */\n disabled?: boolean;\n /** Custom content inside the drop zone. */\n children?: ReactNode;\n}\n\nexport const FileDropZoneBase = forwardRef<HTMLInputElement, FileDropZoneBaseProps>(\n ({ onChange, accept, multiple, disabled, children, ...props }, forwardedRef) => {\n const [isDragOver, setIsDragOver] = useState(false);\n const internalRef = useRef<HTMLInputElement>(null);\n\n const handleFiles = useCallback(\n (fileList: FileList | null) => {\n if (!fileList || fileList.length === 0) return;\n onChange?.(Array.from(fileList));\n },\n [onChange],\n );\n\n const handleDragOver = useCallback(\n (e: DragEvent<HTMLDivElement>) => {\n e.preventDefault();\n if (!disabled) {\n setIsDragOver(true);\n }\n },\n [disabled],\n );\n\n const handleDragLeave = useCallback((e: DragEvent<HTMLDivElement>) => {\n e.preventDefault();\n setIsDragOver(false);\n }, []);\n\n const handleDrop = useCallback(\n (e: DragEvent<HTMLDivElement>) => {\n e.preventDefault();\n setIsDragOver(false);\n if (!disabled) {\n handleFiles(e.dataTransfer.files);\n }\n },\n [disabled, handleFiles],\n );\n\n const handleInputChange = useCallback(\n (e: ChangeEvent<HTMLInputElement>) => {\n handleFiles(e.target.files);\n // Reset so the same file can be selected again\n e.target.value = \"\";\n },\n [handleFiles],\n );\n\n const handleClick = useCallback(() => {\n if (!disabled) {\n internalRef.current?.click();\n }\n }, [disabled]);\n\n const handleKeyDown = useCallback(\n (e: React.KeyboardEvent<HTMLDivElement>) => {\n if (!disabled && (e.key === \"Enter\" || e.key === \" \")) {\n e.preventDefault();\n internalRef.current?.click();\n }\n },\n [disabled],\n );\n\n return (\n <>\n <input\n ref={mergeRefs(forwardedRef, internalRef)}\n type=\"file\"\n style={{ display: \"none\" }}\n accept={accept}\n multiple={multiple}\n disabled={disabled}\n onChange={handleInputChange}\n tabIndex={-1}\n aria-hidden=\"true\"\n />\n <div\n role=\"button\"\n tabIndex={disabled ? -1 : 0}\n aria-disabled={disabled || undefined}\n data-drag-over={isDragOver || undefined}\n onClick={handleClick}\n onKeyDown={handleKeyDown}\n onDragOver={handleDragOver}\n onDragLeave={handleDragLeave}\n onDrop={handleDrop}\n {...props}>\n {children ?? <span>Drop files here or click to browse</span>}\n </div>\n </>\n );\n },\n);\n\nFileDropZoneBase.displayName = \"FileDropZoneBase\";\n"],"names":["InputBase","forwardRef","asChild","props","ref","jsx","Slot","TextareaBase","NumberInputBase","FormFieldBase","label","helperText","errorMessage","validationStatus","required","disabled","htmlFor","children","autoId","useId","fieldId","helperId","errorId","showError","describedBy","enhancedChildren","Children","child","isValidElement","cloneElement","jsxs","PillInputBase","controlledValues","onChange","placeholder","maxPills","delimiters","forwardedRef","internalValues","setInternalValues","useState","inputValue","setInputValue","internalRef","useRef","values","updateValues","useCallback","next","addPill","text","trimmed","removePill","index","_","i","handleKeyDown","e","handleContainerClick","handleContainerKeyDown","pill","mergeRefs","FileDropZoneBase","accept","multiple","isDragOver","setIsDragOver","handleFiles","fileList","handleDragOver","handleDragLeave","handleDrop","handleInputChange","handleClick","Fragment"],"mappings":";;;;AAOO,MAAMA,IAAYC;AAAA,EACvB,CAAC,EAAE,SAAAC,IAAU,IAAO,GAAGC,EAAA,GAASC,MAGvB,gBAAAC,EAFMH,IAAUI,IAAO,SAEtB,EAAK,KAAAF,GAAW,GAAGD,EAAA,CAAO;AAEtC;AAEAH,EAAU,cAAc;ACRjB,MAAMO,IAAeN;AAAA,EAC1B,CAAC,EAAE,SAAAC,IAAU,IAAO,GAAGC,EAAA,GAASC,MAGvB,gBAAAC,EAFMH,IAAUI,IAAO,YAEtB,EAAK,KAAAF,GAAW,GAAGD,EAAA,CAAO;AAEtC;AAEAI,EAAa,cAAc;ACRpB,MAAMC,IAAkBP;AAAA,EAC7B,CAAC,EAAE,SAAAC,IAAU,IAAO,GAAGC,EAAA,GAASC,wBACjBF,IAAUI,IAAO,SAEtB,EAAK,KAAAF,GAAU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MAA2C;AAC1C,QAAI,CAAC1C,MAAa0C,EAAE,QAAQ,WAAWA,EAAE,QAAQ,SAC/CA,EAAE,eAAA,GACFd,EAAY,SAAS,MAAA;AAAA,MAEzB;AAAA,MACA,CAAC5B,CAAQ;AAAA,IAAA;AAGX,WACE,gBAAAe,EAAA4C,GAAA,EACE,UAAA;AAAA,MAAA,gBAAArE;AAAA,QAAC;AAAA,QAAA;AAAA,UACC,KAAKwD,EAAUxB,GAAcM,CAAW;AAAA,UACxC,MAAK;AAAA,UACL,OAAO,EAAE,SAAS,OAAA;AAAA,UAClB,QAAAoB;AAAA,UACA,UAAAC;AAAA,UACA,UAAAjD;AAAA,UACA,UAAUyD;AAAA,UACV,UAAU;AAAA,UACV,eAAY;AAAA,QAAA;AAAA,MAAA;AAAA,MAEd,gBAAAnE;AAAA,QAAC;AAAA,QAAA;AAAA,UACC,MAAK;AAAA,UACL,UAAUU,IAAW,KAAK;AAAA,UAC1B,iBAAeA,KAAY;AAAA,UAC3B,kBAAgBkD,KAAc;AAAA,UAC9B,SAASQ;AAAA,UACT,WAAWjB;AAAA,UACX,YAAYa;AAAA,UACZ,aAAaC;AAAA,UACb,QAAQC;AAAA,UACP,GAAGpE;AAAA,UACH,UAAAc,KAAY,gBAAAZ,EAAC,QAAA,EAAK,UAAA,qCAAA,CAAkC;AAAA,QAAA;AAAA,MAAA;AAAA,IACvD,GACF;AAAA,EAEJ;AACF;AAEAyD,EAAiB,cAAc;"}
@@ -0,0 +1,2 @@
1
+ import { Ref } from 'react';
2
+ export declare function mergeRefs<T>(...refs: (Ref<T> | undefined)[]): (value: T | null) => void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@utk09/finra-ui",
3
- "version": "0.0.3",
3
+ "version": "0.0.5",
4
4
  "description": "Component library for web applications. Core UI components and styles.",
5
5
  "displayName": "Finra UI",
6
6
  "type": "module",
@@ -1,73 +0,0 @@
1
- import { jsx as c, jsxs as u } from "react/jsx-runtime";
2
- import { forwardRef as f, isValidElement as p, cloneElement as l, useRef as y, useEffect as m } from "react";
3
- function B(...e) {
4
- return (o) => {
5
- for (const t of e)
6
- typeof t == "function" ? t(o) : t && typeof t == "object" && (t.current = o);
7
- };
8
- }
9
- function d(e, o) {
10
- const t = { ...e, ...o };
11
- for (const n of Object.keys(e)) {
12
- if (n === "children" || n === "ref") continue;
13
- const s = e[n], r = o[n];
14
- typeof s == "function" && typeof r == "function" && (t[n] = (...a) => {
15
- r(...a), s(...a);
16
- }), n === "className" && typeof s == "string" && typeof r == "string" && (t[n] = `${s} ${r}`.trim()), n === "style" && typeof s == "object" && typeof r == "object" && (t[n] = { ...s, ...r });
17
- }
18
- return t;
19
- }
20
- const i = f(
21
- ({ children: e, ...o }, t) => {
22
- if (!p(e))
23
- return null;
24
- const n = e.props, s = e.ref;
25
- return l(e, {
26
- ...d(o, n),
27
- ref: B(t, s)
28
- });
29
- }
30
- );
31
- i.displayName = "Slot";
32
- const b = f(
33
- ({ asChild: e = !1, ...o }, t) => /* @__PURE__ */ c(e ? i : "button", { ref: t, ...o })
34
- );
35
- b.displayName = "ButtonBase";
36
- const R = f(
37
- ({ asChild: e = !1, icon: o, children: t, ...n }, s) => /* @__PURE__ */ u(e ? i : "button", { ref: s, ...n, children: [
38
- o,
39
- t
40
- ] })
41
- );
42
- R.displayName = "IconButtonBase";
43
- function h(...e) {
44
- return (o) => {
45
- for (const t of e)
46
- typeof t == "function" ? t(o) : t && typeof t == "object" && (t.current = o);
47
- };
48
- }
49
- const N = f(
50
- ({ indeterminate: e, ...o }, t) => {
51
- const n = y(null);
52
- return m(() => {
53
- n.current && (n.current.indeterminate = e ?? !1);
54
- }, [e]), /* @__PURE__ */ c("input", { ref: h(t, n), type: "checkbox", ...o });
55
- }
56
- );
57
- N.displayName = "CheckboxBase";
58
- const j = f((e, o) => /* @__PURE__ */ c("input", { ref: o, type: "checkbox", role: "switch", ...e }));
59
- j.displayName = "SwitchBase";
60
- const x = f((e, o) => /* @__PURE__ */ c("input", { ref: o, type: "radio", ...e }));
61
- x.displayName = "RadioButtonBase";
62
- const C = f((e, o) => /* @__PURE__ */ c("input", { ref: o, type: "range", ...e }));
63
- C.displayName = "SliderBase";
64
- export {
65
- b as B,
66
- N as C,
67
- R as I,
68
- x as R,
69
- j as S,
70
- C as a,
71
- i as b
72
- };
73
- //# sourceMappingURL=Slider-BXQjDfhb.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Slider-BXQjDfhb.js","sources":["../src/unstyled/Slot.tsx","../src/unstyled/Button/Button.tsx","../src/unstyled/IconButton/IconButton.tsx","../src/unstyled/Checkbox/Checkbox.tsx","../src/unstyled/Switch/Switch.tsx","../src/unstyled/RadioButton/RadioButton.tsx","../src/unstyled/Slider/Slider.tsx"],"sourcesContent":["import {\n forwardRef,\n isValidElement,\n cloneElement,\n type ReactNode,\n type HTMLAttributes,\n type Ref,\n} from \"react\";\n\nfunction mergeRefs<T>(...refs: (Ref<T> | undefined)[]): Ref<T> {\n return (value: T | null) => {\n for (const ref of refs) {\n if (typeof ref === \"function\") {\n ref(value);\n } else if (ref && typeof ref === \"object\") {\n (ref as React.RefObject<T | null>).current = value;\n }\n }\n };\n}\n\nfunction mergeProps(\n slotProps: Record<string, unknown>,\n childProps: Record<string, unknown>,\n): Record<string, unknown> {\n const merged: Record<string, unknown> = { ...slotProps, ...childProps };\n\n for (const key of Object.keys(slotProps)) {\n if (key === \"children\" || key === \"ref\") continue;\n\n const slotVal = slotProps[key];\n const childVal = childProps[key];\n\n // Merge event handlers\n if (typeof slotVal === \"function\" && typeof childVal === \"function\") {\n merged[key] = (...args: unknown[]) => {\n childVal(...args);\n slotVal(...args);\n };\n }\n\n // Merge className\n if (key === \"className\" && typeof slotVal === \"string\" && typeof childVal === \"string\") {\n merged[key] = `${slotVal} ${childVal}`.trim();\n }\n\n // Merge style\n if (key === \"style\" && typeof slotVal === \"object\" && typeof childVal === \"object\") {\n merged[key] = { ...(slotVal as object), ...(childVal as object) };\n }\n }\n\n return merged;\n}\n\nexport interface SlotProps extends HTMLAttributes<HTMLElement> {\n children?: ReactNode;\n}\n\nexport const Slot = forwardRef<HTMLElement, SlotProps>(\n ({ children, ...slotProps }, forwardedRef) => {\n if (!isValidElement(children)) {\n return null;\n }\n\n const childProps = children.props as Record<string, unknown>;\n const childRef = (children as unknown as { ref?: Ref<HTMLElement> }).ref;\n\n return cloneElement(children, {\n ...mergeProps(slotProps, childProps),\n ref: mergeRefs(forwardedRef, childRef),\n } as Record<string, unknown>);\n },\n);\n\nSlot.displayName = \"Slot\";\n","import { forwardRef, type ButtonHTMLAttributes } from \"react\";\nimport { Slot } from \"../Slot\";\n\nexport interface ButtonBaseProps extends ButtonHTMLAttributes<HTMLButtonElement> {\n asChild?: boolean;\n}\n\nexport const ButtonBase = forwardRef<HTMLButtonElement, ButtonBaseProps>(\n ({ asChild = false, ...props }, ref) => {\n const Comp = asChild ? Slot : \"button\";\n\n return <Comp ref={ref} {...props} />;\n },\n);\n\nButtonBase.displayName = \"ButtonBase\";\n","import { forwardRef, type ButtonHTMLAttributes, type ReactNode } from \"react\";\nimport { Slot } from \"../Slot\";\n\nexport interface IconButtonBaseProps extends ButtonHTMLAttributes<HTMLButtonElement> {\n asChild?: boolean;\n icon: ReactNode;\n \"aria-label\": string;\n}\n\nexport const IconButtonBase = forwardRef<HTMLButtonElement, IconButtonBaseProps>(\n ({ asChild = false, icon, children, ...props }, ref) => {\n const Comp = asChild ? Slot : \"button\";\n\n return (\n <Comp ref={ref} {...props}>\n {icon}\n {children}\n </Comp>\n );\n },\n);\n\nIconButtonBase.displayName = \"IconButtonBase\";\n","import { forwardRef, useEffect, useRef, type InputHTMLAttributes, type Ref } from \"react\";\n\nexport interface CheckboxBaseProps extends Omit<InputHTMLAttributes<HTMLInputElement>, \"type\"> {\n indeterminate?: boolean;\n}\n\nfunction mergeRefs<T>(...refs: (Ref<T> | undefined)[]): (value: T | null) => void {\n return (value: T | null) => {\n for (const ref of refs) {\n if (typeof ref === \"function\") {\n ref(value);\n } else if (ref && typeof ref === \"object\") {\n (ref as React.RefObject<T | null>).current = value;\n }\n }\n };\n}\n\nexport const CheckboxBase = forwardRef<HTMLInputElement, CheckboxBaseProps>(\n ({ indeterminate, ...props }, forwardedRef) => {\n const internalRef = useRef<HTMLInputElement>(null);\n\n useEffect(() => {\n if (internalRef.current) {\n internalRef.current.indeterminate = indeterminate ?? false;\n }\n }, [indeterminate]);\n\n return <input ref={mergeRefs(forwardedRef, internalRef)} type=\"checkbox\" {...props} />;\n },\n);\n\nCheckboxBase.displayName = \"CheckboxBase\";\n","import { forwardRef, type InputHTMLAttributes } from \"react\";\n\nexport interface SwitchBaseProps extends Omit<\n InputHTMLAttributes<HTMLInputElement>,\n \"type\" | \"role\"\n> {}\n\nexport const SwitchBase = forwardRef<HTMLInputElement, SwitchBaseProps>((props, ref) => {\n return <input ref={ref} type=\"checkbox\" role=\"switch\" {...props} />;\n});\n\nSwitchBase.displayName = \"SwitchBase\";\n","import { forwardRef, type InputHTMLAttributes } from \"react\";\n\nexport interface RadioButtonBaseProps extends Omit<InputHTMLAttributes<HTMLInputElement>, \"type\"> {}\n\nexport const RadioButtonBase = forwardRef<HTMLInputElement, RadioButtonBaseProps>((props, ref) => {\n return <input ref={ref} type=\"radio\" {...props} />;\n});\n\nRadioButtonBase.displayName = \"RadioButtonBase\";\n","import { forwardRef, type InputHTMLAttributes } from \"react\";\n\nexport interface SliderBaseProps extends Omit<InputHTMLAttributes<HTMLInputElement>, \"type\"> {}\n\nexport const SliderBase = forwardRef<HTMLInputElement, SliderBaseProps>((props, ref) => {\n return <input ref={ref} type=\"range\" {...props} />;\n});\n\nSliderBase.displayName = \"SliderBase\";\n"],"names":["mergeRefs","refs","value","ref","mergeProps","slotProps","childProps","merged","key","slotVal","childVal","args","Slot","forwardRef","children","forwardedRef","isValidElement","childRef","cloneElement","ButtonBase","asChild","props","jsx","IconButtonBase","icon","jsxs","CheckboxBase","indeterminate","internalRef","useRef","useEffect","Sw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